Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

typica.cpp 539KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 619 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. #include <QtSvg>
  16. /*:5*//*6:*/
  17. #line 635 "./typica.w"
  18. #include "helpmenu.h"
  19. /*:6*//*291:*/
  20. #line 6608 "./typica.w"
  21. #include "units.h"
  22. #line 1 "./measurement.w"
  23. /*:291*//*561:*/
  24. #line 197 "./webview.w"
  25. #include "webview.h"
  26. /*:561*//*574:*/
  27. #line 375 "./webview.w"
  28. #include "webelement.h"
  29. #line 12584 "./typica.w"
  30. /*:574*//*685:*/
  31. #line 489 "./daterangeselector.w"
  32. #include "daterangeselector.h"
  33. #line 14310 "./typica.w"
  34. /*:685*//*793:*/
  35. #line 16881 "./typica.w"
  36. #include "qextserialport.h"
  37. #include "qextserialenumerator.h"
  38. /*:793*//*976:*/
  39. #line 124 "./dataqsdk.w"
  40. #ifdef Q_OS_WIN32
  41. #include <windef.h>
  42. #else
  43. #define PASCAL
  44. #endif
  45. /*:976*//*1000:*/
  46. #line 862 "./dataqsdk.w"
  47. #include <limits>
  48. /*:1000*//*1015:*/
  49. #line 62 "./scales.w"
  50. #include "draglabel.h"
  51. /*:1015*//*1030:*/
  52. #line 361 "./scales.w"
  53. #include "scale.h"
  54. /*:1030*/
  55. #line 525 "./typica.w"
  56. /*23:*/
  57. #line 997 "./typica.w"
  58. class ScriptQMainWindow:public QMainWindow
  59. {
  60. Q_OBJECT
  61. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  62. public:
  63. ScriptQMainWindow();
  64. QString closePrompt();
  65. public slots:
  66. void show();
  67. void saveSizeAndPosition(const QString&key);
  68. void restoreSizeAndPosition(const QString&key);
  69. void displayStatus(const QString&message= QString());
  70. void setClosePrompt(QString prompt);
  71. protected:
  72. void closeEvent(QCloseEvent*event);
  73. void showEvent(QShowEvent*event);
  74. signals:
  75. void aboutToClose(void);
  76. private:
  77. QString cprompt;
  78. };
  79. /*:23*//*169:*/
  80. #line 3921 "./typica.w"
  81. class SqlQueryConnection:public QSqlQuery
  82. {
  83. public:
  84. SqlQueryConnection(const QString&query= QString());
  85. ~SqlQueryConnection();
  86. QSqlQuery*operator->()const;
  87. private:
  88. QString connection;
  89. QSqlQuery*q;
  90. };
  91. /*:169*//*240:*/
  92. #line 5810 "./typica.w"
  93. class NumericDelegate:public QItemDelegate
  94. {
  95. Q_OBJECT
  96. public:
  97. NumericDelegate(QObject*parent= NULL);
  98. QWidget*createEditor(QWidget*parent,
  99. const QStyleOptionViewItem&option,
  100. const QModelIndex&index)const;
  101. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  102. void setModelData(QWidget*editor,QAbstractItemModel*model,
  103. const QModelIndex&index)const;
  104. void updateEditorGeometry(QWidget*editor,
  105. const QStyleOptionViewItem&option,
  106. const QModelIndex&index)const;
  107. };
  108. /*:240*//*246:*/
  109. #line 5903 "./typica.w"
  110. class ScriptValidator:public QValidator
  111. {
  112. Q_OBJECT
  113. public:
  114. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  115. void fixup(QString&input)const;
  116. QValidator::State validate(QString&input,int&pos)const;
  117. private:
  118. QValidator*v;
  119. };
  120. /*:246*//*287:*/
  121. #line 438 "./units.w"
  122. Q_DECLARE_METATYPE(Units::Unit)
  123. /*:287*//*292:*/
  124. #line 19 "./measurement.w"
  125. class Measurement:public QVariantMap
  126. {
  127. public:
  128. Measurement(double temperature= 0,QTime time= QTime(),
  129. Units::Unit sc= Units::Fahrenheit);
  130. Measurement(double temperature);
  131. double temperature()const;
  132. QTime time()const;
  133. void setTemperature(double temperature);
  134. void setTime(QTime time);
  135. void setUnit(Units::Unit scale);
  136. Units::Unit scale()const;
  137. Measurement toFahrenheit();
  138. Measurement toCelsius();
  139. Measurement toKelvin();
  140. Measurement toRankine();
  141. };
  142. /*:292*//*296:*/
  143. #line 128 "./measurement.w"
  144. Q_DECLARE_METATYPE(Measurement)
  145. /*:296*//*303:*/
  146. #line 6672 "./typica.w"
  147. class Channel;
  148. class DAQImplementation;
  149. class DAQ:public QObject
  150. {
  151. Q_OBJECT
  152. Q_ENUMS(ThermocoupleType)
  153. DAQImplementation*imp;
  154. private slots:
  155. void threadFinished();
  156. public:
  157. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  158. ~DAQ();
  159. Channel*newChannel(int units,int thermocouple);
  160. Q_INVOKABLE void setClockRate(double Hz);
  161. Q_INVOKABLE void start();
  162. Q_INVOKABLE void stop();
  163. enum ThermocoupleType
  164. {
  165. TypeJ= 10072,
  166. TypeK= 10073,
  167. TypeN= 10077,
  168. TypeR= 10082,
  169. TypeS= 10085,
  170. TypeT= 10086,
  171. TypeB= 10047,
  172. TypeE= 10055
  173. };
  174. };
  175. /*:303*//*304:*/
  176. #line 6710 "./typica.w"
  177. class DAQImplementation:public QThread
  178. {
  179. Q_OBJECT
  180. public:
  181. DAQImplementation(const QString&driverinfo);
  182. ~DAQImplementation();
  183. void run();
  184. void measure();
  185. /*305:*/
  186. #line 6730 "./typica.w"
  187. typedef int(*daqfp)(...);
  188. daqfp read;
  189. daqfp errorInfo;
  190. daqfp startTask;
  191. daqfp createTask;
  192. daqfp createChannel;
  193. daqfp setClock;
  194. daqfp stopTask;
  195. daqfp clearTask;
  196. daqfp resetDevice;
  197. daqfp waitForMeasurement;
  198. /*:305*/
  199. #line 6719 "./typica.w"
  200. /*306:*/
  201. #line 6746 "./typica.w"
  202. bool useBase;
  203. QString device;
  204. QVector<Channel*> channelMap;
  205. unsigned int handle;
  206. int error;
  207. int channels;
  208. bool ready;
  209. QLibrary driver;
  210. QVector<Units::Unit> unitMap;
  211. /*:306*/
  212. #line 6720 "./typica.w"
  213. };
  214. /*:304*//*322:*/
  215. #line 7251 "./typica.w"
  216. class FakeDAQImplementation:public QThread
  217. {
  218. Q_OBJECT
  219. public:
  220. FakeDAQImplementation();
  221. ~FakeDAQImplementation();
  222. void run();
  223. void measure();
  224. QVector<Channel*> channelMap;
  225. int channels;
  226. bool ready;
  227. double clockRate;
  228. };
  229. class FakeDAQ:public QObject
  230. {
  231. Q_OBJECT
  232. FakeDAQImplementation*imp;
  233. public:
  234. FakeDAQ(QString device);
  235. ~FakeDAQ();
  236. Channel*newChannel(int units,int thermocouple);
  237. Q_INVOKABLE void setClockRate(double Hz);
  238. Q_INVOKABLE void start();
  239. };
  240. /*:322*//*329:*/
  241. #line 7438 "./typica.w"
  242. class Channel:public QObject
  243. {
  244. Q_OBJECT
  245. public:
  246. Channel();
  247. ~Channel();
  248. public slots:
  249. void input(Measurement measurement);
  250. signals:
  251. void newData(Measurement);
  252. };
  253. /*:329*//*333:*/
  254. #line 7505 "./typica.w"
  255. class LinearCalibrator:public QObject
  256. {
  257. Q_OBJECT
  258. Q_PROPERTY(double measuredLower READ measuredLower
  259. WRITE setMeasuredLower)
  260. Q_PROPERTY(double measuredUpper READ measuredUpper
  261. WRITE setMeasuredUpper)
  262. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  263. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  264. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  265. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  266. public:
  267. LinearCalibrator(QObject*parent= NULL);
  268. double measuredLower();
  269. double measuredUpper();
  270. double mappedLower();
  271. double mappedUpper();
  272. bool isClosedRange();
  273. double sensitivity();
  274. public slots:
  275. void setMeasuredLower(double lower);
  276. void setMeasuredUpper(double upper);
  277. void setMappedLower(double lower);
  278. void setMappedUpper(double upper);
  279. void setClosedRange(bool closed);
  280. void setSensitivity(double sensitivity);
  281. Measurement newMeasurement(Measurement measure);
  282. signals:
  283. void measurement(Measurement measure);
  284. void newData(Measurement measure);
  285. private:
  286. double Lo1;
  287. double Lo2;
  288. double Up1;
  289. double Up2;
  290. double sensitivitySetting;
  291. bool clamp;
  292. };
  293. /*:333*//*340:*/
  294. #line 7701 "./typica.w"
  295. class LinearSplineInterpolator:public QObject
  296. {
  297. Q_OBJECT
  298. public:
  299. LinearSplineInterpolator(QObject*parent= NULL);
  300. Q_INVOKABLE void add_pair(double source,double destination);
  301. public slots:
  302. Measurement newMeasurement(Measurement measure);
  303. signals:
  304. void newData(Measurement measure);
  305. private:
  306. void make_interpolators();
  307. QMap<double,double> *pairs;
  308. QList<LinearCalibrator*> *interpolators;
  309. };
  310. /*:340*//*345:*/
  311. #line 7837 "./typica.w"
  312. class TemperatureDisplay:public QLCDNumber
  313. {
  314. Q_OBJECT
  315. int unit;
  316. bool r;
  317. public:
  318. TemperatureDisplay(QWidget*parent= NULL);
  319. ~TemperatureDisplay();
  320. public slots:
  321. void setValue(Measurement temperature);
  322. void invalidate();
  323. void setDisplayUnits(Units::Unit scale);
  324. void setRelativeMode(bool relative);
  325. };
  326. /*:345*//*356:*/
  327. #line 8056 "./typica.w"
  328. class MeasurementTimeOffset:public QObject
  329. {
  330. Q_OBJECT
  331. QTime epoch;
  332. QTime previous;
  333. bool hasPrevious;
  334. public:
  335. MeasurementTimeOffset(QTime zero);
  336. QTime zeroTime();
  337. public slots:
  338. void newMeasurement(Measurement measure);
  339. void setZeroTime(QTime zero);
  340. signals:
  341. void measurement(Measurement measure);
  342. };
  343. /*:356*//*363:*/
  344. #line 8208 "./typica.w"
  345. class ThresholdDetector:public QObject
  346. {
  347. Q_OBJECT
  348. Q_ENUMS(EdgeDirection)
  349. public:
  350. enum EdgeDirection{
  351. Ascending,Descending
  352. };
  353. ThresholdDetector(double value);
  354. public slots:
  355. void newMeasurement(Measurement measure);
  356. void setThreshold(double value);
  357. void setEdgeDirection(EdgeDirection direction);
  358. signals:
  359. void timeForValue(double);
  360. private:
  361. bool previousValueValid;
  362. double previousValue;
  363. double threshold;
  364. EdgeDirection currentDirection;
  365. };
  366. /*:363*//*368:*/
  367. #line 8324 "./typica.w"
  368. class ZeroEmitter:public QObject
  369. {
  370. Q_OBJECT
  371. Q_PROPERTY(int column READ column WRITE setColumn)
  372. Measurement cache;
  373. int col;
  374. public:
  375. ZeroEmitter(int tempcolumn= 1);
  376. int column();
  377. double lastTemperature();
  378. public slots:
  379. void newMeasurement(Measurement measure);
  380. void setColumn(int column);
  381. void emitZero();
  382. signals:
  383. void measurement(Measurement measure,int tempcolumn);
  384. };
  385. /*:368*//*373:*/
  386. #line 8418 "./typica.w"
  387. class MeasurementAdapter:public QObject
  388. {
  389. Q_OBJECT
  390. int col;
  391. public:
  392. MeasurementAdapter(int tempcolumn);
  393. int column();
  394. public slots:
  395. void newMeasurement(Measurement measure);
  396. void setColumn(int column);
  397. signals:
  398. void measurement(Measurement measure,int tempcolumn);
  399. };
  400. /*:373*//*378:*/
  401. #line 8507 "./typica.w"
  402. class GraphView:public QGraphicsView
  403. {
  404. Q_OBJECT
  405. QGraphicsScene*theScene;
  406. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  407. QMap<int,QPointF> *prevPoints;
  408. QMap<int,double> *translations;
  409. QList<QGraphicsItem*> *gridLinesF;
  410. QList<QGraphicsItem*> *gridLinesC;
  411. QList<QGraphicsItem*> *relativeGridLines;
  412. bool relativeEnabled;
  413. bool timeIndicatorEnabled;
  414. QGraphicsLineItem*timeLine;
  415. LinearSplineInterpolator*relativeAdjuster;
  416. public:
  417. GraphView(QWidget*parent= NULL);
  418. void removeSeries(int column);
  419. protected:
  420. void resizeEvent(QResizeEvent*event);
  421. public slots:
  422. void newMeasurement(Measurement measure,int tempcolumn);
  423. void setSeriesTranslation(int column,double offset);
  424. void setTimeIndicatorEnabled(bool enabled);
  425. void clear();
  426. void showF();
  427. void showC();
  428. };
  429. /*:378*//*395:*/
  430. #line 8972 "./typica.w"
  431. class MeasurementModel;
  432. class ZoomLog:public QTableView
  433. {
  434. Q_OBJECT
  435. /*396:*/
  436. #line 9021 "./typica.w"
  437. MeasurementModel*model_ms;
  438. MeasurementModel*model_1s;
  439. MeasurementModel*model_5s;
  440. MeasurementModel*model_10s;
  441. MeasurementModel*model_15s;
  442. MeasurementModel*model_30s;
  443. MeasurementModel*model_1m;
  444. QList<MeasurementModel*> modelSet;
  445. QHash<int,Measurement> lastMeasurement;
  446. MeasurementModel*currentModel;
  447. QList<int> saveTempCols;
  448. QList<int> saveControlCols;
  449. QList<int> saveNoteCols;
  450. QList<int> currentColumnSet;
  451. /*:396*/
  452. #line 8977 "./typica.w"
  453. void switchLOD(MeasurementModel*m);
  454. private slots:
  455. void centerOn(int row);
  456. void persistColumnResize(int column,int oldsize,int newsize);
  457. void restoreColumnWidths();
  458. public:
  459. ZoomLog();
  460. QVariant data(int row,int column)const;
  461. int rowCount();
  462. bool saveXML(QIODevice*device);
  463. bool saveCSV(QIODevice*device);
  464. QString lastTime(int series);
  465. Q_INVOKABLE Units::Unit displayUnits();
  466. public slots:
  467. void setVisible(bool visibility);
  468. void setHeaderData(int section,QString text);
  469. void LOD_ms();
  470. void LOD_1s();
  471. void LOD_5s();
  472. void LOD_10s();
  473. void LOD_15s();
  474. void LOD_30s();
  475. void LOD_1m();
  476. void newMeasurement(Measurement measure,int tempcolumn);
  477. void newAnnotation(QString annotation,int tempcolumn,
  478. int annotationcolumn);
  479. void clear();
  480. void addOutputTemperatureColumn(int column);
  481. void addOutputControlColumn(int column);
  482. void addOutputAnnotationColumn(int column);
  483. void clearOutputColumns();
  484. void setDisplayUnits(Units::Unit scale);
  485. void addToCurrentColumnSet(int column);
  486. void clearCurrentColumnSet();
  487. protected:
  488. virtual void showEvent(QShowEvent*event);
  489. };
  490. /*:395*//*421:*/
  491. #line 9717 "./typica.w"
  492. class MeasurementList;
  493. class MeasurementModel:public QAbstractItemModel
  494. {
  495. Q_OBJECT
  496. Units::Unit unit;
  497. QList<MeasurementList*> *entries;
  498. QStringList*hData;
  499. int colcount;
  500. QHash<int,int> *lastTemperature;
  501. QList<MeasurementList*> ::iterator lastInsertion;
  502. QHash<int,bool> *controlColumns;
  503. public:
  504. MeasurementModel(QObject*parent= NULL);
  505. ~MeasurementModel();
  506. int rowCount(const QModelIndex&parent= QModelIndex())const;
  507. int columnCount(const QModelIndex&parent= QModelIndex())const;
  508. bool setHeaderData(int section,Qt::Orientation orientation,
  509. const QVariant&value,int role= Qt::DisplayRole);
  510. QVariant data(const QModelIndex&index,int role)const;
  511. bool setData(const QModelIndex&index,const QVariant&value,
  512. int role= Qt::EditRole);
  513. Qt::ItemFlags flags(const QModelIndex&index)const;
  514. QVariant headerData(int section,Qt::Orientation orientation,
  515. int role= Qt::DisplayRole)const;
  516. QModelIndex index(int row,int column,
  517. const QModelIndex&parent= QModelIndex())const;
  518. QModelIndex parent(const QModelIndex&index)const;
  519. Units::Unit displayUnits();
  520. public slots:
  521. void newMeasurement(Measurement measure,int tempcolumn);
  522. void newAnnotation(QString annotation,int tempcolumn,
  523. int annotationColumn);
  524. void clear();
  525. void setDisplayUnits(Units::Unit scale);
  526. signals:
  527. void rowChanged(int);
  528. };
  529. /*:421*//*422:*/
  530. #line 9761 "./typica.w"
  531. class MeasurementList:public QVariantList
  532. {
  533. public:
  534. bool operator<(const MeasurementList&other)const;
  535. bool operator==(const MeasurementList&other)const;
  536. };
  537. /*:422*//*448:*/
  538. #line 10419 "./typica.w"
  539. class AnnotationButton:public QPushButton
  540. {
  541. Q_OBJECT
  542. QString note;
  543. int tc;
  544. int ac;
  545. int count;
  546. public:
  547. AnnotationButton(const QString&text,QWidget*parent= NULL);
  548. public slots:
  549. void setAnnotation(const QString&annotation);
  550. void setTemperatureColumn(int tempcolumn);
  551. void setAnnotationColumn(int annotationcolumn);
  552. void annotate();
  553. void resetCount();
  554. signals:
  555. void annotation(QString annotation,int tempcolumn,
  556. int notecolumn);
  557. };
  558. /*:448*//*456:*/
  559. #line 10544 "./typica.w"
  560. class AnnotationSpinBox:public QDoubleSpinBox
  561. {
  562. Q_OBJECT
  563. QString pretext;
  564. QString posttext;
  565. int tc;
  566. int ac;
  567. bool change;
  568. public:
  569. AnnotationSpinBox(const QString&pret,const QString&postt,
  570. QWidget*parent= NULL);
  571. public slots:
  572. void setPretext(const QString&pret);
  573. void setPosttext(const QString&postt);
  574. void setTemperatureColumn(int tempcolumn);
  575. void setAnnotationColumn(int annotationcolumn);
  576. void annotate();
  577. void resetChange();
  578. signals:
  579. void annotation(QString annotation,int tempcolumn,
  580. int notecolumn);
  581. };
  582. /*:456*//*464:*/
  583. #line 10703 "./typica.w"
  584. class TimerDisplay:public QLCDNumber
  585. {
  586. Q_OBJECT
  587. /*465:*/
  588. #line 10753 "./typica.w"
  589. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  590. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  591. Q_PROPERTY(bool running READ isRunning)
  592. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  593. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  594. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  595. Q_PROPERTY(QString value READ value)
  596. /*:465*/
  597. #line 10707 "./typica.w"
  598. private slots:
  599. void updateTime();
  600. void setCountUpMode();
  601. void setCountDownMode();
  602. void setClockMode();
  603. public:
  604. TimerDisplay(QWidget*parent= NULL);
  605. ~TimerDisplay();
  606. enum TimerMode
  607. {
  608. CountUp,
  609. CountDown,
  610. Clock
  611. };
  612. QString value();
  613. QTime seconds();
  614. TimerMode mode();
  615. bool isRunning();
  616. QTime resetValue();
  617. QString displayFormat();
  618. bool autoReset();
  619. public slots:
  620. void setTimer(QTime value= QTime(0,0,0));
  621. void setMode(TimerMode mode);
  622. void startTimer();
  623. void stopTimer();
  624. void copyTimer();
  625. void setResetValue(QTime value= QTime(0,0,0));
  626. void reset();
  627. void setDisplayFormat(QString format);
  628. void setAutoReset(bool reset);
  629. void updateDisplay();
  630. signals:
  631. void valueChanged(QTime);
  632. void runStateChanged(bool);
  633. private:
  634. /*466:*/
  635. #line 10764 "./typica.w"
  636. QTime s;
  637. QTime r;
  638. QTimer clock;
  639. TimerDisplay::TimerMode m;
  640. bool running;
  641. bool ar;
  642. QAction*startAction;
  643. QAction*stopAction;
  644. QAction*resetAction;
  645. QString f;
  646. QTime relative;
  647. QTime base;
  648. /*:466*/
  649. #line 10744 "./typica.w"
  650. };
  651. /*:464*//*487:*/
  652. #line 11156 "./typica.w"
  653. class PackLayout:public QLayout
  654. {
  655. int doLayout(const QRect&rect,bool testOnly)const;
  656. QList<QLayoutItem*> itemList;
  657. Qt::Orientations orientation;
  658. public:
  659. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  660. PackLayout(int spacing= -1);
  661. ~PackLayout();
  662. void addItem(QLayoutItem*item);
  663. Qt::Orientations expandingDirections()const;
  664. bool hasHeightForWidth()const;
  665. int heightForWidth(int width)const;
  666. int count()const;
  667. QLayoutItem*itemAt(int index)const;
  668. QSize minimumSize()const;
  669. void setGeometry(const QRect&rect);
  670. void setOrientation(Qt::Orientations direction);
  671. QSize sizeHint()const;
  672. QLayoutItem*takeAt(int index);
  673. };
  674. /*:487*//*500:*/
  675. #line 11434 "./typica.w"
  676. class SceneButton:public QGraphicsScene
  677. {
  678. Q_OBJECT
  679. public:
  680. SceneButton();
  681. ~SceneButton();
  682. protected:
  683. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  684. signals:
  685. void clicked(QPoint pos);
  686. };
  687. /*:500*//*502:*/
  688. #line 11476 "./typica.w"
  689. class WidgetDecorator:public QWidget
  690. {
  691. Q_OBJECT
  692. PackLayout*layout;
  693. QGraphicsView*label;
  694. QGraphicsTextItem*text;
  695. SceneButton*scene;
  696. public:
  697. WidgetDecorator(QWidget*widget,const QString&labeltext,
  698. Qt::Orientations orientation= Qt::Horizontal,
  699. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  700. ~WidgetDecorator();
  701. void setBackgroundBrush(QBrush background);
  702. void setTextColor(QColor color);
  703. };
  704. /*:502*//*513:*/
  705. #line 11651 "./typica.w"
  706. class LogEditWindow:public QMainWindow
  707. {
  708. Q_OBJECT
  709. QWidget*centralWidget;
  710. PackLayout*mainLayout;
  711. QHBoxLayout*addRowsLayout;
  712. QLabel*startTimeLabel;
  713. QTimeEdit*startTime;
  714. QLabel*endTimeLabel;
  715. QTimeEdit*endTime;
  716. QLabel*intervalLabel;
  717. QSpinBox*interval;
  718. QPushButton*addRows;
  719. QAction*saveXml;
  720. QAction*saveCsv;
  721. QAction*openXml;
  722. MeasurementModel*model;
  723. QTableView*log;
  724. private slots:
  725. void addTheRows();
  726. void saveXML();
  727. void saveCSV();
  728. void openXML();
  729. protected:
  730. void closeEvent(QCloseEvent*event);
  731. public:
  732. LogEditWindow();
  733. };
  734. /*:513*//*527:*/
  735. #line 11959 "./typica.w"
  736. class XMLOutput:public QObject
  737. {
  738. Q_OBJECT
  739. MeasurementModel*data;
  740. QIODevice*out;
  741. int time;
  742. QMap<int,QString> temperatureColumns;
  743. QMap<int,QString> controlColumns;
  744. QMap<int,QString> annotationColumns;
  745. public:
  746. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  747. void addTemperatureColumn(const QString&series,int column);
  748. void addControlColumn(const QString&series,int column);
  749. void addAnnotationColumn(const QString&series,int column);
  750. void setModel(MeasurementModel*model);
  751. void setTimeColumn(int column);
  752. void setDevice(QIODevice*device);
  753. bool output();
  754. };
  755. /*:527*//*534:*/
  756. #line 12195 "./typica.w"
  757. class XMLInput:public QObject
  758. {
  759. Q_OBJECT
  760. int firstc;
  761. QIODevice*in;
  762. public:
  763. XMLInput(QIODevice*input,int c);
  764. void setFirstColumn(int column);
  765. void setDevice(QIODevice*device);
  766. bool input();
  767. signals:
  768. void measure(Measurement,int);
  769. void annotation(QString,int,int);
  770. void newTemperatureColumn(int,QString);
  771. void newAnnotationColumn(int,QString);
  772. void lastColumn(int);
  773. };
  774. /*:534*//*545:*/
  775. #line 12449 "./typica.w"
  776. class CSVOutput
  777. {
  778. MeasurementModel*data;
  779. QIODevice*out;
  780. int time;
  781. QMap<int,QString> temperatureColumns;
  782. QMap<int,QString> controlColumns;
  783. QMap<int,QString> annotationColumns;
  784. public:
  785. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  786. void addTemperatureColumn(const QString&series,int column);
  787. void addControlColumn(const QString&series,int column);
  788. void addAnnotationColumn(const QString&series,int column);
  789. void setModel(MeasurementModel*model);
  790. void setTimeColumn(int column);
  791. void setDevice(QIODevice*device);
  792. bool output();
  793. };
  794. /*:545*//*575:*/
  795. #line 12592 "./typica.w"
  796. #define AppInstance (qobject_cast<Application *> (qApp))
  797. class NodeInserter;
  798. class DeviceTreeModel;
  799. class Application:public QApplication
  800. {
  801. Q_OBJECT
  802. public:
  803. Application(int&argc,char**argv);
  804. QDomDocument*configuration();
  805. /*717:*/
  806. #line 15156 "./typica.w"
  807. QDomDocument deviceConfiguration();
  808. /*:717*//*750:*/
  809. #line 15829 "./typica.w"
  810. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  811. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  812. const QModelIndex&index);
  813. /*:750*//*755:*/
  814. #line 15933 "./typica.w"
  815. QList<NodeInserter*> topLevelNodeInserters;
  816. /*:755*/
  817. #line 12603 "./typica.w"
  818. QSqlDatabase database();
  819. QScriptEngine*engine;
  820. public slots:
  821. /*718:*/
  822. #line 15163 "./typica.w"
  823. void saveDeviceConfiguration();
  824. /*:718*/
  825. #line 12607 "./typica.w"
  826. private:
  827. /*716:*/
  828. #line 15147 "./typica.w"
  829. QDomDocument deviceConfigurationDocument;
  830. /*:716*//*749:*/
  831. #line 15823 "./typica.w"
  832. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  833. /*:749*/
  834. #line 12609 "./typica.w"
  835. QDomDocument conf;
  836. };
  837. /*:575*//*583:*/
  838. #line 12734 "./typica.w"
  839. class SaltModel:public QAbstractItemModel
  840. {
  841. Q_OBJECT
  842. QList<QList<QMap<int,QVariant> > > modelData;
  843. QStringList hData;
  844. int colcount;
  845. public:
  846. SaltModel(int columns);
  847. ~SaltModel();
  848. int rowCount(const QModelIndex&parent= QModelIndex())const;
  849. int columnCount(const QModelIndex&parent= QModelIndex())const;
  850. bool setHeaderData(int section,Qt::Orientation orientation,
  851. const QVariant&value,int role= Qt::DisplayRole);
  852. QVariant data(const QModelIndex&index,int role)const;
  853. bool setData(const QModelIndex&index,const QVariant&value,
  854. int role= Qt::EditRole);
  855. Qt::ItemFlags flags(const QModelIndex&index)const;
  856. QVariant headerData(int section,Qt::Orientation orientation,
  857. int role= Qt::DisplayRole)const;
  858. QModelIndex index(int row,int column,
  859. const QModelIndex&parent= QModelIndex())const;
  860. QModelIndex parent(const QModelIndex&index)const;
  861. QString arrayLiteral(int column,int role)const;
  862. QString quotedArrayLiteral(int column,int role)const;
  863. void clear();
  864. bool removeRows(int row,int count,
  865. const QModelIndex&parent= QModelIndex());
  866. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  867. };
  868. /*:583*//*599:*/
  869. #line 13119 "./typica.w"
  870. class SqlComboBox:public QComboBox
  871. {
  872. Q_OBJECT
  873. int dataColumn;
  874. int displayColumn;
  875. bool dataColumnShown;
  876. QString specialNullText;
  877. QVariant specialNullData;
  878. public:
  879. SqlComboBox();
  880. ~SqlComboBox();
  881. SqlComboBox*clone(QWidget*parent);
  882. public slots:
  883. void addNullOption();
  884. void addSqlOptions(QString query);
  885. void setDataColumn(int column);
  886. void setDisplayColumn(int column);
  887. void showData(bool show);
  888. void setNullText(QString nullText);
  889. void setNullData(QVariant nullData);
  890. };
  891. /*:599*//*606:*/
  892. #line 13266 "./typica.w"
  893. class SqlComboBoxDelegate:public QItemDelegate
  894. {
  895. Q_OBJECT
  896. SqlComboBox*delegate;
  897. public:
  898. SqlComboBoxDelegate(QObject*parent= NULL);
  899. QWidget*createEditor(QWidget*parent,
  900. const QStyleOptionViewItem&option,
  901. const QModelIndex&index)const;
  902. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  903. void setModelData(QWidget*editor,QAbstractItemModel*model,
  904. const QModelIndex&index)const;
  905. void setWidget(SqlComboBox*widget);
  906. virtual QSize sizeHint()const;
  907. void updateEditorGeometry(QWidget*editor,
  908. const QStyleOptionViewItem&option,
  909. const QModelIndex&index)const;
  910. };
  911. /*:606*//*621:*/
  912. #line 13477 "./typica.w"
  913. class SqlConnectionSetup:public QDialog
  914. {
  915. Q_OBJECT
  916. public:
  917. SqlConnectionSetup();
  918. ~SqlConnectionSetup();
  919. public slots:
  920. void testConnection();
  921. private:
  922. QFormLayout*formLayout;
  923. QComboBox*driver;
  924. QLineEdit*hostname;
  925. QLineEdit*portnumber;
  926. QLineEdit*dbname;
  927. QLineEdit*user;
  928. QLineEdit*password;
  929. QVBoxLayout*layout;
  930. QHBoxLayout*buttons;
  931. QPushButton*cancelButton;
  932. QPushButton*connectButton;
  933. };
  934. /*:621*//*626:*/
  935. #line 13620 "./typica.w"
  936. class SqlQueryView:public QTableView
  937. {
  938. Q_OBJECT
  939. public:
  940. SqlQueryView(QWidget*parent= NULL);
  941. void setQuery(const QString&query);
  942. bool setHeaderData(int section,Qt::Orientation orientation,
  943. const QVariant&value,int role);
  944. Q_INVOKABLE QVariant data(int row,int column,
  945. int role= Qt::DisplayRole);
  946. signals:
  947. void openEntry(QString key);
  948. void openEntryRow(int row);
  949. protected:
  950. virtual void showEvent(QShowEvent*event);
  951. private slots:
  952. void openRow(const QModelIndex&index);
  953. void persistColumnResize(int column,int oldsize,int newsize);
  954. };
  955. /*:626*//*641:*/
  956. #line 13875 "./typica.w"
  957. class ReportAction:public QAction
  958. {
  959. Q_OBJECT
  960. public:
  961. ReportAction(const QString&fileName,const QString&reportName,
  962. QObject*parent= NULL);
  963. private slots:
  964. void createReport();
  965. private:
  966. QString reportFile;
  967. };
  968. /*:641*//*653:*/
  969. #line 14086 "./typica.w"
  970. class ReportTable:public QObject
  971. {
  972. Q_OBJECT
  973. QTextFrame*area;
  974. QDomElement configuration;
  975. QMap<QString,QVariant> bindings;
  976. public:
  977. ReportTable(QTextFrame*frame,QDomElement description);
  978. ~ReportTable();
  979. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  980. public slots:
  981. void refresh();
  982. };
  983. /*:653*//*686:*/
  984. #line 14325 "./typica.w"
  985. class FormArray:public QScrollArea
  986. {
  987. Q_OBJECT
  988. QDomElement configuration;
  989. QWidget itemContainer;
  990. QVBoxLayout itemLayout;
  991. int maxwidth;
  992. int maxheight;
  993. public:
  994. FormArray(QDomElement description);
  995. Q_INVOKABLE QWidget*elementAt(int index);
  996. Q_INVOKABLE int elements();
  997. public slots:
  998. void addElements(int copies= 1);
  999. void removeAllElements();
  1000. void setMaximumElementWidth(int width);
  1001. void setMaximumElementHeight(int height);
  1002. };
  1003. /*:686*//*696:*/
  1004. #line 14541 "./typica.w"
  1005. class ScaleControl:public QGraphicsView
  1006. {
  1007. Q_OBJECT
  1008. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1009. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1010. /*697:*/
  1011. #line 14567 "./typica.w"
  1012. QGraphicsScene scene;
  1013. QGraphicsPolygonItem initialDecrement;
  1014. QGraphicsPolygonItem initialIncrement;
  1015. QGraphicsPolygonItem finalDecrement;
  1016. QGraphicsPolygonItem finalIncrement;
  1017. QGraphicsPolygonItem initialIndicator;
  1018. QGraphicsPolygonItem finalIndicator;
  1019. QGraphicsPathItem scaleLine;
  1020. QPolygonF left;
  1021. QPolygonF right;
  1022. QPolygonF down;
  1023. QPolygonF up;
  1024. QPainterPath scalePath;
  1025. QBrush initialBrush;
  1026. QBrush finalBrush;
  1027. double nonScoredValue;
  1028. double scoredValue;
  1029. bool initialSet;
  1030. bool finalSet;
  1031. bool scaleDown;
  1032. /*:697*/
  1033. #line 14547 "./typica.w"
  1034. public:
  1035. ScaleControl();
  1036. double initialValue(void);
  1037. double finalValue(void);
  1038. virtual QSize sizeHint()const;
  1039. public slots:
  1040. void setInitialValue(double value);
  1041. void setFinalValue(double value);
  1042. signals:
  1043. void initialChanged(double);
  1044. void finalChanged(double);
  1045. protected:
  1046. virtual void mousePressEvent(QMouseEvent*event);
  1047. virtual void mouseReleaseEvent(QMouseEvent*event);
  1048. };
  1049. /*:696*//*708:*/
  1050. #line 14864 "./typica.w"
  1051. class IntensityControl:public QGraphicsView
  1052. {
  1053. Q_OBJECT
  1054. Q_PROPERTY(double value READ value WRITE setValue)
  1055. QGraphicsScene scene;
  1056. QGraphicsPolygonItem decrement;
  1057. QGraphicsPolygonItem increment;
  1058. QGraphicsPolygonItem indicator;
  1059. QGraphicsPathItem scaleLine;
  1060. QPolygonF left;
  1061. QPolygonF up;
  1062. QPolygonF down;
  1063. QPainterPath scalePath;
  1064. QBrush theBrush;
  1065. double theValue;
  1066. bool valueSet;
  1067. bool scaleDown;
  1068. public:
  1069. IntensityControl();
  1070. double value();
  1071. virtual QSize sizeHint()const;
  1072. public slots:
  1073. void setValue(double val);
  1074. signals:
  1075. void valueChanged(double);
  1076. protected:
  1077. virtual void mousePressEvent(QMouseEvent*event);
  1078. virtual void mouseReleaseEvent(QMouseEvent*event);
  1079. };
  1080. /*:708*//*724:*/
  1081. #line 15252 "./typica.w"
  1082. class DeviceTreeModelNode
  1083. {
  1084. public:
  1085. DeviceTreeModelNode(QDomNode&node,int row,
  1086. DeviceTreeModelNode*parent= NULL);
  1087. ~DeviceTreeModelNode();
  1088. DeviceTreeModelNode*child(int index);
  1089. DeviceTreeModelNode*parent();
  1090. QDomNode node()const;
  1091. int row();
  1092. private:
  1093. QDomNode domNode;
  1094. QHash<int,DeviceTreeModelNode*> children;
  1095. int rowNumber;
  1096. DeviceTreeModelNode*parentItem;
  1097. };
  1098. /*:724*//*726:*/
  1099. #line 15327 "./typica.w"
  1100. class DeviceTreeModel:public QAbstractItemModel
  1101. {
  1102. Q_OBJECT
  1103. public:
  1104. DeviceTreeModel(QObject*parent= NULL);
  1105. ~DeviceTreeModel();
  1106. QVariant data(const QModelIndex&index,int role)const;
  1107. Qt::ItemFlags flags(const QModelIndex&index)const;
  1108. QVariant headerData(int section,Qt::Orientation orientation,
  1109. int role= Qt::DisplayRole)const;
  1110. QModelIndex index(int row,int column,
  1111. const QModelIndex&parent= QModelIndex())const;
  1112. QModelIndex parent(const QModelIndex&child)const;
  1113. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1114. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1115. bool setData(const QModelIndex&index,const QVariant&value,
  1116. int role);
  1117. bool removeRows(int row,int count,const QModelIndex&parent);
  1118. QDomElement referenceElement(const QString&id);
  1119. public slots:
  1120. void newNode(const QString&name,const QString&driver,
  1121. const QModelIndex&parent);
  1122. private:
  1123. QDomDocument document;
  1124. DeviceTreeModelNode*root;
  1125. QDomNode referenceSection;
  1126. QDomNode treeRoot;
  1127. };
  1128. /*:726*//*745:*/
  1129. #line 15781 "./typica.w"
  1130. Q_DECLARE_METATYPE(QModelIndex)
  1131. /*:745*//*753:*/
  1132. #line 15888 "./typica.w"
  1133. class NodeInserter:public QAction
  1134. {
  1135. Q_OBJECT
  1136. public:
  1137. NodeInserter(const QString&title,const QString&name,
  1138. const QString&driver,QObject*parent= NULL);
  1139. signals:
  1140. void triggered(QString name,QString driver);
  1141. private slots:
  1142. void onTriggered();
  1143. private:
  1144. QString defaultNodeName;
  1145. QString driverString;
  1146. };
  1147. /*:753*//*756:*/
  1148. #line 15943 "./typica.w"
  1149. class DeviceConfigurationWindow:public QWidget
  1150. {
  1151. Q_OBJECT
  1152. public:
  1153. DeviceConfigurationWindow();
  1154. public slots:
  1155. void addDevice();
  1156. void removeNode();
  1157. void newSelection(const QModelIndex&index);
  1158. private slots:
  1159. void resizeColumn();
  1160. private:
  1161. QDomDocument document;
  1162. DeviceTreeModel*model;
  1163. QTreeView*view;
  1164. QScrollArea*configArea;
  1165. };
  1166. /*:756*//*765:*/
  1167. #line 16113 "./typica.w"
  1168. class BasicDeviceConfigurationWidget:public QWidget
  1169. {
  1170. Q_OBJECT
  1171. public:
  1172. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1173. const QModelIndex&index);
  1174. public slots:
  1175. void insertChildNode(const QString&name,const QString&driver);
  1176. void updateAttribute(const QString&name,const QString&value);
  1177. protected:
  1178. DeviceTreeModel*deviceModel;
  1179. QModelIndex currentNode;
  1180. };
  1181. /*:765*//*769:*/
  1182. #line 16198 "./typica.w"
  1183. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1184. {
  1185. Q_OBJECT
  1186. public:
  1187. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1188. const QModelIndex&index);
  1189. private slots:
  1190. void updateRoasterId(int id);
  1191. void updateCapacityCheck(int value);
  1192. void updateCapacity(const QString&value);
  1193. void updateCapacityUnit(const QString&value);
  1194. };
  1195. /*:769*//*774:*/
  1196. #line 16403 "./typica.w"
  1197. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1198. {
  1199. Q_OBJECT
  1200. public:
  1201. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1202. const QModelIndex&index);
  1203. };
  1204. /*:774*//*776:*/
  1205. #line 16449 "./typica.w"
  1206. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1207. {
  1208. Q_OBJECT
  1209. public:
  1210. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1211. const QModelIndex&index);
  1212. private slots:
  1213. void addChannel();
  1214. void updateDeviceId(const QString&newId);
  1215. };
  1216. /*:776*//*780:*/
  1217. #line 16535 "./typica.w"
  1218. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1219. {
  1220. Q_OBJECT
  1221. public:
  1222. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1223. const QModelIndex&index);
  1224. private slots:
  1225. void updateThermocoupleType(const QString&type);
  1226. void updateColumnName(const QString&name);
  1227. void updateHidden(bool hidden);
  1228. };
  1229. /*:780*//*785:*/
  1230. #line 16651 "./typica.w"
  1231. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1232. {
  1233. Q_OBJECT
  1234. public:
  1235. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1236. const QModelIndex&index);
  1237. };
  1238. /*:785*//*787:*/
  1239. #line 16692 "./typica.w"
  1240. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1241. {
  1242. Q_OBJECT
  1243. public:
  1244. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1245. const QModelIndex&index);
  1246. private slots:
  1247. void addChannel();
  1248. void updateDeviceId(const QString&newId);
  1249. };
  1250. /*:787*//*789:*/
  1251. #line 16761 "./typica.w"
  1252. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1253. {
  1254. Q_OBJECT
  1255. public:
  1256. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1257. const QModelIndex&index);
  1258. private slots:
  1259. void updateDeviceId(const QString&newId);
  1260. void updateThermocoupleType(const QString&type);
  1261. void updateColumnName(const QString&name);
  1262. void updateHidden(bool hidden);
  1263. };
  1264. /*:789*//*794:*/
  1265. #line 16892 "./typica.w"
  1266. class PortSelector:public QComboBox
  1267. {
  1268. Q_OBJECT
  1269. public:
  1270. PortSelector(QWidget*parent= NULL);
  1271. private slots:
  1272. void addDevice(QextPortInfo port);
  1273. private:
  1274. QextSerialEnumerator*lister;
  1275. };
  1276. /*:794*//*796:*/
  1277. #line 16940 "./typica.w"
  1278. class BaudSelector:public QComboBox
  1279. {
  1280. Q_OBJECT
  1281. Q_ENUMS(BaudRateType)
  1282. public:
  1283. BaudSelector(QWidget*parent= NULL);
  1284. enum BaudRateType
  1285. {
  1286. #if defined(Q_OS_UNIX) || defined(qdoc)
  1287. BAUD50= 50,
  1288. BAUD75= 75,
  1289. BAUD134= 134,
  1290. BAUD150= 150,
  1291. BAUD200= 200,
  1292. BAUD1800= 1800,
  1293. #if defined(B76800) || defined(qdoc)
  1294. BAUD76800= 76800,
  1295. #endif
  1296. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1297. BAUD230400= 230400,
  1298. BAUD460800= 460800,
  1299. BAUD500000= 500000,
  1300. BAUD576000= 576000,
  1301. BAUD921600= 921600,
  1302. BAUD1000000= 1000000,
  1303. BAUD1152000= 1152000,
  1304. BAUD1500000= 1500000,
  1305. BAUD2000000= 2000000,
  1306. BAUD2500000= 2500000,
  1307. BAUD3000000= 3000000,
  1308. BAUD3500000= 3500000,
  1309. BAUD4000000= 4000000,
  1310. #endif
  1311. #endif
  1312. #if defined(Q_OS_WIN) || defined(qdoc)
  1313. BAUD14400= 14400,
  1314. BAUD56000= 56000,
  1315. BAUD128000= 128000,
  1316. BAUD256000= 256000,
  1317. #endif
  1318. BAUD110= 110,
  1319. BAUD300= 300,
  1320. BAUD600= 600,
  1321. BAUD1200= 1200,
  1322. BAUD2400= 2400,
  1323. BAUD4800= 4800,
  1324. BAUD9600= 9600,
  1325. BAUD19200= 19200,
  1326. BAUD38400= 38400,
  1327. BAUD57600= 57600,
  1328. BAUD115200= 115200
  1329. };
  1330. };
  1331. /*:796*//*798:*/
  1332. #line 17011 "./typica.w"
  1333. class ParitySelector:public QComboBox
  1334. {
  1335. Q_OBJECT
  1336. Q_ENUMS(ParityType)
  1337. public:
  1338. ParitySelector(QWidget*parent= NULL);
  1339. enum ParityType
  1340. {
  1341. PAR_NONE,
  1342. PAR_ODD,
  1343. PAR_EVEN,
  1344. #if defined(Q_OS_WIN) || defined(qdoc)
  1345. PAR_MARK,
  1346. #endif
  1347. PAR_SPACE
  1348. };
  1349. };
  1350. /*:798*//*800:*/
  1351. #line 17049 "./typica.w"
  1352. class FlowSelector:public QComboBox
  1353. {
  1354. Q_OBJECT
  1355. Q_ENUMS(FlowType)
  1356. public:
  1357. FlowSelector(QWidget*parent= NULL);
  1358. enum FlowType
  1359. {
  1360. FLOW_OFF,
  1361. FLOW_HARDWARE,
  1362. FLOW_XONXOFF
  1363. };
  1364. };
  1365. /*:800*//*802:*/
  1366. #line 17082 "./typica.w"
  1367. class StopSelector:public QComboBox
  1368. {
  1369. Q_OBJECT
  1370. Q_ENUMS(StopBitsType)
  1371. public:
  1372. StopSelector(QWidget*parent= NULL);
  1373. enum StopBitsType
  1374. {
  1375. STOP_1,
  1376. #if defined(Q_OS_WIN) || defined(qdoc)
  1377. STOP_1_5,
  1378. #endif
  1379. STOP_2
  1380. };
  1381. };
  1382. /*:802*//*805:*/
  1383. #line 17139 "./typica.w"
  1384. class ShortHexSpinBox:public QSpinBox
  1385. {
  1386. Q_OBJECT
  1387. public:
  1388. ShortHexSpinBox(QWidget*parent= NULL);
  1389. virtual QValidator::State validate(QString&input,int&pos)const;
  1390. protected:
  1391. virtual int valueFromText(const QString&text)const;
  1392. virtual QString textFromValue(int value)const;
  1393. };
  1394. /*:805*//*807:*/
  1395. #line 17201 "./typica.w"
  1396. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1397. {
  1398. Q_OBJECT
  1399. public:
  1400. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1401. const QModelIndex&index);
  1402. private slots:
  1403. void updatePort(const QString&newPort);
  1404. void updateBaudRate(const QString&newRate);
  1405. void updateParity(const QString&newParity);
  1406. void updateFlowControl(const QString&newFlow);
  1407. void updateStopBits(const QString&newStopBits);
  1408. };
  1409. /*:807*//*809:*/
  1410. #line 17352 "./typica.w"
  1411. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1412. {
  1413. Q_OBJECT
  1414. public:
  1415. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1416. const QModelIndex&index);
  1417. private slots:
  1418. void updateStationNumber(int newStation);
  1419. void updateFixedUnit(bool newFixed);
  1420. void updateFixedDecimal(bool newFixed);
  1421. void updateUnit(const QString&newUnit);
  1422. void updateUnitAddress(int newAddress);
  1423. void updateValueF(int newValue);
  1424. void updateValueC(int newValue);
  1425. void updatePrecisionAddress(int newAddress);
  1426. void updatePrecisionValue(int newValue);
  1427. private:
  1428. QStackedLayout*unitSpecificationLayout;
  1429. QStackedLayout*decimalSpecificationLayout;
  1430. };
  1431. /*:809*//*811:*/
  1432. #line 17611 "./typica.w"
  1433. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1434. {
  1435. Q_OBJECT
  1436. public:
  1437. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1438. const QModelIndex&index);
  1439. private slots:
  1440. void updateAddress(int newAddress);
  1441. };
  1442. /*:811*//*813:*/
  1443. #line 17657 "./typica.w"
  1444. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1445. {
  1446. Q_OBJECT
  1447. public:
  1448. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1449. const QModelIndex&index);
  1450. private slots:
  1451. void updateReadAddress(int newAddress);
  1452. void updateWriteAddress(int newAddress);
  1453. void updateFixedRange(bool fixed);
  1454. void updateLower(const QString&lower);
  1455. void updateUpper(const QString&upper);
  1456. void updateLowerAddress(int newAddress);
  1457. void updateUpperAddress(int newAddress);
  1458. private:
  1459. QStackedLayout*boundsLayout;
  1460. };
  1461. /*:813*//*817:*/
  1462. #line 17851 "./typica.w"
  1463. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1464. {
  1465. Q_OBJECT
  1466. public:
  1467. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1468. private slots:
  1469. void updateButtonText(const QString&text);
  1470. void updateAnnotationText(const QString&text);
  1471. };
  1472. /*:817*//*821:*/
  1473. #line 17919 "./typica.w"
  1474. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1475. {
  1476. Q_OBJECT
  1477. public:
  1478. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1479. private slots:
  1480. void updateButtonText(const QString&text);
  1481. void updateAnnotationText(const QString&text);
  1482. };
  1483. /*:821*//*824:*/
  1484. #line 17993 "./typica.w"
  1485. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1486. {
  1487. Q_OBJECT
  1488. public:
  1489. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1490. private slots:
  1491. void updateLabel(const QString&text);
  1492. void updateMinimum(const QString&minimum);
  1493. void updateMaximum(const QString&maximum);
  1494. void updatePrecision(int precision);
  1495. void updatePretext(const QString&text);
  1496. void updatePosttext(const QString&text);
  1497. };
  1498. /*:824*//*827:*/
  1499. #line 12 "./freeannotation.w"
  1500. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1501. {
  1502. Q_OBJECT
  1503. public:
  1504. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1505. private slots:
  1506. void updateLabel(const QString&text);
  1507. };
  1508. /*:827*//*831:*/
  1509. #line 11 "./settings.w"
  1510. class SettingsWindow:public QMainWindow
  1511. {
  1512. Q_OBJECT
  1513. public:
  1514. SettingsWindow();
  1515. };
  1516. /*:831*//*836:*/
  1517. #line 8 "./graphsettings.w"
  1518. class GraphSettingsWidget:public QWidget
  1519. {
  1520. Q_OBJECT
  1521. public:
  1522. GraphSettingsWidget();
  1523. };
  1524. /*:836*//*838:*/
  1525. #line 46 "./graphsettings.w"
  1526. class GraphSettingsRelativeTab:public QWidget
  1527. {
  1528. Q_OBJECT
  1529. public:
  1530. GraphSettingsRelativeTab();
  1531. public slots:
  1532. void updateEnableSetting(bool enable);
  1533. void updateColorSetting(const QString&color);
  1534. void updateAxisSetting(const QString&gridList);
  1535. void updateUnit(int unit);
  1536. void showColorPicker();
  1537. private:
  1538. QLineEdit*colorEdit;
  1539. };
  1540. /*:838*//*842:*/
  1541. #line 7 "./advancedsettings.w"
  1542. class AdvancedSettingsWidget:public QWidget
  1543. {
  1544. Q_OBJECT
  1545. public:
  1546. AdvancedSettingsWidget();
  1547. public slots:
  1548. void enableDiagnosticLogging(bool enabled);
  1549. };
  1550. /*:842*//*846:*/
  1551. #line 18118 "./typica.w"
  1552. class ModbusRTUDevice:public QObject
  1553. {
  1554. Q_OBJECT
  1555. public:
  1556. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1557. ~ModbusRTUDevice();
  1558. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1559. Q_INVOKABLE double SVLower();
  1560. Q_INVOKABLE double SVUpper();
  1561. Q_INVOKABLE int decimals();
  1562. QList<Channel*> channels;
  1563. public slots:
  1564. void outputSV(double sv);
  1565. signals:
  1566. void SVLowerChanged(double);
  1567. void SVUpperChanged(double);
  1568. void SVDecimalChanged(int);
  1569. void queueEmpty();
  1570. private slots:
  1571. void dataAvailable();
  1572. void sendNextMessage();
  1573. void decimalResponse(QByteArray response);
  1574. void unitResponse(QByteArray response);
  1575. void svlResponse(QByteArray response);
  1576. void svuResponse(QByteArray response);
  1577. void requestMeasurement();
  1578. void mResponse(QByteArray response);
  1579. void ignore(QByteArray response);
  1580. void timeout();
  1581. private:
  1582. QextSerialPort*port;
  1583. QByteArray responseBuffer;
  1584. QList<QByteArray> messageQueue;
  1585. QList<QObject*> retObjQueue;
  1586. QList<char*> callbackQueue;
  1587. quint16 calculateCRC(QByteArray data);
  1588. QTimer*messageDelayTimer;
  1589. QTimer*commTimeout;
  1590. int delayTime;
  1591. char station;
  1592. int decimalPosition;
  1593. int valueF;
  1594. int valueC;
  1595. bool unitIsF;
  1596. double outputSVLower;
  1597. double outputSVUpper;
  1598. QByteArray outputSVStub;
  1599. QByteArray pvStub;
  1600. QByteArray svStub;
  1601. QByteArray mStub;
  1602. quint16 pvaddress;
  1603. quint16 svaddress;
  1604. bool svenabled;
  1605. bool readingsv;
  1606. double savedpv;
  1607. bool waiting;
  1608. };
  1609. /*:846*//*862:*/
  1610. #line 18821 "./typica.w"
  1611. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1612. {
  1613. Q_OBJECT
  1614. public:
  1615. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1616. private slots:
  1617. void updatePort(const QString&newPort);
  1618. void updateBaudRate(const QString&newRate);
  1619. void updateParity(const QString&newParity);
  1620. void updateFlowControl(const QString&newFlow);
  1621. void updateStopBits(const QString&newStopBits);
  1622. void updateStation(int station);
  1623. void updateFixedDecimal(bool fixed);
  1624. void updateDecimalAddress(int address);
  1625. void updateDecimalPosition(int position);
  1626. void updateFixedUnit(bool fixed);
  1627. void updateUnitAddress(int address);
  1628. void updateValueForF(int value);
  1629. void updateValueForC(int value);
  1630. void updateUnit(const QString&newUnit);
  1631. void updatePVAddress(int address);
  1632. void updateSVEnabled(bool enabled);
  1633. void updateSVReadAddress(int address);
  1634. void updateDeviceLimit(bool query);
  1635. void updateSVLowerAddress(int address);
  1636. void updateSVUpperAddress(int address);
  1637. void updateSVLower(double value);
  1638. void updateSVUpper(double value);
  1639. void updateSVWritable(bool canWriteSV);
  1640. void updateSVWriteAddress(int address);
  1641. void updatePVColumnName(const QString&name);
  1642. void updateSVColumnName(const QString&name);
  1643. void updatePVHidden(bool hidden);
  1644. void updateSVHidden(bool hidden);
  1645. private:
  1646. PortSelector*port;
  1647. BaudSelector*baud;
  1648. ParitySelector*parity;
  1649. FlowSelector*flow;
  1650. StopSelector*stop;
  1651. QSpinBox*station;
  1652. QCheckBox*decimalQuery;
  1653. ShortHexSpinBox*decimalAddress;
  1654. QSpinBox*decimalPosition;
  1655. QCheckBox*unitQuery;
  1656. ShortHexSpinBox*unitAddress;
  1657. QSpinBox*valueF;
  1658. QSpinBox*valueC;
  1659. QComboBox*fixedUnit;
  1660. ShortHexSpinBox*pVAddress;
  1661. QCheckBox*sVEnabled;
  1662. ShortHexSpinBox*sVReadAddress;
  1663. QCheckBox*deviceLimit;
  1664. ShortHexSpinBox*sVLowerAddr;
  1665. ShortHexSpinBox*sVUpperAddr;
  1666. QDoubleSpinBox*sVLower;
  1667. QDoubleSpinBox*sVUpper;
  1668. QCheckBox*sVWritable;
  1669. ShortHexSpinBox*sVOutputAddr;
  1670. QLineEdit*pVColumnName;
  1671. QLineEdit*sVColumnName;
  1672. };
  1673. /*:862*//*866:*/
  1674. #line 22 "./modbus.w"
  1675. class ModbusNGConfWidget:public BasicDeviceConfigurationWidget
  1676. {
  1677. Q_OBJECT
  1678. public:
  1679. Q_INVOKABLE ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1680. private slots:
  1681. void updatePort(const QString&value);
  1682. void updateBaudRate(const QString&value);
  1683. void updateParity(int value);
  1684. void updateFlowControl(int value);
  1685. void updateStopBits(int value);
  1686. void addInput();
  1687. private:
  1688. ParitySelector*m_parity;
  1689. FlowSelector*m_flow;
  1690. StopSelector*m_stop;
  1691. };
  1692. /*:866*//*868:*/
  1693. #line 144 "./modbus.w"
  1694. class ModbusNGInputConfWidget:public BasicDeviceConfigurationWidget
  1695. {
  1696. Q_OBJECT
  1697. public:
  1698. Q_INVOKABLE ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1699. private slots:
  1700. void updateStation(int value);
  1701. void updateAddress(int value);
  1702. void updateFunction(int value);
  1703. void updateFormat(int value);
  1704. void updateDecimals(int value);
  1705. void updateUnit(int value);
  1706. void updateColumnName(const QString&value);
  1707. void updateHidden(bool value);
  1708. };
  1709. /*:868*//*872:*/
  1710. #line 338 "./modbus.w"
  1711. enum ModbusDataFormat
  1712. {
  1713. Int16,
  1714. FloatHL,
  1715. FloatLH
  1716. };
  1717. struct ModbusScanItem
  1718. {
  1719. QByteArray request;
  1720. ModbusDataFormat format;
  1721. int decimalPosition;
  1722. Units::Unit unit;
  1723. mutable double lastValue;
  1724. };
  1725. /*:872*//*873:*/
  1726. #line 358 "./modbus.w"
  1727. class ModbusNG:public QObject
  1728. {
  1729. Q_OBJECT
  1730. public:
  1731. ModbusNG(DeviceTreeModel*model,const QModelIndex&index);
  1732. ~ModbusNG();
  1733. Q_INVOKABLE int channelCount();
  1734. Channel*getChannel(int);
  1735. Q_INVOKABLE QString channelColumnName(int);
  1736. Q_INVOKABLE QString channelIndicatorText(int);
  1737. Q_INVOKABLE bool isChannelHidden(int);
  1738. private slots:
  1739. void sendNextMessage();
  1740. void timeout();
  1741. void dataAvailable();
  1742. private:
  1743. quint16 calculateCRC(QByteArray data);
  1744. QextSerialPort*port;
  1745. int delayTime;
  1746. QTimer*messageDelayTimer;
  1747. QTimer*commTimeout;
  1748. int scanPosition;
  1749. bool waiting;
  1750. QByteArray responseBuffer;
  1751. QList<Channel*> channels;
  1752. QList<ModbusScanItem> scanList;
  1753. QList<QString> channelNames;
  1754. QList<QString> channelLabels;
  1755. QList<bool> hiddenStates;
  1756. };
  1757. /*:873*//*878:*/
  1758. #line 36 "./unsupportedserial.w"
  1759. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1760. {
  1761. Q_OBJECT
  1762. public:
  1763. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1764. const QModelIndex&index);
  1765. private slots:
  1766. void updateConfiguration();
  1767. void saveScript();
  1768. void addChannel();
  1769. private:
  1770. SaltModel*deviceSettingsModel;
  1771. QTextEdit*scriptEditor;
  1772. };
  1773. /*:878*//*883:*/
  1774. #line 166 "./unsupportedserial.w"
  1775. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1776. {
  1777. Q_OBJECT
  1778. public:
  1779. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1780. const QModelIndex&index);
  1781. private slots:
  1782. void updateColumnName(const QString&value);
  1783. void updateHidden(bool hidden);
  1784. void updateConfiguration();
  1785. private:
  1786. SaltModel*channelSettingsModel;
  1787. };
  1788. /*:883*//*888:*/
  1789. #line 298 "./unsupportedserial.w"
  1790. class JavaScriptDevice:public QObject
  1791. {
  1792. Q_OBJECT
  1793. public:
  1794. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1795. QScriptEngine*engine);
  1796. Q_INVOKABLE int channelCount();
  1797. Channel*getChannel(int channel);
  1798. Q_INVOKABLE bool isChannelHidden(int channel);
  1799. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1800. Q_INVOKABLE QString channelColumnName(int channel);
  1801. Q_INVOKABLE QString channelIndicatorText(int channel);
  1802. public slots:
  1803. void setTemperatureColumn(int tcol);
  1804. void setAnnotationColumn(int ncol);
  1805. void start();
  1806. void stop();
  1807. signals:
  1808. void annotation(QString note,int tcol,int ncol);
  1809. void triggerStartBatch();
  1810. void triggerStopBatch();
  1811. void deviceStopRequested();
  1812. private:
  1813. QVariantMap deviceSettings;
  1814. QString deviceScript;
  1815. QList<Channel*> channelList;
  1816. QList<bool> hiddenState;
  1817. QList<Units::Unit> channelUnits;
  1818. QList<QString> columnNames;
  1819. QList<QString> indicatorTexts;
  1820. QList<QVariantMap> channelSettings;
  1821. int annotationTemperatureColumn;
  1822. int annotationNoteColumn;
  1823. QScriptEngine*scriptengine;
  1824. };
  1825. /*:888*//*913:*/
  1826. #line 11 "./phidgets.w"
  1827. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1828. {
  1829. Q_OBJECT
  1830. public:
  1831. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1832. const QModelIndex&index);
  1833. private slots:
  1834. void addChannel();
  1835. void updateRate(int ms);
  1836. };
  1837. /*:913*//*917:*/
  1838. #line 82 "./phidgets.w"
  1839. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1840. {
  1841. Q_OBJECT
  1842. public:
  1843. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1844. const QModelIndex&index);
  1845. private slots:
  1846. void updateColumnName(const QString&value);
  1847. void updateHidden(bool hidden);
  1848. void updateTC(int index);
  1849. void updateChannel(int channel);
  1850. private:
  1851. QComboBox*tcType;
  1852. };
  1853. /*:917*//*922:*/
  1854. #line 213 "./phidgets.w"
  1855. class PhidgetsTemperatureSensor:public QObject
  1856. {
  1857. Q_OBJECT
  1858. public:
  1859. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1860. Q_INVOKABLE int channelCount();
  1861. Channel*getChannel(int channel);
  1862. Q_INVOKABLE bool isChannelHidden(int channel);
  1863. Q_INVOKABLE QString channelColumnName(int channel);
  1864. Q_INVOKABLE QString channelIndicatorText(int channel);
  1865. public slots:
  1866. void start();
  1867. void stop();
  1868. private slots:
  1869. void getMeasurements();
  1870. private:
  1871. QList<int> channelIndices;
  1872. QList<int> tctypes;
  1873. QList<Channel*> channelList;
  1874. QMap<int,Channel*> channelMap;
  1875. QList<bool> hiddenState;
  1876. QList<QString> columnNames;
  1877. QList<QString> indicatorTexts;
  1878. QLibrary driver;
  1879. QTimer sampleTimer;
  1880. void*device;
  1881. /*926:*/
  1882. #line 349 "./phidgets.w"
  1883. #ifdef _WIN32
  1884. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  1885. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  1886. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  1887. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1888. #else
  1889. typedef int(*PhidgetHandleOnly)(void*);
  1890. typedef int(*PhidgetHandleInt)(void*,int);
  1891. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1892. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1893. #endif
  1894. PhidgetHandleOnly createDevice;
  1895. PhidgetHandleInt openDevice;
  1896. PhidgetHandleInt waitForOpen;
  1897. PhidgetHandleIntInt setTCType;
  1898. PhidgetHandleIntDoubleOut getTemperature;
  1899. PhidgetHandleOnly closeDevice;
  1900. PhidgetHandleOnly deleteDevice;
  1901. /*:926*/
  1902. #line 240 "./phidgets.w"
  1903. };
  1904. /*:922*//*935:*/
  1905. #line 19361 "./typica.w"
  1906. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1907. {
  1908. Q_OBJECT
  1909. public:
  1910. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1911. const QModelIndex&index);
  1912. private slots:
  1913. void updateSourceColumn(const QString&source);
  1914. void updateDestinationColumn(const QString&dest);
  1915. void updateKnots();
  1916. private:
  1917. SaltModel*tablemodel;
  1918. };
  1919. /*:935*//*941:*/
  1920. #line 19491 "./typica.w"
  1921. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  1922. {
  1923. Q_OBJECT
  1924. public:
  1925. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  1926. const QModelIndex&index);
  1927. private slots:
  1928. void updateResetTime(QTime time);
  1929. };
  1930. /*:941*//*945:*/
  1931. #line 19557 "./typica.w"
  1932. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1933. {
  1934. Q_OBJECT
  1935. public:
  1936. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1937. private slots:
  1938. void updateStartButtonText(const QString&text);
  1939. void updateStopButtonText(const QString&text);
  1940. void updateStartColumnName(const QString&text);
  1941. void updateStopColumnName(const QString&text);
  1942. void updateStartValue(const QString&text);
  1943. void updateStopValue(const QString&text);
  1944. void updateStartTrigger(int option);
  1945. void updateStopTrigger(int option);
  1946. };
  1947. /*:945*//*950:*/
  1948. #line 19809 "./typica.w"
  1949. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1950. {
  1951. Q_OBJECT
  1952. public:
  1953. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  1954. const QModelIndex&index);
  1955. private slots:
  1956. void updateColumnName(const QString&text);
  1957. void updateRangeData();
  1958. private:
  1959. SaltModel*tablemodel;
  1960. };
  1961. /*:950*//*955:*/
  1962. #line 19911 "./typica.w"
  1963. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1964. {
  1965. Q_OBJECT
  1966. public:
  1967. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1968. private slots:
  1969. void updateMatchingColumn(const QString&column);
  1970. void updateTemperature();
  1971. private:
  1972. QDoubleSpinBox*temperatureValue;
  1973. QComboBox*unitSelector;
  1974. };
  1975. /*:955*//*959:*/
  1976. #line 16 "./rate.w"
  1977. class RateOfChange:public QObject
  1978. {
  1979. Q_OBJECT
  1980. public:
  1981. RateOfChange(int cachetime= 1,int scaletime= 1);
  1982. public slots:
  1983. void newMeasurement(Measurement measure);
  1984. void setCacheTime(int seconds);
  1985. void setScaleTime(int seconds);
  1986. signals:
  1987. void newData(Measurement measure);
  1988. private:
  1989. int ct;
  1990. int st;
  1991. QList<Measurement> cache;
  1992. };
  1993. /*:959*//*967:*/
  1994. #line 177 "./rate.w"
  1995. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  1996. {
  1997. Q_OBJECT
  1998. public:
  1999. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2000. private slots:
  2001. void updateColumn(const QString&column);
  2002. void updateCacheTime(const QString&seconds);
  2003. void updateScaleTime(const QString&seconds);
  2004. };
  2005. /*:967*//*973:*/
  2006. #line 19 "./dataqsdk.w"
  2007. class DataqSdkDeviceImplementation;
  2008. class DataqSdkDevice:public QObject
  2009. {
  2010. Q_OBJECT
  2011. DataqSdkDeviceImplementation*imp;
  2012. private slots:
  2013. void threadFinished();
  2014. public:
  2015. DataqSdkDevice(QString device);
  2016. ~DataqSdkDevice();
  2017. Channel*newChannel(Units::Unit scale);
  2018. Q_INVOKABLE void setClockRate(double Hz);
  2019. Q_INVOKABLE void start();
  2020. static QStringList detectPorts();
  2021. static QStringList detectHardware();
  2022. };
  2023. /*:973*//*974:*/
  2024. #line 49 "./dataqsdk.w"
  2025. class DataqSdkDeviceImplementation:public QThread
  2026. {
  2027. Q_OBJECT
  2028. public:
  2029. DataqSdkDeviceImplementation();
  2030. ~DataqSdkDeviceImplementation();
  2031. void run();
  2032. /*975:*/
  2033. #line 70 "./dataqsdk.w"
  2034. typedef struct di_inlist_struct{
  2035. unsigned short chan;
  2036. unsigned short diff;
  2037. unsigned short gain;
  2038. unsigned short unipolar;
  2039. unsigned short dig_out_enable;
  2040. unsigned short dig_out;
  2041. unsigned short ave;
  2042. unsigned short counter;
  2043. }DI_INLIST_STRUCT;
  2044. typedef int(PASCAL*FPDIOPEN)(unsigned);
  2045. typedef int(PASCAL*FPDICLOSE)(void);
  2046. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  2047. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  2048. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  2049. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  2050. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  2051. typedef int(PASCAL*FPDISTARTSCAN)(void);
  2052. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  2053. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  2054. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  2055. typedef int(PASCAL*FPDISTOPSCAN)(void);
  2056. FPDIOPEN di_open;
  2057. FPDICLOSE di_close;
  2058. FPDISAMPLERATE di_sample_rate;
  2059. FPDIMAXIMUMRATE di_maximum_rate;
  2060. FPDILISTLENGTH di_list_length;
  2061. FPDIINLIST di_inlist;
  2062. FPDIBUFFERALLOC di_buffer_alloc;
  2063. FPDISTARTSCAN di_start_scan;
  2064. FPDISTATUSREAD di_status_read;
  2065. FPDIBUFFERSTATUS di_buffer_status;
  2066. FPDIBURSTRATE di_burst_rate;
  2067. FPDISTOPSCAN di_stop_scan;
  2068. /*:975*/
  2069. #line 57 "./dataqsdk.w"
  2070. /*977:*/
  2071. #line 134 "./dataqsdk.w"
  2072. bool isOpen;
  2073. double sampleRate;
  2074. long oversample;
  2075. long burstDivisor;
  2076. QString device;
  2077. unsigned deviceNumber;
  2078. QVector<Channel*> channelMap;
  2079. int error;
  2080. int channels;
  2081. bool ready;
  2082. QLibrary*driver;
  2083. QVector<Units::Unit> unitMap;
  2084. int*input_buffer;
  2085. QTimer*eventClock;
  2086. QMultiMap<int,double> smoother;
  2087. /*:977*/
  2088. #line 58 "./dataqsdk.w"
  2089. public slots:
  2090. void measure();
  2091. private:
  2092. qint16*buffer;
  2093. };
  2094. /*:974*//*994:*/
  2095. #line 663 "./dataqsdk.w"
  2096. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2097. {
  2098. Q_OBJECT
  2099. public:
  2100. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2101. const QModelIndex&index);
  2102. private slots:
  2103. void updateAutoSelect(bool automatic);
  2104. void updateDeviceNumber(int deviceNumber);
  2105. void updatePort(QString portId);
  2106. void addChannel();
  2107. private:
  2108. QStackedWidget*deviceIdStack;
  2109. };
  2110. /*:994*//*999:*/
  2111. #line 808 "./dataqsdk.w"
  2112. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2113. {
  2114. Q_OBJECT
  2115. public:
  2116. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2117. const QModelIndex&index);
  2118. private slots:
  2119. void updateUnits(const QString&unit);
  2120. void updateColumnName(const QString&value);
  2121. void updateMeasuredLower(const QString&value);
  2122. void updateMeasuredUpper(const QString&value);
  2123. void updateMappedLower(const QString&value);
  2124. void updateMappedUpper(const QString&value);
  2125. void updateClosedInterval(bool closed);
  2126. void updateSmoothingEnabled(bool enabled);
  2127. void updateSensitivity(const QString&value);
  2128. void startCalibration();
  2129. void stopCalibration();
  2130. void resetCalibration();
  2131. void updateInput(Measurement measure);
  2132. void updateOutput(Measurement measure);
  2133. void updateHidden(bool hidden);
  2134. private:
  2135. QPushButton*startButton;
  2136. QPushButton*resetButton;
  2137. QPushButton*stopButton;
  2138. /*1004:*/
  2139. #line 1098 "./dataqsdk.w"
  2140. bool autoSelect;
  2141. QString deviceID;
  2142. unsigned int channelOfInterest;
  2143. /*:1004*/
  2144. #line 835 "./dataqsdk.w"
  2145. DataqSdkDevice*calibrationDevice;
  2146. LinearCalibrator*calibrator;
  2147. QLineEdit*currentMeasurement;
  2148. QLineEdit*minimumMeasurement;
  2149. QLineEdit*maximumMeasurement;
  2150. QLineEdit*averageMeasurement;
  2151. QLineEdit*currentMapped;
  2152. QLineEdit*minimumMapped;
  2153. QLineEdit*maximumMapped;
  2154. QLineEdit*averageMapped;
  2155. int rmCount;
  2156. int cmCount;
  2157. double rmin;
  2158. double rmax;
  2159. double rmean;
  2160. double cmin;
  2161. double cmax;
  2162. double cmean;
  2163. };
  2164. /*:999*//*1026:*/
  2165. #line 273 "./scales.w"
  2166. Q_DECLARE_METATYPE(BaudRateType)
  2167. Q_DECLARE_METATYPE(DataBitsType)
  2168. Q_DECLARE_METATYPE(ParityType)
  2169. Q_DECLARE_METATYPE(StopBitsType)
  2170. Q_DECLARE_METATYPE(FlowType)
  2171. /*:1026*//*1033:*/
  2172. #line 396 "./scales.w"
  2173. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2174. {
  2175. Q_OBJECT
  2176. public:
  2177. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2178. const QModelIndex&index);
  2179. private slots:
  2180. void updatePort(const QString&newPort);
  2181. void updateBaudRate(const QString&rate);
  2182. void updateParity(int index);
  2183. void updateFlowControl(int index);
  2184. void updateStopBits(int index);
  2185. void updateWeighCommand(const QString&command);
  2186. void updateCommandTerminator(const QString&terminator);
  2187. private:
  2188. PortSelector*port;
  2189. BaudSelector*baud;
  2190. ParitySelector*parity;
  2191. FlowSelector*flow;
  2192. StopSelector*stop;
  2193. QLineEdit*weighcommand;
  2194. QComboBox*commandterminator;
  2195. };
  2196. /*:1033*//*1038:*/
  2197. #line 14 "./valueannotation.w"
  2198. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2199. {
  2200. Q_OBJECT
  2201. public:
  2202. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2203. const QModelIndex&index);
  2204. private slots:
  2205. void updateSourceColumn(const QString&source);
  2206. void updateAnnotations();
  2207. void updateStart(bool noteOnStart);
  2208. private:
  2209. SaltModel*tablemodel;
  2210. };
  2211. /*:1038*//*1046:*/
  2212. #line 165 "./valueannotation.w"
  2213. class ValueAnnotation:public QObject
  2214. {
  2215. Q_OBJECT
  2216. public:
  2217. ValueAnnotation();
  2218. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2219. public slots:
  2220. void newMeasurement(Measurement measure);
  2221. void annotate();
  2222. void setAnnotationColumn(int column);
  2223. void setTemperatureColumn(int column);
  2224. void setTolerance(double epsilon);
  2225. signals:
  2226. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2227. private:
  2228. int lastIndex;
  2229. int annotationColumn;
  2230. int measurementColumn;
  2231. QList<double> values;
  2232. QStringList annotations;
  2233. double tolerance;
  2234. };
  2235. /*:1046*//*1055:*/
  2236. #line 14 "./thresholdannotation.w"
  2237. class ThresholdAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2238. {
  2239. Q_OBJECT
  2240. public:
  2241. Q_INVOKABLE ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  2242. const QModelIndex&index);
  2243. private slots:
  2244. void updateSourceColumn(const QString&source);
  2245. void updateThreshold(double value);
  2246. void updateDirection(int index);
  2247. void updateAnnotation(const QString&note);
  2248. };
  2249. /*:1055*//*1060:*/
  2250. #line 127 "./thresholdannotation.w"
  2251. class Annotator:public QObject
  2252. {
  2253. Q_OBJECT
  2254. QString note;
  2255. int tc;
  2256. int ac;
  2257. QTimer t;
  2258. public:
  2259. Annotator(const QString&text);
  2260. public slots:
  2261. void setAnnotation(const QString&annotation);
  2262. void setTemperatureColumn(int tempcolumn);
  2263. void setAnnotationColumn(int annotationcolumn);
  2264. void annotate();
  2265. private slots:
  2266. void catchTimer();
  2267. signals:
  2268. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2269. };
  2270. /*:1060*/
  2271. #line 526 "./typica.w"
  2272. /*12:*/
  2273. #line 811 "./typica.w"
  2274. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2275. /*:12*//*14:*/
  2276. #line 826 "./typica.w"
  2277. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2278. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2279. /*:14*//*16:*/
  2280. #line 851 "./typica.w"
  2281. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2282. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2283. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2284. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2285. QScriptEngine*engine);
  2286. /*:16*//*20:*/
  2287. #line 941 "./typica.w"
  2288. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2289. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2290. /*:20*//*30:*/
  2291. #line 1142 "./typica.w"
  2292. QScriptValue constructQMainWindow(QScriptContext*context,
  2293. QScriptEngine*engine);
  2294. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2295. QScriptEngine*engine);
  2296. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2297. QScriptEngine*engine);
  2298. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2299. /*:30*//*35:*/
  2300. #line 1241 "./typica.w"
  2301. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2302. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2303. /*:35*//*38:*/
  2304. #line 1286 "./typica.w"
  2305. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2306. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2307. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2308. /*:38*//*41:*/
  2309. #line 1352 "./typica.w"
  2310. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2311. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2312. /*:41*//*44:*/
  2313. #line 1385 "./typica.w"
  2314. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2315. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2316. /*:44*//*47:*/
  2317. #line 1423 "./typica.w"
  2318. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2319. QScriptValue constructQSvgWidget(QScriptContext*context,
  2320. QScriptEngine*engine);
  2321. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2322. QScriptEngine*engine);
  2323. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2324. QStack<QLayout*> *layoutStack);
  2325. /*:47*//*53:*/
  2326. #line 1510 "./typica.w"
  2327. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2328. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2329. /*:53*//*57:*/
  2330. #line 1549 "./typica.w"
  2331. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2332. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2333. QScriptEngine*engine);
  2334. QScriptValue QSplitter_saveState(QScriptContext*context,
  2335. QScriptEngine*engine);
  2336. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2337. QScriptEngine*engine);
  2338. QScriptValue QSplitter_count(QScriptContext*context,
  2339. QScriptEngine*engine);
  2340. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2341. /*:57*//*63:*/
  2342. #line 1688 "./typica.w"
  2343. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2344. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2345. /*:63*//*65:*/
  2346. #line 1743 "./typica.w"
  2347. QScriptValue constructQBoxLayout(QScriptContext*context,
  2348. QScriptEngine*engine);
  2349. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2350. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2351. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2352. /*:65*//*69:*/
  2353. #line 1856 "./typica.w"
  2354. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2355. QScriptValue QAction_setShortcut(QScriptContext*context,
  2356. QScriptEngine*engine);
  2357. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2358. /*:69*//*72:*/
  2359. #line 1912 "./typica.w"
  2360. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2361. QScriptEngine*engine);
  2362. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2363. QScriptEngine*engine);
  2364. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2365. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2366. /*:72*//*77:*/
  2367. #line 2023 "./typica.w"
  2368. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2369. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2370. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2371. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2372. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2373. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2374. QScriptValue QIODevice_readToString(QScriptContext*context,
  2375. QScriptEngine*engine);
  2376. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2377. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2378. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2379. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2380. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2381. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2382. /*:77*//*88:*/
  2383. #line 2249 "./typica.w"
  2384. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2385. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2386. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2387. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2388. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2389. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2390. /*:88*//*96:*/
  2391. #line 2367 "./typica.w"
  2392. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2393. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2394. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2395. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2396. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2397. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2398. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2399. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2400. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2401. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2402. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2403. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2404. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2405. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2406. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2407. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2408. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2409. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2410. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2411. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2412. /*:96*//*109:*/
  2413. #line 2641 "./typica.w"
  2414. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2415. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2416. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2417. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2418. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2419. /*:109*//*112:*/
  2420. #line 2746 "./typica.w"
  2421. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2422. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2423. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2424. /*:112*//*115:*/
  2425. #line 2791 "./typica.w"
  2426. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2427. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2428. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2429. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2430. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2431. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2432. /*:115*//*121:*/
  2433. #line 2873 "./typica.w"
  2434. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2435. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2436. QScriptEngine*engine);
  2437. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2438. QScriptEngine*engine);
  2439. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2440. QScriptEngine*engine);
  2441. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2442. QScriptEngine*engine);
  2443. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2444. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2445. QScriptEngine*engine);
  2446. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2447. QScriptEngine*engine);
  2448. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2449. QScriptEngine*engine);
  2450. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2451. QScriptEngine*engine);
  2452. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2453. QScriptEngine*engine);
  2454. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2455. QScriptEngine*engine);
  2456. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2457. QScriptEngine*engine);
  2458. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2459. QScriptEngine*engine);
  2460. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2461. /*:121*//*130:*/
  2462. #line 3091 "./typica.w"
  2463. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2464. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2465. QScriptValue XmlReader_attribute(QScriptContext*context,
  2466. QScriptEngine*engine);
  2467. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2468. QScriptEngine*engine);
  2469. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2470. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2471. QScriptEngine*engine);
  2472. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2473. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2474. QScriptEngine*engine);
  2475. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2476. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2477. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2478. /*:130*//*137:*/
  2479. #line 3226 "./typica.w"
  2480. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2481. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2482. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2483. /*:137*//*141:*/
  2484. #line 3308 "./typica.w"
  2485. QScriptValue constructQLCDNumber(QScriptContext*context,
  2486. QScriptEngine*engine);
  2487. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2488. /*:141*//*144:*/
  2489. #line 3346 "./typica.w"
  2490. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2491. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2492. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2493. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2494. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2495. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2496. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2497. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2498. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2499. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2500. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2501. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2502. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2503. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2504. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2505. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2506. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2507. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2508. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2509. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2510. /*:144*//*160:*/
  2511. #line 3824 "./typica.w"
  2512. void setQAbstractScrollAreaProperties(QScriptValue value,
  2513. QScriptEngine*engine);
  2514. /*:160*//*162:*/
  2515. #line 3839 "./typica.w"
  2516. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2517. /*:162*//*164:*/
  2518. #line 3852 "./typica.w"
  2519. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2520. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2521. /*:164*//*166:*/
  2522. #line 3876 "./typica.w"
  2523. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2524. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2525. QScriptValue constructQPushButton(QScriptContext*context,
  2526. QScriptEngine*engine);
  2527. /*:166*//*173:*/
  2528. #line 3975 "./typica.w"
  2529. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2530. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2531. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2532. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2533. QScriptEngine*engine);
  2534. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2535. QScriptEngine*engine);
  2536. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2537. QScriptEngine*engine);
  2538. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2539. QScriptEngine*engine);
  2540. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2541. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2542. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2543. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2544. /*:173*//*180:*/
  2545. #line 4146 "./typica.w"
  2546. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2547. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2548. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2549. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2550. QScriptValue annotationFromRecord(QScriptContext*context,
  2551. QScriptEngine*engine);
  2552. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2553. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2554. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2555. /*:180*//*193:*/
  2556. #line 4478 "./typica.w"
  2557. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2558. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2559. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2560. QStack<QLayout*> *layoutStack);
  2561. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2562. QStack<QLayout*> *layoutStack);
  2563. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2564. QStack<QLayout*> *layoutStack);
  2565. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2566. QStack<QLayout*> *layoutStack);
  2567. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2568. QStack<QLayout*> *layoutStack);
  2569. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2570. QStack<QLayout*> *layoutStack);
  2571. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2572. QStack<QLayout*> *layoutStack);
  2573. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2574. QStack<QLayout*> *layoutStack);
  2575. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2576. QStack<QLayout*> *layoutStack);
  2577. void addTemperatureDisplayToSplitter(QDomElement element,
  2578. QStack<QWidget*> *widgetStack,
  2579. QStack<QLayout*> *layoutStack);
  2580. void addTemperatureDisplayToLayout(QDomElement element,
  2581. QStack<QWidget*> *widgetStack,
  2582. QStack<QLayout*> *layoutStack);
  2583. void addTimerDisplayToSplitter(QDomElement element,
  2584. QStack<QWidget*> *widgetStack,
  2585. QStack<QLayout*> *layoutStack);
  2586. void addTimerDisplayToLayout(QDomElement element,
  2587. QStack<QWidget*> *widgetStack,
  2588. QStack<QLayout*> *layoutStack);
  2589. void addDecorationToSplitter(QDomElement element,
  2590. QStack<QWidget*> *widgetStack,
  2591. QStack<QLayout*> *layoutStack);
  2592. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2593. QStack<QLayout*> *layoutStack);
  2594. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2595. QStack<QLayout*> *layoutStack);
  2596. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2597. QStack<QLayout*> *layoutStack);
  2598. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2599. QStack<QLayout*> *layoutStack);
  2600. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2601. QStack<QLayout*> *layoutStack);
  2602. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2603. QStack<QLayout*> *layoutStack);
  2604. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2605. QStack<QLayout*> *layoutStack);
  2606. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2607. QStack<QLayout*> *layoutStack);
  2608. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2609. QStack<QLayout*> *layoutStack);
  2610. void addSqlQueryViewToLayout(QDomElement element,
  2611. QStack<QWidget*> *widgetStack,
  2612. QStack<QLayout*> *layoutStack);
  2613. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2614. QStack<QLayout*> *layoutStack);
  2615. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2616. QStack<QLayout*> *layoutStack);
  2617. /*:193*//*257:*/
  2618. #line 6160 "./typica.w"
  2619. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2620. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2621. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2622. QScriptEngine*engine);
  2623. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2624. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2625. QScriptEngine*engine);
  2626. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2627. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  2628. /*:257*//*258:*/
  2629. #line 6176 "./typica.w"
  2630. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2631. /*:258*//*262:*/
  2632. #line 6315 "./typica.w"
  2633. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2634. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2635. QScriptEngine*engine);
  2636. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2637. QScriptEngine*engine);
  2638. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2639. QScriptEngine*engine);
  2640. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2641. QScriptEngine*engine);
  2642. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2643. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2644. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2645. QScriptEngine*engine);
  2646. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2647. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2648. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2649. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2650. /*:262*//*272:*/
  2651. #line 6531 "./typica.w"
  2652. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2653. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2654. QScriptValue QComboBox_currentData(QScriptContext*context,
  2655. QScriptEngine*engine);
  2656. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2657. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2658. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2659. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2660. /*:272*//*284:*/
  2661. #line 379 "./units.w"
  2662. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2663. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2664. QScriptEngine*engine);
  2665. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2666. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2667. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2668. /*:284*//*288:*/
  2669. #line 443 "./units.w"
  2670. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2671. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2672. /*:288*//*297:*/
  2673. #line 133 "./measurement.w"
  2674. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2675. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2676. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2677. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2678. /*:297*//*317:*/
  2679. #line 7166 "./typica.w"
  2680. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2681. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2682. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2683. /*:317*//*326:*/
  2684. #line 7371 "./typica.w"
  2685. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2686. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2687. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2688. /*:326*//*331:*/
  2689. #line 7472 "./typica.w"
  2690. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2691. /*:331*//*337:*/
  2692. #line 7654 "./typica.w"
  2693. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2694. QScriptEngine*engine);
  2695. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2696. /*:337*//*342:*/
  2697. #line 7794 "./typica.w"
  2698. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2699. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2700. /*:342*//*352:*/
  2701. #line 7999 "./typica.w"
  2702. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2703. QScriptEngine*engine);
  2704. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2705. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2706. QScriptEngine*engine);
  2707. /*:352*//*360:*/
  2708. #line 8158 "./typica.w"
  2709. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2710. QScriptEngine*engine);
  2711. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2712. QScriptEngine*engine);
  2713. /*:360*//*365:*/
  2714. #line 8281 "./typica.w"
  2715. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2716. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2717. /*:365*//*370:*/
  2718. #line 8379 "./typica.w"
  2719. QScriptValue constructZeroEmitter(QScriptContext*context,
  2720. QScriptEngine*engine);
  2721. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2722. /*:370*//*375:*/
  2723. #line 8458 "./typica.w"
  2724. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2725. QScriptEngine*engine);
  2726. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2727. /*:375*//*392:*/
  2728. #line 8922 "./typica.w"
  2729. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2730. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2731. /*:392*//*415:*/
  2732. #line 9549 "./typica.w"
  2733. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2734. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2735. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2736. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2737. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2738. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2739. QScriptEngine*engine);
  2740. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2741. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2742. QScriptEngine*engnie);
  2743. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2744. QScriptEngine*engine);
  2745. /*:415*//*453:*/
  2746. #line 10506 "./typica.w"
  2747. QScriptValue constructAnnotationButton(QScriptContext*context,
  2748. QScriptEngine*engine);
  2749. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2750. /*:453*//*461:*/
  2751. #line 10646 "./typica.w"
  2752. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2753. QScriptEngine*engine);
  2754. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2755. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2756. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2757. /*:461*//*482:*/
  2758. #line 11072 "./typica.w"
  2759. QScriptValue constructTimerDisplay(QScriptContext*context,
  2760. QScriptEngine*engine);
  2761. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2762. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  2763. /*:482*//*510:*/
  2764. #line 11597 "./typica.w"
  2765. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2766. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2767. QScriptEngine*engine);
  2768. /*:510*//*523:*/
  2769. #line 11880 "./typica.w"
  2770. QScriptValue constructLogEditWindow(QScriptContext*context,
  2771. QScriptEngine*engine);
  2772. /*:523*//*542:*/
  2773. #line 12407 "./typica.w"
  2774. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2775. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2776. /*:542*//*560:*/
  2777. #line 189 "./webview.w"
  2778. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2779. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2780. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2781. QStack<QLayout*> *layoutStack);
  2782. /*:560*//*563:*/
  2783. #line 219 "./webview.w"
  2784. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2785. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2786. /*:563*//*567:*/
  2787. #line 277 "./webview.w"
  2788. QScriptValue constructWebElement(QScriptContext*context,
  2789. QScriptEngine*engine);
  2790. /*:567*//*636:*/
  2791. #line 13754 "./typica.w"
  2792. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2793. QScriptValue constructSqlQueryView(QScriptContext*context,
  2794. QScriptEngine*engine);
  2795. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2796. QScriptEngine*engine);
  2797. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2798. QScriptEngine*engine);
  2799. /*:636*//*646:*/
  2800. #line 13993 "./typica.w"
  2801. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2802. QStack<QLayout*> *layoutStack);
  2803. /*:646*//*662:*/
  2804. #line 14278 "./typica.w"
  2805. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2806. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2807. /*:662*//*684:*/
  2808. #line 482 "./daterangeselector.w"
  2809. void addDateRangeToLayout(QDomElement element,
  2810. QStack<QWidget*> *widgetStack,
  2811. QStack<QLayout*> *layoutStack);
  2812. /*:684*//*693:*/
  2813. #line 14475 "./typica.w"
  2814. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2815. QStack<QLayout*> *layoutStack);
  2816. /*:693*//*714:*/
  2817. #line 15059 "./typica.w"
  2818. void addScaleControlToLayout(QDomElement element,
  2819. QStack<QWidget*> *widgetStack,
  2820. QStack<QLayout*> *layoutStack);
  2821. void addIntensityControlToLayout(QDomElement element,
  2822. QStack<QWidget*> *widgetStack,
  2823. QStack<QLayout*> *layoutStack);
  2824. /*:714*//*740:*/
  2825. #line 15645 "./typica.w"
  2826. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2827. QScriptEngine*engine);
  2828. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2829. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2830. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2831. QScriptEngine*engine);
  2832. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2833. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2834. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2835. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2836. /*:740*//*746:*/
  2837. #line 15787 "./typica.w"
  2838. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2839. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2840. /*:746*//*762:*/
  2841. #line 16085 "./typica.w"
  2842. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2843. QScriptEngine*engine);
  2844. /*:762*//*833:*/
  2845. #line 42 "./settings.w"
  2846. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2847. /*:833*//*857:*/
  2848. #line 18728 "./typica.w"
  2849. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2850. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2851. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2852. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2853. /*:857*//*875:*/
  2854. #line 638 "./modbus.w"
  2855. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine);
  2856. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine);
  2857. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine);
  2858. /*:875*//*889:*/
  2859. #line 345 "./unsupportedserial.w"
  2860. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  2861. /*:889*//*895:*/
  2862. #line 425 "./unsupportedserial.w"
  2863. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  2864. /*:895*//*901:*/
  2865. #line 617 "./unsupportedserial.w"
  2866. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  2867. /*:901*//*905:*/
  2868. #line 651 "./unsupportedserial.w"
  2869. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  2870. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  2871. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  2872. /*:905*//*932:*/
  2873. #line 457 "./phidgets.w"
  2874. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  2875. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  2876. /*:932*//*964:*/
  2877. #line 138 "./rate.w"
  2878. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2879. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2880. /*:964*//*989:*/
  2881. #line 597 "./dataqsdk.w"
  2882. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2883. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2884. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2885. /*:989*//*1016:*/
  2886. #line 67 "./scales.w"
  2887. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2888. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2889. /*:1016*//*1024:*/
  2890. #line 259 "./scales.w"
  2891. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2892. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2893. /*:1024*//*1027:*/
  2894. #line 284 "./scales.w"
  2895. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2896. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2897. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2898. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2899. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2900. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2901. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2902. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2903. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2904. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2905. /*:1027*//*1052:*/
  2906. #line 265 "./valueannotation.w"
  2907. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2908. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2909. /*:1052*//*1063:*/
  2910. #line 194 "./thresholdannotation.w"
  2911. QScriptValue constructAnnotator(QScriptContext*context,
  2912. QScriptEngine*engine);
  2913. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine);
  2914. /*:1063*/
  2915. #line 527 "./typica.w"
  2916. /*616:*/
  2917. #line 13403 "./typica.w"
  2918. void messageFileOutput(QtMsgType type,const char*msg);
  2919. /*:616*/
  2920. #line 528 "./typica.w"
  2921. /*4:*/
  2922. #line 537 "./typica.w"
  2923. /*754:*/
  2924. #line 15908 "./typica.w"
  2925. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2926. const QString&driver,QObject*parent):
  2927. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2928. {
  2929. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2930. }
  2931. void NodeInserter::onTriggered()
  2932. {
  2933. emit triggered(defaultNodeName,driverString);
  2934. }
  2935. /*:754*/
  2936. #line 538 "./typica.w"
  2937. /*293:*/
  2938. #line 40 "./measurement.w"
  2939. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2940. {
  2941. insert("measurement",temperature);
  2942. insert("time",time);
  2943. insert("unit",sc);
  2944. }
  2945. Measurement::Measurement(double temperature)
  2946. {
  2947. insert("measurement",temperature);
  2948. insert("time",QTime::currentTime());
  2949. insert("unit",Units::Fahrenheit);
  2950. }
  2951. void Measurement::setTemperature(double temperature)
  2952. {
  2953. insert("measurement",temperature);
  2954. }
  2955. void Measurement::setTime(QTime time)
  2956. {
  2957. insert("time",time);
  2958. }
  2959. void Measurement::setUnit(Units::Unit scale)
  2960. {
  2961. insert("unit",scale);
  2962. }
  2963. double Measurement::temperature()const
  2964. {
  2965. return value("measurement").toDouble();
  2966. }
  2967. QTime Measurement::time()const
  2968. {
  2969. return value("time").toTime();
  2970. }
  2971. Units::Unit Measurement::scale()const
  2972. {
  2973. return(Units::Unit)(value("unit").toInt());
  2974. }
  2975. /*:293*//*294:*/
  2976. #line 88 "./measurement.w"
  2977. Measurement Measurement::toFahrenheit()
  2978. {
  2979. return Measurement(Units::convertTemperature(this->temperature(),
  2980. this->scale(),Units::Fahrenheit),
  2981. this->time(),Units::Fahrenheit);
  2982. }
  2983. Measurement Measurement::toCelsius()
  2984. {
  2985. return Measurement(Units::convertTemperature(this->temperature(),
  2986. this->scale(),Units::Celsius),
  2987. this->time(),Units::Celsius);
  2988. }
  2989. Measurement Measurement::toKelvin()
  2990. {
  2991. return Measurement(Units::convertTemperature(this->temperature(),
  2992. this->scale(),Units::Kelvin),
  2993. this->time(),Units::Kelvin);
  2994. }
  2995. Measurement Measurement::toRankine()
  2996. {
  2997. return Measurement(Units::convertTemperature(this->temperature(),
  2998. this->scale(),Units::Rankine),
  2999. this->time(),Units::Rankine);
  3000. }
  3001. /*:294*/
  3002. #line 539 "./typica.w"
  3003. /*307:*/
  3004. #line 6771 "./typica.w"
  3005. void DAQImplementation::measure()
  3006. {
  3007. int samplesRead= 0;
  3008. double buffer[channels];
  3009. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  3010. (unsigned long)(0),buffer,(unsigned long)(channels),
  3011. &samplesRead,(signed long)(0));
  3012. if(error)
  3013. {
  3014. ready= false;
  3015. }
  3016. else
  3017. {
  3018. if(samplesRead)
  3019. {
  3020. QTime time= QTime::currentTime();
  3021. for(int i= 0;i<samplesRead;i++)
  3022. {
  3023. for(int j= 0;j<channels;j++)
  3024. {
  3025. double measuredValue= buffer[j+(i*channels)];
  3026. Measurement measure(measuredValue,time,
  3027. unitMap[j]);
  3028. channelMap[j]->input(measure);
  3029. }
  3030. }
  3031. }
  3032. }
  3033. }
  3034. /*:307*//*308:*/
  3035. #line 6814 "./typica.w"
  3036. void DAQImplementation::run()
  3037. {
  3038. setPriority(QThread::TimeCriticalPriority);
  3039. while(ready)
  3040. {
  3041. measure();
  3042. }
  3043. }
  3044. /*:308*//*309:*/
  3045. #line 6830 "./typica.w"
  3046. void DAQ::threadFinished()
  3047. {
  3048. if(imp->error)
  3049. {
  3050. /*310:*/
  3051. #line 6881 "./typica.w"
  3052. imp->ready= false;
  3053. QMessageBox warning;
  3054. warning.setStandardButtons(QMessageBox::Cancel);
  3055. warning.setIcon(QMessageBox::Warning);
  3056. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3057. unsigned long bytes= imp->errorInfo(NULL,0);
  3058. char string[bytes];
  3059. imp->errorInfo(string,bytes);
  3060. warning.setInformativeText(QString(string));
  3061. warning.setWindowTitle(QString(PROGRAM_NAME));
  3062. warning.exec();
  3063. /*:310*/
  3064. #line 6835 "./typica.w"
  3065. }
  3066. }
  3067. /*:309*//*311:*/
  3068. #line 6906 "./typica.w"
  3069. void DAQ::start()
  3070. {
  3071. if(imp->ready)
  3072. {
  3073. imp->error= imp->startTask(imp->handle);
  3074. if(imp->error)
  3075. {
  3076. /*310:*/
  3077. #line 6881 "./typica.w"
  3078. imp->ready= false;
  3079. QMessageBox warning;
  3080. warning.setStandardButtons(QMessageBox::Cancel);
  3081. warning.setIcon(QMessageBox::Warning);
  3082. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3083. unsigned long bytes= imp->errorInfo(NULL,0);
  3084. char string[bytes];
  3085. imp->errorInfo(string,bytes);
  3086. warning.setInformativeText(QString(string));
  3087. warning.setWindowTitle(QString(PROGRAM_NAME));
  3088. warning.exec();
  3089. /*:310*/
  3090. #line 6914 "./typica.w"
  3091. }
  3092. else
  3093. {
  3094. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3095. imp->start();
  3096. }
  3097. }
  3098. }
  3099. void DAQ::stop()
  3100. {
  3101. if(imp->useBase)
  3102. {
  3103. imp->ready= false;
  3104. imp->wait(ULONG_MAX);
  3105. imp->stopTask(imp->handle);
  3106. }
  3107. else
  3108. {
  3109. imp->ready= false;
  3110. imp->error= imp->stopTask(imp->handle);
  3111. if(imp->error)
  3112. {
  3113. /*310:*/
  3114. #line 6881 "./typica.w"
  3115. imp->ready= false;
  3116. QMessageBox warning;
  3117. warning.setStandardButtons(QMessageBox::Cancel);
  3118. warning.setIcon(QMessageBox::Warning);
  3119. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3120. unsigned long bytes= imp->errorInfo(NULL,0);
  3121. char string[bytes];
  3122. imp->errorInfo(string,bytes);
  3123. warning.setInformativeText(QString(string));
  3124. warning.setWindowTitle(QString(PROGRAM_NAME));
  3125. warning.exec();
  3126. /*:310*/
  3127. #line 6938 "./typica.w"
  3128. }
  3129. imp->error= imp->clearTask(imp->handle);
  3130. if(imp->error)
  3131. {
  3132. /*310:*/
  3133. #line 6881 "./typica.w"
  3134. imp->ready= false;
  3135. QMessageBox warning;
  3136. warning.setStandardButtons(QMessageBox::Cancel);
  3137. warning.setIcon(QMessageBox::Warning);
  3138. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3139. unsigned long bytes= imp->errorInfo(NULL,0);
  3140. char string[bytes];
  3141. imp->errorInfo(string,bytes);
  3142. warning.setInformativeText(QString(string));
  3143. warning.setWindowTitle(QString(PROGRAM_NAME));
  3144. warning.exec();
  3145. /*:310*/
  3146. #line 6943 "./typica.w"
  3147. }
  3148. }
  3149. }
  3150. /*:311*//*312:*/
  3151. #line 6953 "./typica.w"
  3152. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3153. {
  3154. imp->device= device;
  3155. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3156. if(imp->error)
  3157. {
  3158. /*310:*/
  3159. #line 6881 "./typica.w"
  3160. imp->ready= false;
  3161. QMessageBox warning;
  3162. warning.setStandardButtons(QMessageBox::Cancel);
  3163. warning.setIcon(QMessageBox::Warning);
  3164. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3165. unsigned long bytes= imp->errorInfo(NULL,0);
  3166. char string[bytes];
  3167. imp->errorInfo(string,bytes);
  3168. warning.setInformativeText(QString(string));
  3169. warning.setWindowTitle(QString(PROGRAM_NAME));
  3170. warning.exec();
  3171. /*:310*/
  3172. #line 6960 "./typica.w"
  3173. }
  3174. else
  3175. {
  3176. imp->ready= true;
  3177. }
  3178. }
  3179. /*:312*//*313:*/
  3180. #line 6974 "./typica.w"
  3181. Channel*DAQ::newChannel(int units,int thermocouple)
  3182. {
  3183. Channel*retval= new Channel();
  3184. imp->channelMap[imp->channels]= retval;
  3185. imp->unitMap[imp->channels]= (Units::Unit)units;
  3186. imp->channels++;
  3187. if(imp->ready)
  3188. {
  3189. if(imp->useBase)
  3190. {
  3191. imp->error= imp->createChannel(imp->handle,
  3192. QString("%1/ai%2").arg(imp->device).
  3193. arg(imp->channels-1).
  3194. toAscii().data(),
  3195. "",(double)(-1.0),(double)(100.0),
  3196. (signed long)(units),
  3197. (signed long)(thermocouple),
  3198. (signed long)(10200),(double)(0),
  3199. "");
  3200. }
  3201. else
  3202. {
  3203. imp->error= imp->createChannel(imp->handle,
  3204. QString("%1/ai%2").arg(imp->device).
  3205. arg(imp->channels-1).
  3206. toAscii().data(),
  3207. "",(double)(50.0),(double)(500.0),
  3208. (signed long)(units),
  3209. (signed long)(thermocouple),
  3210. (signed long)(10200),(double)(0),
  3211. "");
  3212. }
  3213. if(imp->error)
  3214. {
  3215. /*310:*/
  3216. #line 6881 "./typica.w"
  3217. imp->ready= false;
  3218. QMessageBox warning;
  3219. warning.setStandardButtons(QMessageBox::Cancel);
  3220. warning.setIcon(QMessageBox::Warning);
  3221. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3222. unsigned long bytes= imp->errorInfo(NULL,0);
  3223. char string[bytes];
  3224. imp->errorInfo(string,bytes);
  3225. warning.setInformativeText(QString(string));
  3226. warning.setWindowTitle(QString(PROGRAM_NAME));
  3227. warning.exec();
  3228. /*:310*/
  3229. #line 7009 "./typica.w"
  3230. }
  3231. }
  3232. return retval;
  3233. }
  3234. /*:313*//*314:*/
  3235. #line 7023 "./typica.w"
  3236. void DAQ::setClockRate(double Hz)
  3237. {
  3238. if(imp->ready)
  3239. {
  3240. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3241. (signed long)(10280),(signed long)(10123),
  3242. (unsigned long long)(1));
  3243. if(imp->error)
  3244. {
  3245. /*310:*/
  3246. #line 6881 "./typica.w"
  3247. imp->ready= false;
  3248. QMessageBox warning;
  3249. warning.setStandardButtons(QMessageBox::Cancel);
  3250. warning.setIcon(QMessageBox::Warning);
  3251. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3252. unsigned long bytes= imp->errorInfo(NULL,0);
  3253. char string[bytes];
  3254. imp->errorInfo(string,bytes);
  3255. warning.setInformativeText(QString(string));
  3256. warning.setWindowTitle(QString(PROGRAM_NAME));
  3257. warning.exec();
  3258. /*:310*/
  3259. #line 7033 "./typica.w"
  3260. }
  3261. }
  3262. }
  3263. /*:314*//*315:*/
  3264. #line 7043 "./typica.w"
  3265. DAQ::~DAQ()
  3266. {
  3267. if(imp->useBase)
  3268. {
  3269. imp->resetDevice(imp->device.toAscii().data());
  3270. imp->clearTask(imp->handle);
  3271. }
  3272. else
  3273. {
  3274. if(imp->ready)
  3275. {
  3276. imp->ready= false;
  3277. imp->wait(ULONG_MAX);
  3278. imp->stopTask(imp->handle);
  3279. imp->resetDevice(imp->device.toAscii().data());
  3280. imp->clearTask(imp->handle);
  3281. }
  3282. }
  3283. delete imp;
  3284. }
  3285. /*:315*//*316:*/
  3286. #line 7074 "./typica.w"
  3287. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3288. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3289. unitMap(4)
  3290. {
  3291. if(driverinfo=="nidaqmxbase")
  3292. {
  3293. useBase= true;
  3294. }
  3295. else
  3296. {
  3297. useBase= false;
  3298. }
  3299. if(useBase)
  3300. {
  3301. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3302. if(!driver.load())
  3303. {
  3304. driver.setFileName("nidaqmxbase");
  3305. if(!driver.load())
  3306. {
  3307. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3308. tr("Failed to find nidaqmxbase. Please install it."));
  3309. QApplication::quit();
  3310. }
  3311. }
  3312. }
  3313. else
  3314. {
  3315. driver.setFileName("nicaiu");
  3316. if(!driver.load())
  3317. {
  3318. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3319. tr("Failed to find nidaqmx. Please install it."));
  3320. QApplication::quit();
  3321. }
  3322. }
  3323. if(useBase)
  3324. {
  3325. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3326. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3327. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3328. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3329. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3330. ==0||
  3331. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3332. 0||
  3333. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3334. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3335. 0||
  3336. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3337. {
  3338. waitForMeasurement= NULL;
  3339. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3340. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3341. QApplication::quit();
  3342. }
  3343. }
  3344. else
  3345. {
  3346. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3347. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3348. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3349. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3350. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3351. ==0||
  3352. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3353. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3354. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3355. 0||
  3356. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3357. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3358. {
  3359. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3360. tr("Failed to link a required symbol in NI-DAQmx."));
  3361. QApplication::quit();
  3362. }
  3363. }
  3364. }
  3365. DAQImplementation::~DAQImplementation()
  3366. {
  3367. driver.unload();
  3368. }
  3369. /*:316*/
  3370. #line 540 "./typica.w"
  3371. /*978:*/
  3372. #line 197 "./dataqsdk.w"
  3373. void DataqSdkDeviceImplementation::measure()
  3374. {
  3375. unsigned count= channels*40;
  3376. di_status_read(buffer,count);
  3377. QTime time= QTime::currentTime();
  3378. for(unsigned int i= 0;i<count;i++)
  3379. {
  3380. buffer[i]= buffer[i]&0xFFFC;
  3381. }
  3382. QList<int> countList;
  3383. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3384. {
  3385. QList<double> channelBuffer;
  3386. for(unsigned int j= 0;j<40;j++)
  3387. {
  3388. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3389. if(i==0)
  3390. {
  3391. countList<<buffer[i+(channels*j)];
  3392. }
  3393. }
  3394. double value= 0.0;
  3395. for(unsigned int j= 0;j<40;j++)
  3396. {
  3397. value+= channelBuffer[j];
  3398. }
  3399. value/= 40.0;
  3400. if(i==0)
  3401. {
  3402. QList<double> smoothingList;
  3403. smoothingList<<value;
  3404. QList<int> smoothingKeys= smoother.uniqueKeys();
  3405. for(int j= 0;j<smoothingKeys.size();j++)
  3406. {
  3407. if(countList.contains(smoothingKeys[j]))
  3408. {
  3409. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3410. for(int k= 0;k<keyValues.size();k++)
  3411. {
  3412. smoothingList<<keyValues[k];
  3413. }
  3414. }
  3415. else
  3416. {
  3417. smoother.remove(smoothingKeys[j]);
  3418. }
  3419. }
  3420. qSort(countList);
  3421. int lastCount= 0;
  3422. for(int j= 0;j<countList.size();j++)
  3423. {
  3424. if(j==0||countList[j]!=lastCount)
  3425. {
  3426. smoother.insert(countList[j],value);
  3427. lastCount= countList[j];
  3428. }
  3429. }
  3430. value= 0.0;
  3431. for(int j= 0;j<smoothingList.size();j++)
  3432. {
  3433. value+= smoothingList[j];
  3434. }
  3435. value/= smoothingList.size();
  3436. }
  3437. Measurement measure(value,time,unitMap[i]);
  3438. channelMap[i]->input(measure);
  3439. }
  3440. }
  3441. /*:978*//*979:*/
  3442. #line 290 "./dataqsdk.w"
  3443. void DataqSdkDeviceImplementation::run()
  3444. {
  3445. if(!ready)
  3446. {
  3447. error= 9;
  3448. return;
  3449. }
  3450. driver= new QLibrary(device);
  3451. if(!driver->load())
  3452. {
  3453. error= 1;
  3454. qDebug()<<"Failed to load driver: "<<device;
  3455. return;
  3456. }
  3457. di_open= (FPDIOPEN)driver->resolve("di_open");
  3458. di_close= (FPDICLOSE)driver->resolve("di_close");
  3459. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3460. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3461. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3462. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3463. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3464. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3465. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3466. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3467. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3468. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3469. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3470. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3471. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3472. (!di_burst_rate)||(!di_stop_scan))
  3473. {
  3474. error= 2;
  3475. return;
  3476. }
  3477. error= di_open(deviceNumber);
  3478. if(error)
  3479. {
  3480. di_close();
  3481. error= di_open(deviceNumber);
  3482. if(error)
  3483. {
  3484. error= 3;
  3485. di_close();
  3486. return;
  3487. }
  3488. }
  3489. isOpen= true;
  3490. di_maximum_rate(240.0);
  3491. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3492. &burstDivisor);
  3493. buffer= new qint16[(int)sampleRate];
  3494. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3495. for(unsigned short i= 0;i<channels;i++)
  3496. {
  3497. inlist[i].chan= i;
  3498. inlist[i].gain= 0;
  3499. inlist[i].ave= 1;
  3500. inlist[i].counter= (oversample-1);
  3501. }
  3502. error= di_list_length(channels,0);
  3503. if(error)
  3504. {
  3505. error= 4;
  3506. return;
  3507. }
  3508. error= di_inlist(inlist);
  3509. if(error)
  3510. {
  3511. error= 5;
  3512. return;
  3513. }
  3514. input_buffer= di_buffer_alloc(0,4096);
  3515. if(input_buffer==NULL)
  3516. {
  3517. error= 6;
  3518. return;
  3519. }
  3520. error= di_start_scan();
  3521. if(error)
  3522. {
  3523. error= 7;
  3524. return;
  3525. }
  3526. while(ready)
  3527. {
  3528. measure();
  3529. }
  3530. }
  3531. /*:979*//*980:*/
  3532. #line 386 "./dataqsdk.w"
  3533. void DataqSdkDevice::threadFinished()
  3534. {
  3535. if(imp->error)
  3536. {
  3537. /*981:*/
  3538. #line 400 "./dataqsdk.w"
  3539. imp->ready= false;
  3540. QMessageBox warning;
  3541. warning.setStandardButtons(QMessageBox::Cancel);
  3542. warning.setIcon(QMessageBox::Warning);
  3543. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3544. warning.setInformativeText(tr("An error occurred"));
  3545. warning.setWindowTitle(QString(PROGRAM_NAME));
  3546. warning.exec();
  3547. /*:981*/
  3548. #line 391 "./dataqsdk.w"
  3549. }
  3550. }
  3551. /*:980*//*982:*/
  3552. #line 417 "./dataqsdk.w"
  3553. void DataqSdkDevice::start()
  3554. {
  3555. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3556. imp->start();
  3557. }
  3558. /*:982*//*983:*/
  3559. #line 428 "./dataqsdk.w"
  3560. QStringList DataqSdkDevice::detectHardware()
  3561. {
  3562. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3563. QSettings::NativeFormat);
  3564. QStringList keys= deviceLookup.childKeys();
  3565. QStringList devices;
  3566. for(int i= 0;i<keys.size();i++)
  3567. {
  3568. QString value= deviceLookup.value(keys.at(i)).toString();
  3569. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3570. {
  3571. devices.append(value.split("\\").at(2));
  3572. }
  3573. }
  3574. QStringList portList;
  3575. foreach(QString device,devices)
  3576. {
  3577. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3578. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3579. portList.append(deviceEntry.value("FriendlyName").toString());
  3580. }
  3581. return portList;
  3582. }
  3583. QStringList DataqSdkDevice::detectPorts()
  3584. {
  3585. QStringList friendlyNames= detectHardware();
  3586. QStringList portList;
  3587. foreach(QString name,friendlyNames)
  3588. {
  3589. name.remove(0,name.indexOf("COM"));
  3590. name.chop(1);
  3591. portList.append(name);
  3592. }
  3593. return portList;
  3594. }
  3595. /*:983*//*984:*/
  3596. #line 473 "./dataqsdk.w"
  3597. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3598. {
  3599. bool usesAuto= false;
  3600. int autoIndex= device.toInt(&usesAuto);
  3601. QString finalizedPort;
  3602. if(usesAuto)
  3603. {
  3604. QStringList portList= detectPorts();
  3605. if(autoIndex> 0&&autoIndex<=portList.size())
  3606. {
  3607. finalizedPort= portList.at(autoIndex-1);
  3608. }
  3609. else
  3610. {
  3611. imp->error= 8;
  3612. qDebug()<<"Failed to detect port.";
  3613. }
  3614. }
  3615. else
  3616. {
  3617. finalizedPort= device;
  3618. }
  3619. int rstart= finalizedPort.indexOf("COM");
  3620. finalizedPort.remove(0,rstart+3);
  3621. bool chopFinished= false;
  3622. int finalizedPortNumber= 0;
  3623. while(finalizedPort.size()> 0&&!chopFinished)
  3624. {
  3625. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3626. if(!chopFinished)
  3627. {
  3628. finalizedPort.chop(1);
  3629. }
  3630. }
  3631. if(finalizedPortNumber<10)
  3632. {
  3633. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3634. }
  3635. else
  3636. {
  3637. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3638. }
  3639. imp->deviceNumber= 0x12C02D00;
  3640. imp->deviceNumber+= finalizedPortNumber;
  3641. imp->ready= true;
  3642. }
  3643. /*:984*//*985:*/
  3644. #line 523 "./dataqsdk.w"
  3645. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3646. {
  3647. Channel*retval= NULL;
  3648. if(imp->ready)
  3649. {
  3650. retval= new Channel();
  3651. imp->channelMap[imp->channels]= retval;
  3652. imp->unitMap[imp->channels]= scale;
  3653. imp->channels++;
  3654. }
  3655. return retval;
  3656. }
  3657. /*:985*//*986:*/
  3658. #line 547 "./dataqsdk.w"
  3659. void DataqSdkDevice::setClockRate(double Hz)
  3660. {
  3661. imp->sampleRate= Hz;
  3662. }
  3663. /*:986*//*987:*/
  3664. #line 557 "./dataqsdk.w"
  3665. DataqSdkDevice::~DataqSdkDevice()
  3666. {
  3667. if(imp->ready)
  3668. {
  3669. imp->ready= false;
  3670. }
  3671. imp->wait(ULONG_MAX);
  3672. delete imp;
  3673. }
  3674. /*:987*//*988:*/
  3675. #line 575 "./dataqsdk.w"
  3676. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3677. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3678. {
  3679. }
  3680. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3681. {
  3682. if(isOpen)
  3683. {
  3684. di_stop_scan();
  3685. di_close();
  3686. }
  3687. if(driver->isLoaded())
  3688. {
  3689. driver->unload();
  3690. }
  3691. }
  3692. /*:988*/
  3693. #line 541 "./typica.w"
  3694. /*323:*/
  3695. #line 7283 "./typica.w"
  3696. void FakeDAQImplementation::measure()
  3697. {
  3698. msleep((int)(1000/clockRate));
  3699. QTime time= QTime::currentTime();
  3700. for(int i= 0;i<channels;i++)
  3701. {
  3702. Measurement measure(qrand()%500,time);
  3703. channelMap[i]->input(measure);
  3704. }
  3705. }
  3706. /*:323*//*324:*/
  3707. #line 7297 "./typica.w"
  3708. void FakeDAQImplementation::run()
  3709. {
  3710. setPriority(QThread::TimeCriticalPriority);
  3711. while(ready)
  3712. {
  3713. measure();
  3714. }
  3715. }
  3716. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3717. channels(0),ready(false),clockRate(1)
  3718. {
  3719. }
  3720. FakeDAQImplementation::~FakeDAQImplementation()
  3721. {
  3722. }
  3723. /*:324*//*325:*/
  3724. #line 7322 "./typica.w"
  3725. void FakeDAQ::start()
  3726. {
  3727. if(imp->ready)
  3728. {
  3729. imp->start();
  3730. }
  3731. }
  3732. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3733. {
  3734. imp->ready= true;
  3735. }
  3736. Channel*FakeDAQ::newChannel(int,int)
  3737. {
  3738. Channel*retval;
  3739. if(imp->ready)
  3740. {
  3741. retval= new Channel();
  3742. imp->channelMap[imp->channels]= retval;
  3743. imp->channels++;
  3744. }
  3745. else
  3746. {
  3747. return NULL;
  3748. }
  3749. return retval;
  3750. }
  3751. void FakeDAQ::setClockRate(double Hz)
  3752. {
  3753. if(imp->ready)
  3754. {
  3755. imp->clockRate= Hz;
  3756. }
  3757. }
  3758. FakeDAQ::~FakeDAQ()
  3759. {
  3760. imp->ready= false;
  3761. imp->wait(ULONG_MAX);
  3762. delete imp;
  3763. }
  3764. /*:325*/
  3765. #line 542 "./typica.w"
  3766. /*330:*/
  3767. #line 7453 "./typica.w"
  3768. Channel::Channel():QObject(NULL)
  3769. {
  3770. }
  3771. Channel::~Channel()
  3772. {
  3773. }
  3774. void Channel::input(Measurement measurement)
  3775. {
  3776. emit newData(measurement);
  3777. }
  3778. /*:330*/
  3779. #line 543 "./typica.w"
  3780. /*346:*/
  3781. #line 7858 "./typica.w"
  3782. void TemperatureDisplay::setRelativeMode(bool relative)
  3783. {
  3784. r= relative;
  3785. }
  3786. /*:346*//*347:*/
  3787. #line 7875 "./typica.w"
  3788. void TemperatureDisplay::setValue(Measurement temperature)
  3789. {
  3790. QString number;
  3791. switch(unit)
  3792. {
  3793. case Units::Fahrenheit:
  3794. display(QString("%1'F").
  3795. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3796. 2)));
  3797. break;
  3798. case Units::Celsius:
  3799. if(!r){
  3800. display(QString("%1'C").
  3801. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3802. 2)));
  3803. }else{
  3804. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3805. display(QString("%1'C").arg(number));
  3806. }
  3807. break;
  3808. case Units::Kelvin:
  3809. if(!r){
  3810. display(QString("%1").
  3811. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3812. 2)));
  3813. }else{
  3814. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3815. display(QString("%1").arg(number));
  3816. }
  3817. break;
  3818. case Units::Rankine:
  3819. display(QString("%1'r").
  3820. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3821. 2)));
  3822. break;
  3823. case Units::Unitless:
  3824. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3825. break;
  3826. default:
  3827. switch(temperature.scale())
  3828. {
  3829. case Units::Fahrenheit:
  3830. display(QString("%1'F").
  3831. arg(number.setNum(temperature.temperature(),'f',2)));
  3832. break;
  3833. case Units::Celsius:
  3834. display(QString("%1'C").
  3835. arg(number.setNum(temperature.temperature(),'f',2)));
  3836. break;
  3837. case Units::Kelvin:
  3838. display(QString("%1").
  3839. arg(number.setNum(temperature.temperature(),'f',2)));
  3840. break;
  3841. case Units::Rankine:
  3842. display(QString("%1'r").
  3843. arg(number.setNum(temperature.temperature(),'f',2)));
  3844. break;
  3845. case Units::Unitless:
  3846. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3847. break;
  3848. default:
  3849. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  3850. break;
  3851. }
  3852. break;
  3853. }
  3854. }
  3855. /*:347*//*348:*/
  3856. #line 7954 "./typica.w"
  3857. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3858. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3859. {
  3860. setSegmentStyle(Filled);
  3861. display("---.--'F");
  3862. }
  3863. /*:348*//*349:*/
  3864. #line 7970 "./typica.w"
  3865. void TemperatureDisplay::invalidate()
  3866. {
  3867. display("---.--'F");
  3868. }
  3869. /*:349*//*350:*/
  3870. #line 7982 "./typica.w"
  3871. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3872. {
  3873. unit= scale;
  3874. }
  3875. /*:350*//*351:*/
  3876. #line 7990 "./typica.w"
  3877. TemperatureDisplay::~TemperatureDisplay()
  3878. {
  3879. }
  3880. /*:351*/
  3881. #line 544 "./typica.w"
  3882. /*357:*/
  3883. #line 8090 "./typica.w"
  3884. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3885. {
  3886. if(measure.time()<epoch)
  3887. {
  3888. if(hasPrevious)
  3889. {
  3890. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3891. epoch.msec());
  3892. QTime jitComp(epoch.hour(),measure.time().minute(),
  3893. measure.time().second(),measure.time().msec());
  3894. int relTime= jitBase.msecsTo(jitComp);
  3895. /*358:*/
  3896. #line 8124 "./typica.w"
  3897. QTime newTime(0,0,0,0);
  3898. newTime= newTime.addMSecs(relTime);
  3899. if(newTime.hour()> 0)
  3900. {
  3901. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3902. }
  3903. Measurement rel= measure;
  3904. rel.setTime(newTime);
  3905. emit measurement(rel);
  3906. /*:358*/
  3907. #line 8102 "./typica.w"
  3908. }
  3909. else
  3910. {
  3911. Measurement rel= measure;
  3912. rel.setTime(QTime(0,0,0,0));
  3913. emit measurement(rel);
  3914. }
  3915. }
  3916. else
  3917. {
  3918. int relTime= epoch.msecsTo(measure.time());
  3919. /*358:*/
  3920. #line 8124 "./typica.w"
  3921. QTime newTime(0,0,0,0);
  3922. newTime= newTime.addMSecs(relTime);
  3923. if(newTime.hour()> 0)
  3924. {
  3925. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3926. }
  3927. Measurement rel= measure;
  3928. rel.setTime(newTime);
  3929. emit measurement(rel);
  3930. /*:358*/
  3931. #line 8114 "./typica.w"
  3932. }
  3933. hasPrevious= true;
  3934. previous= measure.time();
  3935. }
  3936. /*:357*//*359:*/
  3937. #line 8137 "./typica.w"
  3938. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3939. previous(0,0,0,0),hasPrevious(false)
  3940. {
  3941. }
  3942. QTime MeasurementTimeOffset::zeroTime()
  3943. {
  3944. return epoch;
  3945. }
  3946. void MeasurementTimeOffset::setZeroTime(QTime zero)
  3947. {
  3948. epoch= zero;
  3949. hasPrevious= false;
  3950. }
  3951. /*:359*/
  3952. #line 545 "./typica.w"
  3953. /*369:*/
  3954. #line 8345 "./typica.w"
  3955. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  3956. {
  3957. }
  3958. int ZeroEmitter::column()
  3959. {
  3960. return col;
  3961. }
  3962. double ZeroEmitter::lastTemperature()
  3963. {
  3964. return cache.temperature();
  3965. }
  3966. void ZeroEmitter::newMeasurement(Measurement measure)
  3967. {
  3968. cache= measure;
  3969. }
  3970. void ZeroEmitter::setColumn(int column)
  3971. {
  3972. col= column;
  3973. }
  3974. void ZeroEmitter::emitZero()
  3975. {
  3976. cache.setTime(QTime(0,0,0,0));
  3977. emit measurement(cache,col);
  3978. }
  3979. /*:369*/
  3980. #line 546 "./typica.w"
  3981. /*374:*/
  3982. #line 8435 "./typica.w"
  3983. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  3984. {
  3985. }
  3986. int MeasurementAdapter::column()
  3987. {
  3988. return col;
  3989. }
  3990. void MeasurementAdapter::newMeasurement(Measurement measure)
  3991. {
  3992. emit measurement(measure,col);
  3993. }
  3994. void MeasurementAdapter::setColumn(int column)
  3995. {
  3996. col= column;
  3997. }
  3998. /*:374*/
  3999. #line 547 "./typica.w"
  4000. /*379:*/
  4001. #line 8557 "./typica.w"
  4002. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  4003. theScene(new QGraphicsScene),
  4004. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  4005. prevPoints(new QMap<int,QPointF> ),
  4006. translations(new QMap<int,double> ),
  4007. gridLinesF(new QList<QGraphicsItem*> ),
  4008. gridLinesC(new QList<QGraphicsItem*> ),
  4009. relativeGridLines(new QList<QGraphicsItem*> ),
  4010. relativeEnabled(false),
  4011. timeIndicatorEnabled(false),
  4012. timeLine(new QGraphicsLineItem),
  4013. relativeAdjuster(new LinearSplineInterpolator)
  4014. {
  4015. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4016. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4017. setScene(theScene);
  4018. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  4019. QPen timePen;
  4020. timePen.setColor(QColor(160,160,164,127));
  4021. timeLine->setPen(timePen);
  4022. timeLine->setLine(0,0,0,-500);
  4023. timeLine->hide();
  4024. theScene->addItem(timeLine);
  4025. /*380:*/
  4026. #line 8597 "./typica.w"
  4027. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  4028. tempaxis->setLine(-10,-500,-10,0);
  4029. theScene->addItem(tempaxis);
  4030. QGraphicsLineItem*gridLine;
  4031. QGraphicsTextItem*label;
  4032. for(int y= -100;y> -600;y-= 100)
  4033. {
  4034. gridLine= new QGraphicsLineItem;
  4035. gridLine->setLine(0,y,1200,y);
  4036. theScene->addItem(gridLine);
  4037. label= new QGraphicsTextItem;
  4038. label->setHtml(QString("%1&deg;F").arg(-y));
  4039. label->setPos(-55,y-(label->boundingRect().height()/2));
  4040. theScene->addItem(label);
  4041. gridLinesF->append(gridLine);
  4042. gridLinesF->append(label);
  4043. }
  4044. for(int degC= 50;degC<=250;degC+= 50)
  4045. {
  4046. gridLine= new QGraphicsLineItem;
  4047. int y= -(degC*(9.0/5.0)+32);
  4048. gridLine->setLine(0,y,1200,y);
  4049. gridLine->hide();
  4050. theScene->addItem(gridLine);
  4051. gridLinesC->append(gridLine);
  4052. label= new QGraphicsTextItem;
  4053. label->setHtml(QString("%1&deg;C").arg(degC));
  4054. label->setPos(-55,y-(label->boundingRect().height()/2));
  4055. label->hide();
  4056. theScene->addItem(label);
  4057. gridLinesC->append(label);
  4058. }
  4059. /*:380*/
  4060. #line 8581 "./typica.w"
  4061. ;
  4062. /*381:*/
  4063. #line 8638 "./typica.w"
  4064. QSettings settings;
  4065. if(settings.contains("settings/graph/relative/enable"))
  4066. {
  4067. if(settings.value("settings/graph/relative/enable").toBool())
  4068. {
  4069. relativeEnabled= true;
  4070. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  4071. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  4072. QMap<double,QString> relativeAxisPairs;
  4073. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  4074. foreach(QString item,relativeAxisLabels)
  4075. {
  4076. relativeAxisPairs.insert(item.toDouble(),item);
  4077. }
  4078. if(relativeAxisPairs.size()> 1)
  4079. {
  4080. double skip= 500.0/(relativeAxisPairs.size()-1);
  4081. double y= 0;
  4082. foreach(double key,relativeAxisPairs.keys())
  4083. {
  4084. gridLine= new QGraphicsLineItem;
  4085. gridLine->setLine(0,y,1205,y);
  4086. gridLine->setPen(QPen(relativeColor));
  4087. theScene->addItem(gridLine);
  4088. relativeGridLines->append(gridLine);
  4089. label= new QGraphicsTextItem;
  4090. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  4091. label->setPos(1210,y-(label->boundingRect().height()/2));
  4092. theScene->addItem(label);
  4093. relativeGridLines->append(label);
  4094. if(unit=="F")
  4095. {
  4096. relativeAdjuster->add_pair(key,-y);
  4097. }
  4098. else
  4099. {
  4100. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  4101. }
  4102. y-= skip;
  4103. }
  4104. }
  4105. }
  4106. }
  4107. /*:381*/
  4108. #line 8582 "./typica.w"
  4109. /*383:*/
  4110. #line 8715 "./typica.w"
  4111. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  4112. timeaxis->setLine(0,10,1200,10);
  4113. theScene->addItem(timeaxis);
  4114. for(int x= 0;x<1201;x+= 120)
  4115. {
  4116. QGraphicsLineItem*tick= new QGraphicsLineItem;
  4117. tick->setLine(x,0,x,20);
  4118. theScene->addItem(tick);
  4119. QGraphicsTextItem*label= new QGraphicsTextItem;
  4120. label->setPlainText(QString("%1").arg(x/60));
  4121. label->setPos(x-(label->boundingRect().width()/2),20);
  4122. theScene->addItem(label);
  4123. }
  4124. /*:383*/
  4125. #line 8583 "./typica.w"
  4126. ;
  4127. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4128. }
  4129. /*:379*//*382:*/
  4130. #line 8685 "./typica.w"
  4131. void GraphView::showF()
  4132. {
  4133. for(int i= 0;i<gridLinesF->size();i++)
  4134. {
  4135. gridLinesF->at(i)->show();
  4136. }
  4137. for(int i= 0;i<gridLinesC->size();i++)
  4138. {
  4139. gridLinesC->at(i)->hide();
  4140. }
  4141. }
  4142. void GraphView::showC()
  4143. {
  4144. for(int i= 0;i<gridLinesF->size();i++)
  4145. {
  4146. gridLinesF->at(i)->hide();
  4147. }
  4148. for(int i= 0;i<gridLinesC->size();i++)
  4149. {
  4150. gridLinesC->at(i)->show();
  4151. }
  4152. }
  4153. /*:382*//*384:*/
  4154. #line 8734 "./typica.w"
  4155. void GraphView::resizeEvent(QResizeEvent*)
  4156. {
  4157. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4158. }
  4159. /*:384*//*385:*/
  4160. #line 8748 "./typica.w"
  4161. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4162. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4163. {
  4164. double offset= 0;
  4165. if(measure.contains("relative"))
  4166. {
  4167. if(measure.value("relative").toBool())
  4168. {
  4169. if(relativeEnabled)
  4170. {
  4171. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4172. }
  4173. else
  4174. {
  4175. return;
  4176. }
  4177. }
  4178. }
  4179. if(translations->contains(tempcolumn))
  4180. {
  4181. offset= translations->value(tempcolumn);
  4182. }
  4183. if(prevPoints->contains(tempcolumn))
  4184. {
  4185. /*387:*/
  4186. #line 8825 "./typica.w"
  4187. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4188. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4189. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4190. -(prevPoints->value(tempcolumn).y()),
  4191. nextPoint.x()+offset,-(nextPoint.y()));
  4192. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4193. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4194. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4195. Qt::darkYellow};
  4196. segment->setPen(p[tempcolumn%12]);
  4197. theScene->addItem(segment);
  4198. prevPoints->insert(tempcolumn,nextPoint);
  4199. if(timeIndicatorEnabled)
  4200. {
  4201. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4202. }
  4203. /*:387*/
  4204. #line 8774 "./typica.w"
  4205. if(graphLines->contains(tempcolumn))
  4206. {
  4207. graphLines->value(tempcolumn)->append(segment);
  4208. }
  4209. else
  4210. {
  4211. QList<QGraphicsLineItem*> *newLine=
  4212. new QList<QGraphicsLineItem*> ;
  4213. newLine->append(segment);
  4214. graphLines->insert(tempcolumn,newLine);
  4215. }
  4216. }
  4217. else
  4218. {
  4219. /*386:*/
  4220. #line 8810 "./typica.w"
  4221. int x= FULLTIMETOINT(measure.time())/1000;
  4222. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4223. if(timeIndicatorEnabled)
  4224. {
  4225. timeLine->setLine(x,0,x,-500);
  4226. }
  4227. /*:386*/
  4228. #line 8791 "./typica.w"
  4229. }
  4230. }
  4231. /*:385*//*388:*/
  4232. #line 8846 "./typica.w"
  4233. void GraphView::clear()
  4234. {
  4235. int i;
  4236. foreach(i,prevPoints->keys())
  4237. {
  4238. removeSeries(i);
  4239. }
  4240. translations->clear();
  4241. }
  4242. /*:388*//*389:*/
  4243. #line 8860 "./typica.w"
  4244. void GraphView::removeSeries(int column)
  4245. {
  4246. if(graphLines->contains(column))
  4247. {
  4248. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4249. QGraphicsLineItem*segment;
  4250. foreach(segment,*series)
  4251. {
  4252. theScene->removeItem(segment);
  4253. }
  4254. qDeleteAll(*series);
  4255. }
  4256. graphLines->remove(column);
  4257. prevPoints->remove(column);
  4258. }
  4259. /*:389*//*390:*/
  4260. #line 8879 "./typica.w"
  4261. void GraphView::setSeriesTranslation(int column,double offset)
  4262. {
  4263. if(graphLines->contains(column))
  4264. {
  4265. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4266. QGraphicsLineItem*segment;
  4267. foreach(segment,*series)
  4268. {
  4269. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4270. }
  4271. }
  4272. if(translations->contains(column))
  4273. {
  4274. translations->insert(column,offset+translations->value(column));
  4275. }
  4276. else
  4277. {
  4278. translations->insert(column,offset);
  4279. }
  4280. }
  4281. /*:390*//*391:*/
  4282. #line 8906 "./typica.w"
  4283. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4284. {
  4285. timeIndicatorEnabled= enabled;
  4286. if(enabled)
  4287. {
  4288. timeLine->show();
  4289. }
  4290. else
  4291. {
  4292. timeLine->hide();
  4293. }
  4294. }
  4295. /*:391*/
  4296. #line 548 "./typica.w"
  4297. /*397:*/
  4298. #line 9050 "./typica.w"
  4299. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4300. {
  4301. if(measure.time()!=QTime(0,0,0,0))
  4302. {
  4303. /*399:*/
  4304. #line 9124 "./typica.w"
  4305. if(lastMeasurement.contains(tempcolumn))
  4306. {
  4307. if(lastMeasurement[tempcolumn].time()<measure.time())
  4308. {
  4309. QList<QTime> timelist;
  4310. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4311. {
  4312. timelist.append(i);
  4313. }
  4314. for(int i= 0;i<timelist.size();i++)
  4315. {
  4316. Measurement synthesized= measure;
  4317. synthesized.setTime(timelist[i]);
  4318. newMeasurement(synthesized,tempcolumn);
  4319. }
  4320. }
  4321. }
  4322. /*:399*/
  4323. #line 9055 "./typica.w"
  4324. }
  4325. model_ms->newMeasurement(measure,tempcolumn);
  4326. if(lastMeasurement.contains(tempcolumn))
  4327. {
  4328. if(measure.time().second()!=
  4329. lastMeasurement.value(tempcolumn).time().second())
  4330. {
  4331. Measurement adjusted= measure;
  4332. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4333. adjusted.setTime(adjtime);
  4334. model_1s->newMeasurement(adjusted,tempcolumn);
  4335. if(adjusted.time().second()%5==0)
  4336. {
  4337. model_5s->newMeasurement(adjusted,tempcolumn);
  4338. if(adjusted.time().second()%10==0)
  4339. {
  4340. model_10s->newMeasurement(adjusted,tempcolumn);
  4341. }
  4342. if(adjusted.time().second()%15==0)
  4343. {
  4344. model_15s->newMeasurement(adjusted,tempcolumn);
  4345. if(adjusted.time().second()%30==0)
  4346. {
  4347. model_30s->newMeasurement(adjusted,tempcolumn);
  4348. if(adjusted.time().second()==0)
  4349. {
  4350. model_1m->newMeasurement(adjusted,tempcolumn);
  4351. }
  4352. }
  4353. }
  4354. }
  4355. }
  4356. /*401:*/
  4357. #line 9168 "./typica.w"
  4358. if(currentColumnSet.contains(tempcolumn))
  4359. {
  4360. int replicationcolumn;
  4361. foreach(replicationcolumn,currentColumnSet)
  4362. {
  4363. if(replicationcolumn!=tempcolumn)
  4364. {
  4365. if(lastMeasurement.contains(replicationcolumn))
  4366. {
  4367. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4368. {
  4369. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4370. synthetic.setTime(measure.time());
  4371. model_ms->newMeasurement(synthetic,replicationcolumn);
  4372. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4373. {
  4374. Measurement adjusted= synthetic;
  4375. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4376. model_1s->newMeasurement(adjusted,replicationcolumn);
  4377. if(adjusted.time().second()%5==0)
  4378. {
  4379. model_5s->newMeasurement(adjusted,replicationcolumn);
  4380. if(adjusted.time().second()%10==0)
  4381. {
  4382. model_10s->newMeasurement(adjusted,replicationcolumn);
  4383. }
  4384. if(adjusted.time().second()%15==0)
  4385. {
  4386. model_15s->newMeasurement(adjusted,replicationcolumn);
  4387. if(adjusted.time().second()%30==0)
  4388. {
  4389. model_30s->newMeasurement(adjusted,replicationcolumn);
  4390. if(adjusted.time().second()==0)
  4391. {
  4392. model_1m->newMeasurement(adjusted,replicationcolumn);
  4393. }
  4394. }
  4395. }
  4396. }
  4397. }
  4398. lastMeasurement[replicationcolumn]= synthetic;
  4399. }
  4400. }
  4401. }
  4402. }
  4403. }
  4404. /*:401*/
  4405. #line 9088 "./typica.w"
  4406. }
  4407. else
  4408. {
  4409. /*398:*/
  4410. #line 9100 "./typica.w"
  4411. MeasurementModel*m;
  4412. foreach(m,modelSet)
  4413. {
  4414. m->newMeasurement(measure,tempcolumn);
  4415. }
  4416. /*:398*/
  4417. #line 9092 "./typica.w"
  4418. }
  4419. lastMeasurement.insert(tempcolumn,measure);
  4420. }
  4421. /*:397*//*400:*/
  4422. #line 9154 "./typica.w"
  4423. void ZoomLog::addToCurrentColumnSet(int column)
  4424. {
  4425. currentColumnSet.append(column);
  4426. }
  4427. void ZoomLog::clearCurrentColumnSet()
  4428. {
  4429. currentColumnSet.clear();
  4430. }
  4431. /*:400*//*402:*/
  4432. #line 9238 "./typica.w"
  4433. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4434. int annotationcolumn)
  4435. {
  4436. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4437. MeasurementModel*m;
  4438. if(lastMeasurement.contains(tempcolumn))
  4439. {
  4440. foreach(m,modelSet)
  4441. {
  4442. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4443. }
  4444. }
  4445. foreach(m,modelSet)
  4446. {
  4447. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4448. }
  4449. }
  4450. /*:402*//*403:*/
  4451. #line 9262 "./typica.w"
  4452. void ZoomLog::centerOn(int row)
  4453. {
  4454. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4455. }
  4456. /*:403*//*404:*/
  4457. #line 9272 "./typica.w"
  4458. void ZoomLog::clear()
  4459. {
  4460. MeasurementModel*m;
  4461. foreach(m,modelSet)
  4462. {
  4463. m->clear();
  4464. }
  4465. lastMeasurement.clear();
  4466. saveTempCols.clear();
  4467. saveControlCols.clear();
  4468. saveNoteCols.clear();
  4469. }
  4470. /*:404*//*405:*/
  4471. #line 9290 "./typica.w"
  4472. QVariant ZoomLog::data(int row,int column)const
  4473. {
  4474. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4475. Qt::DisplayRole);
  4476. }
  4477. int ZoomLog::rowCount()
  4478. {
  4479. return model_ms->rowCount();
  4480. }
  4481. /*:405*//*406:*/
  4482. #line 9313 "./typica.w"
  4483. bool ZoomLog::saveXML(QIODevice*device)
  4484. {
  4485. Units::Unit prevUnits= model_ms->displayUnits();
  4486. if(prevUnits!=Units::Fahrenheit)
  4487. {
  4488. model_ms->setDisplayUnits(Units::Fahrenheit);
  4489. }
  4490. XMLOutput writer(model_ms,device,0);
  4491. int c;
  4492. foreach(c,saveTempCols)
  4493. {
  4494. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4495. toString(),c);
  4496. }
  4497. foreach(c,saveControlCols)
  4498. {
  4499. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4500. toString(),c);
  4501. }
  4502. foreach(c,saveNoteCols)
  4503. {
  4504. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4505. toString(),c);
  4506. }
  4507. bool retval= writer.output();
  4508. if(prevUnits!=Units::Fahrenheit)
  4509. {
  4510. model_ms->setDisplayUnits(prevUnits);
  4511. }
  4512. return retval;
  4513. }
  4514. /*:406*//*407:*/
  4515. #line 9349 "./typica.w"
  4516. bool ZoomLog::saveCSV(QIODevice*device)
  4517. {
  4518. CSVOutput writer(currentModel,device,0);
  4519. int c;
  4520. foreach(c,saveTempCols)
  4521. {
  4522. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4523. toString(),c);
  4524. }
  4525. foreach(c,saveControlCols)
  4526. {
  4527. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4528. toString(),c);
  4529. }
  4530. foreach(c,saveNoteCols)
  4531. {
  4532. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4533. toString(),c);
  4534. }
  4535. return writer.output();
  4536. }
  4537. /*:407*//*408:*/
  4538. #line 9378 "./typica.w"
  4539. void ZoomLog::switchLOD(MeasurementModel*m)
  4540. {
  4541. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4542. setModel(m);
  4543. currentModel= m;
  4544. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4545. }
  4546. void ZoomLog::LOD_ms()
  4547. {
  4548. switchLOD(model_ms);
  4549. }
  4550. void ZoomLog::LOD_1s()
  4551. {
  4552. switchLOD(model_1s);
  4553. }
  4554. void ZoomLog::LOD_5s()
  4555. {
  4556. switchLOD(model_5s);
  4557. }
  4558. void ZoomLog::LOD_10s()
  4559. {
  4560. switchLOD(model_10s);
  4561. }
  4562. void ZoomLog::LOD_15s()
  4563. {
  4564. switchLOD(model_15s);
  4565. }
  4566. void ZoomLog::LOD_30s()
  4567. {
  4568. switchLOD(model_30s);
  4569. }
  4570. void ZoomLog::LOD_1m()
  4571. {
  4572. switchLOD(model_1m);
  4573. }
  4574. /*:408*//*409:*/
  4575. #line 9426 "./typica.w"
  4576. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4577. {
  4578. model_ms->setDisplayUnits(scale);
  4579. model_1s->setDisplayUnits(scale);
  4580. model_5s->setDisplayUnits(scale);
  4581. model_10s->setDisplayUnits(scale);
  4582. model_15s->setDisplayUnits(scale);
  4583. model_30s->setDisplayUnits(scale);
  4584. model_1m->setDisplayUnits(scale);
  4585. }
  4586. Units::Unit ZoomLog::displayUnits()
  4587. {
  4588. return model_ms->displayUnits();
  4589. }
  4590. /*:409*//*410:*/
  4591. #line 9446 "./typica.w"
  4592. QString ZoomLog::lastTime(int series)
  4593. {
  4594. Measurement measure= lastMeasurement.value(series);
  4595. QTime time= measure.time();
  4596. return time.toString("h:mm:ss.zzz");
  4597. }
  4598. /*:410*//*411:*/
  4599. #line 9456 "./typica.w"
  4600. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4601. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4602. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4603. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4604. {
  4605. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4606. setSelectionMode(QAbstractItemView::NoSelection);
  4607. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4608. model_30s<<model_1m;
  4609. currentModel= model_30s;
  4610. setModel(currentModel);
  4611. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4612. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4613. this,SLOT(persistColumnResize(int,int,int)));
  4614. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4615. this,SLOT(restoreColumnWidths()));
  4616. }
  4617. /*:411*//*412:*/
  4618. #line 9479 "./typica.w"
  4619. void ZoomLog::setHeaderData(int section,QString text)
  4620. {
  4621. MeasurementModel*m;
  4622. foreach(m,modelSet)
  4623. {
  4624. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4625. }
  4626. }
  4627. /*:412*//*413:*/
  4628. #line 9497 "./typica.w"
  4629. void ZoomLog::addOutputTemperatureColumn(int column)
  4630. {
  4631. saveTempCols.append(column);
  4632. }
  4633. void ZoomLog::addOutputControlColumn(int column)
  4634. {
  4635. saveControlCols.append(column);
  4636. }
  4637. void ZoomLog::addOutputAnnotationColumn(int column)
  4638. {
  4639. saveNoteCols.append(column);
  4640. }
  4641. void ZoomLog::clearOutputColumns()
  4642. {
  4643. saveTempCols.clear();
  4644. saveControlCols.clear();
  4645. saveNoteCols.clear();
  4646. }
  4647. /*:413*//*414:*/
  4648. #line 9523 "./typica.w"
  4649. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4650. {
  4651. /*629:*/
  4652. #line 13669 "./typica.w"
  4653. QSettings settings;
  4654. /*630:*/
  4655. #line 13682 "./typica.w"
  4656. QWidget*topLevelWidget= this;
  4657. while(topLevelWidget->parentWidget())
  4658. {
  4659. topLevelWidget= topLevelWidget->parentWidget();
  4660. }
  4661. /*:630*/
  4662. #line 13671 "./typica.w"
  4663. settings.setValue(QString("columnWidths/%1/%2/%3").
  4664. arg(topLevelWidget->objectName()).
  4665. arg(objectName()).arg(column),
  4666. QVariant(newsize));
  4667. /*:629*/
  4668. #line 9526 "./typica.w"
  4669. }
  4670. void ZoomLog::restoreColumnWidths()
  4671. {
  4672. /*632:*/
  4673. #line 13702 "./typica.w"
  4674. QSettings settings;
  4675. /*630:*/
  4676. #line 13682 "./typica.w"
  4677. QWidget*topLevelWidget= this;
  4678. while(topLevelWidget->parentWidget())
  4679. {
  4680. topLevelWidget= topLevelWidget->parentWidget();
  4681. }
  4682. /*:630*/
  4683. #line 13704 "./typica.w"
  4684. QString baseKey=
  4685. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4686. arg(objectName());
  4687. for(int i= 0;i<model()->columnCount();i++)
  4688. {
  4689. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4690. if(settings.contains(key))
  4691. {
  4692. setColumnWidth(i,settings.value(key).toInt());
  4693. }
  4694. }
  4695. /*:632*/
  4696. #line 9531 "./typica.w"
  4697. }
  4698. void ZoomLog::setVisible(bool visibility)
  4699. {
  4700. QTableView::setVisible(visibility);
  4701. }
  4702. void ZoomLog::showEvent(QShowEvent*)
  4703. {
  4704. /*632:*/
  4705. #line 13702 "./typica.w"
  4706. QSettings settings;
  4707. /*630:*/
  4708. #line 13682 "./typica.w"
  4709. QWidget*topLevelWidget= this;
  4710. while(topLevelWidget->parentWidget())
  4711. {
  4712. topLevelWidget= topLevelWidget->parentWidget();
  4713. }
  4714. /*:630*/
  4715. #line 13704 "./typica.w"
  4716. QString baseKey=
  4717. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4718. arg(objectName());
  4719. for(int i= 0;i<model()->columnCount();i++)
  4720. {
  4721. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4722. if(settings.contains(key))
  4723. {
  4724. setColumnWidth(i,settings.value(key).toInt());
  4725. }
  4726. }
  4727. /*:632*/
  4728. #line 9541 "./typica.w"
  4729. }
  4730. /*:414*/
  4731. #line 549 "./typica.w"
  4732. /*423:*/
  4733. #line 9774 "./typica.w"
  4734. bool MeasurementList::operator<(const MeasurementList&other)const
  4735. {
  4736. return this->first().toTime()<other.first().toTime();
  4737. }
  4738. bool MeasurementList::operator==(const MeasurementList&other)const
  4739. {
  4740. return this->first().toTime()==other.first().toTime();
  4741. }
  4742. /*:423*//*424:*/
  4743. #line 9790 "./typica.w"
  4744. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4745. {
  4746. return QModelIndex();
  4747. }
  4748. /*:424*//*425:*/
  4749. #line 9800 "./typica.w"
  4750. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4751. {
  4752. if(measure.scale()==Units::Unitless)
  4753. {
  4754. controlColumns->insert(tempcolumn,true);
  4755. }
  4756. else
  4757. {
  4758. controlColumns->insert(tempcolumn,false);
  4759. }
  4760. MeasurementList*temp;
  4761. temp= new MeasurementList;
  4762. temp->append(QVariant(measure.time()));
  4763. /*426:*/
  4764. #line 9859 "./typica.w"
  4765. /*427:*/
  4766. #line 9904 "./typica.w"
  4767. QList<MeasurementList*> ::iterator i= lastInsertion;
  4768. bool quickscan= false;
  4769. if(entries->size()> 5)
  4770. {
  4771. if(**i<*temp)
  4772. {
  4773. i+= 1;
  4774. for(int j= 10;j> 0;j--)
  4775. {
  4776. if(i!=entries->end())
  4777. {
  4778. if(**i<*temp)
  4779. {
  4780. i+= 1;
  4781. }
  4782. else
  4783. {
  4784. quickscan= true;
  4785. break;
  4786. }
  4787. }
  4788. else
  4789. {
  4790. quickscan= true;
  4791. break;
  4792. }
  4793. }
  4794. }
  4795. else
  4796. {
  4797. if(**i==*temp)
  4798. {
  4799. quickscan= true;
  4800. }
  4801. }
  4802. }
  4803. /*:427*/
  4804. #line 9860 "./typica.w"
  4805. if(quickscan==false)
  4806. {
  4807. i= entries->begin();
  4808. QList<MeasurementList*> ::iterator u= entries->end();
  4809. QList<MeasurementList*> ::iterator midpoint;
  4810. int n= u-i;
  4811. int rA;
  4812. while(n> 0)
  4813. {
  4814. rA= n>>1;
  4815. midpoint= i+rA;
  4816. if(**midpoint<*temp)
  4817. {
  4818. i= midpoint+1;
  4819. n-= rA+1;
  4820. }
  4821. else
  4822. {
  4823. n= rA;
  4824. }
  4825. }
  4826. }
  4827. /*:426*/
  4828. #line 9814 "./typica.w"
  4829. MeasurementList*newEntry;
  4830. int insertion;
  4831. if(i!=entries->end())
  4832. {
  4833. insertion= entries->indexOf(*i);
  4834. if((*i)->first().toTime()==measure.time())
  4835. {
  4836. /*428:*/
  4837. #line 9946 "./typica.w"
  4838. if((*i)->size()<tempcolumn+1)
  4839. {
  4840. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4841. {
  4842. (*i)->append(QVariant());
  4843. }
  4844. }
  4845. (*i)->replace(tempcolumn,measure);
  4846. lastInsertion= i;
  4847. emit dataChanged(createIndex(insertion,tempcolumn),
  4848. createIndex(insertion,tempcolumn));
  4849. lastTemperature->insert(tempcolumn,insertion);
  4850. /*:428*/
  4851. #line 9822 "./typica.w"
  4852. }
  4853. else
  4854. {
  4855. /*429:*/
  4856. #line 9964 "./typica.w"
  4857. beginInsertRows(QModelIndex(),insertion,insertion);
  4858. newEntry= new MeasurementList;
  4859. newEntry->append(QVariant(measure.time()));
  4860. for(int j= 0;j<tempcolumn+1;j++)
  4861. {
  4862. newEntry->append(QVariant());
  4863. }
  4864. newEntry->replace(tempcolumn,measure);
  4865. lastInsertion= entries->insert(i,newEntry);
  4866. endInsertRows();
  4867. lastTemperature->insert(tempcolumn,insertion);
  4868. /*:429*/
  4869. #line 9826 "./typica.w"
  4870. }
  4871. }
  4872. else
  4873. {
  4874. /*430:*/
  4875. #line 9982 "./typica.w"
  4876. insertion= entries->size();
  4877. /*429:*/
  4878. #line 9964 "./typica.w"
  4879. beginInsertRows(QModelIndex(),insertion,insertion);
  4880. newEntry= new MeasurementList;
  4881. newEntry->append(QVariant(measure.time()));
  4882. for(int j= 0;j<tempcolumn+1;j++)
  4883. {
  4884. newEntry->append(QVariant());
  4885. }
  4886. newEntry->replace(tempcolumn,measure);
  4887. lastInsertion= entries->insert(i,newEntry);
  4888. endInsertRows();
  4889. lastTemperature->insert(tempcolumn,insertion);
  4890. /*:429*/
  4891. #line 9984 "./typica.w"
  4892. /*:430*/
  4893. #line 9831 "./typica.w"
  4894. }
  4895. if(tempcolumn>=colcount)
  4896. {
  4897. colcount= tempcolumn+1;
  4898. }
  4899. emit rowChanged(insertion);
  4900. delete temp;
  4901. }
  4902. /*:425*//*431:*/
  4903. #line 9994 "./typica.w"
  4904. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4905. int annotationColumn)
  4906. {
  4907. int r;
  4908. if(lastTemperature->contains(tempcolumn))
  4909. {
  4910. r= lastTemperature->value(tempcolumn);
  4911. }
  4912. else
  4913. {
  4914. r= 0;
  4915. }
  4916. if(r==0&&entries->size()==0)
  4917. {
  4918. /*432:*/
  4919. #line 10032 "./typica.w"
  4920. beginInsertRows(QModelIndex(),0,0);
  4921. MeasurementList*newEntry= new MeasurementList;
  4922. newEntry->append(QVariant(QTime(0,0,0,0)));
  4923. entries->append(newEntry);
  4924. endInsertRows();
  4925. /*:432*/
  4926. #line 10009 "./typica.w"
  4927. }
  4928. MeasurementList*row= entries->at(r);
  4929. if(row->size()<=annotationColumn)
  4930. {
  4931. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4932. {
  4933. row->append(QVariant());
  4934. }
  4935. }
  4936. row->replace(annotationColumn,annotation);
  4937. emit dataChanged(createIndex(r,annotationColumn),
  4938. createIndex(r,annotationColumn));
  4939. emit rowChanged(r);
  4940. if(annotationColumn> colcount-1)
  4941. {
  4942. colcount= annotationColumn+1;
  4943. }
  4944. }
  4945. /*:431*//*433:*/
  4946. #line 10043 "./typica.w"
  4947. void MeasurementModel::clear()
  4948. {
  4949. beginRemoveRows(QModelIndex(),0,entries->size());
  4950. while(entries->size()!=0)
  4951. {
  4952. MeasurementList*row= entries->takeFirst();
  4953. delete row;
  4954. }
  4955. endRemoveRows();
  4956. colcount= hData->size();
  4957. lastTemperature->clear();
  4958. reset();
  4959. }
  4960. /*:433*//*434:*/
  4961. #line 10076 "./typica.w"
  4962. bool MeasurementModel::setData(const QModelIndex&index,
  4963. const QVariant&value,int role)
  4964. {
  4965. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  4966. {
  4967. return false;
  4968. }
  4969. /*435:*/
  4970. #line 10108 "./typica.w"
  4971. bool valid= false;
  4972. if(index.isValid())
  4973. {
  4974. if(index.row()<entries->size())
  4975. {
  4976. if(index.column()<colcount)
  4977. {
  4978. valid= true;
  4979. }
  4980. }
  4981. }
  4982. /*:435*/
  4983. #line 10084 "./typica.w"
  4984. if(!valid)
  4985. {
  4986. return false;
  4987. }
  4988. MeasurementList*row= entries->at(index.row());
  4989. if(index.column()>=row->size())
  4990. {
  4991. /*436:*/
  4992. #line 10125 "./typica.w"
  4993. for(int i= row->size()-1;i<index.column();i++)
  4994. {
  4995. row->append(QVariant());
  4996. }
  4997. /*:436*/
  4998. #line 10092 "./typica.w"
  4999. }
  5000. if(index.column()==0)
  5001. {
  5002. /*437:*/
  5003. #line 10140 "./typica.w"
  5004. QTime time;
  5005. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  5006. {
  5007. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  5008. {
  5009. return false;
  5010. }
  5011. }
  5012. row= entries->takeAt(index.row());
  5013. row->replace(index.column(),QVariant(time));
  5014. MeasurementList*temp= row;
  5015. /*426:*/
  5016. #line 9859 "./typica.w"
  5017. /*427:*/
  5018. #line 9904 "./typica.w"
  5019. QList<MeasurementList*> ::iterator i= lastInsertion;
  5020. bool quickscan= false;
  5021. if(entries->size()> 5)
  5022. {
  5023. if(**i<*temp)
  5024. {
  5025. i+= 1;
  5026. for(int j= 10;j> 0;j--)
  5027. {
  5028. if(i!=entries->end())
  5029. {
  5030. if(**i<*temp)
  5031. {
  5032. i+= 1;
  5033. }
  5034. else
  5035. {
  5036. quickscan= true;
  5037. break;
  5038. }
  5039. }
  5040. else
  5041. {
  5042. quickscan= true;
  5043. break;
  5044. }
  5045. }
  5046. }
  5047. else
  5048. {
  5049. if(**i==*temp)
  5050. {
  5051. quickscan= true;
  5052. }
  5053. }
  5054. }
  5055. /*:427*/
  5056. #line 9860 "./typica.w"
  5057. if(quickscan==false)
  5058. {
  5059. i= entries->begin();
  5060. QList<MeasurementList*> ::iterator u= entries->end();
  5061. QList<MeasurementList*> ::iterator midpoint;
  5062. int n= u-i;
  5063. int rA;
  5064. while(n> 0)
  5065. {
  5066. rA= n>>1;
  5067. midpoint= i+rA;
  5068. if(**midpoint<*temp)
  5069. {
  5070. i= midpoint+1;
  5071. n-= rA+1;
  5072. }
  5073. else
  5074. {
  5075. n= rA;
  5076. }
  5077. }
  5078. }
  5079. /*:426*/
  5080. #line 10152 "./typica.w"
  5081. entries->insert(i,row);
  5082. int newRow= entries->indexOf(*i);
  5083. if(newRow<index.row())
  5084. {
  5085. emit dataChanged(createIndex(newRow,index.column()),index);
  5086. }
  5087. else
  5088. {
  5089. emit dataChanged(index,createIndex(newRow,index.column()));
  5090. }
  5091. /*:437*/
  5092. #line 10096 "./typica.w"
  5093. }
  5094. else
  5095. {
  5096. /*438:*/
  5097. #line 10166 "./typica.w"
  5098. row->replace(index.column(),value);
  5099. emit dataChanged(index,index);
  5100. /*:438*/
  5101. #line 10100 "./typica.w"
  5102. }
  5103. return true;
  5104. }
  5105. /*:434*//*439:*/
  5106. #line 10174 "./typica.w"
  5107. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  5108. unit(Units::Fahrenheit),hData(new QStringList),
  5109. lastTemperature(new QHash<int,int> ),
  5110. controlColumns(new QHash<int,bool> )
  5111. {
  5112. colcount= 1;
  5113. entries= new QList<MeasurementList*> ;
  5114. lastInsertion= entries->begin();
  5115. hData->append(tr("Time"));
  5116. }
  5117. /*:439*//*440:*/
  5118. #line 10188 "./typica.w"
  5119. MeasurementModel::~MeasurementModel()
  5120. {
  5121. clear();
  5122. delete entries;
  5123. delete hData;
  5124. }
  5125. /*:440*//*441:*/
  5126. #line 10200 "./typica.w"
  5127. int MeasurementModel::rowCount(const QModelIndex&parent)const
  5128. {
  5129. if(parent==QModelIndex())
  5130. {
  5131. return entries->size();
  5132. }
  5133. return 0;
  5134. }
  5135. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5136. {
  5137. if(parent==QModelIndex())
  5138. {
  5139. return colcount;
  5140. }
  5141. return 0;
  5142. }
  5143. /*:441*//*442:*/
  5144. #line 10227 "./typica.w"
  5145. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5146. const QVariant&value,int)
  5147. {
  5148. if(orientation==Qt::Horizontal)
  5149. {
  5150. if(hData->size()<section+1)
  5151. {
  5152. for(int i= hData->size();i<section+1;i++)
  5153. {
  5154. if(colcount<i)
  5155. {
  5156. beginInsertColumns(QModelIndex(),i,i);
  5157. }
  5158. hData->append(QString());
  5159. if(colcount<i)
  5160. {
  5161. endInsertColumns();
  5162. }
  5163. }
  5164. }
  5165. hData->replace(section,value.toString());
  5166. emit headerDataChanged(orientation,section,section);
  5167. if(colcount<section+1)
  5168. {
  5169. colcount= section+1;
  5170. }
  5171. return true;
  5172. }
  5173. return false;
  5174. }
  5175. /*:442*//*443:*/
  5176. #line 10267 "./typica.w"
  5177. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5178. {
  5179. beginResetModel();
  5180. unit= scale;
  5181. endResetModel();
  5182. }
  5183. Units::Unit MeasurementModel::displayUnits()
  5184. {
  5185. return unit;
  5186. }
  5187. /*:443*//*444:*/
  5188. #line 10293 "./typica.w"
  5189. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5190. {
  5191. /*435:*/
  5192. #line 10108 "./typica.w"
  5193. bool valid= false;
  5194. if(index.isValid())
  5195. {
  5196. if(index.row()<entries->size())
  5197. {
  5198. if(index.column()<colcount)
  5199. {
  5200. valid= true;
  5201. }
  5202. }
  5203. }
  5204. /*:435*/
  5205. #line 10296 "./typica.w"
  5206. if(!valid)
  5207. {
  5208. return QVariant();
  5209. }
  5210. MeasurementList*row= entries->at(index.row());
  5211. if(role==Qt::UserRole)
  5212. {
  5213. return QVariant(row->at(index.column()));
  5214. }
  5215. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5216. {
  5217. if(index.column()> row->size())
  5218. {
  5219. return QVariant();
  5220. }
  5221. else
  5222. {
  5223. if(index.column()==0)
  5224. {
  5225. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5226. }
  5227. else if(lastTemperature->contains(index.column()))
  5228. {
  5229. QVariantMap v= row->at(index.column()).toMap();
  5230. if(!v.contains("measurement"))
  5231. {
  5232. return QVariant();
  5233. }
  5234. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5235. {
  5236. return v.value("measurement");
  5237. }
  5238. else
  5239. {
  5240. if(v.contains("relative"))
  5241. {
  5242. if(v.value("relative").toBool())
  5243. {
  5244. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5245. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5246. }
  5247. }
  5248. return QVariant(QString("%1").
  5249. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5250. (Units::Unit)(v.value("unit").toInt()),unit)));
  5251. }
  5252. }
  5253. return QVariant(row->at(index.column()).toString());
  5254. }
  5255. }
  5256. return QVariant();
  5257. }
  5258. /*:444*//*445:*/
  5259. #line 10352 "./typica.w"
  5260. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5261. int role)const
  5262. {
  5263. if(orientation==Qt::Horizontal)
  5264. {
  5265. if(role==Qt::DisplayRole)
  5266. {
  5267. if(section<hData->size())
  5268. {
  5269. return QVariant(hData->at(section));
  5270. }
  5271. }
  5272. }
  5273. return QVariant();
  5274. }
  5275. /*:445*//*446:*/
  5276. #line 10379 "./typica.w"
  5277. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5278. {
  5279. /*435:*/
  5280. #line 10108 "./typica.w"
  5281. bool valid= false;
  5282. if(index.isValid())
  5283. {
  5284. if(index.row()<entries->size())
  5285. {
  5286. if(index.column()<colcount)
  5287. {
  5288. valid= true;
  5289. }
  5290. }
  5291. }
  5292. /*:435*/
  5293. #line 10382 "./typica.w"
  5294. if(valid)
  5295. {
  5296. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5297. }
  5298. return 0;
  5299. }
  5300. /*:446*//*447:*/
  5301. #line 10394 "./typica.w"
  5302. QModelIndex MeasurementModel::index(int row,int column,
  5303. const QModelIndex&parent)const
  5304. {
  5305. if(parent==QModelIndex())
  5306. {
  5307. if(row<entries->size()&&entries->isEmpty()==false)
  5308. {
  5309. if(column<entries->at(row)->size())
  5310. {
  5311. return createIndex(row,column);
  5312. }
  5313. }
  5314. }
  5315. return QModelIndex();
  5316. }
  5317. /*:447*/
  5318. #line 550 "./typica.w"
  5319. /*449:*/
  5320. #line 10445 "./typica.w"
  5321. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5322. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5323. {
  5324. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5325. }
  5326. /*:449*//*450:*/
  5327. #line 10460 "./typica.w"
  5328. void AnnotationButton::annotate()
  5329. {
  5330. if(note.contains("%1"))
  5331. {
  5332. count++;
  5333. emit annotation(note.arg(count),tc,ac);
  5334. }
  5335. else
  5336. {
  5337. emit annotation(note,tc,ac);
  5338. }
  5339. }
  5340. /*:450*//*451:*/
  5341. #line 10478 "./typica.w"
  5342. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5343. {
  5344. tc= tempcolumn;
  5345. }
  5346. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5347. {
  5348. ac= annotationcolumn;
  5349. }
  5350. void AnnotationButton::setAnnotation(const QString&annotation)
  5351. {
  5352. note= annotation;
  5353. }
  5354. /*:451*//*452:*/
  5355. #line 10497 "./typica.w"
  5356. void AnnotationButton::resetCount()
  5357. {
  5358. count= 0;
  5359. }
  5360. /*:452*/
  5361. #line 551 "./typica.w"
  5362. /*457:*/
  5363. #line 10580 "./typica.w"
  5364. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5365. const QString&postt,
  5366. QWidget*parent)
  5367. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5368. {
  5369. resetChange();
  5370. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5371. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5372. }
  5373. /*:457*//*458:*/
  5374. #line 10597 "./typica.w"
  5375. void AnnotationSpinBox::resetChange()
  5376. {
  5377. change= true;
  5378. }
  5379. /*:458*//*459:*/
  5380. #line 10608 "./typica.w"
  5381. void AnnotationSpinBox::annotate()
  5382. {
  5383. if(change)
  5384. {
  5385. change= false;
  5386. emit annotation(QString("%1%2%3").arg(pretext).
  5387. arg(value()).arg(posttext),tc,ac);
  5388. }
  5389. }
  5390. /*:459*//*460:*/
  5391. #line 10621 "./typica.w"
  5392. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5393. {
  5394. tc= tempcolumn;
  5395. }
  5396. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5397. {
  5398. ac= annotationcolumn;
  5399. }
  5400. void AnnotationSpinBox::setPretext(const QString&pret)
  5401. {
  5402. pretext= pret;
  5403. }
  5404. void AnnotationSpinBox::setPosttext(const QString&postt)
  5405. {
  5406. posttext= postt;
  5407. }
  5408. /*:460*/
  5409. #line 552 "./typica.w"
  5410. /*467:*/
  5411. #line 10790 "./typica.w"
  5412. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5413. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5414. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5415. stopAction(new QAction(tr("Stop"),NULL)),
  5416. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5417. relative(QTime::currentTime()),base(QTime(0,0,0))
  5418. {
  5419. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5420. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5421. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5422. clock.setInterval(500);
  5423. clock.setSingleShot(false);
  5424. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5425. setSegmentStyle(Filled);
  5426. updateDisplay();
  5427. }
  5428. /*:467*//*468:*/
  5429. #line 10811 "./typica.w"
  5430. void TimerDisplay::updateTime()
  5431. {
  5432. QTime time;
  5433. int cseconds= 0;
  5434. int oseconds= 0;
  5435. int r= 0;
  5436. QTime nt= QTime(0,0,0);
  5437. int n= 0;
  5438. int bseconds= 0;
  5439. switch(m)
  5440. {
  5441. case TimerDisplay::CountUp:
  5442. /*469:*/
  5443. #line 10843 "./typica.w"
  5444. /*470:*/
  5445. #line 10856 "./typica.w"
  5446. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5447. time= QTime::currentTime();
  5448. cseconds= TIMETOINT(time);
  5449. oseconds= TIMETOINT(relative);
  5450. r= cseconds-oseconds;
  5451. /*:470*/
  5452. #line 10844 "./typica.w"
  5453. nt= nt.addSecs(r);
  5454. if(nt!=s)
  5455. {
  5456. s= nt;
  5457. emit valueChanged(s);
  5458. }
  5459. /*:469*/
  5460. #line 10824 "./typica.w"
  5461. ;
  5462. break;
  5463. case TimerDisplay::CountDown:
  5464. /*471:*/
  5465. #line 10868 "./typica.w"
  5466. if(s> QTime(0,0,0))
  5467. {
  5468. /*470:*/
  5469. #line 10856 "./typica.w"
  5470. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5471. time= QTime::currentTime();
  5472. cseconds= TIMETOINT(time);
  5473. oseconds= TIMETOINT(relative);
  5474. r= cseconds-oseconds;
  5475. /*:470*/
  5476. #line 10871 "./typica.w"
  5477. bseconds= TIMETOINT(base);
  5478. n= bseconds-r;
  5479. nt= nt.addSecs(n);
  5480. if(nt!=s)
  5481. {
  5482. s= nt;
  5483. emit valueChanged(s);
  5484. }
  5485. }else{
  5486. stopTimer();
  5487. }
  5488. /*:471*/
  5489. #line 10827 "./typica.w"
  5490. ;
  5491. break;
  5492. case TimerDisplay::Clock:
  5493. /*472:*/
  5494. #line 10887 "./typica.w"
  5495. time= QTime::currentTime();
  5496. if(time!=s)
  5497. {
  5498. s= time;
  5499. emit valueChanged(s);
  5500. }
  5501. /*:472*/
  5502. #line 10830 "./typica.w"
  5503. ;
  5504. break;
  5505. default:
  5506. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5507. break;
  5508. }
  5509. updateDisplay();
  5510. }
  5511. /*:468*//*473:*/
  5512. #line 10899 "./typica.w"
  5513. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5514. void TimerDisplay::startTimer()
  5515. {
  5516. if(!running)
  5517. {
  5518. relative= QTime::currentTime();
  5519. if(ar)
  5520. {
  5521. reset();
  5522. }
  5523. else
  5524. {
  5525. relative= TIMESUBTRACT(relative,s);
  5526. }
  5527. if(m==Clock)
  5528. {
  5529. updateTime();
  5530. }
  5531. base= s;
  5532. clock.start();
  5533. running= true;
  5534. emit runStateChanged(true);
  5535. }
  5536. }
  5537. /*:473*//*474:*/
  5538. #line 10929 "./typica.w"
  5539. void TimerDisplay::stopTimer()
  5540. {
  5541. if(running)
  5542. {
  5543. clock.stop();
  5544. running= false;
  5545. emit runStateChanged(false);
  5546. }
  5547. }
  5548. /*:474*//*475:*/
  5549. #line 10942 "./typica.w"
  5550. TimerDisplay::~TimerDisplay()
  5551. {
  5552. clock.stop();
  5553. }
  5554. /*:475*//*476:*/
  5555. #line 10951 "./typica.w"
  5556. void TimerDisplay::setCountUpMode()
  5557. {
  5558. m= TimerDisplay::CountUp;
  5559. }
  5560. void TimerDisplay::setCountDownMode()
  5561. {
  5562. m= TimerDisplay::CountDown;
  5563. }
  5564. void TimerDisplay::setClockMode()
  5565. {
  5566. m= TimerDisplay::Clock;
  5567. }
  5568. /*:476*//*477:*/
  5569. #line 10969 "./typica.w"
  5570. QString TimerDisplay::value()
  5571. {
  5572. return s.toString(f);
  5573. }
  5574. QTime TimerDisplay::seconds()
  5575. {
  5576. return s;
  5577. }
  5578. TimerDisplay::TimerMode TimerDisplay::mode()
  5579. {
  5580. return m;
  5581. }
  5582. bool TimerDisplay::isRunning()
  5583. {
  5584. return running;
  5585. }
  5586. QTime TimerDisplay::resetValue()
  5587. {
  5588. return r;
  5589. }
  5590. QString TimerDisplay::displayFormat()
  5591. {
  5592. return f;
  5593. }
  5594. bool TimerDisplay::autoReset()
  5595. {
  5596. return ar;
  5597. }
  5598. /*:477*//*478:*/
  5599. #line 11007 "./typica.w"
  5600. void TimerDisplay::setTimer(QTime value)
  5601. {
  5602. if(value.isValid())
  5603. {
  5604. s= value;
  5605. updateDisplay();
  5606. emit valueChanged(value);
  5607. }
  5608. }
  5609. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5610. {
  5611. m= mode;
  5612. }
  5613. void TimerDisplay::setResetValue(QTime value)
  5614. {
  5615. r= value;
  5616. }
  5617. void TimerDisplay::setDisplayFormat(QString format)
  5618. {
  5619. f= format;
  5620. setNumDigits(format.length());
  5621. }
  5622. void TimerDisplay::setAutoReset(bool reset)
  5623. {
  5624. ar= reset;
  5625. }
  5626. /*:478*//*479:*/
  5627. #line 11042 "./typica.w"
  5628. void TimerDisplay::copyTimer()
  5629. {
  5630. QApplication::clipboard()->setText(value());
  5631. }
  5632. /*:479*//*480:*/
  5633. #line 11051 "./typica.w"
  5634. void TimerDisplay::reset()
  5635. {
  5636. if(!running)
  5637. {
  5638. s= r;
  5639. updateDisplay();
  5640. }
  5641. }
  5642. /*:480*//*481:*/
  5643. #line 11064 "./typica.w"
  5644. void TimerDisplay::updateDisplay()
  5645. {
  5646. display(value());
  5647. }
  5648. /*:481*/
  5649. #line 553 "./typica.w"
  5650. /*488:*/
  5651. #line 11189 "./typica.w"
  5652. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5653. {
  5654. int x= rect.x();
  5655. int y= rect.y();
  5656. QLayoutItem*item;
  5657. if(orientation==Qt::Horizontal)
  5658. {
  5659. /*489:*/
  5660. #line 11213 "./typica.w"
  5661. foreach(item,itemList)
  5662. {
  5663. int nextX= x+item->sizeHint().width()+spacing();
  5664. int right= x+item->sizeHint().width();
  5665. if(item==itemList.last())
  5666. {
  5667. right= rect.right();
  5668. }
  5669. int bottom= rect.bottom();
  5670. if(!testOnly)
  5671. {
  5672. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5673. }
  5674. x= nextX;
  5675. }
  5676. /*:489*/
  5677. #line 11197 "./typica.w"
  5678. }
  5679. else
  5680. {
  5681. /*490:*/
  5682. #line 11232 "./typica.w"
  5683. foreach(item,itemList)
  5684. {
  5685. int nextY= y+item->sizeHint().height()+spacing();
  5686. int bottom= y+item->sizeHint().height();
  5687. if(item==itemList.last())
  5688. {
  5689. bottom= rect.bottom();
  5690. }
  5691. int right= rect.right();
  5692. if(!testOnly)
  5693. {
  5694. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5695. }
  5696. y= nextY;
  5697. }
  5698. /*:490*/
  5699. #line 11201 "./typica.w"
  5700. }
  5701. return y;
  5702. }
  5703. /*:488*//*491:*/
  5704. #line 11256 "./typica.w"
  5705. QSize PackLayout::minimumSize()const
  5706. {
  5707. QSize size;
  5708. QLayoutItem*item;
  5709. foreach(item,itemList)
  5710. {
  5711. if(orientation==Qt::Horizontal)
  5712. {
  5713. size+= QSize(item->minimumSize().width(),0);
  5714. if(size.height()<item->minimumSize().height())
  5715. {
  5716. size.setHeight(item->minimumSize().height());
  5717. }
  5718. }
  5719. else
  5720. {
  5721. size+= QSize(0,item->minimumSize().height());
  5722. if(size.width()<item->minimumSize().width())
  5723. {
  5724. size.setWidth(item->minimumSize().width());
  5725. }
  5726. }
  5727. }
  5728. size+= QSize(2*margin(),2*margin());
  5729. return size;
  5730. }
  5731. /*:491*//*492:*/
  5732. #line 11288 "./typica.w"
  5733. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5734. QLayout(parent)
  5735. {
  5736. setMargin(margin);
  5737. setSpacing(spacing);
  5738. setOrientation(Qt::Horizontal);
  5739. }
  5740. PackLayout::PackLayout(int spacing)
  5741. {
  5742. setSpacing(spacing);
  5743. setOrientation(Qt::Horizontal);
  5744. }
  5745. /*:492*//*493:*/
  5746. #line 11306 "./typica.w"
  5747. PackLayout::~PackLayout()
  5748. {
  5749. QLayoutItem*item;
  5750. while((item= takeAt(0)))
  5751. {
  5752. delete item;
  5753. }
  5754. }
  5755. /*:493*//*494:*/
  5756. #line 11320 "./typica.w"
  5757. QLayoutItem*PackLayout::takeAt(int index)
  5758. {
  5759. if(index>=0&&index<itemList.size())
  5760. {
  5761. return itemList.takeAt(index);
  5762. }
  5763. else
  5764. {
  5765. return NULL;
  5766. }
  5767. }
  5768. /*:494*//*495:*/
  5769. #line 11336 "./typica.w"
  5770. QLayoutItem*PackLayout::itemAt(int index)const
  5771. {
  5772. if(index>=0&&index<itemList.size())
  5773. {
  5774. return itemList.at(index);
  5775. }
  5776. else
  5777. {
  5778. return NULL;
  5779. }
  5780. }
  5781. /*:495*//*496:*/
  5782. #line 11359 "./typica.w"
  5783. void PackLayout::addItem(QLayoutItem*item)
  5784. {
  5785. itemList.append(item);
  5786. }
  5787. /*:496*//*497:*/
  5788. #line 11367 "./typica.w"
  5789. int PackLayout::count()const
  5790. {
  5791. return itemList.size();
  5792. }
  5793. /*:497*//*498:*/
  5794. #line 11379 "./typica.w"
  5795. Qt::Orientations PackLayout::expandingDirections()const
  5796. {
  5797. return Qt::Vertical|Qt::Horizontal;
  5798. }
  5799. bool PackLayout::hasHeightForWidth()const
  5800. {
  5801. return false;
  5802. }
  5803. int PackLayout::heightForWidth(int width)const
  5804. {
  5805. return doLayout(QRect(0,0,width,0),true);
  5806. }
  5807. void PackLayout::setGeometry(const QRect&rect)
  5808. {
  5809. QLayout::setGeometry(rect);
  5810. doLayout(rect,false);
  5811. }
  5812. QSize PackLayout::sizeHint()const
  5813. {
  5814. return minimumSize();
  5815. }
  5816. /*:498*//*499:*/
  5817. #line 11410 "./typica.w"
  5818. void PackLayout::setOrientation(Qt::Orientations direction)
  5819. {
  5820. orientation= direction;
  5821. doLayout(geometry(),false);
  5822. }
  5823. /*:499*/
  5824. #line 554 "./typica.w"
  5825. /*501:*/
  5826. #line 11449 "./typica.w"
  5827. SceneButton::SceneButton():QGraphicsScene()
  5828. {
  5829. }
  5830. SceneButton::~SceneButton()
  5831. {
  5832. }
  5833. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5834. {
  5835. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5836. }
  5837. /*:501*/
  5838. #line 555 "./typica.w"
  5839. /*503:*/
  5840. #line 11495 "./typica.w"
  5841. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5842. Qt::Orientations orientation,
  5843. QWidget*parent,Qt::WindowFlags f):
  5844. QWidget(parent,f),label(new QGraphicsView()),
  5845. scene(new SceneButton())
  5846. {
  5847. layout= new PackLayout(this);
  5848. layout->setOrientation(orientation);
  5849. /*504:*/
  5850. #line 11515 "./typica.w"
  5851. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5852. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5853. label->setFrameShape(QFrame::NoFrame);
  5854. label->setInteractive(true);
  5855. /*:504*/
  5856. #line 11504 "./typica.w"
  5857. /*505:*/
  5858. #line 11526 "./typica.w"
  5859. scene->setBackgroundBrush(Qt::cyan);
  5860. text= scene->addText(labeltext);
  5861. if(orientation==Qt::Horizontal)
  5862. {
  5863. text->rotate(270.0);
  5864. }
  5865. label->setScene(scene);
  5866. /*:505*/
  5867. #line 11505 "./typica.w"
  5868. /*506:*/
  5869. #line 11544 "./typica.w"
  5870. if(orientation==Qt::Horizontal)
  5871. {
  5872. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5873. }
  5874. else
  5875. {
  5876. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5877. }
  5878. label->centerOn(text);
  5879. /*:506*/
  5880. #line 11506 "./typica.w"
  5881. /*507:*/
  5882. #line 11559 "./typica.w"
  5883. layout->addWidget(label);
  5884. layout->addWidget(widget);
  5885. if(orientation==Qt::Horizontal)
  5886. {
  5887. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5888. widget->sizeHint().height());
  5889. }
  5890. else
  5891. {
  5892. setMinimumSize(widget->sizeHint().width(),
  5893. widget->sizeHint().height()+label->sizeHint().height());
  5894. }
  5895. /*:507*/
  5896. #line 11507 "./typica.w"
  5897. }
  5898. /*:503*//*508:*/
  5899. #line 11576 "./typica.w"
  5900. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5901. {
  5902. scene->setBackgroundBrush(background);
  5903. }
  5904. void WidgetDecorator::setTextColor(QColor color)
  5905. {
  5906. text->setDefaultTextColor(color);
  5907. }
  5908. /*:508*//*509:*/
  5909. #line 11589 "./typica.w"
  5910. WidgetDecorator::~WidgetDecorator()
  5911. {
  5912. }
  5913. /*:509*/
  5914. #line 556 "./typica.w"
  5915. /*514:*/
  5916. #line 11688 "./typica.w"
  5917. void LogEditWindow::addTheRows()
  5918. {
  5919. QTime s= startTime->time();
  5920. while(s<endTime->time())
  5921. {
  5922. model->newMeasurement(Measurement(0,s),1);
  5923. s= s.addSecs(interval->value());
  5924. }
  5925. model->newMeasurement(Measurement(0,endTime->time()),1);
  5926. }
  5927. /*:514*//*515:*/
  5928. #line 11702 "./typica.w"
  5929. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5930. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5931. addRowsLayout(new QHBoxLayout(NULL)),
  5932. startTimeLabel(new QLabel("Start Time")),
  5933. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5934. endTimeLabel(new QLabel("End Time")),
  5935. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5936. intervalLabel(new QLabel("Interval (seconds)")),
  5937. interval(new QSpinBox()),
  5938. addRows(new QPushButton("Add Rows")),
  5939. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5940. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5941. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5942. model(new MeasurementModel()),
  5943. log(new QTableView())
  5944. {
  5945. /*516:*/
  5946. #line 11739 "./typica.w"
  5947. QSettings settings;
  5948. resize(settings.value("logSize",QSize(620,400)).toSize());
  5949. move(settings.value("logPos",QPoint(200,60)).toPoint());
  5950. /*:516*/
  5951. #line 11719 "./typica.w"
  5952. /*517:*/
  5953. #line 11752 "./typica.w"
  5954. mainLayout->setOrientation(Qt::Vertical);
  5955. addRowsLayout->addSpacing(10);
  5956. addRowsLayout->addWidget(startTimeLabel);
  5957. addRowsLayout->addWidget(startTime);
  5958. addRowsLayout->addSpacing(10);
  5959. startTime->setDisplayFormat("mm:ss");
  5960. addRowsLayout->addWidget(endTimeLabel);
  5961. addRowsLayout->addWidget(endTime);
  5962. addRowsLayout->addSpacing(10);
  5963. endTime->setDisplayFormat("mm:ss");
  5964. addRowsLayout->addWidget(intervalLabel);
  5965. addRowsLayout->addWidget(interval);
  5966. addRowsLayout->addSpacing(10);
  5967. interval->setRange(0,60);
  5968. interval->setValue(30);
  5969. addRowsLayout->addWidget(addRows);
  5970. addRowsLayout->addSpacing(10);
  5971. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  5972. /*:517*/
  5973. #line 11720 "./typica.w"
  5974. /*518:*/
  5975. #line 11775 "./typica.w"
  5976. model->setHeaderData(0,Qt::Horizontal,"Time");
  5977. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  5978. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  5979. model->clear();
  5980. /*:518*/
  5981. #line 11721 "./typica.w"
  5982. /*519:*/
  5983. #line 11784 "./typica.w"
  5984. log->setModel(model);
  5985. log->setColumnWidth(0,100);
  5986. log->setColumnWidth(1,100);
  5987. log->setColumnWidth(2,100);
  5988. /*:519*/
  5989. #line 11722 "./typica.w"
  5990. mainLayout->addItem(addRowsLayout);
  5991. mainLayout->addWidget(log);
  5992. centralWidget->setLayout(mainLayout);
  5993. setCentralWidget(centralWidget);
  5994. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  5995. fileMenu->addAction(openXml);
  5996. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  5997. fileMenu->addAction(saveXml);
  5998. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  5999. fileMenu->addAction(saveCsv);
  6000. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  6001. }
  6002. /*:515*//*520:*/
  6003. #line 11795 "./typica.w"
  6004. void LogEditWindow::saveXML()
  6005. {
  6006. QSettings settings;
  6007. QString lastDir= settings.value("lastDirectory").toString();
  6008. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  6009. lastDir,"",0);
  6010. QFile file(filename);
  6011. XMLOutput writer(model,&file,0);
  6012. writer.addTemperatureColumn("Temperature",1);
  6013. writer.addAnnotationColumn("Annotation",2);
  6014. if(writer.output())
  6015. {
  6016. QFileInfo info(filename);
  6017. QDir directory= info.dir();
  6018. lastDir= directory.path();
  6019. settings.setValue("lastDirectory",lastDir);
  6020. }
  6021. }
  6022. void LogEditWindow::saveCSV()
  6023. {
  6024. QSettings settings;
  6025. QString lastDir= settings.value("lastDirectory").toString();
  6026. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  6027. lastDir,"",0);
  6028. QFile file(filename);
  6029. CSVOutput writer(model,&file,0);
  6030. writer.addTemperatureColumn("Temperature",1);
  6031. writer.addAnnotationColumn("Annotation",2);
  6032. if(writer.output())
  6033. {
  6034. QFileInfo info(filename);
  6035. QDir directory= info.dir();
  6036. lastDir= directory.path();
  6037. settings.setValue("lastDirectory",lastDir);
  6038. }
  6039. }
  6040. /*:520*//*521:*/
  6041. #line 11838 "./typica.w"
  6042. void LogEditWindow::openXML()
  6043. {
  6044. QSettings settings;
  6045. QString lastDir= settings.value("lastDirectory").toString();
  6046. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  6047. lastDir,"",0);
  6048. if(filename.isNull())
  6049. {
  6050. return;
  6051. }
  6052. QFile file(filename);
  6053. XMLInput reader(&file,1);
  6054. connect(&reader,SIGNAL(measure(Measurement,int)),
  6055. model,SLOT(newMeasurement(Measurement,int)));
  6056. connect(&reader,SIGNAL(annotation(QString,int,int)),
  6057. model,SLOT(newAnnotation(QString,int,int)));
  6058. if(reader.input())
  6059. {
  6060. QFileInfo info(filename);
  6061. setWindowTitle(QString(tr("%1 - %2")).
  6062. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  6063. QDir directory= info.dir();
  6064. lastDir= directory.path();
  6065. settings.setValue("lastDirectory",lastDir);
  6066. }
  6067. }
  6068. /*:521*//*522:*/
  6069. #line 11869 "./typica.w"
  6070. void LogEditWindow::closeEvent(QCloseEvent*event)
  6071. {
  6072. QSettings settings;
  6073. settings.setValue("logSize",size());
  6074. settings.setValue("logPos",pos());
  6075. event->accept();
  6076. }
  6077. /*:522*/
  6078. #line 557 "./typica.w"
  6079. /*528:*/
  6080. #line 11984 "./typica.w"
  6081. bool XMLOutput::output()
  6082. {
  6083. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6084. {
  6085. return false;
  6086. }
  6087. QXmlStreamWriter xmlout(out);
  6088. xmlout.writeStartDocument("1.0");
  6089. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  6090. xmlout.writeStartElement("roastlog");
  6091. /*529:*/
  6092. #line 12017 "./typica.w"
  6093. foreach(int c,temperatureColumns.keys())
  6094. {
  6095. xmlout.writeStartElement("tempseries");
  6096. xmlout.writeAttribute("name",temperatureColumns.value(c));
  6097. xmlout.writeEndElement();
  6098. }
  6099. foreach(int c,controlColumns.keys())
  6100. {
  6101. xmlout.writeStartElement("controlseries");
  6102. xmlout.writeAttribute("name",controlColumns.value(c));
  6103. xmlout.writeEndElement();
  6104. }
  6105. foreach(int c,annotationColumns.keys())
  6106. {
  6107. xmlout.writeStartElement("noteseries");
  6108. xmlout.writeAttribute("name",annotationColumns.value(c));
  6109. xmlout.writeEndElement();
  6110. }
  6111. /*:529*/
  6112. #line 11995 "./typica.w"
  6113. xmlout.writeStartElement("roast");
  6114. bool oresult;
  6115. for(int i= 0;i<data->rowCount();i++)
  6116. {
  6117. /*530:*/
  6118. #line 12042 "./typica.w"
  6119. oresult= false;
  6120. foreach(int c,temperatureColumns.keys())
  6121. {
  6122. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6123. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6124. {
  6125. oresult= true;
  6126. break;
  6127. }
  6128. }
  6129. foreach(int c,controlColumns.keys())
  6130. {
  6131. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6132. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6133. {
  6134. oresult= true;
  6135. break;
  6136. }
  6137. }
  6138. if(oresult==false)
  6139. {
  6140. foreach(int c,annotationColumns.keys())
  6141. {
  6142. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6143. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6144. isEmpty()))
  6145. {
  6146. oresult= true;
  6147. break;
  6148. }
  6149. }
  6150. }
  6151. /*:530*/
  6152. #line 12000 "./typica.w"
  6153. if(oresult)
  6154. {
  6155. /*531:*/
  6156. #line 12081 "./typica.w"
  6157. xmlout.writeStartElement("tuple");
  6158. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6159. Qt::DisplayRole).toString());
  6160. foreach(int c,temperatureColumns.keys())
  6161. {
  6162. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6163. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6164. {
  6165. xmlout.writeStartElement("temperature");
  6166. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6167. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6168. {
  6169. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6170. {
  6171. xmlout.writeAttribute("relative","true");
  6172. }
  6173. }
  6174. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6175. toString());
  6176. xmlout.writeEndElement();
  6177. }
  6178. }
  6179. foreach(int c,controlColumns.keys())
  6180. {
  6181. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6182. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6183. {
  6184. xmlout.writeStartElement("control");
  6185. xmlout.writeAttribute("series",controlColumns.value(c));
  6186. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6187. xmlout.writeEndElement();
  6188. }
  6189. }
  6190. foreach(int c,annotationColumns.keys())
  6191. {
  6192. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6193. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6194. {
  6195. xmlout.writeStartElement("annotation");
  6196. xmlout.writeAttribute("series",annotationColumns.value(c));
  6197. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6198. toString());
  6199. xmlout.writeEndElement();
  6200. }
  6201. }
  6202. xmlout.writeEndElement();
  6203. /*:531*/
  6204. #line 12003 "./typica.w"
  6205. }
  6206. }
  6207. xmlout.writeEndElement();
  6208. xmlout.writeEndElement();
  6209. xmlout.writeEndDocument();
  6210. out->close();
  6211. return true;
  6212. }
  6213. /*:528*//*532:*/
  6214. #line 12131 "./typica.w"
  6215. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6216. :QObject(NULL),data(model),out(device),time(timec)
  6217. {
  6218. }
  6219. void XMLOutput::setModel(MeasurementModel*model)
  6220. {
  6221. data= model;
  6222. }
  6223. void XMLOutput::setTimeColumn(int column)
  6224. {
  6225. time= column;
  6226. }
  6227. void XMLOutput::setDevice(QIODevice*device)
  6228. {
  6229. out= device;
  6230. }
  6231. /*:532*//*533:*/
  6232. #line 12160 "./typica.w"
  6233. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6234. {
  6235. temperatureColumns.insert(column,series);
  6236. }
  6237. void XMLOutput::addControlColumn(const QString&series,int column)
  6238. {
  6239. controlColumns.insert(column,series);
  6240. }
  6241. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6242. {
  6243. annotationColumns.insert(column,series);
  6244. }
  6245. /*:533*/
  6246. #line 558 "./typica.w"
  6247. /*535:*/
  6248. #line 12217 "./typica.w"
  6249. bool XMLInput::input()
  6250. {
  6251. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6252. {
  6253. return false;
  6254. }
  6255. QXmlStreamReader xmlin(in);
  6256. QMap<QString,int> temperatureColumns;
  6257. QMap<QString,int> annotationColumns;
  6258. int nextColumn= firstc;
  6259. /*536:*/
  6260. #line 12248 "./typica.w"
  6261. while(!xmlin.isDTD())
  6262. {
  6263. xmlin.readNext();
  6264. }
  6265. if(xmlin.isDTD())
  6266. {
  6267. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6268. {
  6269. /*537:*/
  6270. #line 12270 "./typica.w"
  6271. emit newTemperatureColumn(firstc,"Bean");
  6272. emit newAnnotationColumn(firstc+1,"Note");
  6273. emit lastColumn(firstc+1);
  6274. /*:537*/
  6275. #line 12257 "./typica.w"
  6276. }
  6277. else
  6278. {
  6279. xmlin.readNext();
  6280. /*538:*/
  6281. #line 12279 "./typica.w"
  6282. while(xmlin.name()!="roast")
  6283. {
  6284. if(xmlin.isStartElement())
  6285. {
  6286. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6287. {
  6288. temperatureColumns.insert(xmlin.attributes().value("name").
  6289. toString(),
  6290. nextColumn);
  6291. emit newTemperatureColumn(nextColumn,
  6292. xmlin.attributes().value("name").
  6293. toString());
  6294. nextColumn++;
  6295. }
  6296. else if(xmlin.name()=="noteseries")
  6297. {
  6298. annotationColumns.insert(xmlin.attributes().value("name").
  6299. toString(),nextColumn);
  6300. emit newAnnotationColumn(nextColumn,
  6301. xmlin.attributes().value("name").
  6302. toString());
  6303. nextColumn++;
  6304. }
  6305. }
  6306. xmlin.readNext();
  6307. }
  6308. emit lastColumn(nextColumn-1);
  6309. /*:538*/
  6310. #line 12262 "./typica.w"
  6311. }
  6312. }
  6313. /*:536*/
  6314. #line 12228 "./typica.w"
  6315. QTime timeval= QTime();
  6316. double tempval= 0;
  6317. QString noteval= QString();
  6318. int column;
  6319. int counter= 0;
  6320. while(!xmlin.atEnd())
  6321. {
  6322. /*539:*/
  6323. #line 12320 "./typica.w"
  6324. xmlin.readNext();
  6325. if(xmlin.isStartElement())
  6326. {
  6327. /*540:*/
  6328. #line 12346 "./typica.w"
  6329. if(xmlin.name()=="time")
  6330. {
  6331. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6332. }
  6333. else if(xmlin.name()=="temperature")
  6334. {
  6335. column= xmlin.attributes().hasAttribute("series")?
  6336. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6337. bool relative= (xmlin.attributes().value("relative")=="true");
  6338. tempval= xmlin.readElementText().toDouble();
  6339. Measurement measurement(tempval,timeval);
  6340. if(relative)
  6341. {
  6342. measurement.insert("relative",true);
  6343. }
  6344. emit measure(measurement,column);
  6345. }
  6346. else if(xmlin.name()=="control")
  6347. {
  6348. column= xmlin.attributes().value("series").toString().isEmpty()?
  6349. firstc:temperatureColumns.value(xmlin.attributes().
  6350. value("series").toString());
  6351. tempval= xmlin.readElementText().toDouble();
  6352. Measurement measurement(tempval,timeval,Units::Unitless);
  6353. emit measure(measurement,column);
  6354. }
  6355. else if(xmlin.name()=="annotation")
  6356. {
  6357. column= xmlin.attributes().value("series").toString().isEmpty()?
  6358. firstc+1:annotationColumns.value(xmlin.attributes().
  6359. value("series").toString());
  6360. noteval= xmlin.readElementText();
  6361. if(!noteval.isEmpty())
  6362. {
  6363. emit annotation(noteval,firstc,column);
  6364. }
  6365. }
  6366. /*:540*/
  6367. #line 12324 "./typica.w"
  6368. }
  6369. counter++;
  6370. if(counter%100==0)
  6371. {
  6372. QCoreApplication::processEvents();
  6373. }
  6374. /*:539*/
  6375. #line 12236 "./typica.w"
  6376. }
  6377. return true;
  6378. }
  6379. /*:535*//*541:*/
  6380. #line 12387 "./typica.w"
  6381. XMLInput::XMLInput(QIODevice*input,int c):
  6382. firstc(c),in(input)
  6383. {
  6384. }
  6385. void XMLInput::setFirstColumn(int column)
  6386. {
  6387. firstc= column;
  6388. }
  6389. void XMLInput::setDevice(QIODevice*device)
  6390. {
  6391. in= device;
  6392. }
  6393. /*:541*/
  6394. #line 559 "./typica.w"
  6395. /*546:*/
  6396. #line 12478 "./typica.w"
  6397. bool CSVOutput::output()
  6398. {
  6399. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6400. {
  6401. return false;
  6402. }
  6403. QTextStream output(out);
  6404. /*547:*/
  6405. #line 12502 "./typica.w"
  6406. output<<"Time";
  6407. foreach(int c,temperatureColumns.keys())
  6408. {
  6409. output<<','<<temperatureColumns.value(c);
  6410. }
  6411. foreach(int c,controlColumns.keys())
  6412. {
  6413. output<<','<<controlColumns.value(c);
  6414. }
  6415. foreach(int c,annotationColumns.keys())
  6416. {
  6417. output<<','<<annotationColumns.value(c);
  6418. }
  6419. output<<'\n';
  6420. /*:547*/
  6421. #line 12486 "./typica.w"
  6422. bool oresult;
  6423. for(int i= 0;i<data->rowCount();i++)
  6424. {
  6425. /*530:*/
  6426. #line 12042 "./typica.w"
  6427. oresult= false;
  6428. foreach(int c,temperatureColumns.keys())
  6429. {
  6430. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6431. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6432. {
  6433. oresult= true;
  6434. break;
  6435. }
  6436. }
  6437. foreach(int c,controlColumns.keys())
  6438. {
  6439. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6440. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6441. {
  6442. oresult= true;
  6443. break;
  6444. }
  6445. }
  6446. if(oresult==false)
  6447. {
  6448. foreach(int c,annotationColumns.keys())
  6449. {
  6450. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6451. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6452. isEmpty()))
  6453. {
  6454. oresult= true;
  6455. break;
  6456. }
  6457. }
  6458. }
  6459. /*:530*/
  6460. #line 12490 "./typica.w"
  6461. if(oresult)
  6462. {
  6463. /*548:*/
  6464. #line 12527 "./typica.w"
  6465. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6466. foreach(int c,temperatureColumns.keys())
  6467. {
  6468. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6469. }
  6470. foreach(int c,controlColumns.keys())
  6471. {
  6472. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6473. }
  6474. foreach(int c,annotationColumns.keys())
  6475. {
  6476. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6477. }
  6478. output<<'\n';
  6479. /*:548*/
  6480. #line 12493 "./typica.w"
  6481. }
  6482. }
  6483. out->close();
  6484. return true;
  6485. }
  6486. /*:546*//*549:*/
  6487. #line 12546 "./typica.w"
  6488. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6489. data(model),out(device),time(timec)
  6490. {
  6491. }
  6492. void CSVOutput::setModel(MeasurementModel*model)
  6493. {
  6494. data= model;
  6495. }
  6496. void CSVOutput::setTimeColumn(int column)
  6497. {
  6498. time= column;
  6499. }
  6500. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6501. {
  6502. temperatureColumns.insert(column,series);
  6503. }
  6504. void CSVOutput::addControlColumn(const QString&series,int column)
  6505. {
  6506. controlColumns.insert(column,series);
  6507. }
  6508. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6509. {
  6510. annotationColumns.insert(column,series);
  6511. }
  6512. void CSVOutput::setDevice(QIODevice*device)
  6513. {
  6514. out= device;
  6515. }
  6516. #line 1 "./webview.w"
  6517. /*:549*/
  6518. #line 560 "./typica.w"
  6519. /*584:*/
  6520. #line 12807 "./typica.w"
  6521. QString SaltModel::arrayLiteral(int column,int role)const
  6522. {
  6523. QString literal= "'{";
  6524. for(int i= 0;i<rowCount();i++)
  6525. {
  6526. QString datum= data(index(i,column),role).toString();
  6527. if(!datum.isEmpty())
  6528. {
  6529. literal.append(datum);
  6530. literal.append(", ");
  6531. }
  6532. }
  6533. if(literal.size()> 2)
  6534. {
  6535. literal.chop(2);
  6536. }
  6537. literal.append("}'");
  6538. return literal;
  6539. }
  6540. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6541. {
  6542. QString literal= "'{";
  6543. for(int i= 0;i<rowCount();i++)
  6544. {
  6545. QString datum= data(index(i,column),role).toString();
  6546. if(!datum.isEmpty())
  6547. {
  6548. literal.append("\"");
  6549. literal.append(datum);
  6550. literal.append("\", ");
  6551. }
  6552. }
  6553. if(literal.size()> 2)
  6554. {
  6555. literal.chop(2);
  6556. }
  6557. literal.append("}'");
  6558. return literal;
  6559. }
  6560. /*:584*//*585:*/
  6561. #line 12851 "./typica.w"
  6562. QModelIndex SaltModel::parent(const QModelIndex&)const
  6563. {
  6564. return QModelIndex();
  6565. }
  6566. /*:585*//*586:*/
  6567. #line 12870 "./typica.w"
  6568. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6569. int role)
  6570. {
  6571. /*587:*/
  6572. #line 12901 "./typica.w"
  6573. bool valid= false;
  6574. if(index.isValid())
  6575. {
  6576. if(index.row()<modelData.size())
  6577. {
  6578. if(index.column()<colcount)
  6579. {
  6580. valid= true;
  6581. }
  6582. }
  6583. }
  6584. /*:587*/
  6585. #line 12874 "./typica.w"
  6586. if(!valid)
  6587. {
  6588. return false;
  6589. }
  6590. if(index.row()==modelData.size()-1)
  6591. {
  6592. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6593. /*588:*/
  6594. #line 12917 "./typica.w"
  6595. QList<QMap<int,QVariant> > newRow;
  6596. QMap<int,QVariant> defaults;
  6597. for(int i= 0;i<colcount;i++)
  6598. {
  6599. newRow.append(defaults);
  6600. }
  6601. modelData.append(newRow);
  6602. /*:588*/
  6603. #line 12882 "./typica.w"
  6604. endInsertRows();
  6605. }
  6606. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6607. QMap<int,QVariant> cell= row.at(index.column());
  6608. cell.insert(role,value);
  6609. if(role==Qt::EditRole)
  6610. {
  6611. cell.insert(Qt::DisplayRole,value);
  6612. }
  6613. row.replace(index.column(),cell);
  6614. modelData.replace(index.row(),row);
  6615. emit dataChanged(index,index);
  6616. return true;
  6617. }
  6618. /*:586*//*589:*/
  6619. #line 12928 "./typica.w"
  6620. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6621. {
  6622. for(int i= 0;i<columns;i++)
  6623. {
  6624. hData<<"";
  6625. }
  6626. /*588:*/
  6627. #line 12917 "./typica.w"
  6628. QList<QMap<int,QVariant> > newRow;
  6629. QMap<int,QVariant> defaults;
  6630. for(int i= 0;i<colcount;i++)
  6631. {
  6632. newRow.append(defaults);
  6633. }
  6634. modelData.append(newRow);
  6635. /*:588*/
  6636. #line 12935 "./typica.w"
  6637. }
  6638. /*:589*//*590:*/
  6639. #line 12940 "./typica.w"
  6640. SaltModel::~SaltModel()
  6641. {
  6642. }
  6643. /*:590*//*591:*/
  6644. #line 12950 "./typica.w"
  6645. int SaltModel::rowCount(const QModelIndex&parent)const
  6646. {
  6647. return(parent==QModelIndex()?modelData.size():0);
  6648. }
  6649. int SaltModel::columnCount(const QModelIndex&parent)const
  6650. {
  6651. return(parent==QModelIndex()?colcount:0);
  6652. }
  6653. /*:591*//*592:*/
  6654. #line 12963 "./typica.w"
  6655. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6656. const QVariant&value,int)
  6657. {
  6658. if(orientation==Qt::Horizontal&&section<colcount)
  6659. {
  6660. hData.replace(section,value.toString());
  6661. emit headerDataChanged(orientation,section,section);
  6662. return true;
  6663. }
  6664. return false;
  6665. }
  6666. /*:592*//*593:*/
  6667. #line 12978 "./typica.w"
  6668. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6669. {
  6670. /*587:*/
  6671. #line 12901 "./typica.w"
  6672. bool valid= false;
  6673. if(index.isValid())
  6674. {
  6675. if(index.row()<modelData.size())
  6676. {
  6677. if(index.column()<colcount)
  6678. {
  6679. valid= true;
  6680. }
  6681. }
  6682. }
  6683. /*:587*/
  6684. #line 12981 "./typica.w"
  6685. if(!valid)
  6686. {
  6687. return QVariant();
  6688. }
  6689. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6690. QMap<int,QVariant> cell= row.at(index.column());
  6691. return cell.value(role,QVariant());
  6692. }
  6693. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6694. int role)const
  6695. {
  6696. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6697. section<colcount)
  6698. {
  6699. return QVariant(hData.at(section));
  6700. }
  6701. return QVariant();
  6702. }
  6703. /*:593*//*594:*/
  6704. #line 13005 "./typica.w"
  6705. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6706. {
  6707. /*587:*/
  6708. #line 12901 "./typica.w"
  6709. bool valid= false;
  6710. if(index.isValid())
  6711. {
  6712. if(index.row()<modelData.size())
  6713. {
  6714. if(index.column()<colcount)
  6715. {
  6716. valid= true;
  6717. }
  6718. }
  6719. }
  6720. /*:587*/
  6721. #line 13008 "./typica.w"
  6722. if(valid)
  6723. {
  6724. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6725. }
  6726. return 0;
  6727. }
  6728. /*:594*//*595:*/
  6729. #line 13019 "./typica.w"
  6730. QModelIndex SaltModel::index(int row,int column,
  6731. const QModelIndex&parent)const
  6732. {
  6733. if(parent==QModelIndex())
  6734. {
  6735. if(row<modelData.size()&&column<colcount)
  6736. {
  6737. return createIndex(row,column);
  6738. }
  6739. }
  6740. return QModelIndex();
  6741. }
  6742. /*:595*//*596:*/
  6743. #line 13037 "./typica.w"
  6744. void SaltModel::clear()
  6745. {
  6746. beginResetModel();
  6747. modelData.clear();
  6748. /*588:*/
  6749. #line 12917 "./typica.w"
  6750. QList<QMap<int,QVariant> > newRow;
  6751. QMap<int,QVariant> defaults;
  6752. for(int i= 0;i<colcount;i++)
  6753. {
  6754. newRow.append(defaults);
  6755. }
  6756. modelData.append(newRow);
  6757. /*:588*/
  6758. #line 13042 "./typica.w"
  6759. endResetModel();
  6760. }
  6761. /*:596*//*597:*/
  6762. #line 13051 "./typica.w"
  6763. bool SaltModel::removeRows(int row,int count,
  6764. const QModelIndex&parent)
  6765. {
  6766. if(parent==QModelIndex())
  6767. {
  6768. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6769. {
  6770. beginRemoveRows(parent,row,row+count-1);
  6771. for(int i= 0;i<count;i++)
  6772. {
  6773. modelData.removeAt(row);
  6774. }
  6775. endRemoveRows();
  6776. if(modelData.size()==0)
  6777. {
  6778. beginInsertRows(parent,0,0);
  6779. /*588:*/
  6780. #line 12917 "./typica.w"
  6781. QList<QMap<int,QVariant> > newRow;
  6782. QMap<int,QVariant> defaults;
  6783. for(int i= 0;i<colcount;i++)
  6784. {
  6785. newRow.append(defaults);
  6786. }
  6787. modelData.append(newRow);
  6788. /*:588*/
  6789. #line 13068 "./typica.w"
  6790. endInsertRows();
  6791. }
  6792. return true;
  6793. }
  6794. }
  6795. return false;
  6796. }
  6797. /*:597*//*598:*/
  6798. #line 13082 "./typica.w"
  6799. int SaltModel::findData(const QVariant&value,int column,int role)
  6800. {
  6801. for(int i= 0;i<modelData.size();i++)
  6802. {
  6803. if(modelData.at(i).size()> column)
  6804. {
  6805. if(modelData.at(i).at(column).contains(role))
  6806. {
  6807. if(modelData.at(i).at(column).value(role)==value)
  6808. {
  6809. return i;
  6810. }
  6811. }
  6812. }
  6813. }
  6814. return-1;
  6815. }
  6816. /*:598*/
  6817. #line 561 "./typica.w"
  6818. /*600:*/
  6819. #line 13146 "./typica.w"
  6820. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6821. {
  6822. SqlComboBox*widget= new SqlComboBox();
  6823. widget->setParent(parent);
  6824. for(int i= 0;i<count();i++)
  6825. {
  6826. widget->addItem(itemText(i),itemData(i));
  6827. }
  6828. return widget;
  6829. }
  6830. /*:600*//*601:*/
  6831. #line 13163 "./typica.w"
  6832. void SqlComboBox::showData(bool show)
  6833. {
  6834. dataColumnShown= show;
  6835. }
  6836. /*:601*//*602:*/
  6837. #line 13177 "./typica.w"
  6838. void SqlComboBox::addNullOption()
  6839. {
  6840. addItem(specialNullText,specialNullData);
  6841. }
  6842. void SqlComboBox::setNullText(QString nullText)
  6843. {
  6844. specialNullText= nullText;
  6845. }
  6846. void SqlComboBox::setNullData(QVariant nullData)
  6847. {
  6848. specialNullData= nullData;
  6849. }
  6850. /*:602*//*603:*/
  6851. #line 13200 "./typica.w"
  6852. void SqlComboBox::setDataColumn(int column)
  6853. {
  6854. dataColumn= column;
  6855. }
  6856. void SqlComboBox::setDisplayColumn(int column)
  6857. {
  6858. displayColumn= column;
  6859. }
  6860. /*:603*//*604:*/
  6861. #line 13214 "./typica.w"
  6862. void SqlComboBox::addSqlOptions(QString query)
  6863. {
  6864. SqlQueryConnection h;
  6865. QSqlQuery*dbquery= h.operator->();
  6866. if(!dbquery->exec(query))
  6867. {
  6868. QSqlError error= dbquery->lastError();
  6869. qDebug()<<error.databaseText();
  6870. qDebug()<<error.driverText();
  6871. qDebug()<<error.text();
  6872. qDebug()<<dbquery->lastQuery();
  6873. }
  6874. while(dbquery->next())
  6875. {
  6876. QString displayValue(dbquery->value(displayColumn).toString());
  6877. QString dataValue(dbquery->value(dataColumn).toString());
  6878. if(dataColumnShown)
  6879. {
  6880. displayValue.append(QString(" (%1)").arg(dataValue));
  6881. }
  6882. addItem(displayValue,dataValue);
  6883. }
  6884. }
  6885. /*:604*//*605:*/
  6886. #line 13250 "./typica.w"
  6887. SqlComboBox::SqlComboBox():
  6888. dataColumn(0),displayColumn(0),dataColumnShown(false),
  6889. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  6890. {
  6891. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6892. }
  6893. SqlComboBox::~SqlComboBox()
  6894. {
  6895. }
  6896. /*:605*/
  6897. #line 562 "./typica.w"
  6898. /*607:*/
  6899. #line 13289 "./typica.w"
  6900. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6901. {
  6902. delegate= widget;
  6903. }
  6904. /*:607*//*608:*/
  6905. #line 13298 "./typica.w"
  6906. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6907. const QStyleOptionViewItem&,
  6908. const QModelIndex&)const
  6909. {
  6910. return delegate->clone(parent);
  6911. }
  6912. /*:608*//*609:*/
  6913. #line 13309 "./typica.w"
  6914. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6915. const QModelIndex&index)const
  6916. {
  6917. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6918. self->setCurrentIndex(self->findData(
  6919. index.model()->data(index,
  6920. Qt::UserRole).toString()));
  6921. }
  6922. /*:609*//*610:*/
  6923. #line 13322 "./typica.w"
  6924. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6925. QAbstractItemModel*model,
  6926. const QModelIndex&index)const
  6927. {
  6928. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6929. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6930. Qt::UserRole);
  6931. model->setData(index,self->currentText(),Qt::DisplayRole);
  6932. }
  6933. /*:610*//*611:*/
  6934. #line 13335 "./typica.w"
  6935. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6936. const QStyleOptionViewItem&option,
  6937. const QModelIndex&)const
  6938. {
  6939. editor->setGeometry(option.rect);
  6940. }
  6941. /*:611*//*612:*/
  6942. #line 13346 "./typica.w"
  6943. QSize SqlComboBoxDelegate::sizeHint()const
  6944. {
  6945. return delegate->sizeHint();
  6946. }
  6947. /*:612*//*613:*/
  6948. #line 13354 "./typica.w"
  6949. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  6950. :QItemDelegate(parent)
  6951. {
  6952. }
  6953. /*:613*/
  6954. #line 563 "./typica.w"
  6955. /*576:*/
  6956. #line 12616 "./typica.w"
  6957. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  6958. {
  6959. /*577:*/
  6960. #line 12631 "./typica.w"
  6961. setOrganizationName("Wilson's Coffee & Tea");
  6962. setOrganizationDomain("wilsonscoffee.com");
  6963. setApplicationName(PROGRAM_NAME);
  6964. /*:577*/
  6965. #line 12619 "./typica.w"
  6966. /*578:*/
  6967. #line 12640 "./typica.w"
  6968. QTranslator*base= new QTranslator;
  6969. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  6970. {
  6971. installTranslator(base);
  6972. }
  6973. QTranslator*app= new QTranslator;
  6974. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  6975. {
  6976. installTranslator(app);
  6977. }
  6978. /*:578*/
  6979. #line 12620 "./typica.w"
  6980. /*295:*/
  6981. #line 123 "./measurement.w"
  6982. qRegisterMetaType<Measurement> ("Measurement");
  6983. /*:295*/
  6984. #line 12621 "./typica.w"
  6985. /*784:*/
  6986. #line 16635 "./typica.w"
  6987. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  6988. tr("NI DAQmx Base"),
  6989. "nidaqmxbase",NULL);
  6990. topLevelNodeInserters.append(inserter);
  6991. /*:784*//*792:*/
  6992. #line 16866 "./typica.w"
  6993. #ifdef Q_OS_WIN32
  6994. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  6995. topLevelNodeInserters.append(inserter);
  6996. #endif
  6997. /*:792*//*816:*/
  6998. #line 17833 "./typica.w"
  6999. #if 0
  7000. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  7001. topLevelNodeInserters.append(inserter);
  7002. #endif
  7003. /*:816*//*865:*/
  7004. #line 19346 "./typica.w"
  7005. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  7006. topLevelNodeInserters.append(inserter);
  7007. #line 1 "./modbus.w"
  7008. /*:865*//*871:*/
  7009. #line 324 "./modbus.w"
  7010. inserter= new NodeInserter(tr("ModbusNG Port"),tr("Modbus RTU Port"),"modbusngport",NULL);
  7011. topLevelNodeInserters.append(inserter);
  7012. /*:871*//*887:*/
  7013. #line 272 "./unsupportedserial.w"
  7014. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  7015. "unsupporteddevice",NULL);
  7016. topLevelNodeInserters.append(inserter);
  7017. /*:887*//*921:*/
  7018. #line 190 "./phidgets.w"
  7019. QLibrary phidgetsCheck("phidget21");
  7020. if(phidgetsCheck.load())
  7021. {
  7022. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7023. "phidgets1048",NULL);
  7024. topLevelNodeInserters.append(inserter);
  7025. phidgetsCheck.unload();
  7026. }
  7027. else
  7028. {
  7029. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  7030. if(phidgetsCheck.load())
  7031. {
  7032. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7033. "phidgets1048",NULL);
  7034. topLevelNodeInserters.append(inserter);
  7035. phidgetsCheck.unload();
  7036. }
  7037. }
  7038. /*:921*//*1012:*/
  7039. #line 1241 "./dataqsdk.w"
  7040. #ifdef Q_OS_WIN32
  7041. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  7042. "dataqsdk",NULL);
  7043. topLevelNodeInserters.append(inserter);
  7044. #endif
  7045. #line 19998 "./typica.w"
  7046. #line 1 "./scales.w"
  7047. /*:1012*//*1037:*/
  7048. #line 557 "./scales.w"
  7049. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  7050. topLevelNodeInserters.append(inserter);
  7051. #line 20000 "./typica.w"
  7052. #line 1 "./valueannotation.w"
  7053. /*:1037*/
  7054. #line 12622 "./typica.w"
  7055. }
  7056. /*:576*//*580:*/
  7057. #line 12663 "./typica.w"
  7058. QDomDocument*Application::configuration()
  7059. {
  7060. return&conf;
  7061. }
  7062. /*:580*//*581:*/
  7063. #line 12672 "./typica.w"
  7064. QSqlDatabase Application::database()
  7065. {
  7066. QString connectionName;
  7067. QSqlDatabase connection=
  7068. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  7069. do
  7070. {
  7071. connectionName= QUuid::createUuid().toString();
  7072. }while(QSqlDatabase::connectionNames().contains(connectionName));
  7073. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  7074. }
  7075. /*:581*//*719:*/
  7076. #line 15168 "./typica.w"
  7077. void Application::saveDeviceConfiguration()
  7078. {
  7079. QSettings settings;
  7080. settings.setValue("DeviceConfiguration",
  7081. QVariant(deviceConfigurationDocument.toByteArray()));
  7082. }
  7083. /*:719*//*720:*/
  7084. #line 15180 "./typica.w"
  7085. QDomDocument Application::deviceConfiguration()
  7086. {
  7087. if(deviceConfigurationDocument.isNull())
  7088. {
  7089. /*721:*/
  7090. #line 15194 "./typica.w"
  7091. QSettings settings;
  7092. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  7093. QString etext;
  7094. int eline;
  7095. int ecol;
  7096. if(document.length()==0)
  7097. {
  7098. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  7099. /*722:*/
  7100. #line 15218 "./typica.w"
  7101. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7102. emptyDocument.open(QIODevice::ReadOnly);
  7103. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7104. &etext,&eline,&ecol))
  7105. {
  7106. /*723:*/
  7107. #line 15235 "./typica.w"
  7108. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7109. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7110. qDebug()<<etext;
  7111. /*:723*/
  7112. #line 15224 "./typica.w"
  7113. }
  7114. else
  7115. {
  7116. saveDeviceConfiguration();
  7117. }
  7118. /*:722*/
  7119. #line 15203 "./typica.w"
  7120. }
  7121. else
  7122. {
  7123. if(!deviceConfigurationDocument.setContent(document,false,
  7124. &etext,&eline,&ecol))
  7125. {
  7126. /*723:*/
  7127. #line 15235 "./typica.w"
  7128. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7129. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7130. qDebug()<<etext;
  7131. /*:723*/
  7132. #line 15210 "./typica.w"
  7133. /*722:*/
  7134. #line 15218 "./typica.w"
  7135. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7136. emptyDocument.open(QIODevice::ReadOnly);
  7137. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7138. &etext,&eline,&ecol))
  7139. {
  7140. /*723:*/
  7141. #line 15235 "./typica.w"
  7142. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7143. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7144. qDebug()<<etext;
  7145. /*:723*/
  7146. #line 15224 "./typica.w"
  7147. }
  7148. else
  7149. {
  7150. saveDeviceConfiguration();
  7151. }
  7152. /*:722*/
  7153. #line 15211 "./typica.w"
  7154. }
  7155. }
  7156. /*:721*/
  7157. #line 15185 "./typica.w"
  7158. }
  7159. return deviceConfigurationDocument;
  7160. }
  7161. /*:720*//*751:*/
  7162. #line 15836 "./typica.w"
  7163. void Application::registerDeviceConfigurationWidget(QString driver,
  7164. QMetaObject widget)
  7165. {
  7166. deviceConfigurationWidgets.insert(driver,widget);
  7167. }
  7168. /*:751*//*752:*/
  7169. #line 15852 "./typica.w"
  7170. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7171. const QModelIndex&index)
  7172. {
  7173. QVariant nodeReference= index.data(Qt::UserRole);
  7174. QDomElement referenceElement= model->referenceElement(
  7175. model->data(index,Qt::UserRole).toString());
  7176. QMetaObject metaObject=
  7177. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7178. QWidget::staticMetaObject);
  7179. QWidget*editor;
  7180. if(metaObject.className()==QWidget::staticMetaObject.className())
  7181. {
  7182. editor= NULL;
  7183. }
  7184. else
  7185. {
  7186. editor= qobject_cast<QWidget*> (
  7187. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7188. Q_ARG(QModelIndex,index)));
  7189. }
  7190. return editor;
  7191. }
  7192. /*:752*/
  7193. #line 564 "./typica.w"
  7194. /*622:*/
  7195. #line 13502 "./typica.w"
  7196. SqlConnectionSetup::SqlConnectionSetup():
  7197. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7198. portnumber(new QLineEdit),
  7199. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7200. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7201. cancelButton(new QPushButton(tr("Cancel"))),
  7202. connectButton(new QPushButton(tr("Connect")))
  7203. {
  7204. driver->addItem("PostgreSQL","QPSQL");
  7205. formLayout->addRow(tr("Database driver:"),driver);
  7206. formLayout->addRow(tr("Host name:"),hostname);
  7207. formLayout->addRow(tr("Port number:"),portnumber);
  7208. portnumber->setText("5432");
  7209. formLayout->addRow(tr("Database name:"),dbname);
  7210. formLayout->addRow(tr("User name:"),user);
  7211. password->setEchoMode(QLineEdit::Password);
  7212. formLayout->addRow(tr("Password:"),password);
  7213. layout->addLayout(formLayout);
  7214. buttons->addStretch(1);
  7215. buttons->addWidget(cancelButton);
  7216. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7217. buttons->addWidget(connectButton);
  7218. layout->addLayout(buttons);
  7219. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7220. connectButton->setDefault(true);
  7221. setLayout(layout);
  7222. setModal(true);
  7223. }
  7224. SqlConnectionSetup::~SqlConnectionSetup()
  7225. {
  7226. }
  7227. /*:622*//*623:*/
  7228. #line 13540 "./typica.w"
  7229. void SqlConnectionSetup::testConnection()
  7230. {
  7231. QSqlDatabase database=
  7232. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7233. toString());
  7234. database.setConnectOptions("application_name=Typica");
  7235. database.setHostName(hostname->text());
  7236. database.setPort(portnumber->text().toInt());
  7237. database.setDatabaseName(dbname->text());
  7238. database.setUserName(user->text());
  7239. database.setPassword(password->text());
  7240. if(database.open())
  7241. {
  7242. QSettings settings;
  7243. settings.setValue("database/exists","true");
  7244. settings.setValue("database/driver",
  7245. driver->itemData(driver->currentIndex()).toString());
  7246. settings.setValue("database/hostname",hostname->text());
  7247. settings.setValue("database/portnumber",portnumber->text());
  7248. settings.setValue("database/dbname",dbname->text());
  7249. settings.setValue("database/user",user->text());
  7250. settings.setValue("database/password",password->text());
  7251. database.close();
  7252. accept();
  7253. }
  7254. else
  7255. {
  7256. QMessageBox::information(this,tr("Database connection failed"),
  7257. tr("Failed to connect to database."));
  7258. }
  7259. }
  7260. /*:623*/
  7261. #line 565 "./typica.w"
  7262. /*627:*/
  7263. #line 13645 "./typica.w"
  7264. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7265. {
  7266. setModel(new QSqlQueryModel);
  7267. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7268. this,SLOT(openRow(QModelIndex)));
  7269. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7270. this,SLOT(persistColumnResize(int,int,int)));
  7271. }
  7272. /*:627*//*628:*/
  7273. #line 13660 "./typica.w"
  7274. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7275. {
  7276. /*629:*/
  7277. #line 13669 "./typica.w"
  7278. QSettings settings;
  7279. /*630:*/
  7280. #line 13682 "./typica.w"
  7281. QWidget*topLevelWidget= this;
  7282. while(topLevelWidget->parentWidget())
  7283. {
  7284. topLevelWidget= topLevelWidget->parentWidget();
  7285. }
  7286. /*:630*/
  7287. #line 13671 "./typica.w"
  7288. settings.setValue(QString("columnWidths/%1/%2/%3").
  7289. arg(topLevelWidget->objectName()).
  7290. arg(objectName()).arg(column),
  7291. QVariant(newsize));
  7292. /*:629*/
  7293. #line 13663 "./typica.w"
  7294. }
  7295. /*:628*//*631:*/
  7296. #line 13692 "./typica.w"
  7297. void SqlQueryView::showEvent(QShowEvent*event)
  7298. {
  7299. /*632:*/
  7300. #line 13702 "./typica.w"
  7301. QSettings settings;
  7302. /*630:*/
  7303. #line 13682 "./typica.w"
  7304. QWidget*topLevelWidget= this;
  7305. while(topLevelWidget->parentWidget())
  7306. {
  7307. topLevelWidget= topLevelWidget->parentWidget();
  7308. }
  7309. /*:630*/
  7310. #line 13704 "./typica.w"
  7311. QString baseKey=
  7312. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7313. arg(objectName());
  7314. for(int i= 0;i<model()->columnCount();i++)
  7315. {
  7316. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7317. if(settings.contains(key))
  7318. {
  7319. setColumnWidth(i,settings.value(key).toInt());
  7320. }
  7321. }
  7322. /*:632*/
  7323. #line 13695 "./typica.w"
  7324. event->accept();
  7325. }
  7326. /*:631*//*633:*/
  7327. #line 13719 "./typica.w"
  7328. void SqlQueryView::openRow(const QModelIndex&index)
  7329. {
  7330. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7331. emit openEntryRow(index.row());
  7332. }
  7333. /*:633*//*634:*/
  7334. #line 13728 "./typica.w"
  7335. void SqlQueryView::setQuery(const QString&query)
  7336. {
  7337. QSqlDatabase database= AppInstance->database();
  7338. database.open();
  7339. QSqlQuery q(query,database);
  7340. ((QSqlQueryModel*)model())->setQuery(q);
  7341. database.close();
  7342. }
  7343. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7344. const QVariant&value,int role)
  7345. {
  7346. return model()->setHeaderData(section,orientation,value,role);
  7347. }
  7348. /*:634*//*635:*/
  7349. #line 13746 "./typica.w"
  7350. QVariant SqlQueryView::data(int row,int column,int role)
  7351. {
  7352. return model()->data(model()->index(row,column),role);
  7353. }
  7354. /*:635*/
  7355. #line 566 "./typica.w"
  7356. /*170:*/
  7357. #line 3939 "./typica.w"
  7358. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7359. {
  7360. QSqlDatabase database= AppInstance->database();
  7361. database.open();
  7362. q= new QSqlQuery(query,database);
  7363. connection= database.connectionName();
  7364. }
  7365. /*:170*//*171:*/
  7366. #line 3952 "./typica.w"
  7367. SqlQueryConnection::~SqlQueryConnection()
  7368. {
  7369. delete q;
  7370. {
  7371. QSqlDatabase database= QSqlDatabase::database(connection);
  7372. database.close();
  7373. }
  7374. QSqlDatabase::removeDatabase(connection);
  7375. }
  7376. /*:171*//*172:*/
  7377. #line 3966 "./typica.w"
  7378. QSqlQuery*SqlQueryConnection::operator->()const
  7379. {
  7380. return q;
  7381. }
  7382. /*:172*/
  7383. #line 567 "./typica.w"
  7384. /*654:*/
  7385. #line 14105 "./typica.w"
  7386. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7387. area(frame),configuration(description)
  7388. {
  7389. refresh();
  7390. }
  7391. ReportTable::~ReportTable()
  7392. {
  7393. }
  7394. /*:654*//*655:*/
  7395. #line 14121 "./typica.w"
  7396. void ReportTable::bind(QString placeholder,QVariant value)
  7397. {
  7398. bindings.insert(placeholder,value);
  7399. }
  7400. /*:655*//*656:*/
  7401. #line 14131 "./typica.w"
  7402. void ReportTable::refresh()
  7403. {
  7404. /*657:*/
  7405. #line 14152 "./typica.w"
  7406. QTextCursor cursor= area->firstCursorPosition();
  7407. while(cursor<area->lastCursorPosition())
  7408. {
  7409. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7410. }
  7411. cursor.removeSelectedText();
  7412. /*:657*/
  7413. #line 14134 "./typica.w"
  7414. int rows= 1;
  7415. int columns= 1;
  7416. int currentRow= 0;
  7417. QTextTable*table= cursor.insertTable(rows,columns);
  7418. /*658:*/
  7419. #line 14165 "./typica.w"
  7420. QTextTableFormat format= table->format();
  7421. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7422. if(configuration.hasAttribute("align"))
  7423. {
  7424. if(configuration.attribute("align")=="center")
  7425. {
  7426. format.setAlignment(Qt::AlignHCenter);
  7427. }
  7428. }
  7429. table->setFormat(format);
  7430. /*:658*/
  7431. #line 14139 "./typica.w"
  7432. /*659:*/
  7433. #line 14179 "./typica.w"
  7434. QDomNodeList children= configuration.childNodes();
  7435. for(int i= 0;i<children.count();i++)
  7436. {
  7437. QDomNode current;
  7438. QDomElement currentElement;
  7439. current= children.at(i);
  7440. if(current.isElement())
  7441. {
  7442. currentElement= current.toElement();
  7443. if(currentElement.tagName()=="query")
  7444. {
  7445. /*660:*/
  7446. #line 14206 "./typica.w"
  7447. SqlQueryConnection h;
  7448. QSqlQuery*query= h.operator->();
  7449. query->prepare(currentElement.text());
  7450. foreach(QString key,bindings.uniqueKeys())
  7451. {
  7452. if(currentElement.text().contains(key))
  7453. {
  7454. query->bindValue(key,bindings.value(key));
  7455. }
  7456. }
  7457. query->exec();
  7458. if(!query->next())
  7459. {
  7460. continue;
  7461. }
  7462. if(query->record().count()> columns)
  7463. {
  7464. table->appendColumns(query->record().count()-columns);
  7465. }
  7466. do
  7467. {
  7468. table->appendRows(1);
  7469. rows++;
  7470. currentRow++;
  7471. for(int j= 0;j<query->record().count();j++)
  7472. {
  7473. QTextTableCell cell= table->cellAt(currentRow,j);
  7474. cursor= cell.firstCursorPosition();
  7475. cursor.insertText(query->value(j).toString());
  7476. }
  7477. }while(query->next());
  7478. /*:660*/
  7479. #line 14191 "./typica.w"
  7480. }
  7481. else if(currentElement.tagName()=="row")
  7482. {
  7483. /*661:*/
  7484. #line 14246 "./typica.w"
  7485. table->appendRows(1);
  7486. currentRow++;
  7487. rows++;
  7488. QDomNodeList rowChildren= currentElement.childNodes();
  7489. int currentColumn= 0;
  7490. for(int j= 0;j<rowChildren.count();j++)
  7491. {
  7492. QDomNode node;
  7493. QDomElement nodeElement;
  7494. node= rowChildren.at(j);
  7495. if(node.isElement())
  7496. {
  7497. nodeElement= node.toElement();
  7498. if(nodeElement.tagName()=="cell")
  7499. {
  7500. if(currentColumn==columns)
  7501. {
  7502. table->appendColumns(1);
  7503. columns++;
  7504. }
  7505. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7506. cursor= cell.firstCursorPosition();
  7507. cursor.insertText(nodeElement.text());
  7508. currentColumn++;
  7509. }
  7510. }
  7511. }
  7512. /*:661*/
  7513. #line 14195 "./typica.w"
  7514. }
  7515. }
  7516. }
  7517. /*:659*/
  7518. #line 14140 "./typica.w"
  7519. if(rows> 1)
  7520. {
  7521. table->removeRows(0,1);
  7522. }
  7523. }
  7524. /*:656*/
  7525. #line 568 "./typica.w"
  7526. /*687:*/
  7527. #line 14350 "./typica.w"
  7528. FormArray::FormArray(QDomElement description):configuration(description),
  7529. maxwidth(-1),maxheight(-1)
  7530. {
  7531. setWidget(&itemContainer);
  7532. itemContainer.setLayout(&itemLayout);
  7533. }
  7534. /*:687*//*688:*/
  7535. #line 14367 "./typica.w"
  7536. void FormArray::addElements(int copies)
  7537. {
  7538. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7539. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7540. QWidget*widget;
  7541. for(int i= 0;i<copies;i++)
  7542. {
  7543. widget= new QWidget;
  7544. if(maxwidth> -1)
  7545. {
  7546. widget->setMaximumWidth(maxwidth);
  7547. }
  7548. if(maxheight> -1)
  7549. {
  7550. widget->setMaximumHeight(maxheight);
  7551. }
  7552. if(configuration.hasChildNodes())
  7553. {
  7554. widgetStack->push(widget);
  7555. populateWidget(configuration,widgetStack,layoutStack);
  7556. widgetStack->pop();
  7557. widget->setMinimumHeight(widget->sizeHint().height());
  7558. itemLayout.addWidget(widget);
  7559. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7560. {
  7561. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7562. }
  7563. else
  7564. {
  7565. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7566. +widget->sizeHint().height());
  7567. }
  7568. if(maxwidth> -1)
  7569. {
  7570. itemContainer.setMinimumWidth(maxwidth+50);
  7571. }
  7572. else
  7573. {
  7574. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7575. }
  7576. }
  7577. }
  7578. }
  7579. /*:688*//*689:*/
  7580. #line 14417 "./typica.w"
  7581. QWidget*FormArray::elementAt(int index)
  7582. {
  7583. if(index<itemLayout.count())
  7584. {
  7585. QLayoutItem*item= itemLayout.itemAt(index);
  7586. return item->widget();
  7587. }
  7588. else
  7589. {
  7590. return NULL;
  7591. }
  7592. }
  7593. /*:689*//*690:*/
  7594. #line 14434 "./typica.w"
  7595. void FormArray::removeAllElements()
  7596. {
  7597. while(itemLayout.count()> 0)
  7598. {
  7599. QLayoutItem*item;
  7600. item= itemLayout.itemAt(0);
  7601. item->widget()->hide();
  7602. itemLayout.removeWidget(item->widget());
  7603. }
  7604. itemContainer.setMinimumHeight(0);
  7605. }
  7606. /*:690*//*691:*/
  7607. #line 14450 "./typica.w"
  7608. int FormArray::elements()
  7609. {
  7610. return itemLayout.count();
  7611. }
  7612. /*:691*//*692:*/
  7613. #line 14461 "./typica.w"
  7614. void FormArray::setMaximumElementWidth(int width)
  7615. {
  7616. maxwidth= width;
  7617. }
  7618. void FormArray::setMaximumElementHeight(int height)
  7619. {
  7620. maxheight= height;
  7621. }
  7622. /*:692*/
  7623. #line 569 "./typica.w"
  7624. /*698:*/
  7625. #line 14592 "./typica.w"
  7626. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7627. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7628. {
  7629. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7630. QPointF(0,5);
  7631. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7632. QPointF(10,5);
  7633. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7634. QPointF(0,0);
  7635. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7636. initialBrush.setColor(QColor(170,170,255));
  7637. initialBrush.setStyle(Qt::SolidPattern);
  7638. finalBrush.setColor(Qt::blue);
  7639. finalBrush.setStyle(Qt::SolidPattern);
  7640. initialDecrement.setPolygon(left);
  7641. initialDecrement.setBrush(initialBrush);
  7642. initialDecrement.setPos(0,0);
  7643. scene.addItem(&initialDecrement);
  7644. initialIncrement.setPolygon(right);
  7645. initialIncrement.setBrush(initialBrush);
  7646. initialIncrement.setPos(122,0);
  7647. scene.addItem(&initialIncrement);
  7648. finalDecrement.setPolygon(left);
  7649. finalDecrement.setBrush(finalBrush);
  7650. finalDecrement.setPos(0,12);
  7651. scene.addItem(&finalDecrement);
  7652. finalIncrement.setPolygon(right);
  7653. finalIncrement.setBrush(finalBrush);
  7654. finalIncrement.setPos(122,12);
  7655. scene.addItem(&finalIncrement);
  7656. scalePath.moveTo(0,10);
  7657. scalePath.lineTo(100,10);
  7658. scalePath.moveTo(0,0);
  7659. scalePath.lineTo(0,20);
  7660. scalePath.moveTo(10,5);
  7661. scalePath.lineTo(10,15);
  7662. scalePath.moveTo(20,5);
  7663. scalePath.lineTo(20,15);
  7664. scalePath.moveTo(30,5);
  7665. scalePath.lineTo(30,15);
  7666. scalePath.moveTo(40,5);
  7667. scalePath.lineTo(40,15);
  7668. scalePath.moveTo(50,0);
  7669. scalePath.lineTo(50,20);
  7670. scalePath.moveTo(60,5);
  7671. scalePath.lineTo(60,15);
  7672. scalePath.moveTo(70,5);
  7673. scalePath.lineTo(70,15);
  7674. scalePath.moveTo(80,5);
  7675. scalePath.lineTo(80,15);
  7676. scalePath.moveTo(90,5);
  7677. scalePath.lineTo(90,15);
  7678. scalePath.moveTo(100,0);
  7679. scalePath.lineTo(100,20);
  7680. scaleLine.setPath(scalePath);
  7681. scaleLine.setPos(16,1);
  7682. scene.addItem(&scaleLine);
  7683. setScene(&scene);
  7684. initialIndicator.setPolygon(down);
  7685. initialIndicator.setBrush(initialBrush);
  7686. finalIndicator.setPolygon(up);
  7687. finalIndicator.setBrush(finalBrush);
  7688. setMinimumSize(sizeHint());
  7689. setMaximumSize(sizeHint());
  7690. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7691. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7692. setMinimumSize(sizeHint());
  7693. }
  7694. /*:698*//*699:*/
  7695. #line 14665 "./typica.w"
  7696. QSize ScaleControl::sizeHint()const
  7697. {
  7698. return QSize(140,30);
  7699. }
  7700. /*:699*//*700:*/
  7701. #line 14674 "./typica.w"
  7702. void ScaleControl::setInitialValue(double value)
  7703. {
  7704. if(value>=0&&value<=10)
  7705. {
  7706. nonScoredValue= value;
  7707. if(!initialSet)
  7708. {
  7709. scene.addItem(&initialIndicator);
  7710. }
  7711. initialSet= true;
  7712. initialIndicator.setPos(value*10+16,10);
  7713. emit initialChanged(value);
  7714. if(!finalSet)
  7715. {
  7716. setFinalValue(value);
  7717. }
  7718. }
  7719. }
  7720. void ScaleControl::setFinalValue(double value)
  7721. {
  7722. if(value>=0&&value<=10)
  7723. {
  7724. scoredValue= value;
  7725. if(!finalSet)
  7726. {
  7727. scene.addItem(&finalIndicator);
  7728. }
  7729. finalSet= true;
  7730. finalIndicator.setPos(value*10+16,11);
  7731. emit finalChanged(value);
  7732. }
  7733. }
  7734. /*:700*//*701:*/
  7735. #line 14711 "./typica.w"
  7736. double ScaleControl::initialValue(void)
  7737. {
  7738. return nonScoredValue;
  7739. }
  7740. double ScaleControl::finalValue(void)
  7741. {
  7742. return scoredValue;
  7743. }
  7744. /*:701*//*702:*/
  7745. #line 14732 "./typica.w"
  7746. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7747. {
  7748. /*703:*/
  7749. #line 14744 "./typica.w"
  7750. if(event->button()!=Qt::LeftButton)
  7751. {
  7752. event->ignore();
  7753. return;
  7754. }
  7755. /*:703*/
  7756. #line 14735 "./typica.w"
  7757. scaleDown= true;
  7758. event->accept();
  7759. }
  7760. /*:702*//*704:*/
  7761. #line 14755 "./typica.w"
  7762. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7763. {
  7764. /*703:*/
  7765. #line 14744 "./typica.w"
  7766. if(event->button()!=Qt::LeftButton)
  7767. {
  7768. event->ignore();
  7769. return;
  7770. }
  7771. /*:703*/
  7772. #line 14758 "./typica.w"
  7773. if(!scaleDown)
  7774. {
  7775. event->ignore();
  7776. return;
  7777. }
  7778. scaleDown= false;
  7779. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7780. /*705:*/
  7781. #line 14780 "./typica.w"
  7782. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7783. {
  7784. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7785. {
  7786. if(initialSet)
  7787. {
  7788. setInitialValue(nonScoredValue-0.05);
  7789. }
  7790. event->accept();
  7791. return;
  7792. }
  7793. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7794. {
  7795. if(finalSet)
  7796. {
  7797. setFinalValue(scoredValue-0.05);
  7798. event->accept();
  7799. return;
  7800. }
  7801. }
  7802. }
  7803. /*:705*/
  7804. #line 14766 "./typica.w"
  7805. /*706:*/
  7806. #line 14806 "./typica.w"
  7807. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7808. {
  7809. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7810. {
  7811. if(initialSet)
  7812. {
  7813. setInitialValue(nonScoredValue+0.05);
  7814. event->accept();
  7815. return;
  7816. }
  7817. }
  7818. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7819. {
  7820. if(finalSet)
  7821. {
  7822. setFinalValue(scoredValue+0.05);
  7823. event->accept();
  7824. return;
  7825. }
  7826. }
  7827. }
  7828. /*:706*/
  7829. #line 14767 "./typica.w"
  7830. /*707:*/
  7831. #line 14832 "./typica.w"
  7832. double relativeX= sceneCoordinate.x()-16;
  7833. if(initialSet)
  7834. {
  7835. if(relativeX>=0&&relativeX<=100)
  7836. {
  7837. setFinalValue(relativeX/10.0);
  7838. event->accept();
  7839. return;
  7840. }
  7841. }
  7842. else
  7843. {
  7844. if(relativeX>=0&&relativeX<=100)
  7845. {
  7846. setInitialValue(relativeX/10.0);
  7847. event->accept();
  7848. return;
  7849. }
  7850. }
  7851. /*:707*/
  7852. #line 14768 "./typica.w"
  7853. event->ignore();
  7854. return;
  7855. }
  7856. /*:704*/
  7857. #line 570 "./typica.w"
  7858. /*709:*/
  7859. #line 14898 "./typica.w"
  7860. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7861. valueSet(false),scaleDown(false)
  7862. {
  7863. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7864. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7865. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7866. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7867. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7868. theBrush.setColor(Qt::blue);
  7869. theBrush.setStyle(Qt::SolidPattern);
  7870. increment.setPolygon(up);
  7871. increment.setBrush(theBrush);
  7872. increment.setPos(0,0);
  7873. scene.addItem(&increment);
  7874. decrement.setPolygon(down);
  7875. decrement.setBrush(theBrush);
  7876. decrement.setPos(0,122);
  7877. scene.addItem(&decrement);
  7878. scalePath.moveTo(5,0);
  7879. scalePath.lineTo(5,100);
  7880. scalePath.moveTo(0,0);
  7881. scalePath.lineTo(10,0);
  7882. scalePath.moveTo(0,10);
  7883. scalePath.lineTo(10,10);
  7884. scalePath.moveTo(0,20);
  7885. scalePath.lineTo(10,20);
  7886. scalePath.moveTo(0,30);
  7887. scalePath.lineTo(10,30);
  7888. scalePath.moveTo(0,40);
  7889. scalePath.lineTo(10,40);
  7890. scalePath.moveTo(0,50);
  7891. scalePath.lineTo(10,50);
  7892. scalePath.moveTo(0,60);
  7893. scalePath.lineTo(10,60);
  7894. scalePath.moveTo(0,70);
  7895. scalePath.lineTo(10,70);
  7896. scalePath.moveTo(0,80);
  7897. scalePath.lineTo(10,80);
  7898. scalePath.moveTo(0,90);
  7899. scalePath.lineTo(10,90);
  7900. scalePath.moveTo(0,100);
  7901. scalePath.lineTo(10,100);
  7902. scaleLine.setPath(scalePath);
  7903. scaleLine.setPos(0,16);
  7904. scene.addItem(&scaleLine);
  7905. setScene(&scene);
  7906. indicator.setPolygon(left);
  7907. indicator.setBrush(theBrush);
  7908. setMinimumSize(sizeHint());
  7909. setMaximumSize(sizeHint());
  7910. }
  7911. /*:709*//*710:*/
  7912. #line 14953 "./typica.w"
  7913. QSize IntensityControl::sizeHint()const
  7914. {
  7915. return QSize(25,160);
  7916. }
  7917. /*:710*//*711:*/
  7918. #line 14968 "./typica.w"
  7919. void IntensityControl::setValue(double val)
  7920. {
  7921. if(val>=0&&val<=10)
  7922. {
  7923. theValue= val;
  7924. if(!valueSet)
  7925. {
  7926. scene.addItem(&indicator);
  7927. }
  7928. valueSet= true;
  7929. indicator.setPos(6,(100-(val*10))+16);
  7930. emit(valueChanged(val));
  7931. }
  7932. else if(val<1)
  7933. {
  7934. setValue(0);
  7935. }
  7936. else
  7937. {
  7938. setValue(10);
  7939. }
  7940. }
  7941. double IntensityControl::value()
  7942. {
  7943. return theValue;
  7944. }
  7945. /*:711*//*712:*/
  7946. #line 15000 "./typica.w"
  7947. void IntensityControl::mousePressEvent(QMouseEvent*event)
  7948. {
  7949. /*703:*/
  7950. #line 14744 "./typica.w"
  7951. if(event->button()!=Qt::LeftButton)
  7952. {
  7953. event->ignore();
  7954. return;
  7955. }
  7956. /*:703*/
  7957. #line 15003 "./typica.w"
  7958. scaleDown= true;
  7959. event->accept();
  7960. }
  7961. /*:712*//*713:*/
  7962. #line 15014 "./typica.w"
  7963. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  7964. {
  7965. /*703:*/
  7966. #line 14744 "./typica.w"
  7967. if(event->button()!=Qt::LeftButton)
  7968. {
  7969. event->ignore();
  7970. return;
  7971. }
  7972. /*:703*/
  7973. #line 15017 "./typica.w"
  7974. if(!scaleDown)
  7975. {
  7976. event->ignore();
  7977. return;
  7978. }
  7979. scaleDown= false;
  7980. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7981. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  7982. {
  7983. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7984. {
  7985. if(valueSet)
  7986. {
  7987. setValue(theValue+0.05);
  7988. }
  7989. event->accept();
  7990. return;
  7991. }
  7992. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  7993. {
  7994. if(valueSet)
  7995. {
  7996. setValue(theValue-0.05);
  7997. }
  7998. event->accept();
  7999. return;
  8000. }
  8001. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  8002. {
  8003. setValue(10-((sceneCoordinate.y()-16)/10.0));
  8004. event->accept();
  8005. return;
  8006. }
  8007. }
  8008. }
  8009. /*:713*/
  8010. #line 571 "./typica.w"
  8011. /*364:*/
  8012. #line 8241 "./typica.w"
  8013. void ThresholdDetector::newMeasurement(Measurement measure)
  8014. {
  8015. if((currentDirection==Ascending&&previousValue<threshold&&
  8016. previousValueValid)||(currentDirection==Descending&&
  8017. previousValue> threshold&&previousValueValid))
  8018. {
  8019. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  8020. (currentDirection==Descending&&measure.temperature()<=threshold))
  8021. {
  8022. double offset= measure.time().hour()*60*60;
  8023. offset+= measure.time().minute()*60;
  8024. offset+= measure.time().second();
  8025. offset+= measure.time().msec()/1000;
  8026. emit timeForValue(offset);
  8027. }
  8028. }
  8029. previousValue= measure.temperature();
  8030. previousValueValid= true;
  8031. }
  8032. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  8033. previousValueValid(false),
  8034. previousValue(-1),threshold(value),currentDirection(Ascending)
  8035. {
  8036. }
  8037. void ThresholdDetector::setThreshold(double value)
  8038. {
  8039. threshold= value;
  8040. }
  8041. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  8042. {
  8043. currentDirection= direction;
  8044. }
  8045. /*:364*/
  8046. #line 572 "./typica.w"
  8047. /*795:*/
  8048. #line 16906 "./typica.w"
  8049. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  8050. lister(new QextSerialEnumerator)
  8051. {
  8052. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  8053. QextPortInfo port;
  8054. foreach(port,ports)
  8055. {
  8056. #ifdef Q_OS_WIN32
  8057. addItem(port.portName);
  8058. #else
  8059. addItem(port.physName);
  8060. #endif
  8061. }
  8062. lister->setUpNotifications();
  8063. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  8064. this,SLOT(addDevice(QextPortInfo)));
  8065. setEditable(true);
  8066. }
  8067. void PortSelector::addDevice(QextPortInfo port)
  8068. {
  8069. addItem(port.portName);
  8070. }
  8071. /*:795*/
  8072. #line 573 "./typica.w"
  8073. /*797:*/
  8074. #line 16998 "./typica.w"
  8075. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  8076. {
  8077. QMetaObject meta= BaudSelector::staticMetaObject;
  8078. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  8079. for(int i= 0;i<type.keyCount();i++)
  8080. {
  8081. addItem(QString("%1").arg(type.value(i)));
  8082. }
  8083. }
  8084. /*:797*/
  8085. #line 574 "./typica.w"
  8086. /*799:*/
  8087. #line 17036 "./typica.w"
  8088. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  8089. {
  8090. QMetaObject meta= ParitySelector::staticMetaObject;
  8091. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  8092. for(int i= 0;i<type.keyCount();i++)
  8093. {
  8094. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8095. }
  8096. }
  8097. /*:799*/
  8098. #line 575 "./typica.w"
  8099. /*801:*/
  8100. #line 17066 "./typica.w"
  8101. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  8102. {
  8103. QMetaObject meta= FlowSelector::staticMetaObject;
  8104. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  8105. for(int i= 0;i<type.keyCount();i++)
  8106. {
  8107. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8108. }
  8109. }
  8110. /*:801*/
  8111. #line 576 "./typica.w"
  8112. /*803:*/
  8113. #line 17101 "./typica.w"
  8114. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  8115. {
  8116. QMetaObject meta= StopSelector::staticMetaObject;
  8117. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  8118. for(int i= 0;i<type.keyCount();i++)
  8119. {
  8120. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8121. }
  8122. }
  8123. /*:803*/
  8124. #line 577 "./typica.w"
  8125. /*863:*/
  8126. #line 18887 "./typica.w"
  8127. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  8128. :BasicDeviceConfigurationWidget(model,index),
  8129. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  8130. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  8131. decimalQuery(new QCheckBox(tr("Enable"))),
  8132. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  8133. unitQuery(new QCheckBox(tr("Enable"))),
  8134. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  8135. valueC(new QSpinBox),fixedUnit(new QComboBox),
  8136. pVAddress(new ShortHexSpinBox),
  8137. sVEnabled(new QCheckBox(tr("Enable"))),
  8138. sVReadAddress(new ShortHexSpinBox),
  8139. deviceLimit(new QCheckBox(tr("Enable"))),
  8140. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8141. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8142. sVWritable(new QCheckBox(tr("Enable"))),
  8143. sVOutputAddr(new ShortHexSpinBox),
  8144. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8145. {
  8146. QHBoxLayout*layout= new QHBoxLayout;
  8147. QWidget*form= new QWidget;
  8148. QHBoxLayout*masterLayout= new QHBoxLayout;
  8149. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8150. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8151. QFormLayout*serialSection= new QFormLayout;
  8152. serialSection->addRow(QString(tr("Port:")),port);
  8153. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8154. serialSection->addRow(QString(tr("Parity:")),parity);
  8155. serialSection->addRow(QString(tr("Flow control:")),flow);
  8156. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8157. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8158. serialSectionBox->setLayout(serialSection);
  8159. portAndDeviceLayout->addWidget(serialSectionBox);
  8160. QFormLayout*deviceSection= new QFormLayout;
  8161. station->setMinimum(1);
  8162. station->setMaximum(255);
  8163. decimalPosition->setMinimum(0);
  8164. decimalPosition->setMaximum(9);
  8165. valueF->setMinimum(0);
  8166. valueF->setMaximum(0xFFFF);
  8167. valueC->setMinimum(0);
  8168. valueC->setMaximum(0xFFFF);
  8169. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8170. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8171. deviceSection->addRow(tr("Station:"),station);
  8172. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8173. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8174. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8175. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8176. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8177. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8178. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8179. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8180. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8181. deviceSectionBox->setLayout(deviceSection);
  8182. portAndDeviceLayout->addWidget(deviceSectionBox);
  8183. QFormLayout*pVSection= new QFormLayout;
  8184. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8185. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8186. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8187. pVSection->addRow(pVHideBox);
  8188. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8189. processValueBox->setLayout(pVSection);
  8190. seriesLayout->addWidget(processValueBox);
  8191. QFormLayout*sVSection= new QFormLayout;
  8192. sVLower->setDecimals(1);
  8193. sVLower->setMinimum(0.0);
  8194. sVLower->setMaximum(999.9);
  8195. sVUpper->setDecimals(1);
  8196. sVUpper->setMinimum(0.0);
  8197. sVUpper->setMaximum(999.9);
  8198. sVSection->addRow(tr("Set value:"),sVEnabled);
  8199. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8200. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8201. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8202. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8203. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8204. sVSection->addRow(tr("Lower limit:"),sVLower);
  8205. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8206. sVSection->addRow(tr("Output set value:"),sVWritable);
  8207. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8208. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8209. sVSection->addRow(sVHideBox);
  8210. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8211. setValueBox->setLayout(sVSection);
  8212. seriesLayout->addWidget(setValueBox);
  8213. masterLayout->addLayout(portAndDeviceLayout);
  8214. masterLayout->addLayout(seriesLayout);
  8215. form->setLayout(masterLayout);
  8216. /*771:*/
  8217. #line 16347 "./typica.w"
  8218. QDomElement referenceElement=
  8219. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8220. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8221. QDomElement node;
  8222. /*:771*/
  8223. #line 18977 "./typica.w"
  8224. for(int i= 0;i<configData.size();i++)
  8225. {
  8226. node= configData.at(i).toElement();
  8227. if(node.attribute("name")=="port")
  8228. {
  8229. QString portname= node.attribute("value");
  8230. int idx= port->findText(portname);
  8231. if(idx>=0)
  8232. {
  8233. port->setCurrentIndex(idx);
  8234. }
  8235. else
  8236. {
  8237. port->addItem(portname);
  8238. }
  8239. }
  8240. else if(node.attribute("name")=="baud")
  8241. {
  8242. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8243. }
  8244. else if(node.attribute("name")=="parity")
  8245. {
  8246. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8247. }
  8248. else if(node.attribute("name")=="flow")
  8249. {
  8250. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8251. }
  8252. else if(node.attribute("name")=="stop")
  8253. {
  8254. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8255. }
  8256. else if(node.attribute("name")=="station")
  8257. {
  8258. station->setValue(node.attribute("value").toInt());
  8259. }
  8260. else if(node.attribute("name")=="decimalQuery")
  8261. {
  8262. if(node.attribute("value")=="true")
  8263. {
  8264. decimalQuery->setChecked(true);
  8265. }
  8266. else
  8267. {
  8268. decimalQuery->setChecked(false);
  8269. }
  8270. }
  8271. else if(node.attribute("name")=="decimalAddress")
  8272. {
  8273. decimalAddress->setValue(node.attribute("value").toInt());
  8274. }
  8275. else if(node.attribute("name")=="decimalPosition")
  8276. {
  8277. decimalPosition->setValue(node.attribute("value").toInt());
  8278. }
  8279. else if(node.attribute("name")=="unitQuery")
  8280. {
  8281. if(node.attribute("value")=="true")
  8282. {
  8283. unitQuery->setChecked(true);
  8284. }
  8285. else
  8286. {
  8287. unitQuery->setChecked(false);
  8288. }
  8289. }
  8290. else if(node.attribute("name")=="unitAddress")
  8291. {
  8292. unitAddress->setValue(node.attribute("value").toInt());
  8293. }
  8294. else if(node.attribute("name")=="valueF")
  8295. {
  8296. valueF->setValue(node.attribute("value").toInt());
  8297. }
  8298. else if(node.attribute("name")=="valueC")
  8299. {
  8300. valueC->setValue(node.attribute("value").toInt());
  8301. }
  8302. else if(node.attribute("name")=="fixedUnit")
  8303. {
  8304. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8305. }
  8306. else if(node.attribute("name")=="pVAddress")
  8307. {
  8308. pVAddress->setValue(node.attribute("value").toInt());
  8309. }
  8310. else if(node.attribute("name")=="sVEnabled")
  8311. {
  8312. if(node.attribute("value")=="true")
  8313. {
  8314. sVEnabled->setChecked(true);
  8315. }
  8316. else
  8317. {
  8318. sVEnabled->setChecked(false);
  8319. }
  8320. }
  8321. else if(node.attribute("name")=="sVReadAddress")
  8322. {
  8323. sVReadAddress->setValue(node.attribute("value").toInt());
  8324. }
  8325. else if(node.attribute("name")=="deviceLimit")
  8326. {
  8327. if(node.attribute("value")=="true")
  8328. {
  8329. deviceLimit->setChecked(true);
  8330. }
  8331. else
  8332. {
  8333. deviceLimit->setChecked(false);
  8334. }
  8335. }
  8336. else if(node.attribute("name")=="sVLowerAddr")
  8337. {
  8338. sVLowerAddr->setValue(node.attribute("value").toInt());
  8339. }
  8340. else if(node.attribute("name")=="sVUpperAddr")
  8341. {
  8342. sVUpperAddr->setValue(node.attribute("value").toInt());
  8343. }
  8344. else if(node.attribute("name")=="sVLower")
  8345. {
  8346. sVLower->setValue(node.attribute("value").toDouble());
  8347. }
  8348. else if(node.attribute("name")=="sVUpper")
  8349. {
  8350. sVUpper->setValue(node.attribute("value").toDouble());
  8351. }
  8352. else if(node.attribute("name")=="sVWritable")
  8353. {
  8354. if(node.attribute("value")=="true")
  8355. {
  8356. sVWritable->setChecked(true);
  8357. }
  8358. else
  8359. {
  8360. sVWritable->setChecked(false);
  8361. }
  8362. }
  8363. else if(node.attribute("name")=="sVOutputAddr")
  8364. {
  8365. sVOutputAddr->setValue(node.attribute("value").toInt());
  8366. }
  8367. else if(node.attribute("name")=="pvcolname")
  8368. {
  8369. pVColumnName->setText(node.attribute("value"));
  8370. }
  8371. else if(node.attribute("name")=="svcolname")
  8372. {
  8373. sVColumnName->setText(node.attribute("value"));
  8374. }
  8375. else if(node.attribute("name")=="pvhidden")
  8376. {
  8377. pVHideBox->setChecked(node.attribute("value")=="true");
  8378. }
  8379. else if(node.attribute("name")=="svhidden")
  8380. {
  8381. sVHideBox->setChecked(node.attribute("value")=="true");
  8382. }
  8383. }
  8384. updatePort(port->currentText());
  8385. updateBaudRate(baud->currentText());
  8386. updateParity(parity->itemData(parity->currentIndex()).toString());
  8387. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8388. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8389. updateStation(station->value());
  8390. updateFixedDecimal(decimalQuery->isChecked());
  8391. updateDecimalAddress(decimalAddress->value());
  8392. updateDecimalPosition(decimalPosition->value());
  8393. updateFixedUnit(unitQuery->isChecked());
  8394. updateUnitAddress(unitAddress->value());
  8395. updateValueForF(valueF->value());
  8396. updateValueForC(valueC->value());
  8397. updateUnit(fixedUnit->currentText());
  8398. updatePVAddress(pVAddress->value());
  8399. updateSVEnabled(sVEnabled->isChecked());
  8400. updateSVReadAddress(sVReadAddress->value());
  8401. updateDeviceLimit(deviceLimit->isChecked());
  8402. updateSVLowerAddress(sVLowerAddr->value());
  8403. updateSVUpperAddress(sVUpperAddr->value());
  8404. updateSVLower(sVLower->value());
  8405. updateSVUpper(sVUpper->value());
  8406. updateSVWritable(sVWritable->isChecked());
  8407. updateSVWriteAddress(sVOutputAddr->value());
  8408. updatePVColumnName(pVColumnName->text());
  8409. updateSVColumnName(sVColumnName->text());
  8410. updatePVHidden(pVHideBox->isChecked());
  8411. updateSVHidden(sVHideBox->isChecked());
  8412. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8413. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8414. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8415. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8416. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8417. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8418. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8419. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8420. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8421. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8422. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8423. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8424. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8425. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8426. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8427. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8428. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8429. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8430. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8431. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8432. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8433. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8434. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8435. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8436. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8437. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8438. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8439. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8440. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8441. layout->addWidget(form);
  8442. setLayout(layout);
  8443. }
  8444. void ModbusConfigurator::updatePort(const QString&newPort)
  8445. {
  8446. updateAttribute("port",newPort);
  8447. }
  8448. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8449. {
  8450. updateAttribute("baud",newRate);
  8451. }
  8452. void ModbusConfigurator::updateParity(const QString&)
  8453. {
  8454. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8455. }
  8456. void ModbusConfigurator::updateFlowControl(const QString&)
  8457. {
  8458. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8459. }
  8460. void ModbusConfigurator::updateStopBits(const QString&)
  8461. {
  8462. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8463. }
  8464. void ModbusConfigurator::updateStation(int station)
  8465. {
  8466. updateAttribute("station",QString("%1").arg(station));
  8467. }
  8468. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8469. {
  8470. updateAttribute("decimalQuery",fixed?"true":"false");
  8471. }
  8472. void ModbusConfigurator::updateDecimalAddress(int address)
  8473. {
  8474. updateAttribute("decimalAddress",QString("%1").arg(address));
  8475. }
  8476. void ModbusConfigurator::updateDecimalPosition(int position)
  8477. {
  8478. updateAttribute("decimalPosition",QString("%1").arg(position));
  8479. }
  8480. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8481. {
  8482. updateAttribute("unitQuery",fixed?"true":"false");
  8483. }
  8484. void ModbusConfigurator::updateUnitAddress(int address)
  8485. {
  8486. updateAttribute("unitAddress",QString("%1").arg(address));
  8487. }
  8488. void ModbusConfigurator::updateValueForF(int value)
  8489. {
  8490. updateAttribute("valueF",QString("%1").arg(value));
  8491. }
  8492. void ModbusConfigurator::updateValueForC(int value)
  8493. {
  8494. updateAttribute("valueC",QString("%1").arg(value));
  8495. }
  8496. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8497. {
  8498. updateAttribute("fixedUnit",newUnit);
  8499. }
  8500. void ModbusConfigurator::updatePVAddress(int address)
  8501. {
  8502. updateAttribute("pVAddress",QString("%1").arg(address));
  8503. }
  8504. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8505. {
  8506. updateAttribute("sVEnabled",enabled?"true":"false");
  8507. }
  8508. void ModbusConfigurator::updateSVReadAddress(int address)
  8509. {
  8510. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8511. }
  8512. void ModbusConfigurator::updateDeviceLimit(bool query)
  8513. {
  8514. updateAttribute("deviceLimit",query?"true":"false");
  8515. }
  8516. void ModbusConfigurator::updateSVLowerAddress(int address)
  8517. {
  8518. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8519. }
  8520. void ModbusConfigurator::updateSVUpperAddress(int address)
  8521. {
  8522. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8523. }
  8524. void ModbusConfigurator::updateSVLower(double value)
  8525. {
  8526. updateAttribute("sVLower",QString("%1").arg(value));
  8527. }
  8528. void ModbusConfigurator::updateSVUpper(double value)
  8529. {
  8530. updateAttribute("sVUpper",QString("%1").arg(value));
  8531. }
  8532. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8533. {
  8534. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8535. }
  8536. void ModbusConfigurator::updateSVWriteAddress(int address)
  8537. {
  8538. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8539. }
  8540. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8541. {
  8542. updateAttribute("pvcolname",name);
  8543. }
  8544. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8545. {
  8546. updateAttribute("svcolname",name);
  8547. }
  8548. void ModbusConfigurator::updatePVHidden(bool hidden)
  8549. {
  8550. updateAttribute("pvhidden",hidden?"true":"false");
  8551. }
  8552. void ModbusConfigurator::updateSVHidden(bool hidden)
  8553. {
  8554. updateAttribute("svhidden",hidden?"true":"false");
  8555. }
  8556. /*:863*/
  8557. #line 578 "./typica.w"
  8558. /*806:*/
  8559. #line 17154 "./typica.w"
  8560. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8561. {
  8562. setMinimum(0);
  8563. setMaximum(0xFFFF);
  8564. setPrefix("0x");
  8565. setMinimumWidth(65);
  8566. }
  8567. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8568. {
  8569. if(input.size()==2)
  8570. {
  8571. return QValidator::Intermediate;
  8572. }
  8573. bool okay;
  8574. input.toInt(&okay,16);
  8575. if(okay)
  8576. {
  8577. return QValidator::Acceptable;
  8578. }
  8579. return QValidator::Invalid;
  8580. }
  8581. int ShortHexSpinBox::valueFromText(const QString&text)const
  8582. {
  8583. return text.toInt(NULL,16);
  8584. }
  8585. QString ShortHexSpinBox::textFromValue(int value)const
  8586. {
  8587. QString retval;
  8588. retval.setNum(value,16);
  8589. while(retval.size()<4)
  8590. {
  8591. retval.prepend("0");
  8592. }
  8593. return retval.toUpper();
  8594. }
  8595. /*:806*/
  8596. #line 579 "./typica.w"
  8597. /*847:*/
  8598. #line 18186 "./typica.w"
  8599. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8600. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  8601. waiting(false)
  8602. {
  8603. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8604. Qt::UserRole).toString());
  8605. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8606. QDomElement node;
  8607. QVariantMap attributes;
  8608. for(int i= 0;i<portConfigData.size();i++)
  8609. {
  8610. node= portConfigData.at(i).toElement();
  8611. attributes.insert(node.attribute("name"),node.attribute("value"));
  8612. }
  8613. port= new QextSerialPort(attributes.value("port").toString(),
  8614. QextSerialPort::EventDriven);
  8615. int baudRate= attributes.value("baud").toInt();
  8616. port->setBaudRate((BaudRateType)baudRate);
  8617. double temp= ((double)(1)/(double)(baudRate))*48;
  8618. delayTime= (int)(temp*3000);
  8619. messageDelayTimer->setSingleShot(true);
  8620. commTimeout->setSingleShot(true);
  8621. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8622. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  8623. port->setDataBits(DATA_8);
  8624. port->setParity((ParityType)attributes.value("parity").toInt());
  8625. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8626. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8627. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8628. port->open(QIODevice::ReadWrite);
  8629. station= (char)attributes.value("station").toInt();
  8630. if(attributes.value("decimalQuery")=="true")
  8631. {
  8632. decimalPosition= 0;
  8633. QByteArray message;
  8634. message.append(station);
  8635. message.append((char)0x03);
  8636. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8637. char*addressBytes= (char*)&address;
  8638. message.append(addressBytes[1]);
  8639. message.append(addressBytes[0]);
  8640. message.append((char)0x00);
  8641. message.append((char)0x01);
  8642. queueMessage(message,this,"decimalResponse(QByteArray)");
  8643. }
  8644. else
  8645. {
  8646. decimalPosition= attributes.value("decimalPosition").toInt();
  8647. }
  8648. valueF= attributes.value("valueF").toInt();
  8649. valueC= attributes.value("valueC").toInt();
  8650. if(attributes.value("unitQuery")=="true")
  8651. {
  8652. QByteArray message;
  8653. message.append(station);
  8654. message.append((char)0x03);
  8655. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8656. char*addressBytes= (char*)&address;
  8657. message.append(addressBytes[1]);
  8658. message.append(addressBytes[0]);
  8659. message.append((char)0x00);
  8660. message.append((char)0x01);
  8661. queueMessage(message,this,"unitResponse(QByteArray)");
  8662. }
  8663. else
  8664. {
  8665. if(attributes.value("fixedUnit")=="Celsius")
  8666. {
  8667. unitIsF= false;
  8668. }
  8669. }
  8670. if(attributes.value("sVWritable")=="true")
  8671. {
  8672. if(attributes.value("deviceLimit")=="true")
  8673. {
  8674. QByteArray lmessage;
  8675. lmessage.append(station);
  8676. lmessage.append((char)0x03);
  8677. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8678. char*addressBytes= (char*)&laddress;
  8679. lmessage.append(addressBytes[1]);
  8680. lmessage.append(addressBytes[0]);
  8681. lmessage.append((char)0x00);
  8682. lmessage.append((char)0x01);
  8683. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8684. QByteArray umessage;
  8685. umessage.append(station);
  8686. umessage.append((char)0x03);
  8687. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8688. addressBytes= (char*)&uaddress;
  8689. umessage.append(addressBytes[1]);
  8690. umessage.append(addressBytes[0]);
  8691. umessage.append((char)0x00);
  8692. umessage.append((char)0x01);
  8693. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8694. }
  8695. else
  8696. {
  8697. outputSVLower= attributes.value("sVLower").toDouble();
  8698. outputSVUpper= attributes.value("sVUpper").toDouble();
  8699. }
  8700. outputSVStub.append(station);
  8701. outputSVStub.append((char)0x06);
  8702. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8703. char*addressBytes= (char*)&address;
  8704. outputSVStub.append(addressBytes[1]);
  8705. outputSVStub.append(addressBytes[0]);
  8706. }
  8707. Channel*pv= new Channel;
  8708. channels.append(pv);
  8709. pvStub.append(station);
  8710. pvStub.append((char)0x04);
  8711. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8712. char*pvac= (char*)&pvaddress;
  8713. pvStub.append(pvac[1]);
  8714. pvStub.append(pvac[0]);
  8715. pvStub.append((char)0x00);
  8716. pvStub.append((char)0x01);
  8717. svenabled= attributes.value("sVEnabled").toBool();
  8718. if(svenabled)
  8719. {
  8720. Channel*sv= new Channel;
  8721. channels.append(sv);
  8722. svStub.append(station);
  8723. svStub.append((char)0x04);
  8724. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8725. char*svac= (char*)&svaddress;
  8726. svStub.append(svac[1]);
  8727. svStub.append(svac[0]);
  8728. svStub.append((char)0x00);
  8729. svStub.append((char)0x01);
  8730. if(svaddress-pvaddress==1)
  8731. {
  8732. mStub.append(station);
  8733. mStub.append((char)0x04);
  8734. mStub.append(pvac[1]);
  8735. mStub.append(pvac[0]);
  8736. mStub.append((char)0x00);
  8737. mStub.append((char)0x02);
  8738. }
  8739. }
  8740. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8741. requestMeasurement();
  8742. }
  8743. double ModbusRTUDevice::SVLower()
  8744. {
  8745. return outputSVLower;
  8746. }
  8747. double ModbusRTUDevice::SVUpper()
  8748. {
  8749. return outputSVUpper;
  8750. }
  8751. int ModbusRTUDevice::decimals()
  8752. {
  8753. return decimalPosition;
  8754. }
  8755. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8756. {
  8757. quint16 temp;
  8758. char*tchar= (char*)&temp;
  8759. tchar[1]= response.at(3);
  8760. tchar[0]= response.at(4);
  8761. decimalPosition= temp;
  8762. emit SVDecimalChanged(decimalPosition);
  8763. qDebug()<<"Received decimal response";
  8764. }
  8765. void ModbusRTUDevice::unitResponse(QByteArray response)
  8766. {
  8767. quint16 temp;
  8768. char*tchar= (char*)&temp;
  8769. tchar[1]= response.at(3);
  8770. tchar[0]= response.at(4);
  8771. int value= temp;
  8772. if(value==valueF)
  8773. {
  8774. unitIsF= true;
  8775. }
  8776. else
  8777. {
  8778. unitIsF= false;
  8779. }
  8780. qDebug()<<"Received unit response";
  8781. }
  8782. void ModbusRTUDevice::svlResponse(QByteArray response)
  8783. {
  8784. quint16 temp;
  8785. char*tchar= (char*)&temp;
  8786. tchar[1]= response.at(3);
  8787. tchar[0]= response.at(4);
  8788. outputSVLower= (double)temp;
  8789. for(int i= 0;i<decimalPosition;i++)
  8790. {
  8791. outputSVLower/= 10;
  8792. }
  8793. emit SVLowerChanged(outputSVLower);
  8794. qDebug()<<"Received set value lower bound response";
  8795. }
  8796. void ModbusRTUDevice::svuResponse(QByteArray response)
  8797. {
  8798. quint16 temp;
  8799. char*tchar= (char*)&temp;
  8800. tchar[1]= response.at(3);
  8801. tchar[0]= response.at(4);
  8802. outputSVUpper= (double)temp;
  8803. for(int i= 0;i<decimalPosition;i++)
  8804. {
  8805. outputSVUpper/= 10;
  8806. }
  8807. emit SVUpperChanged(outputSVUpper);
  8808. qDebug()<<"Received set value upper bound response";
  8809. }
  8810. void ModbusRTUDevice::requestMeasurement()
  8811. {
  8812. if(mStub.length()> 0)
  8813. {
  8814. queueMessage(mStub,this,"mResponse(QByteArray)");
  8815. }
  8816. else
  8817. {
  8818. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8819. if(svenabled)
  8820. {
  8821. queueMessage(svStub,this,"mResponse(QByteArray)");
  8822. }
  8823. }
  8824. }
  8825. void ModbusRTUDevice::mResponse(QByteArray response)
  8826. {
  8827. QTime time= QTime::currentTime();
  8828. if(response.at(2)==0x04)
  8829. {
  8830. /*848:*/
  8831. #line 18440 "./typica.w"
  8832. quint16 pv;
  8833. quint16 sv;
  8834. char*pvBytes= (char*)&pv;
  8835. char*svBytes= (char*)&sv;
  8836. pvBytes[1]= response.at(3);
  8837. pvBytes[0]= response.at(4);
  8838. svBytes[1]= response.at(5);
  8839. svBytes[0]= response.at(6);
  8840. double pvOut= (double)pv;
  8841. double svOut= (double)sv;
  8842. for(int i= 0;i<decimalPosition;i++)
  8843. {
  8844. pvOut/= 10;
  8845. svOut/= 10;
  8846. }
  8847. if(!unitIsF)
  8848. {
  8849. pvOut= pvOut*9/5+32;
  8850. svOut= svOut*9/5+32;
  8851. }
  8852. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8853. Measurement svm(svOut,time,Units::Fahrenheit);
  8854. channels.at(0)->input(pvm);
  8855. channels.at(1)->input(svm);
  8856. /*:848*/
  8857. #line 18427 "./typica.w"
  8858. }
  8859. else
  8860. {
  8861. /*849:*/
  8862. #line 18470 "./typica.w"
  8863. quint16 value;
  8864. char*valueBytes= (char*)&value;
  8865. valueBytes[1]= response.at(3);
  8866. valueBytes[0]= response.at(4);
  8867. double valueOut= (double)value;
  8868. for(int i= 0;i<decimalPosition;i++)
  8869. {
  8870. valueOut/= 10;
  8871. }
  8872. if(!unitIsF)
  8873. {
  8874. valueOut= valueOut*9/5+32;
  8875. }
  8876. if(!svenabled)
  8877. {
  8878. Measurement vm(valueOut,time,Units::Fahrenheit);
  8879. channels.at(0)->input(vm);
  8880. }
  8881. else
  8882. {
  8883. if(readingsv)
  8884. {
  8885. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8886. Measurement svm(valueOut,time,Units::Fahrenheit);
  8887. channels.at(0)->input(pvm);
  8888. channels.at(1)->input(svm);
  8889. readingsv= false;
  8890. }
  8891. else
  8892. {
  8893. savedpv= valueOut;
  8894. readingsv= true;
  8895. }
  8896. }
  8897. /*:849*/
  8898. #line 18431 "./typica.w"
  8899. }
  8900. }
  8901. /*:847*//*850:*/
  8902. #line 18508 "./typica.w"
  8903. ModbusRTUDevice::~ModbusRTUDevice()
  8904. {
  8905. commTimeout->stop();
  8906. messageDelayTimer->stop();
  8907. port->close();
  8908. }
  8909. /*:850*//*851:*/
  8910. #line 18535 "./typica.w"
  8911. void ModbusRTUDevice::dataAvailable()
  8912. {
  8913. if(messageDelayTimer->isActive())
  8914. {
  8915. messageDelayTimer->stop();
  8916. }
  8917. responseBuffer.append(port->readAll());
  8918. /*852:*/
  8919. #line 18581 "./typica.w"
  8920. if(responseBuffer.size()<5)
  8921. {
  8922. return;
  8923. }
  8924. switch(responseBuffer.at(1))
  8925. {
  8926. case 0x01:
  8927. case 0x02:
  8928. if(responseBuffer.size()<6)
  8929. {
  8930. return;
  8931. }
  8932. responseBuffer= responseBuffer.left(6);
  8933. break;
  8934. case 0x03:
  8935. case 0x04:
  8936. if(responseBuffer.size()<5+responseBuffer.at(2))
  8937. {
  8938. return;
  8939. }
  8940. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8941. break;
  8942. case 0x05:
  8943. case 0x06:
  8944. case 0x10:
  8945. if(responseBuffer.size()<8)
  8946. {
  8947. return;
  8948. }
  8949. responseBuffer= responseBuffer.left(8);
  8950. break;
  8951. }
  8952. /*:852*/
  8953. #line 18543 "./typica.w"
  8954. commTimeout->stop();
  8955. if(calculateCRC(responseBuffer)==0)
  8956. {
  8957. QObject*object= retObjQueue.at(0);
  8958. char*method= callbackQueue.at(0);
  8959. QMetaMethod metamethod= object->metaObject()->
  8960. method(object->metaObject()->
  8961. indexOfMethod(QMetaObject::normalizedSignature(method)));
  8962. metamethod.invoke(object,Qt::QueuedConnection,
  8963. Q_ARG(QByteArray,responseBuffer));
  8964. messageQueue.removeAt(0);
  8965. retObjQueue.removeAt(0);
  8966. callbackQueue.removeAt(0);
  8967. }
  8968. else
  8969. {
  8970. qDebug()<<"CRC failed";
  8971. }
  8972. messageDelayTimer->start(delayTime);
  8973. waiting= false;
  8974. responseBuffer.clear();
  8975. }
  8976. /*:851*//*853:*/
  8977. #line 18623 "./typica.w"
  8978. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  8979. {
  8980. quint16 retval= 0xFFFF;
  8981. int i= 0;
  8982. while(i<data.size())
  8983. {
  8984. retval^= 0x00FF&(quint16)data.at(i);
  8985. for(int j= 0;j<8;j++)
  8986. {
  8987. if(retval&1)
  8988. {
  8989. retval= (retval>>1)^0xA001;
  8990. }
  8991. else
  8992. {
  8993. retval>>= 1;
  8994. }
  8995. }
  8996. i++;
  8997. }
  8998. return retval;
  8999. }
  9000. /*:853*//*854:*/
  9001. #line 18654 "./typica.w"
  9002. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  9003. const char*callback)
  9004. {
  9005. messageQueue.append(request);
  9006. retObjQueue.append(object);
  9007. callbackQueue.append(const_cast<char*> (callback));
  9008. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  9009. {
  9010. sendNextMessage();
  9011. }
  9012. }
  9013. void ModbusRTUDevice::sendNextMessage()
  9014. {
  9015. if(messageQueue.size()> 0&&!waiting)
  9016. {
  9017. QByteArray message= messageQueue.at(0);
  9018. quint16 crc= calculateCRC(message);
  9019. char*check= (char*)&crc;
  9020. message.append(check[0]);
  9021. message.append(check[1]);
  9022. qDebug()<<"Writing"<<message.toHex();
  9023. port->write(message);
  9024. commTimeout->start(2000);
  9025. messageDelayTimer->start(delayTime);
  9026. waiting= true;
  9027. }
  9028. else
  9029. {
  9030. emit queueEmpty();
  9031. }
  9032. }
  9033. void ModbusRTUDevice::outputSV(double value)
  9034. {
  9035. for(int i= 0;i<decimalPosition;i++)
  9036. {
  9037. value*= 10;
  9038. }
  9039. quint16 outval= (quint16)value;
  9040. QByteArray message(outputSVStub);
  9041. char*valBytes= (char*)&outval;
  9042. message.append(valBytes[1]);
  9043. message.append(valBytes[0]);
  9044. queueMessage(message,this,"ignore(QByteArray)");
  9045. }
  9046. /*:854*//*855:*/
  9047. #line 18704 "./typica.w"
  9048. void ModbusRTUDevice::ignore(QByteArray)
  9049. {
  9050. return;
  9051. }
  9052. /*:855*//*856:*/
  9053. #line 18717 "./typica.w"
  9054. void ModbusRTUDevice::timeout()
  9055. {
  9056. qDebug()<<"Communications timeout.";
  9057. responseBuffer.clear();
  9058. waiting= false;
  9059. messageDelayTimer->start();
  9060. }
  9061. /*:856*/
  9062. #line 580 "./typica.w"
  9063. /*725:*/
  9064. #line 15272 "./typica.w"
  9065. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  9066. DeviceTreeModelNode*parent)
  9067. :domNode(node),rowNumber(row),parentItem(parent)
  9068. {
  9069. }
  9070. DeviceTreeModelNode::~DeviceTreeModelNode()
  9071. {
  9072. QHash<int,DeviceTreeModelNode*> ::iterator i;
  9073. for(i= children.begin();i!=children.end();i++)
  9074. {
  9075. delete i.value();
  9076. }
  9077. }
  9078. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  9079. {
  9080. return parentItem;
  9081. }
  9082. int DeviceTreeModelNode::row()
  9083. {
  9084. return rowNumber;
  9085. }
  9086. QDomNode DeviceTreeModelNode::node()const
  9087. {
  9088. return domNode;
  9089. }
  9090. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  9091. {
  9092. if(children.contains(index))
  9093. {
  9094. return children[index];
  9095. }
  9096. if(index>=0&&index<domNode.childNodes().count())
  9097. {
  9098. QDomNode childNode= domNode.childNodes().item(index);
  9099. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  9100. index,this);
  9101. children[index]= childItem;
  9102. return childItem;
  9103. }
  9104. return NULL;
  9105. }
  9106. /*:725*/
  9107. #line 581 "./typica.w"
  9108. /*727:*/
  9109. #line 15361 "./typica.w"
  9110. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  9111. :QAbstractItemModel(parent)
  9112. {
  9113. document= AppInstance->deviceConfiguration();
  9114. QDomNodeList elements= document.elementsByTagName("devices");
  9115. if(elements.size()!=1)
  9116. {
  9117. qDebug()<<"Unexpected result when loading device map.";
  9118. }
  9119. treeRoot= elements.at(0);
  9120. root= new DeviceTreeModelNode(treeRoot,0);
  9121. elements= document.elementsByTagName("references");
  9122. if(elements.size()!=1)
  9123. {
  9124. qDebug()<<"No references section. Creating.";
  9125. referenceSection= document.createElement("references");
  9126. document.appendChild(referenceSection);
  9127. }
  9128. else
  9129. {
  9130. referenceSection= elements.at(0);
  9131. }
  9132. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  9133. AppInstance,SLOT(saveDeviceConfiguration()));
  9134. connect(this,SIGNAL(modelReset()),
  9135. AppInstance,SLOT(saveDeviceConfiguration()));
  9136. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9137. AppInstance,SLOT(saveDeviceConfiguration()));
  9138. }
  9139. /*:727*//*728:*/
  9140. #line 15396 "./typica.w"
  9141. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9142. {
  9143. return 1;
  9144. }
  9145. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9146. {
  9147. if(parent.column()> 0)
  9148. {
  9149. return 0;
  9150. }
  9151. /*729:*/
  9152. #line 15415 "./typica.w"
  9153. DeviceTreeModelNode*parentItem;
  9154. if(!parent.isValid())
  9155. {
  9156. parentItem= root;
  9157. }
  9158. else
  9159. {
  9160. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9161. }
  9162. /*:729*/
  9163. #line 15408 "./typica.w"
  9164. return parentItem->node().childNodes().count();
  9165. }
  9166. /*:728*//*730:*/
  9167. #line 15429 "./typica.w"
  9168. QModelIndex DeviceTreeModel::index(int row,int column,
  9169. const QModelIndex&parent)const
  9170. {
  9171. if(!hasIndex(row,column,parent))
  9172. {
  9173. return QModelIndex();
  9174. }
  9175. /*729:*/
  9176. #line 15415 "./typica.w"
  9177. DeviceTreeModelNode*parentItem;
  9178. if(!parent.isValid())
  9179. {
  9180. parentItem= root;
  9181. }
  9182. else
  9183. {
  9184. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9185. }
  9186. /*:729*/
  9187. #line 15437 "./typica.w"
  9188. DeviceTreeModelNode*childItem= parentItem->child(row);
  9189. if(childItem)
  9190. {
  9191. return createIndex(row,column,childItem);
  9192. }
  9193. return QModelIndex();
  9194. }
  9195. /*:730*//*731:*/
  9196. #line 15448 "./typica.w"
  9197. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9198. {
  9199. if(!child.isValid())
  9200. {
  9201. return QModelIndex();
  9202. }
  9203. DeviceTreeModelNode*childItem=
  9204. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9205. DeviceTreeModelNode*parentItem= childItem->parent();
  9206. if(!parentItem||parentItem==root)
  9207. {
  9208. return QModelIndex();
  9209. }
  9210. return createIndex(parentItem->row(),0,parentItem);
  9211. }
  9212. /*:731*//*732:*/
  9213. #line 15467 "./typica.w"
  9214. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9215. {
  9216. if(!index.isValid())
  9217. {
  9218. return 0;
  9219. }
  9220. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9221. }
  9222. /*:732*//*733:*/
  9223. #line 15482 "./typica.w"
  9224. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9225. {
  9226. if(!index.isValid())
  9227. {
  9228. return QVariant();
  9229. }
  9230. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9231. {
  9232. return QVariant();
  9233. }
  9234. DeviceTreeModelNode*item=
  9235. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9236. QDomNode node= item->node();
  9237. QDomElement element= node.toElement();
  9238. switch(role)
  9239. {
  9240. case Qt::DisplayRole:
  9241. case Qt::EditRole:
  9242. return QVariant(element.attribute("name"));
  9243. case Qt::UserRole:
  9244. return QVariant(element.attribute("reference"));
  9245. default:
  9246. return QVariant();
  9247. }
  9248. return QVariant();
  9249. }
  9250. /*:733*//*734:*/
  9251. #line 15514 "./typica.w"
  9252. bool DeviceTreeModel::setData(const QModelIndex&index,
  9253. const QVariant&value,int)
  9254. {
  9255. if(!index.isValid())
  9256. {
  9257. return false;
  9258. }
  9259. DeviceTreeModelNode*item=
  9260. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9261. QDomNode node= item->node();
  9262. QDomElement element= node.toElement();
  9263. element.setAttribute("name",value.toString());
  9264. emit dataChanged(index,index);
  9265. return true;
  9266. }
  9267. /*:734*//*735:*/
  9268. #line 15537 "./typica.w"
  9269. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9270. const QModelIndex&parent)
  9271. {
  9272. QString referenceID= QUuid::createUuid().toString();
  9273. /*729:*/
  9274. #line 15415 "./typica.w"
  9275. DeviceTreeModelNode*parentItem;
  9276. if(!parent.isValid())
  9277. {
  9278. parentItem= root;
  9279. }
  9280. else
  9281. {
  9282. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9283. }
  9284. /*:729*/
  9285. #line 15542 "./typica.w"
  9286. QDomNode parentNode= parentItem->node();
  9287. int newRowNumber= rowCount(parent);
  9288. beginInsertRows(parent,newRowNumber,newRowNumber);
  9289. QDomElement deviceElement= document.createElement("node");
  9290. deviceElement.setAttribute("name",name);
  9291. deviceElement.setAttribute("reference",referenceID);
  9292. parentNode.appendChild(deviceElement);
  9293. QDomElement referenceElement= document.createElement("reference");
  9294. referenceElement.setAttribute("id",referenceID);
  9295. referenceElement.setAttribute("driver",driver);
  9296. referenceSection.appendChild(referenceElement);
  9297. endInsertRows();
  9298. }
  9299. /*:735*//*736:*/
  9300. #line 15560 "./typica.w"
  9301. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9302. {
  9303. /*729:*/
  9304. #line 15415 "./typica.w"
  9305. DeviceTreeModelNode*parentItem;
  9306. if(!parent.isValid())
  9307. {
  9308. parentItem= root;
  9309. }
  9310. else
  9311. {
  9312. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9313. }
  9314. /*:729*/
  9315. #line 15563 "./typica.w"
  9316. QDomNode parentNode= parentItem->node();
  9317. QDomNodeList childNodes= parentNode.childNodes();
  9318. if(childNodes.size()<row+count)
  9319. {
  9320. return false;
  9321. }
  9322. beginRemoveRows(parent,row,row+count-1);
  9323. QList<QDomElement> removalList;
  9324. for(int i= row;i<row+count;i++)
  9325. {
  9326. removalList.append(childNodes.at(i).toElement());
  9327. }
  9328. QDomElement element;
  9329. QDomElement reference;
  9330. for(int i= 0;i<count;i++)
  9331. {
  9332. element= removalList.at(i);
  9333. if(element.hasAttribute("reference"))
  9334. {
  9335. reference= referenceElement(element.attribute("reference"));
  9336. if(!reference.isNull())
  9337. {
  9338. referenceSection.removeChild(reference);
  9339. }
  9340. }
  9341. parentNode.removeChild(element);
  9342. }
  9343. endRemoveRows();
  9344. beginResetModel();
  9345. delete root;
  9346. root= new DeviceTreeModelNode(treeRoot,0);
  9347. endResetModel();
  9348. return true;
  9349. }
  9350. /*:736*//*737:*/
  9351. #line 15602 "./typica.w"
  9352. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9353. {
  9354. QDomNodeList childNodes= referenceSection.childNodes();
  9355. QDomElement element;
  9356. for(int i= 0;i<childNodes.size();i++)
  9357. {
  9358. element= childNodes.at(i).toElement();
  9359. if(element.hasAttribute("id"))
  9360. {
  9361. if(element.attribute("id")==id)
  9362. {
  9363. return element;
  9364. }
  9365. }
  9366. }
  9367. return QDomElement();
  9368. }
  9369. /*:737*//*738:*/
  9370. #line 15623 "./typica.w"
  9371. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9372. {
  9373. return QVariant();
  9374. }
  9375. /*:738*//*739:*/
  9376. #line 15632 "./typica.w"
  9377. DeviceTreeModel::~DeviceTreeModel()
  9378. {
  9379. delete root;
  9380. }
  9381. /*:739*/
  9382. #line 582 "./typica.w"
  9383. /*766:*/
  9384. #line 16132 "./typica.w"
  9385. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9386. DeviceTreeModel*model,const QModelIndex&index)
  9387. :QWidget(NULL),deviceModel(model),currentNode(index)
  9388. {
  9389. }
  9390. /*:766*//*767:*/
  9391. #line 16144 "./typica.w"
  9392. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9393. const QString&value)
  9394. {
  9395. QDomElement referenceElement= deviceModel->referenceElement(
  9396. deviceModel->data(currentNode,Qt::UserRole).toString());
  9397. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9398. QDomElement node;
  9399. bool found= false;
  9400. for(int i= 0;i<configData.size();i++)
  9401. {
  9402. node= configData.at(i).toElement();
  9403. if(node.attribute("name")==name)
  9404. {
  9405. node.setAttribute("value",value);
  9406. found= true;
  9407. break;
  9408. }
  9409. }
  9410. if(!found)
  9411. {
  9412. node= AppInstance->deviceConfiguration().createElement("attribute");
  9413. node.setAttribute("name",name);
  9414. node.setAttribute("value",value);
  9415. referenceElement.appendChild(node);
  9416. }
  9417. AppInstance->saveDeviceConfiguration();
  9418. }
  9419. /*:767*//*768:*/
  9420. #line 16178 "./typica.w"
  9421. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9422. const QString&driver)
  9423. {
  9424. deviceModel->newNode(name,driver,currentNode);
  9425. }
  9426. /*:768*/
  9427. #line 583 "./typica.w"
  9428. /*757:*/
  9429. #line 15976 "./typica.w"
  9430. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9431. view(new QTreeView),configArea(new QScrollArea)
  9432. {
  9433. QSplitter*splitter= new QSplitter;
  9434. QWidget*leftWidget= new QWidget;
  9435. leftWidget->setMinimumWidth(200);
  9436. QVBoxLayout*left= new QVBoxLayout;
  9437. view->setAnimated(true);
  9438. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9439. document= AppInstance->deviceConfiguration();
  9440. model= new DeviceTreeModel;
  9441. view->setModel(model);
  9442. view->setTextElideMode(Qt::ElideNone);
  9443. view->expandAll();
  9444. view->resizeColumnToContents(0);
  9445. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9446. QHBoxLayout*treeButtons= new QHBoxLayout;
  9447. QToolButton*addDeviceButton= new QToolButton;
  9448. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9449. addDeviceButton->setToolTip(tr("New Roaster"));
  9450. connect(addDeviceButton,SIGNAL(clicked()),
  9451. this,SLOT(addDevice()));
  9452. QToolButton*removeNodeButton= new QToolButton;
  9453. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9454. removeNodeButton->setToolTip(tr("Delete Selection"));
  9455. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9456. treeButtons->addWidget(addDeviceButton);
  9457. treeButtons->addWidget(removeNodeButton);
  9458. left->addWidget(view);
  9459. left->addLayout(treeButtons);
  9460. leftWidget->setLayout(left);
  9461. splitter->addWidget(leftWidget);
  9462. configArea->setMinimumWidth(580);
  9463. configArea->setMinimumHeight(460);
  9464. configArea->setWidgetResizable(true);
  9465. splitter->addWidget(configArea);
  9466. QVBoxLayout*centralLayout= new QVBoxLayout;
  9467. centralLayout->addWidget(splitter);
  9468. setLayout(centralLayout);
  9469. connect(view,SIGNAL(activated(QModelIndex)),
  9470. this,SLOT(newSelection(QModelIndex)));
  9471. connect(view,SIGNAL(clicked(QModelIndex)),
  9472. this,SLOT(newSelection(QModelIndex)));
  9473. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9474. view,SLOT(expand(QModelIndex)));
  9475. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9476. this,SLOT(resizeColumn()));
  9477. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9478. this,SLOT(resizeColumn()));
  9479. }
  9480. /*:757*//*758:*/
  9481. #line 16031 "./typica.w"
  9482. void DeviceConfigurationWindow::addDevice()
  9483. {
  9484. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9485. }
  9486. /*:758*//*759:*/
  9487. #line 16039 "./typica.w"
  9488. void DeviceConfigurationWindow::removeNode()
  9489. {
  9490. QModelIndex index= view->currentIndex();
  9491. if(index.isValid())
  9492. {
  9493. int row= index.row();
  9494. QModelIndex parent= index.parent();
  9495. model->removeRow(row,parent);
  9496. }
  9497. }
  9498. /*:759*//*760:*/
  9499. #line 16055 "./typica.w"
  9500. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9501. {
  9502. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9503. if(editor)
  9504. {
  9505. configArea->setWidget(editor);
  9506. editor->show();
  9507. }
  9508. }
  9509. /*:760*//*761:*/
  9510. #line 16072 "./typica.w"
  9511. void DeviceConfigurationWindow::resizeColumn()
  9512. {
  9513. view->resizeColumnToContents(0);
  9514. }
  9515. /*:761*/
  9516. #line 584 "./typica.w"
  9517. /*781:*/
  9518. #line 16553 "./typica.w"
  9519. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9520. const QModelIndex&index):
  9521. BasicDeviceConfigurationWidget(model,index)
  9522. {
  9523. QFormLayout*layout= new QFormLayout;
  9524. QLineEdit*columnName= new QLineEdit;
  9525. layout->addRow(tr("Column Name:"),columnName);
  9526. QComboBox*typeSelector= new QComboBox;
  9527. typeSelector->addItem("J");
  9528. typeSelector->addItem("K");
  9529. typeSelector->addItem("T");
  9530. typeSelector->addItem("B");
  9531. typeSelector->addItem("E");
  9532. typeSelector->addItem("N");
  9533. typeSelector->addItem("R");
  9534. typeSelector->addItem("S");
  9535. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9536. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9537. layout->addRow(hideSeries);
  9538. setLayout(layout);
  9539. /*771:*/
  9540. #line 16347 "./typica.w"
  9541. QDomElement referenceElement=
  9542. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9543. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9544. QDomElement node;
  9545. /*:771*/
  9546. #line 16574 "./typica.w"
  9547. for(int i= 0;i<configData.size();i++)
  9548. {
  9549. node= configData.at(i).toElement();
  9550. if(node.attribute("name")=="type")
  9551. {
  9552. typeSelector->setCurrentIndex(
  9553. typeSelector->findText(node.attribute("value")));
  9554. }
  9555. else if(node.attribute("name")=="columnname")
  9556. {
  9557. columnName->setText(node.attribute("value"));
  9558. }
  9559. else if(node.attribute("name")=="hidden")
  9560. {
  9561. hideSeries->setChecked(node.attribute("value")=="true");
  9562. }
  9563. }
  9564. updateThermocoupleType(typeSelector->currentText());
  9565. updateColumnName(columnName->text());
  9566. updateHidden(hideSeries->isChecked());
  9567. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9568. this,SLOT(updateThermocoupleType(QString)));
  9569. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9570. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9571. }
  9572. /*:781*//*782:*/
  9573. #line 16604 "./typica.w"
  9574. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9575. {
  9576. updateAttribute("type",type);
  9577. }
  9578. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9579. {
  9580. updateAttribute("columnname",name);
  9581. }
  9582. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9583. {
  9584. updateAttribute("hidden",hidden?"true":"false");
  9585. }
  9586. /*:782*/
  9587. #line 585 "./typica.w"
  9588. /*777:*/
  9589. #line 16467 "./typica.w"
  9590. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9591. const QModelIndex&index)
  9592. :BasicDeviceConfigurationWidget(model,index)
  9593. {
  9594. QVBoxLayout*layout= new QVBoxLayout;
  9595. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9596. QLabel*label= new QLabel(tr("Device ID:"));
  9597. QLineEdit*deviceId= new QLineEdit;
  9598. deviceIdLayout->addWidget(label);
  9599. deviceIdLayout->addWidget(deviceId);
  9600. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9601. layout->addLayout(deviceIdLayout);
  9602. layout->addWidget(addChannelButton);
  9603. /*771:*/
  9604. #line 16347 "./typica.w"
  9605. QDomElement referenceElement=
  9606. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9607. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9608. QDomElement node;
  9609. /*:771*/
  9610. #line 16481 "./typica.w"
  9611. for(int i= 0;i<configData.size();i++)
  9612. {
  9613. node= configData.at(i).toElement();
  9614. if(node.attribute("name")=="deviceID")
  9615. {
  9616. deviceId->setText(node.attribute("value","Dev1"));
  9617. break;
  9618. }
  9619. }
  9620. updateDeviceId(deviceId->text());
  9621. connect(addChannelButton,SIGNAL(clicked()),
  9622. this,SLOT(addChannel()));
  9623. connect(deviceId,SIGNAL(textEdited(QString)),
  9624. this,SLOT(updateDeviceId(QString)));
  9625. setLayout(layout);
  9626. }
  9627. /*:777*//*778:*/
  9628. #line 16503 "./typica.w"
  9629. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9630. {
  9631. updateAttribute("deviceID",newId);
  9632. }
  9633. /*:778*//*779:*/
  9634. #line 16511 "./typica.w"
  9635. void NiDaqMxBase9211ConfWidget::addChannel()
  9636. {
  9637. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9638. }
  9639. /*:779*/
  9640. #line 586 "./typica.w"
  9641. /*775:*/
  9642. #line 16418 "./typica.w"
  9643. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9644. DeviceTreeModel*model,const QModelIndex&index):
  9645. BasicDeviceConfigurationWidget(model,index)
  9646. {
  9647. QHBoxLayout*layout= new QHBoxLayout;
  9648. QToolButton*addDeviceButton= new QToolButton;
  9649. addDeviceButton->setText(tr("Add Device"));
  9650. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9651. "nidaqmxbase9211series");
  9652. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9653. "nidaqmxbase9211series");
  9654. connect(add9211,SIGNAL(triggered(QString,QString)),
  9655. this,SLOT(insertChildNode(QString,QString)));
  9656. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9657. this,SLOT(insertChildNode(QString,QString)));
  9658. QMenu*deviceMenu= new QMenu;
  9659. deviceMenu->addAction(add9211);
  9660. deviceMenu->addAction(add9211a);
  9661. addDeviceButton->setMenu(deviceMenu);
  9662. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9663. layout->addWidget(addDeviceButton);
  9664. setLayout(layout);
  9665. }
  9666. /*:775*/
  9667. #line 587 "./typica.w"
  9668. /*642:*/
  9669. #line 13892 "./typica.w"
  9670. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9671. QObject*parent):
  9672. QAction(reportName,parent),reportFile(fileName)
  9673. {
  9674. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9675. }
  9676. /*:642*//*643:*/
  9677. #line 13908 "./typica.w"
  9678. void ReportAction::createReport()
  9679. {
  9680. QFile file(reportFile);
  9681. QDomDocument document;
  9682. if(file.open(QIODevice::ReadOnly))
  9683. {
  9684. document.setContent(&file,true);
  9685. QDomElement element= document.documentElement();
  9686. QScriptEngine*engine= AppInstance->engine;
  9687. QScriptContext*context= engine->pushContext();
  9688. QScriptValue object;
  9689. QString targetID= reportFile;
  9690. /*198:*/
  9691. #line 4632 "./typica.w"
  9692. ScriptQMainWindow*window= new ScriptQMainWindow;
  9693. window->setObjectName(targetID);
  9694. object= engine->newQObject(window);
  9695. setQMainWindowProperties(object,engine);
  9696. QWidget*central= new(QWidget);
  9697. central->setParent(window);
  9698. central->setObjectName("centralWidget");
  9699. window->setCentralWidget(central);
  9700. if(element.hasChildNodes())
  9701. {
  9702. /*199:*/
  9703. #line 4667 "./typica.w"
  9704. QStack<QWidget*> widgetStack;
  9705. QStack<QLayout*> layoutStack;
  9706. QString windowScript;
  9707. widgetStack.push(central);
  9708. QDomNodeList windowChildren= element.childNodes();
  9709. int i= 0;
  9710. while(i<windowChildren.count())
  9711. {
  9712. QDomNode current;
  9713. QDomElement element;
  9714. current= windowChildren.at(i);
  9715. if(current.isElement())
  9716. {
  9717. element= current.toElement();
  9718. if(element.tagName()=="program")
  9719. {
  9720. windowScript.append(element.text());
  9721. }
  9722. else if(element.tagName()=="layout")
  9723. {
  9724. element.setAttribute("trcontext","configuration");
  9725. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9726. }
  9727. else if(element.tagName()=="menu")
  9728. {
  9729. /*200:*/
  9730. #line 4715 "./typica.w"
  9731. QMenuBar*bar= window->menuBar();
  9732. bar->setParent(window);
  9733. bar->setObjectName("menuBar");
  9734. if(element.hasAttribute("name"))
  9735. {
  9736. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  9737. element.attribute("name").toUtf8().data()));
  9738. menu->setParent(bar);
  9739. if(element.hasAttribute("type"))
  9740. {
  9741. if(element.attribute("type")=="reports")
  9742. {
  9743. if(element.hasAttribute("src"))
  9744. {
  9745. /*640:*/
  9746. #line 13852 "./typica.w"
  9747. QSettings settings;
  9748. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9749. toString()).
  9750. arg(element.attribute("src"));
  9751. QDir::addSearchPath("reports",reportDirectory);
  9752. QDir directory(reportDirectory);
  9753. directory.setFilter(QDir::Files);
  9754. directory.setSorting(QDir::Name);
  9755. QStringList nameFilter;
  9756. nameFilter<<"*.xml";
  9757. directory.setNameFilters(nameFilter);
  9758. QFileInfoList reportFiles= directory.entryInfoList();
  9759. for(int i= 0;i<reportFiles.size();i++)
  9760. {
  9761. QFileInfo reportFile= reportFiles.at(i);
  9762. /*644:*/
  9763. #line 13932 "./typica.w"
  9764. QString path= reportFile.absoluteFilePath();
  9765. QFile file(path);
  9766. if(file.open(QIODevice::ReadOnly))
  9767. {
  9768. QDomDocument document;
  9769. document.setContent(&file,true);
  9770. QDomElement root= document.documentElement();
  9771. QString translationContext= root.attribute("id");
  9772. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9773. if(!titleNode.isNull())
  9774. {
  9775. QDomElement titleElement= titleNode.toElement();
  9776. QString title= QCoreApplication::translate("configuration",
  9777. titleElement.text().toUtf8().data());
  9778. if(!title.isEmpty())
  9779. {
  9780. QStringList hierarchy= title.split(":->");
  9781. QMenu*insertionPoint= menu;
  9782. /*645:*/
  9783. #line 13961 "./typica.w"
  9784. for(int j= 0;j<hierarchy.size()-1;j++)
  9785. {
  9786. QObjectList menuList= insertionPoint->children();
  9787. bool menuFound= false;
  9788. for(int k= 0;k<menuList.size();k++)
  9789. {
  9790. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9791. if(currentItem)
  9792. {
  9793. if(currentItem->title()==hierarchy.at(j))
  9794. {
  9795. menuFound= true;
  9796. insertionPoint= currentItem;
  9797. break;
  9798. }
  9799. }
  9800. }
  9801. if(!menuFound)
  9802. {
  9803. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9804. }
  9805. }
  9806. /*:645*/
  9807. #line 13951 "./typica.w"
  9808. ReportAction*action= new ReportAction(path,hierarchy.last());
  9809. insertionPoint->addAction(action);
  9810. }
  9811. }
  9812. }
  9813. /*:644*/
  9814. #line 13868 "./typica.w"
  9815. }
  9816. /*:640*/
  9817. #line 4730 "./typica.w"
  9818. }
  9819. }
  9820. }
  9821. if(element.hasChildNodes())
  9822. {
  9823. /*201:*/
  9824. #line 4743 "./typica.w"
  9825. QDomNodeList menuItems= element.childNodes();
  9826. int j= 0;
  9827. while(j<menuItems.count())
  9828. {
  9829. QDomNode item= menuItems.at(j);
  9830. if(item.isElement())
  9831. {
  9832. QDomElement itemElement= item.toElement();
  9833. if(itemElement.tagName()=="item")
  9834. {
  9835. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  9836. itemElement.text().toUtf8().data()),menu);
  9837. if(itemElement.hasAttribute("id"))
  9838. {
  9839. itemAction->setObjectName(itemElement.attribute("id"));
  9840. }
  9841. if(itemElement.hasAttribute("shortcut"))
  9842. {
  9843. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9844. }
  9845. menu->addAction(itemAction);
  9846. }
  9847. else if(itemElement.tagName()=="separator")
  9848. {
  9849. menu->addSeparator();
  9850. }
  9851. }
  9852. j++;
  9853. }
  9854. #line 1 "./helpmenu.w"
  9855. /*:201*/
  9856. #line 4736 "./typica.w"
  9857. }
  9858. }
  9859. /*:200*/
  9860. #line 4693 "./typica.w"
  9861. }
  9862. }
  9863. i++;
  9864. }
  9865. QScriptValue oldThis= context->thisObject();
  9866. context->setThisObject(object);
  9867. QScriptValue result= engine->evaluate(windowScript);
  9868. /*192:*/
  9869. #line 4449 "./typica.w"
  9870. if(engine->hasUncaughtException())
  9871. {
  9872. int line= engine->uncaughtExceptionLineNumber();
  9873. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9874. result.toString();
  9875. QString trace;
  9876. foreach(trace,engine->uncaughtExceptionBacktrace())
  9877. {
  9878. qDebug()<<trace;
  9879. }
  9880. }
  9881. /*:192*/
  9882. #line 4701 "./typica.w"
  9883. context->setThisObject(oldThis);
  9884. /*:199*/
  9885. #line 4643 "./typica.w"
  9886. }
  9887. /*202:*/
  9888. #line 9 "./helpmenu.w"
  9889. HelpMenu*helpMenu= new HelpMenu();
  9890. window->menuBar()->addMenu(helpMenu);
  9891. /*:202*/
  9892. #line 4645 "./typica.w"
  9893. window->show();
  9894. /*:198*/
  9895. #line 13921 "./typica.w"
  9896. file.close();
  9897. engine->popContext();
  9898. }
  9899. }
  9900. /*:643*/
  9901. #line 588 "./typica.w"
  9902. /*241:*/
  9903. #line 5829 "./typica.w"
  9904. NumericDelegate::NumericDelegate(QObject*parent):
  9905. QItemDelegate(parent)
  9906. {
  9907. }
  9908. /*:241*//*242:*/
  9909. #line 5841 "./typica.w"
  9910. void NumericDelegate::setEditorData(QWidget*editor,
  9911. const QModelIndex&index)const
  9912. {
  9913. QString value= index.model()->data(index,Qt::EditRole).toString();
  9914. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9915. line->setText(value);
  9916. }
  9917. /*:242*//*243:*/
  9918. #line 5856 "./typica.w"
  9919. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  9920. const QModelIndex&index)const
  9921. {
  9922. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9923. model->setData(index,line->text(),Qt::EditRole);
  9924. QScriptEngine*engine= AppInstance->engine;
  9925. engine->pushContext();
  9926. QString script= QString("Number(%1)").arg(line->text());
  9927. QScriptValue result= engine->evaluate(line->text());
  9928. if(result.isNumber())
  9929. {
  9930. model->setData(index,result.toVariant(),Qt::DisplayRole);
  9931. }
  9932. else
  9933. {
  9934. model->setData(index,QVariant(),Qt::DisplayRole);
  9935. }
  9936. engine->popContext();
  9937. }
  9938. /*:243*//*244:*/
  9939. #line 5879 "./typica.w"
  9940. QWidget*NumericDelegate::createEditor(QWidget*parent,
  9941. const QStyleOptionViewItem&,
  9942. const QModelIndex&)const
  9943. {
  9944. return(new QLineEdit(parent));
  9945. }
  9946. /*:244*//*245:*/
  9947. #line 5890 "./typica.w"
  9948. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  9949. const QStyleOptionViewItem&option,
  9950. const QModelIndex&)const
  9951. {
  9952. editor->setGeometry(option.rect);
  9953. }
  9954. /*:245*/
  9955. #line 589 "./typica.w"
  9956. /*786:*/
  9957. #line 16663 "./typica.w"
  9958. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  9959. const QModelIndex&index)
  9960. :BasicDeviceConfigurationWidget(model,index)
  9961. {
  9962. QHBoxLayout*layout= new QHBoxLayout;
  9963. QToolButton*addDeviceButton= new QToolButton;
  9964. addDeviceButton->setText(tr("Add Device"));
  9965. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9966. "nidaqmx9211series");
  9967. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  9968. "nidaqmxtc01");
  9969. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9970. this,SLOT(insertChildNode(QString,QString)));
  9971. connect(addtc01,SIGNAL(triggered(QString,QString)),
  9972. this,SLOT(insertChildNode(QString,QString)));
  9973. QMenu*deviceMenu= new QMenu;
  9974. deviceMenu->addAction(add9211a);
  9975. deviceMenu->addAction(addtc01);
  9976. addDeviceButton->setMenu(deviceMenu);
  9977. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9978. layout->addWidget(addDeviceButton);
  9979. setLayout(layout);
  9980. }
  9981. /*:786*/
  9982. #line 590 "./typica.w"
  9983. /*788:*/
  9984. #line 16712 "./typica.w"
  9985. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  9986. const QModelIndex&index)
  9987. :BasicDeviceConfigurationWidget(model,index)
  9988. {
  9989. QVBoxLayout*layout= new QVBoxLayout;
  9990. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9991. QLabel*label= new QLabel(tr("Device ID:"));
  9992. QLineEdit*deviceId= new QLineEdit;
  9993. deviceIdLayout->addWidget(label);
  9994. deviceIdLayout->addWidget(deviceId);
  9995. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9996. layout->addLayout(deviceIdLayout);
  9997. layout->addWidget(addChannelButton);
  9998. /*771:*/
  9999. #line 16347 "./typica.w"
  10000. QDomElement referenceElement=
  10001. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10002. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10003. QDomElement node;
  10004. /*:771*/
  10005. #line 16726 "./typica.w"
  10006. for(int i= 0;i<configData.size();i++)
  10007. {
  10008. node= configData.at(i).toElement();
  10009. if(node.attribute("name")=="deviceID")
  10010. {
  10011. deviceId->setText(node.attribute("value","Dev1"));
  10012. break;
  10013. }
  10014. }
  10015. updateDeviceId(deviceId->text());
  10016. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  10017. connect(deviceId,SIGNAL(textEdited(QString)),
  10018. this,SLOT(updateDeviceId(QString)));
  10019. setLayout(layout);
  10020. }
  10021. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  10022. {
  10023. updateAttribute("deviceID",newId);
  10024. }
  10025. void NiDaqMx9211ConfWidget::addChannel()
  10026. {
  10027. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10028. }
  10029. /*:788*/
  10030. #line 591 "./typica.w"
  10031. /*790:*/
  10032. #line 16777 "./typica.w"
  10033. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  10034. const QModelIndex&index)
  10035. :BasicDeviceConfigurationWidget(model,index)
  10036. {
  10037. QFormLayout*layout= new QFormLayout;
  10038. QLineEdit*deviceId= new QLineEdit;
  10039. layout->addRow(tr("Device ID:"),deviceId);
  10040. QLineEdit*columnName= new QLineEdit;
  10041. layout->addRow(tr("Column Name:"),columnName);
  10042. QComboBox*typeSelector= new QComboBox;
  10043. typeSelector->addItem("J");
  10044. typeSelector->addItem("K");
  10045. typeSelector->addItem("T");
  10046. typeSelector->addItem("B");
  10047. typeSelector->addItem("E");
  10048. typeSelector->addItem("N");
  10049. typeSelector->addItem("R");
  10050. typeSelector->addItem("S");
  10051. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10052. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  10053. layout->addRow(hideSeries);
  10054. /*771:*/
  10055. #line 16347 "./typica.w"
  10056. QDomElement referenceElement=
  10057. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10058. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10059. QDomElement node;
  10060. /*:771*/
  10061. #line 16799 "./typica.w"
  10062. for(int i= 0;i<configData.size();i++)
  10063. {
  10064. node= configData.at(i).toElement();
  10065. if(node.attribute("name")=="deviceID")
  10066. {
  10067. deviceId->setText(node.attribute("value"));
  10068. }
  10069. else if(node.attribute("name")=="type")
  10070. {
  10071. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  10072. }
  10073. else if(node.attribute("name")=="columnname")
  10074. {
  10075. columnName->setText(node.attribute("value"));
  10076. }
  10077. else if(node.attribute("name")=="hidden")
  10078. {
  10079. hideSeries->setChecked(node.attribute("value")=="true");
  10080. }
  10081. }
  10082. updateDeviceId(deviceId->text());
  10083. updateThermocoupleType(typeSelector->currentText());
  10084. updateColumnName(columnName->text());
  10085. updateHidden(hideSeries->isChecked());
  10086. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  10087. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  10088. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10089. setLayout(layout);
  10090. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10091. }
  10092. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  10093. {
  10094. updateAttribute("deviceID",newId);
  10095. }
  10096. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  10097. {
  10098. updateAttribute("type",type);
  10099. }
  10100. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  10101. {
  10102. updateAttribute("columnname",name);
  10103. }
  10104. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  10105. {
  10106. updateAttribute("hidden",hidden?"true":"false");
  10107. }
  10108. /*:790*/
  10109. #line 592 "./typica.w"
  10110. /*808:*/
  10111. #line 17219 "./typica.w"
  10112. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  10113. const QModelIndex&index)
  10114. :BasicDeviceConfigurationWidget(model,index)
  10115. {
  10116. QFormLayout*layout= new QFormLayout;
  10117. QToolButton*addDeviceButton= new QToolButton;
  10118. addDeviceButton->setText(tr("Add Device"));
  10119. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  10120. "Modbus RTU Device",
  10121. "modbusrtudevice");
  10122. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  10123. this,SLOT(insertChildNode(QString,QString)));
  10124. QMenu*deviceMenu= new QMenu;
  10125. deviceMenu->addAction(addModbusRtuDevice);
  10126. addDeviceButton->setMenu(deviceMenu);
  10127. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10128. layout->addRow(QString(),addDeviceButton);
  10129. PortSelector*port= new PortSelector;
  10130. layout->addRow(tr("Port:"),port);
  10131. connect(port,SIGNAL(currentIndexChanged(QString)),
  10132. this,SLOT(updatePort(QString)));
  10133. connect(port,SIGNAL(editTextChanged(QString)),
  10134. this,SLOT(updatePort(QString)));
  10135. BaudSelector*rate= new BaudSelector;
  10136. layout->addRow(tr("Baud:"),rate);
  10137. connect(rate,SIGNAL(currentIndexChanged(QString)),
  10138. this,SLOT(updateBaudRate(QString)));
  10139. ParitySelector*parity= new ParitySelector;
  10140. layout->addRow(tr("Parity:"),parity);
  10141. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10142. this,SLOT(updateParity(QString)));
  10143. FlowSelector*flow= new FlowSelector;
  10144. layout->addRow(tr("Flow Control:"),flow);
  10145. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10146. this,SLOT(updateFlowControl(QString)));
  10147. StopSelector*stop= new StopSelector;
  10148. layout->addRow(tr("Stop Bits:"),stop);
  10149. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10150. this,SLOT(updateStopBits(QString)));
  10151. /*771:*/
  10152. #line 16347 "./typica.w"
  10153. QDomElement referenceElement=
  10154. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10155. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10156. QDomElement node;
  10157. /*:771*/
  10158. #line 17259 "./typica.w"
  10159. for(int i= 0;i<configData.size();i++)
  10160. {
  10161. node= configData.at(i).toElement();
  10162. if(node.attribute("name")=="port")
  10163. {
  10164. int j= port->findText(node.attribute("value"));
  10165. if(j>=0)
  10166. {
  10167. port->setCurrentIndex(j);
  10168. }
  10169. else
  10170. {
  10171. port->insertItem(0,node.attribute("value"));
  10172. port->setCurrentIndex(0);
  10173. }
  10174. }
  10175. else if(node.attribute("name")=="baudrate")
  10176. {
  10177. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10178. }
  10179. else if(node.attribute("name")=="parity")
  10180. {
  10181. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10182. }
  10183. else if(node.attribute("name")=="flowcontrol")
  10184. {
  10185. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10186. }
  10187. else if(node.attribute("name")=="stopbits")
  10188. {
  10189. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10190. }
  10191. }
  10192. updatePort(port->currentText());
  10193. updateBaudRate(rate->currentText());
  10194. updateParity(parity->currentText());
  10195. updateFlowControl(flow->currentText());
  10196. updateStopBits(stop->currentText());
  10197. setLayout(layout);
  10198. }
  10199. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10200. {
  10201. updateAttribute("port",newPort);
  10202. }
  10203. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10204. {
  10205. updateAttribute("baudrate",newRate);
  10206. }
  10207. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10208. {
  10209. updateAttribute("parity",newParity);
  10210. }
  10211. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10212. {
  10213. updateAttribute("flowcontrol",newFlow);
  10214. }
  10215. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10216. {
  10217. updateAttribute("stopbits",newStopBits);
  10218. }
  10219. /*:808*/
  10220. #line 593 "./typica.w"
  10221. /*810:*/
  10222. #line 17382 "./typica.w"
  10223. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10224. const QModelIndex&index)
  10225. :BasicDeviceConfigurationWidget(model,index),
  10226. unitSpecificationLayout(new QStackedLayout),
  10227. decimalSpecificationLayout(new QStackedLayout)
  10228. {
  10229. QVBoxLayout*layout= new QVBoxLayout;
  10230. QToolButton*addChannelButton= new QToolButton;
  10231. addChannelButton->setText(tr("Add Channel"));
  10232. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10233. "Temperature Process Value",
  10234. "modbustemperaturepv");
  10235. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10236. "Temperature Set Value",
  10237. "modbustemperaturesv");
  10238. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10239. this,SLOT(insertChildNode(QString,QString)));
  10240. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10241. this,SLOT(insertChildNode(QString,QString)));
  10242. QMenu*channelMenu= new QMenu;
  10243. channelMenu->addAction(addTemperaturePV);
  10244. channelMenu->addAction(addTemperatureSV);
  10245. addChannelButton->setMenu(channelMenu);
  10246. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10247. layout->addWidget(addChannelButton);
  10248. QHBoxLayout*stationLayout= new QHBoxLayout;
  10249. QLabel*stationLabel= new QLabel(tr("Station:"));
  10250. QSpinBox*stationNumber= new QSpinBox;
  10251. stationNumber->setMinimum(0);
  10252. stationNumber->setMaximum(255);
  10253. stationLayout->addWidget(stationLabel);
  10254. stationLayout->addWidget(stationNumber);
  10255. layout->addLayout(stationLayout);
  10256. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10257. layout->addWidget(fixedUnit);
  10258. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10259. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10260. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10261. QComboBox*fixedUnitSelector= new QComboBox;
  10262. fixedUnitSelector->addItem("Fahrenheit");
  10263. fixedUnitSelector->addItem("Celsius");
  10264. fixedUnitLayout->addWidget(fixedUnitLabel);
  10265. fixedUnitLayout->addWidget(fixedUnitSelector);
  10266. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10267. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10268. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10269. QFormLayout*queriedUnitLayout= new QFormLayout;
  10270. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10271. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10272. QSpinBox*valueF= new QSpinBox;
  10273. valueF->setMinimum(0);
  10274. valueF->setMaximum(65535);
  10275. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10276. QSpinBox*valueC= new QSpinBox;
  10277. valueC->setMinimum(0);
  10278. valueC->setMaximum(65535);
  10279. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10280. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10281. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10282. layout->addLayout(unitSpecificationLayout);
  10283. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10284. layout->addWidget(fixedPrecision);
  10285. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10286. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10287. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10288. fixedPrecisionValue->setMinimum(0);
  10289. fixedPrecisionValue->setMaximum(9);
  10290. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10291. fixedPrecisionValue);
  10292. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10293. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10294. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10295. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10296. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10297. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10298. precisionAddress);
  10299. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10300. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10301. layout->addLayout(decimalSpecificationLayout);
  10302. /*771:*/
  10303. #line 16347 "./typica.w"
  10304. QDomElement referenceElement=
  10305. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10306. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10307. QDomElement node;
  10308. /*:771*/
  10309. #line 17462 "./typica.w"
  10310. for(int i= 0;i<configData.size();i++)
  10311. {
  10312. node= configData.at(i).toElement();
  10313. if(node.attribute("name")=="station")
  10314. {
  10315. stationNumber->setValue(node.attribute("value").toInt());
  10316. }
  10317. else if(node.attribute("name")=="fixedunit")
  10318. {
  10319. if(node.attribute("value")=="true")
  10320. {
  10321. fixedUnit->setCheckState(Qt::Checked);
  10322. }
  10323. else if(node.attribute("value")=="false")
  10324. {
  10325. fixedUnit->setCheckState(Qt::Unchecked);
  10326. }
  10327. }
  10328. else if(node.attribute("name")=="fixedprecision")
  10329. {
  10330. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10331. }
  10332. else if(node.attribute("name")=="unit")
  10333. {
  10334. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10335. }
  10336. else if(node.attribute("name")=="unitaddress")
  10337. {
  10338. unitAddress->setValue(node.attribute("value").toInt());
  10339. }
  10340. else if(node.attribute("name")=="fvalue")
  10341. {
  10342. valueF->setValue(node.attribute("value").toInt());
  10343. }
  10344. else if(node.attribute("name")=="cvalue")
  10345. {
  10346. valueC->setValue(node.attribute("value").toInt());
  10347. }
  10348. else if(node.attribute("name")=="precisionaddress")
  10349. {
  10350. precisionAddress->setValue(node.attribute("value").toInt());
  10351. }
  10352. else if(node.attribute("name")=="precision")
  10353. {
  10354. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10355. }
  10356. }
  10357. updateStationNumber(stationNumber->value());
  10358. updateFixedUnit(fixedUnit->isChecked());
  10359. updateFixedDecimal(fixedPrecision->isChecked());
  10360. updateUnit(fixedUnitSelector->currentText());
  10361. updateUnitAddress(unitAddress->value());
  10362. updateValueF(valueF->value());
  10363. updateValueC(valueC->value());
  10364. updatePrecisionAddress(precisionAddress->value());
  10365. updatePrecisionValue(fixedPrecisionValue->value());
  10366. connect(stationNumber,SIGNAL(valueChanged(int)),
  10367. this,SLOT(updateStationNumber(int)));
  10368. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10369. this,SLOT(updateUnit(QString)));
  10370. connect(unitAddress,SIGNAL(valueChanged(int)),
  10371. this,SLOT(updateUnitAddress(int)));
  10372. connect(valueF,SIGNAL(valueChanged(int)),
  10373. this,SLOT(updateValueF(int)));
  10374. connect(valueC,SIGNAL(valueChanged(int)),
  10375. this,SLOT(updateValueC(int)));
  10376. connect(fixedUnit,SIGNAL(toggled(bool)),
  10377. this,SLOT(updateFixedUnit(bool)));
  10378. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10379. this,SLOT(updateFixedDecimal(bool)));
  10380. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10381. this,SLOT(updatePrecisionValue(int)));
  10382. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10383. this,SLOT(updatePrecisionAddress(int)));
  10384. setLayout(layout);
  10385. }
  10386. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10387. {
  10388. updateAttribute("station",QString("%1").arg(newStation));
  10389. }
  10390. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10391. {
  10392. if(newFixed)
  10393. {
  10394. unitSpecificationLayout->setCurrentIndex(0);
  10395. updateAttribute("fixedunit","true");
  10396. }
  10397. else
  10398. {
  10399. unitSpecificationLayout->setCurrentIndex(1);
  10400. updateAttribute("fixedunit","false");
  10401. }
  10402. }
  10403. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10404. {
  10405. if(newFixed)
  10406. {
  10407. decimalSpecificationLayout->setCurrentIndex(0);
  10408. updateAttribute("fixedprecision","true");
  10409. }
  10410. else
  10411. {
  10412. decimalSpecificationLayout->setCurrentIndex(1);
  10413. updateAttribute("fixedprecision","false");
  10414. }
  10415. }
  10416. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10417. {
  10418. updateAttribute("unit",newUnit);
  10419. }
  10420. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10421. {
  10422. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10423. }
  10424. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10425. {
  10426. updateAttribute("fvalue",QString("%1").arg(newValue));
  10427. }
  10428. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10429. {
  10430. updateAttribute("cvalue",QString("%1").arg(newValue));
  10431. }
  10432. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10433. {
  10434. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10435. }
  10436. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10437. {
  10438. updateAttribute("precision",QString("%1").arg(newValue));
  10439. }
  10440. /*:810*/
  10441. #line 594 "./typica.w"
  10442. /*812:*/
  10443. #line 17625 "./typica.w"
  10444. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10445. const QModelIndex&index)
  10446. :BasicDeviceConfigurationWidget(model,index)
  10447. {
  10448. QFormLayout*layout= new QFormLayout;
  10449. ShortHexSpinBox*address= new ShortHexSpinBox;
  10450. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10451. /*771:*/
  10452. #line 16347 "./typica.w"
  10453. QDomElement referenceElement=
  10454. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10455. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10456. QDomElement node;
  10457. /*:771*/
  10458. #line 17633 "./typica.w"
  10459. for(int i= 0;i<configData.size();i++)
  10460. {
  10461. node= configData.at(i).toElement();
  10462. if(node.attribute("name")=="address")
  10463. {
  10464. address->setValue(node.attribute("value").toInt());
  10465. break;
  10466. }
  10467. }
  10468. updateAddress(address->value());
  10469. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10470. setLayout(layout);
  10471. }
  10472. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10473. {
  10474. updateAttribute("address",QString("%1").arg(newAddress));
  10475. }
  10476. /*:812*/
  10477. #line 595 "./typica.w"
  10478. /*814:*/
  10479. #line 17681 "./typica.w"
  10480. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10481. const QModelIndex&index)
  10482. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10483. {
  10484. QVBoxLayout*layout= new QVBoxLayout;
  10485. QFormLayout*addressLayout= new QFormLayout;
  10486. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10487. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10488. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10489. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10490. layout->addLayout(addressLayout);
  10491. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10492. layout->addWidget(fixedRange);
  10493. QWidget*queriedRangePlaceholder= new QWidget(this);
  10494. QFormLayout*queriedRangeLayout= new QFormLayout;
  10495. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10496. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10497. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10498. lowerAddress);
  10499. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10500. upperAddress);
  10501. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10502. boundsLayout->addWidget(queriedRangePlaceholder);
  10503. QWidget*fixedRangePlaceholder= new QWidget(this);
  10504. QFormLayout*fixedRangeLayout= new QFormLayout;
  10505. QLineEdit*fixedLower= new QLineEdit;
  10506. QLineEdit*fixedUpper= new QLineEdit;
  10507. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10508. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10509. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10510. boundsLayout->addWidget(fixedRangePlaceholder);
  10511. layout->addLayout(boundsLayout);
  10512. /*771:*/
  10513. #line 16347 "./typica.w"
  10514. QDomElement referenceElement=
  10515. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10516. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10517. QDomElement node;
  10518. /*:771*/
  10519. #line 17714 "./typica.w"
  10520. for(int i= 0;i<configData.size();i++)
  10521. {
  10522. node= configData.at(i).toElement();
  10523. if(node.attribute("name")=="readaddress")
  10524. {
  10525. readAddress->setValue(node.attribute("value").toInt());
  10526. }
  10527. else if(node.attribute("name")=="writeaddress")
  10528. {
  10529. writeAddress->setValue(node.attribute("value").toInt());
  10530. }
  10531. else if(node.attribute("name")=="fixedrange")
  10532. {
  10533. if(node.attribute("value")=="true")
  10534. {
  10535. fixedRange->setCheckState(Qt::Checked);
  10536. }
  10537. else if(node.attribute("value")=="false")
  10538. {
  10539. fixedRange->setCheckState(Qt::Unchecked);
  10540. }
  10541. }
  10542. else if(node.attribute("name")=="fixedlower")
  10543. {
  10544. fixedLower->setText(node.attribute("value"));
  10545. }
  10546. else if(node.attribute("name")=="fixedupper")
  10547. {
  10548. fixedUpper->setText(node.attribute("value"));
  10549. }
  10550. else if(node.attribute("name")=="loweraddress")
  10551. {
  10552. lowerAddress->setValue(node.attribute("value").toInt());
  10553. }
  10554. else if(node.attribute("name")=="upperaddress")
  10555. {
  10556. upperAddress->setValue(node.attribute("value").toInt());
  10557. }
  10558. }
  10559. updateReadAddress(readAddress->value());
  10560. updateWriteAddress(writeAddress->value());
  10561. updateFixedRange(fixedRange->isChecked());
  10562. updateLower(fixedLower->text());
  10563. updateUpper(fixedUpper->text());
  10564. updateLowerAddress(lowerAddress->value());
  10565. updateUpperAddress(upperAddress->value());
  10566. connect(readAddress,SIGNAL(valueChanged(int)),
  10567. this,SLOT(updateReadAddress(int)));
  10568. connect(writeAddress,SIGNAL(valueChanged(int)),
  10569. this,SLOT(updateWriteAddress(int)));
  10570. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10571. connect(fixedLower,SIGNAL(textChanged(QString)),
  10572. this,SLOT(updateLower(QString)));
  10573. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10574. this,SLOT(updateUpper(QString)));
  10575. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10576. this,SLOT(updateLowerAddress(int)));
  10577. connect(upperAddress,SIGNAL(valueChanged(int)),
  10578. this,SLOT(updateUpperAddress(int)));
  10579. setLayout(layout);
  10580. }
  10581. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10582. {
  10583. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10584. }
  10585. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10586. {
  10587. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10588. }
  10589. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10590. {
  10591. if(fixed)
  10592. {
  10593. updateAttribute("fixedrange","true");
  10594. boundsLayout->setCurrentIndex(1);
  10595. }
  10596. else
  10597. {
  10598. updateAttribute("fixedrange","false");
  10599. boundsLayout->setCurrentIndex(0);
  10600. }
  10601. }
  10602. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10603. {
  10604. updateAttribute("fixedlower",lower);
  10605. }
  10606. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10607. {
  10608. updateAttribute("fixedupper",upper);
  10609. }
  10610. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10611. {
  10612. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10613. }
  10614. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10615. {
  10616. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10617. }
  10618. /*:814*/
  10619. #line 596 "./typica.w"
  10620. /*770:*/
  10621. #line 16217 "./typica.w"
  10622. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10623. :BasicDeviceConfigurationWidget(model,index)
  10624. {
  10625. QVBoxLayout*layout= new QVBoxLayout;
  10626. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10627. QMenu*deviceMenu= new QMenu;
  10628. NodeInserter*insertAction;
  10629. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10630. {
  10631. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10632. this,SLOT(insertChildNode(QString,QString)));
  10633. deviceMenu->addAction(insertAction);
  10634. }
  10635. addDeviceButton->setMenu(deviceMenu);
  10636. layout->addWidget(addDeviceButton);
  10637. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10638. QMenu*annotationMenu= new QMenu;
  10639. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10640. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10641. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10642. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10643. tr("Free Text"),
  10644. "freeannotation");
  10645. annotationMenu->addAction(basicButtonInserter);
  10646. annotationMenu->addAction(countingButtonInserter);
  10647. annotationMenu->addAction(spinBoxInserter);
  10648. annotationMenu->addAction(freeAnnotationInserter);
  10649. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10650. this,SLOT(insertChildNode(QString,QString)));
  10651. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10652. this,SLOT(insertChildNode(QString,QString)));
  10653. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10654. this,SLOT(insertChildNode(QString,QString)));
  10655. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10656. this,SLOT(insertChildNode(QString,QString)));
  10657. /*1045:*/
  10658. #line 144 "./valueannotation.w"
  10659. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10660. tr("Value Annotation"),
  10661. "valueannotation");
  10662. annotationMenu->addAction(valueAnnotationInserter);
  10663. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10664. this,SLOT(insertChildNode(QString,QString)));
  10665. /*:1045*//*1059:*/
  10666. #line 115 "./thresholdannotation.w"
  10667. NodeInserter*thresholdAnnotationInserter= new NodeInserter(tr("Threshold Annotation"),
  10668. tr("Threshold Annotation"),
  10669. "thresholdannotation");
  10670. annotationMenu->addAction(thresholdAnnotationInserter);
  10671. connect(thresholdAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10672. this,SLOT(insertChildNode(QString,QString)));
  10673. /*:1059*/
  10674. #line 16253 "./typica.w"
  10675. addAnnotationControlButton->setMenu(annotationMenu);
  10676. layout->addWidget(addAnnotationControlButton);
  10677. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  10678. QMenu*timersMenu= new QMenu;
  10679. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  10680. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  10681. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  10682. timersMenu->addAction(coolingTimerInserter);
  10683. timersMenu->addAction(rangeTimerInserter);
  10684. timersMenu->addAction(multirangeTimerInserter);
  10685. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  10686. this,SLOT(insertChildNode(QString,QString)));
  10687. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10688. this,SLOT(insertChildNode(QString,QString)));
  10689. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10690. this,SLOT(insertChildNode(QString,QString)));
  10691. timersButton->setMenu(timersMenu);
  10692. layout->addWidget(timersButton);
  10693. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10694. QMenu*advancedMenu= new QMenu;
  10695. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10696. advancedMenu->addAction(linearsplineinserter);
  10697. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10698. advancedMenu->addAction(translationinserter);
  10699. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10700. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10701. /*971:*/
  10702. #line 258 "./rate.w"
  10703. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10704. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10705. advancedMenu->addAction(rateOfChangeInserter);
  10706. /*:971*/
  10707. #line 16282 "./typica.w"
  10708. advancedButton->setMenu(advancedMenu);
  10709. layout->addWidget(advancedButton);
  10710. QHBoxLayout*idLayout= new QHBoxLayout;
  10711. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10712. idLayout->addWidget(idLabel);
  10713. QSpinBox*id= new QSpinBox;
  10714. idLayout->addWidget(id);
  10715. idLayout->addStretch();
  10716. layout->addLayout(idLayout);
  10717. QHBoxLayout*capacityLayout= new QHBoxLayout;
  10718. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  10719. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  10720. capacity->setMinimum(0.0);
  10721. capacity->setDecimals(3);
  10722. capacity->setMaximum(999999.999);
  10723. QComboBox*capacityUnit= new QComboBox;
  10724. capacityUnit->addItem("g");
  10725. capacityUnit->addItem("Kg");
  10726. capacityUnit->addItem("oz");
  10727. capacityUnit->addItem("Lb");
  10728. capacityUnit->setCurrentIndex(3);
  10729. capacityLayout->addWidget(capacityCheckEnabled);
  10730. capacityLayout->addWidget(capacity);
  10731. capacityLayout->addWidget(capacityUnit);
  10732. capacityLayout->addStretch();
  10733. layout->addLayout(capacityLayout);
  10734. layout->addStretch();
  10735. /*771:*/
  10736. #line 16347 "./typica.w"
  10737. QDomElement referenceElement=
  10738. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10739. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10740. QDomElement node;
  10741. /*:771*/
  10742. #line 16311 "./typica.w"
  10743. for(int i= 0;i<configData.size();i++)
  10744. {
  10745. node= configData.at(i).toElement();
  10746. if(node.attribute("name")=="databaseid")
  10747. {
  10748. id->setValue(node.attribute("value").toInt());
  10749. }
  10750. else if(node.attribute("name")=="checkcapacity")
  10751. {
  10752. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  10753. }
  10754. else if(node.attribute("name")=="capacity")
  10755. {
  10756. capacity->setValue(node.attribute("value").toDouble());
  10757. }
  10758. else if(node.attribute("name")=="capacityunit")
  10759. {
  10760. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  10761. }
  10762. }
  10763. updateRoasterId(id->value());
  10764. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10765. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  10766. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  10767. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  10768. setLayout(layout);
  10769. }
  10770. /*:770*//*772:*/
  10771. #line 16357 "./typica.w"
  10772. void RoasterConfWidget::updateRoasterId(int id)
  10773. {
  10774. updateAttribute("databaseid",QString("%1").arg(id));
  10775. }
  10776. void RoasterConfWidget::updateCapacityCheck(int value)
  10777. {
  10778. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  10779. }
  10780. void RoasterConfWidget::updateCapacity(const QString&value)
  10781. {
  10782. updateAttribute("capacity",value);
  10783. }
  10784. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  10785. {
  10786. updateAttribute("capacityunit",value);
  10787. }
  10788. /*:772*/
  10789. #line 597 "./typica.w"
  10790. /*818:*/
  10791. #line 17864 "./typica.w"
  10792. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10793. :BasicDeviceConfigurationWidget(model,index)
  10794. {
  10795. QFormLayout*layout= new QFormLayout;
  10796. QLineEdit*buttonTextEdit= new QLineEdit;
  10797. QLineEdit*annotationTextEdit= new QLineEdit;
  10798. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10799. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10800. /*771:*/
  10801. #line 16347 "./typica.w"
  10802. QDomElement referenceElement=
  10803. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10804. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10805. QDomElement node;
  10806. /*:771*/
  10807. #line 17873 "./typica.w"
  10808. for(int i= 0;i<configData.size();i++)
  10809. {
  10810. node= configData.at(i).toElement();
  10811. if(node.attribute("name")=="buttontext")
  10812. {
  10813. buttonTextEdit->setText(node.attribute("value"));
  10814. }
  10815. else if(node.attribute("name")=="annotationtext")
  10816. {
  10817. annotationTextEdit->setText(node.attribute("value"));
  10818. }
  10819. }
  10820. updateButtonText(buttonTextEdit->text());
  10821. updateAnnotationText(annotationTextEdit->text());
  10822. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10823. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10824. setLayout(layout);
  10825. }
  10826. /*:818*//*819:*/
  10827. #line 17895 "./typica.w"
  10828. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10829. {
  10830. updateAttribute("buttontext",text);
  10831. }
  10832. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10833. {
  10834. updateAttribute("annotationtext",text);
  10835. }
  10836. /*:819*//*822:*/
  10837. #line 17933 "./typica.w"
  10838. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10839. :BasicDeviceConfigurationWidget(model,index)
  10840. {
  10841. QFormLayout*layout= new QFormLayout;
  10842. QLineEdit*buttonTextEdit= new QLineEdit;
  10843. QLineEdit*annotationTextEdit= new QLineEdit;
  10844. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10845. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10846. /*771:*/
  10847. #line 16347 "./typica.w"
  10848. QDomElement referenceElement=
  10849. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10850. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10851. QDomElement node;
  10852. /*:771*/
  10853. #line 17942 "./typica.w"
  10854. for(int i= 0;i<configData.size();i++)
  10855. {
  10856. node= configData.at(i).toElement();
  10857. if(node.attribute("name")=="buttontext")
  10858. {
  10859. buttonTextEdit->setText(node.attribute("value"));
  10860. }
  10861. else if(node.attribute("name")=="annotationtext")
  10862. {
  10863. annotationTextEdit->setText(node.attribute("value"));
  10864. }
  10865. }
  10866. updateButtonText(buttonTextEdit->text());
  10867. updateAnnotationText(annotationTextEdit->text());
  10868. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10869. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10870. QTextEdit*documentation= new QTextEdit;
  10871. documentation->setHtml(tr("If the <b>Annotation Text</b> contains <tt>%1</tt>, this will be replaced in the annotation with a number that increments each time the button is pressed."));
  10872. documentation->setReadOnly(true);
  10873. layout->addRow("",documentation);
  10874. setLayout(layout);
  10875. }
  10876. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10877. {
  10878. updateAttribute("buttontext",text);
  10879. }
  10880. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10881. {
  10882. updateAttribute("annotationtext",text);
  10883. }
  10884. /*:822*/
  10885. #line 598 "./typica.w"
  10886. /*825:*/
  10887. #line 18010 "./typica.w"
  10888. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10889. :BasicDeviceConfigurationWidget(model,index)
  10890. {
  10891. QFormLayout*layout= new QFormLayout;
  10892. QLineEdit*labelEdit= new QLineEdit;
  10893. layout->addRow(tr("Control Label: "),labelEdit);
  10894. QLineEdit*minimumEdit= new QLineEdit;
  10895. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10896. QLineEdit*maximumEdit= new QLineEdit;
  10897. layout->addRow(tr("Maximum Value: "),maximumEdit);
  10898. QSpinBox*precisionEdit= new QSpinBox;
  10899. precisionEdit->setMinimum(0);
  10900. precisionEdit->setMaximum(9);
  10901. layout->addRow(tr("Precision"),precisionEdit);
  10902. QLineEdit*pretext= new QLineEdit;
  10903. layout->addRow(tr("Prefix text"),pretext);
  10904. QLineEdit*posttext= new QLineEdit;
  10905. layout->addRow(tr("Suffix text"),posttext);
  10906. /*771:*/
  10907. #line 16347 "./typica.w"
  10908. QDomElement referenceElement=
  10909. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10910. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10911. QDomElement node;
  10912. /*:771*/
  10913. #line 18029 "./typica.w"
  10914. for(int i= 0;i<configData.size();i++)
  10915. {
  10916. node= configData.at(i).toElement();
  10917. if(node.attribute("name")=="label")
  10918. {
  10919. labelEdit->setText(node.attribute("value"));
  10920. }
  10921. else if(node.attribute("name")=="minimum")
  10922. {
  10923. minimumEdit->setText(node.attribute("value"));
  10924. }
  10925. else if(node.attribute("name")=="maximum")
  10926. {
  10927. maximumEdit->setText(node.attribute("value"));
  10928. }
  10929. else if(node.attribute("name")=="precision")
  10930. {
  10931. precisionEdit->setValue(node.attribute("value").toInt());
  10932. }
  10933. else if(node.attribute("name")=="pretext")
  10934. {
  10935. pretext->setText(node.attribute("value"));
  10936. }
  10937. else if(node.attribute("name")=="posttext")
  10938. {
  10939. posttext->setText(node.attribute("value"));
  10940. }
  10941. }
  10942. updateLabel(labelEdit->text());
  10943. updateMinimum(minimumEdit->text());
  10944. updateMaximum(maximumEdit->text());
  10945. updatePrecision(precisionEdit->value());
  10946. updatePretext(pretext->text());
  10947. updatePosttext(posttext->text());
  10948. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  10949. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  10950. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  10951. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  10952. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  10953. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  10954. setLayout(layout);
  10955. }
  10956. void NoteSpinConfWidget::updateLabel(const QString&text)
  10957. {
  10958. updateAttribute("label",text);
  10959. }
  10960. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  10961. {
  10962. updateAttribute("minimum",minimum);
  10963. }
  10964. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  10965. {
  10966. updateAttribute("maximum",maximum);
  10967. }
  10968. void NoteSpinConfWidget::updatePrecision(int precision)
  10969. {
  10970. updateAttribute("precision",QString("%1").arg(precision));
  10971. }
  10972. void NoteSpinConfWidget::updatePretext(const QString&text)
  10973. {
  10974. updateAttribute("pretext",text);
  10975. }
  10976. void NoteSpinConfWidget::updatePosttext(const QString&text)
  10977. {
  10978. updateAttribute("posttext",text);
  10979. }
  10980. /*:825*/
  10981. #line 599 "./typica.w"
  10982. /*334:*/
  10983. #line 7549 "./typica.w"
  10984. LinearCalibrator::LinearCalibrator(QObject*parent):
  10985. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  10986. {
  10987. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10988. }
  10989. /*:334*//*335:*/
  10990. #line 7563 "./typica.w"
  10991. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  10992. {
  10993. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  10994. if(clamp)
  10995. {
  10996. if(outval<Lo1)
  10997. {
  10998. outval= Lo1;
  10999. }
  11000. else if(outval> Up1)
  11001. {
  11002. outval= Up1;
  11003. }
  11004. }
  11005. if(sensitivitySetting>=0.05)
  11006. {
  11007. int temp= qRound(outval/sensitivitySetting);
  11008. outval= temp*sensitivitySetting;
  11009. }
  11010. Measurement adjusted(outval,measure.time(),measure.scale());
  11011. emit measurement(adjusted);
  11012. return adjusted;
  11013. }
  11014. /*:335*//*336:*/
  11015. #line 7590 "./typica.w"
  11016. double LinearCalibrator::measuredLower()
  11017. {
  11018. return Lo2;
  11019. }
  11020. double LinearCalibrator::measuredUpper()
  11021. {
  11022. return Up2;
  11023. }
  11024. double LinearCalibrator::mappedLower()
  11025. {
  11026. return Lo1;
  11027. }
  11028. double LinearCalibrator::mappedUpper()
  11029. {
  11030. return Up1;
  11031. }
  11032. bool LinearCalibrator::isClosedRange()
  11033. {
  11034. return clamp;
  11035. }
  11036. void LinearCalibrator::setMeasuredLower(double lower)
  11037. {
  11038. Lo2= lower;
  11039. }
  11040. void LinearCalibrator::setMeasuredUpper(double upper)
  11041. {
  11042. Up2= upper;
  11043. }
  11044. void LinearCalibrator::setMappedLower(double lower)
  11045. {
  11046. Lo1= lower;
  11047. }
  11048. void LinearCalibrator::setMappedUpper(double upper)
  11049. {
  11050. Up1= upper;
  11051. }
  11052. void LinearCalibrator::setClosedRange(bool closed)
  11053. {
  11054. clamp= closed;
  11055. }
  11056. void LinearCalibrator::setSensitivity(double sensitivity)
  11057. {
  11058. sensitivitySetting= sensitivity;
  11059. }
  11060. double LinearCalibrator::sensitivity()
  11061. {
  11062. return sensitivitySetting;
  11063. }
  11064. /*:336*/
  11065. #line 600 "./typica.w"
  11066. /*341:*/
  11067. #line 7723 "./typica.w"
  11068. void LinearSplineInterpolator::add_pair(double source,double destination)
  11069. {
  11070. pairs->insert(source,destination);
  11071. make_interpolators();
  11072. }
  11073. void LinearSplineInterpolator::make_interpolators()
  11074. {
  11075. if(pairs->size()> 1)
  11076. {
  11077. while(interpolators->size()> 0)
  11078. {
  11079. LinearCalibrator*removed= interpolators->takeFirst();
  11080. removed->deleteLater();
  11081. }
  11082. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11083. QMap<double,double> ::const_iterator j= i+1;
  11084. while(j!=pairs->constEnd())
  11085. {
  11086. LinearCalibrator*segment= new LinearCalibrator();
  11087. segment->setMeasuredLower(i.key());
  11088. segment->setMappedLower(i.value());
  11089. segment->setMeasuredUpper(j.key());
  11090. segment->setMappedUpper(j.value());
  11091. segment->setClosedRange(false);
  11092. interpolators->append(segment);
  11093. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11094. i++;
  11095. j++;
  11096. }
  11097. }
  11098. }
  11099. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  11100. QObject(parent),pairs(new QMap<double,double> ),
  11101. interpolators(new QList<LinearCalibrator*> )
  11102. {
  11103. }
  11104. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  11105. {
  11106. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11107. int index= -1;
  11108. while(i!=pairs->constEnd())
  11109. {
  11110. if(measure.temperature()<=i.key())
  11111. {
  11112. break;
  11113. }
  11114. i++;
  11115. index++;
  11116. }
  11117. if(index<0)
  11118. {
  11119. index= 0;
  11120. }
  11121. if(index>=interpolators->size())
  11122. {
  11123. index= interpolators->size()-1;
  11124. }
  11125. if(interpolators->at(index)!=NULL)
  11126. {
  11127. return interpolators->at(index)->newMeasurement(measure);
  11128. }
  11129. return Measurement();
  11130. }
  11131. /*:341*/
  11132. #line 601 "./typica.w"
  11133. /*936:*/
  11134. #line 19380 "./typica.w"
  11135. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11136. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  11137. {
  11138. QFormLayout*layout= new QFormLayout;
  11139. QLineEdit*source= new QLineEdit;
  11140. layout->addRow(tr("Source column name:"),source);
  11141. QLineEdit*destination= new QLineEdit;
  11142. layout->addRow(tr("Destination column name:"),destination);
  11143. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  11144. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  11145. QTableView*mappingTable= new QTableView;
  11146. mappingTable->setModel(tablemodel);
  11147. NumericDelegate*delegate= new NumericDelegate;
  11148. mappingTable->setItemDelegate(delegate);
  11149. layout->addRow(tr("Mapping data:"),mappingTable);
  11150. /*771:*/
  11151. #line 16347 "./typica.w"
  11152. QDomElement referenceElement=
  11153. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11154. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11155. QDomElement node;
  11156. /*:771*/
  11157. #line 19396 "./typica.w"
  11158. for(int i= 0;i<configData.size();i++)
  11159. {
  11160. node= configData.at(i).toElement();
  11161. if(node.attribute("name")=="source")
  11162. {
  11163. source->setText(node.attribute("value"));
  11164. }
  11165. else if(node.attribute("name")=="destination")
  11166. {
  11167. destination->setText(node.attribute("value"));
  11168. }
  11169. else if(node.attribute("name")=="sourcevalues")
  11170. {
  11171. /*937:*/
  11172. #line 19435 "./typica.w"
  11173. QString data= node.attribute("value");
  11174. if(data.length()> 3)
  11175. {
  11176. data.chop(2);
  11177. data= data.remove(0,2);
  11178. }
  11179. QStringList itemList= data.split(",");
  11180. /*:937*/
  11181. #line 19410 "./typica.w"
  11182. int column= 0;
  11183. /*938:*/
  11184. #line 19447 "./typica.w"
  11185. for(int j= 0;j<itemList.size();j++)
  11186. {
  11187. tablemodel->setData(tablemodel->index(j,column),
  11188. QVariant(itemList.at(j).toDouble()),
  11189. Qt::DisplayRole);
  11190. }
  11191. /*:938*/
  11192. #line 19412 "./typica.w"
  11193. }
  11194. else if(node.attribute("name")=="destinationvalues")
  11195. {
  11196. /*937:*/
  11197. #line 19435 "./typica.w"
  11198. QString data= node.attribute("value");
  11199. if(data.length()> 3)
  11200. {
  11201. data.chop(2);
  11202. data= data.remove(0,2);
  11203. }
  11204. QStringList itemList= data.split(",");
  11205. /*:937*/
  11206. #line 19417 "./typica.w"
  11207. int column= 1;
  11208. /*938:*/
  11209. #line 19447 "./typica.w"
  11210. for(int j= 0;j<itemList.size();j++)
  11211. {
  11212. tablemodel->setData(tablemodel->index(j,column),
  11213. QVariant(itemList.at(j).toDouble()),
  11214. Qt::DisplayRole);
  11215. }
  11216. /*:938*/
  11217. #line 19419 "./typica.w"
  11218. }
  11219. }
  11220. updateSourceColumn(source->text());
  11221. updateDestinationColumn(destination->text());
  11222. updateKnots();
  11223. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11224. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11225. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11226. setLayout(layout);
  11227. }
  11228. /*:936*//*939:*/
  11229. #line 19458 "./typica.w"
  11230. void LinearSplineInterpolationConfWidget::updateKnots()
  11231. {
  11232. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11233. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11234. }
  11235. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11236. {
  11237. updateAttribute("source",source);
  11238. }
  11239. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11240. {
  11241. updateAttribute("destination",dest);
  11242. }
  11243. /*:939*/
  11244. #line 602 "./typica.w"
  11245. /*956:*/
  11246. #line 19927 "./typica.w"
  11247. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11248. :BasicDeviceConfigurationWidget(model,index),
  11249. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  11250. {
  11251. unitSelector->addItem("Fahrenheit");
  11252. unitSelector->addItem("Celsius");
  11253. temperatureValue->setMinimum(0);
  11254. temperatureValue->setMaximum(1000);
  11255. QFormLayout*layout= new QFormLayout;
  11256. QLineEdit*column= new QLineEdit;
  11257. layout->addRow(tr("Column to match:"),column);
  11258. layout->addRow(tr("Unit:"),unitSelector);
  11259. layout->addRow(tr("Value:"),temperatureValue);
  11260. /*771:*/
  11261. #line 16347 "./typica.w"
  11262. QDomElement referenceElement=
  11263. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11264. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11265. QDomElement node;
  11266. /*:771*/
  11267. #line 19941 "./typica.w"
  11268. for(int i= 0;i<configData.size();i++)
  11269. {
  11270. node= configData.at(i).toElement();
  11271. if(node.attribute("name")=="column")
  11272. {
  11273. column->setText(node.attribute("value"));
  11274. }
  11275. else if(node.attribute("name")=="unit")
  11276. {
  11277. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11278. }
  11279. else if(node.attribute("name")=="value")
  11280. {
  11281. temperatureValue->setValue(node.attribute("value").toDouble());
  11282. }
  11283. }
  11284. updateMatchingColumn(column->text());
  11285. updateTemperature();
  11286. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  11287. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  11288. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  11289. setLayout(layout);
  11290. }
  11291. /*:956*//*957:*/
  11292. #line 19970 "./typica.w"
  11293. void TranslationConfWidget::updateTemperature()
  11294. {
  11295. updateAttribute("unit",unitSelector->currentText());
  11296. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  11297. if(unitSelector->currentText()=="Fahrenheit")
  11298. {
  11299. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  11300. }
  11301. else
  11302. {
  11303. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11304. }
  11305. }
  11306. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11307. {
  11308. updateAttribute("column",column);
  11309. }
  11310. /*:957*/
  11311. #line 603 "./typica.w"
  11312. /*828:*/
  11313. #line 24 "./freeannotation.w"
  11314. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11315. const QModelIndex&index)
  11316. :BasicDeviceConfigurationWidget(model,index)
  11317. {
  11318. QFormLayout*layout= new QFormLayout;
  11319. QLineEdit*labelEdit= new QLineEdit;
  11320. layout->addRow(tr("Label Text:"),labelEdit);
  11321. /*771:*/
  11322. #line 16347 "./typica.w"
  11323. QDomElement referenceElement=
  11324. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11325. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11326. QDomElement node;
  11327. /*:771*/
  11328. #line 32 "./freeannotation.w"
  11329. for(int i= 0;i<configData.size();i++)
  11330. {
  11331. node= configData.at(i).toElement();
  11332. if(node.attribute("name")=="labeltext")
  11333. {
  11334. labelEdit->setText(node.attribute("value"));
  11335. }
  11336. }
  11337. updateLabel(labelEdit->text());
  11338. connect(labelEdit,SIGNAL(textEdited(QString)),
  11339. this,SLOT(updateLabel(QString)));
  11340. setLayout(layout);
  11341. }
  11342. /*:828*//*829:*/
  11343. #line 49 "./freeannotation.w"
  11344. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11345. {
  11346. updateAttribute("labeltext",text);
  11347. }
  11348. /*:829*/
  11349. #line 604 "./typica.w"
  11350. /*960:*/
  11351. #line 39 "./rate.w"
  11352. void RateOfChange::newMeasurement(Measurement measure)
  11353. {
  11354. cache.append(measure);
  11355. /*961:*/
  11356. #line 64 "./rate.w"
  11357. if(cache.size()> 2)
  11358. {
  11359. bool done= false;
  11360. while(!done)
  11361. {
  11362. if(cache.front().time().secsTo(cache.back().time())> ct)
  11363. {
  11364. cache.removeFirst();
  11365. }
  11366. else if(cache.back().time()<cache.front().time())
  11367. {
  11368. cache.removeFirst();
  11369. done= true;
  11370. }
  11371. else
  11372. {
  11373. done= true;
  11374. }
  11375. if(cache.size()<3)
  11376. {
  11377. done= true;
  11378. }
  11379. }
  11380. }
  11381. /*:961*/
  11382. #line 43 "./rate.w"
  11383. if(cache.size()>=2)
  11384. {
  11385. /*962:*/
  11386. #line 96 "./rate.w"
  11387. int N= cache.size();
  11388. double SXY= 0;
  11389. double SX= 0;
  11390. double SXX= 0;
  11391. double SY= 0;
  11392. double y;
  11393. double x;
  11394. for(int i= 0;i<N;i++)
  11395. {
  11396. y= cache.at(i).temperature();
  11397. SY+= y;
  11398. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11399. SX+= x;
  11400. SXX+= (x*x);
  11401. SXY+= (x*y);
  11402. }
  11403. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11404. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11405. value.insert("relative",true);
  11406. emit newData(value);
  11407. /*:962*/
  11408. #line 46 "./rate.w"
  11409. }
  11410. }
  11411. /*:960*//*963:*/
  11412. #line 120 "./rate.w"
  11413. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11414. {
  11415. setScaleTime(scaletime);
  11416. }
  11417. void RateOfChange::setCacheTime(int seconds)
  11418. {
  11419. ct= seconds;
  11420. }
  11421. void RateOfChange::setScaleTime(int seconds)
  11422. {
  11423. st= (seconds> 0?seconds:1);
  11424. }
  11425. /*:963*/
  11426. #line 605 "./typica.w"
  11427. /*832:*/
  11428. #line 26 "./settings.w"
  11429. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11430. {
  11431. QTabWidget*settingsTab= new QTabWidget;
  11432. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11433. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11434. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11435. settingsTab->addTab(graphSettings,tr("Graph"));
  11436. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11437. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11438. setCentralWidget(settingsTab);
  11439. }
  11440. /*:832*/
  11441. #line 606 "./typica.w"
  11442. /*837:*/
  11443. #line 27 "./graphsettings.w"
  11444. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11445. {
  11446. QTabWidget*graphCategories= new QTabWidget;
  11447. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11448. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11449. QVBoxLayout*layout= new QVBoxLayout;
  11450. layout->addWidget(graphCategories);
  11451. setLayout(layout);
  11452. }
  11453. /*:837*//*839:*/
  11454. #line 65 "./graphsettings.w"
  11455. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11456. colorEdit(new QLineEdit)
  11457. {
  11458. QSettings settings;
  11459. QVBoxLayout*layout= new QVBoxLayout;
  11460. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11461. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11462. updateEnableSetting(enable->isChecked());
  11463. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11464. layout->addWidget(enable);
  11465. QHBoxLayout*colorLayout= new QHBoxLayout;
  11466. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11467. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11468. updateColorSetting(colorEdit->text());
  11469. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11470. QToolButton*colorPickerButton= new QToolButton();
  11471. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11472. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11473. colorLayout->addWidget(colorLabel);
  11474. colorLayout->addWidget(colorEdit);
  11475. colorLayout->addWidget(colorPickerButton);
  11476. colorLayout->addStretch();
  11477. layout->addLayout(colorLayout);
  11478. QHBoxLayout*unitLayout= new QHBoxLayout;
  11479. QLabel*unitLabel= new QLabel(tr("Unit"));
  11480. QComboBox*unitSelector= new QComboBox;
  11481. unitSelector->addItem(tr("Fahrenheit"));
  11482. unitSelector->addItem(tr("Celsius"));
  11483. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11484. updateUnit(unitSelector->currentIndex());
  11485. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11486. unitLayout->addWidget(unitLabel);
  11487. unitLayout->addWidget(unitSelector);
  11488. unitLayout->addStretch();
  11489. layout->addLayout(unitLayout);
  11490. QHBoxLayout*axisLayout= new QHBoxLayout;
  11491. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11492. QLineEdit*axisEdit= new QLineEdit;
  11493. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  11494. updateAxisSetting(axisEdit->text());
  11495. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11496. axisLayout->addWidget(axisLabel);
  11497. axisLayout->addWidget(axisEdit);
  11498. layout->addLayout(axisLayout);
  11499. layout->addStretch();
  11500. setLayout(layout);
  11501. }
  11502. /*:839*//*840:*/
  11503. #line 116 "./graphsettings.w"
  11504. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11505. {
  11506. QSettings settings;
  11507. settings.setValue("settings/graph/relative/enable",enabled);
  11508. }
  11509. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11510. {
  11511. QSettings settings;
  11512. settings.setValue("settings/graph/relative/color",color);
  11513. }
  11514. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11515. {
  11516. QSettings settings;
  11517. QString settingValue;
  11518. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11519. QStringList numbers;
  11520. foreach(QString text,points)
  11521. {
  11522. bool okay= false;
  11523. text.toDouble(&okay);
  11524. if(okay)
  11525. {
  11526. numbers.append(text);
  11527. }
  11528. }
  11529. numbers.removeDuplicates();
  11530. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11531. }
  11532. void GraphSettingsRelativeTab::updateUnit(int unit)
  11533. {
  11534. QSettings settings;
  11535. settings.setValue("settings/graph/relative/unit",unit);
  11536. }
  11537. /*:840*//*841:*/
  11538. #line 159 "./graphsettings.w"
  11539. void GraphSettingsRelativeTab::showColorPicker()
  11540. {
  11541. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11542. colorEdit->setText(color.name());
  11543. }
  11544. #line 62 "./settings.w"
  11545. #line 1 "./advancedsettings.w"
  11546. /*:841*/
  11547. #line 607 "./typica.w"
  11548. /*995:*/
  11549. #line 682 "./dataqsdk.w"
  11550. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11551. const QModelIndex&index)
  11552. :BasicDeviceConfigurationWidget(model,index),
  11553. deviceIdStack(new QStackedWidget)
  11554. {
  11555. QVBoxLayout*layout= new QVBoxLayout;
  11556. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11557. layout->addWidget(autoDetect);
  11558. QWidget*autoLayerWidget= new QWidget;
  11559. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11560. QLabel*autoLabel= new QLabel(tr("Device number"));
  11561. QSpinBox*autoNumber= new QSpinBox;
  11562. autoNumber->setMinimum(1);
  11563. autoNumber->setMaximum(99);
  11564. autoLayerLayout->addWidget(autoLabel);
  11565. autoLayerLayout->addWidget(autoNumber);
  11566. autoLayerWidget->setLayout(autoLayerLayout);
  11567. QWidget*fixedLayerWidget= new QWidget;
  11568. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11569. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11570. QComboBox*portSelection= new QComboBox;
  11571. portSelection->setEditable(true);
  11572. portSelection->addItems(DataqSdkDevice::detectHardware());
  11573. fixedLayerLayout->addWidget(fixedLabel);
  11574. fixedLayerLayout->addWidget(portSelection);
  11575. fixedLayerWidget->setLayout(fixedLayerLayout);
  11576. deviceIdStack->addWidget(autoLayerWidget);
  11577. deviceIdStack->addWidget(fixedLayerWidget);
  11578. layout->addWidget(deviceIdStack);
  11579. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11580. layout->addWidget(addChannelButton);
  11581. /*771:*/
  11582. #line 16347 "./typica.w"
  11583. QDomElement referenceElement=
  11584. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11585. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11586. QDomElement node;
  11587. /*:771*/
  11588. #line 714 "./dataqsdk.w"
  11589. for(int i= 0;i<configData.size();i++)
  11590. {
  11591. node= configData.at(i).toElement();
  11592. if(node.attribute("name")=="autoSelect")
  11593. {
  11594. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11595. }
  11596. else if(node.attribute("name")=="deviceNumber")
  11597. {
  11598. autoNumber->setValue(node.attribute("value").toInt());
  11599. }
  11600. else if(node.attribute("name")=="port")
  11601. {
  11602. int index= portSelection->findText(node.attribute("value"));
  11603. if(index> -1)
  11604. {
  11605. portSelection->setCurrentIndex(index);
  11606. }
  11607. else
  11608. {
  11609. portSelection->setEditText(node.attribute("value"));
  11610. }
  11611. }
  11612. }
  11613. updateAutoSelect(autoDetect->isChecked());
  11614. updateDeviceNumber(autoNumber->value());
  11615. updatePort(portSelection->currentText());
  11616. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11617. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11618. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11619. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11620. setLayout(layout);
  11621. }
  11622. /*:995*//*996:*/
  11623. #line 758 "./dataqsdk.w"
  11624. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11625. {
  11626. if(automatic)
  11627. {
  11628. updateAttribute("autoSelect","true");
  11629. deviceIdStack->setCurrentIndex(0);
  11630. }
  11631. else
  11632. {
  11633. updateAttribute("autoSelect","false");
  11634. deviceIdStack->setCurrentIndex(1);
  11635. }
  11636. }
  11637. /*:996*//*997:*/
  11638. #line 775 "./dataqsdk.w"
  11639. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11640. {
  11641. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11642. }
  11643. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11644. {
  11645. updateAttribute("port",portId);
  11646. }
  11647. /*:997*//*998:*/
  11648. #line 788 "./dataqsdk.w"
  11649. void DataqSdkDeviceConfWidget::addChannel()
  11650. {
  11651. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11652. }
  11653. /*:998*//*1001:*/
  11654. #line 868 "./dataqsdk.w"
  11655. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11656. const QModelIndex&index)
  11657. :BasicDeviceConfigurationWidget(model,index),
  11658. startButton(new QPushButton(tr("Start"))),
  11659. resetButton(new QPushButton(tr("Reset"))),
  11660. stopButton(new QPushButton(tr("Stop"))),
  11661. calibrator(new LinearCalibrator),
  11662. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11663. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11664. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11665. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11666. rmCount(0),cmCount(0),
  11667. rmin(std::numeric_limits<double> ::max()),
  11668. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11669. cmin(std::numeric_limits<double> ::max()),
  11670. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11671. {
  11672. /*1005:*/
  11673. #line 1107 "./dataqsdk.w"
  11674. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11675. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11676. QDomElement deviceNode;
  11677. QString configPort;
  11678. QString configAuto;
  11679. for(int i= 0;i<deviceConfigData.size();i++)
  11680. {
  11681. deviceNode= deviceConfigData.at(i).toElement();
  11682. if(deviceNode.attribute("name")=="autoSelect")
  11683. {
  11684. autoSelect= (deviceNode.attribute("value")=="true");
  11685. }
  11686. else if(deviceNode.attribute("name")=="deviceNumber")
  11687. {
  11688. configAuto= deviceNode.attribute("value");
  11689. }
  11690. else if(deviceNode.attribute("name")=="port")
  11691. {
  11692. configPort= deviceNode.attribute("value");
  11693. }
  11694. }
  11695. deviceID= autoSelect?configAuto:configPort;
  11696. channelOfInterest= index.row();
  11697. /*:1005*/
  11698. #line 886 "./dataqsdk.w"
  11699. resetButton->setEnabled(false);
  11700. stopButton->setEnabled(false);
  11701. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11702. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11703. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11704. QVBoxLayout*layout= new QVBoxLayout;
  11705. QFormLayout*topLayout= new QFormLayout;
  11706. QLineEdit*columnEdit= new QLineEdit;
  11707. topLayout->addRow(tr("Column name"),columnEdit);
  11708. QComboBox*unitSelector= new QComboBox;
  11709. unitSelector->addItem(tr("Temperature"));
  11710. unitSelector->addItem(tr("Control"));
  11711. topLayout->addRow(tr("Measurement type"),unitSelector);
  11712. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11713. topLayout->addRow(smoothingBox);
  11714. layout->addLayout(topLayout);
  11715. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11716. topLayout->addRow(hideSeries);
  11717. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11718. layout->addWidget(calibrationLabel);
  11719. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11720. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11721. QLineEdit*measuredLowerEdit= new QLineEdit;
  11722. measuredLowerEdit->setText("0");
  11723. QLineEdit*measuredUpperEdit= new QLineEdit;
  11724. measuredUpperEdit->setText("10");
  11725. QLineEdit*mappedLowerEdit= new QLineEdit;
  11726. mappedLowerEdit->setText("0");
  11727. QLineEdit*mappedUpperEdit= new QLineEdit;
  11728. mappedUpperEdit->setText("10");
  11729. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11730. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11731. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11732. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11733. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11734. calibrationControlsLayout->addRow(closedBox);
  11735. QLineEdit*sensitivityEdit= new QLineEdit;
  11736. sensitivityEdit->setText("0");
  11737. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11738. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11739. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11740. deviceControlLayout->addWidget(startButton);
  11741. deviceControlLayout->addWidget(resetButton);
  11742. deviceControlLayout->addWidget(stopButton);
  11743. QFormLayout*indicatorLayout= new QFormLayout;
  11744. currentMeasurement->setReadOnly(true);
  11745. minimumMeasurement->setReadOnly(true);
  11746. maximumMeasurement->setReadOnly(true);
  11747. averageMeasurement->setReadOnly(true);
  11748. currentMapped->setReadOnly(true);
  11749. minimumMapped->setReadOnly(true);
  11750. maximumMapped->setReadOnly(true);
  11751. averageMapped->setReadOnly(true);
  11752. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11753. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11754. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11755. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11756. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11757. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11758. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11759. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11760. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11761. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11762. calibrationTestLayout->addLayout(deviceControlLayout);
  11763. calibrationTestLayout->addLayout(indicatorLayout);
  11764. calibrationLayout->addLayout(calibrationControlsLayout);
  11765. calibrationLayout->addLayout(calibrationTestLayout);
  11766. layout->addLayout(calibrationLayout);
  11767. /*771:*/
  11768. #line 16347 "./typica.w"
  11769. QDomElement referenceElement=
  11770. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11771. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11772. QDomElement node;
  11773. /*:771*/
  11774. #line 955 "./dataqsdk.w"
  11775. for(int i= 0;i<configData.size();i++)
  11776. {
  11777. node= configData.at(i).toElement();
  11778. if(node.attribute("name")=="column")
  11779. {
  11780. columnEdit->setText(node.attribute("value"));
  11781. }
  11782. else if(node.attribute("name")=="type")
  11783. {
  11784. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11785. }
  11786. else if(node.attribute("name")=="smoothing")
  11787. {
  11788. smoothingBox->setChecked(node.attribute("value")=="true");
  11789. }
  11790. else if(node.attribute("name")=="calibrationMeasuredLower")
  11791. {
  11792. measuredLowerEdit->setText(node.attribute("value"));
  11793. }
  11794. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11795. {
  11796. measuredUpperEdit->setText(node.attribute("value"));
  11797. }
  11798. else if(node.attribute("name")=="calibrationMappedLower")
  11799. {
  11800. mappedLowerEdit->setText(node.attribute("value"));
  11801. }
  11802. else if(node.attribute("name")=="calibrationMappedUpper")
  11803. {
  11804. mappedUpperEdit->setText(node.attribute("value"));
  11805. }
  11806. else if(node.attribute("name")=="calibrationClosedInterval")
  11807. {
  11808. closedBox->setChecked(node.attribute("value")=="true");
  11809. }
  11810. else if(node.attribute("name")=="calibrationSensitivity")
  11811. {
  11812. sensitivityEdit->setText(node.attribute("value"));
  11813. }
  11814. else if(node.attribute("name")=="hidden")
  11815. {
  11816. hideSeries->setChecked(node.attribute("value")=="true");
  11817. }
  11818. }
  11819. updateColumnName(columnEdit->text());
  11820. updateUnits(unitSelector->currentText());
  11821. updateSmoothingEnabled(smoothingBox->isChecked());
  11822. updateMeasuredLower(measuredLowerEdit->text());
  11823. updateMeasuredUpper(measuredUpperEdit->text());
  11824. updateMappedLower(mappedLowerEdit->text());
  11825. updateMappedUpper(mappedUpperEdit->text());
  11826. updateClosedInterval(closedBox->isChecked());
  11827. updateSensitivity(sensitivityEdit->text());
  11828. updateHidden(hideSeries->isChecked());
  11829. connect(columnEdit,SIGNAL(textChanged(QString)),
  11830. this,SLOT(updateColumnName(QString)));
  11831. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11832. this,SLOT(updateUnits(QString)));
  11833. connect(smoothingBox,SIGNAL(toggled(bool)),
  11834. this,SLOT(updateSmoothingEnabled(bool)));
  11835. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11836. this,SLOT(updateMeasuredLower(QString)));
  11837. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11838. this,SLOT(updateMappedLower(QString)));
  11839. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11840. this,SLOT(updateMeasuredUpper(QString)));
  11841. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11842. this,SLOT(updateMappedUpper(QString)));
  11843. connect(closedBox,SIGNAL(toggled(bool)),
  11844. this,SLOT(updateClosedInterval(bool)));
  11845. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11846. this,SLOT(updateSensitivity(QString)));
  11847. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11848. setLayout(layout);
  11849. }
  11850. /*:1001*//*1002:*/
  11851. #line 1038 "./dataqsdk.w"
  11852. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11853. {
  11854. updateAttribute("type",unit);
  11855. }
  11856. /*:1002*//*1003:*/
  11857. #line 1047 "./dataqsdk.w"
  11858. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11859. {
  11860. updateAttribute("calibrationMeasuredLower",value);
  11861. calibrator->setMeasuredLower(value.toDouble());
  11862. }
  11863. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11864. {
  11865. updateAttribute("calibrationMeasuredUpper",value);
  11866. calibrator->setMeasuredUpper(value.toDouble());
  11867. }
  11868. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11869. {
  11870. updateAttribute("calibrationMappedLower",value);
  11871. calibrator->setMappedLower(value.toDouble());
  11872. }
  11873. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11874. {
  11875. updateAttribute("calibrationMappedUpper",value);
  11876. calibrator->setMappedUpper(value.toDouble());
  11877. }
  11878. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11879. {
  11880. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11881. calibrator->setClosedRange(closed);
  11882. }
  11883. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11884. {
  11885. updateAttribute("smoothing",enabled?"true":"false");
  11886. }
  11887. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  11888. {
  11889. updateAttribute("calibrationSensitivity",value);
  11890. calibrator->setSensitivity(value.toDouble());
  11891. }
  11892. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  11893. {
  11894. updateAttribute("hidden",hidden?"true":"false");
  11895. }
  11896. /*:1003*//*1006:*/
  11897. #line 1136 "./dataqsdk.w"
  11898. void DataqSdkChannelConfWidget::startCalibration()
  11899. {
  11900. startButton->setEnabled(false);
  11901. stopButton->setEnabled(true);
  11902. resetButton->setEnabled(true);
  11903. calibrationDevice= new DataqSdkDevice(deviceID);
  11904. Channel*channel;
  11905. for(unsigned int i= 0;i<=channelOfInterest;i++)
  11906. {
  11907. channel= calibrationDevice->newChannel(Units::Unitless);
  11908. }
  11909. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  11910. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  11911. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  11912. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  11913. calibrationDevice->start();
  11914. }
  11915. void DataqSdkChannelConfWidget::stopCalibration()
  11916. {
  11917. startButton->setEnabled(true);
  11918. stopButton->setEnabled(false);
  11919. resetButton->setEnabled(false);
  11920. calibrationDevice->deleteLater();
  11921. /*1008:*/
  11922. #line 1181 "./dataqsdk.w"
  11923. rmCount= 0;
  11924. cmCount= 0;
  11925. rmin= std::numeric_limits<double> ::max();
  11926. rmax= std::numeric_limits<double> ::min();
  11927. rmean= 0;
  11928. cmin= std::numeric_limits<double> ::max();
  11929. cmax= std::numeric_limits<double> ::min();
  11930. cmean= 0;
  11931. /*:1008*/
  11932. #line 1161 "./dataqsdk.w"
  11933. }
  11934. /*:1006*//*1007:*/
  11935. #line 1172 "./dataqsdk.w"
  11936. void DataqSdkChannelConfWidget::resetCalibration()
  11937. {
  11938. /*1008:*/
  11939. #line 1181 "./dataqsdk.w"
  11940. rmCount= 0;
  11941. cmCount= 0;
  11942. rmin= std::numeric_limits<double> ::max();
  11943. rmax= std::numeric_limits<double> ::min();
  11944. rmean= 0;
  11945. cmin= std::numeric_limits<double> ::max();
  11946. cmax= std::numeric_limits<double> ::min();
  11947. cmean= 0;
  11948. /*:1008*/
  11949. #line 1175 "./dataqsdk.w"
  11950. }
  11951. /*:1007*//*1009:*/
  11952. #line 1195 "./dataqsdk.w"
  11953. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  11954. {
  11955. double nv= measure.temperature();
  11956. currentMeasurement->setText(QString("%1").arg(nv));
  11957. rmin= qMin(nv,rmin);
  11958. minimumMeasurement->setText(QString("%1").arg(rmin));
  11959. rmax= qMax(nv,rmax);
  11960. maximumMeasurement->setText(QString("%1").arg(rmax));
  11961. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  11962. rmCount++;
  11963. averageMeasurement->setText(QString("%1").arg(rmean));
  11964. }
  11965. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  11966. {
  11967. double nv= measure.temperature();
  11968. currentMapped->setText(QString("%1").arg(nv));
  11969. cmin= qMin(nv,cmin);
  11970. minimumMapped->setText(QString("%1").arg(cmin));
  11971. cmax= qMax(nv,cmax);
  11972. maximumMapped->setText(QString("%1").arg(cmax));
  11973. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  11974. cmCount++;
  11975. averageMapped->setText(QString("%1").arg(cmean));
  11976. }
  11977. /*:1009*//*1010:*/
  11978. #line 1224 "./dataqsdk.w"
  11979. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  11980. {
  11981. updateAttribute("column",value);
  11982. }
  11983. /*:1010*/
  11984. #line 608 "./typica.w"
  11985. /*1034:*/
  11986. #line 423 "./scales.w"
  11987. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  11988. const QModelIndex&index)
  11989. :BasicDeviceConfigurationWidget(model,index),
  11990. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  11991. flow(new FlowSelector),stop(new StopSelector),
  11992. weighcommand(new QLineEdit("!KP")),commandterminator(new QComboBox)
  11993. {
  11994. QFormLayout*layout= new QFormLayout;
  11995. layout->addRow(tr("Port:"),port);
  11996. connect(port,SIGNAL(currentIndexChanged(QString)),
  11997. this,SLOT(updatePort(QString)));
  11998. connect(port,SIGNAL(editTextChanged(QString)),
  11999. this,SLOT(updatePort(QString)));
  12000. layout->addRow(tr("Baud:"),baud);
  12001. connect(baud,SIGNAL(currentIndexChanged(QString)),
  12002. this,SLOT(updateBaudRate(QString)));
  12003. layout->addRow(tr("Parity:"),parity);
  12004. connect(parity,SIGNAL(currentIndexChanged(int)),
  12005. this,SLOT(updateParity(int)));
  12006. layout->addRow(tr("Flow Control:"),flow);
  12007. connect(flow,SIGNAL(currentIndexChanged(int)),
  12008. this,SLOT(updateFlowControl(int)));
  12009. layout->addRow(tr("Stop Bits:"),stop);
  12010. connect(stop,SIGNAL(currentIndexChanged(int)),
  12011. this,SLOT(updateStopBits(int)));
  12012. layout->addRow(tr("Weigh Command:"),weighcommand);
  12013. connect(weighcommand,SIGNAL(textChanged(QString)),
  12014. this,SLOT(updateWeighCommand(QString)));
  12015. commandterminator->addItem("CRLF");
  12016. commandterminator->addItem("CR");
  12017. commandterminator->addItem("LF");
  12018. layout->addRow(tr("Command Terminator:"),commandterminator);
  12019. connect(commandterminator,SIGNAL(currentIndexChanged(QString)),
  12020. this,SLOT(updateCommandTerminator(QString)));
  12021. /*771:*/
  12022. #line 16347 "./typica.w"
  12023. QDomElement referenceElement=
  12024. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12025. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12026. QDomElement node;
  12027. /*:771*/
  12028. #line 459 "./scales.w"
  12029. for(int i= 0;i<configData.size();i++)
  12030. {
  12031. node= configData.at(i).toElement();
  12032. if(node.attribute("name")=="port")
  12033. {
  12034. int j= port->findText(node.attribute("value"));
  12035. if(j>=0)
  12036. {
  12037. port->setCurrentIndex(j);
  12038. }
  12039. else
  12040. {
  12041. port->insertItem(0,node.attribute("value"));
  12042. port->setCurrentIndex(0);
  12043. }
  12044. }
  12045. else if(node.attribute("name")=="baudrate")
  12046. {
  12047. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12048. }
  12049. else if(node.attribute("name")=="parity")
  12050. {
  12051. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  12052. }
  12053. else if(node.attribute("name")=="flowcontrol")
  12054. {
  12055. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  12056. }
  12057. else if(node.attribute("name")=="stopbits")
  12058. {
  12059. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  12060. }
  12061. else if(node.attribute("name")=="weighcommand")
  12062. {
  12063. weighcommand->setText(node.attribute("value"));
  12064. }
  12065. else if(node.attribute("name")=="commandterminator")
  12066. {
  12067. commandterminator->setCurrentIndex(
  12068. commandterminator->findText(node.attribute("value")));
  12069. }
  12070. }
  12071. updatePort(port->currentText());
  12072. updateBaudRate(baud->currentText());
  12073. updateParity(parity->currentIndex());
  12074. updateFlowControl(flow->currentIndex());
  12075. updateStopBits(stop->currentIndex());
  12076. updateWeighCommand(weighcommand->text());
  12077. updateCommandTerminator(commandterminator->currentText());
  12078. setLayout(layout);
  12079. }
  12080. /*:1034*//*1035:*/
  12081. #line 514 "./scales.w"
  12082. void SerialScaleConfWidget::updatePort(const QString&newPort)
  12083. {
  12084. updateAttribute("port",newPort);
  12085. }
  12086. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  12087. {
  12088. updateAttribute("baudrate",rate);
  12089. }
  12090. void SerialScaleConfWidget::updateParity(int index)
  12091. {
  12092. updateAttribute("parity",parity->itemData(index).toString());
  12093. }
  12094. void SerialScaleConfWidget::updateFlowControl(int index)
  12095. {
  12096. updateAttribute("flowcontrol",flow->itemData(index).toString());
  12097. }
  12098. void SerialScaleConfWidget::updateStopBits(int index)
  12099. {
  12100. updateAttribute("stopbits",stop->itemData(index).toString());
  12101. }
  12102. void SerialScaleConfWidget::updateWeighCommand(const QString&command)
  12103. {
  12104. updateAttribute("weighcommand",command);
  12105. }
  12106. void SerialScaleConfWidget::updateCommandTerminator(const QString&terminator)
  12107. {
  12108. updateAttribute("commandterminator",terminator);
  12109. }
  12110. /*:1035*/
  12111. #line 609 "./typica.w"
  12112. /*1047:*/
  12113. #line 195 "./valueannotation.w"
  12114. void ValueAnnotation::newMeasurement(Measurement measure)
  12115. {
  12116. for(int i= 0;i<values.size();i++)
  12117. {
  12118. if(measure.temperature()> values.at(i)-tolerance&&
  12119. measure.temperature()<values.at(i)+tolerance)
  12120. {
  12121. if(i!=lastIndex)
  12122. {
  12123. lastIndex= i;
  12124. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  12125. }
  12126. }
  12127. }
  12128. }
  12129. /*:1047*//*1048:*/
  12130. #line 216 "./valueannotation.w"
  12131. void ValueAnnotation::annotate()
  12132. {
  12133. if(lastIndex> -1)
  12134. {
  12135. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  12136. }
  12137. }
  12138. /*:1048*//*1049:*/
  12139. #line 228 "./valueannotation.w"
  12140. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  12141. {
  12142. values.append(value);
  12143. annotations.append(annotation);
  12144. }
  12145. /*:1049*//*1050:*/
  12146. #line 237 "./valueannotation.w"
  12147. void ValueAnnotation::setAnnotationColumn(int column)
  12148. {
  12149. annotationColumn= column;
  12150. }
  12151. void ValueAnnotation::setTemperatureColumn(int column)
  12152. {
  12153. measurementColumn= column;
  12154. }
  12155. void ValueAnnotation::setTolerance(double epsilon)
  12156. {
  12157. tolerance= epsilon;
  12158. }
  12159. /*:1050*//*1051:*/
  12160. #line 255 "./valueannotation.w"
  12161. ValueAnnotation::ValueAnnotation():QObject(),
  12162. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  12163. {
  12164. }
  12165. /*:1051*/
  12166. #line 610 "./typica.w"
  12167. /*1039:*/
  12168. #line 33 "./valueannotation.w"
  12169. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  12170. const QModelIndex&index)
  12171. :BasicDeviceConfigurationWidget(model,index),
  12172. tablemodel(new SaltModel(2))
  12173. {
  12174. QFormLayout*layout= new QFormLayout;
  12175. QLineEdit*source= new QLineEdit;
  12176. layout->addRow(tr("Source column name:"),source);
  12177. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12178. noteOnStart->setChecked(true);
  12179. layout->addRow(noteOnStart);
  12180. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12181. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12182. QTableView*annotationTable= new QTableView;
  12183. annotationTable->setModel(tablemodel);
  12184. NumericDelegate*delegate= new NumericDelegate;
  12185. annotationTable->setItemDelegateForColumn(0,delegate);
  12186. layout->addRow(tr("Annotations for values:"),annotationTable);
  12187. /*771:*/
  12188. #line 16347 "./typica.w"
  12189. QDomElement referenceElement=
  12190. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12191. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12192. QDomElement node;
  12193. /*:771*/
  12194. #line 52 "./valueannotation.w"
  12195. for(int i= 0;i<configData.size();i++)
  12196. {
  12197. node= configData.at(i).toElement();
  12198. if(node.attribute("name")=="source")
  12199. {
  12200. source->setText(node.attribute("value"));
  12201. }
  12202. else if(node.attribute("name")=="emitOnStart")
  12203. {
  12204. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12205. }
  12206. else if(node.attribute("name")=="measuredValues")
  12207. {
  12208. /*937:*/
  12209. #line 19435 "./typica.w"
  12210. QString data= node.attribute("value");
  12211. if(data.length()> 3)
  12212. {
  12213. data.chop(2);
  12214. data= data.remove(0,2);
  12215. }
  12216. QStringList itemList= data.split(",");
  12217. /*:937*/
  12218. #line 66 "./valueannotation.w"
  12219. int column= 0;
  12220. /*938:*/
  12221. #line 19447 "./typica.w"
  12222. for(int j= 0;j<itemList.size();j++)
  12223. {
  12224. tablemodel->setData(tablemodel->index(j,column),
  12225. QVariant(itemList.at(j).toDouble()),
  12226. Qt::DisplayRole);
  12227. }
  12228. /*:938*/
  12229. #line 68 "./valueannotation.w"
  12230. }
  12231. else if(node.attribute("name")=="annotations")
  12232. {
  12233. /*1040:*/
  12234. #line 89 "./valueannotation.w"
  12235. QString data= node.attribute("value");
  12236. if(data.length()> 3)
  12237. {
  12238. data.chop(2);
  12239. data= data.remove(0,2);
  12240. }
  12241. QStringList itemList= data.split(",");
  12242. for(int i= 0;i<itemList.size();i++)
  12243. {
  12244. itemList[i]= itemList[i].simplified();
  12245. }
  12246. /*:1040*/
  12247. #line 72 "./valueannotation.w"
  12248. int column= 1;
  12249. /*1041:*/
  12250. #line 104 "./valueannotation.w"
  12251. for(int i= 0;i<itemList.size();i++)
  12252. {
  12253. tablemodel->setData(tablemodel->index(i,column),
  12254. QVariant(itemList.at(i)),
  12255. Qt::DisplayRole);
  12256. }
  12257. /*:1041*/
  12258. #line 74 "./valueannotation.w"
  12259. }
  12260. }
  12261. updateSourceColumn(source->text());
  12262. updateStart(noteOnStart->isChecked());
  12263. updateAnnotations();
  12264. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12265. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12266. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12267. setLayout(layout);
  12268. }
  12269. /*:1039*//*1042:*/
  12270. #line 115 "./valueannotation.w"
  12271. void ValueAnnotationConfWidget::updateAnnotations()
  12272. {
  12273. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12274. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12275. }
  12276. /*:1042*//*1043:*/
  12277. #line 125 "./valueannotation.w"
  12278. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  12279. {
  12280. updateAttribute("source",source);
  12281. }
  12282. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  12283. {
  12284. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  12285. }
  12286. /*:1043*/
  12287. #line 611 "./typica.w"
  12288. /*867:*/
  12289. #line 44 "./modbus.w"
  12290. ModbusNGConfWidget::ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index):
  12291. BasicDeviceConfigurationWidget(model,index),m_parity(new ParitySelector),
  12292. m_flow(new FlowSelector),m_stop(new StopSelector)
  12293. {
  12294. QFormLayout*layout= new QFormLayout;
  12295. PortSelector*port= new PortSelector;
  12296. BaudSelector*baud= new BaudSelector;
  12297. QPushButton*newInput= new QPushButton(tr("Add Input Channel"));
  12298. layout->addRow(QString(tr("Port:")),port);
  12299. layout->addRow(QString(tr("Baud rate:")),baud);
  12300. layout->addRow(QString(tr("Parity:")),m_parity);
  12301. layout->addRow(QString(tr("Flow control:")),m_flow);
  12302. layout->addRow(QString(tr("Stop bits:")),m_stop);
  12303. layout->addRow(newInput);
  12304. /*771:*/
  12305. #line 16347 "./typica.w"
  12306. QDomElement referenceElement=
  12307. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12308. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12309. QDomElement node;
  12310. /*:771*/
  12311. #line 60 "./modbus.w"
  12312. for(int i= 0;i<configData.size();i++)
  12313. {
  12314. node= configData.at(i).toElement();
  12315. if(node.attribute("name")=="port")
  12316. {
  12317. int idx= port->findText(node.attribute("value"));
  12318. if(idx>=0)
  12319. {
  12320. port->setCurrentIndex(idx);
  12321. }
  12322. else
  12323. {
  12324. port->addItem(node.attribute("value"));
  12325. }
  12326. }
  12327. else if(node.attribute("name")=="baud")
  12328. {
  12329. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12330. }
  12331. else if(node.attribute("name")=="parity")
  12332. {
  12333. m_parity->setCurrentIndex(m_parity->findData(node.attribute("value")));
  12334. }
  12335. else if(node.attribute("name")=="flow")
  12336. {
  12337. m_flow->setCurrentIndex(m_flow->findData(node.attribute("value")));
  12338. }
  12339. else if(node.attribute("name")=="stop")
  12340. {
  12341. m_stop->setCurrentIndex(m_stop->findData(node.attribute("value")));
  12342. }
  12343. }
  12344. updatePort(port->currentText());
  12345. updateBaudRate(baud->currentText());
  12346. updateParity(m_parity->currentIndex());
  12347. updateFlowControl(m_flow->currentIndex());
  12348. updateStopBits(m_stop->currentIndex());
  12349. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12350. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  12351. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  12352. connect(m_parity,SIGNAL(currentIndexChanged(int)),this,SLOT(updateParity(int)));
  12353. connect(m_flow,SIGNAL(currentIndexChanged(int)),
  12354. this,SLOT(updateFlowControl(int)));
  12355. connect(m_stop,SIGNAL(currentIndexChanged(int)),this,SLOT(updateStopBits(int)));
  12356. connect(newInput,SIGNAL(clicked()),this,SLOT(addInput()));
  12357. setLayout(layout);
  12358. }
  12359. void ModbusNGConfWidget::updatePort(const QString&value)
  12360. {
  12361. updateAttribute("port",value);
  12362. }
  12363. void ModbusNGConfWidget::updateBaudRate(const QString&value)
  12364. {
  12365. updateAttribute("baud",value);
  12366. }
  12367. void ModbusNGConfWidget::updateParity(int value)
  12368. {
  12369. updateAttribute("parity",m_parity->itemData(value).toString());
  12370. }
  12371. void ModbusNGConfWidget::updateFlowControl(int value)
  12372. {
  12373. updateAttribute("flow",m_flow->itemData(value).toString());
  12374. }
  12375. void ModbusNGConfWidget::updateStopBits(int value)
  12376. {
  12377. updateAttribute("stop",m_stop->itemData(value).toString());
  12378. }
  12379. void ModbusNGConfWidget::addInput()
  12380. {
  12381. insertChildNode(tr("Input"),"modbusnginput");
  12382. }
  12383. /*:867*//*869:*/
  12384. #line 164 "./modbus.w"
  12385. ModbusNGInputConfWidget::ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index):BasicDeviceConfigurationWidget(model,index)
  12386. {
  12387. QFormLayout*layout= new QFormLayout;
  12388. QSpinBox*station= new QSpinBox;
  12389. station->setMinimum(1);
  12390. station->setMaximum(247);
  12391. layout->addRow(tr("Station ID"),station);
  12392. QComboBox*function= new QComboBox;
  12393. function->addItem("3","3");
  12394. function->addItem("4","4");
  12395. function->setCurrentIndex(1);
  12396. layout->addRow(tr("Function"),function);
  12397. ShortHexSpinBox*address= new ShortHexSpinBox;
  12398. layout->addRow(tr("Address"),address);
  12399. QComboBox*format= new QComboBox;
  12400. format->addItem(tr("16 bits fixed point"),"16fixedint");
  12401. format->addItem(tr("32 bits floating point (High Low)"),"32floathl");
  12402. format->addItem(tr("32 bits floating point (Low High)"),"32floatlh");
  12403. layout->addRow(tr("Data format"),format);
  12404. QSpinBox*decimals= new QSpinBox;
  12405. decimals->setMinimum(0);
  12406. decimals->setMaximum(9);
  12407. layout->addRow(tr("Decimal places"),decimals);
  12408. QComboBox*unit= new QComboBox;
  12409. unit->addItem("Celsius","C");
  12410. unit->addItem("Fahrenheit","F");
  12411. unit->setCurrentIndex(1);
  12412. layout->addRow(tr("Unit"),unit);
  12413. QLineEdit*column= new QLineEdit;
  12414. layout->addRow(tr("Column name"),column);
  12415. QCheckBox*hidden= new QCheckBox(tr("Hide this channel"));
  12416. layout->addRow(hidden);
  12417. /*771:*/
  12418. #line 16347 "./typica.w"
  12419. QDomElement referenceElement=
  12420. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12421. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12422. QDomElement node;
  12423. /*:771*/
  12424. #line 198 "./modbus.w"
  12425. for(int i= 0;i<configData.size();i++)
  12426. {
  12427. node= configData.at(i).toElement();
  12428. if(node.attribute("name")=="station")
  12429. {
  12430. station->setValue(node.attribute("value").toInt());
  12431. }
  12432. else if(node.attribute("name")=="function")
  12433. {
  12434. function->setCurrentIndex(function->findText(node.attribute("value")));
  12435. }
  12436. else if(node.attribute("name")=="address")
  12437. {
  12438. address->setValue(node.attribute("value").toInt());
  12439. }
  12440. else if(node.attribute("name")=="format")
  12441. {
  12442. format->setCurrentIndex(format->findData(node.attribute("value")));
  12443. }
  12444. else if(node.attribute("name")=="decimals")
  12445. {
  12446. decimals->setValue(node.attribute("value").toInt());
  12447. }
  12448. else if(node.attribute("name")=="unit")
  12449. {
  12450. unit->setCurrentIndex(unit->findData(node.attribute("value")));
  12451. }
  12452. else if(node.attribute("name")=="column")
  12453. {
  12454. column->setText(node.attribute("value"));
  12455. }
  12456. else if(node.attribute("name")=="hidden")
  12457. {
  12458. hidden->setChecked(node.attribute("value")=="true"?true:false);
  12459. }
  12460. }
  12461. updateStation(station->value());
  12462. updateFunction(function->currentIndex());
  12463. updateAddress(address->value());
  12464. updateFormat(format->currentIndex());
  12465. updateDecimals(decimals->value());
  12466. updateUnit(unit->currentIndex());
  12467. updateColumnName(column->text());
  12468. updateHidden(hidden->isChecked());
  12469. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  12470. connect(function,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFunction(int)));
  12471. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  12472. connect(format,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFormat(int)));
  12473. connect(decimals,SIGNAL(valueChanged(int)),this,SLOT(updateDecimals(int)));
  12474. connect(unit,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  12475. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12476. connect(hidden,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12477. setLayout(layout);
  12478. }
  12479. void ModbusNGInputConfWidget::updateStation(int value)
  12480. {
  12481. updateAttribute("station",QString("%1").arg(value));
  12482. }
  12483. void ModbusNGInputConfWidget::updateFunction(int value)
  12484. {
  12485. updateAttribute("function",QString("%1").arg(value==0?"3":"4"));
  12486. }
  12487. void ModbusNGInputConfWidget::updateAddress(int value)
  12488. {
  12489. updateAttribute("address",QString("%1").arg(value));
  12490. }
  12491. void ModbusNGInputConfWidget::updateFormat(int value)
  12492. {
  12493. switch(value)
  12494. {
  12495. case 0:
  12496. updateAttribute("format","16fixedint");
  12497. break;
  12498. case 1:
  12499. updateAttribute("format","32floathl");
  12500. break;
  12501. case 2:
  12502. updateAttribute("format","32floatlh");
  12503. break;
  12504. }
  12505. }
  12506. void ModbusNGInputConfWidget::updateDecimals(int value)
  12507. {
  12508. updateAttribute("decimals",QString("%1").arg(value));
  12509. }
  12510. void ModbusNGInputConfWidget::updateUnit(int value)
  12511. {
  12512. switch(value)
  12513. {
  12514. case 0:
  12515. updateAttribute("unit","C");
  12516. break;
  12517. case 1:
  12518. updateAttribute("unit","F");
  12519. break;
  12520. }
  12521. }
  12522. void ModbusNGInputConfWidget::updateColumnName(const QString&value)
  12523. {
  12524. updateAttribute("column",value);
  12525. }
  12526. void ModbusNGInputConfWidget::updateHidden(bool value)
  12527. {
  12528. updateAttribute("hidden",value?"true":"false");
  12529. }
  12530. /*:869*//*874:*/
  12531. #line 394 "./modbus.w"
  12532. ModbusNG::ModbusNG(DeviceTreeModel*model,const QModelIndex&index):
  12533. QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),
  12534. scanPosition(0),waiting(false)
  12535. {
  12536. QDomElement portReferenceElement=
  12537. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12538. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  12539. QDomElement node;
  12540. QVariantMap attributes;
  12541. for(int i= 0;i<portConfigData.size();i++)
  12542. {
  12543. node= portConfigData.at(i).toElement();
  12544. attributes.insert(node.attribute("name"),node.attribute("value"));
  12545. }
  12546. port= new QextSerialPort(attributes.value("port").toString(),
  12547. QextSerialPort::EventDriven);
  12548. port->setBaudRate((BaudRateType)(attributes.value("baud").toInt()));
  12549. port->setDataBits(DATA_8);
  12550. port->setParity((ParityType)attributes.value("parity").toInt());
  12551. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  12552. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  12553. delayTime= (int)(((double)(1)/(double)(attributes.value("baud").toInt()))*144000.0);
  12554. messageDelayTimer->setSingleShot(true);
  12555. commTimeout->setSingleShot(true);
  12556. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  12557. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  12558. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  12559. port->open(QIODevice::ReadWrite);
  12560. for(int i= 0;i<model->rowCount(index);i++)
  12561. {
  12562. QModelIndex channelIndex= model->index(i,0,index);
  12563. QDomElement channelReferenceElement=
  12564. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12565. QDomNodeList channelConfigData=
  12566. channelReferenceElement.elementsByTagName("attribute");
  12567. QDomElement channelNode;
  12568. QVariantMap channelAttributes;
  12569. for(int j= 0;j<channelConfigData.size();j++)
  12570. {
  12571. channelNode= channelConfigData.at(j).toElement();
  12572. channelAttributes.insert(channelNode.attribute("name"),
  12573. channelNode.attribute("value"));
  12574. }
  12575. ModbusScanItem scanItem;
  12576. QString format= channelAttributes.value("format").toString();
  12577. if(format=="16fixedint")
  12578. {
  12579. scanItem.format= Int16;
  12580. }
  12581. else if(format=="32floathl")
  12582. {
  12583. scanItem.format= FloatHL;
  12584. }
  12585. else if(format=="32floatlh")
  12586. {
  12587. scanItem.format= FloatLH;
  12588. }
  12589. scanItem.request.append((char)channelAttributes.value("station").toInt());
  12590. scanItem.request.append((char)channelAttributes.value("function").toInt());
  12591. quint16 startAddress= (quint16)channelAttributes.value("address").toInt();
  12592. char*startAddressBytes= (char*)&startAddress;
  12593. scanItem.request.append(startAddressBytes[1]);
  12594. scanItem.request.append(startAddressBytes[0]);
  12595. scanItem.request.append((char)0x00);
  12596. if(scanItem.format==Int16)
  12597. {
  12598. scanItem.request.append((char)0x01);
  12599. }
  12600. else
  12601. {
  12602. scanItem.request.append((char)0x02);
  12603. }
  12604. quint16 crc= calculateCRC(scanItem.request);
  12605. char*crcBytes= (char*)&crc;
  12606. scanItem.request.append(crcBytes[0]);
  12607. scanItem.request.append(crcBytes[1]);
  12608. scanItem.decimalPosition= channelAttributes.value("decimals").toInt();
  12609. if(channelAttributes.value("unit").toString()=="C")
  12610. {
  12611. scanItem.unit= Units::Celsius;
  12612. }
  12613. else
  12614. {
  12615. scanItem.unit= Units::Fahrenheit;
  12616. }
  12617. scanList.append(scanItem);
  12618. channels.append(new Channel);
  12619. channelNames.append(channelAttributes.value("column").toString());
  12620. hiddenStates.append(
  12621. channelAttributes.value("hidden").toString()=="true"?true:false);
  12622. channelLabels.append(model->data(channelIndex,0).toString());
  12623. }
  12624. messageDelayTimer->start();
  12625. }
  12626. ModbusNG::~ModbusNG()
  12627. {
  12628. commTimeout->stop();
  12629. messageDelayTimer->stop();
  12630. port->close();
  12631. }
  12632. void ModbusNG::sendNextMessage()
  12633. {
  12634. if(scanList.length()> 0&&!waiting)
  12635. {
  12636. port->write(scanList.at(scanPosition).request);
  12637. commTimeout->start(2000);
  12638. messageDelayTimer->start(delayTime);
  12639. waiting= true;
  12640. }
  12641. }
  12642. void ModbusNG::timeout()
  12643. {
  12644. qDebug()<<"Communications timeout.";
  12645. messageDelayTimer->start();
  12646. }
  12647. void ModbusNG::dataAvailable()
  12648. {
  12649. if(messageDelayTimer->isActive())
  12650. {
  12651. messageDelayTimer->stop();
  12652. }
  12653. responseBuffer.append(port->readAll());
  12654. if(responseBuffer.size()<5)
  12655. {
  12656. return;
  12657. }
  12658. if(responseBuffer.size()<5+responseBuffer.at(2))
  12659. {
  12660. return;
  12661. }
  12662. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  12663. commTimeout->stop();
  12664. if(calculateCRC(responseBuffer)==0)
  12665. {
  12666. quint16 intresponse;
  12667. float floatresponse;
  12668. char*ibytes= (char*)&intresponse;
  12669. char*fbytes= (char*)&floatresponse;
  12670. double output;
  12671. switch(scanList.at(scanPosition).format)
  12672. {
  12673. case Int16:
  12674. ibytes[0]= responseBuffer.at(4);
  12675. ibytes[1]= responseBuffer.at(3);
  12676. output= intresponse;
  12677. for(int i= 0;i<scanList.at(scanPosition).decimalPosition;i++)
  12678. {
  12679. output/= 10;
  12680. }
  12681. break;
  12682. case FloatHL:
  12683. fbytes[0]= responseBuffer.at(4);
  12684. fbytes[1]= responseBuffer.at(3);
  12685. fbytes[2]= responseBuffer.at(6);
  12686. fbytes[3]= responseBuffer.at(5);
  12687. output= floatresponse;
  12688. break;
  12689. case FloatLH:
  12690. fbytes[0]= responseBuffer.at(6);
  12691. fbytes[1]= responseBuffer.at(5);
  12692. fbytes[2]= responseBuffer.at(4);
  12693. fbytes[3]= responseBuffer.at(3);
  12694. output= floatresponse;
  12695. break;
  12696. }
  12697. if(scanList.at(scanPosition).unit==Units::Celsius)
  12698. {
  12699. output= output*9.0/5.0+32.0;
  12700. }
  12701. scanList.at(scanPosition).lastValue= output;
  12702. }
  12703. else
  12704. {
  12705. qDebug()<<"CRC failed";
  12706. }
  12707. scanPosition= (scanPosition+1)%scanList.size();
  12708. if(scanPosition==0)
  12709. {
  12710. QTime time= QTime::currentTime();
  12711. for(int i= 0;i<scanList.size();i++)
  12712. {
  12713. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Fahrenheit));
  12714. }
  12715. }
  12716. responseBuffer.clear();
  12717. waiting= false;
  12718. messageDelayTimer->start(delayTime);
  12719. }
  12720. quint16 ModbusNG::calculateCRC(QByteArray data)
  12721. {
  12722. quint16 retval= 0xFFFF;
  12723. int i= 0;
  12724. while(i<data.size())
  12725. {
  12726. retval^= 0x00FF&(quint16)data.at(i);
  12727. for(int j= 0;j<8;j++)
  12728. {
  12729. if(retval&1)
  12730. {
  12731. retval= (retval>>1)^0xA001;
  12732. }
  12733. else
  12734. {
  12735. retval>>= 1;
  12736. }
  12737. }
  12738. i++;
  12739. }
  12740. return retval;
  12741. }
  12742. int ModbusNG::channelCount()
  12743. {
  12744. return channels.size();
  12745. }
  12746. Channel*ModbusNG::getChannel(int channel)
  12747. {
  12748. return channels.at(channel);
  12749. }
  12750. QString ModbusNG::channelColumnName(int channel)
  12751. {
  12752. return channelNames.at(channel);
  12753. }
  12754. QString ModbusNG::channelIndicatorText(int channel)
  12755. {
  12756. return channelLabels.at(channel);
  12757. }
  12758. bool ModbusNG::isChannelHidden(int channel)
  12759. {
  12760. return hiddenStates.at(channel);
  12761. }
  12762. /*:874*/
  12763. #line 612 "./typica.w"
  12764. /*1056:*/
  12765. #line 33 "./thresholdannotation.w"
  12766. ThresholdAnnotationConfWidget::ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  12767. const QModelIndex&index)
  12768. :BasicDeviceConfigurationWidget(model,index)
  12769. {
  12770. QFormLayout*layout= new QFormLayout;
  12771. QLineEdit*source= new QLineEdit;
  12772. layout->addRow(tr("Source column name:"),source);
  12773. QDoubleSpinBox*value= new QDoubleSpinBox;
  12774. value->setMinimum(-9999.99);
  12775. value->setMaximum(9999.99);
  12776. value->setDecimals(2);
  12777. layout->addRow(tr("Threshold value:"),value);
  12778. QComboBox*direction= new QComboBox;
  12779. direction->addItem(tr("Ascending"));
  12780. direction->addItem(tr("Descending"));
  12781. layout->addRow(tr("Direction:"),direction);
  12782. QLineEdit*annotation= new QLineEdit;
  12783. layout->addRow(tr("Annotation:"),annotation);
  12784. /*771:*/
  12785. #line 16347 "./typica.w"
  12786. QDomElement referenceElement=
  12787. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12788. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12789. QDomElement node;
  12790. /*:771*/
  12791. #line 52 "./thresholdannotation.w"
  12792. for(int i= 0;i<configData.size();i++)
  12793. {
  12794. node= configData.at(i).toElement();
  12795. if(node.attribute("name")=="source")
  12796. {
  12797. source->setText(node.attribute("value"));
  12798. }
  12799. else if(node.attribute("name")=="value")
  12800. {
  12801. value->setValue(node.attribute("value").toDouble());
  12802. }
  12803. else if(node.attribute("name")=="direction")
  12804. {
  12805. direction->setCurrentIndex(node.attribute("value").toInt());
  12806. }
  12807. else if(node.attribute("name")=="annotation")
  12808. {
  12809. annotation->setText(node.attribute("value"));
  12810. }
  12811. }
  12812. updateSourceColumn(source->text());
  12813. updateThreshold(value->value());
  12814. updateDirection(direction->currentIndex());
  12815. updateAnnotation(annotation->text());
  12816. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12817. connect(value,SIGNAL(valueChanged(double)),this,SLOT(updateThreshold(double)));
  12818. connect(direction,SIGNAL(currentIndexChanged(int)),this,SLOT(updateDirection(int)));
  12819. connect(annotation,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotation(QString)));
  12820. setLayout(layout);
  12821. }
  12822. /*:1056*//*1057:*/
  12823. #line 86 "./thresholdannotation.w"
  12824. void ThresholdAnnotationConfWidget::updateSourceColumn(const QString&source)
  12825. {
  12826. updateAttribute("source",source);
  12827. }
  12828. void ThresholdAnnotationConfWidget::updateThreshold(double value)
  12829. {
  12830. updateAttribute("value",QString("%1").arg(value));
  12831. }
  12832. void ThresholdAnnotationConfWidget::updateDirection(int direction)
  12833. {
  12834. updateAttribute("direction",QString("%1").arg(direction));
  12835. }
  12836. void ThresholdAnnotationConfWidget::updateAnnotation(const QString&annotation)
  12837. {
  12838. updateAttribute("annotation",annotation);
  12839. }
  12840. /*:1057*/
  12841. #line 613 "./typica.w"
  12842. /*1061:*/
  12843. #line 152 "./thresholdannotation.w"
  12844. Annotator::Annotator(const QString&text):QObject(NULL),note(text)
  12845. {
  12846. t.setInterval(0);
  12847. t.setSingleShot(true);
  12848. connect(&t,SIGNAL(timeout()),this,SLOT(catchTimer()));
  12849. }
  12850. void Annotator::setAnnotation(const QString&annotation)
  12851. {
  12852. note= annotation;
  12853. }
  12854. void Annotator::setTemperatureColumn(int tempcolumn)
  12855. {
  12856. tc= tempcolumn;
  12857. }
  12858. void Annotator::setAnnotationColumn(int annotationcolumn)
  12859. {
  12860. ac= annotationcolumn;
  12861. }
  12862. /*:1061*//*1062:*/
  12863. #line 181 "./thresholdannotation.w"
  12864. void Annotator::catchTimer()
  12865. {
  12866. emit annotation(note,tc,ac);
  12867. }
  12868. void Annotator::annotate()
  12869. {
  12870. t.start();
  12871. }
  12872. /*:1062*/
  12873. #line 614 "./typica.w"
  12874. /*:4*//*250:*/
  12875. #line 5955 "./typica.w"
  12876. /*247:*/
  12877. #line 5918 "./typica.w"
  12878. void ScriptValidator::fixup(QString&input)const
  12879. {
  12880. QScriptEngine*engine= AppInstance->engine;
  12881. engine->pushContext();
  12882. input= engine->evaluate(input).toString();
  12883. engine->popContext();
  12884. }
  12885. /*:247*//*248:*/
  12886. #line 5931 "./typica.w"
  12887. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  12888. {
  12889. if(v)
  12890. {
  12891. if(v->validate(input,pos)==QValidator::Acceptable)
  12892. {
  12893. return QValidator::Acceptable;
  12894. }
  12895. }
  12896. return QValidator::Intermediate;
  12897. }
  12898. /*:248*//*249:*/
  12899. #line 5946 "./typica.w"
  12900. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  12901. :QValidator(parent),v(validator)
  12902. {
  12903. }
  12904. /*:249*/
  12905. #line 5956 "./typica.w"
  12906. /*:250*//*845:*/
  12907. #line 60 "./advancedsettings.w"
  12908. /*843:*/
  12909. #line 26 "./advancedsettings.w"
  12910. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  12911. {
  12912. QSettings settings;
  12913. QFormLayout*layout= new QFormLayout;
  12914. QCheckBox*logDiagnostics= new QCheckBox;
  12915. logDiagnostics->setCheckState(
  12916. settings.value("settings/advanced/logging",false).toBool()?
  12917. Qt::Checked:Qt::Unchecked);
  12918. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  12919. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  12920. setLayout(layout);
  12921. }
  12922. /*:843*//*844:*/
  12923. #line 43 "./advancedsettings.w"
  12924. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  12925. {
  12926. QSettings settings;
  12927. settings.setValue("settings/advanced/logging",enabled);
  12928. if(enabled)
  12929. {
  12930. qInstallMsgHandler(messageFileOutput);
  12931. }
  12932. else
  12933. {
  12934. qInstallMsgHandler(0);
  12935. }
  12936. }
  12937. /*:844*/
  12938. #line 61 "./advancedsettings.w"
  12939. #line 18111 "./typica.w"
  12940. /*:845*//*904:*/
  12941. #line 639 "./unsupportedserial.w"
  12942. /*879:*/
  12943. #line 58 "./unsupportedserial.w"
  12944. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  12945. const QModelIndex&index)
  12946. :BasicDeviceConfigurationWidget(model,index),
  12947. deviceSettingsModel(new SaltModel(2)),
  12948. scriptEditor(new QTextEdit)
  12949. {
  12950. scriptEditor->setTabStopWidth(20);
  12951. QVBoxLayout*dummyLayout= new QVBoxLayout;
  12952. QTabWidget*central= new QTabWidget;
  12953. QWidget*deviceConfigurationWidget= new QWidget;
  12954. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  12955. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12956. deviceConfigurationLayout->addWidget(addChannelButton);
  12957. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12958. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  12959. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  12960. QTableView*deviceSettingsView= new QTableView;
  12961. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  12962. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  12963. deviceSettingsView->setModel(deviceSettingsModel);
  12964. deviceConfigurationLayout->addWidget(deviceSettingsView);
  12965. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  12966. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  12967. central->addTab(scriptEditor,tr("Script"));
  12968. dummyLayout->addWidget(central);
  12969. /*771:*/
  12970. #line 16347 "./typica.w"
  12971. QDomElement referenceElement=
  12972. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12973. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12974. QDomElement node;
  12975. /*:771*/
  12976. #line 86 "./unsupportedserial.w"
  12977. for(int i= 0;i<configData.size();i++)
  12978. {
  12979. node= configData.at(i).toElement();
  12980. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12981. {
  12982. int column= 0;
  12983. if(node.attribute("name")=="values")
  12984. {
  12985. column= 1;
  12986. }
  12987. QString data= node.attribute("value");
  12988. if(data.length()> 3)
  12989. {
  12990. data.chop(2);
  12991. data= data.remove(0,2);
  12992. }
  12993. QStringList keyList= data.split(", ");
  12994. for(int j= 0;j<keyList.size();j++)
  12995. {
  12996. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  12997. QVariant(keyList.at(j)),
  12998. Qt::EditRole);
  12999. }
  13000. }
  13001. else if(node.attribute("name")=="script")
  13002. {
  13003. scriptEditor->setPlainText(node.attribute("value"));
  13004. }
  13005. }
  13006. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13007. this,SLOT(updateConfiguration()));
  13008. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  13009. setLayout(dummyLayout);
  13010. }
  13011. /*:879*//*880:*/
  13012. #line 131 "./unsupportedserial.w"
  13013. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  13014. {
  13015. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13016. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13017. }
  13018. /*:880*//*881:*/
  13019. #line 144 "./unsupportedserial.w"
  13020. void UnsupportedSerialDeviceConfWidget::saveScript()
  13021. {
  13022. updateAttribute("script",scriptEditor->toPlainText());
  13023. }
  13024. /*:881*//*882:*/
  13025. #line 155 "./unsupportedserial.w"
  13026. void UnsupportedSerialDeviceConfWidget::addChannel()
  13027. {
  13028. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  13029. }
  13030. /*:882*//*884:*/
  13031. #line 183 "./unsupportedserial.w"
  13032. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  13033. const QModelIndex&index)
  13034. :BasicDeviceConfigurationWidget(model,index),
  13035. channelSettingsModel(new SaltModel(2))
  13036. {
  13037. QFormLayout*layout= new QFormLayout;
  13038. QLineEdit*columnName= new QLineEdit;
  13039. layout->addRow(tr("Column Name:"),columnName);
  13040. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13041. layout->addRow(hideSeries);
  13042. QTableView*channelSettings= new QTableView;
  13043. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  13044. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  13045. channelSettings->setModel(channelSettingsModel);
  13046. layout->addRow(channelSettings);
  13047. setLayout(layout);
  13048. /*771:*/
  13049. #line 16347 "./typica.w"
  13050. QDomElement referenceElement=
  13051. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13052. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13053. QDomElement node;
  13054. /*:771*/
  13055. #line 200 "./unsupportedserial.w"
  13056. for(int i= 0;i<configData.size();i++)
  13057. {
  13058. node= configData.at(i).toElement();
  13059. if(node.attribute("name")=="columnname")
  13060. {
  13061. columnName->setText(node.attribute("value"));
  13062. }
  13063. else if(node.attribute("name")=="hidden")
  13064. {
  13065. hideSeries->setChecked(node.attribute("value")=="true");
  13066. }
  13067. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13068. {
  13069. int column= 0;
  13070. if(node.attribute("name")=="values")
  13071. {
  13072. column= 1;
  13073. }
  13074. QString data= node.attribute("value");
  13075. if(data.length()> 3)
  13076. {
  13077. data.chop(2);
  13078. data= data.remove(0,2);
  13079. }
  13080. QStringList keyList= data.split(", ");
  13081. for(int j= 0;j<keyList.size();j++)
  13082. {
  13083. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  13084. QVariant(keyList.at(j)),
  13085. Qt::EditRole);
  13086. }
  13087. }
  13088. }
  13089. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13090. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13091. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13092. this,SLOT(updateConfiguration()));
  13093. }
  13094. /*:884*//*885:*/
  13095. #line 244 "./unsupportedserial.w"
  13096. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  13097. {
  13098. updateAttribute("columnname",value);
  13099. }
  13100. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  13101. {
  13102. updateAttribute("hidden",hidden?"true":"false");
  13103. }
  13104. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  13105. {
  13106. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13107. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13108. }
  13109. /*:885*/
  13110. #line 640 "./unsupportedserial.w"
  13111. /*892:*/
  13112. #line 371 "./unsupportedserial.w"
  13113. void JavaScriptDevice::start()
  13114. {
  13115. QScriptValue object= scriptengine->newQObject(this);
  13116. /*893:*/
  13117. #line 390 "./unsupportedserial.w"
  13118. QScriptValue settingsObject= scriptengine->newObject();
  13119. QVariantMap::const_iterator i= deviceSettings.constBegin();
  13120. while(i!=deviceSettings.constEnd())
  13121. {
  13122. settingsObject.setProperty(i.key(),i.value().toString());
  13123. i++;
  13124. }
  13125. object.setProperty("settings",settingsObject);
  13126. /*:893*/
  13127. #line 375 "./unsupportedserial.w"
  13128. /*894:*/
  13129. #line 405 "./unsupportedserial.w"
  13130. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  13131. for(int i= 0;i<channelCount();i++)
  13132. {
  13133. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  13134. QScriptValue channelSettingsObject= scriptengine->newObject();
  13135. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  13136. while(j!=channelSettings.at(i).constEnd())
  13137. {
  13138. channelSettingsObject.setProperty(j.key(),j.value().toString());
  13139. j++;
  13140. }
  13141. channelObject.setProperty("settings",channelSettingsObject);
  13142. channelsArray.setProperty(i,channelObject);
  13143. }
  13144. object.setProperty("channels",channelsArray);
  13145. /*:894*/
  13146. #line 376 "./unsupportedserial.w"
  13147. QScriptContext*context= scriptengine->currentContext();
  13148. QScriptValue oldThis= context->thisObject();
  13149. context->setThisObject(object);
  13150. QScriptValue result= scriptengine->evaluate(deviceScript);
  13151. QScriptEngine*engine= scriptengine;
  13152. /*192:*/
  13153. #line 4449 "./typica.w"
  13154. if(engine->hasUncaughtException())
  13155. {
  13156. int line= engine->uncaughtExceptionLineNumber();
  13157. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  13158. result.toString();
  13159. QString trace;
  13160. foreach(trace,engine->uncaughtExceptionBacktrace())
  13161. {
  13162. qDebug()<<trace;
  13163. }
  13164. }
  13165. /*:192*/
  13166. #line 382 "./unsupportedserial.w"
  13167. context->setThisObject(oldThis);
  13168. }
  13169. /*:892*//*897:*/
  13170. #line 446 "./unsupportedserial.w"
  13171. void JavaScriptDevice::stop()
  13172. {
  13173. emit deviceStopRequested();
  13174. }
  13175. /*:897*//*898:*/
  13176. #line 459 "./unsupportedserial.w"
  13177. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  13178. QScriptEngine*engine):
  13179. QObject(NULL),scriptengine(engine)
  13180. {
  13181. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13182. QDomElement deviceReferenceElement=
  13183. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13184. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13185. QDomElement node;
  13186. QStringList deviceKeys;
  13187. QStringList deviceValues;
  13188. for(int i= 0;i<deviceConfigData.size();i++)
  13189. {
  13190. node= deviceConfigData.at(i).toElement();
  13191. if(node.attribute("name")=="keys")
  13192. {
  13193. QString data= node.attribute("value");
  13194. if(data.length()> 3)
  13195. {
  13196. data.chop(2);
  13197. data= data.remove(0,2);
  13198. }
  13199. deviceKeys= data.split(", ");
  13200. }
  13201. else if(node.attribute("name")=="values")
  13202. {
  13203. QString data= node.attribute("value");
  13204. if(data.length()> 3)
  13205. {
  13206. data.chop(2);
  13207. data= data.remove(0,2);
  13208. }
  13209. deviceValues= data.split(", ");
  13210. }
  13211. else if(node.attribute("name")=="script")
  13212. {
  13213. deviceScript= node.attribute("value");
  13214. }
  13215. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  13216. }
  13217. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  13218. {
  13219. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  13220. }
  13221. if(model->hasChildren(index))
  13222. {
  13223. for(int i= 0;i<model->rowCount(index);i++)
  13224. {
  13225. QModelIndex channelIndex= model->index(i,0,index);
  13226. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13227. channelList.append(new Channel);
  13228. QDomElement channelReferenceElement=
  13229. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13230. QDomNodeList channelConfigData=
  13231. channelReferenceElement.elementsByTagName("attribute");
  13232. QStringList channelKeys;
  13233. QStringList channelValues;
  13234. for(int j= 0;j<channelConfigData.size();j++)
  13235. {
  13236. node= channelConfigData.at(j).toElement();
  13237. if(node.attribute("name")=="keys")
  13238. {
  13239. QString data= node.attribute("value");
  13240. if(data.length()> 3)
  13241. {
  13242. data.chop(2);
  13243. data= data.remove(0,2);
  13244. }
  13245. channelKeys= data.split(", ");
  13246. }
  13247. else if(node.attribute("name")=="values")
  13248. {
  13249. QString data= node.attribute("value");
  13250. if(data.length()> 3)
  13251. {
  13252. data.chop(2);
  13253. data= data.remove(0,2);
  13254. }
  13255. channelValues= data.split(", ");
  13256. }
  13257. else if(node.attribute("name")=="hidden")
  13258. {
  13259. hiddenState.append(node.attribute("value")=="true");
  13260. }
  13261. else if(node.attribute("name")=="columnname")
  13262. {
  13263. columnNames.append(node.attribute("value"));
  13264. }
  13265. }
  13266. QVariantMap cs;
  13267. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  13268. {
  13269. cs.insert(channelKeys[j],channelValues[j]);
  13270. }
  13271. channelSettings.append(cs);
  13272. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13273. channelUnits.append(Units::Fahrenheit);
  13274. }
  13275. }
  13276. }
  13277. /*:898*//*899:*/
  13278. #line 564 "./unsupportedserial.w"
  13279. int JavaScriptDevice::channelCount()
  13280. {
  13281. return channelList.length();
  13282. }
  13283. Channel*JavaScriptDevice::getChannel(int channel)
  13284. {
  13285. return channelList.at(channel);
  13286. }
  13287. bool JavaScriptDevice::isChannelHidden(int channel)
  13288. {
  13289. return hiddenState.at(channel);
  13290. }
  13291. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  13292. {
  13293. return channelUnits.at(channel);
  13294. }
  13295. QString JavaScriptDevice::channelColumnName(int channel)
  13296. {
  13297. if(channel>=0&&channel<columnNames.length())
  13298. {
  13299. return columnNames.at(channel);
  13300. }
  13301. return QString();
  13302. }
  13303. QString JavaScriptDevice::channelIndicatorText(int channel)
  13304. {
  13305. return indicatorTexts.at(channel);
  13306. }
  13307. /*:899*//*900:*/
  13308. #line 601 "./unsupportedserial.w"
  13309. void JavaScriptDevice::setTemperatureColumn(int tcol)
  13310. {
  13311. annotationTemperatureColumn= tcol;
  13312. }
  13313. void JavaScriptDevice::setAnnotationColumn(int ncol)
  13314. {
  13315. annotationNoteColumn= ncol;
  13316. }
  13317. /*:900*/
  13318. #line 641 "./unsupportedserial.w"
  13319. /*:904*//*930:*/
  13320. #line 444 "./phidgets.w"
  13321. /*914:*/
  13322. #line 31 "./phidgets.w"
  13323. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  13324. const QModelIndex&index)
  13325. :BasicDeviceConfigurationWidget(model,index)
  13326. {
  13327. QFormLayout*layout= new QFormLayout;
  13328. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13329. QSpinBox*sampleRate= new QSpinBox;
  13330. sampleRate->setMinimum(40);
  13331. sampleRate->setMaximum(600);
  13332. sampleRate->setSingleStep(40);
  13333. sampleRate->setValue(360);
  13334. /*771:*/
  13335. #line 16347 "./typica.w"
  13336. QDomElement referenceElement=
  13337. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13338. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13339. QDomElement node;
  13340. /*:771*/
  13341. #line 44 "./phidgets.w"
  13342. for(int i= 0;i<configData.size();i++)
  13343. {
  13344. node= configData.at(i).toElement();
  13345. if(node.attribute("name")=="sampleRate")
  13346. {
  13347. sampleRate->setValue(node.attribute("value").toInt());
  13348. }
  13349. }
  13350. updateRate(sampleRate->value());
  13351. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  13352. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13353. layout->addRow(addChannelButton);
  13354. layout->addRow(tr("Sample rate:"),sampleRate);
  13355. setLayout(layout);
  13356. }
  13357. /*:914*//*915:*/
  13358. #line 66 "./phidgets.w"
  13359. void PhidgetsTemperatureSensorConfWidget::addChannel()
  13360. {
  13361. insertChildNode(tr("Channel"),"phidgets1048channel");
  13362. }
  13363. /*:915*//*916:*/
  13364. #line 74 "./phidgets.w"
  13365. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  13366. {
  13367. updateAttribute("sampleRate",QString("%1").arg(ms));
  13368. }
  13369. /*:916*//*918:*/
  13370. #line 103 "./phidgets.w"
  13371. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  13372. DeviceTreeModel*model,const QModelIndex&index)
  13373. :BasicDeviceConfigurationWidget(model,index),
  13374. tcType(new QComboBox)
  13375. {
  13376. QFormLayout*layout= new QFormLayout;
  13377. QLineEdit*columnName= new QLineEdit;
  13378. layout->addRow(tr("Column Name:"),columnName);
  13379. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13380. layout->addRow(hideSeries);
  13381. layout->addRow(tr("Thermocouple Type:"),tcType);
  13382. tcType->addItem("Type K","1");
  13383. tcType->addItem("Type J","2");
  13384. tcType->addItem("Type E","3");
  13385. tcType->addItem("Type T","4");
  13386. QSpinBox*channel= new QSpinBox;
  13387. layout->addRow(tr("Channel:"),channel);
  13388. channel->setMinimum(0);
  13389. channel->setMaximum(3);
  13390. setLayout(layout);
  13391. /*771:*/
  13392. #line 16347 "./typica.w"
  13393. QDomElement referenceElement=
  13394. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13395. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13396. QDomElement node;
  13397. /*:771*/
  13398. #line 124 "./phidgets.w"
  13399. for(int i= 0;i<configData.size();i++)
  13400. {
  13401. node= configData.at(i).toElement();
  13402. if(node.attribute("name")=="columnname")
  13403. {
  13404. columnName->setText(node.attribute("value"));
  13405. }
  13406. else if(node.attribute("name")=="hidden")
  13407. {
  13408. hideSeries->setChecked(node.attribute("value")=="true");
  13409. }
  13410. else if(node.attribute("name")=="tctype")
  13411. {
  13412. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  13413. }
  13414. else if(node.attribute("name")=="channel")
  13415. {
  13416. channel->setValue(node.attribute("value").toInt());
  13417. }
  13418. }
  13419. updateColumnName(columnName->text());
  13420. updateHidden(hideSeries->isChecked());
  13421. updateTC(tcType->currentIndex());
  13422. updateChannel(channel->value());
  13423. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13424. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13425. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  13426. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  13427. }
  13428. /*:918*//*919:*/
  13429. #line 157 "./phidgets.w"
  13430. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  13431. {
  13432. updateAttribute("columnname",value);
  13433. }
  13434. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  13435. {
  13436. updateAttribute("hidden",hidden?"true":"false");
  13437. }
  13438. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  13439. {
  13440. updateAttribute("tctype",tcType->itemData(index).toString());
  13441. }
  13442. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  13443. {
  13444. updateAttribute("channel",QString("%1").arg(channel));
  13445. }
  13446. /*:919*//*923:*/
  13447. #line 246 "./phidgets.w"
  13448. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  13449. :QObject(NULL),driver("phidget21"),device(NULL)
  13450. {
  13451. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13452. QDomElement deviceReferenceElement=
  13453. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13454. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13455. QDomElement node;
  13456. for(int i= 0;i<deviceConfigData.size();i++)
  13457. {
  13458. node= deviceConfigData.at(i).toElement();
  13459. if(node.attribute("name")=="sampleRate")
  13460. {
  13461. sampleTimer.setInterval(node.attribute("value").toInt());
  13462. }
  13463. }
  13464. if(model->hasChildren(index))
  13465. {
  13466. for(int i= 0;i<model->rowCount(index);i++)
  13467. {
  13468. QModelIndex channelIndex= model->index(i,0,index);
  13469. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13470. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13471. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  13472. for(int j= 0;j<channelConfigData.size();j++)
  13473. {
  13474. node= channelConfigData.at(j).toElement();
  13475. if(node.attribute("name")=="channel")
  13476. {
  13477. int channelID= node.attribute("value").toInt();
  13478. channelIndices.append(channelID);
  13479. Channel*channel= new Channel;
  13480. channelList.append(channel);
  13481. channelMap.insert(channelID,channel);
  13482. }
  13483. else if(node.attribute("name")=="hidden")
  13484. {
  13485. hiddenState.append(node.attribute("value")=="true");
  13486. }
  13487. else if(node.attribute("name")=="columnname")
  13488. {
  13489. columnNames.append(node.attribute("value"));
  13490. }
  13491. else if(node.attribute("name")=="tctype")
  13492. {
  13493. tctypes.append(node.attribute("value").toInt());
  13494. }
  13495. }
  13496. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13497. }
  13498. }
  13499. }
  13500. /*:923*//*924:*/
  13501. #line 306 "./phidgets.w"
  13502. int PhidgetsTemperatureSensor::channelCount()
  13503. {
  13504. return channelList.length();
  13505. }
  13506. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  13507. {
  13508. return channelList.at(channel);
  13509. }
  13510. /*:924*//*925:*/
  13511. #line 319 "./phidgets.w"
  13512. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  13513. {
  13514. return hiddenState.at(channel);
  13515. }
  13516. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  13517. {
  13518. if(channel>=0&&channel<columnNames.length())
  13519. {
  13520. return columnNames.at(channel);
  13521. }
  13522. return QString();
  13523. }
  13524. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  13525. {
  13526. if(channel>=0&&channel<indicatorTexts.length())
  13527. {
  13528. return indicatorTexts.at(channel);
  13529. }
  13530. return QString();
  13531. }
  13532. /*:925*//*927:*/
  13533. #line 371 "./phidgets.w"
  13534. void PhidgetsTemperatureSensor::start()
  13535. {
  13536. if(!driver.load())
  13537. {
  13538. driver.setFileName("Phidget21.framework/Phidget21");
  13539. if(!driver.load())
  13540. {
  13541. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  13542. tr("Failed to find phidget21. Please install it."));
  13543. return;
  13544. }
  13545. }
  13546. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  13547. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  13548. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  13549. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  13550. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  13551. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  13552. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  13553. {
  13554. QMessageBox::critical(NULL,tr("Typica: Link error"),
  13555. tr("Failed to link a required symbol in phidget21."));
  13556. return;
  13557. }
  13558. createDevice(&device);
  13559. openDevice(device,-1);
  13560. int error;
  13561. if((error= waitForOpen(device,10000)))
  13562. {
  13563. closeDevice(device);
  13564. deleteDevice(device);
  13565. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  13566. tr("CPhidget_waitForAttachment returns error %n",0,error));
  13567. return;
  13568. }
  13569. for(int i= 0;i<channelIndices.length();i++)
  13570. {
  13571. setTCType(device,channelIndices.at(i),tctypes.at(i));
  13572. }
  13573. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  13574. sampleTimer.start();
  13575. }
  13576. /*:927*//*928:*/
  13577. #line 418 "./phidgets.w"
  13578. void PhidgetsTemperatureSensor::getMeasurements()
  13579. {
  13580. double value= 0.0;
  13581. QTime time= QTime::currentTime();
  13582. foreach(int i,channelIndices)
  13583. {
  13584. getTemperature(device,i,&value);
  13585. Measurement measure(value*9.0/5.0+32.0,time);
  13586. channelMap[i]->input(measure);
  13587. }
  13588. }
  13589. /*:928*//*929:*/
  13590. #line 433 "./phidgets.w"
  13591. void PhidgetsTemperatureSensor::stop()
  13592. {
  13593. sampleTimer.stop();
  13594. closeDevice(device);
  13595. deleteDevice(device);
  13596. driver.unload();
  13597. }
  13598. /*:929*/
  13599. #line 445 "./phidgets.w"
  13600. /*:930*//*944:*/
  13601. #line 19543 "./typica.w"
  13602. /*942:*/
  13603. #line 19505 "./typica.w"
  13604. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  13605. const QModelIndex&index)
  13606. :BasicDeviceConfigurationWidget(model,index)
  13607. {
  13608. QHBoxLayout*layout= new QHBoxLayout;
  13609. QLabel*label= new QLabel(tr("Cooling Time: "));
  13610. QTimeEdit*editor= new QTimeEdit;
  13611. editor->setDisplayFormat("mm:ss");
  13612. /*771:*/
  13613. #line 16347 "./typica.w"
  13614. QDomElement referenceElement=
  13615. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13616. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13617. QDomElement node;
  13618. /*:771*/
  13619. #line 19514 "./typica.w"
  13620. for(int i= 0;i<configData.size();i++)
  13621. {
  13622. node= configData.at(i).toElement();
  13623. if(node.attribute("name")=="reset")
  13624. {
  13625. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  13626. }
  13627. }
  13628. updateResetTime(editor->time());
  13629. connect(editor,SIGNAL(timeChanged(QTime)),
  13630. this,SLOT(updateResetTime(QTime)));
  13631. layout->addWidget(label);
  13632. layout->addWidget(editor);
  13633. setLayout(layout);
  13634. }
  13635. void CoolingTimerConfWidget::updateResetTime(QTime time)
  13636. {
  13637. updateAttribute("reset",time.toString("mm:ss"));
  13638. }
  13639. /*:942*/
  13640. #line 19544 "./typica.w"
  13641. /*:944*//*949:*/
  13642. #line 19802 "./typica.w"
  13643. /*946:*/
  13644. #line 19576 "./typica.w"
  13645. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  13646. :BasicDeviceConfigurationWidget(model,index)
  13647. {
  13648. QVBoxLayout*layout= new QVBoxLayout;
  13649. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  13650. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  13651. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  13652. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  13653. QButtonGroup*startOptionGroup= new QButtonGroup;
  13654. startOptionGroup->addButton(startBatchOption,1);
  13655. startOptionGroup->addButton(buttonOption,2);
  13656. startOptionGroup->addButton(thresholdOption,3);
  13657. startBatchOption->setChecked(true);
  13658. QGridLayout*startOptions= new QGridLayout;
  13659. startOptions->addWidget(startBatchOption,0,0);
  13660. startOptions->addWidget(buttonOption,1,0);
  13661. startOptions->addWidget(thresholdOption,2,0);
  13662. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  13663. QLineEdit*buttonTextEdit= new QLineEdit;
  13664. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  13665. buttonTextOptions->addWidget(buttonTextLabel);
  13666. buttonTextOptions->addWidget(buttonTextEdit);
  13667. startOptions->addLayout(buttonTextOptions,1,1);
  13668. QFormLayout*thresholdOptions= new QFormLayout;
  13669. QLineEdit*startColumnName= new QLineEdit;
  13670. QLineEdit*startValue= new QLineEdit;
  13671. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  13672. thresholdOptions->addRow(tr("Value: "),startValue);
  13673. startOptions->addLayout(thresholdOptions,2,1);
  13674. startConfigurationGroup->setLayout(startOptions);
  13675. layout->addWidget(startConfigurationGroup);
  13676. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  13677. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  13678. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  13679. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  13680. QButtonGroup*stopOptionGroup= new QButtonGroup;
  13681. stopOptionGroup->addButton(stopBatchOption,1);
  13682. stopOptionGroup->addButton(stopButtonOption,2);
  13683. stopOptionGroup->addButton(stopThresholdOption,3);
  13684. stopBatchOption->setChecked(true);
  13685. QGridLayout*stopOptions= new QGridLayout;
  13686. stopOptions->addWidget(stopBatchOption,0,0);
  13687. stopOptions->addWidget(stopButtonOption,1,0);
  13688. stopOptions->addWidget(stopThresholdOption,2,0);
  13689. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  13690. QLineEdit*stopButtonEdit= new QLineEdit;
  13691. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  13692. stopButtonTextOptions->addWidget(stopButtonLabel);
  13693. stopButtonTextOptions->addWidget(stopButtonEdit);
  13694. stopOptions->addLayout(stopButtonTextOptions,1,1);
  13695. QLineEdit*stopColumnName= new QLineEdit;
  13696. QLineEdit*stopValue= new QLineEdit;
  13697. QFormLayout*stopThresholdOptions= new QFormLayout;
  13698. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  13699. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  13700. stopOptions->addLayout(stopThresholdOptions,2,1);
  13701. stopConfigurationGroup->setLayout(stopOptions);
  13702. layout->addWidget(stopConfigurationGroup);
  13703. /*771:*/
  13704. #line 16347 "./typica.w"
  13705. QDomElement referenceElement=
  13706. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13707. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13708. QDomElement node;
  13709. /*:771*/
  13710. #line 19638 "./typica.w"
  13711. for(int i= 0;i<configData.size();i++)
  13712. {
  13713. node= configData.at(i).toElement();
  13714. if(node.attribute("name")=="startbuttontext")
  13715. {
  13716. buttonTextEdit->setText(node.attribute("value"));
  13717. }
  13718. else if(node.attribute("name")=="stopbuttontext")
  13719. {
  13720. stopButtonEdit->setText(node.attribute("value"));
  13721. }
  13722. else if(node.attribute("name")=="startcolumnname")
  13723. {
  13724. startColumnName->setText(node.attribute("value"));
  13725. }
  13726. else if(node.attribute("name")=="stopcolumnname")
  13727. {
  13728. stopColumnName->setText(node.attribute("value"));
  13729. }
  13730. else if(node.attribute("name")=="startvalue")
  13731. {
  13732. startValue->setText(node.attribute("value"));
  13733. }
  13734. else if(node.attribute("name")=="stopvalue")
  13735. {
  13736. stopValue->setText(node.attribute("value"));
  13737. }
  13738. else if(node.attribute("name")=="starttrigger")
  13739. {
  13740. if(node.attribute("value")=="batch")
  13741. {
  13742. startBatchOption->setChecked(true);
  13743. }
  13744. else if(node.attribute("value")=="manual")
  13745. {
  13746. buttonOption->setChecked(true);
  13747. }
  13748. else if(node.attribute("value")=="value")
  13749. {
  13750. thresholdOption->setChecked(true);
  13751. }
  13752. }
  13753. else if(node.attribute("name")=="stoptrigger")
  13754. {
  13755. if(node.attribute("value")=="batch")
  13756. {
  13757. stopBatchOption->setChecked(true);
  13758. }
  13759. else if(node.attribute("value")=="manual")
  13760. {
  13761. stopButtonOption->setChecked(true);
  13762. }
  13763. else if(node.attribute("value")=="value")
  13764. {
  13765. stopThresholdOption->setChecked(true);
  13766. }
  13767. }
  13768. }
  13769. updateStartButtonText(buttonTextEdit->text());
  13770. updateStopButtonText(stopButtonEdit->text());
  13771. updateStartColumnName(startColumnName->text());
  13772. updateStopColumnName(stopColumnName->text());
  13773. updateStartValue(startValue->text());
  13774. updateStopValue(stopValue->text());
  13775. updateStartTrigger(startOptionGroup->checkedId());
  13776. updateStopTrigger(stopOptionGroup->checkedId());
  13777. setLayout(layout);
  13778. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  13779. this,SLOT(updateStartButtonText(QString)));
  13780. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  13781. this,SLOT(updateStopButtonText(QString)));
  13782. connect(startColumnName,SIGNAL(textChanged(QString)),
  13783. this,SLOT(updateStartColumnName(QString)));
  13784. connect(stopColumnName,SIGNAL(textChanged(QString)),
  13785. this,SLOT(updateStopColumnName(QString)));
  13786. connect(startValue,SIGNAL(textChanged(QString)),
  13787. this,SLOT(updateStartValue(QString)));
  13788. connect(stopValue,SIGNAL(textChanged(QString)),
  13789. this,SLOT(updateStopValue(QString)));
  13790. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  13791. this,SLOT(updateStartTrigger(int)));
  13792. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  13793. this,SLOT(updateStopTrigger(int)));
  13794. }
  13795. /*:946*//*947:*/
  13796. #line 19728 "./typica.w"
  13797. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  13798. {
  13799. updateAttribute("startbuttontext",text);
  13800. }
  13801. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  13802. {
  13803. updateAttribute("stopbuttontext",text);
  13804. }
  13805. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  13806. {
  13807. updateAttribute("startcolumnname",text);
  13808. }
  13809. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  13810. {
  13811. updateAttribute("stopcolumnname",text);
  13812. }
  13813. void RangeTimerConfWidget::updateStartValue(const QString&text)
  13814. {
  13815. updateAttribute("startvalue",text);
  13816. }
  13817. void RangeTimerConfWidget::updateStopValue(const QString&text)
  13818. {
  13819. updateAttribute("stopvalue",text);
  13820. }
  13821. void RangeTimerConfWidget::updateStartTrigger(int option)
  13822. {
  13823. switch(option)
  13824. {
  13825. case 1:
  13826. updateAttribute("starttrigger","batch");
  13827. break;
  13828. case 2:
  13829. updateAttribute("starttrigger","manual");
  13830. break;
  13831. case 3:
  13832. updateAttribute("starttrigger","value");
  13833. break;
  13834. default:
  13835. break;
  13836. }
  13837. }
  13838. void RangeTimerConfWidget::updateStopTrigger(int option)
  13839. {
  13840. switch(option)
  13841. {
  13842. case 1:
  13843. updateAttribute("stoptrigger","batch");
  13844. break;
  13845. case 2:
  13846. updateAttribute("stoptrigger","manual");
  13847. break;
  13848. case 3:
  13849. updateAttribute("stoptrigger","value");
  13850. break;
  13851. default:
  13852. break;
  13853. }
  13854. }
  13855. /*:947*/
  13856. #line 19803 "./typica.w"
  13857. /*:949*//*954:*/
  13858. #line 19903 "./typica.w"
  13859. /*951:*/
  13860. #line 19827 "./typica.w"
  13861. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  13862. const QModelIndex&index)
  13863. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  13864. {
  13865. QFormLayout*layout= new QFormLayout;
  13866. QLineEdit*trigger= new QLineEdit;
  13867. layout->addRow(tr("Trigger column name:"),trigger);
  13868. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  13869. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  13870. QTableView*rangeTable= new QTableView;
  13871. rangeTable->setModel(tablemodel);
  13872. layout->addRow(tr("Range data:"),rangeTable);
  13873. /*771:*/
  13874. #line 16347 "./typica.w"
  13875. QDomElement referenceElement=
  13876. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13877. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13878. QDomElement node;
  13879. /*:771*/
  13880. #line 19840 "./typica.w"
  13881. for(int i= 0;i<configData.size();i++)
  13882. {
  13883. node= configData.at(i).toElement();
  13884. if(node.attribute("name")=="trigger")
  13885. {
  13886. trigger->setText(node.attribute("value"));
  13887. }
  13888. else if(node.attribute("name")=="rangenames")
  13889. {
  13890. QString data= node.attribute("value");
  13891. if(data.length()> 3)
  13892. {
  13893. data.chop(2);
  13894. data= data.remove(0,2);
  13895. }
  13896. QStringList itemList= data.split(", ");
  13897. for(int j= 0;j<itemList.size();j++)
  13898. {
  13899. QString item= itemList.at(j);
  13900. item.chop(1);
  13901. item= item.remove(0,1);
  13902. tablemodel->setData(tablemodel->index(j,0),
  13903. QVariant(item),Qt::DisplayRole);
  13904. }
  13905. }
  13906. else if(node.attribute("name")=="endtemps")
  13907. {
  13908. /*937:*/
  13909. #line 19435 "./typica.w"
  13910. QString data= node.attribute("value");
  13911. if(data.length()> 3)
  13912. {
  13913. data.chop(2);
  13914. data= data.remove(0,2);
  13915. }
  13916. QStringList itemList= data.split(",");
  13917. /*:937*/
  13918. #line 19868 "./typica.w"
  13919. int column= 1;
  13920. /*938:*/
  13921. #line 19447 "./typica.w"
  13922. for(int j= 0;j<itemList.size();j++)
  13923. {
  13924. tablemodel->setData(tablemodel->index(j,column),
  13925. QVariant(itemList.at(j).toDouble()),
  13926. Qt::DisplayRole);
  13927. }
  13928. /*:938*/
  13929. #line 19870 "./typica.w"
  13930. }
  13931. }
  13932. updateColumnName(trigger->text());
  13933. updateRangeData();
  13934. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13935. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  13936. setLayout(layout);
  13937. }
  13938. /*:951*//*952:*/
  13939. #line 19884 "./typica.w"
  13940. void MultiRangeTimerConfWidget::updateRangeData()
  13941. {
  13942. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  13943. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  13944. }
  13945. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  13946. {
  13947. updateAttribute("trigger",text);
  13948. }
  13949. /*:952*/
  13950. #line 19904 "./typica.w"
  13951. /*:954*//*972:*/
  13952. #line 265 "./rate.w"
  13953. /*968:*/
  13954. #line 191 "./rate.w"
  13955. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  13956. :BasicDeviceConfigurationWidget(model,index)
  13957. {
  13958. QFormLayout*layout= new QFormLayout;
  13959. QLineEdit*column= new QLineEdit;
  13960. layout->addRow(tr("Primary series column name:"),column);
  13961. QSpinBox*cacheTime= new QSpinBox;
  13962. cacheTime->setMinimum(0);
  13963. cacheTime->setMaximum(300);
  13964. layout->addRow(tr("Cache time:"),cacheTime);
  13965. QSpinBox*scaleTime= new QSpinBox;
  13966. scaleTime->setMinimum(1);
  13967. scaleTime->setMaximum(300);
  13968. layout->addRow(tr("Scale time:"),scaleTime);
  13969. /*771:*/
  13970. #line 16347 "./typica.w"
  13971. QDomElement referenceElement=
  13972. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13973. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13974. QDomElement node;
  13975. /*:771*/
  13976. #line 206 "./rate.w"
  13977. for(int i= 0;i<configData.size();i++)
  13978. {
  13979. node= configData.at(i).toElement();
  13980. if(node.attribute("name")=="column")
  13981. {
  13982. column->setText(node.attribute("value"));
  13983. }
  13984. else if(node.attribute("name")=="cache")
  13985. {
  13986. cacheTime->setValue(node.attribute("value").toInt());
  13987. }
  13988. else if(node.attribute("name")=="scale")
  13989. {
  13990. scaleTime->setValue(node.attribute("value").toInt());
  13991. }
  13992. }
  13993. updateColumn(column->text());
  13994. updateCacheTime(cacheTime->text());
  13995. updateScaleTime(scaleTime->text());
  13996. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  13997. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  13998. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  13999. setLayout(layout);
  14000. }
  14001. /*:968*//*969:*/
  14002. #line 235 "./rate.w"
  14003. void RateOfChangeConfWidget::updateColumn(const QString&column)
  14004. {
  14005. updateAttribute("column",column);
  14006. }
  14007. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  14008. {
  14009. updateAttribute("cache",seconds);
  14010. }
  14011. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  14012. {
  14013. updateAttribute("scale",seconds);
  14014. }
  14015. /*:969*/
  14016. #line 266 "./rate.w"
  14017. #line 19996 "./typica.w"
  14018. #line 1 "./dataqsdk.w"
  14019. /*:972*/
  14020. #line 529 "./typica.w"
  14021. /*8:*/
  14022. #line 675 "./typica.w"
  14023. template<class TYPE> TYPE getself(QScriptContext*context)
  14024. {
  14025. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  14026. return self;
  14027. }
  14028. template<> QTime getself(QScriptContext*context)
  14029. {
  14030. QTime self= context->thisObject().toVariant().toTime();
  14031. return self;
  14032. }
  14033. template<> QByteArray getself(QScriptContext*context)
  14034. {
  14035. QByteArray self= context->thisObject().toVariant().toByteArray();
  14036. return self;
  14037. }
  14038. template<> SqlQueryConnection*getself(QScriptContext*context)
  14039. {
  14040. SqlQueryConnection*self=
  14041. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  14042. return self;
  14043. }
  14044. template<> QXmlQuery*getself(QScriptContext*context)
  14045. {
  14046. QXmlQuery*self=
  14047. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  14048. return self;
  14049. }
  14050. template<> QXmlStreamWriter*getself(QScriptContext*context)
  14051. {
  14052. QXmlStreamWriter*self=
  14053. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  14054. return self;
  14055. }
  14056. template<> QXmlStreamReader*getself(QScriptContext*context)
  14057. {
  14058. QXmlStreamReader*self=
  14059. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  14060. return self;
  14061. }
  14062. /*:8*//*9:*/
  14063. #line 726 "./typica.w"
  14064. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  14065. {
  14066. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  14067. return argument;
  14068. }
  14069. template<> QString argument(int arg,QScriptContext*context)
  14070. {
  14071. return context->argument(arg).toString();
  14072. }
  14073. template<> QVariant argument(int arg,QScriptContext*context)
  14074. {
  14075. return context->argument(arg).toVariant();
  14076. }
  14077. template<> int argument(int arg,QScriptContext*context)
  14078. {
  14079. return context->argument(arg).toInt32();
  14080. }
  14081. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  14082. {
  14083. return(SqlQueryConnection*)
  14084. qscriptvalue_cast<void*> (context->argument(arg));
  14085. }
  14086. template<> QModelIndex argument(int arg,QScriptContext*context)
  14087. {
  14088. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  14089. }
  14090. template<> double argument(int arg,QScriptContext*context)
  14091. {
  14092. return(double)(context->argument(arg).toNumber());
  14093. }
  14094. template<> Units::Unit argument(int arg,QScriptContext*context)
  14095. {
  14096. return(Units::Unit)(context->argument(arg).toInt32());
  14097. }
  14098. template<> QByteArray argument(int arg,QScriptContext*context)
  14099. {
  14100. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  14101. }
  14102. /*:9*//*13:*/
  14103. #line 818 "./typica.w"
  14104. void setQObjectProperties(QScriptValue,QScriptEngine*)
  14105. {
  14106. }
  14107. /*:13*//*15:*/
  14108. #line 832 "./typica.w"
  14109. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  14110. {
  14111. }
  14112. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  14113. {
  14114. }
  14115. /*:15*//*18:*/
  14116. #line 871 "./typica.w"
  14117. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  14118. {
  14119. QScriptValue object= engine->newQObject(new QWidget);
  14120. setQWidgetProperties(object,engine);
  14121. return object;
  14122. }
  14123. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  14124. {
  14125. setQObjectProperties(value,engine);
  14126. setQPaintDeviceProperties(value,engine);
  14127. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  14128. value.setProperty("activateWindow",
  14129. engine->newFunction(QWidget_activateWindow));
  14130. }
  14131. /*:18*//*19:*/
  14132. #line 893 "./typica.w"
  14133. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  14134. {
  14135. if(context->argumentCount()==1)
  14136. {
  14137. QWidget*self= getself<QWidget*> (context);
  14138. QLayout*layout= argument<QLayout*> (0,context);
  14139. if(layout)
  14140. {
  14141. self->setLayout(layout);
  14142. }
  14143. else
  14144. {
  14145. context->throwError("Incorrect argument type passed to "
  14146. "QWidget::setLayout(). This method requires "
  14147. "a QLayout.");
  14148. }
  14149. }
  14150. else
  14151. {
  14152. context->throwError("Incorrect number of arguments passed to "
  14153. "QWidget::setLayout(). This method takes one "
  14154. "QLayout as an argument.");
  14155. }
  14156. return QScriptValue();
  14157. }
  14158. QScriptValue QWidget_activateWindow(QScriptContext*context,
  14159. QScriptEngine*)
  14160. {
  14161. QWidget*self= getself<QWidget*> (context);
  14162. self->activateWindow();
  14163. return QScriptValue();
  14164. }
  14165. /*:19*//*22:*/
  14166. #line 955 "./typica.w"
  14167. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  14168. {
  14169. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  14170. argument<QString> (0,context),
  14171. argument<QString> (1,context),
  14172. QMessageBox::Ok|QMessageBox::Cancel);
  14173. if(selection==QMessageBox::Ok){
  14174. return QScriptValue(true);
  14175. }
  14176. return QScriptValue(false);
  14177. }
  14178. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  14179. {
  14180. QMessageBox::critical(NULL,argument<QString> (0,context),
  14181. argument<QString> (1,context));
  14182. return QScriptValue();
  14183. }
  14184. /*:22*//*24:*/
  14185. #line 1022 "./typica.w"
  14186. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  14187. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  14188. {
  14189. }
  14190. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  14191. {
  14192. QSettings settings;
  14193. settings.beginGroup(key);
  14194. settings.setValue("pos",pos());
  14195. settings.setValue("size",size());
  14196. settings.endGroup();
  14197. }
  14198. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  14199. {
  14200. QSettings settings;
  14201. settings.beginGroup(key);
  14202. if(settings.contains("size"))
  14203. {
  14204. resize(settings.value("size").toSize());
  14205. }
  14206. if(settings.contains("pos"))
  14207. {
  14208. move(settings.value("pos").toPoint());
  14209. }
  14210. settings.endGroup();
  14211. }
  14212. void ScriptQMainWindow::displayStatus(const QString&message)
  14213. {
  14214. statusBar()->showMessage(message);
  14215. }
  14216. void ScriptQMainWindow::showEvent(QShowEvent*event)
  14217. {
  14218. if(!event->spontaneous())
  14219. {
  14220. /*29:*/
  14221. #line 1134 "./typica.w"
  14222. QSettings settings;
  14223. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  14224. toByteArray());
  14225. /*:29*/
  14226. #line 1062 "./typica.w"
  14227. event->accept();
  14228. }
  14229. else
  14230. {
  14231. event->ignore();
  14232. }
  14233. }
  14234. void ScriptQMainWindow::show()
  14235. {
  14236. QMainWindow::show();
  14237. }
  14238. /*:24*//*25:*/
  14239. #line 1083 "./typica.w"
  14240. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  14241. {
  14242. if(isWindowModified()){
  14243. /*26:*/
  14244. #line 1097 "./typica.w"
  14245. QMessageBox::StandardButton result;
  14246. result= QMessageBox::warning(this,"Typica",closePrompt(),
  14247. QMessageBox::Ok|QMessageBox::Cancel);
  14248. if(result==QMessageBox::Cancel)
  14249. {
  14250. event->ignore();
  14251. return;
  14252. }
  14253. /*:26*/
  14254. #line 1087 "./typica.w"
  14255. }
  14256. emit aboutToClose();
  14257. /*28:*/
  14258. #line 1128 "./typica.w"
  14259. QSettings settings;
  14260. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  14261. /*:28*/
  14262. #line 1090 "./typica.w"
  14263. event->accept();
  14264. }
  14265. /*:25*//*27:*/
  14266. #line 1109 "./typica.w"
  14267. QString ScriptQMainWindow::closePrompt()
  14268. {
  14269. return cprompt;
  14270. }
  14271. void ScriptQMainWindow::setClosePrompt(QString prompt)
  14272. {
  14273. cprompt= prompt;
  14274. }
  14275. /*:27*//*32:*/
  14276. #line 1162 "./typica.w"
  14277. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  14278. {
  14279. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  14280. setQMainWindowProperties(object,engine);
  14281. return object;
  14282. }
  14283. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  14284. {
  14285. setQWidgetProperties(value,engine);
  14286. value.setProperty("setCentralWidget",
  14287. engine->newFunction(QMainWindow_setCentralWidget));
  14288. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  14289. }
  14290. /*:32*//*33:*/
  14291. #line 1184 "./typica.w"
  14292. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  14293. QScriptEngine*)
  14294. {
  14295. if(context->argumentCount()==1)
  14296. {
  14297. QMainWindow*self= getself<QMainWindow*> (context);
  14298. QWidget*widget= argument<QWidget*> (0,context);
  14299. if(widget)
  14300. {
  14301. self->setCentralWidget(widget);
  14302. }
  14303. else
  14304. {
  14305. context->throwError("Incorrect argument type passed to "
  14306. "QMainWindow::setCentralWidget(). This "
  14307. "method requires a QWidget.");
  14308. }
  14309. }
  14310. else
  14311. {
  14312. context->throwError("Incorrect number of arguments passed to "
  14313. "QMainWindow::setCentralWidget(). This method "
  14314. "takes one QWidget as an argument.");
  14315. }
  14316. return QScriptValue();
  14317. }
  14318. /*:33*//*34:*/
  14319. #line 1218 "./typica.w"
  14320. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  14321. {
  14322. QScriptValue object;
  14323. if(context->argumentCount()==0)
  14324. {
  14325. QMainWindow*self= getself<QMainWindow*> (context);
  14326. QMenuBar*bar= self->menuBar();
  14327. object= engine->newQObject(bar);
  14328. setQMenuBarProperties(object,engine);
  14329. }
  14330. else
  14331. {
  14332. context->throwError("Incorrect number of arguments passed to "
  14333. "QMainWindow::menuBar(). This method takes no "
  14334. "arguments.");
  14335. }
  14336. return object;
  14337. }
  14338. /*:34*//*36:*/
  14339. #line 1248 "./typica.w"
  14340. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  14341. {
  14342. setQWidgetProperties(value,engine);
  14343. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  14344. }
  14345. /*:36*//*37:*/
  14346. #line 1263 "./typica.w"
  14347. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  14348. {
  14349. QScriptValue object;
  14350. if(context->argumentCount()==1)
  14351. {
  14352. QMenuBar*self= getself<QMenuBar*> (context);
  14353. QString title= argument<QString> (0,context);
  14354. object= engine->newQObject(self->addMenu(title));
  14355. setQMenuProperties(object,engine);
  14356. }
  14357. else
  14358. {
  14359. context->throwError("Incorrect number of arguments passed to "
  14360. "QMenuBar::addMenu(). This method takes one "
  14361. "string as an argument.");
  14362. }
  14363. return object;
  14364. }
  14365. /*:37*//*39:*/
  14366. #line 1293 "./typica.w"
  14367. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  14368. {
  14369. setQWidgetProperties(value,engine);
  14370. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  14371. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  14372. }
  14373. /*:39*//*40:*/
  14374. #line 1303 "./typica.w"
  14375. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  14376. {
  14377. if(context->argumentCount()==1)
  14378. {
  14379. QMenu*self= getself<QMenu*> (context);
  14380. QAction*action= argument<QAction*> (0,context);
  14381. if(action)
  14382. {
  14383. self->addAction(action);
  14384. }
  14385. else
  14386. {
  14387. context->throwError("Incorrect argument type passed to "
  14388. "QMenu::addAction(). This method requires a "
  14389. "QAction.");
  14390. }
  14391. }
  14392. else
  14393. {
  14394. context->throwError("Incorrect number of arguments passed to "
  14395. "QMenu::addAction(). This method takes one "
  14396. "QAction as an argument.");
  14397. }
  14398. return QScriptValue();
  14399. }
  14400. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  14401. {
  14402. if(context->argumentCount()==0)
  14403. {
  14404. QMenu*self= getself<QMenu*> (context);
  14405. self->addSeparator();
  14406. }
  14407. else
  14408. {
  14409. context->throwError("Incorrect number of arguments passed to "
  14410. "QMenu::addSeparator(). This method takes no "
  14411. "arguments.");
  14412. }
  14413. return QScriptValue();
  14414. }
  14415. /*:40*//*43:*/
  14416. #line 1365 "./typica.w"
  14417. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  14418. {
  14419. QScriptValue object= engine->newQObject(new QFrame);
  14420. setQFrameProperties(object,engine);
  14421. return object;
  14422. }
  14423. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  14424. {
  14425. setQWidgetProperties(value,engine);
  14426. }
  14427. /*:43*//*46:*/
  14428. #line 1399 "./typica.w"
  14429. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  14430. {
  14431. QString text;
  14432. if(context->argumentCount()==1)
  14433. {
  14434. text= argument<QString> (0,context);
  14435. }
  14436. QScriptValue object= engine->newQObject(new QLabel(text));
  14437. setQLabelProperties(object,engine);
  14438. return object;
  14439. }
  14440. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  14441. {
  14442. setQFrameProperties(value,engine);
  14443. }
  14444. /*:46*//*49:*/
  14445. #line 1441 "./typica.w"
  14446. QScriptValue constructQSvgWidget(QScriptContext*,
  14447. QScriptEngine*engine)
  14448. {
  14449. QScriptValue object= engine->newQObject(new QSvgWidget);
  14450. setQSvgWidgetProperties(object,engine);
  14451. return object;
  14452. }
  14453. /*:49*//*50:*/
  14454. #line 1452 "./typica.w"
  14455. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  14456. {
  14457. setQWidgetProperties(value,engine);
  14458. value.setProperty("loadDevice",
  14459. engine->newFunction(QSvgWidget_loadDevice));
  14460. }
  14461. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  14462. {
  14463. if(context->argumentCount()==1)
  14464. {
  14465. QSvgWidget*self= getself<QSvgWidget*> (context);
  14466. QIODevice*device= argument<QIODevice*> (0,context);
  14467. device->reset();
  14468. QByteArray data= device->readAll();
  14469. self->load(data);
  14470. }
  14471. else
  14472. {
  14473. context->throwError("Incorrect number of arguments passed to "
  14474. "QSvgWidget::loadData(). This method takes one "
  14475. "QIODevice as an argument.");
  14476. }
  14477. return QScriptValue();
  14478. }
  14479. /*:50*//*52:*/
  14480. #line 1490 "./typica.w"
  14481. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  14482. QStack<QLayout*> *layoutStack)
  14483. {
  14484. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14485. QSvgWidget*widget= new QSvgWidget;
  14486. layout->addWidget(widget);
  14487. QString id= element.attribute("id");
  14488. if(!id.isEmpty())
  14489. {
  14490. widget->setObjectName(id);
  14491. }
  14492. }
  14493. /*:52*//*55:*/
  14494. #line 1523 "./typica.w"
  14495. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  14496. {
  14497. QScriptValue object= engine->newQObject(new QLineEdit());
  14498. setQLineEditProperties(object,engine);
  14499. return object;
  14500. }
  14501. /*:55*//*56:*/
  14502. #line 1534 "./typica.w"
  14503. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  14504. {
  14505. setQWidgetProperties(value,engine);
  14506. }
  14507. /*:56*//*59:*/
  14508. #line 1570 "./typica.w"
  14509. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  14510. {
  14511. QScriptValue object= engine->newQObject(new QSplitter);
  14512. setQSplitterProperties(object,engine);
  14513. return object;
  14514. }
  14515. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  14516. {
  14517. setQFrameProperties(value,engine);
  14518. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  14519. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  14520. value.setProperty("restoreState",
  14521. engine->newFunction(QSplitter_restoreState));
  14522. value.setProperty("count",engine->newFunction(QSplitter_count));
  14523. }
  14524. /*:59*//*60:*/
  14525. #line 1591 "./typica.w"
  14526. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  14527. {
  14528. if(context->argumentCount()==1)
  14529. {
  14530. QSplitter*self= getself<QSplitter*> (context);
  14531. QWidget*widget= argument<QWidget*> (0,context);
  14532. if(widget)
  14533. {
  14534. self->addWidget(widget);
  14535. }
  14536. else
  14537. {
  14538. context->throwError("Incorrect argument type passed to "
  14539. "QSplitter::addWidget(). This method "
  14540. "requires a QWidget.");
  14541. }
  14542. }
  14543. else
  14544. {
  14545. context->throwError("Incorrect number of arguments passed to "
  14546. "QSplitter::addWidget(). This method takes one "
  14547. "QWidget as an argument.");
  14548. }
  14549. return QScriptValue();
  14550. }
  14551. /*:60*//*61:*/
  14552. #line 1628 "./typica.w"
  14553. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  14554. {
  14555. QSplitter*self= getself<QSplitter*> (context);
  14556. return QScriptValue(self->count());
  14557. }
  14558. /*:61*//*62:*/
  14559. #line 1641 "./typica.w"
  14560. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  14561. {
  14562. if(context->argumentCount()==1)
  14563. {
  14564. QSplitter*self= getself<QSplitter*> (context);
  14565. QString key= argument<QString> (0,context);
  14566. QSettings settings;
  14567. settings.setValue(key,self->saveState());
  14568. }
  14569. else
  14570. {
  14571. context->throwError("Incorrect number of arguments passed to "
  14572. "QSplitter::saveState(). This method takes one "
  14573. "string as an argument.");
  14574. }
  14575. return QScriptValue();
  14576. }
  14577. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  14578. {
  14579. if(context->argumentCount()==1)
  14580. {
  14581. QSplitter*self= getself<QSplitter*> (context);
  14582. QString key= argument<QString> (0,context);
  14583. QSettings settings;
  14584. self->restoreState(settings.value(key).toByteArray());
  14585. }
  14586. else
  14587. {
  14588. context->throwError("Incorrect number of arguments passed to "
  14589. "QSplitter::restoreState(). This method takes "
  14590. "one string as an argument.");
  14591. }
  14592. return QScriptValue();
  14593. }
  14594. /*:62*//*64:*/
  14595. #line 1694 "./typica.w"
  14596. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  14597. {
  14598. setQLayoutItemProperties(value,engine);
  14599. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  14600. }
  14601. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  14602. {
  14603. if(context->argumentCount()==1)
  14604. {
  14605. QLayout*self= getself<QLayout*> (context);
  14606. QWidget*widget= argument<QWidget*> (0,context);
  14607. if(widget)
  14608. {
  14609. self->addWidget(widget);
  14610. }
  14611. else
  14612. {
  14613. context->throwError("Incorrect argument type passed to "
  14614. "QLayout::addWidget(). This method requires "
  14615. "a QWidget.");
  14616. }
  14617. }
  14618. else
  14619. {
  14620. context->throwError("Incorrect number of arguments passed to "
  14621. "QLayout::addWidget(). This method takes one "
  14622. "QWidget as an argument.");
  14623. }
  14624. return QScriptValue();
  14625. }
  14626. /*:64*//*67:*/
  14627. #line 1761 "./typica.w"
  14628. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  14629. {
  14630. QScriptValue object=
  14631. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  14632. setQBoxLayoutProperties(object,engine);
  14633. return object;
  14634. }
  14635. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  14636. {
  14637. setQLayoutProperties(value,engine);
  14638. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  14639. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  14640. }
  14641. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  14642. {
  14643. if(context->argumentCount()> 0&&context->argumentCount()<3)
  14644. {
  14645. QBoxLayout*self= getself<QBoxLayout*> (context);
  14646. QLayout*layout= argument<QLayout*> (0,context);
  14647. int stretch= 0;
  14648. if(context->argumentCount()==2)
  14649. {
  14650. stretch= argument<int> (1,context);
  14651. }
  14652. if(layout)
  14653. {
  14654. self->addLayout(layout,stretch);
  14655. }
  14656. else
  14657. {
  14658. context->throwError("Incorrect argument type passed to "
  14659. "QLayout::addLayout(). This method requires "
  14660. "a QLayout.");
  14661. }
  14662. }
  14663. else
  14664. {
  14665. context->throwError("Incorrect number of arguments passed to "
  14666. "QLayout::addLayout(). This method takes one "
  14667. "QLayout as an argument and optionally one integer.");
  14668. }
  14669. return QScriptValue();
  14670. }
  14671. /*:67*//*68:*/
  14672. #line 1812 "./typica.w"
  14673. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  14674. {
  14675. if(context->argumentCount()> 0&&context->argumentCount()<4)
  14676. {
  14677. QBoxLayout*self= getself<QBoxLayout*> (context);
  14678. QWidget*widget= argument<QWidget*> (0,context);
  14679. int stretch= 0;
  14680. Qt::Alignment alignment= 0;
  14681. if(context->argumentCount()> 1)
  14682. {
  14683. stretch= argument<int> (1,context);
  14684. }
  14685. if(context->argumentCount()> 2)
  14686. {
  14687. alignment= (Qt::Alignment)(argument<int> (2,context));
  14688. }
  14689. if(widget)
  14690. {
  14691. self->addWidget(widget,stretch,alignment);
  14692. }
  14693. else
  14694. {
  14695. context->throwError("Incorrect argument type passed to "
  14696. "QBoxLayout::addWidget(). This method requires "
  14697. "a QWidget.");
  14698. }
  14699. }
  14700. else
  14701. {
  14702. context->throwError("Incorrect number of arguments passed to "
  14703. "QBoxLayout::addWidget(). This method takes one "
  14704. "QWidget and optionally up to two integers as "
  14705. "arguments.");
  14706. }
  14707. return QScriptValue();
  14708. }
  14709. /*:68*//*71:*/
  14710. #line 1876 "./typica.w"
  14711. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  14712. {
  14713. QScriptValue object= engine->newQObject(new QAction(NULL));
  14714. setQActionProperties(object,engine);
  14715. return object;
  14716. }
  14717. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  14718. {
  14719. setQObjectProperties(value,engine);
  14720. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  14721. }
  14722. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  14723. {
  14724. if(context->argumentCount()==1)
  14725. {
  14726. QAction*self= getself<QAction*> (context);
  14727. self->setShortcut(argument<QString> (0,context));
  14728. }
  14729. else
  14730. {
  14731. context->throwError("Incorrect number of arguments passed to "
  14732. "QAction::setShortcut(). This method takes one "
  14733. "string as an argument.");
  14734. }
  14735. return QScriptValue();
  14736. }
  14737. /*:71*//*74:*/
  14738. #line 1934 "./typica.w"
  14739. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  14740. QScriptEngine*engine)
  14741. {
  14742. QScriptValue retval;
  14743. if(context->argumentCount()==3)
  14744. {
  14745. QWidget*widget= argument<QWidget*> (0,context);
  14746. if(widget)
  14747. {
  14748. QString caption= argument<QString> (1,context);
  14749. QString dir= argument<QString> (2,context);
  14750. retval= QScriptValue(engine,
  14751. QFileDialog::getOpenFileName(widget,caption,
  14752. dir,"",0,0));
  14753. setQFileDialogProperties(retval,engine);
  14754. }
  14755. else
  14756. {
  14757. context->throwError("Incorrect argument type passed to "
  14758. "QFileDialog::getOpenFileName(). The first "
  14759. "argument to this method must be a QWidget.");
  14760. }
  14761. }
  14762. else
  14763. {
  14764. context->throwError("Incorrect number of arguments passed to "
  14765. "QFileDialog::getOpenFileName(). This method "
  14766. "takes one QWidget followed by two strings for a "
  14767. "total of three arguments.");
  14768. }
  14769. return retval;
  14770. }
  14771. /*:74*//*75:*/
  14772. #line 1970 "./typica.w"
  14773. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  14774. QScriptEngine*engine)
  14775. {
  14776. QScriptValue retval;
  14777. if(context->argumentCount()==3)
  14778. {
  14779. QWidget*widget= argument<QWidget*> (0,context);
  14780. if(widget)
  14781. {
  14782. QString caption= argument<QString> (1,context);
  14783. QString dir= argument<QString> (2,context);
  14784. retval= QScriptValue(engine,
  14785. QFileDialog::getSaveFileName(widget,caption,
  14786. dir,"",0,0));
  14787. setQFileDialogProperties(retval,engine);
  14788. }
  14789. else
  14790. {
  14791. context->throwError("Incorrect argument type passed to "
  14792. "QFileDialog::getSaveFileName(). The first "
  14793. "argument to this method must be a QWidget.");
  14794. }
  14795. }
  14796. else
  14797. {
  14798. context->throwError("Incorrect number of arguments passed to "
  14799. "QFileDialog::getSaveFileName(). This method "
  14800. "takes one QWidget followed by two strings for a "
  14801. "total of three arguments.");
  14802. }
  14803. return retval;
  14804. }
  14805. /*:75*//*76:*/
  14806. #line 2007 "./typica.w"
  14807. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  14808. {
  14809. setQDialogProperties(value,engine);
  14810. }
  14811. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  14812. {
  14813. setQWidgetProperties(value,engine);
  14814. }
  14815. /*:76*//*79:*/
  14816. #line 2048 "./typica.w"
  14817. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  14818. {
  14819. QScriptValue object=
  14820. engine->newQObject(new QFile(argument<QString> (0,context)));
  14821. setQFileProperties(object,engine);
  14822. return object;
  14823. }
  14824. /*:79*//*80:*/
  14825. #line 2059 "./typica.w"
  14826. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  14827. {
  14828. setQIODeviceProperties(value,engine);
  14829. value.setProperty("remove",engine->newFunction(QFile_remove));
  14830. }
  14831. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  14832. {
  14833. QFile*self= getself<QFile*> (context);
  14834. bool retval= self->remove();
  14835. return QScriptValue(engine,retval);
  14836. }
  14837. /*:80*//*81:*/
  14838. #line 2081 "./typica.w"
  14839. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  14840. {
  14841. setQObjectProperties(value,engine);
  14842. value.setProperty("open",engine->newFunction(QIODevice_open));
  14843. value.setProperty("close",engine->newFunction(QIODevice_close));
  14844. value.setProperty("readToString",
  14845. engine->newFunction(QIODevice_readToString));
  14846. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  14847. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  14848. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  14849. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  14850. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  14851. value.setProperty("read",engine->newFunction(QIODevice_read));
  14852. }
  14853. /*:81*//*82:*/
  14854. #line 2102 "./typica.w"
  14855. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  14856. {
  14857. QIODevice*self= getself<QIODevice*> (context);
  14858. bool retval= false;
  14859. if(context->argumentCount()==1)
  14860. {
  14861. switch(argument<int> (0,context))
  14862. {
  14863. case 1:
  14864. retval= self->open(QIODevice::ReadOnly);
  14865. break;
  14866. case 2:
  14867. retval= self->open(QIODevice::WriteOnly);
  14868. break;
  14869. case 3:
  14870. retval= self->open(QIODevice::ReadWrite);
  14871. break;
  14872. default:
  14873. break;
  14874. }
  14875. }
  14876. else
  14877. {
  14878. retval= self->open(QIODevice::ReadWrite);
  14879. }
  14880. return QScriptValue(retval);
  14881. }
  14882. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  14883. {
  14884. QIODevice*self= getself<QIODevice*> (context);
  14885. self->close();
  14886. return QScriptValue();
  14887. }
  14888. /*:82*//*83:*/
  14889. #line 2142 "./typica.w"
  14890. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  14891. {
  14892. QIODevice*self= getself<QIODevice*> (context);
  14893. self->reset();
  14894. return QScriptValue(QString(self->readAll()));
  14895. }
  14896. /*:83*//*84:*/
  14897. #line 2158 "./typica.w"
  14898. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  14899. {
  14900. QIODevice*self= getself<QIODevice*> (context);
  14901. if(context->argumentCount()==1)
  14902. {
  14903. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  14904. }
  14905. context->throwError("Incorrect number of arguments passed to "
  14906. "QIODevice::putChar()");
  14907. return QScriptValue();
  14908. }
  14909. /*:84*//*85:*/
  14910. #line 2176 "./typica.w"
  14911. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  14912. {
  14913. QIODevice*self= getself<QIODevice*> (context);
  14914. if(context->argumentCount()==1)
  14915. {
  14916. self->write(argument<QString> (0,context).toUtf8());
  14917. }
  14918. else
  14919. {
  14920. context->throwError("Incorrect number of arguments passed to "
  14921. "QIODevice::writeString()");
  14922. }
  14923. return QScriptValue();
  14924. }
  14925. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  14926. {
  14927. QIODevice*self= getself<QIODevice*> (context);
  14928. if(context->argumentCount()==1)
  14929. {
  14930. self->write(argument<QByteArray> (0,context));
  14931. }
  14932. else
  14933. {
  14934. context->throwError("Incorrect number of arguments passed to "
  14935. "QIODevice::writeBytes()");
  14936. }
  14937. return QScriptValue();
  14938. }
  14939. /*:85*//*86:*/
  14940. #line 2210 "./typica.w"
  14941. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  14942. {
  14943. QIODevice*self= getself<QIODevice*> (context);
  14944. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  14945. setQByteArrayProperties(value,engine);
  14946. return value;
  14947. }
  14948. /*:86*//*87:*/
  14949. #line 2221 "./typica.w"
  14950. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  14951. {
  14952. QIODevice*self= getself<QIODevice*> (context);
  14953. QScriptValue value= engine->toScriptValue<QByteArray> (
  14954. self->peek(argument<int> (0,context)));
  14955. setQByteArrayProperties(value,engine);
  14956. return value;
  14957. }
  14958. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  14959. {
  14960. QIODevice*self= getself<QIODevice*> (context);
  14961. QScriptValue value= engine->toScriptValue<QByteArray> (
  14962. self->read(argument<int> (0,context)));
  14963. setQByteArrayProperties(value,engine);
  14964. return value;
  14965. }
  14966. /*:87*//*90:*/
  14967. #line 2266 "./typica.w"
  14968. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  14969. {
  14970. QScriptValue object= engine->newQObject(new QProcess);
  14971. setQProcessProperties(object,engine);
  14972. return object;
  14973. }
  14974. /*:90*//*91:*/
  14975. #line 2277 "./typica.w"
  14976. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  14977. {
  14978. setQIODeviceProperties(value,engine);
  14979. value.setProperty("execute",engine->newFunction(QProcess_execute));
  14980. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  14981. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  14982. value.setProperty("start",engine->newFunction(QProcess_start));
  14983. }
  14984. /*:91*//*92:*/
  14985. #line 2291 "./typica.w"
  14986. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  14987. {
  14988. QProcess*self= getself<QProcess*> (context);
  14989. QString program= argument<QString> (0,context);
  14990. QStringList arguments= QStringList();
  14991. if(context->argumentCount()> 1){
  14992. arguments= argument<QVariant> (1,context).toStringList();
  14993. }
  14994. int retval= self->execute(program,arguments);
  14995. return QScriptValue(retval);
  14996. }
  14997. /*:92*//*93:*/
  14998. #line 2306 "./typica.w"
  14999. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  15000. {
  15001. QProcess*self= getself<QProcess*> (context);
  15002. QString program= argument<QString> (0,context);
  15003. QStringList arguments= QStringList();
  15004. if(context->argumentCount()> 1){
  15005. arguments= argument<QVariant> (1,context).toStringList();
  15006. }
  15007. QString workingDirectory= "";
  15008. if(context->argumentCount()> 2){
  15009. workingDirectory= argument<QString> (2,context);
  15010. }
  15011. bool retval;
  15012. switch(context->argumentCount())
  15013. {
  15014. case 1:
  15015. retval= self->startDetached(program);
  15016. break;
  15017. case 2:
  15018. retval= self->startDetached(program,arguments);
  15019. break;
  15020. case 3:
  15021. retval= self->startDetached(program,arguments,workingDirectory);
  15022. break;
  15023. default:
  15024. retval= false;
  15025. }
  15026. return QScriptValue(retval);
  15027. }
  15028. /*:93*//*94:*/
  15029. #line 2339 "./typica.w"
  15030. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  15031. {
  15032. QProcess*self= getself<QProcess*> (context);
  15033. QString directory= argument<QString> (0,context);
  15034. self->setWorkingDirectory(directory);
  15035. return QScriptValue();
  15036. }
  15037. /*:94*//*95:*/
  15038. #line 2351 "./typica.w"
  15039. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  15040. {
  15041. QProcess*self= getself<QProcess*> (context);
  15042. QString program= argument<QString> (0,context);
  15043. QStringList arguments= QStringList();
  15044. if(context->argumentCount()> 1){
  15045. arguments= argument<QVariant> (1,context).toStringList();
  15046. }
  15047. self->start(program,arguments);
  15048. return QScriptValue();
  15049. }
  15050. /*:95*//*97:*/
  15051. #line 2392 "./typica.w"
  15052. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  15053. {
  15054. QScriptValue object= engine->newVariant(QVariant(bytes));
  15055. setQByteArrayProperties(object,engine);
  15056. return object;
  15057. }
  15058. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  15059. {
  15060. bytes= value.toVariant().toByteArray();
  15061. }
  15062. /*:97*//*99:*/
  15063. #line 2415 "./typica.w"
  15064. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  15065. {
  15066. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  15067. setQByteArrayProperties(object,engine);
  15068. return object;
  15069. }
  15070. /*:99*//*100:*/
  15071. #line 2426 "./typica.w"
  15072. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  15073. {
  15074. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  15075. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  15076. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  15077. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  15078. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  15079. value.setProperty("size",engine->newFunction(QByteArray_size));
  15080. value.setProperty("left",engine->newFunction(QByteArray_left));
  15081. value.setProperty("right",engine->newFunction(QByteArray_right));
  15082. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  15083. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  15084. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  15085. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  15086. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  15087. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  15088. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  15089. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  15090. }
  15091. /*:100*//*101:*/
  15092. #line 2450 "./typica.w"
  15093. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  15094. {
  15095. QByteArray self= getself<QByteArray> (context);
  15096. QByteArray retval;
  15097. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  15098. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  15099. setQByteArrayProperties(value,engine);
  15100. return value;
  15101. }
  15102. /*:101*//*102:*/
  15103. #line 2464 "./typica.w"
  15104. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  15105. {
  15106. QByteArray self= getself<QByteArray> (context);
  15107. return QScriptValue((int)(self.at(argument<int> (0,context))));
  15108. }
  15109. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  15110. {
  15111. QByteArray self= getself<QByteArray> (context);
  15112. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  15113. return QScriptValue();
  15114. }
  15115. /*:102*//*103:*/
  15116. #line 2482 "./typica.w"
  15117. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  15118. {
  15119. QByteArray self= getself<QByteArray> (context);
  15120. QScriptValue value=
  15121. engine->toScriptValue<QByteArray> (
  15122. self.append(argument<QByteArray> (0,context)));
  15123. setQByteArrayProperties(value,engine);
  15124. return value;
  15125. }
  15126. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  15127. {
  15128. QByteArray self= getself<QByteArray> (context);
  15129. QScriptValue value= engine->toScriptValue<QByteArray> (
  15130. self.append(argument<QString> (0,context)));
  15131. setQByteArrayProperties(value,engine);
  15132. return value;
  15133. }
  15134. /*:103*//*104:*/
  15135. #line 2504 "./typica.w"
  15136. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  15137. {
  15138. QByteArray self= getself<QByteArray> (context);
  15139. return QScriptValue(self.size());
  15140. }
  15141. /*:104*//*105:*/
  15142. #line 2514 "./typica.w"
  15143. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  15144. {
  15145. QByteArray self= getself<QByteArray> (context);
  15146. QScriptValue value= engine->toScriptValue<QByteArray> (
  15147. self.left(argument<int> (0,context)));
  15148. setQByteArrayProperties(value,engine);
  15149. return value;
  15150. }
  15151. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  15152. {
  15153. QByteArray self= getself<QByteArray> (context);
  15154. QScriptValue value= engine->toScriptValue<QByteArray> (
  15155. self.right(argument<int> (0,context)));
  15156. setQByteArrayProperties(value,engine);
  15157. return value;
  15158. }
  15159. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  15160. {
  15161. QByteArray self= getself<QByteArray> (context);
  15162. int length= -1;
  15163. if(context->argumentCount()> 1)
  15164. {
  15165. length= argument<int> (1,context);
  15166. }
  15167. QScriptValue value= engine->toScriptValue<QByteArray> (
  15168. self.mid(argument<int> (0,context),length));
  15169. setQByteArrayProperties(value,engine);
  15170. return value;
  15171. }
  15172. /*:105*//*106:*/
  15173. #line 2549 "./typica.w"
  15174. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  15175. {
  15176. QByteArray self= getself<QByteArray> (context);
  15177. self.chop(argument<int> (0,context));
  15178. return QScriptValue();
  15179. }
  15180. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  15181. {
  15182. QByteArray self= getself<QByteArray> (context);
  15183. QScriptValue value= engine->toScriptValue<QByteArray> (
  15184. self.remove(argument<int> (0,context),argument<int> (1,context)));
  15185. setQByteArrayProperties(value,engine);
  15186. return value;
  15187. }
  15188. /*:106*//*107:*/
  15189. #line 2572 "./typica.w"
  15190. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  15191. {
  15192. QByteArray self= getself<QByteArray> (context);
  15193. int value= 0;
  15194. char*bytes= (char*)&value;
  15195. bytes[0]= self[0];
  15196. return QScriptValue(value);
  15197. }
  15198. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  15199. {
  15200. QByteArray self= getself<QByteArray> (context);
  15201. int value= 0;
  15202. char*bytes= (char*)&value;
  15203. bytes[0]= self[0];
  15204. bytes[1]= self[1];
  15205. return QScriptValue(value);
  15206. }
  15207. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  15208. {
  15209. QByteArray self= getself<QByteArray> (context);
  15210. int value= 0;
  15211. char*bytes= (char*)&value;
  15212. bytes[0]= self[0];
  15213. bytes[1]= self[1];
  15214. bytes[2]= self[2];
  15215. bytes[3]= self[3];
  15216. return QScriptValue(value);
  15217. }
  15218. /*:107*//*108:*/
  15219. #line 2608 "./typica.w"
  15220. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  15221. {
  15222. QByteArray self= getself<QByteArray> (context);
  15223. float value= 0.0;
  15224. char*bytes= (char*)&value;
  15225. bytes[0]= self[0];
  15226. bytes[1]= self[1];
  15227. bytes[2]= self[2];
  15228. bytes[3]= self[3];
  15229. return QScriptValue(value);
  15230. }
  15231. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  15232. {
  15233. QByteArray self= getself<QByteArray> (context);
  15234. double value= 0.0;
  15235. char*bytes= (char*)&value;
  15236. bytes[0]= self[0];
  15237. bytes[1]= self[1];
  15238. bytes[2]= self[2];
  15239. bytes[3]= self[3];
  15240. bytes[4]= self[4];
  15241. bytes[5]= self[5];
  15242. bytes[6]= self[6];
  15243. bytes[7]= self[7];
  15244. return QScriptValue(value);
  15245. }
  15246. /*:108*//*111:*/
  15247. #line 2663 "./typica.w"
  15248. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  15249. {
  15250. qint8 value= (qint8)(argument<int> (0,context));
  15251. char*bytes= (char*)&value;
  15252. QByteArray retval;
  15253. retval.resize(1);
  15254. retval[0]= bytes[0];
  15255. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15256. setQByteArrayProperties(v,engine);
  15257. return v;
  15258. }
  15259. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  15260. {
  15261. qint16 value= (qint16)(argument<int> (0,context));
  15262. char*bytes= (char*)&value;
  15263. QByteArray retval;
  15264. retval.resize(2);
  15265. retval[0]= bytes[0];
  15266. retval[1]= bytes[1];
  15267. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15268. setQByteArrayProperties(v,engine);
  15269. return v;
  15270. }
  15271. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  15272. {
  15273. qint32 value= (qint32)(argument<int> (0,context));
  15274. char*bytes= (char*)&value;
  15275. QByteArray retval;
  15276. retval.resize(4);
  15277. retval[0]= bytes[0];
  15278. retval[1]= bytes[1];
  15279. retval[2]= bytes[2];
  15280. retval[3]= bytes[3];
  15281. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15282. setQByteArrayProperties(v,engine);
  15283. return v;
  15284. }
  15285. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  15286. {
  15287. float value= (float)(argument<double> (0,context));
  15288. char*bytes= (char*)&value;
  15289. QByteArray retval;
  15290. retval.resize(4);
  15291. retval[0]= bytes[0];
  15292. retval[1]= bytes[1];
  15293. retval[2]= bytes[2];
  15294. retval[3]= bytes[3];
  15295. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15296. setQByteArrayProperties(v,engine);
  15297. return v;
  15298. }
  15299. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  15300. {
  15301. double value= (double)(argument<double> (0,context));
  15302. char*bytes= (char*)&value;
  15303. QByteArray retval;
  15304. retval.resize(8);
  15305. retval[0]= bytes[0];
  15306. retval[1]= bytes[1];
  15307. retval[2]= bytes[2];
  15308. retval[3]= bytes[3];
  15309. retval[4]= bytes[4];
  15310. retval[5]= bytes[5];
  15311. retval[6]= bytes[6];
  15312. retval[7]= bytes[7];
  15313. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15314. setQByteArrayProperties(v,engine);
  15315. return v;
  15316. }
  15317. /*:111*//*114:*/
  15318. #line 2760 "./typica.w"
  15319. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  15320. {
  15321. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  15322. QScriptValue object= engine->newQObject(new QBuffer(array));
  15323. setQBufferProperties(object,engine);
  15324. return object;
  15325. }
  15326. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  15327. {
  15328. setQIODeviceProperties(value,engine);
  15329. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  15330. }
  15331. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  15332. {
  15333. QBuffer*self= getself<QBuffer*> (context);
  15334. self->setData(argument<QString> (0,context).toAscii());
  15335. return QScriptValue();
  15336. }
  15337. /*:114*//*117:*/
  15338. #line 2809 "./typica.w"
  15339. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  15340. {
  15341. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  15342. setXQueryProperties(object,engine);
  15343. return object;
  15344. }
  15345. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  15346. {
  15347. QXmlQuery*self= getself<QXmlQuery*> (context);
  15348. delete self;
  15349. return QScriptValue();
  15350. }
  15351. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  15352. {
  15353. value.setProperty("bind",engine->newFunction(XQuery_bind));
  15354. value.setProperty("exec",engine->newFunction(XQuery_exec));
  15355. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  15356. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  15357. }
  15358. /*:117*//*118:*/
  15359. #line 2835 "./typica.w"
  15360. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  15361. {
  15362. QXmlQuery*self= getself<QXmlQuery*> (context);
  15363. QIODevice*buffer= argument<QIODevice*> (1,context);
  15364. self->bindVariable(argument<QString> (0,context),buffer);
  15365. return QScriptValue();
  15366. }
  15367. /*:118*//*119:*/
  15368. #line 2846 "./typica.w"
  15369. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  15370. {
  15371. QXmlQuery*self= getself<QXmlQuery*> (context);
  15372. self->setQuery(argument<QString> (0,context));
  15373. return QScriptValue();
  15374. }
  15375. /*:119*//*120:*/
  15376. #line 2856 "./typica.w"
  15377. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  15378. {
  15379. QXmlQuery*self= getself<QXmlQuery*> (context);
  15380. QString result;
  15381. self->evaluateTo(&result);
  15382. return QScriptValue(result);
  15383. }
  15384. /*:120*//*123:*/
  15385. #line 2911 "./typica.w"
  15386. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  15387. {
  15388. QXmlStreamWriter*retval;
  15389. if(context->argumentCount()==1)
  15390. {
  15391. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  15392. }
  15393. else
  15394. {
  15395. retval= new QXmlStreamWriter;
  15396. }
  15397. QScriptValue object= engine->toScriptValue<void*> (retval);
  15398. setXmlWriterProperties(object,engine);
  15399. return object;
  15400. }
  15401. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  15402. {
  15403. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  15404. value.setProperty("writeAttribute",
  15405. engine->newFunction(XmlWriter_writeAttribute));
  15406. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  15407. value.setProperty("writeCharacters",
  15408. engine->newFunction(XmlWriter_writeCharacters));
  15409. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  15410. value.setProperty("writeEmptyElement",
  15411. engine->newFunction(XmlWriter_writeEmptyElement));
  15412. value.setProperty("writeEndDocument",
  15413. engine->newFunction(XmlWriter_writeEndDocument));
  15414. value.setProperty("writeEndElement",
  15415. engine->newFunction(XmlWriter_writeEndElement));
  15416. value.setProperty("writeEntityReference",
  15417. engine->newFunction(XmlWriter_writeEntityReference));
  15418. value.setProperty("writeProcessingInstruction",
  15419. engine->newFunction(XmlWriter_writeProcessingInstruction));
  15420. value.setProperty("writeStartDocument",
  15421. engine->newFunction(XmlWriter_writeStartDocument));
  15422. value.setProperty("writeStartElement",
  15423. engine->newFunction(XmlWriter_writeStartElement));
  15424. value.setProperty("writeTextElement",
  15425. engine->newFunction(XmlWriter_writeTextElement));
  15426. }
  15427. /*:123*//*124:*/
  15428. #line 2958 "./typica.w"
  15429. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  15430. {
  15431. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15432. QIODevice*device= argument<QIODevice*> (0,context);
  15433. self->setDevice(device);
  15434. return QScriptValue();
  15435. }
  15436. /*:124*//*125:*/
  15437. #line 2972 "./typica.w"
  15438. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  15439. QScriptEngine*)
  15440. {
  15441. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15442. self->writeStartDocument(argument<QString> (0,context));
  15443. return QScriptValue();
  15444. }
  15445. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  15446. QScriptEngine*)
  15447. {
  15448. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15449. self->writeEndDocument();
  15450. return QScriptValue();
  15451. }
  15452. /*:125*//*126:*/
  15453. #line 2991 "./typica.w"
  15454. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  15455. {
  15456. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15457. self->writeDTD(argument<QString> (0,context));
  15458. return QScriptValue();
  15459. }
  15460. /*:126*//*127:*/
  15461. #line 3002 "./typica.w"
  15462. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  15463. QScriptEngine*)
  15464. {
  15465. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15466. self->writeStartElement(argument<QString> (0,context));
  15467. return QScriptValue();
  15468. }
  15469. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  15470. {
  15471. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15472. self->writeAttribute(argument<QString> (0,context),
  15473. argument<QString> (1,context));
  15474. return QScriptValue();
  15475. }
  15476. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  15477. {
  15478. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15479. self->writeCharacters(argument<QString> (0,context));
  15480. return QScriptValue();
  15481. }
  15482. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  15483. {
  15484. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15485. self->writeEndElement();
  15486. return QScriptValue();
  15487. }
  15488. /*:127*//*128:*/
  15489. #line 3038 "./typica.w"
  15490. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  15491. QScriptEngine*)
  15492. {
  15493. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15494. self->writeEmptyElement(argument<QString> (0,context));
  15495. return QScriptValue();
  15496. }
  15497. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  15498. QScriptEngine*)
  15499. {
  15500. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15501. self->writeTextElement(argument<QString> (0,context),
  15502. argument<QString> (1,context));
  15503. return QScriptValue();
  15504. }
  15505. /*:128*//*129:*/
  15506. #line 3059 "./typica.w"
  15507. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  15508. {
  15509. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15510. self->writeCDATA(argument<QString> (0,context));
  15511. return QScriptValue();
  15512. }
  15513. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  15514. QScriptEngine*)
  15515. {
  15516. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15517. self->writeEntityReference(argument<QString> (0,context));
  15518. return QScriptValue();
  15519. }
  15520. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  15521. QScriptEngine*)
  15522. {
  15523. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15524. self->writeProcessingInstruction(argument<QString> (0,context),
  15525. argument<QString> (1,context));
  15526. return QScriptValue();
  15527. }
  15528. /*:129*//*132:*/
  15529. #line 3118 "./typica.w"
  15530. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  15531. {
  15532. QXmlStreamReader*retval=
  15533. new QXmlStreamReader(argument<QIODevice*> (0,context));
  15534. QScriptValue object= engine->toScriptValue<void*> (retval);
  15535. setXmlReaderProperties(object,engine);
  15536. return object;
  15537. }
  15538. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  15539. {
  15540. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  15541. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  15542. value.setProperty("hasAttribute",
  15543. engine->newFunction(XmlReader_hasAttribute));
  15544. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  15545. value.setProperty("isStartElement",
  15546. engine->newFunction(XmlReader_isStartElement));
  15547. value.setProperty("name",engine->newFunction(XmlReader_name));
  15548. value.setProperty("readElementText",
  15549. engine->newFunction(XmlReader_readElementText));
  15550. value.setProperty("readNext",
  15551. engine->newFunction(XmlReader_readNext));
  15552. value.setProperty("text",engine->newFunction(XmlReader_text));
  15553. }
  15554. /*:132*//*133:*/
  15555. #line 3148 "./typica.w"
  15556. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  15557. {
  15558. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15559. QString retval=
  15560. self->attributes().value(argument<QString> (0,context)).toString();
  15561. return QScriptValue(retval);
  15562. }
  15563. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  15564. {
  15565. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15566. bool retval=
  15567. self->attributes().hasAttribute(argument<QString> (0,context));
  15568. return QScriptValue(retval);
  15569. }
  15570. /*:133*//*134:*/
  15571. #line 3168 "./typica.w"
  15572. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  15573. {
  15574. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15575. return QScriptValue(self->atEnd());
  15576. }
  15577. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  15578. {
  15579. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15580. return QScriptValue(self->isDTD());
  15581. }
  15582. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  15583. {
  15584. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15585. return QScriptValue(self->isStartElement());
  15586. }
  15587. /*:134*//*135:*/
  15588. #line 3189 "./typica.w"
  15589. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  15590. {
  15591. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15592. self->readNext();
  15593. return QScriptValue();
  15594. }
  15595. /*:135*//*136:*/
  15596. #line 3199 "./typica.w"
  15597. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  15598. {
  15599. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15600. return QScriptValue(self->name().toString());
  15601. }
  15602. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  15603. {
  15604. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15605. return QScriptValue(self->readElementText());
  15606. }
  15607. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  15608. {
  15609. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15610. return QScriptValue(self->text().toString());
  15611. }
  15612. /*:136*//*139:*/
  15613. #line 3241 "./typica.w"
  15614. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  15615. {
  15616. setQObjectProperties(value,engine);
  15617. value.setProperty("value",engine->newFunction(QSettings_value));
  15618. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  15619. }
  15620. /*:139*//*140:*/
  15621. #line 3253 "./typica.w"
  15622. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  15623. {
  15624. QScriptValue object;
  15625. if(context->argumentCount()==1||context->argumentCount()==2)
  15626. {
  15627. QSettings settings;
  15628. QString key= argument<QString> (0,context);
  15629. QVariant value;
  15630. QVariant retval;
  15631. if(context->argumentCount()> 1)
  15632. {
  15633. value= argument<QVariant> (1,context);
  15634. retval= settings.value(key,value);
  15635. }
  15636. else
  15637. {
  15638. retval= settings.value(key);
  15639. }
  15640. object= engine->newVariant(retval);
  15641. }
  15642. else
  15643. {
  15644. context->throwError("Incorrect number of arguments passed to "
  15645. "QSettings::value(). This method takes one "
  15646. "string and one optional variant type.");
  15647. }
  15648. return object;
  15649. }
  15650. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  15651. {
  15652. if(context->argumentCount()==2)
  15653. {
  15654. QSettings settings;
  15655. QString key= argument<QString> (0,context);
  15656. QVariant value= argument<QVariant> (1,context);
  15657. settings.setValue(key,value);
  15658. }
  15659. else
  15660. {
  15661. context->throwError("Incorrect number of arguments passed to "
  15662. "QSettings::setValue(). This method takes one "
  15663. "string and one variant type for a total of two "
  15664. "arguments.");
  15665. }
  15666. return QScriptValue();
  15667. }
  15668. /*:140*//*143:*/
  15669. #line 3322 "./typica.w"
  15670. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  15671. {
  15672. QScriptValue object= engine->newQObject(new QLCDNumber());
  15673. setQLCDNumberProperties(object,engine);
  15674. return object;
  15675. }
  15676. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  15677. {
  15678. setQFrameProperties(value,engine);
  15679. }
  15680. /*:143*//*146:*/
  15681. #line 3380 "./typica.w"
  15682. QScriptValue constructQTime(QScriptContext*context,
  15683. QScriptEngine*engine)
  15684. {
  15685. QScriptValue object;
  15686. if(context->argumentCount()==0||
  15687. (context->argumentCount()>=2&&context->argumentCount()<=4))
  15688. {
  15689. int arg1= 0;
  15690. int arg2= 0;
  15691. int arg3= 0;
  15692. int arg4= 0;
  15693. switch(context->argumentCount())
  15694. {
  15695. case 4:
  15696. arg4= argument<int> (3,context);
  15697. case 3:
  15698. arg3= argument<int> (2,context);
  15699. case 2:
  15700. arg2= argument<int> (1,context);
  15701. arg1= argument<int> (0,context);
  15702. default:
  15703. break;
  15704. }
  15705. if(context->argumentCount())
  15706. {
  15707. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  15708. arg4));
  15709. }
  15710. else
  15711. {
  15712. object= engine->toScriptValue<QTime> (QTime());
  15713. }
  15714. setQTimeProperties(object,engine);
  15715. }
  15716. else
  15717. {
  15718. context->throwError("Incorrect number of arguments passed to "
  15719. "QTime::QTime(). This method takes zero, two, "
  15720. "three, or four integer arguments.");
  15721. }
  15722. return object;
  15723. }
  15724. /*:146*//*147:*/
  15725. #line 3428 "./typica.w"
  15726. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  15727. {
  15728. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  15729. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  15730. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  15731. value.setProperty("hour",engine->newFunction(QTime_hour));
  15732. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  15733. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  15734. value.setProperty("minute",engine->newFunction(QTime_minute));
  15735. value.setProperty("msec",engine->newFunction(QTime_msec));
  15736. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  15737. value.setProperty("restart",engine->newFunction(QTime_restart));
  15738. value.setProperty("second",engine->newFunction(QTime_second));
  15739. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  15740. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  15741. value.setProperty("start",engine->newFunction(QTime_start));
  15742. value.setProperty("toString",engine->newFunction(QTime_toString));
  15743. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  15744. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  15745. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  15746. }
  15747. /*:147*//*148:*/
  15748. #line 3457 "./typica.w"
  15749. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  15750. {
  15751. QTime self= getself<QTime> (context);
  15752. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  15753. (self.second()*1000)+self.msec();
  15754. return QScriptValue(retval);
  15755. }
  15756. /*:148*//*149:*/
  15757. #line 3471 "./typica.w"
  15758. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  15759. {
  15760. QTime time;
  15761. QScriptValue retval;
  15762. if(context->argumentCount()==1)
  15763. {
  15764. QTime self= getself<QTime> (context);
  15765. time= self.addMSecs(argument<int> (0,context));
  15766. retval= engine->toScriptValue<QTime> (time);
  15767. setQTimeProperties(retval,engine);
  15768. }
  15769. else
  15770. {
  15771. context->throwError("Incorrect number of arguments passed to "
  15772. "QTime::addMSecs(). This method takes one "
  15773. "integer as an argument.");
  15774. }
  15775. return retval;
  15776. }
  15777. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  15778. {
  15779. QTime time;
  15780. QScriptValue retval;
  15781. if(context->argumentCount()==1)
  15782. {
  15783. QTime self= getself<QTime> (context);
  15784. time= self.addSecs(argument<int> (0,context));
  15785. retval= engine->toScriptValue<QTime> (time);
  15786. setQTimeProperties(retval,engine);
  15787. }
  15788. else
  15789. {
  15790. context->throwError("Incorrect number of arguments passed to "
  15791. "QTime::addSecs(). This method takes one "
  15792. "integer as an argument.");
  15793. }
  15794. return retval;
  15795. }
  15796. /*:149*//*150:*/
  15797. #line 3514 "./typica.w"
  15798. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  15799. {
  15800. QScriptValue retval;
  15801. if(context->argumentCount()==0)
  15802. {
  15803. QTime self= getself<QTime> (context);
  15804. retval= QScriptValue(engine,self.elapsed());
  15805. }
  15806. else
  15807. {
  15808. context->throwError("Incorrect number of arguments passed to "
  15809. "QTime::elapsed(). This method takes no "
  15810. "arguments.");
  15811. }
  15812. return retval;
  15813. }
  15814. /*:150*//*151:*/
  15815. #line 3535 "./typica.w"
  15816. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  15817. {
  15818. QScriptValue retval;
  15819. if(context->argumentCount()==0)
  15820. {
  15821. QTime self= getself<QTime> (context);
  15822. retval= QScriptValue(engine,self.hour());
  15823. }
  15824. else
  15825. {
  15826. context->throwError("Incorrect number of arguments passed to "
  15827. "QTime::hour(). This method takes no "
  15828. "arguments.");
  15829. }
  15830. return retval;
  15831. }
  15832. /*:151*//*152:*/
  15833. #line 3555 "./typica.w"
  15834. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  15835. {
  15836. QScriptValue retval;
  15837. if(context->argumentCount()==0)
  15838. {
  15839. QTime self= getself<QTime> (context);
  15840. retval= QScriptValue(engine,self.minute());
  15841. }
  15842. else
  15843. {
  15844. context->throwError("Incorrect number of arguments passed to "
  15845. "QTime::minute(). This method takes no "
  15846. "arguments.");
  15847. }
  15848. return retval;
  15849. }
  15850. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  15851. {
  15852. QScriptValue retval;
  15853. if(context->argumentCount()==0)
  15854. {
  15855. QTime self= getself<QTime> (context);
  15856. retval= QScriptValue(engine,self.second());
  15857. }
  15858. else
  15859. {
  15860. context->throwError("Incorrect number of arguments passed to "
  15861. "QTime::second(). This method takes no "
  15862. "arguments.");
  15863. }
  15864. return retval;
  15865. }
  15866. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  15867. {
  15868. QScriptValue retval;
  15869. if(context->argumentCount()==0)
  15870. {
  15871. QTime self= getself<QTime> (context);
  15872. retval= QScriptValue(engine,self.msec());
  15873. }
  15874. else
  15875. {
  15876. context->throwError("Incorrect number of arguments passed to "
  15877. "QTime::msec(). This method takes no "
  15878. "arguments.");
  15879. }
  15880. return retval;
  15881. }
  15882. /*:152*//*153:*/
  15883. #line 3611 "./typica.w"
  15884. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  15885. {
  15886. QScriptValue retval;
  15887. if(context->argumentCount()==0)
  15888. {
  15889. QTime self= getself<QTime> (context);
  15890. retval= QScriptValue(engine,self.isNull());
  15891. }
  15892. else
  15893. {
  15894. context->throwError("Incorrect number of arguments passed to "
  15895. "QTime::isNull(). This method takes no "
  15896. "arguments.");
  15897. }
  15898. return retval;
  15899. }
  15900. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  15901. {
  15902. QScriptValue retval;
  15903. if(context->argumentCount()==0)
  15904. {
  15905. QTime self= getself<QTime> (context);
  15906. retval= QScriptValue(engine,self.isValid());
  15907. }
  15908. else
  15909. {
  15910. context->throwError("Incorrect number of arguments passed to "
  15911. "QTime::isValid(). This method takes no "
  15912. "arguments.");
  15913. }
  15914. return retval;
  15915. }
  15916. /*:153*//*154:*/
  15917. #line 3649 "./typica.w"
  15918. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  15919. {
  15920. QScriptValue retval;
  15921. if(context->argumentCount()==1)
  15922. {
  15923. QTime self= getself<QTime> (context);
  15924. QTime arg= argument<QVariant> (0,context).toTime();
  15925. retval= QScriptValue(engine,self.msecsTo(arg));
  15926. }
  15927. else
  15928. {
  15929. context->throwError("Incorrect number of arguments passed to "
  15930. "QTime::msecsTo(). This method takes one QTime.");
  15931. }
  15932. return retval;
  15933. }
  15934. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  15935. {
  15936. QScriptValue retval;
  15937. if(context->argumentCount()==1)
  15938. {
  15939. QTime self= getself<QTime> (context);
  15940. QTime arg= argument<QVariant> (0,context).toTime();
  15941. retval= QScriptValue(engine,self.secsTo(arg));
  15942. }
  15943. else
  15944. {
  15945. context->throwError("Incorrect number of arguments passed to "
  15946. "QTime::secsTo(). This method takes one QTime.");
  15947. }
  15948. return retval;
  15949. }
  15950. /*:154*//*155:*/
  15951. #line 3688 "./typica.w"
  15952. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  15953. {
  15954. QScriptValue retval;
  15955. if(context->argumentCount()==0)
  15956. {
  15957. QTime self= getself<QTime> (context);
  15958. retval= QScriptValue(engine,self.restart());
  15959. }
  15960. else
  15961. {
  15962. context->throwError("Incorrect number of arguments passed to "
  15963. "QTime::restart(). This method takes no "
  15964. "arguments.");
  15965. }
  15966. return retval;
  15967. }
  15968. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  15969. {
  15970. if(context->argumentCount()==0)
  15971. {
  15972. QTime self= getself<QTime> (context);
  15973. self.start();
  15974. }
  15975. else
  15976. {
  15977. context->throwError("Incorrect number of arguments passed to "
  15978. "QTime::start(). This method takes no arguments.");
  15979. }
  15980. return QScriptValue();
  15981. }
  15982. /*:155*//*156:*/
  15983. #line 3724 "./typica.w"
  15984. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  15985. {
  15986. QScriptValue retval;
  15987. if(context->argumentCount()==3||context->argumentCount()==4)
  15988. {
  15989. QTime self= getself<QTime> (context);
  15990. int arg1= 0;
  15991. int arg2= 0;
  15992. int arg3= 0;
  15993. int arg4= 0;
  15994. switch(context->argumentCount())
  15995. {
  15996. case 4:
  15997. arg4= argument<int> (3,context);
  15998. case 3:
  15999. arg3= argument<int> (2,context);
  16000. arg2= argument<int> (1,context);
  16001. arg1= argument<int> (0,context);
  16002. default:
  16003. break;
  16004. }
  16005. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  16006. }
  16007. else
  16008. {
  16009. context->throwError("Incorrect number of arguments passed to "
  16010. "QTime::setHMS(). This method takes three or "
  16011. "four integer arguments.");
  16012. }
  16013. return retval;
  16014. }
  16015. /*:156*//*157:*/
  16016. #line 3760 "./typica.w"
  16017. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  16018. {
  16019. QScriptValue retval;
  16020. if(context->argumentCount()==1)
  16021. {
  16022. QTime self= getself<QTime> (context);
  16023. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  16024. }
  16025. else
  16026. {
  16027. context->throwError("Incorrect number of arguments passed to "
  16028. "QTime::toString(). This method takes one QString "
  16029. "as an argument.");
  16030. }
  16031. return retval;
  16032. }
  16033. /*:157*//*158:*/
  16034. #line 3781 "./typica.w"
  16035. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  16036. {
  16037. QScriptValue object;
  16038. object= engine->toScriptValue<QTime> (QTime::currentTime());
  16039. setQTimeProperties(object,engine);
  16040. return object;
  16041. }
  16042. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  16043. {
  16044. QScriptValue object;
  16045. if(context->argumentCount()==2)
  16046. {
  16047. QString time= argument<QString> (0,context);
  16048. QString format= argument<QString> (1,context);
  16049. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  16050. setQTimeProperties(object,engine);
  16051. }
  16052. else
  16053. {
  16054. context->throwError("Incorrect number of arguments passed to "
  16055. "QTime::fromString(). This method takes two "
  16056. "string arguments.");
  16057. }
  16058. return object;
  16059. }
  16060. /*:158*//*159:*/
  16061. #line 3812 "./typica.w"
  16062. template<> QTime argument(int arg,QScriptContext*context)
  16063. {
  16064. return qscriptvalue_cast<QTime> (context->argument(arg));
  16065. }
  16066. /*:159*//*161:*/
  16067. #line 3830 "./typica.w"
  16068. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  16069. {
  16070. setQFrameProperties(value,engine);
  16071. }
  16072. /*:161*//*163:*/
  16073. #line 3844 "./typica.w"
  16074. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  16075. {
  16076. setQAbstractScrollAreaProperties(value,engine);
  16077. }
  16078. /*:163*//*165:*/
  16079. #line 3858 "./typica.w"
  16080. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  16081. {
  16082. setQAbstractScrollAreaProperties(value,engine);
  16083. }
  16084. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  16085. {
  16086. setQAbstractItemViewProperties(value,engine);
  16087. }
  16088. /*:165*//*168:*/
  16089. #line 3891 "./typica.w"
  16090. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  16091. {
  16092. QScriptValue object= engine->newQObject(new QPushButton());
  16093. setQPushButtonProperties(object,engine);
  16094. return object;
  16095. }
  16096. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  16097. {
  16098. setQAbstractButtonProperties(value,engine);
  16099. }
  16100. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  16101. {
  16102. setQWidgetProperties(value,engine);
  16103. }
  16104. /*:168*//*175:*/
  16105. #line 4003 "./typica.w"
  16106. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  16107. {
  16108. SqlQueryConnection*obj= new SqlQueryConnection();
  16109. QScriptValue object=
  16110. engine->toScriptValue<void*> (obj);
  16111. setQSqlQueryProperties(object,engine);
  16112. return object;
  16113. }
  16114. /*:175*//*176:*/
  16115. #line 4016 "./typica.w"
  16116. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  16117. {
  16118. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  16119. value.setProperty("bindFileData",
  16120. engine->newFunction(QSqlQuery_bindFileData));
  16121. value.setProperty("bindDeviceData",
  16122. engine->newFunction(QSqlQuery_bindDeviceData));
  16123. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  16124. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  16125. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  16126. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  16127. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  16128. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  16129. }
  16130. /*:176*//*177:*/
  16131. #line 4034 "./typica.w"
  16132. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  16133. {
  16134. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  16135. QScriptValue retval;
  16136. if(context->argumentCount()==1)
  16137. {
  16138. retval= QScriptValue(engine,
  16139. q->exec(argument<QString> (0,context)));
  16140. }
  16141. else
  16142. {
  16143. retval= QScriptValue(engine,q->exec());
  16144. }
  16145. if(q->lastError().isValid())
  16146. {
  16147. qDebug()<<q->lastQuery();
  16148. qDebug()<<q->lastError().text();
  16149. }
  16150. return retval;
  16151. }
  16152. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  16153. {
  16154. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16155. return QScriptValue(query->lastQuery());
  16156. }
  16157. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  16158. {
  16159. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16160. return QScriptValue(engine,query->next());
  16161. }
  16162. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  16163. {
  16164. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16165. return QScriptValue(engine,
  16166. query->value(argument<int> (0,context)).toString());
  16167. }
  16168. /*:177*//*178:*/
  16169. #line 4078 "./typica.w"
  16170. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  16171. {
  16172. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16173. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  16174. }
  16175. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  16176. {
  16177. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16178. query->bindValue(argument<QString> (0,context),
  16179. argument<QVariant> (1,context));
  16180. return QScriptValue();
  16181. }
  16182. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  16183. QScriptEngine*)
  16184. {
  16185. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16186. QString placeholder= argument<QString> (0,context);
  16187. QString filename= argument<QString> (1,context);
  16188. QFile file(filename);
  16189. QByteArray data;
  16190. if(file.open(QIODevice::ReadOnly))
  16191. {
  16192. data= file.readAll();
  16193. file.close();
  16194. }
  16195. query->bindValue(placeholder,data);
  16196. return QScriptValue();
  16197. }
  16198. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  16199. QScriptEngine*)
  16200. {
  16201. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16202. QString placeholder= argument<QString> (0,context);
  16203. QIODevice*device= argument<QIODevice*> (1,context);
  16204. device->reset();
  16205. QByteArray data;
  16206. data= device->readAll();
  16207. query->bindValue(placeholder,data);
  16208. return QScriptValue();
  16209. }
  16210. /*:178*//*179:*/
  16211. #line 4130 "./typica.w"
  16212. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  16213. {
  16214. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  16215. delete query;
  16216. return QScriptValue::UndefinedValue;
  16217. }
  16218. /*:179*//*182:*/
  16219. #line 4177 "./typica.w"
  16220. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  16221. {
  16222. QFileInfo info(argument<QString> (0,context));
  16223. QScriptValue retval(engine,info.baseName());
  16224. return retval;
  16225. }
  16226. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  16227. {
  16228. QFileInfo info(argument<QString> (0,context));
  16229. QDir dir= info.dir();
  16230. QScriptValue retval(engine,dir.path());
  16231. return retval;
  16232. }
  16233. /*:182*//*183:*/
  16234. #line 4196 "./typica.w"
  16235. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  16236. {
  16237. SqlQueryConnection h;
  16238. QSqlQuery*query= h.operator->();
  16239. QString q= "SELECT file FROM files WHERE id = :file";
  16240. query->prepare(q);
  16241. query->bindValue(":file",argument<int> (0,context));
  16242. query->exec();
  16243. query->next();
  16244. QByteArray array= query->value(0).toByteArray();
  16245. QFile file(argument<QString> (1,context));
  16246. file.open(QIODevice::WriteOnly);
  16247. file.write(array);
  16248. file.close();
  16249. return QScriptValue();
  16250. }
  16251. /*:183*//*184:*/
  16252. #line 4217 "./typica.w"
  16253. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  16254. {
  16255. QString source= argument<QString> (0,context);
  16256. source.remove(0,1);
  16257. source.chop(1);
  16258. QStringList elements= source.split(",");
  16259. QString element;
  16260. QScriptValue dest= engine->newArray(elements.size());
  16261. int i= 0;
  16262. foreach(element,elements)
  16263. {
  16264. if(element.startsWith("\"")&&element.endsWith("\""))
  16265. {
  16266. element.chop(1);
  16267. element= element.remove(0,1);
  16268. }
  16269. dest.setProperty(i,QScriptValue(engine,element));
  16270. i++;
  16271. }
  16272. return dest;
  16273. }
  16274. /*:184*//*185:*/
  16275. #line 4243 "./typica.w"
  16276. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  16277. {
  16278. QString font= argument<QString> (0,context);
  16279. QString classname;
  16280. if(context->argumentCount()> 1)
  16281. {
  16282. classname= argument<QString> (1,context);
  16283. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  16284. }
  16285. else
  16286. {
  16287. QApplication::setFont(QFont(font));
  16288. }
  16289. return QScriptValue();
  16290. }
  16291. /*:185*//*186:*/
  16292. #line 4263 "./typica.w"
  16293. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  16294. {
  16295. SqlQueryConnection h;
  16296. QSqlQuery*query= h.operator->();
  16297. QString q= "SELECT file FROM files WHERE id = :file";
  16298. query->prepare(q);
  16299. query->bindValue(":file",argument<int> (0,context));
  16300. query->exec();
  16301. query->next();
  16302. QByteArray array= query->value(0).toByteArray();
  16303. QBuffer buffer(&array);
  16304. buffer.open(QIODevice::ReadOnly);
  16305. QXmlQuery xquery;
  16306. xquery.bindVariable("profile",&buffer);
  16307. QString xq;
  16308. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  16309. xquery.setQuery(xq);
  16310. QString result;
  16311. xquery.evaluateTo(&result);
  16312. return QScriptValue(result);
  16313. }
  16314. /*:186*//*187:*/
  16315. #line 4290 "./typica.w"
  16316. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  16317. {
  16318. QWidget::setTabOrder(argument<QWidget*> (0,context),
  16319. argument<QWidget*> (1,context));
  16320. return QScriptValue();
  16321. }
  16322. /*:187*//*188:*/
  16323. #line 4301 "./typica.w"
  16324. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  16325. {
  16326. return QScriptValue(QCoreApplication::translate(
  16327. "configuration",
  16328. argument<QString> (1,context).toUtf8().data()));
  16329. }
  16330. /*:188*//*195:*/
  16331. #line 4553 "./typica.w"
  16332. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  16333. {
  16334. QString targetID= argument<QString> (0,context);
  16335. QDomNode element;
  16336. QScriptValue object;
  16337. /*197:*/
  16338. #line 4600 "./typica.w"
  16339. QDomNodeList windows=
  16340. AppInstance->configuration()->documentElement().elementsByTagName("window");
  16341. QDomNode nullNode;
  16342. int i= 0;
  16343. element= nullNode;
  16344. while(i<windows.count())
  16345. {
  16346. element= windows.at(i);
  16347. QDomNamedNodeMap attributes= element.attributes();
  16348. if(attributes.contains("id"))
  16349. {
  16350. if(attributes.namedItem("id").toAttr().value()==targetID)
  16351. {
  16352. break;
  16353. }
  16354. }
  16355. element= nullNode;
  16356. i++;
  16357. }
  16358. /*:197*/
  16359. #line 4559 "./typica.w"
  16360. if(!element.isNull())
  16361. {
  16362. /*198:*/
  16363. #line 4632 "./typica.w"
  16364. ScriptQMainWindow*window= new ScriptQMainWindow;
  16365. window->setObjectName(targetID);
  16366. object= engine->newQObject(window);
  16367. setQMainWindowProperties(object,engine);
  16368. QWidget*central= new(QWidget);
  16369. central->setParent(window);
  16370. central->setObjectName("centralWidget");
  16371. window->setCentralWidget(central);
  16372. if(element.hasChildNodes())
  16373. {
  16374. /*199:*/
  16375. #line 4667 "./typica.w"
  16376. QStack<QWidget*> widgetStack;
  16377. QStack<QLayout*> layoutStack;
  16378. QString windowScript;
  16379. widgetStack.push(central);
  16380. QDomNodeList windowChildren= element.childNodes();
  16381. int i= 0;
  16382. while(i<windowChildren.count())
  16383. {
  16384. QDomNode current;
  16385. QDomElement element;
  16386. current= windowChildren.at(i);
  16387. if(current.isElement())
  16388. {
  16389. element= current.toElement();
  16390. if(element.tagName()=="program")
  16391. {
  16392. windowScript.append(element.text());
  16393. }
  16394. else if(element.tagName()=="layout")
  16395. {
  16396. element.setAttribute("trcontext","configuration");
  16397. addLayoutToWidget(element,&widgetStack,&layoutStack);
  16398. }
  16399. else if(element.tagName()=="menu")
  16400. {
  16401. /*200:*/
  16402. #line 4715 "./typica.w"
  16403. QMenuBar*bar= window->menuBar();
  16404. bar->setParent(window);
  16405. bar->setObjectName("menuBar");
  16406. if(element.hasAttribute("name"))
  16407. {
  16408. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  16409. element.attribute("name").toUtf8().data()));
  16410. menu->setParent(bar);
  16411. if(element.hasAttribute("type"))
  16412. {
  16413. if(element.attribute("type")=="reports")
  16414. {
  16415. if(element.hasAttribute("src"))
  16416. {
  16417. /*640:*/
  16418. #line 13852 "./typica.w"
  16419. QSettings settings;
  16420. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  16421. toString()).
  16422. arg(element.attribute("src"));
  16423. QDir::addSearchPath("reports",reportDirectory);
  16424. QDir directory(reportDirectory);
  16425. directory.setFilter(QDir::Files);
  16426. directory.setSorting(QDir::Name);
  16427. QStringList nameFilter;
  16428. nameFilter<<"*.xml";
  16429. directory.setNameFilters(nameFilter);
  16430. QFileInfoList reportFiles= directory.entryInfoList();
  16431. for(int i= 0;i<reportFiles.size();i++)
  16432. {
  16433. QFileInfo reportFile= reportFiles.at(i);
  16434. /*644:*/
  16435. #line 13932 "./typica.w"
  16436. QString path= reportFile.absoluteFilePath();
  16437. QFile file(path);
  16438. if(file.open(QIODevice::ReadOnly))
  16439. {
  16440. QDomDocument document;
  16441. document.setContent(&file,true);
  16442. QDomElement root= document.documentElement();
  16443. QString translationContext= root.attribute("id");
  16444. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  16445. if(!titleNode.isNull())
  16446. {
  16447. QDomElement titleElement= titleNode.toElement();
  16448. QString title= QCoreApplication::translate("configuration",
  16449. titleElement.text().toUtf8().data());
  16450. if(!title.isEmpty())
  16451. {
  16452. QStringList hierarchy= title.split(":->");
  16453. QMenu*insertionPoint= menu;
  16454. /*645:*/
  16455. #line 13961 "./typica.w"
  16456. for(int j= 0;j<hierarchy.size()-1;j++)
  16457. {
  16458. QObjectList menuList= insertionPoint->children();
  16459. bool menuFound= false;
  16460. for(int k= 0;k<menuList.size();k++)
  16461. {
  16462. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  16463. if(currentItem)
  16464. {
  16465. if(currentItem->title()==hierarchy.at(j))
  16466. {
  16467. menuFound= true;
  16468. insertionPoint= currentItem;
  16469. break;
  16470. }
  16471. }
  16472. }
  16473. if(!menuFound)
  16474. {
  16475. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  16476. }
  16477. }
  16478. /*:645*/
  16479. #line 13951 "./typica.w"
  16480. ReportAction*action= new ReportAction(path,hierarchy.last());
  16481. insertionPoint->addAction(action);
  16482. }
  16483. }
  16484. }
  16485. /*:644*/
  16486. #line 13868 "./typica.w"
  16487. }
  16488. /*:640*/
  16489. #line 4730 "./typica.w"
  16490. }
  16491. }
  16492. }
  16493. if(element.hasChildNodes())
  16494. {
  16495. /*201:*/
  16496. #line 4743 "./typica.w"
  16497. QDomNodeList menuItems= element.childNodes();
  16498. int j= 0;
  16499. while(j<menuItems.count())
  16500. {
  16501. QDomNode item= menuItems.at(j);
  16502. if(item.isElement())
  16503. {
  16504. QDomElement itemElement= item.toElement();
  16505. if(itemElement.tagName()=="item")
  16506. {
  16507. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  16508. itemElement.text().toUtf8().data()),menu);
  16509. if(itemElement.hasAttribute("id"))
  16510. {
  16511. itemAction->setObjectName(itemElement.attribute("id"));
  16512. }
  16513. if(itemElement.hasAttribute("shortcut"))
  16514. {
  16515. itemAction->setShortcut(itemElement.attribute("shortcut"));
  16516. }
  16517. menu->addAction(itemAction);
  16518. }
  16519. else if(itemElement.tagName()=="separator")
  16520. {
  16521. menu->addSeparator();
  16522. }
  16523. }
  16524. j++;
  16525. }
  16526. #line 1 "./helpmenu.w"
  16527. /*:201*/
  16528. #line 4736 "./typica.w"
  16529. }
  16530. }
  16531. /*:200*/
  16532. #line 4693 "./typica.w"
  16533. }
  16534. }
  16535. i++;
  16536. }
  16537. QScriptValue oldThis= context->thisObject();
  16538. context->setThisObject(object);
  16539. QScriptValue result= engine->evaluate(windowScript);
  16540. /*192:*/
  16541. #line 4449 "./typica.w"
  16542. if(engine->hasUncaughtException())
  16543. {
  16544. int line= engine->uncaughtExceptionLineNumber();
  16545. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16546. result.toString();
  16547. QString trace;
  16548. foreach(trace,engine->uncaughtExceptionBacktrace())
  16549. {
  16550. qDebug()<<trace;
  16551. }
  16552. }
  16553. /*:192*/
  16554. #line 4701 "./typica.w"
  16555. context->setThisObject(oldThis);
  16556. /*:199*/
  16557. #line 4643 "./typica.w"
  16558. }
  16559. /*202:*/
  16560. #line 9 "./helpmenu.w"
  16561. HelpMenu*helpMenu= new HelpMenu();
  16562. window->menuBar()->addMenu(helpMenu);
  16563. /*:202*/
  16564. #line 4645 "./typica.w"
  16565. window->show();
  16566. /*:198*/
  16567. #line 4562 "./typica.w"
  16568. }
  16569. return object;
  16570. }
  16571. /*:195*//*196:*/
  16572. #line 4573 "./typica.w"
  16573. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  16574. {
  16575. QString targetID= argument<QString> (0,context);
  16576. QFile file(QString("reports:%1").arg(targetID));
  16577. QScriptValue object;
  16578. if(file.open(QIODevice::ReadOnly))
  16579. {
  16580. QDomDocument document;
  16581. document.setContent(&file,true);
  16582. QDomElement element= document.documentElement();
  16583. if(!element.isNull())
  16584. {
  16585. /*198:*/
  16586. #line 4632 "./typica.w"
  16587. ScriptQMainWindow*window= new ScriptQMainWindow;
  16588. window->setObjectName(targetID);
  16589. object= engine->newQObject(window);
  16590. setQMainWindowProperties(object,engine);
  16591. QWidget*central= new(QWidget);
  16592. central->setParent(window);
  16593. central->setObjectName("centralWidget");
  16594. window->setCentralWidget(central);
  16595. if(element.hasChildNodes())
  16596. {
  16597. /*199:*/
  16598. #line 4667 "./typica.w"
  16599. QStack<QWidget*> widgetStack;
  16600. QStack<QLayout*> layoutStack;
  16601. QString windowScript;
  16602. widgetStack.push(central);
  16603. QDomNodeList windowChildren= element.childNodes();
  16604. int i= 0;
  16605. while(i<windowChildren.count())
  16606. {
  16607. QDomNode current;
  16608. QDomElement element;
  16609. current= windowChildren.at(i);
  16610. if(current.isElement())
  16611. {
  16612. element= current.toElement();
  16613. if(element.tagName()=="program")
  16614. {
  16615. windowScript.append(element.text());
  16616. }
  16617. else if(element.tagName()=="layout")
  16618. {
  16619. element.setAttribute("trcontext","configuration");
  16620. addLayoutToWidget(element,&widgetStack,&layoutStack);
  16621. }
  16622. else if(element.tagName()=="menu")
  16623. {
  16624. /*200:*/
  16625. #line 4715 "./typica.w"
  16626. QMenuBar*bar= window->menuBar();
  16627. bar->setParent(window);
  16628. bar->setObjectName("menuBar");
  16629. if(element.hasAttribute("name"))
  16630. {
  16631. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  16632. element.attribute("name").toUtf8().data()));
  16633. menu->setParent(bar);
  16634. if(element.hasAttribute("type"))
  16635. {
  16636. if(element.attribute("type")=="reports")
  16637. {
  16638. if(element.hasAttribute("src"))
  16639. {
  16640. /*640:*/
  16641. #line 13852 "./typica.w"
  16642. QSettings settings;
  16643. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  16644. toString()).
  16645. arg(element.attribute("src"));
  16646. QDir::addSearchPath("reports",reportDirectory);
  16647. QDir directory(reportDirectory);
  16648. directory.setFilter(QDir::Files);
  16649. directory.setSorting(QDir::Name);
  16650. QStringList nameFilter;
  16651. nameFilter<<"*.xml";
  16652. directory.setNameFilters(nameFilter);
  16653. QFileInfoList reportFiles= directory.entryInfoList();
  16654. for(int i= 0;i<reportFiles.size();i++)
  16655. {
  16656. QFileInfo reportFile= reportFiles.at(i);
  16657. /*644:*/
  16658. #line 13932 "./typica.w"
  16659. QString path= reportFile.absoluteFilePath();
  16660. QFile file(path);
  16661. if(file.open(QIODevice::ReadOnly))
  16662. {
  16663. QDomDocument document;
  16664. document.setContent(&file,true);
  16665. QDomElement root= document.documentElement();
  16666. QString translationContext= root.attribute("id");
  16667. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  16668. if(!titleNode.isNull())
  16669. {
  16670. QDomElement titleElement= titleNode.toElement();
  16671. QString title= QCoreApplication::translate("configuration",
  16672. titleElement.text().toUtf8().data());
  16673. if(!title.isEmpty())
  16674. {
  16675. QStringList hierarchy= title.split(":->");
  16676. QMenu*insertionPoint= menu;
  16677. /*645:*/
  16678. #line 13961 "./typica.w"
  16679. for(int j= 0;j<hierarchy.size()-1;j++)
  16680. {
  16681. QObjectList menuList= insertionPoint->children();
  16682. bool menuFound= false;
  16683. for(int k= 0;k<menuList.size();k++)
  16684. {
  16685. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  16686. if(currentItem)
  16687. {
  16688. if(currentItem->title()==hierarchy.at(j))
  16689. {
  16690. menuFound= true;
  16691. insertionPoint= currentItem;
  16692. break;
  16693. }
  16694. }
  16695. }
  16696. if(!menuFound)
  16697. {
  16698. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  16699. }
  16700. }
  16701. /*:645*/
  16702. #line 13951 "./typica.w"
  16703. ReportAction*action= new ReportAction(path,hierarchy.last());
  16704. insertionPoint->addAction(action);
  16705. }
  16706. }
  16707. }
  16708. /*:644*/
  16709. #line 13868 "./typica.w"
  16710. }
  16711. /*:640*/
  16712. #line 4730 "./typica.w"
  16713. }
  16714. }
  16715. }
  16716. if(element.hasChildNodes())
  16717. {
  16718. /*201:*/
  16719. #line 4743 "./typica.w"
  16720. QDomNodeList menuItems= element.childNodes();
  16721. int j= 0;
  16722. while(j<menuItems.count())
  16723. {
  16724. QDomNode item= menuItems.at(j);
  16725. if(item.isElement())
  16726. {
  16727. QDomElement itemElement= item.toElement();
  16728. if(itemElement.tagName()=="item")
  16729. {
  16730. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  16731. itemElement.text().toUtf8().data()),menu);
  16732. if(itemElement.hasAttribute("id"))
  16733. {
  16734. itemAction->setObjectName(itemElement.attribute("id"));
  16735. }
  16736. if(itemElement.hasAttribute("shortcut"))
  16737. {
  16738. itemAction->setShortcut(itemElement.attribute("shortcut"));
  16739. }
  16740. menu->addAction(itemAction);
  16741. }
  16742. else if(itemElement.tagName()=="separator")
  16743. {
  16744. menu->addSeparator();
  16745. }
  16746. }
  16747. j++;
  16748. }
  16749. #line 1 "./helpmenu.w"
  16750. /*:201*/
  16751. #line 4736 "./typica.w"
  16752. }
  16753. }
  16754. /*:200*/
  16755. #line 4693 "./typica.w"
  16756. }
  16757. }
  16758. i++;
  16759. }
  16760. QScriptValue oldThis= context->thisObject();
  16761. context->setThisObject(object);
  16762. QScriptValue result= engine->evaluate(windowScript);
  16763. /*192:*/
  16764. #line 4449 "./typica.w"
  16765. if(engine->hasUncaughtException())
  16766. {
  16767. int line= engine->uncaughtExceptionLineNumber();
  16768. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16769. result.toString();
  16770. QString trace;
  16771. foreach(trace,engine->uncaughtExceptionBacktrace())
  16772. {
  16773. qDebug()<<trace;
  16774. }
  16775. }
  16776. /*:192*/
  16777. #line 4701 "./typica.w"
  16778. context->setThisObject(oldThis);
  16779. /*:199*/
  16780. #line 4643 "./typica.w"
  16781. }
  16782. /*202:*/
  16783. #line 9 "./helpmenu.w"
  16784. HelpMenu*helpMenu= new HelpMenu();
  16785. window->menuBar()->addMenu(helpMenu);
  16786. /*:202*/
  16787. #line 4645 "./typica.w"
  16788. window->show();
  16789. /*:198*/
  16790. #line 4586 "./typica.w"
  16791. }
  16792. file.close();
  16793. }
  16794. return object;
  16795. }
  16796. /*:196*//*214:*/
  16797. #line 4788 "./typica.w"
  16798. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  16799. QStack<QLayout*> *layoutStack)
  16800. {
  16801. if(element.hasAttribute("type"))
  16802. {
  16803. /*215:*/
  16804. #line 4809 "./typica.w"
  16805. QLayout*layout;
  16806. QString layoutType= element.attribute("type");
  16807. if(layoutType=="horizontal")
  16808. {
  16809. layout= new QHBoxLayout;
  16810. layoutStack->push(layout);
  16811. populateBoxLayout(element,widgetStack,layoutStack);
  16812. }
  16813. else if(layoutType=="vertical")
  16814. {
  16815. layout= new QVBoxLayout;
  16816. layoutStack->push(layout);
  16817. populateBoxLayout(element,widgetStack,layoutStack);
  16818. }
  16819. else if(layoutType=="grid")
  16820. {
  16821. layout= new QGridLayout;
  16822. layoutStack->push(layout);
  16823. populateGridLayout(element,widgetStack,layoutStack);
  16824. }
  16825. else if(layoutType=="stack")
  16826. {
  16827. layout= new QStackedLayout;
  16828. layoutStack->push(layout);
  16829. populateStackedLayout(element,widgetStack,layoutStack);
  16830. }
  16831. if(element.hasAttribute("id"))
  16832. {
  16833. layout->setObjectName(element.attribute("id"));
  16834. }
  16835. if(element.hasAttribute("spacing"))
  16836. {
  16837. layout->setSpacing(element.attribute("spacing").toInt());
  16838. }
  16839. if(element.hasAttribute("margin"))
  16840. {
  16841. int m= element.attribute("margin").toInt();
  16842. layout->setContentsMargins(m,m,m,m);
  16843. }
  16844. /*:215*/
  16845. #line 4794 "./typica.w"
  16846. QWidget*widget= widgetStack->top();
  16847. if(layout)
  16848. {
  16849. widget->setLayout(layout);
  16850. }
  16851. layoutStack->pop();
  16852. }
  16853. }
  16854. /*:214*//*216:*/
  16855. #line 4856 "./typica.w"
  16856. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16857. QStack<QLayout*> *layoutStack)
  16858. {
  16859. QDomNodeList children= element.childNodes();
  16860. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  16861. for(int i= 0;i<children.count();i++)
  16862. {
  16863. QDomNode current;
  16864. QDomElement currentElement;
  16865. current= children.at(i);
  16866. if(current.isElement())
  16867. {
  16868. currentElement= current.toElement();
  16869. if(currentElement.tagName()=="page")
  16870. {
  16871. QWidget*widget= new QWidget;
  16872. layout->addWidget(widget);
  16873. widgetStack->push(widget);
  16874. currentElement.setAttribute("trcontext","configuration");
  16875. populateWidget(currentElement,widgetStack,layoutStack);
  16876. widgetStack->pop();
  16877. }
  16878. }
  16879. }
  16880. }
  16881. /*:216*//*217:*/
  16882. #line 4889 "./typica.w"
  16883. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16884. QStack<QLayout*> *layoutStack)
  16885. {
  16886. QDomNodeList children= element.childNodes();
  16887. int row= -1;
  16888. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  16889. for(int i= 0;i<children.count();i++)
  16890. {
  16891. QDomNode current;
  16892. QDomElement currentElement;
  16893. current= children.at(i);
  16894. if(current.isElement())
  16895. {
  16896. currentElement= current.toElement();
  16897. if(currentElement.tagName()=="row")
  16898. {
  16899. row++;
  16900. if(currentElement.hasAttribute("height"))
  16901. {
  16902. layout->setRowMinimumHeight(row,
  16903. currentElement.attribute("height").toInt());
  16904. }
  16905. if(currentElement.hasAttribute("stretch"))
  16906. {
  16907. layout->setRowStretch(row,
  16908. currentElement.attribute("stretch").toInt());
  16909. }
  16910. /*218:*/
  16911. #line 4945 "./typica.w"
  16912. int column= -1;
  16913. QDomNodeList rowChildren= currentElement.childNodes();
  16914. for(int j= 0;j<rowChildren.count();j++)
  16915. {
  16916. QDomNode columnNode;
  16917. QDomElement columnElement;
  16918. columnNode= rowChildren.at(j);
  16919. if(columnNode.isElement())
  16920. {
  16921. columnElement= columnNode.toElement();
  16922. if(columnElement.tagName()=="column")
  16923. {
  16924. column++;
  16925. if(columnElement.hasAttribute("column"))
  16926. {
  16927. column= columnElement.attribute("column").toInt();
  16928. }
  16929. if(columnElement.hasAttribute("width"))
  16930. {
  16931. layout->setColumnMinimumWidth(column,
  16932. columnElement.attribute("width").toInt());
  16933. }
  16934. if(columnElement.hasAttribute("stretch"))
  16935. {
  16936. layout->setColumnStretch(column,
  16937. columnElement.attribute("stretch").toInt());
  16938. }
  16939. int hspan= 1;
  16940. int vspan= 1;
  16941. if(columnElement.hasAttribute("rowspan"))
  16942. {
  16943. vspan= columnElement.attribute("rowspan").toInt();
  16944. }
  16945. if(columnElement.hasAttribute("colspan"))
  16946. {
  16947. hspan= columnElement.attribute("colspan").toInt();
  16948. }
  16949. QHBoxLayout*cell= new QHBoxLayout;
  16950. layout->addLayout(cell,row,column,vspan,hspan);
  16951. layoutStack->push(cell);
  16952. columnElement.setAttribute("trcontext","configuration");
  16953. populateBoxLayout(columnElement,widgetStack,layoutStack);
  16954. layoutStack->pop();
  16955. }
  16956. }
  16957. }
  16958. /*:218*/
  16959. #line 4917 "./typica.w"
  16960. }
  16961. }
  16962. }
  16963. }
  16964. /*:217*//*219:*/
  16965. #line 4996 "./typica.w"
  16966. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16967. QStack<QLayout*> *layoutStack)
  16968. {
  16969. QDomNodeList children= element.childNodes();
  16970. for(int i= 0;i<children.count();i++)
  16971. {
  16972. QDomNode current;
  16973. QDomElement currentElement;
  16974. current= children.at(i);
  16975. if(current.isElement())
  16976. {
  16977. currentElement= current.toElement();
  16978. currentElement.setAttribute("trcontext","configuration");
  16979. if(currentElement.tagName()=="button")
  16980. {
  16981. addButtonToLayout(currentElement,widgetStack,layoutStack);
  16982. }
  16983. else if(currentElement.tagName()=="calendar")
  16984. {
  16985. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  16986. }
  16987. else if(currentElement.tagName()=="decoration")
  16988. {
  16989. addDecorationToLayout(currentElement,widgetStack,
  16990. layoutStack);
  16991. }
  16992. else if(currentElement.tagName()=="layout")
  16993. {
  16994. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  16995. }
  16996. else if(currentElement.tagName()=="splitter")
  16997. {
  16998. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  16999. }
  17000. else if(currentElement.tagName()=="label")
  17001. {
  17002. QBoxLayout*layout=
  17003. qobject_cast<QBoxLayout*> (layoutStack->top());
  17004. QLabel*label= new QLabel(QCoreApplication::translate(
  17005. "configuration",
  17006. currentElement.text().toUtf8().data()));
  17007. layout->addWidget(label);
  17008. }
  17009. else if(currentElement.tagName()=="lcdtemperature")
  17010. {
  17011. addTemperatureDisplayToLayout(currentElement,widgetStack,
  17012. layoutStack);
  17013. }
  17014. else if(currentElement.tagName()=="lcdtimer")
  17015. {
  17016. addTimerDisplayToLayout(currentElement,widgetStack,
  17017. layoutStack);
  17018. }
  17019. else if(currentElement.tagName()=="line")
  17020. {
  17021. addLineToLayout(currentElement,widgetStack,layoutStack);
  17022. }
  17023. else if(currentElement.tagName()=="report")
  17024. {
  17025. addReportToLayout(currentElement,widgetStack,layoutStack);
  17026. }
  17027. else if(currentElement.tagName()=="sqldrop")
  17028. {
  17029. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  17030. }
  17031. else if(currentElement.tagName()=="sqltablearray")
  17032. {
  17033. addSaltToLayout(currentElement,widgetStack,layoutStack);
  17034. }
  17035. else if(currentElement.tagName()=="sqlview")
  17036. {
  17037. addSqlQueryViewToLayout(currentElement,widgetStack,
  17038. layoutStack);
  17039. }
  17040. else if(currentElement.tagName()=="textarea")
  17041. {
  17042. addTextToLayout(currentElement,widgetStack,layoutStack);
  17043. }
  17044. else if(currentElement.tagName()=="spinbox")
  17045. {
  17046. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  17047. }
  17048. else if(currentElement.tagName()=="formarray")
  17049. {
  17050. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  17051. }
  17052. else if(currentElement.tagName()=="hscale")
  17053. {
  17054. addScaleControlToLayout(currentElement,widgetStack,
  17055. layoutStack);
  17056. }
  17057. else if(currentElement.tagName()=="vscale")
  17058. {
  17059. addIntensityControlToLayout(currentElement,widgetStack,
  17060. layoutStack);
  17061. }
  17062. else if(currentElement.tagName()=="webview")
  17063. {
  17064. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  17065. }
  17066. else if(currentElement.tagName()=="stretch")
  17067. {
  17068. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17069. layout->addStretch();
  17070. }
  17071. /*51:*/
  17072. #line 1482 "./typica.w"
  17073. else if(currentElement.tagName()=="svgwidget")
  17074. {
  17075. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  17076. }
  17077. /*:51*//*682:*/
  17078. #line 453 "./daterangeselector.w"
  17079. else if(currentElement.tagName()=="daterange")
  17080. {
  17081. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  17082. }
  17083. /*:682*/
  17084. #line 5102 "./typica.w"
  17085. }
  17086. }
  17087. }
  17088. /*:219*//*220:*/
  17089. #line 5110 "./typica.w"
  17090. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17091. QStack<QLayout*> *layoutStack)
  17092. {
  17093. QLayout*targetLayout= layoutStack->pop();
  17094. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  17095. if(element.hasAttribute("type"))
  17096. {
  17097. /*215:*/
  17098. #line 4809 "./typica.w"
  17099. QLayout*layout;
  17100. QString layoutType= element.attribute("type");
  17101. if(layoutType=="horizontal")
  17102. {
  17103. layout= new QHBoxLayout;
  17104. layoutStack->push(layout);
  17105. populateBoxLayout(element,widgetStack,layoutStack);
  17106. }
  17107. else if(layoutType=="vertical")
  17108. {
  17109. layout= new QVBoxLayout;
  17110. layoutStack->push(layout);
  17111. populateBoxLayout(element,widgetStack,layoutStack);
  17112. }
  17113. else if(layoutType=="grid")
  17114. {
  17115. layout= new QGridLayout;
  17116. layoutStack->push(layout);
  17117. populateGridLayout(element,widgetStack,layoutStack);
  17118. }
  17119. else if(layoutType=="stack")
  17120. {
  17121. layout= new QStackedLayout;
  17122. layoutStack->push(layout);
  17123. populateStackedLayout(element,widgetStack,layoutStack);
  17124. }
  17125. if(element.hasAttribute("id"))
  17126. {
  17127. layout->setObjectName(element.attribute("id"));
  17128. }
  17129. if(element.hasAttribute("spacing"))
  17130. {
  17131. layout->setSpacing(element.attribute("spacing").toInt());
  17132. }
  17133. if(element.hasAttribute("margin"))
  17134. {
  17135. int m= element.attribute("margin").toInt();
  17136. layout->setContentsMargins(m,m,m,m);
  17137. }
  17138. /*:215*/
  17139. #line 5118 "./typica.w"
  17140. boxLayout->addLayout(layout);
  17141. layoutStack->pop();
  17142. }
  17143. layoutStack->push(targetLayout);
  17144. }
  17145. /*:220*//*221:*/
  17146. #line 5129 "./typica.w"
  17147. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17148. QStack<QLayout*> *layoutStack)
  17149. {
  17150. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17151. QSplitter*splitter= new(QSplitter);
  17152. layout->addWidget(splitter);
  17153. /*222:*/
  17154. #line 5142 "./typica.w"
  17155. QString orientation= element.attribute("type");
  17156. if(orientation=="horizontal")
  17157. {
  17158. splitter->setOrientation(Qt::Horizontal);
  17159. }
  17160. else if(orientation=="vertical")
  17161. {
  17162. splitter->setOrientation(Qt::Vertical);
  17163. }
  17164. QString id= element.attribute("id");
  17165. if(!id.isEmpty())
  17166. {
  17167. splitter->setObjectName(id);
  17168. }
  17169. if(element.hasChildNodes())
  17170. {
  17171. widgetStack->push(splitter);
  17172. populateSplitter(element,widgetStack,layoutStack);
  17173. widgetStack->pop();
  17174. }
  17175. /*:222*/
  17176. #line 5136 "./typica.w"
  17177. }
  17178. /*:221*//*223:*/
  17179. #line 5168 "./typica.w"
  17180. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17181. QStack<QLayout*> *layoutStack)
  17182. {
  17183. QDomNodeList children= element.childNodes();
  17184. for(int i= 0;i<children.count();i++)
  17185. {
  17186. QDomNode current;
  17187. QDomElement currentElement;
  17188. current= children.at(i);
  17189. if(current.isElement())
  17190. {
  17191. currentElement= current.toElement();
  17192. currentElement.setAttribute("trcontext","configuration");
  17193. if(currentElement.tagName()=="decoration")
  17194. {
  17195. addDecorationToSplitter(currentElement,widgetStack,
  17196. layoutStack);
  17197. }
  17198. else if(currentElement.tagName()=="graph")
  17199. {
  17200. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  17201. }
  17202. else if(currentElement.tagName()=="splitter")
  17203. {
  17204. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  17205. }
  17206. else if(currentElement.tagName()=="lcdtemperature")
  17207. {
  17208. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  17209. layoutStack);
  17210. }
  17211. else if(currentElement.tagName()=="lcdtimer")
  17212. {
  17213. addTimerDisplayToSplitter(currentElement,widgetStack,
  17214. layoutStack);
  17215. }
  17216. else if(currentElement.tagName()=="measurementtable")
  17217. {
  17218. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  17219. }
  17220. else if(currentElement.tagName()=="widget")
  17221. {
  17222. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  17223. }
  17224. }
  17225. }
  17226. }
  17227. /*:223*//*224:*/
  17228. #line 5219 "./typica.w"
  17229. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17230. QStack<QLayout*> *layoutStack)
  17231. {
  17232. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  17233. QSplitter*splitter= new(QSplitter);
  17234. splitter->setParent(parent);
  17235. parent->addWidget(splitter);
  17236. /*222:*/
  17237. #line 5142 "./typica.w"
  17238. QString orientation= element.attribute("type");
  17239. if(orientation=="horizontal")
  17240. {
  17241. splitter->setOrientation(Qt::Horizontal);
  17242. }
  17243. else if(orientation=="vertical")
  17244. {
  17245. splitter->setOrientation(Qt::Vertical);
  17246. }
  17247. QString id= element.attribute("id");
  17248. if(!id.isEmpty())
  17249. {
  17250. splitter->setObjectName(id);
  17251. }
  17252. if(element.hasChildNodes())
  17253. {
  17254. widgetStack->push(splitter);
  17255. populateSplitter(element,widgetStack,layoutStack);
  17256. widgetStack->pop();
  17257. }
  17258. /*:222*/
  17259. #line 5227 "./typica.w"
  17260. }
  17261. /*:224*//*225:*/
  17262. #line 5236 "./typica.w"
  17263. void addTemperatureDisplayToSplitter(QDomElement element,
  17264. QStack<QWidget*> *widgetStack,
  17265. QStack<QLayout*> *)
  17266. {
  17267. TemperatureDisplay*display= new(TemperatureDisplay);
  17268. if(element.hasAttribute("id"))
  17269. {
  17270. display->setObjectName(element.attribute("id"));
  17271. }
  17272. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17273. splitter->addWidget(display);
  17274. }
  17275. void addTemperatureDisplayToLayout(QDomElement element,
  17276. QStack<QWidget*> *,
  17277. QStack<QLayout*> *layoutStack)
  17278. {
  17279. TemperatureDisplay*display= new(TemperatureDisplay);
  17280. if(element.hasAttribute("id"))
  17281. {
  17282. display->setObjectName(element.attribute("id"));
  17283. }
  17284. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17285. layout->addWidget(display);
  17286. }
  17287. /*:225*//*226:*/
  17288. #line 5267 "./typica.w"
  17289. void addTimerDisplayToSplitter(QDomElement element,
  17290. QStack<QWidget*> *widgetStack,
  17291. QStack<QLayout*> *)
  17292. {
  17293. TimerDisplay*display= new(TimerDisplay);
  17294. if(element.hasAttribute("id"))
  17295. {
  17296. display->setObjectName(element.attribute("id"));
  17297. }
  17298. if(element.hasAttribute("format"))
  17299. {
  17300. display->setDisplayFormat(element.attribute("format"));
  17301. }
  17302. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17303. splitter->addWidget(display);
  17304. }
  17305. void addTimerDisplayToLayout(QDomElement element,
  17306. QStack<QWidget*> *,
  17307. QStack<QLayout*> *layoutStack)
  17308. {
  17309. TimerDisplay*display= new(TimerDisplay);
  17310. if(element.hasAttribute("id"))
  17311. {
  17312. display->setObjectName(element.attribute("id"));
  17313. }
  17314. if(element.hasAttribute("format"))
  17315. {
  17316. display->setDisplayFormat(element.attribute("format"));
  17317. }
  17318. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17319. layout->addWidget(display);
  17320. }
  17321. /*:226*//*227:*/
  17322. #line 5305 "./typica.w"
  17323. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  17324. QStack<QLayout*> *layoutStack)
  17325. {
  17326. /*228:*/
  17327. #line 5326 "./typica.w"
  17328. QString labelText=
  17329. QCoreApplication::translate("configuration",
  17330. element.attribute("name").toUtf8().data());
  17331. Qt::Orientations orientation= Qt::Horizontal;
  17332. if(element.hasAttribute("type"))
  17333. {
  17334. if(element.attribute("type")=="horizontal")
  17335. {
  17336. orientation= Qt::Horizontal;
  17337. }
  17338. else if(element.attribute("type")=="vertical")
  17339. {
  17340. orientation= Qt::Vertical;
  17341. }
  17342. }
  17343. /*229:*/
  17344. #line 5353 "./typica.w"
  17345. QWidget*theWidget= NULL;
  17346. QDomNodeList children= element.childNodes();
  17347. for(int i= 0;i<children.count();i++)
  17348. {
  17349. QDomNode item= children.at(i);
  17350. if(item.isElement())
  17351. {
  17352. QDomElement itemElement= item.toElement();
  17353. if(itemElement.tagName()=="lcdtemperature")
  17354. {
  17355. TemperatureDisplay*display= new TemperatureDisplay;
  17356. if(itemElement.hasAttribute("id"))
  17357. {
  17358. display->setObjectName(itemElement.attribute("id"));
  17359. }
  17360. theWidget= display;
  17361. }
  17362. else if(itemElement.tagName()=="lcdtimer")
  17363. {
  17364. TimerDisplay*display= new TimerDisplay;
  17365. if(itemElement.hasAttribute("id"))
  17366. {
  17367. display->setObjectName(itemElement.attribute("id"));
  17368. }
  17369. if(itemElement.hasAttribute("format"))
  17370. {
  17371. display->setDisplayFormat(itemElement.attribute("format"));
  17372. }
  17373. theWidget= display;
  17374. }
  17375. }
  17376. }
  17377. /*:229*/
  17378. #line 5342 "./typica.w"
  17379. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  17380. orientation);
  17381. if(element.hasAttribute("id"))
  17382. {
  17383. decoration->setObjectName(element.attribute("id"));
  17384. }
  17385. /*:228*/
  17386. #line 5309 "./typica.w"
  17387. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17388. layout->addWidget(decoration);
  17389. }
  17390. void addDecorationToSplitter(QDomElement element,
  17391. QStack<QWidget*> *widgetStack,
  17392. QStack<QLayout*> *)
  17393. {
  17394. /*228:*/
  17395. #line 5326 "./typica.w"
  17396. QString labelText=
  17397. QCoreApplication::translate("configuration",
  17398. element.attribute("name").toUtf8().data());
  17399. Qt::Orientations orientation= Qt::Horizontal;
  17400. if(element.hasAttribute("type"))
  17401. {
  17402. if(element.attribute("type")=="horizontal")
  17403. {
  17404. orientation= Qt::Horizontal;
  17405. }
  17406. else if(element.attribute("type")=="vertical")
  17407. {
  17408. orientation= Qt::Vertical;
  17409. }
  17410. }
  17411. /*229:*/
  17412. #line 5353 "./typica.w"
  17413. QWidget*theWidget= NULL;
  17414. QDomNodeList children= element.childNodes();
  17415. for(int i= 0;i<children.count();i++)
  17416. {
  17417. QDomNode item= children.at(i);
  17418. if(item.isElement())
  17419. {
  17420. QDomElement itemElement= item.toElement();
  17421. if(itemElement.tagName()=="lcdtemperature")
  17422. {
  17423. TemperatureDisplay*display= new TemperatureDisplay;
  17424. if(itemElement.hasAttribute("id"))
  17425. {
  17426. display->setObjectName(itemElement.attribute("id"));
  17427. }
  17428. theWidget= display;
  17429. }
  17430. else if(itemElement.tagName()=="lcdtimer")
  17431. {
  17432. TimerDisplay*display= new TimerDisplay;
  17433. if(itemElement.hasAttribute("id"))
  17434. {
  17435. display->setObjectName(itemElement.attribute("id"));
  17436. }
  17437. if(itemElement.hasAttribute("format"))
  17438. {
  17439. display->setDisplayFormat(itemElement.attribute("format"));
  17440. }
  17441. theWidget= display;
  17442. }
  17443. }
  17444. }
  17445. /*:229*/
  17446. #line 5342 "./typica.w"
  17447. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  17448. orientation);
  17449. if(element.hasAttribute("id"))
  17450. {
  17451. decoration->setObjectName(element.attribute("id"));
  17452. }
  17453. /*:228*/
  17454. #line 5318 "./typica.w"
  17455. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17456. splitter->addWidget(decoration);
  17457. }
  17458. /*:227*//*230:*/
  17459. #line 5392 "./typica.w"
  17460. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17461. QStack<QLayout*> *layoutStack)
  17462. {
  17463. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17464. QWidget*widget= new QWidget;
  17465. if(element.hasAttribute("id"))
  17466. {
  17467. widget->setObjectName(element.attribute("id"));
  17468. }
  17469. splitter->addWidget(widget);
  17470. if(element.hasChildNodes())
  17471. {
  17472. widgetStack->push(widget);
  17473. populateWidget(element,widgetStack,layoutStack);
  17474. widgetStack->pop();
  17475. }
  17476. }
  17477. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  17478. QStack<QLayout*> *layoutStack)
  17479. {
  17480. QDomNodeList children= element.childNodes();
  17481. for(int i= 0;i<children.count();i++)
  17482. {
  17483. QDomNode current;
  17484. QDomElement currentElement;
  17485. current= children.at(i);
  17486. if(current.isElement())
  17487. {
  17488. currentElement= current.toElement();
  17489. if(currentElement.tagName()=="layout")
  17490. {
  17491. currentElement.setAttribute("trcontext","configuration");
  17492. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  17493. }
  17494. }
  17495. }
  17496. }
  17497. /*:230*//*231:*/
  17498. #line 5436 "./typica.w"
  17499. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  17500. QStack<QLayout*> *layoutStack)
  17501. {
  17502. QAbstractButton*button= NULL;
  17503. QString text=
  17504. QCoreApplication::translate("configuration",
  17505. element.attribute("name").toUtf8().data());
  17506. if(element.hasAttribute("type"))
  17507. {
  17508. QString type= element.attribute("type");
  17509. if(type=="annotation")
  17510. {
  17511. AnnotationButton*abutton= new AnnotationButton(text);
  17512. if(element.hasAttribute("annotation"))
  17513. {
  17514. abutton->setAnnotation(element.attribute("annotation"));
  17515. }
  17516. if(element.hasAttribute("series"))
  17517. {
  17518. abutton->setTemperatureColumn(element.attribute("series").
  17519. toInt());
  17520. }
  17521. if(element.hasAttribute("column"))
  17522. {
  17523. abutton->setAnnotationColumn(element.attribute("column").
  17524. toInt());
  17525. }
  17526. button= abutton;
  17527. }
  17528. else if(type=="check")
  17529. {
  17530. button= new QCheckBox(text);
  17531. }
  17532. else if(type=="push")
  17533. {
  17534. button= new QPushButton(text);
  17535. }
  17536. }
  17537. if(element.hasAttribute("id"))
  17538. {
  17539. button->setObjectName(element.attribute("id"));
  17540. }
  17541. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17542. layout->addWidget(button);
  17543. }
  17544. /*:231*//*232:*/
  17545. #line 5490 "./typica.w"
  17546. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  17547. QStack<QLayout*> *layoutStack)
  17548. {
  17549. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  17550. if(element.hasAttribute("pretext"))
  17551. {
  17552. box->setPretext(QCoreApplication::translate(
  17553. "configuration",
  17554. element.attribute("pretext").toUtf8().data()));
  17555. }
  17556. if(element.hasAttribute("posttext"))
  17557. {
  17558. box->setPosttext(QCoreApplication::translate(
  17559. "configuration",
  17560. element.attribute("posttext").toUtf8().data()));
  17561. }
  17562. if(element.hasAttribute("series"))
  17563. {
  17564. box->setTemperatureColumn(element.attribute("series").toInt());
  17565. }
  17566. if(element.hasAttribute("column"))
  17567. {
  17568. box->setAnnotationColumn(element.attribute("column").toInt());
  17569. }
  17570. if(element.hasAttribute("min"))
  17571. {
  17572. box->setMinimum(element.attribute("min").toDouble());
  17573. }
  17574. if(element.hasAttribute("max"))
  17575. {
  17576. box->setMaximum(element.attribute("max").toDouble());
  17577. }
  17578. if(element.hasAttribute("decimals"))
  17579. {
  17580. box->setDecimals(element.attribute("decimals").toInt());
  17581. }
  17582. if(element.hasAttribute("step"))
  17583. {
  17584. box->setSingleStep(element.attribute("step").toDouble());
  17585. }
  17586. if(element.hasAttribute("id"))
  17587. {
  17588. box->setObjectName(element.attribute("id"));
  17589. }
  17590. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17591. layout->addWidget(box);
  17592. }
  17593. /*:232*//*233:*/
  17594. #line 5550 "./typica.w"
  17595. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17596. QStack<QLayout*> *)
  17597. {
  17598. ZoomLog*widget= new ZoomLog;
  17599. if(element.hasAttribute("id"))
  17600. {
  17601. widget->setObjectName(element.attribute("id"));
  17602. }
  17603. if(element.hasChildNodes())
  17604. {
  17605. QDomNodeList children= element.childNodes();
  17606. int column= 0;
  17607. for(int i= 0;i<children.count();i++)
  17608. {
  17609. QDomNode current;
  17610. QDomElement currentElement;
  17611. current= children.at(i);
  17612. if(current.isElement())
  17613. {
  17614. currentElement= current.toElement();
  17615. if(currentElement.tagName()=="column")
  17616. {
  17617. QString text=
  17618. QCoreApplication::translate(
  17619. "configuration",
  17620. currentElement.text().toUtf8().data());
  17621. widget->setHeaderData(column,text);
  17622. column++;
  17623. }
  17624. }
  17625. }
  17626. }
  17627. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17628. if(splitter)
  17629. {
  17630. splitter->addWidget(widget);
  17631. }
  17632. else
  17633. {
  17634. qDebug()<<"Splitter not found at top of widget stack!";
  17635. }
  17636. }
  17637. /*:233*//*234:*/
  17638. #line 5597 "./typica.w"
  17639. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17640. QStack<QLayout*> *)
  17641. {
  17642. GraphView*view= new GraphView;
  17643. if(element.hasAttribute("id"))
  17644. {
  17645. view->setObjectName(element.attribute("id"));
  17646. }
  17647. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17648. splitter->addWidget(view);
  17649. }
  17650. /*:234*//*235:*/
  17651. #line 5614 "./typica.w"
  17652. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  17653. QStack<QLayout*> *layoutStack)
  17654. {
  17655. SqlComboBox*box= new SqlComboBox();
  17656. if(element.hasAttribute("data"))
  17657. {
  17658. box->setDataColumn(element.attribute("data").toInt());
  17659. }
  17660. if(element.hasAttribute("display"))
  17661. {
  17662. box->setDisplayColumn(element.attribute("display").toInt());
  17663. }
  17664. if(element.hasAttribute("showdata"))
  17665. {
  17666. if(element.attribute("showdata")=="true")
  17667. {
  17668. box->showData(true);
  17669. }
  17670. }
  17671. if(element.hasAttribute("editable"))
  17672. {
  17673. if(element.attribute("editable")=="true")
  17674. {
  17675. box->setEditable(true);
  17676. }
  17677. }
  17678. if(element.hasChildNodes())
  17679. {
  17680. QDomNodeList children= element.childNodes();
  17681. for(int i= 0;i<children.count();i++)
  17682. {
  17683. QDomNode current;
  17684. QDomElement currentElement;
  17685. current= children.at(i);
  17686. if(current.isElement())
  17687. {
  17688. currentElement= current.toElement();
  17689. if(currentElement.tagName()=="null")
  17690. {
  17691. box->addNullOption();
  17692. }
  17693. else if(currentElement.tagName()=="query")
  17694. {
  17695. box->addSqlOptions(currentElement.text());
  17696. }
  17697. }
  17698. }
  17699. }
  17700. if(element.hasAttribute("id"))
  17701. {
  17702. box->setObjectName(element.attribute("id"));
  17703. }
  17704. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17705. layout->addWidget(box);
  17706. }
  17707. /*:235*//*236:*/
  17708. #line 5693 "./typica.w"
  17709. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  17710. QStack<QLayout*> *layoutStack)
  17711. {
  17712. QTableView*view= new QTableView;
  17713. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  17714. SaltModel*model= new SaltModel(element.childNodes().count());
  17715. if(element.hasAttribute("id"))
  17716. {
  17717. view->setObjectName(element.attribute("id"));
  17718. }
  17719. if(element.hasChildNodes())
  17720. {
  17721. QDomNodeList children= element.childNodes();
  17722. int currentColumn= 0;
  17723. for(int i= 0;i<children.count();i++)
  17724. {
  17725. QDomNode current;
  17726. QDomElement currentElement;
  17727. current= children.at(i);
  17728. if(current.isElement())
  17729. {
  17730. currentElement= current.toElement();
  17731. if(currentElement.tagName()=="column")
  17732. {
  17733. if(currentElement.hasAttribute("name"))
  17734. {
  17735. model->setHeaderData(currentColumn,
  17736. Qt::Horizontal,
  17737. QCoreApplication::translate(
  17738. "configuration",
  17739. currentElement.attribute("name").toUtf8().data()));
  17740. }
  17741. if(currentElement.hasAttribute("delegate"))
  17742. {
  17743. /*237:*/
  17744. #line 5744 "./typica.w"
  17745. if(currentElement.attribute("delegate")=="sql")
  17746. {
  17747. /*238:*/
  17748. #line 5760 "./typica.w"
  17749. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  17750. SqlComboBox*widget= new SqlComboBox();
  17751. if(currentElement.hasAttribute("nulltext"))
  17752. {
  17753. widget->setNullText(currentElement.attribute("nulltext"));
  17754. }
  17755. if(currentElement.hasAttribute("nulldata"))
  17756. {
  17757. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  17758. }
  17759. if(currentElement.hasAttribute("null"))
  17760. {
  17761. if(currentElement.attribute("null")=="true")
  17762. {
  17763. widget->addNullOption();
  17764. }
  17765. }
  17766. if(currentElement.hasAttribute("showdata"))
  17767. {
  17768. if(currentElement.attribute("showdata")=="true")
  17769. {
  17770. widget->showData(true);
  17771. }
  17772. }
  17773. if(currentElement.hasAttribute("data"))
  17774. {
  17775. widget->setDataColumn(currentElement.attribute("data").toInt());
  17776. }
  17777. if(currentElement.hasAttribute("display"))
  17778. {
  17779. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  17780. }
  17781. widget->addSqlOptions(currentElement.text());
  17782. delegate->setWidget(widget);
  17783. view->setItemDelegateForColumn(currentColumn,delegate);
  17784. /*:238*/
  17785. #line 5747 "./typica.w"
  17786. }
  17787. else if(currentElement.attribute("delegate")=="numeric")
  17788. {
  17789. /*239:*/
  17790. #line 5801 "./typica.w"
  17791. NumericDelegate*delegate= new NumericDelegate;
  17792. view->setItemDelegateForColumn(currentColumn,delegate);
  17793. /*:239*/
  17794. #line 5751 "./typica.w"
  17795. }
  17796. /*:237*/
  17797. #line 5728 "./typica.w"
  17798. }
  17799. currentColumn++;
  17800. }
  17801. }
  17802. }
  17803. }
  17804. view->setModel(model);
  17805. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17806. layout->addWidget(view);
  17807. }
  17808. /*:236*//*251:*/
  17809. #line 5974 "./typica.w"
  17810. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  17811. QStack<QLayout*> *layoutStack)
  17812. {
  17813. QLineEdit*widget= new QLineEdit(element.text());
  17814. if(element.hasAttribute("id"))
  17815. {
  17816. widget->setObjectName(element.attribute("id"));
  17817. }
  17818. if(element.hasAttribute("writable"))
  17819. {
  17820. if(element.attribute("writable")=="false")
  17821. {
  17822. widget->setReadOnly(true);
  17823. }
  17824. }
  17825. if(element.hasAttribute("validator"))
  17826. {
  17827. if(element.attribute("validator")=="numeric")
  17828. {
  17829. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  17830. }
  17831. else if(element.attribute("validator")=="integer")
  17832. {
  17833. widget->setValidator(new ScriptValidator(new QIntValidator));
  17834. }
  17835. else if(element.attribute("validator")=="expression"&&
  17836. element.hasAttribute("expression"))
  17837. {
  17838. widget->setValidator(new QRegExpValidator(
  17839. QRegExp(element.attribute("expression")),
  17840. NULL));
  17841. }
  17842. }
  17843. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17844. layout->addWidget(widget);
  17845. }
  17846. /*:251*//*252:*/
  17847. #line 6015 "./typica.w"
  17848. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  17849. QStack<QLayout*> *layoutStack)
  17850. {
  17851. QTextEdit*widget= new QTextEdit;
  17852. if(element.hasAttribute("id"))
  17853. {
  17854. widget->setObjectName(element.attribute("id"));
  17855. }
  17856. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17857. layout->addWidget(widget);
  17858. }
  17859. /*:252*//*253:*/
  17860. #line 6032 "./typica.w"
  17861. void addSqlQueryViewToLayout(QDomElement element,
  17862. QStack<QWidget*> *,
  17863. QStack<QLayout*> *layoutStack)
  17864. {
  17865. SqlQueryView*view= new SqlQueryView;
  17866. if(element.hasAttribute("id"))
  17867. {
  17868. view->setObjectName(element.attribute("id"));
  17869. }
  17870. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17871. layout->addWidget(view);
  17872. }
  17873. /*:253*//*254:*/
  17874. #line 6049 "./typica.w"
  17875. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  17876. QStack<QLayout*> *layoutStack)
  17877. {
  17878. QWidget*widget;
  17879. if(element.hasAttribute("time"))
  17880. {
  17881. if(element.attribute("time")=="true")
  17882. {
  17883. QDateTimeEdit*edit= new QDateTimeEdit;
  17884. edit->setDateTime(QDateTime::currentDateTime());
  17885. edit->setCalendarPopup(true);
  17886. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  17887. widget= qobject_cast<QWidget*> (edit);
  17888. }
  17889. else
  17890. {
  17891. QDateEdit*edit= new QDateEdit;
  17892. edit->setDate(QDate::currentDate());
  17893. edit->setCalendarPopup(true);
  17894. edit->setDisplayFormat("yyyy-MM-dd");
  17895. widget= qobject_cast<QWidget*> (edit);
  17896. }
  17897. }
  17898. else
  17899. {
  17900. QDateEdit*edit= new QDateEdit;
  17901. edit->setDate(QDate::currentDate());
  17902. edit->setCalendarPopup(true);
  17903. edit->setDisplayFormat("yyyy-MM-dd");
  17904. widget= qobject_cast<QWidget*> (edit);
  17905. }
  17906. if(element.hasAttribute("id"))
  17907. {
  17908. widget->setObjectName(element.attribute("id"));
  17909. }
  17910. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17911. layout->addWidget(widget);
  17912. }
  17913. /*:254*//*255:*/
  17914. #line 6092 "./typica.w"
  17915. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  17916. {
  17917. setQDateTimeEditProperties(value,engine);
  17918. }
  17919. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  17920. {
  17921. setQAbstractSpinBoxProperties(value,engine);
  17922. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  17923. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  17924. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  17925. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  17926. value.setProperty("setToCurrentTime",
  17927. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  17928. }
  17929. /*:255*//*256:*/
  17930. #line 6114 "./typica.w"
  17931. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  17932. {
  17933. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17934. if(context->argumentCount()==3)
  17935. {
  17936. self->setDate(QDate(argument<int> (0,context),
  17937. argument<int> (1,context),
  17938. argument<int> (2,context)));
  17939. }
  17940. else
  17941. {
  17942. context->throwError("Incorrect number of arguments passed to "
  17943. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  17944. "specifying the year, month, and day.");
  17945. }
  17946. return QScriptValue();
  17947. }
  17948. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  17949. {
  17950. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17951. return QScriptValue(self->date().day());
  17952. }
  17953. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  17954. {
  17955. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17956. return QScriptValue(self->date().month());
  17957. }
  17958. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  17959. {
  17960. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17961. return QScriptValue(self->date().year());
  17962. }
  17963. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  17964. {
  17965. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17966. self->setDateTime(QDateTime::currentDateTime());
  17967. return QScriptValue();
  17968. }
  17969. /*:256*//*260:*/
  17970. #line 6189 "./typica.w"
  17971. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  17972. {
  17973. QObject*parent= argument<QObject*> (0,context);
  17974. QString name= argument<QString> (1,context);
  17975. QObject*object= parent->findChild<QObject*> (name);
  17976. QScriptValue value;
  17977. if(object)
  17978. {
  17979. value= engine->newQObject(object);
  17980. QString className= object->metaObject()->className();
  17981. /*261:*/
  17982. #line 6207 "./typica.w"
  17983. if(className=="TemperatureDisplay")
  17984. {
  17985. setTemperatureDisplayProperties(value,engine);
  17986. }
  17987. else if(className=="TimerDisplay")
  17988. {
  17989. setTimerDisplayProperties(value,engine);
  17990. }
  17991. else if(className=="QAction")
  17992. {
  17993. setQActionProperties(value,engine);
  17994. }
  17995. else if(className=="QBoxLayout")
  17996. {
  17997. setQBoxLayoutProperties(value,engine);
  17998. }
  17999. else if(className=="QDateEdit")
  18000. {
  18001. setQDateEditProperties(value,engine);
  18002. }
  18003. else if(className=="QDateTimeEdit")
  18004. {
  18005. setQDateTimeEditProperties(value,engine);
  18006. }
  18007. else if(className=="QFrame")
  18008. {
  18009. setQFrameProperties(value,engine);
  18010. }
  18011. else if(className=="QHBoxLayout")
  18012. {
  18013. setQBoxLayoutProperties(value,engine);
  18014. }
  18015. else if(className=="QLCDNumber")
  18016. {
  18017. setQLCDNumberProperties(value,engine);
  18018. }
  18019. else if(className=="QMenu")
  18020. {
  18021. setQMenuProperties(value,engine);
  18022. }
  18023. else if(className=="QMenuBar")
  18024. {
  18025. setQMenuBarProperties(value,engine);
  18026. }
  18027. else if(className=="QPushButton")
  18028. {
  18029. setQPushButtonProperties(value,engine);
  18030. }
  18031. else if(className=="QSplitter")
  18032. {
  18033. setQSplitterProperties(value,engine);
  18034. }
  18035. else if(className=="QTableView")
  18036. {
  18037. if(object->property("tabletype").isValid())
  18038. {
  18039. if(object->property("tabletype").toString()=="SaltTable")
  18040. {
  18041. setSaltTableProperties(value,engine);
  18042. }
  18043. }
  18044. }
  18045. else if(className=="QVBoxLayout")
  18046. {
  18047. setQBoxLayoutProperties(value,engine);
  18048. }
  18049. else if(className=="QWidget")
  18050. {
  18051. setQWidgetProperties(value,engine);
  18052. }
  18053. else if(className=="ScriptQMainWindow")
  18054. {
  18055. setQMainWindowProperties(value,engine);
  18056. }
  18057. else if(className=="SqlComboBox")
  18058. {
  18059. setSqlComboBoxProperties(value,engine);
  18060. }
  18061. else if(className=="SqlQueryView")
  18062. {
  18063. setSqlQueryViewProperties(value,engine);
  18064. }
  18065. else if(className=="ZoomLog")
  18066. {
  18067. setZoomLogProperties(value,engine);
  18068. }
  18069. else if(className=="QTextEdit")
  18070. {
  18071. setQTextEditProperties(value,engine);
  18072. }
  18073. else if(className=="QWebView")
  18074. {
  18075. setQWebViewProperties(value,engine);
  18076. }
  18077. else if(className=="QLineEdit")
  18078. {
  18079. setQLineEditProperties(value,engine);
  18080. }
  18081. else if(className=="QSvgWidget")
  18082. {
  18083. setQSvgWidgetProperties(value,engine);
  18084. }
  18085. /*:261*/
  18086. #line 6200 "./typica.w"
  18087. }
  18088. return value;
  18089. }
  18090. /*:260*//*263:*/
  18091. #line 6340 "./typica.w"
  18092. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  18093. {
  18094. QTableView*self= getself<QTableView*> (context);
  18095. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18096. QString datum;
  18097. double total= 0.0;
  18098. int column= argument<int> (0,context);
  18099. int role= argument<int> (1,context);
  18100. for(int i= 0;i<model->rowCount();i++)
  18101. {
  18102. datum= model->data(model->index(i,column),role).toString();
  18103. if(!datum.isEmpty())
  18104. {
  18105. total+= datum.toDouble();
  18106. }
  18107. }
  18108. return QScriptValue(engine,total);
  18109. }
  18110. /*:263*//*264:*/
  18111. #line 6364 "./typica.w"
  18112. QScriptValue SaltTable_columnArray(QScriptContext*context,
  18113. QScriptEngine*engine)
  18114. {
  18115. QTableView*self= getself<QTableView*> (context);
  18116. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18117. int column= argument<int> (0,context);
  18118. int role= argument<int> (1,context);
  18119. QString literal= model->arrayLiteral(column,role);
  18120. return QScriptValue(engine,literal);
  18121. }
  18122. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  18123. QScriptEngine*engine)
  18124. {
  18125. QTableView*self= getself<QTableView*> (context);
  18126. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18127. int column= argument<int> (0,context);
  18128. int role= argument<int> (1,context);
  18129. QString literal= model->quotedArrayLiteral(column,role);
  18130. return QScriptValue(engine,literal);
  18131. }
  18132. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  18133. QScriptEngine*engine)
  18134. {
  18135. QTableView*self= getself<QTableView*> (context);
  18136. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18137. int column= argument<int> (0,context);
  18138. int role= argument<int> (1,context);
  18139. QString literal= model->arrayLiteral(column,role);
  18140. literal.chop(1);
  18141. literal= literal.remove(0,1);
  18142. return QScriptValue(engine,literal);
  18143. }
  18144. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  18145. QScriptEngine*engine)
  18146. {
  18147. QTableView*self= getself<QTableView*> (context);
  18148. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18149. int column= argument<int> (0,context);
  18150. int role= argument<int> (1,context);
  18151. QString literal= model->quotedArrayLiteral(column,role);
  18152. literal.chop(1);
  18153. literal= literal.remove(0,1);
  18154. return QScriptValue(engine,literal);
  18155. }
  18156. /*:264*//*265:*/
  18157. #line 6416 "./typica.w"
  18158. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  18159. {
  18160. QTableView*self= getself<QTableView*> (context);
  18161. QScriptValue value= engine->newQObject(self->model());
  18162. return value;
  18163. }
  18164. /*:265*//*266:*/
  18165. #line 6430 "./typica.w"
  18166. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  18167. {
  18168. QTableView*self= getself<QTableView*> (context);
  18169. int row= argument<int> (0,context);
  18170. int column= argument<int> (1,context);
  18171. QVariant value= argument<QVariant> (2,context);
  18172. int role= argument<int> (3,context);
  18173. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18174. QModelIndex cell= model->index(row,column);
  18175. model->setData(cell,value,role);
  18176. self->update(cell);
  18177. return QScriptValue();
  18178. }
  18179. /*:266*//*267:*/
  18180. #line 6448 "./typica.w"
  18181. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  18182. {
  18183. QTableView*self= getself<QTableView*> (context);
  18184. int row= argument<int> (0,context);
  18185. int column= argument<int> (1,context);
  18186. int role= argument<int> (2,context);
  18187. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18188. QModelIndex cell= model->index(row,column);
  18189. QVariant value= model->data(cell,role);
  18190. QScriptValue retval= engine->newVariant(value);
  18191. retval.setProperty("value",QScriptValue(value.toString()));
  18192. return retval;
  18193. }
  18194. /*:267*//*268:*/
  18195. #line 6468 "./typica.w"
  18196. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  18197. {
  18198. QTableView*self= getself<QTableView*> (context);
  18199. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18200. model->clear();
  18201. return QScriptValue();
  18202. }
  18203. /*:268*//*269:*/
  18204. #line 6480 "./typica.w"
  18205. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  18206. {
  18207. QTableView*self= getself<QTableView*> (context);
  18208. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18209. int row= argument<int> (0,context);
  18210. return engine->newVariant(model->removeRow(row));
  18211. }
  18212. /*:269*//*270:*/
  18213. #line 6493 "./typica.w"
  18214. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  18215. {
  18216. QTableView*self= getself<QTableView*> (context);
  18217. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18218. QVariant value= argument<QVariant> (0,context);
  18219. int column= argument<int> (1,context);
  18220. return engine->newVariant(model->findData(value,column));
  18221. }
  18222. /*:270*//*271:*/
  18223. #line 6506 "./typica.w"
  18224. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  18225. {
  18226. setQWidgetProperties(value,engine);
  18227. value.setProperty("columnArray",
  18228. engine->newFunction(SaltTable_columnArray));
  18229. value.setProperty("quotedColumnArray",
  18230. engine->newFunction(SaltTable_quotedColumnArray));
  18231. value.setProperty("bindableColumnArray",
  18232. engine->newFunction(SaltTable_bindableColumnArray));
  18233. value.setProperty("bindableQuotedColumnArray",
  18234. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  18235. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  18236. value.setProperty("data",engine->newFunction(SaltTable_data));
  18237. value.setProperty("model",engine->newFunction(SaltTable_model));
  18238. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  18239. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  18240. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  18241. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  18242. }
  18243. /*:271*//*273:*/
  18244. #line 6543 "./typica.w"
  18245. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  18246. {
  18247. setQComboBoxProperties(value,engine);
  18248. }
  18249. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  18250. {
  18251. setQWidgetProperties(value,engine);
  18252. value.setProperty("currentData",
  18253. engine->newFunction(QComboBox_currentData));
  18254. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  18255. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  18256. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  18257. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  18258. }
  18259. QScriptValue QComboBox_currentData(QScriptContext*context,
  18260. QScriptEngine*engine)
  18261. {
  18262. QComboBox*self= getself<QComboBox*> (context);
  18263. return QScriptValue(engine,
  18264. self->itemData(self->currentIndex()).toString());
  18265. }
  18266. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  18267. {
  18268. QComboBox*self= getself<QComboBox*> (context);
  18269. self->addItem(argument<QString> (0,context));
  18270. return QScriptValue();
  18271. }
  18272. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  18273. {
  18274. QComboBox*self= getself<QComboBox*> (context);
  18275. self->setModel(argument<QAbstractItemModel*> (0,context));
  18276. return QScriptValue();
  18277. }
  18278. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  18279. {
  18280. QComboBox*self= getself<QComboBox*> (context);
  18281. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  18282. }
  18283. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  18284. {
  18285. QComboBox*self= getself<QComboBox*> (context);
  18286. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  18287. }
  18288. #line 1 "./abouttypica.w"
  18289. /*:273*//*286:*/
  18290. #line 401 "./units.w"
  18291. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  18292. {
  18293. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  18294. argument<Units::Unit> (1,context),
  18295. argument<Units::Unit> (2,context)));
  18296. }
  18297. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  18298. QScriptEngine*)
  18299. {
  18300. return QScriptValue(Units::convertRelativeTemperature(
  18301. argument<double> (0,context),
  18302. argument<Units::Unit> (1,context),
  18303. argument<Units::Unit> (2,context)));
  18304. }
  18305. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  18306. {
  18307. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  18308. }
  18309. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  18310. {
  18311. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  18312. argument<Units::Unit> (1,context),
  18313. argument<Units::Unit> (2,context)));
  18314. }
  18315. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  18316. {
  18317. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  18318. }
  18319. /*:286*//*289:*/
  18320. #line 449 "./units.w"
  18321. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  18322. {
  18323. return engine->newVariant(QVariant(value));
  18324. }
  18325. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  18326. {
  18327. value= sv.toVariant().value<Units::Unit> ();
  18328. }
  18329. /*:289*//*299:*/
  18330. #line 149 "./measurement.w"
  18331. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  18332. {
  18333. QScriptValue object;
  18334. if(context->argumentCount()==2||context->argumentCount()==3)
  18335. {
  18336. double measurement= argument<double> (0,context);
  18337. QTime timestamp= argument<QTime> (1,context);
  18338. Units::Unit unit= Units::Fahrenheit;
  18339. if(context->argumentCount()==3)
  18340. {
  18341. unit= argument<Units::Unit> (2,context);
  18342. }
  18343. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  18344. setMeasurementProperties(object,engine);
  18345. }
  18346. else
  18347. {
  18348. context->throwError("Incorrect number of arguments passed to "
  18349. "Measurement::Measurement(). This method takes two "
  18350. "or three arguments.");
  18351. }
  18352. return object;
  18353. }
  18354. /*:299*//*300:*/
  18355. #line 176 "./measurement.w"
  18356. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  18357. {
  18358. }
  18359. /*:300*//*301:*/
  18360. #line 184 "./measurement.w"
  18361. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  18362. {
  18363. QVariant var;
  18364. var.setValue(measurement);
  18365. return engine->newVariant(var);
  18366. }
  18367. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  18368. {
  18369. measurement= value.toVariant().value<Measurement> ();
  18370. }
  18371. #line 6612 "./typica.w"
  18372. /*:301*//*319:*/
  18373. #line 7190 "./typica.w"
  18374. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  18375. {
  18376. QScriptValue object;
  18377. if(context->argumentCount()==1)
  18378. {
  18379. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  18380. QScriptEngine::ScriptOwnership);
  18381. setDAQProperties(object,engine);
  18382. }
  18383. else if(context->argumentCount()==2)
  18384. {
  18385. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  18386. argument<QString> (1,context)),
  18387. QScriptEngine::ScriptOwnership);
  18388. setDAQProperties(object,engine);
  18389. }
  18390. else
  18391. {
  18392. context->throwError("Incorrect number of arguments passed to DAQ"
  18393. "constructor. The DAQ constructor takes one"
  18394. "string as an argument specifying a device name."
  18395. "Example: Dev1");
  18396. }
  18397. return object;
  18398. }
  18399. /*:319*//*320:*/
  18400. #line 7220 "./typica.w"
  18401. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  18402. {
  18403. setQObjectProperties(value,engine);
  18404. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  18405. }
  18406. /*:320*//*321:*/
  18407. #line 7230 "./typica.w"
  18408. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  18409. {
  18410. DAQ*self= getself<DAQ*> (context);
  18411. QScriptValue object;
  18412. if(self)
  18413. {
  18414. object=
  18415. engine->newQObject(self->newChannel(argument<int> (0,context),
  18416. argument<int> (1,context)));
  18417. setChannelProperties(object,engine);
  18418. }
  18419. return object;
  18420. }
  18421. /*:321*//*328:*/
  18422. #line 7386 "./typica.w"
  18423. QScriptValue constructFakeDAQ(QScriptContext*context,
  18424. QScriptEngine*engine)
  18425. {
  18426. QScriptValue object;
  18427. if(context->argumentCount()==1)
  18428. {
  18429. object=
  18430. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  18431. QScriptEngine::ScriptOwnership);
  18432. setFakeDAQProperties(object,engine);
  18433. }
  18434. else
  18435. {
  18436. context->throwError("Incorrect number of arguments passed to DAQ"
  18437. "constructor. The DAQ constructor takes one"
  18438. "string as an argument specifying a device name."
  18439. "Example: Dev1");
  18440. }
  18441. return object;
  18442. }
  18443. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  18444. {
  18445. setQObjectProperties(value,engine);
  18446. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  18447. }
  18448. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  18449. {
  18450. FakeDAQ*self= getself<FakeDAQ*> (context);
  18451. QScriptValue object;
  18452. if(self)
  18453. {
  18454. object=
  18455. engine->newQObject(self->newChannel(argument<int> (0,context),
  18456. argument<int> (1,context)));
  18457. setChannelProperties(object,engine);
  18458. }
  18459. return object;
  18460. }
  18461. /*:328*//*332:*/
  18462. #line 7477 "./typica.w"
  18463. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  18464. {
  18465. setQObjectProperties(value,engine);
  18466. }
  18467. /*:332*//*339:*/
  18468. #line 7669 "./typica.w"
  18469. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  18470. {
  18471. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  18472. setLinearCalibratorProperties(object,engine);
  18473. return object;
  18474. }
  18475. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  18476. {
  18477. setQObjectProperties(value,engine);
  18478. }
  18479. /*:339*//*344:*/
  18480. #line 7807 "./typica.w"
  18481. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  18482. {
  18483. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  18484. setLinearSplineInterpolatorProperties(object,engine);
  18485. return object;
  18486. }
  18487. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  18488. {
  18489. setQObjectProperties(value,engine);
  18490. }
  18491. /*:344*//*354:*/
  18492. #line 8016 "./typica.w"
  18493. QScriptValue constructTemperatureDisplay(QScriptContext*,
  18494. QScriptEngine*engine)
  18495. {
  18496. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  18497. setTemperatureDisplayProperties(object,engine);
  18498. return object;
  18499. }
  18500. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  18501. {
  18502. setQLCDNumberProperties(value,engine);
  18503. value.setProperty("setDisplayUnits",
  18504. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  18505. }
  18506. /*:354*//*355:*/
  18507. #line 8040 "./typica.w"
  18508. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  18509. {
  18510. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  18511. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  18512. return QScriptValue();
  18513. }
  18514. /*:355*//*362:*/
  18515. #line 8177 "./typica.w"
  18516. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  18517. QScriptEngine*engine)
  18518. {
  18519. QScriptValue object=
  18520. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  18521. setMeasurementTimeOffsetProperties(object,engine);
  18522. return object;
  18523. }
  18524. void setMeasurementTimeOffsetProperties(QScriptValue value,
  18525. QScriptEngine*engine)
  18526. {
  18527. setQObjectProperties(value,engine);
  18528. }
  18529. /*:362*//*367:*/
  18530. #line 8296 "./typica.w"
  18531. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  18532. {
  18533. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  18534. return object;
  18535. }
  18536. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  18537. {
  18538. setQObjectProperties(value,engine);
  18539. }
  18540. /*:367*//*372:*/
  18541. #line 8393 "./typica.w"
  18542. QScriptValue constructZeroEmitter(QScriptContext*context,
  18543. QScriptEngine*engine)
  18544. {
  18545. QScriptValue object=
  18546. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  18547. setZeroEmitterProperties(object,engine);
  18548. return object;
  18549. }
  18550. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  18551. {
  18552. setQObjectProperties(value,engine);
  18553. }
  18554. /*:372*//*377:*/
  18555. #line 8473 "./typica.w"
  18556. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  18557. QScriptEngine*engine)
  18558. {
  18559. QScriptValue object=
  18560. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  18561. setMeasurementAdapterProperties(object,engine);
  18562. return object;
  18563. }
  18564. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  18565. {
  18566. setQObjectProperties(value,engine);
  18567. }
  18568. /*:377*//*394:*/
  18569. #line 8935 "./typica.w"
  18570. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  18571. {
  18572. QScriptValue object= engine->newQObject(new GraphView);
  18573. setGraphViewProperties(object,engine);
  18574. return object;
  18575. }
  18576. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  18577. {
  18578. setQGraphicsViewProperties(value,engine);
  18579. }
  18580. /*:394*//*417:*/
  18581. #line 9573 "./typica.w"
  18582. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  18583. {
  18584. QScriptValue object= engine->newQObject(new ZoomLog);
  18585. setZoomLogProperties(object,engine);
  18586. return object;
  18587. }
  18588. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  18589. {
  18590. setQTableViewProperties(value,engine);
  18591. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  18592. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  18593. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  18594. value.setProperty("restoreState",
  18595. engine->newFunction(ZoomLog_restoreState));
  18596. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  18597. value.setProperty("saveTemporary",
  18598. engine->newFunction(ZoomLog_saveTemporary));
  18599. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  18600. }
  18601. /*:417*//*418:*/
  18602. #line 9600 "./typica.w"
  18603. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  18604. {
  18605. ZoomLog*self= getself<ZoomLog*> (context);
  18606. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  18607. return QScriptValue(engine,retval);
  18608. }
  18609. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  18610. {
  18611. ZoomLog*self= getself<ZoomLog*> (context);
  18612. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  18613. return QScriptValue(engine,retval);
  18614. }
  18615. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  18616. QScriptEngine*engine)
  18617. {
  18618. ZoomLog*self= getself<ZoomLog*> (context);
  18619. QString filename= QDir::tempPath();
  18620. filename.append("/");
  18621. filename.append(QUuid::createUuid().toString());
  18622. filename.append(".xml");
  18623. QFile*file= new QFile(filename);
  18624. self->saveXML(file);
  18625. file->close();
  18626. delete file;
  18627. return QScriptValue(engine,filename);
  18628. }
  18629. /*:418*//*419:*/
  18630. #line 9648 "./typica.w"
  18631. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  18632. {
  18633. ZoomLog*self= getself<ZoomLog*> (context);
  18634. QString key= argument<QString> (0,context);
  18635. int columns= argument<int> (1,context);
  18636. QSettings settings;
  18637. for(int i= 0;i<columns;i++)
  18638. {
  18639. if(self->columnWidth(i))
  18640. {
  18641. settings.beginGroup(key);
  18642. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  18643. settings.endGroup();
  18644. }
  18645. }
  18646. return QScriptValue();
  18647. }
  18648. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  18649. {
  18650. ZoomLog*self= getself<ZoomLog*> (context);
  18651. QString key= argument<QString> (0,context);
  18652. int columns= argument<int> (1,context);
  18653. QSettings settings;
  18654. for(int i= 0;i<columns;i++)
  18655. {
  18656. settings.beginGroup(key);
  18657. self->setColumnWidth(i,
  18658. settings.value(QString("%1").arg(i),80).toInt());
  18659. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  18660. {
  18661. self->setColumnWidth(i,80);
  18662. }
  18663. settings.endGroup();
  18664. }
  18665. return QScriptValue();
  18666. }
  18667. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  18668. {
  18669. ZoomLog*self= getself<ZoomLog*> (context);
  18670. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  18671. }
  18672. /*:419*//*420:*/
  18673. #line 9701 "./typica.w"
  18674. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  18675. {
  18676. ZoomLog*self= getself<ZoomLog*> (context);
  18677. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  18678. return QScriptValue();
  18679. }
  18680. /*:420*//*455:*/
  18681. #line 10521 "./typica.w"
  18682. QScriptValue constructAnnotationButton(QScriptContext*context,
  18683. QScriptEngine*engine)
  18684. {
  18685. QScriptValue object=
  18686. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  18687. setAnnotationButtonProperties(object,engine);
  18688. return object;
  18689. }
  18690. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  18691. {
  18692. setQPushButtonProperties(value,engine);
  18693. }
  18694. /*:455*//*463:*/
  18695. #line 10664 "./typica.w"
  18696. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  18697. QScriptEngine*engine)
  18698. {
  18699. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  18700. argument<QString> (0,context),argument<QString> (1,context)));
  18701. setAnnotationSpinBoxProperties(object,engine);
  18702. return object;
  18703. }
  18704. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18705. {
  18706. setQDoubleSpinBoxProperties(value,engine);
  18707. }
  18708. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18709. {
  18710. setQAbstractSpinBoxProperties(value,engine);
  18711. }
  18712. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18713. {
  18714. setQWidgetProperties(value,engine);
  18715. }
  18716. /*:463*//*484:*/
  18717. #line 11087 "./typica.w"
  18718. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  18719. {
  18720. QScriptValue object= engine->newQObject(new TimerDisplay);
  18721. setTimerDisplayProperties(object,engine);
  18722. return object;
  18723. }
  18724. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  18725. {
  18726. setQLCDNumberProperties(value,engine);
  18727. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  18728. }
  18729. /*:484*//*485:*/
  18730. #line 11106 "./typica.w"
  18731. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  18732. {
  18733. TimerDisplay*self= getself<TimerDisplay*> (context);
  18734. if(self)
  18735. {
  18736. switch(argument<int> (0,context))
  18737. {
  18738. case 0:
  18739. self->setMode(TimerDisplay::CountUp);
  18740. break;
  18741. case 1:
  18742. self->setMode(TimerDisplay::CountDown);
  18743. break;
  18744. case 2:
  18745. self->setMode(TimerDisplay::Clock);
  18746. break;
  18747. default:
  18748. break;
  18749. }
  18750. }
  18751. return QScriptValue();
  18752. }
  18753. /*:485*//*512:*/
  18754. #line 11612 "./typica.w"
  18755. QScriptValue constructWidgetDecorator(QScriptContext*context,
  18756. QScriptEngine*engine)
  18757. {
  18758. QWidget*widget= argument<QWidget*> (0,context);
  18759. QString text= argument<QString> (1,context);
  18760. Qt::Orientations orientation;
  18761. switch(argument<int> (2,context))
  18762. {
  18763. case 2:
  18764. orientation= Qt::Vertical;
  18765. break;
  18766. default:
  18767. orientation= Qt::Horizontal;
  18768. break;
  18769. }
  18770. QScriptValue object=
  18771. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  18772. setWidgetDecoratorProperties(object,engine);
  18773. return object;
  18774. }
  18775. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  18776. {
  18777. setQWidgetProperties(value,engine);
  18778. }
  18779. /*:512*//*525:*/
  18780. #line 11893 "./typica.w"
  18781. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  18782. {
  18783. QScriptValue object= engine->newQObject(new LogEditWindow);
  18784. return object;
  18785. }
  18786. /*:525*//*544:*/
  18787. #line 12420 "./typica.w"
  18788. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  18789. {
  18790. QIODevice*device= argument<QIODevice*> (0,context);
  18791. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  18792. argument<int> (1,context)));
  18793. object.setProperty("input",engine->newFunction(XMLInput_input));
  18794. return object;
  18795. }
  18796. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  18797. {
  18798. XMLInput*self= getself<XMLInput*> (context);
  18799. self->input();
  18800. return QScriptValue();
  18801. }
  18802. /*:544*//*558:*/
  18803. #line 157 "./webview.w"
  18804. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  18805. {
  18806. QScriptValue object= engine->newQObject(new TypicaWebView);
  18807. setQWebViewProperties(object,engine);
  18808. return object;
  18809. }
  18810. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  18811. {
  18812. setQWidgetProperties(value,engine);
  18813. }
  18814. /*:558*//*559:*/
  18815. #line 174 "./webview.w"
  18816. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  18817. QStack<QLayout*> *layoutStack)
  18818. {
  18819. TypicaWebView*view= new TypicaWebView;
  18820. if(element.hasAttribute("id"))
  18821. {
  18822. view->setObjectName(element.attribute("id"));
  18823. }
  18824. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18825. layout->addWidget(view);
  18826. }
  18827. /*:559*//*564:*/
  18828. #line 225 "./webview.w"
  18829. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  18830. {
  18831. QVariant var;
  18832. var.setValue(element);
  18833. QScriptValue object= engine->newVariant(var);
  18834. return object;
  18835. }
  18836. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  18837. {
  18838. element= value.toVariant().value<QWebElement> ();
  18839. }
  18840. /*:564*//*569:*/
  18841. #line 290 "./webview.w"
  18842. template<> QWebElement argument(int arg,QScriptContext*context)
  18843. {
  18844. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  18845. }
  18846. /*:569*//*570:*/
  18847. #line 299 "./webview.w"
  18848. QScriptValue constructWebElement(QScriptContext*context,
  18849. QScriptEngine*engine)
  18850. {
  18851. QWebElement element= argument<QWebElement> (0,context);
  18852. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  18853. return object;
  18854. }
  18855. /*:570*//*638:*/
  18856. #line 13773 "./typica.w"
  18857. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  18858. {
  18859. QScriptValue object= engine->newQObject(new SqlQueryView);
  18860. setSqlQueryViewProperties(object,engine);
  18861. return object;
  18862. }
  18863. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  18864. {
  18865. setQTableViewProperties(value,engine);
  18866. value.setProperty("setHeaderData",
  18867. engine->newFunction(SqlQueryView_setHeaderData));
  18868. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  18869. }
  18870. /*:638*//*639:*/
  18871. #line 13791 "./typica.w"
  18872. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  18873. {
  18874. SqlQueryView*self= getself<SqlQueryView*> (context);
  18875. QString query= argument<QString> (0,context);
  18876. self->setQuery(query);
  18877. self->reset();
  18878. return QScriptValue();
  18879. }
  18880. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  18881. QScriptEngine*)
  18882. {
  18883. SqlQueryView*self= getself<SqlQueryView*> (context);
  18884. int section= argument<int> (0,context);
  18885. QString data= argument<QString> (1,context);
  18886. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  18887. return QScriptValue();
  18888. }
  18889. /*:639*//*647:*/
  18890. #line 14000 "./typica.w"
  18891. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  18892. QStack<QLayout*> *layoutStack)
  18893. {
  18894. QTextEdit*widget= new QTextEdit;
  18895. if(element.hasAttribute("id"))
  18896. {
  18897. widget->setObjectName(element.attribute("id"));
  18898. }
  18899. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18900. layout->addWidget(widget);
  18901. QTextDocument*document= new QTextDocument;
  18902. QFont defaultFont;
  18903. defaultFont.setPointSize(11);
  18904. document->setDefaultFont(defaultFont);
  18905. QTextCursor cursor(document);
  18906. /*648:*/
  18907. #line 14023 "./typica.w"
  18908. QDomNodeList children= element.childNodes();
  18909. for(int i= 0;i<children.count();i++)
  18910. {
  18911. QDomNode current;
  18912. QDomElement currentElement;
  18913. current= children.at(i);
  18914. if(current.isElement())
  18915. {
  18916. currentElement= current.toElement();
  18917. /*649:*/
  18918. #line 14040 "./typica.w"
  18919. if(currentElement.tagName()=="style")
  18920. {
  18921. document->setDefaultStyleSheet(currentElement.text());
  18922. }
  18923. /*:649*//*650:*/
  18924. #line 14051 "./typica.w"
  18925. if(currentElement.tagName()=="html")
  18926. {
  18927. cursor.insertHtml(currentElement.text());
  18928. }
  18929. /*:650*//*651:*/
  18930. #line 14061 "./typica.w"
  18931. if(currentElement.tagName()=="text")
  18932. {
  18933. cursor.insertText(currentElement.text());
  18934. }
  18935. /*:651*//*652:*/
  18936. #line 14071 "./typica.w"
  18937. if(currentElement.tagName()=="table")
  18938. {
  18939. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  18940. ReportTable*table= new ReportTable(frame,currentElement);
  18941. table->setParent(widget);
  18942. if(currentElement.hasAttribute("id"))
  18943. {
  18944. table->setObjectName(currentElement.attribute("id"));
  18945. }
  18946. }
  18947. /*:652*/
  18948. #line 14033 "./typica.w"
  18949. }
  18950. }
  18951. /*:648*/
  18952. #line 14016 "./typica.w"
  18953. widget->setDocument(document);
  18954. }
  18955. /*:647*//*663:*/
  18956. #line 14284 "./typica.w"
  18957. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  18958. {
  18959. QTextEdit*self= getself<QTextEdit*> (context);
  18960. QTextDocument*document= self->document();
  18961. QPrinter printer;
  18962. QPrintDialog printwindow(&printer,self);
  18963. if(printwindow.exec()!=QDialog::Accepted)
  18964. {
  18965. return QScriptValue();
  18966. }
  18967. document->print(&printer);
  18968. return QScriptValue();
  18969. }
  18970. /*:663*//*664:*/
  18971. #line 14302 "./typica.w"
  18972. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  18973. {
  18974. setQAbstractScrollAreaProperties(value,engine);
  18975. value.setProperty("print",engine->newFunction(QTextEdit_print));
  18976. }
  18977. #line 1 "./daterangeselector.w"
  18978. /*:664*//*683:*/
  18979. #line 463 "./daterangeselector.w"
  18980. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  18981. QStack<QLayout*> *layoutStack)
  18982. {
  18983. DateRangeSelector*widget= new DateRangeSelector;
  18984. if(element.hasAttribute("id"))
  18985. {
  18986. widget->setObjectName(element.attribute("id"));
  18987. }
  18988. if(element.hasAttribute("initial"))
  18989. {
  18990. widget->setCurrentIndex(element.attribute("initial").toInt());
  18991. }
  18992. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18993. layout->addWidget(widget);
  18994. }
  18995. /*:683*//*694:*/
  18996. #line 14482 "./typica.w"
  18997. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  18998. QStack<QLayout*> *layoutStack)
  18999. {
  19000. FormArray*widget= new FormArray(element);
  19001. if(element.hasAttribute("id"))
  19002. {
  19003. widget->setObjectName(element.attribute("id"));
  19004. }
  19005. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19006. layout->addWidget(widget);
  19007. }
  19008. /*:694*//*715:*/
  19009. #line 15069 "./typica.w"
  19010. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  19011. QStack<QLayout*> *layoutStack)
  19012. {
  19013. ScaleControl*scale= new ScaleControl;
  19014. if(element.hasAttribute("id"))
  19015. {
  19016. scale->setObjectName(element.attribute("id"));
  19017. }
  19018. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19019. layout->addWidget(scale);
  19020. }
  19021. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  19022. QStack<QLayout*> *layoutStack)
  19023. {
  19024. IntensityControl*scale= new IntensityControl;
  19025. if(element.hasAttribute("id"))
  19026. {
  19027. scale->setObjectName(element.attribute("id"));
  19028. }
  19029. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19030. layout->addWidget(scale);
  19031. }
  19032. /*:715*//*741:*/
  19033. #line 15659 "./typica.w"
  19034. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  19035. {
  19036. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  19037. setDeviceTreeModelProperties(object,engine);
  19038. return object;
  19039. }
  19040. /*:741*//*743:*/
  19041. #line 15682 "./typica.w"
  19042. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  19043. {
  19044. setQAbstractItemModelProperties(value,engine);
  19045. value.setProperty("referenceElement",
  19046. engine->newFunction(DeviceTreeModel_referenceElement));
  19047. }
  19048. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  19049. {
  19050. setQObjectProperties(value,engine);
  19051. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  19052. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  19053. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  19054. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  19055. }
  19056. /*:743*//*744:*/
  19057. #line 15709 "./typica.w"
  19058. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  19059. QScriptEngine*engine)
  19060. {
  19061. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  19062. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  19063. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  19064. QDomElement node;
  19065. QVariantMap retval;
  19066. retval.insert("driver",referenceElement.attribute("driver"));
  19067. for(int i= 0;i<configData.size();i++)
  19068. {
  19069. node= configData.at(i).toElement();
  19070. retval.insert(node.attribute("name"),node.attribute("value"));
  19071. }
  19072. return engine->toScriptValue(retval);
  19073. }
  19074. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  19075. {
  19076. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19077. QModelIndex index= argument<QModelIndex> (0,context);
  19078. int role= argument<int> (1,context);
  19079. return engine->toScriptValue(model->data(index,role));
  19080. }
  19081. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  19082. {
  19083. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19084. int row= 0;
  19085. int column= 0;
  19086. QModelIndex index;
  19087. if(context->argumentCount()> 1)
  19088. {
  19089. row= argument<int> (0,context);
  19090. column= argument<int> (1,context);
  19091. }
  19092. if(context->argumentCount()> 2)
  19093. {
  19094. index= argument<QModelIndex> (2,context);
  19095. }
  19096. QModelIndex retval= model->index(row,column,index);
  19097. return engine->toScriptValue(retval);
  19098. }
  19099. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  19100. QScriptEngine*)
  19101. {
  19102. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19103. QModelIndex index;
  19104. if(context->argumentCount()==1)
  19105. {
  19106. index= argument<QModelIndex> (0,context);
  19107. }
  19108. return QScriptValue(model->rowCount(index));
  19109. }
  19110. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  19111. QScriptEngine*engine)
  19112. {
  19113. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19114. QModelIndex index;
  19115. if(context->argumentCount()==1)
  19116. {
  19117. index= argument<QModelIndex> (0,context);
  19118. }
  19119. return QScriptValue(engine,model->hasChildren(index));
  19120. }
  19121. /*:744*//*747:*/
  19122. #line 15793 "./typica.w"
  19123. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  19124. {
  19125. QVariant var;
  19126. var.setValue(index);
  19127. QScriptValue object= engine->newVariant(var);
  19128. return object;
  19129. }
  19130. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  19131. {
  19132. index= value.toVariant().value<QModelIndex> ();
  19133. }
  19134. /*:747*//*763:*/
  19135. #line 16091 "./typica.w"
  19136. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  19137. QScriptEngine*engine)
  19138. {
  19139. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  19140. return object;
  19141. }
  19142. /*:763*//*834:*/
  19143. #line 47 "./settings.w"
  19144. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  19145. {
  19146. QScriptValue object= engine->newQObject(new SettingsWindow);
  19147. return object;
  19148. }
  19149. /*:834*//*859:*/
  19150. #line 18745 "./typica.w"
  19151. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  19152. {
  19153. QScriptValue object;
  19154. if(context->argumentCount()==2)
  19155. {
  19156. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  19157. argument<QModelIndex> (1,context)),
  19158. QScriptEngine::ScriptOwnership);
  19159. setModbusRTUDeviceProperties(object,engine);
  19160. }
  19161. else
  19162. {
  19163. context->throwError("Incorrect number of arguments passed to "
  19164. "ModbusRTUDevice constructor. This takes the configuration model "
  19165. "and an index.");
  19166. }
  19167. return object;
  19168. }
  19169. /*:859*//*860:*/
  19170. #line 18767 "./typica.w"
  19171. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  19172. {
  19173. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  19174. QScriptValue object;
  19175. if(self)
  19176. {
  19177. if(self->channels.size()> 0)
  19178. {
  19179. object= engine->newQObject(self->channels.at(0));
  19180. setChannelProperties(object,engine);
  19181. }
  19182. }
  19183. return object;
  19184. }
  19185. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  19186. {
  19187. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  19188. QScriptValue object;
  19189. if(self)
  19190. {
  19191. if(self->channels.size()> 1)
  19192. {
  19193. object= engine->newQObject(self->channels.at(1));
  19194. setChannelProperties(object,engine);
  19195. }
  19196. }
  19197. return object;
  19198. }
  19199. /*:860*//*861:*/
  19200. #line 18800 "./typica.w"
  19201. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  19202. {
  19203. setQObjectProperties(value,engine);
  19204. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  19205. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  19206. }
  19207. /*:861*//*877:*/
  19208. #line 653 "./modbus.w"
  19209. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine)
  19210. {
  19211. QScriptValue object;
  19212. if(context->argumentCount()==2)
  19213. {
  19214. object= engine->newQObject(new ModbusNG(argument<DeviceTreeModel*> (0,context),
  19215. argument<QModelIndex> (1,context)),
  19216. QScriptEngine::ScriptOwnership);
  19217. setModbusNGProperties(object,engine);
  19218. }
  19219. else
  19220. {
  19221. context->throwError("Incorrect number of arguments passed to "
  19222. "ModbusNG constructor.");
  19223. }
  19224. return object;
  19225. }
  19226. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine)
  19227. {
  19228. setQObjectProperties(value,engine);
  19229. value.setProperty("getChannel",engine->newFunction(ModbusNG_getChannel));
  19230. }
  19231. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine)
  19232. {
  19233. ModbusNG*self= getself<ModbusNG*> (context);
  19234. QScriptValue object;
  19235. if(self)
  19236. {
  19237. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19238. setChannelProperties(object,engine);
  19239. }
  19240. return object;
  19241. }
  19242. #line 19351 "./typica.w"
  19243. #line 1 "./unsupportedserial.w"
  19244. /*:877*//*891:*/
  19245. #line 357 "./unsupportedserial.w"
  19246. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  19247. {
  19248. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  19249. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  19250. QScriptValue object= engine->newQObject(device);
  19251. setQObjectProperties(object,engine);
  19252. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  19253. return object;
  19254. }
  19255. /*:891*//*896:*/
  19256. #line 430 "./unsupportedserial.w"
  19257. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  19258. {
  19259. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  19260. QScriptValue object;
  19261. if(self)
  19262. {
  19263. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19264. setChannelProperties(object,engine);
  19265. }
  19266. return object;
  19267. }
  19268. /*:896*//*903:*/
  19269. #line 630 "./unsupportedserial.w"
  19270. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  19271. {
  19272. return engine->toScriptValue<QTime> (QTime::currentTime());
  19273. }
  19274. /*:903*//*907:*/
  19275. #line 667 "./unsupportedserial.w"
  19276. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  19277. {
  19278. QScriptValue object= engine->newQObject(new QextSerialPort());
  19279. setSerialPortProperties(object,engine);
  19280. return object;
  19281. }
  19282. /*:907*//*908:*/
  19283. #line 678 "./unsupportedserial.w"
  19284. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  19285. {
  19286. setQIODeviceProperties(value,engine);
  19287. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  19288. }
  19289. /*:908*//*909:*/
  19290. #line 687 "./unsupportedserial.w"
  19291. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  19292. {
  19293. QextSerialPort*self= getself<QextSerialPort*> (context);
  19294. self->flush();
  19295. return QScriptValue();
  19296. }
  19297. /*:909*//*912:*/
  19298. #line 721 "./unsupportedserial.w"
  19299. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  19300. {
  19301. setQObjectProperties(value,engine);
  19302. }
  19303. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  19304. {
  19305. QScriptValue object= engine->newQObject(new QTimer);
  19306. setQTimerProperties(object,engine);
  19307. return object;
  19308. }
  19309. #line 19353 "./typica.w"
  19310. #line 1 "./phidgets.w"
  19311. /*:912*//*933:*/
  19312. #line 463 "./phidgets.w"
  19313. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  19314. {
  19315. if(context->argumentCount()!=1)
  19316. {
  19317. context->throwError("Incorrect number of arguments passed to "
  19318. "PhidgetsTemperatureSensor constructor. This takes "
  19319. "a QModelIndex.");
  19320. }
  19321. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  19322. setQObjectProperties(object,engine);
  19323. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  19324. return object;
  19325. }
  19326. /*:933*//*934:*/
  19327. #line 480 "./phidgets.w"
  19328. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  19329. {
  19330. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  19331. QScriptValue object;
  19332. if(self)
  19333. {
  19334. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19335. setChannelProperties(object,engine);
  19336. }
  19337. return object;
  19338. }
  19339. #line 19355 "./typica.w"
  19340. /*:934*//*966:*/
  19341. #line 151 "./rate.w"
  19342. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  19343. {
  19344. int cachetime= 1;
  19345. int scaletime= 1;
  19346. if(context->argumentCount()> 0)
  19347. {
  19348. cachetime= argument<int> (0,context);
  19349. if(context->argumentCount()> 1)
  19350. {
  19351. scaletime= argument<int> (1,context);
  19352. }
  19353. }
  19354. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  19355. setRateOfChangeProperties(object,engine);
  19356. return object;
  19357. }
  19358. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  19359. {
  19360. setQObjectProperties(value,engine);
  19361. }
  19362. /*:966*//*991:*/
  19363. #line 614 "./dataqsdk.w"
  19364. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  19365. {
  19366. QScriptValue object;
  19367. if(context->argumentCount()==1)
  19368. {
  19369. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  19370. QScriptEngine::ScriptOwnership);
  19371. setDataqSdkDeviceProperties(object,engine);
  19372. }
  19373. else
  19374. {
  19375. context->throwError("Incorrect number of arguments passed to "
  19376. "DataqSdkDevice. The constructor takes one string "
  19377. "as an argument specifying a device name. "
  19378. "Example: Dev1");
  19379. }
  19380. return object;
  19381. }
  19382. /*:991*//*992:*/
  19383. #line 637 "./dataqsdk.w"
  19384. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  19385. {
  19386. setQObjectProperties(value,engine);
  19387. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  19388. }
  19389. /*:992*//*993:*/
  19390. #line 647 "./dataqsdk.w"
  19391. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  19392. {
  19393. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  19394. QScriptValue object;
  19395. if(self)
  19396. {
  19397. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  19398. setChannelProperties(object,engine);
  19399. }
  19400. return object;
  19401. }
  19402. /*:993*//*1018:*/
  19403. #line 80 "./scales.w"
  19404. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  19405. {
  19406. QScriptValue object;
  19407. QString labelText= "";
  19408. if(context->argumentCount()==1)
  19409. {
  19410. labelText= argument<QString> (0,context);
  19411. }
  19412. object= engine->newQObject(new DragLabel(labelText));
  19413. setDragLabelProperties(object,engine);
  19414. return object;
  19415. }
  19416. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  19417. {
  19418. setQLabelProperties(value,engine);
  19419. }
  19420. /*:1018*//*1028:*/
  19421. #line 298 "./scales.w"
  19422. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  19423. {
  19424. return engine->newVariant(QVariant((int)(value)));
  19425. }
  19426. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  19427. {
  19428. value= (BaudRateType)(sv.toVariant().toInt());
  19429. }
  19430. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  19431. {
  19432. return engine->newVariant(QVariant((int)(value)));
  19433. }
  19434. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  19435. {
  19436. value= (DataBitsType)(sv.toVariant().toInt());
  19437. }
  19438. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  19439. {
  19440. return engine->newVariant(QVariant((int)(value)));
  19441. }
  19442. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  19443. {
  19444. value= (ParityType)(sv.toVariant().toInt());
  19445. }
  19446. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  19447. {
  19448. return engine->newVariant(QVariant((int)(value)));
  19449. }
  19450. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  19451. {
  19452. value= (StopBitsType)(sv.toVariant().toInt());
  19453. }
  19454. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  19455. {
  19456. return engine->newVariant(QVariant((int)(value)));
  19457. }
  19458. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  19459. {
  19460. value= (FlowType)(sv.toVariant().toInt());
  19461. }
  19462. /*:1028*//*1031:*/
  19463. #line 367 "./scales.w"
  19464. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  19465. {
  19466. setQIODeviceProperties(value,engine);
  19467. }
  19468. /*:1031*//*1032:*/
  19469. #line 375 "./scales.w"
  19470. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  19471. {
  19472. QScriptValue object;
  19473. if(context->argumentCount()==1)
  19474. {
  19475. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  19476. setSerialScaleProperties(object,engine);
  19477. }
  19478. else
  19479. {
  19480. context->throwError("Incorrect number of arguments passed to "
  19481. "SerialScale. The constructor takes one string "
  19482. "as an argument specifying a port name.");
  19483. }
  19484. return object;
  19485. }
  19486. /*:1032*//*1054:*/
  19487. #line 278 "./valueannotation.w"
  19488. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  19489. {
  19490. QScriptValue object= engine->newQObject(new ValueAnnotation);
  19491. setValueAnnotationProperties(object,engine);
  19492. return object;
  19493. }
  19494. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  19495. {
  19496. setQObjectProperties(value,engine);
  19497. }
  19498. #line 20002 "./typica.w"
  19499. #line 1 "./thresholdannotation.w"
  19500. /*:1054*//*1065:*/
  19501. #line 208 "./thresholdannotation.w"
  19502. QScriptValue constructAnnotator(QScriptContext*context,QScriptEngine*engine)
  19503. {
  19504. QScriptValue object= engine->newQObject(new Annotator(argument<QString> (0,context)));
  19505. setAnnotatorProperties(object,engine);
  19506. return object;
  19507. }
  19508. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine)
  19509. {
  19510. setQObjectProperties(value,engine);
  19511. }
  19512. #line 20004 "./typica.w"
  19513. /*:1065*/
  19514. #line 530 "./typica.w"
  19515. /*617:*/
  19516. #line 13408 "./typica.w"
  19517. void messageFileOutput(QtMsgType,const char*msg)
  19518. {
  19519. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  19520. output.open(QIODevice::WriteOnly|QIODevice::Append);
  19521. QTextStream outstream(&output);
  19522. outstream<<msg<<"\r\n";
  19523. }
  19524. /*:617*/
  19525. #line 531 "./typica.w"
  19526. /*614:*/
  19527. #line 13369 "./typica.w"
  19528. int main(int argc,char**argv)
  19529. {
  19530. int*c= &argc;
  19531. Application app(*c,argv);
  19532. QSettings settings;
  19533. /*615:*/
  19534. #line 13395 "./typica.w"
  19535. if(settings.value("settings/advanced/logging",false).toBool())
  19536. {
  19537. qInstallMsgHandler(messageFileOutput);
  19538. }
  19539. /*:615*/
  19540. #line 13375 "./typica.w"
  19541. /*618:*/
  19542. #line 13421 "./typica.w"
  19543. QStringList themeSearchPath= QIcon::themeSearchPaths();
  19544. themeSearchPath.append(":/resources/icons/tango");
  19545. QIcon::setThemeSearchPaths(themeSearchPath);
  19546. QIcon::setThemeName(":/resources/icons/tango");
  19547. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  19548. /*:618*/
  19549. #line 13376 "./typica.w"
  19550. /*619:*/
  19551. #line 13441 "./typica.w"
  19552. QFile entypo(":/resources/fonts/entypo.ttf");
  19553. entypo.open(QIODevice::ReadOnly);
  19554. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  19555. entypo.close();
  19556. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  19557. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  19558. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  19559. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  19560. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  19561. /*:619*/
  19562. #line 13377 "./typica.w"
  19563. /*773:*/
  19564. #line 16381 "./typica.w"
  19565. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  19566. /*:773*//*783:*/
  19567. #line 16623 "./typica.w"
  19568. app.registerDeviceConfigurationWidget("nidaqmxbase",
  19569. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  19570. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  19571. NiDaqMxBase9211ConfWidget::staticMetaObject);
  19572. app.registerDeviceConfigurationWidget("ni9211seriestc",
  19573. Ni9211TcConfWidget::staticMetaObject);
  19574. /*:783*//*791:*/
  19575. #line 16854 "./typica.w"
  19576. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  19577. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  19578. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  19579. /*:791*//*815:*/
  19580. #line 17823 "./typica.w"
  19581. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  19582. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  19583. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  19584. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  19585. /*:815*//*820:*/
  19586. #line 17908 "./typica.w"
  19587. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  19588. /*:820*//*823:*/
  19589. #line 17978 "./typica.w"
  19590. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  19591. /*:823*//*826:*/
  19592. #line 18105 "./typica.w"
  19593. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  19594. #line 1 "./freeannotation.w"
  19595. /*:826*//*830:*/
  19596. #line 57 "./freeannotation.w"
  19597. app.registerDeviceConfigurationWidget("freeannotation",
  19598. FreeAnnotationConfWidget::staticMetaObject);
  19599. #line 18109 "./typica.w"
  19600. #line 1 "./settings.w"
  19601. /*:830*//*864:*/
  19602. #line 19341 "./typica.w"
  19603. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  19604. /*:864*//*870:*/
  19605. #line 317 "./modbus.w"
  19606. app.registerDeviceConfigurationWidget("modbusngport",ModbusNGConfWidget::staticMetaObject);
  19607. app.registerDeviceConfigurationWidget("modbusnginput",
  19608. ModbusNGInputConfWidget::staticMetaObject);
  19609. /*:870*//*886:*/
  19610. #line 264 "./unsupportedserial.w"
  19611. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  19612. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  19613. app.registerDeviceConfigurationWidget("unsupporteddevice",
  19614. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  19615. /*:886*//*920:*/
  19616. #line 181 "./phidgets.w"
  19617. app.registerDeviceConfigurationWidget("phidgets1048",
  19618. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  19619. app.registerDeviceConfigurationWidget("phidgets1048channel",
  19620. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  19621. /*:920*//*940:*/
  19622. #line 19477 "./typica.w"
  19623. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  19624. /*:940*//*943:*/
  19625. #line 19537 "./typica.w"
  19626. app.registerDeviceConfigurationWidget("coolingtimer",
  19627. CoolingTimerConfWidget::staticMetaObject);
  19628. /*:943*//*948:*/
  19629. #line 19796 "./typica.w"
  19630. app.registerDeviceConfigurationWidget("rangetimer",
  19631. RangeTimerConfWidget::staticMetaObject);
  19632. /*:948*//*953:*/
  19633. #line 19897 "./typica.w"
  19634. app.registerDeviceConfigurationWidget("multirangetimer",
  19635. MultiRangeTimerConfWidget::staticMetaObject);
  19636. /*:953*//*958:*/
  19637. #line 19992 "./typica.w"
  19638. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  19639. #line 1 "./rate.w"
  19640. /*:958*//*970:*/
  19641. #line 253 "./rate.w"
  19642. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  19643. /*:970*//*1011:*/
  19644. #line 1233 "./dataqsdk.w"
  19645. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  19646. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  19647. DataqSdkChannelConfWidget::staticMetaObject);
  19648. /*:1011*//*1036:*/
  19649. #line 552 "./scales.w"
  19650. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  19651. /*:1036*//*1044:*/
  19652. #line 138 "./valueannotation.w"
  19653. app.registerDeviceConfigurationWidget("valueannotation",
  19654. ValueAnnotationConfWidget::staticMetaObject);
  19655. /*:1044*//*1058:*/
  19656. #line 109 "./thresholdannotation.w"
  19657. app.registerDeviceConfigurationWidget("thresholdannotation",
  19658. ThresholdAnnotationConfWidget::staticMetaObject);
  19659. /*:1058*/
  19660. #line 13379 "./typica.w"
  19661. /*620:*/
  19662. #line 13458 "./typica.w"
  19663. if(settings.value("database/exists","false").toString()=="true")
  19664. {
  19665. /*625:*/
  19666. #line 13587 "./typica.w"
  19667. QSqlDatabase database=
  19668. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  19669. database.setConnectOptions("application_name=Typica");
  19670. database.setHostName(settings.value("database/hostname").toString());
  19671. database.setPort(settings.value("database/portnumber",5432).toInt());
  19672. database.setDatabaseName(settings.value("database/dbname").toString());
  19673. database.setUserName(settings.value("database/user").toString());
  19674. database.setPassword(settings.value("database/password").toString());
  19675. if(!database.open())
  19676. {
  19677. settings.setValue("database/exists","false");
  19678. }
  19679. else
  19680. {
  19681. database.close();
  19682. }
  19683. /*:625*/
  19684. #line 13461 "./typica.w"
  19685. }
  19686. if(settings.value("database/exists","false").toString()=="false")
  19687. {
  19688. /*624:*/
  19689. #line 13578 "./typica.w"
  19690. SqlConnectionSetup dialog;
  19691. dialog.exec();
  19692. /*:624*/
  19693. #line 13465 "./typica.w"
  19694. }
  19695. /*:620*/
  19696. #line 13380 "./typica.w"
  19697. /*189:*/
  19698. #line 4335 "./typica.w"
  19699. QStringList arguments= QCoreApplication::arguments();
  19700. int position= arguments.indexOf("-c");
  19701. QString filename= QString();
  19702. if(position!=-1)
  19703. {
  19704. if(arguments.size()>=position+1)
  19705. {
  19706. filename= arguments.at(position+1);
  19707. }
  19708. }
  19709. if(filename.isEmpty())
  19710. {
  19711. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  19712. settings.value("config","").toString());
  19713. }
  19714. QDir directory;
  19715. if(!filename.isEmpty())
  19716. {
  19717. QFile file(filename);
  19718. QFileInfo info(filename);
  19719. directory= info.dir();
  19720. QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
  19721. QTranslator*configtr= new QTranslator;
  19722. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  19723. QString("%1/Translations").arg(directory.canonicalPath())))
  19724. {
  19725. QCoreApplication::installTranslator(configtr);
  19726. }
  19727. settings.setValue("config",directory.path());
  19728. if(file.open(QIODevice::ReadOnly))
  19729. {
  19730. app.configuration()->setContent(&file,true);
  19731. }
  19732. }
  19733. /*190:*/
  19734. #line 4376 "./typica.w"
  19735. QDomElement root= app.configuration()->documentElement();
  19736. QDomNodeList children= root.childNodes();
  19737. QString replacementDoc;
  19738. QDomDocument includedDoc;
  19739. QDomDocumentFragment fragment;
  19740. for(int i= 0;i<children.size();i++)
  19741. {
  19742. QDomNode currentNode= children.at(i);
  19743. QDomElement currentElement;
  19744. if(currentNode.nodeName()=="include")
  19745. {
  19746. currentElement= currentNode.toElement();
  19747. if(currentElement.hasAttribute("src"))
  19748. {
  19749. replacementDoc= directory.path();
  19750. replacementDoc.append('/');
  19751. replacementDoc.append(currentElement.attribute("src"));
  19752. QFile doc(replacementDoc);
  19753. if(doc.open(QIODevice::ReadOnly))
  19754. {
  19755. includedDoc.setContent(&doc,true);
  19756. fragment= includedDoc.createDocumentFragment();
  19757. fragment.appendChild(includedDoc.documentElement());
  19758. root.replaceChild(fragment,currentNode);
  19759. doc.close();
  19760. }
  19761. }
  19762. }
  19763. }
  19764. /*:190*/
  19765. #line 4370 "./typica.w"
  19766. /*:189*/
  19767. #line 13381 "./typica.w"
  19768. /*7:*/
  19769. #line 663 "./typica.w"
  19770. QScriptEngine*engine= new QScriptEngine;
  19771. QScriptValue constructor;
  19772. QScriptValue value;
  19773. /*:7*//*17:*/
  19774. #line 860 "./typica.w"
  19775. constructor= engine->newFunction(constructQWidget);
  19776. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  19777. engine->globalObject().setProperty("QWidget",value);
  19778. /*:17*//*21:*/
  19779. #line 947 "./typica.w"
  19780. constructor= engine->newFunction(displayWarning);
  19781. engine->globalObject().setProperty("displayWarning",constructor);
  19782. constructor= engine->newFunction(displayError);
  19783. engine->globalObject().setProperty("displayError",constructor);
  19784. /*:21*//*31:*/
  19785. #line 1153 "./typica.w"
  19786. constructor= engine->newFunction(constructQMainWindow);
  19787. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  19788. constructor);
  19789. engine->globalObject().setProperty("QMainWindow",value);
  19790. /*:31*//*42:*/
  19791. #line 1358 "./typica.w"
  19792. constructor= engine->newFunction(constructQFrame);
  19793. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  19794. engine->globalObject().setProperty("QFrame",value);
  19795. /*:42*//*45:*/
  19796. #line 1391 "./typica.w"
  19797. constructor= engine->newFunction(constructQLabel);
  19798. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  19799. engine->globalObject().setProperty("QLabel",value);
  19800. /*:45*//*48:*/
  19801. #line 1434 "./typica.w"
  19802. constructor= engine->newFunction(constructQSvgWidget);
  19803. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  19804. engine->globalObject().setProperty("QSvgWidget",value);
  19805. /*:48*//*54:*/
  19806. #line 1516 "./typica.w"
  19807. constructor= engine->newFunction(constructQLineEdit);
  19808. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  19809. engine->globalObject().setProperty("QLineEdit",value);
  19810. /*:54*//*58:*/
  19811. #line 1563 "./typica.w"
  19812. constructor= engine->newFunction(constructQSplitter);
  19813. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  19814. engine->globalObject().setProperty("QSplitter",value);
  19815. /*:58*//*66:*/
  19816. #line 1752 "./typica.w"
  19817. constructor= engine->newFunction(constructQBoxLayout);
  19818. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  19819. engine->globalObject().setProperty("QBoxLayout",value);
  19820. /*:66*//*70:*/
  19821. #line 1864 "./typica.w"
  19822. constructor= engine->newFunction(constructQAction);
  19823. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  19824. engine->globalObject().setProperty("QAction",value);
  19825. /*:70*//*73:*/
  19826. #line 1923 "./typica.w"
  19827. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  19828. value.setProperty("getOpenFileName",
  19829. engine->newFunction(QFileDialog_getOpenFileName));
  19830. value.setProperty("getSaveFileName",
  19831. engine->newFunction(QFileDialog_getSaveFileName));
  19832. engine->globalObject().setProperty("QFileDialog",value);
  19833. /*:73*//*78:*/
  19834. #line 2041 "./typica.w"
  19835. constructor= engine->newFunction(constructQFile);
  19836. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  19837. engine->globalObject().setProperty("QFile",value);
  19838. /*:78*//*89:*/
  19839. #line 2259 "./typica.w"
  19840. constructor= engine->newFunction(constructQProcess);
  19841. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  19842. engine->globalObject().setProperty("QProcess",value);
  19843. /*:89*//*98:*/
  19844. #line 2408 "./typica.w"
  19845. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  19846. constructor= engine->newFunction(constructQByteArray);
  19847. engine->globalObject().setProperty("QByteArray",constructor);
  19848. /*:98*//*110:*/
  19849. #line 2650 "./typica.w"
  19850. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  19851. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  19852. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  19853. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  19854. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  19855. /*:110*//*113:*/
  19856. #line 2753 "./typica.w"
  19857. constructor= engine->newFunction(constructQBuffer);
  19858. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  19859. engine->globalObject().setProperty("QBuffer",value);
  19860. /*:113*//*116:*/
  19861. #line 2802 "./typica.w"
  19862. constructor= engine->newFunction(constructXQuery);
  19863. engine->globalObject().setProperty("XQuery",constructor);
  19864. /*:116*//*122:*/
  19865. #line 2904 "./typica.w"
  19866. constructor= engine->newFunction(constructXmlWriter);
  19867. engine->globalObject().setProperty("XmlWriter",constructor);
  19868. /*:122*//*131:*/
  19869. #line 3110 "./typica.w"
  19870. constructor= engine->newFunction(constructXmlReader);
  19871. engine->globalObject().setProperty("XmlReader",constructor);
  19872. /*:131*//*138:*/
  19873. #line 3234 "./typica.w"
  19874. value= engine->newQObject(&settings);
  19875. setQSettingsProperties(value,engine);
  19876. engine->globalObject().setProperty("QSettings",value);
  19877. /*:138*//*142:*/
  19878. #line 3315 "./typica.w"
  19879. constructor= engine->newFunction(constructQLCDNumber);
  19880. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  19881. engine->globalObject().setProperty("QLCDNumber",value);
  19882. /*:142*//*145:*/
  19883. #line 3371 "./typica.w"
  19884. constructor= engine->newFunction(constructQTime);
  19885. engine->globalObject().setProperty("QTime",constructor);
  19886. /*:145*//*167:*/
  19887. #line 3884 "./typica.w"
  19888. constructor= engine->newFunction(constructQPushButton);
  19889. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  19890. engine->globalObject().setProperty("QPushButton",value);
  19891. /*:167*//*174:*/
  19892. #line 3995 "./typica.w"
  19893. constructor= engine->newFunction(constructQSqlQuery);
  19894. engine->globalObject().setProperty("QSqlQuery",constructor);
  19895. /*:174*//*181:*/
  19896. #line 4159 "./typica.w"
  19897. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  19898. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  19899. engine->globalObject().setProperty("sqlToArray",
  19900. engine->newFunction(sqlToArray));
  19901. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  19902. engine->globalObject().setProperty("annotationFromRecord",
  19903. engine->newFunction(annotationFromRecord));
  19904. engine->globalObject().setProperty("setTabOrder",
  19905. engine->newFunction(setTabOrder));
  19906. engine->globalObject().setProperty("saveFileFromDatabase",
  19907. engine->newFunction(saveFileFromDatabase));
  19908. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  19909. /*:181*//*194:*/
  19910. #line 4543 "./typica.w"
  19911. engine->globalObject().setProperty("createWindow",
  19912. engine->newFunction(createWindow));
  19913. engine->globalObject().setProperty("createReport",
  19914. engine->newFunction(createReport));
  19915. /*:194*//*259:*/
  19916. #line 6181 "./typica.w"
  19917. engine->globalObject().setProperty("findChildObject",
  19918. engine->newFunction(findChildObject));
  19919. /*:259*//*285:*/
  19920. #line 389 "./units.w"
  19921. value= engine->newQMetaObject(&Units::staticMetaObject);
  19922. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  19923. value.setProperty("convertRelativeTemperature",
  19924. engine->newFunction(Units_convertRelativeTemperature));
  19925. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  19926. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  19927. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  19928. engine->globalObject().setProperty("Units",value);
  19929. /*:285*//*290:*/
  19930. #line 462 "./units.w"
  19931. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  19932. #line 6605 "./typica.w"
  19933. /*:290*//*298:*/
  19934. #line 141 "./measurement.w"
  19935. constructor= engine->newFunction(constructMeasurement);
  19936. engine->globalObject().setProperty("Measurement",constructor);
  19937. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  19938. /*:298*//*318:*/
  19939. #line 7176 "./typica.w"
  19940. constructor= engine->newFunction(constructDAQ);
  19941. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  19942. value.setProperty("Fahrenheit",Units::Fahrenheit);
  19943. value.setProperty("Celsius",Units::Celsius);
  19944. value.setProperty("Kelvin",Units::Kelvin);
  19945. value.setProperty("Rankine",Units::Rankine);
  19946. engine->globalObject().setProperty("DAQ",value);
  19947. /*:318*//*327:*/
  19948. #line 7378 "./typica.w"
  19949. constructor= engine->newFunction(constructFakeDAQ);
  19950. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  19951. engine->globalObject().setProperty("FakeDAQ",value);
  19952. /*:327*//*338:*/
  19953. #line 7661 "./typica.w"
  19954. constructor= engine->newFunction(constructLinearCalibrator);
  19955. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  19956. constructor);
  19957. engine->globalObject().setProperty("LinearCalibrator",value);
  19958. /*:338*//*343:*/
  19959. #line 7800 "./typica.w"
  19960. constructor= engine->newFunction(constructLinearSplineInterpolator);
  19961. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  19962. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  19963. /*:343*//*353:*/
  19964. #line 8008 "./typica.w"
  19965. constructor= engine->newFunction(constructTemperatureDisplay);
  19966. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  19967. constructor);
  19968. engine->globalObject().setProperty("TemperatureDisplay",value);
  19969. /*:353*//*361:*/
  19970. #line 8166 "./typica.w"
  19971. constructor= engine->newFunction(constructMeasurementTimeOffset);
  19972. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  19973. constructor);
  19974. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  19975. /*:361*//*366:*/
  19976. #line 8287 "./typica.w"
  19977. constructor= engine->newFunction(constructThresholdDetector);
  19978. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  19979. engine->globalObject().setProperty("ThresholdDetector",value);
  19980. /*:366*//*371:*/
  19981. #line 8386 "./typica.w"
  19982. constructor= engine->newFunction(constructZeroEmitter);
  19983. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  19984. engine->globalObject().setProperty("ZeroEmitter",value);
  19985. /*:371*//*376:*/
  19986. #line 8465 "./typica.w"
  19987. constructor= engine->newFunction(constructMeasurementAdapter);
  19988. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  19989. constructor);
  19990. engine->globalObject().setProperty("MeasurementAdapter",value);
  19991. /*:376*//*393:*/
  19992. #line 8928 "./typica.w"
  19993. constructor= engine->newFunction(constructGraphView);
  19994. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  19995. engine->globalObject().setProperty("GraphView",value);
  19996. /*:393*//*416:*/
  19997. #line 9565 "./typica.w"
  19998. constructor= engine->newFunction(constructZoomLog);
  19999. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  20000. engine->globalObject().setProperty("ZoomLog",value);
  20001. /*:416*//*454:*/
  20002. #line 10513 "./typica.w"
  20003. constructor= engine->newFunction(constructAnnotationButton);
  20004. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  20005. constructor);
  20006. engine->globalObject().setProperty("AnnotationButton",value);
  20007. /*:454*//*462:*/
  20008. #line 10655 "./typica.w"
  20009. constructor= engine->newFunction(constructAnnotationSpinBox);
  20010. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  20011. constructor);
  20012. engine->globalObject().setProperty("AnnotationSpinBox",value);
  20013. /*:462*//*483:*/
  20014. #line 11080 "./typica.w"
  20015. constructor= engine->newFunction(constructTimerDisplay);
  20016. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  20017. engine->globalObject().setProperty("TimerDisplay",value);
  20018. /*:483*//*511:*/
  20019. #line 11604 "./typica.w"
  20020. constructor= engine->newFunction(constructWidgetDecorator);
  20021. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  20022. engine->globalObject().setProperty("WidgetDecorator",value);
  20023. /*:511*//*524:*/
  20024. #line 11886 "./typica.w"
  20025. constructor= engine->newFunction(constructLogEditWindow);
  20026. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  20027. engine->globalObject().setProperty("LogEditWindow",value);
  20028. /*:524*//*543:*/
  20029. #line 12413 "./typica.w"
  20030. constructor= engine->newFunction(constructXMLInput);
  20031. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  20032. engine->globalObject().setProperty("XMLInput",value);
  20033. /*:543*//*557:*/
  20034. #line 149 "./webview.w"
  20035. constructor= engine->newFunction(constructWebView);
  20036. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  20037. engine->globalObject().setProperty("WebView",value);
  20038. /*:557*//*565:*/
  20039. #line 241 "./webview.w"
  20040. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  20041. /*:565*//*568:*/
  20042. #line 283 "./webview.w"
  20043. constructor= engine->newFunction(constructWebElement);
  20044. engine->globalObject().setProperty("WebElement",constructor);
  20045. /*:568*//*579:*/
  20046. #line 12656 "./typica.w"
  20047. value= engine->newQObject(AppInstance);
  20048. engine->globalObject().setProperty("Application",value);
  20049. /*:579*//*637:*/
  20050. #line 13765 "./typica.w"
  20051. constructor= engine->newFunction(constructSqlQueryView);
  20052. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  20053. engine->globalObject().setProperty("SqlQueryView",value);
  20054. /*:637*//*742:*/
  20055. #line 15669 "./typica.w"
  20056. constructor= engine->newFunction(constructDeviceTreeModel);
  20057. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  20058. constructor);
  20059. engine->globalObject().setProperty("DeviceTreeModel",value);
  20060. /*:742*//*748:*/
  20061. #line 15809 "./typica.w"
  20062. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  20063. /*:748*//*764:*/
  20064. #line 16101 "./typica.w"
  20065. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  20066. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  20067. constructor);
  20068. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  20069. /*:764*//*835:*/
  20070. #line 56 "./settings.w"
  20071. constructor= engine->newFunction(constructSettingsWindow);
  20072. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  20073. engine->globalObject().setProperty("SettingsWindow",value);
  20074. #line 1 "./graphsettings.w"
  20075. /*:835*//*858:*/
  20076. #line 18736 "./typica.w"
  20077. constructor= engine->newFunction(constructModbusRTUDevice);
  20078. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  20079. engine->globalObject().setProperty("ModbusRTUDevice",value);
  20080. /*:858*//*876:*/
  20081. #line 645 "./modbus.w"
  20082. constructor= engine->newFunction(constructModbusNG);
  20083. value= engine->newQMetaObject(&ModbusNG::staticMetaObject,constructor);
  20084. engine->globalObject().setProperty("ModbusNG",value);
  20085. /*:876*//*890:*/
  20086. #line 350 "./unsupportedserial.w"
  20087. engine->globalObject().setProperty("createDevice",
  20088. engine->newFunction(createDevice));
  20089. /*:890*//*902:*/
  20090. #line 622 "./unsupportedserial.w"
  20091. engine->globalObject().setProperty("getMeasurementTimestamp",
  20092. engine->newFunction(getMeasurementTimestamp));
  20093. /*:902*//*906:*/
  20094. #line 658 "./unsupportedserial.w"
  20095. constructor= engine->newFunction(constructSerialPort);
  20096. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  20097. engine->globalObject().setProperty("SerialPort",value);
  20098. /*:906*//*911:*/
  20099. #line 713 "./unsupportedserial.w"
  20100. constructor= engine->newFunction(constructQTimer);
  20101. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  20102. engine->globalObject().setProperty("Timer",value);
  20103. /*:911*//*931:*/
  20104. #line 450 "./phidgets.w"
  20105. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  20106. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  20107. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  20108. /*:931*//*965:*/
  20109. #line 144 "./rate.w"
  20110. constructor= engine->newFunction(constructRateOfChange);
  20111. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  20112. engine->globalObject().setProperty("RateOfChange",value);
  20113. /*:965*//*990:*/
  20114. #line 604 "./dataqsdk.w"
  20115. constructor= engine->newFunction(constructDataqSdkDevice);
  20116. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  20117. engine->globalObject().setProperty("DataqSdkDevice",value);
  20118. /*:990*//*1017:*/
  20119. #line 73 "./scales.w"
  20120. constructor= engine->newFunction(constructDragLabel);
  20121. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  20122. engine->globalObject().setProperty("DragLabel",value);
  20123. /*:1017*//*1025:*/
  20124. #line 265 "./scales.w"
  20125. constructor= engine->newFunction(constructSerialScale);
  20126. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  20127. engine->globalObject().setProperty("SerialScale",value);
  20128. /*:1025*//*1029:*/
  20129. #line 351 "./scales.w"
  20130. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  20131. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  20132. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  20133. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  20134. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  20135. /*:1029*//*1053:*/
  20136. #line 271 "./valueannotation.w"
  20137. constructor= engine->newFunction(constructValueAnnotation);
  20138. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  20139. engine->globalObject().setProperty("ValueAnnotation",value);
  20140. /*:1053*//*1064:*/
  20141. #line 201 "./thresholdannotation.w"
  20142. constructor= engine->newFunction(constructAnnotator);
  20143. value= engine->newQMetaObject(&Annotator::staticMetaObject,constructor);
  20144. engine->globalObject().setProperty("Annotator",value);
  20145. /*:1064*/
  20146. #line 13382 "./typica.w"
  20147. app.engine= engine;
  20148. /*191:*/
  20149. #line 4424 "./typica.w"
  20150. QString styleText;
  20151. QString programText;
  20152. QDomElement currentElement;
  20153. for(int i= 0;i<children.size();i++)
  20154. {
  20155. QDomNode currentNode= children.at(i);
  20156. if(currentNode.nodeName()=="style")
  20157. {
  20158. currentElement= currentNode.toElement();
  20159. styleText.append(currentElement.text());
  20160. }
  20161. else if(currentNode.nodeName()=="program")
  20162. {
  20163. currentElement= currentNode.toElement();
  20164. programText.append(currentElement.text());
  20165. }
  20166. }
  20167. app.setStyleSheet(styleText);
  20168. QScriptValue result= engine->evaluate(programText);
  20169. /*192:*/
  20170. #line 4449 "./typica.w"
  20171. if(engine->hasUncaughtException())
  20172. {
  20173. int line= engine->uncaughtExceptionLineNumber();
  20174. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  20175. result.toString();
  20176. QString trace;
  20177. foreach(trace,engine->uncaughtExceptionBacktrace())
  20178. {
  20179. qDebug()<<trace;
  20180. }
  20181. }
  20182. /*:192*/
  20183. #line 4444 "./typica.w"
  20184. /*:191*/
  20185. #line 13384 "./typica.w"
  20186. int retval= app.exec();
  20187. delete engine;
  20188. return retval;
  20189. }
  20190. /*:614*/
  20191. #line 532 "./typica.w"
  20192. #include "moc_typica.cpp"
  20193. /*:3*/