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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 622 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. #include <QtSvg>
  16. #include <QtNetwork>
  17. /*:5*//*6:*/
  18. #line 639 "./typica.w"
  19. #include "helpmenu.h"
  20. /*:6*//*304:*/
  21. #line 6887 "./typica.w"
  22. #include "units.h"
  23. #line 1 "./measurement.w"
  24. /*:304*//*575:*/
  25. #line 212 "./webview.w"
  26. #include "webview.h"
  27. /*:575*//*588:*/
  28. #line 390 "./webview.w"
  29. #include "webelement.h"
  30. #line 12875 "./typica.w"
  31. #line 1 "./printerselector.w"
  32. /*:588*//*590:*/
  33. #line 40 "./printerselector.w"
  34. #include "printerselector.h"
  35. /*:590*//*721:*/
  36. #line 487 "./daterangeselector.w"
  37. #include "daterangeselector.h"
  38. #line 14754 "./typica.w"
  39. /*:721*//*829:*/
  40. #line 17325 "./typica.w"
  41. #include "qextserialport.h"
  42. #include "qextserialenumerator.h"
  43. /*:829*//*1059:*/
  44. #line 124 "./dataqsdk.w"
  45. #ifdef Q_OS_WIN32
  46. #include <windef.h>
  47. #else
  48. #define PASCAL
  49. #endif
  50. /*:1059*//*1083:*/
  51. #line 862 "./dataqsdk.w"
  52. #include <limits>
  53. /*:1083*//*1098:*/
  54. #line 62 "./scales.w"
  55. #include "draglabel.h"
  56. /*:1098*//*1113:*/
  57. #line 361 "./scales.w"
  58. #include "scale.h"
  59. /*:1113*/
  60. #line 525 "./typica.w"
  61. /*977:*/
  62. #line 114 "./phidget22.w"
  63. #if defined(__stdcall)
  64. #define CCONV __stdcall
  65. #else
  66. #if defined(_MSC_VER)
  67. #define CCONV __stdcall
  68. #else
  69. #define CCONV
  70. #endif
  71. #endif
  72. typedef int(CCONV*PhidgetPointer)(void*);
  73. typedef int(CCONV*PhidgetPointerStringOut)(void*,char**);
  74. typedef int(CCONV*PhidgetPointerIntOut)(void*,int*);
  75. typedef void(CCONV*PhidgetManagerCallback)(void*,void*,void*);
  76. typedef void(CCONV*PhidgetValueCallback)(void*,void*,double);
  77. typedef int(CCONV*PhidgetPointerCallbackPointer)(void*,
  78. PhidgetManagerCallback,
  79. void*);
  80. typedef int(CCONV*PhidgetPointerVCPointer)(void*,
  81. PhidgetValueCallback,
  82. void*);
  83. typedef int(CCONV*PhidgetPointerIntIn)(void*,int);
  84. /*:977*/
  85. #line 526 "./typica.w"
  86. /*982:*/
  87. #line 220 "./phidget22.w"
  88. void CCONV ChannelListAddChannel(void*manager,void*context,void*device);
  89. void CCONV ChannelListRemoveChannel(void*manager,void*context,
  90. void*device);
  91. /*:982*//*997:*/
  92. #line 773 "./phidget22.w"
  93. void CCONV Phidget22ValueCallback(void*device,void*context,double value);
  94. /*:997*/
  95. #line 527 "./typica.w"
  96. /*26:*/
  97. #line 1070 "./typica.w"
  98. class ScriptQMainWindow:public QMainWindow
  99. {
  100. Q_OBJECT
  101. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  102. public:
  103. ScriptQMainWindow();
  104. QString closePrompt();
  105. public slots:
  106. void show();
  107. void saveSizeAndPosition(const QString&key);
  108. void restoreSizeAndPosition(const QString&key);
  109. void displayStatus(const QString&message= QString());
  110. void setClosePrompt(QString prompt);
  111. void setupFinished();
  112. signals:
  113. void aboutToClose(void);
  114. void windowReady(void);
  115. protected:
  116. void closeEvent(QCloseEvent*event);
  117. void showEvent(QShowEvent*event);
  118. private:
  119. QString cprompt;
  120. };
  121. /*:26*//*173:*/
  122. #line 4038 "./typica.w"
  123. class SqlQueryConnection:public QSqlQuery
  124. {
  125. public:
  126. SqlQueryConnection(const QString&query= QString());
  127. ~SqlQueryConnection();
  128. QSqlQuery*operator->()const;
  129. private:
  130. QString connection;
  131. QSqlQuery*q;
  132. };
  133. /*:173*//*250:*/
  134. #line 6044 "./typica.w"
  135. class NumericDelegate:public QItemDelegate
  136. {
  137. Q_OBJECT
  138. public:
  139. NumericDelegate(QObject*parent= NULL);
  140. QWidget*createEditor(QWidget*parent,
  141. const QStyleOptionViewItem&option,
  142. const QModelIndex&index)const;
  143. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  144. void setModelData(QWidget*editor,QAbstractItemModel*model,
  145. const QModelIndex&index)const;
  146. void updateEditorGeometry(QWidget*editor,
  147. const QStyleOptionViewItem&option,
  148. const QModelIndex&index)const;
  149. };
  150. /*:250*//*256:*/
  151. #line 6137 "./typica.w"
  152. class ScriptValidator:public QValidator
  153. {
  154. Q_OBJECT
  155. public:
  156. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  157. void fixup(QString&input)const;
  158. QValidator::State validate(QString&input,int&pos)const;
  159. private:
  160. QValidator*v;
  161. };
  162. /*:256*//*300:*/
  163. #line 438 "./units.w"
  164. Q_DECLARE_METATYPE(Units::Unit)
  165. /*:300*//*305:*/
  166. #line 19 "./measurement.w"
  167. class Measurement:public QVariantMap
  168. {
  169. public:
  170. Measurement(double temperature= 0,QTime time= QTime(),
  171. Units::Unit sc= Units::Fahrenheit);
  172. Measurement(double temperature);
  173. double temperature()const;
  174. QTime time()const;
  175. void setTemperature(double temperature);
  176. void setTime(QTime time);
  177. void setUnit(Units::Unit scale);
  178. Units::Unit scale()const;
  179. Measurement toFahrenheit();
  180. Measurement toCelsius();
  181. Measurement toKelvin();
  182. Measurement toRankine();
  183. };
  184. /*:305*//*309:*/
  185. #line 128 "./measurement.w"
  186. Q_DECLARE_METATYPE(Measurement)
  187. /*:309*//*316:*/
  188. #line 6951 "./typica.w"
  189. class Channel;
  190. class DAQImplementation;
  191. class DAQ:public QObject
  192. {
  193. Q_OBJECT
  194. Q_ENUMS(ThermocoupleType)
  195. DAQImplementation*imp;
  196. private slots:
  197. void threadFinished();
  198. public:
  199. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  200. ~DAQ();
  201. Channel*newChannel(int units,int thermocouple);
  202. Q_INVOKABLE void setClockRate(double Hz);
  203. Q_INVOKABLE void start();
  204. Q_INVOKABLE void stop();
  205. enum ThermocoupleType
  206. {
  207. TypeJ= 10072,
  208. TypeK= 10073,
  209. TypeN= 10077,
  210. TypeR= 10082,
  211. TypeS= 10085,
  212. TypeT= 10086,
  213. TypeB= 10047,
  214. TypeE= 10055
  215. };
  216. };
  217. /*:316*//*317:*/
  218. #line 6989 "./typica.w"
  219. class DAQImplementation:public QThread
  220. {
  221. Q_OBJECT
  222. public:
  223. DAQImplementation(const QString&driverinfo);
  224. ~DAQImplementation();
  225. void run();
  226. void measure();
  227. /*318:*/
  228. #line 7009 "./typica.w"
  229. typedef int(*daqfp)(...);
  230. daqfp read;
  231. daqfp errorInfo;
  232. daqfp startTask;
  233. daqfp createTask;
  234. daqfp createChannel;
  235. daqfp setClock;
  236. daqfp stopTask;
  237. daqfp clearTask;
  238. daqfp resetDevice;
  239. daqfp waitForMeasurement;
  240. /*:318*/
  241. #line 6998 "./typica.w"
  242. /*319:*/
  243. #line 7025 "./typica.w"
  244. bool useBase;
  245. QString device;
  246. QVector<Channel*> channelMap;
  247. unsigned int handle;
  248. int error;
  249. int channels;
  250. bool ready;
  251. QLibrary driver;
  252. QVector<Units::Unit> unitMap;
  253. /*:319*/
  254. #line 6999 "./typica.w"
  255. };
  256. /*:317*//*335:*/
  257. #line 7530 "./typica.w"
  258. class FakeDAQImplementation:public QThread
  259. {
  260. Q_OBJECT
  261. public:
  262. FakeDAQImplementation();
  263. ~FakeDAQImplementation();
  264. void run();
  265. void measure();
  266. QVector<Channel*> channelMap;
  267. int channels;
  268. bool ready;
  269. double clockRate;
  270. };
  271. class FakeDAQ:public QObject
  272. {
  273. Q_OBJECT
  274. FakeDAQImplementation*imp;
  275. public:
  276. FakeDAQ(QString device);
  277. ~FakeDAQ();
  278. Channel*newChannel(int units,int thermocouple);
  279. Q_INVOKABLE void setClockRate(double Hz);
  280. Q_INVOKABLE void start();
  281. };
  282. /*:335*//*342:*/
  283. #line 7717 "./typica.w"
  284. class Channel:public QObject
  285. {
  286. Q_OBJECT
  287. public:
  288. Channel();
  289. ~Channel();
  290. public slots:
  291. void input(Measurement measurement);
  292. signals:
  293. void newData(Measurement);
  294. };
  295. /*:342*//*346:*/
  296. #line 7784 "./typica.w"
  297. class LinearCalibrator:public QObject
  298. {
  299. Q_OBJECT
  300. Q_PROPERTY(double measuredLower READ measuredLower
  301. WRITE setMeasuredLower)
  302. Q_PROPERTY(double measuredUpper READ measuredUpper
  303. WRITE setMeasuredUpper)
  304. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  305. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  306. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  307. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  308. public:
  309. LinearCalibrator(QObject*parent= NULL);
  310. double measuredLower();
  311. double measuredUpper();
  312. double mappedLower();
  313. double mappedUpper();
  314. bool isClosedRange();
  315. double sensitivity();
  316. public slots:
  317. void setMeasuredLower(double lower);
  318. void setMeasuredUpper(double upper);
  319. void setMappedLower(double lower);
  320. void setMappedUpper(double upper);
  321. void setClosedRange(bool closed);
  322. void setSensitivity(double sensitivity);
  323. Measurement newMeasurement(Measurement measure);
  324. signals:
  325. void measurement(Measurement measure);
  326. void newData(Measurement measure);
  327. private:
  328. double Lo1;
  329. double Lo2;
  330. double Up1;
  331. double Up2;
  332. double sensitivitySetting;
  333. bool clamp;
  334. };
  335. /*:346*//*353:*/
  336. #line 7980 "./typica.w"
  337. class LinearSplineInterpolator:public QObject
  338. {
  339. Q_OBJECT
  340. public:
  341. LinearSplineInterpolator(QObject*parent= NULL);
  342. Q_INVOKABLE void add_pair(double source,double destination);
  343. public slots:
  344. Measurement newMeasurement(Measurement measure);
  345. signals:
  346. void newData(Measurement measure);
  347. private:
  348. void make_interpolators();
  349. QMap<double,double> *pairs;
  350. QList<LinearCalibrator*> *interpolators;
  351. };
  352. /*:353*//*358:*/
  353. #line 8116 "./typica.w"
  354. class TemperatureDisplay:public QLCDNumber
  355. {
  356. Q_OBJECT
  357. int unit;
  358. bool r;
  359. public:
  360. TemperatureDisplay(QWidget*parent= NULL);
  361. ~TemperatureDisplay();
  362. public slots:
  363. void setValue(Measurement temperature);
  364. void invalidate();
  365. void setDisplayUnits(Units::Unit scale);
  366. void setRelativeMode(bool relative);
  367. };
  368. /*:358*//*369:*/
  369. #line 8335 "./typica.w"
  370. class MeasurementTimeOffset:public QObject
  371. {
  372. Q_OBJECT
  373. QTime epoch;
  374. QTime previous;
  375. bool hasPrevious;
  376. public:
  377. MeasurementTimeOffset(QTime zero);
  378. QTime zeroTime();
  379. public slots:
  380. void newMeasurement(Measurement measure);
  381. void setZeroTime(QTime zero);
  382. signals:
  383. void measurement(Measurement measure);
  384. };
  385. /*:369*//*376:*/
  386. #line 8487 "./typica.w"
  387. class ThresholdDetector:public QObject
  388. {
  389. Q_OBJECT
  390. Q_ENUMS(EdgeDirection)
  391. public:
  392. enum EdgeDirection{
  393. Ascending,Descending
  394. };
  395. ThresholdDetector(double value);
  396. public slots:
  397. void newMeasurement(Measurement measure);
  398. void setThreshold(double value);
  399. void setEdgeDirection(EdgeDirection direction);
  400. signals:
  401. void timeForValue(double);
  402. private:
  403. bool previousValueValid;
  404. double previousValue;
  405. double threshold;
  406. EdgeDirection currentDirection;
  407. };
  408. /*:376*//*381:*/
  409. #line 8603 "./typica.w"
  410. class ZeroEmitter:public QObject
  411. {
  412. Q_OBJECT
  413. Q_PROPERTY(int column READ column WRITE setColumn)
  414. Measurement cache;
  415. int col;
  416. public:
  417. ZeroEmitter(int tempcolumn= 1);
  418. int column();
  419. double lastTemperature();
  420. public slots:
  421. void newMeasurement(Measurement measure);
  422. void setColumn(int column);
  423. void emitZero();
  424. signals:
  425. void measurement(Measurement measure,int tempcolumn);
  426. };
  427. /*:381*//*386:*/
  428. #line 8697 "./typica.w"
  429. class MeasurementAdapter:public QObject
  430. {
  431. Q_OBJECT
  432. int col;
  433. public:
  434. MeasurementAdapter(int tempcolumn);
  435. int column();
  436. public slots:
  437. void newMeasurement(Measurement measure);
  438. void setColumn(int column);
  439. signals:
  440. void measurement(Measurement measure,int tempcolumn);
  441. };
  442. /*:386*//*391:*/
  443. #line 8786 "./typica.w"
  444. class GraphView:public QGraphicsView
  445. {
  446. Q_OBJECT
  447. QGraphicsScene*theScene;
  448. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  449. QMap<int,QPointF> *prevPoints;
  450. QMap<int,double> *translations;
  451. QList<QGraphicsItem*> *gridLinesF;
  452. QList<QGraphicsItem*> *gridLinesC;
  453. QList<QGraphicsItem*> *relativeGridLines;
  454. bool relativeEnabled;
  455. bool timeIndicatorEnabled;
  456. QGraphicsLineItem*timeLine;
  457. LinearSplineInterpolator*relativeAdjuster;
  458. public:
  459. GraphView(QWidget*parent= NULL);
  460. void removeSeries(int column);
  461. protected:
  462. void resizeEvent(QResizeEvent*event);
  463. public slots:
  464. void newMeasurement(Measurement measure,int tempcolumn);
  465. void setSeriesTranslation(int column,double offset);
  466. void setTimeIndicatorEnabled(bool enabled);
  467. void clear();
  468. void showF();
  469. void showC();
  470. };
  471. /*:391*//*408:*/
  472. #line 9254 "./typica.w"
  473. class MeasurementModel;
  474. class ZoomLog:public QTableView
  475. {
  476. Q_OBJECT
  477. /*409:*/
  478. #line 9303 "./typica.w"
  479. MeasurementModel*model_ms;
  480. MeasurementModel*model_1s;
  481. MeasurementModel*model_5s;
  482. MeasurementModel*model_10s;
  483. MeasurementModel*model_15s;
  484. MeasurementModel*model_30s;
  485. MeasurementModel*model_1m;
  486. QList<MeasurementModel*> modelSet;
  487. QHash<int,Measurement> lastMeasurement;
  488. MeasurementModel*currentModel;
  489. QList<int> saveTempCols;
  490. QList<int> saveControlCols;
  491. QList<int> saveNoteCols;
  492. QList<int> currentColumnSet;
  493. /*:409*/
  494. #line 9259 "./typica.w"
  495. void switchLOD(MeasurementModel*m);
  496. private slots:
  497. void centerOn(int row);
  498. void persistColumnResize(int column,int oldsize,int newsize);
  499. void restoreColumnWidths();
  500. public:
  501. ZoomLog();
  502. QVariant data(int row,int column)const;
  503. Q_INVOKABLE int rowCount();
  504. bool saveXML(QIODevice*device);
  505. bool saveCSV(QIODevice*device);
  506. QString lastTime(int series);
  507. Q_INVOKABLE Units::Unit displayUnits();
  508. public slots:
  509. void setVisible(bool visibility);
  510. void setHeaderData(int section,QString text);
  511. void LOD_ms();
  512. void LOD_1s();
  513. void LOD_5s();
  514. void LOD_10s();
  515. void LOD_15s();
  516. void LOD_30s();
  517. void LOD_1m();
  518. void newMeasurement(Measurement measure,int tempcolumn);
  519. void newAnnotation(QString annotation,int tempcolumn,
  520. int annotationcolumn);
  521. void clear();
  522. void addOutputTemperatureColumn(int column);
  523. void addOutputControlColumn(int column);
  524. void addOutputAnnotationColumn(int column);
  525. void clearOutputColumns();
  526. void setDisplayUnits(Units::Unit scale);
  527. void addToCurrentColumnSet(int column);
  528. void clearCurrentColumnSet();
  529. protected:
  530. virtual void showEvent(QShowEvent*event);
  531. };
  532. /*:408*//*434:*/
  533. #line 10008 "./typica.w"
  534. class MeasurementList;
  535. class MeasurementModel:public QAbstractItemModel
  536. {
  537. Q_OBJECT
  538. Units::Unit unit;
  539. QList<MeasurementList*> *entries;
  540. QStringList*hData;
  541. int colcount;
  542. QHash<int,int> *lastTemperature;
  543. QList<MeasurementList*> ::iterator lastInsertion;
  544. QHash<int,bool> *controlColumns;
  545. public:
  546. MeasurementModel(QObject*parent= NULL);
  547. ~MeasurementModel();
  548. int rowCount(const QModelIndex&parent= QModelIndex())const;
  549. int columnCount(const QModelIndex&parent= QModelIndex())const;
  550. bool setHeaderData(int section,Qt::Orientation orientation,
  551. const QVariant&value,int role= Qt::DisplayRole);
  552. QVariant data(const QModelIndex&index,int role)const;
  553. bool setData(const QModelIndex&index,const QVariant&value,
  554. int role= Qt::EditRole);
  555. Qt::ItemFlags flags(const QModelIndex&index)const;
  556. QVariant headerData(int section,Qt::Orientation orientation,
  557. int role= Qt::DisplayRole)const;
  558. QModelIndex index(int row,int column,
  559. const QModelIndex&parent= QModelIndex())const;
  560. QModelIndex parent(const QModelIndex&index)const;
  561. Units::Unit displayUnits();
  562. public slots:
  563. void newMeasurement(Measurement measure,int tempcolumn);
  564. void newAnnotation(QString annotation,int tempcolumn,
  565. int annotationColumn);
  566. void clear();
  567. void setDisplayUnits(Units::Unit scale);
  568. signals:
  569. void rowChanged(int);
  570. };
  571. /*:434*//*435:*/
  572. #line 10052 "./typica.w"
  573. class MeasurementList:public QVariantList
  574. {
  575. public:
  576. bool operator<(const MeasurementList&other)const;
  577. bool operator==(const MeasurementList&other)const;
  578. };
  579. /*:435*//*461:*/
  580. #line 10710 "./typica.w"
  581. class AnnotationButton:public QPushButton
  582. {
  583. Q_OBJECT
  584. QString note;
  585. int tc;
  586. int ac;
  587. int count;
  588. public:
  589. AnnotationButton(const QString&text,QWidget*parent= NULL);
  590. public slots:
  591. void setAnnotation(const QString&annotation);
  592. void setTemperatureColumn(int tempcolumn);
  593. void setAnnotationColumn(int annotationcolumn);
  594. void annotate();
  595. void resetCount();
  596. signals:
  597. void annotation(QString annotation,int tempcolumn,
  598. int notecolumn);
  599. };
  600. /*:461*//*469:*/
  601. #line 10835 "./typica.w"
  602. class AnnotationSpinBox:public QDoubleSpinBox
  603. {
  604. Q_OBJECT
  605. QString pretext;
  606. QString posttext;
  607. int tc;
  608. int ac;
  609. bool change;
  610. public:
  611. AnnotationSpinBox(const QString&pret,const QString&postt,
  612. QWidget*parent= NULL);
  613. public slots:
  614. void setPretext(const QString&pret);
  615. void setPosttext(const QString&postt);
  616. void setTemperatureColumn(int tempcolumn);
  617. void setAnnotationColumn(int annotationcolumn);
  618. void annotate();
  619. void resetChange();
  620. signals:
  621. void annotation(QString annotation,int tempcolumn,
  622. int notecolumn);
  623. };
  624. /*:469*//*477:*/
  625. #line 10994 "./typica.w"
  626. class TimerDisplay:public QLCDNumber
  627. {
  628. Q_OBJECT
  629. /*478:*/
  630. #line 11044 "./typica.w"
  631. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  632. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  633. Q_PROPERTY(bool running READ isRunning)
  634. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  635. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  636. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  637. Q_PROPERTY(QString value READ value)
  638. /*:478*/
  639. #line 10998 "./typica.w"
  640. private slots:
  641. void updateTime();
  642. void setCountUpMode();
  643. void setCountDownMode();
  644. void setClockMode();
  645. public:
  646. TimerDisplay(QWidget*parent= NULL);
  647. ~TimerDisplay();
  648. enum TimerMode
  649. {
  650. CountUp,
  651. CountDown,
  652. Clock
  653. };
  654. QString value();
  655. QTime seconds();
  656. TimerMode mode();
  657. bool isRunning();
  658. QTime resetValue();
  659. QString displayFormat();
  660. bool autoReset();
  661. public slots:
  662. void setTimer(QTime value= QTime(0,0,0));
  663. void setMode(TimerMode mode);
  664. void startTimer();
  665. void stopTimer();
  666. void copyTimer();
  667. void setResetValue(QTime value= QTime(0,0,0));
  668. void reset();
  669. void setDisplayFormat(QString format);
  670. void setAutoReset(bool reset);
  671. void updateDisplay();
  672. signals:
  673. void valueChanged(QTime);
  674. void runStateChanged(bool);
  675. private:
  676. /*479:*/
  677. #line 11055 "./typica.w"
  678. QTime s;
  679. QTime r;
  680. QTimer clock;
  681. TimerDisplay::TimerMode m;
  682. bool running;
  683. bool ar;
  684. QAction*startAction;
  685. QAction*stopAction;
  686. QAction*resetAction;
  687. QString f;
  688. QTime relative;
  689. QTime base;
  690. /*:479*/
  691. #line 11035 "./typica.w"
  692. };
  693. /*:477*//*500:*/
  694. #line 11447 "./typica.w"
  695. class PackLayout:public QLayout
  696. {
  697. int doLayout(const QRect&rect,bool testOnly)const;
  698. QList<QLayoutItem*> itemList;
  699. Qt::Orientations orientation;
  700. public:
  701. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  702. PackLayout(int spacing= -1);
  703. ~PackLayout();
  704. void addItem(QLayoutItem*item);
  705. Qt::Orientations expandingDirections()const;
  706. bool hasHeightForWidth()const;
  707. int heightForWidth(int width)const;
  708. int count()const;
  709. QLayoutItem*itemAt(int index)const;
  710. QSize minimumSize()const;
  711. void setGeometry(const QRect&rect);
  712. void setOrientation(Qt::Orientations direction);
  713. QSize sizeHint()const;
  714. QLayoutItem*takeAt(int index);
  715. };
  716. /*:500*//*513:*/
  717. #line 11725 "./typica.w"
  718. class SceneButton:public QGraphicsScene
  719. {
  720. Q_OBJECT
  721. public:
  722. SceneButton();
  723. ~SceneButton();
  724. protected:
  725. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  726. signals:
  727. void clicked(QPoint pos);
  728. };
  729. /*:513*//*515:*/
  730. #line 11767 "./typica.w"
  731. class WidgetDecorator:public QWidget
  732. {
  733. Q_OBJECT
  734. PackLayout*layout;
  735. QGraphicsView*label;
  736. QGraphicsTextItem*text;
  737. SceneButton*scene;
  738. public:
  739. WidgetDecorator(QWidget*widget,const QString&labeltext,
  740. Qt::Orientations orientation= Qt::Horizontal,
  741. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  742. ~WidgetDecorator();
  743. void setBackgroundBrush(QBrush background);
  744. void setTextColor(QColor color);
  745. };
  746. /*:515*//*526:*/
  747. #line 11942 "./typica.w"
  748. class LogEditWindow:public QMainWindow
  749. {
  750. Q_OBJECT
  751. QWidget*centralWidget;
  752. PackLayout*mainLayout;
  753. QHBoxLayout*addRowsLayout;
  754. QLabel*startTimeLabel;
  755. QTimeEdit*startTime;
  756. QLabel*endTimeLabel;
  757. QTimeEdit*endTime;
  758. QLabel*intervalLabel;
  759. QSpinBox*interval;
  760. QPushButton*addRows;
  761. QAction*saveXml;
  762. QAction*saveCsv;
  763. QAction*openXml;
  764. MeasurementModel*model;
  765. QTableView*log;
  766. private slots:
  767. void addTheRows();
  768. void saveXML();
  769. void saveCSV();
  770. void openXML();
  771. protected:
  772. void closeEvent(QCloseEvent*event);
  773. public:
  774. LogEditWindow();
  775. };
  776. /*:526*//*540:*/
  777. #line 12250 "./typica.w"
  778. class XMLOutput:public QObject
  779. {
  780. Q_OBJECT
  781. MeasurementModel*data;
  782. QIODevice*out;
  783. int time;
  784. QMap<int,QString> temperatureColumns;
  785. QMap<int,QString> controlColumns;
  786. QMap<int,QString> annotationColumns;
  787. public:
  788. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  789. void addTemperatureColumn(const QString&series,int column);
  790. void addControlColumn(const QString&series,int column);
  791. void addAnnotationColumn(const QString&series,int column);
  792. void setModel(MeasurementModel*model);
  793. void setTimeColumn(int column);
  794. void setDevice(QIODevice*device);
  795. bool output();
  796. };
  797. /*:540*//*547:*/
  798. #line 12486 "./typica.w"
  799. class XMLInput:public QObject
  800. {
  801. Q_OBJECT
  802. int firstc;
  803. QIODevice*in;
  804. public:
  805. XMLInput(QIODevice*input,int c);
  806. void setFirstColumn(int column);
  807. void setDevice(QIODevice*device);
  808. bool input();
  809. signals:
  810. void measure(Measurement,int);
  811. void annotation(QString,int,int);
  812. void newTemperatureColumn(int,QString);
  813. void newAnnotationColumn(int,QString);
  814. void lastColumn(int);
  815. };
  816. /*:547*//*558:*/
  817. #line 12740 "./typica.w"
  818. class CSVOutput
  819. {
  820. MeasurementModel*data;
  821. QIODevice*out;
  822. int time;
  823. QMap<int,QString> temperatureColumns;
  824. QMap<int,QString> controlColumns;
  825. QMap<int,QString> annotationColumns;
  826. public:
  827. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  828. void addTemperatureColumn(const QString&series,int column);
  829. void addControlColumn(const QString&series,int column);
  830. void addAnnotationColumn(const QString&series,int column);
  831. void setModel(MeasurementModel*model);
  832. void setTimeColumn(int column);
  833. void setDevice(QIODevice*device);
  834. bool output();
  835. };
  836. /*:558*//*598:*/
  837. #line 12885 "./typica.w"
  838. #define AppInstance (qobject_cast<Application *> (qApp))
  839. class NodeInserter;
  840. class DeviceTreeModel;
  841. class DatabaseNotification;
  842. class Application:public QApplication
  843. {
  844. Q_OBJECT
  845. public:
  846. Application(int&argc,char**argv);
  847. QDomDocument*configuration();
  848. /*753:*/
  849. #line 15600 "./typica.w"
  850. QDomDocument deviceConfiguration();
  851. /*:753*//*786:*/
  852. #line 16273 "./typica.w"
  853. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  854. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  855. const QModelIndex&index);
  856. /*:786*//*791:*/
  857. #line 16377 "./typica.w"
  858. QList<NodeInserter*> topLevelNodeInserters;
  859. /*:791*/
  860. #line 12897 "./typica.w"
  861. QSqlDatabase database();
  862. Q_INVOKABLE bool databaseConnected();
  863. Q_INVOKABLE QString currentTypicaUser();
  864. Q_INVOKABLE bool login(const QString&user,const QString&password);
  865. Q_INVOKABLE bool autoLogin();
  866. QScriptEngine*engine;
  867. QNetworkAccessManager*network;
  868. DatabaseNotification*subscribe(const QString&notification);
  869. public slots:
  870. void setDatabaseConnected(bool status);
  871. void setCurrentTypicaUser(const QString&user);
  872. void notify(const QString&notification);
  873. /*754:*/
  874. #line 15607 "./typica.w"
  875. void saveDeviceConfiguration();
  876. /*:754*/
  877. #line 12910 "./typica.w"
  878. signals:
  879. void userChanged(const QString&user);
  880. private:
  881. /*752:*/
  882. #line 15591 "./typica.w"
  883. QDomDocument deviceConfigurationDocument;
  884. /*:752*//*785:*/
  885. #line 16267 "./typica.w"
  886. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  887. /*:785*/
  888. #line 12914 "./typica.w"
  889. QDomDocument conf;
  890. bool connectionStatus;
  891. QString currentUser;
  892. QMap<QString,DatabaseNotification*> notifiers;
  893. QSqlDriver*notificationDriver;
  894. };
  895. /*:598*//*610:*/
  896. #line 13086 "./typica.w"
  897. class DatabaseNotification:public QObject
  898. {
  899. Q_OBJECT
  900. public:
  901. DatabaseNotification();
  902. public slots:
  903. void forwardNotification(const QString&notification);
  904. signals:
  905. void notify(const QString&notification);
  906. };
  907. /*:610*//*611:*/
  908. #line 13100 "./typica.w"
  909. DatabaseNotification::DatabaseNotification():QObject(NULL)
  910. {
  911. }
  912. void DatabaseNotification::forwardNotification(const QString&notification)
  913. {
  914. emit notify(notification);
  915. }
  916. /*:611*//*613:*/
  917. #line 13160 "./typica.w"
  918. class SaltModel:public QAbstractItemModel
  919. {
  920. Q_OBJECT
  921. QList<QList<QMap<int,QVariant> > > modelData;
  922. QStringList hData;
  923. int colcount;
  924. public:
  925. SaltModel(int columns);
  926. ~SaltModel();
  927. int rowCount(const QModelIndex&parent= QModelIndex())const;
  928. int columnCount(const QModelIndex&parent= QModelIndex())const;
  929. bool setHeaderData(int section,Qt::Orientation orientation,
  930. const QVariant&value,int role= Qt::DisplayRole);
  931. QVariant data(const QModelIndex&index,int role)const;
  932. bool setData(const QModelIndex&index,const QVariant&value,
  933. int role= Qt::EditRole);
  934. Qt::ItemFlags flags(const QModelIndex&index)const;
  935. QVariant headerData(int section,Qt::Orientation orientation,
  936. int role= Qt::DisplayRole)const;
  937. QModelIndex index(int row,int column,
  938. const QModelIndex&parent= QModelIndex())const;
  939. QModelIndex parent(const QModelIndex&index)const;
  940. QString arrayLiteral(int column,int role)const;
  941. QString quotedArrayLiteral(int column,int role)const;
  942. void clear();
  943. bool removeRows(int row,int count,
  944. const QModelIndex&parent= QModelIndex());
  945. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  946. };
  947. /*:613*//*629:*/
  948. #line 13545 "./typica.w"
  949. class SqlComboBox:public QComboBox
  950. {
  951. Q_OBJECT
  952. int dataColumn;
  953. int displayColumn;
  954. bool dataColumnShown;
  955. QString specialNullText;
  956. QVariant specialNullData;
  957. public:
  958. SqlComboBox();
  959. ~SqlComboBox();
  960. SqlComboBox*clone(QWidget*parent);
  961. public slots:
  962. void addNullOption();
  963. void addSqlOptions(QString query);
  964. void setDataColumn(int column);
  965. void setDisplayColumn(int column);
  966. void showData(bool show);
  967. void setNullText(QString nullText);
  968. void setNullData(QVariant nullData);
  969. };
  970. /*:629*//*636:*/
  971. #line 13692 "./typica.w"
  972. class SqlComboBoxDelegate:public QItemDelegate
  973. {
  974. Q_OBJECT
  975. SqlComboBox*delegate;
  976. public:
  977. SqlComboBoxDelegate(QObject*parent= NULL);
  978. QWidget*createEditor(QWidget*parent,
  979. const QStyleOptionViewItem&option,
  980. const QModelIndex&index)const;
  981. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  982. void setModelData(QWidget*editor,QAbstractItemModel*model,
  983. const QModelIndex&index)const;
  984. void setWidget(SqlComboBox*widget);
  985. virtual QSize sizeHint()const;
  986. void updateEditorGeometry(QWidget*editor,
  987. const QStyleOptionViewItem&option,
  988. const QModelIndex&index)const;
  989. };
  990. /*:636*//*651:*/
  991. #line 13903 "./typica.w"
  992. class SqlConnectionSetup:public QDialog
  993. {
  994. Q_OBJECT
  995. public:
  996. SqlConnectionSetup();
  997. ~SqlConnectionSetup();
  998. public slots:
  999. void testConnection();
  1000. private:
  1001. QFormLayout*formLayout;
  1002. QComboBox*driver;
  1003. QLineEdit*hostname;
  1004. QLineEdit*portnumber;
  1005. QLineEdit*dbname;
  1006. QLineEdit*user;
  1007. QLineEdit*password;
  1008. QVBoxLayout*layout;
  1009. QHBoxLayout*buttons;
  1010. QPushButton*cancelButton;
  1011. QPushButton*connectButton;
  1012. };
  1013. /*:651*//*656:*/
  1014. #line 14051 "./typica.w"
  1015. class SqlQueryView:public QTableView
  1016. {
  1017. Q_OBJECT
  1018. public:
  1019. SqlQueryView(QWidget*parent= NULL);
  1020. void setQuery(const QString&query);
  1021. bool setHeaderData(int section,Qt::Orientation orientation,
  1022. const QVariant&value,int role);
  1023. Q_INVOKABLE QVariant data(int row,int column,
  1024. int role= Qt::DisplayRole);
  1025. signals:
  1026. void openEntry(QString key);
  1027. void openEntryRow(int row);
  1028. void selectEntry(QString key);
  1029. void selectEntryRow(int row);
  1030. protected:
  1031. virtual void showEvent(QShowEvent*event);
  1032. private slots:
  1033. void openRow(const QModelIndex&index);
  1034. void persistColumnResize(int column,int oldsize,int newsize);
  1035. void selectRow(const QModelIndex&index);
  1036. };
  1037. /*:656*//*671:*/
  1038. #line 14317 "./typica.w"
  1039. class ReportAction:public QAction
  1040. {
  1041. Q_OBJECT
  1042. public:
  1043. ReportAction(const QString&fileName,const QString&reportName,
  1044. QObject*parent= NULL);
  1045. private slots:
  1046. void createReport();
  1047. private:
  1048. QString reportFile;
  1049. };
  1050. /*:671*//*683:*/
  1051. #line 14528 "./typica.w"
  1052. class ReportTable:public QObject
  1053. {
  1054. Q_OBJECT
  1055. QTextFrame*area;
  1056. QDomElement configuration;
  1057. QMap<QString,QVariant> bindings;
  1058. public:
  1059. ReportTable(QTextFrame*frame,QDomElement description);
  1060. ~ReportTable();
  1061. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  1062. public slots:
  1063. void refresh();
  1064. };
  1065. /*:683*//*696:*/
  1066. #line 63 "./plugins.w"
  1067. class PluginAction:public QAction
  1068. {
  1069. Q_OBJECT
  1070. Q_PROPERTY(QString preRun READ preRun WRITE setPreRun);
  1071. Q_PROPERTY(QString postRun READ postRun WRITE setPostRun);
  1072. public:
  1073. PluginAction(const QFileInfo&info,QObject*parent);
  1074. QString preRun();
  1075. QString postRun();
  1076. public slots:
  1077. void setPreRun(const QString&script);
  1078. void setPostRun(const QString&script);
  1079. private slots:
  1080. void runScript();
  1081. private:
  1082. QString pluginFile;
  1083. QString preRunScript;
  1084. QString postRunScript;
  1085. };
  1086. /*:696*//*699:*/
  1087. #line 155 "./plugins.w"
  1088. Q_DECLARE_METATYPE(QScriptValue)
  1089. /*:699*//*722:*/
  1090. #line 14769 "./typica.w"
  1091. class FormArray:public QScrollArea
  1092. {
  1093. Q_OBJECT
  1094. QDomElement configuration;
  1095. QWidget itemContainer;
  1096. QVBoxLayout itemLayout;
  1097. int maxwidth;
  1098. int maxheight;
  1099. public:
  1100. FormArray(QDomElement description);
  1101. Q_INVOKABLE QWidget*elementAt(int index);
  1102. Q_INVOKABLE int elements();
  1103. public slots:
  1104. void addElements(int copies= 1);
  1105. void removeAllElements();
  1106. void setMaximumElementWidth(int width);
  1107. void setMaximumElementHeight(int height);
  1108. };
  1109. /*:722*//*732:*/
  1110. #line 14985 "./typica.w"
  1111. class ScaleControl:public QGraphicsView
  1112. {
  1113. Q_OBJECT
  1114. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1115. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1116. /*733:*/
  1117. #line 15011 "./typica.w"
  1118. QGraphicsScene scene;
  1119. QGraphicsPolygonItem initialDecrement;
  1120. QGraphicsPolygonItem initialIncrement;
  1121. QGraphicsPolygonItem finalDecrement;
  1122. QGraphicsPolygonItem finalIncrement;
  1123. QGraphicsPolygonItem initialIndicator;
  1124. QGraphicsPolygonItem finalIndicator;
  1125. QGraphicsPathItem scaleLine;
  1126. QPolygonF left;
  1127. QPolygonF right;
  1128. QPolygonF down;
  1129. QPolygonF up;
  1130. QPainterPath scalePath;
  1131. QBrush initialBrush;
  1132. QBrush finalBrush;
  1133. double nonScoredValue;
  1134. double scoredValue;
  1135. bool initialSet;
  1136. bool finalSet;
  1137. bool scaleDown;
  1138. /*:733*/
  1139. #line 14991 "./typica.w"
  1140. public:
  1141. ScaleControl();
  1142. double initialValue(void);
  1143. double finalValue(void);
  1144. virtual QSize sizeHint()const;
  1145. public slots:
  1146. void setInitialValue(double value);
  1147. void setFinalValue(double value);
  1148. signals:
  1149. void initialChanged(double);
  1150. void finalChanged(double);
  1151. protected:
  1152. virtual void mousePressEvent(QMouseEvent*event);
  1153. virtual void mouseReleaseEvent(QMouseEvent*event);
  1154. };
  1155. /*:732*//*744:*/
  1156. #line 15308 "./typica.w"
  1157. class IntensityControl:public QGraphicsView
  1158. {
  1159. Q_OBJECT
  1160. Q_PROPERTY(double value READ value WRITE setValue)
  1161. QGraphicsScene scene;
  1162. QGraphicsPolygonItem decrement;
  1163. QGraphicsPolygonItem increment;
  1164. QGraphicsPolygonItem indicator;
  1165. QGraphicsPathItem scaleLine;
  1166. QPolygonF left;
  1167. QPolygonF up;
  1168. QPolygonF down;
  1169. QPainterPath scalePath;
  1170. QBrush theBrush;
  1171. double theValue;
  1172. bool valueSet;
  1173. bool scaleDown;
  1174. public:
  1175. IntensityControl();
  1176. double value();
  1177. virtual QSize sizeHint()const;
  1178. public slots:
  1179. void setValue(double val);
  1180. signals:
  1181. void valueChanged(double);
  1182. protected:
  1183. virtual void mousePressEvent(QMouseEvent*event);
  1184. virtual void mouseReleaseEvent(QMouseEvent*event);
  1185. };
  1186. /*:744*//*760:*/
  1187. #line 15696 "./typica.w"
  1188. class DeviceTreeModelNode
  1189. {
  1190. public:
  1191. DeviceTreeModelNode(QDomNode&node,int row,
  1192. DeviceTreeModelNode*parent= NULL);
  1193. ~DeviceTreeModelNode();
  1194. DeviceTreeModelNode*child(int index);
  1195. DeviceTreeModelNode*parent();
  1196. QDomNode node()const;
  1197. int row();
  1198. private:
  1199. QDomNode domNode;
  1200. QHash<int,DeviceTreeModelNode*> children;
  1201. int rowNumber;
  1202. DeviceTreeModelNode*parentItem;
  1203. };
  1204. /*:760*//*762:*/
  1205. #line 15771 "./typica.w"
  1206. class DeviceTreeModel:public QAbstractItemModel
  1207. {
  1208. Q_OBJECT
  1209. public:
  1210. DeviceTreeModel(QObject*parent= NULL);
  1211. ~DeviceTreeModel();
  1212. QVariant data(const QModelIndex&index,int role)const;
  1213. Qt::ItemFlags flags(const QModelIndex&index)const;
  1214. QVariant headerData(int section,Qt::Orientation orientation,
  1215. int role= Qt::DisplayRole)const;
  1216. QModelIndex index(int row,int column,
  1217. const QModelIndex&parent= QModelIndex())const;
  1218. QModelIndex parent(const QModelIndex&child)const;
  1219. Q_INVOKABLE int rowCount(const QModelIndex&parent= QModelIndex())const;
  1220. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1221. bool setData(const QModelIndex&index,const QVariant&value,
  1222. int role);
  1223. bool removeRows(int row,int count,const QModelIndex&parent);
  1224. QDomElement referenceElement(const QString&id);
  1225. public slots:
  1226. void newNode(const QString&name,const QString&driver,
  1227. const QModelIndex&parent);
  1228. private:
  1229. QDomDocument document;
  1230. DeviceTreeModelNode*root;
  1231. QDomNode referenceSection;
  1232. QDomNode treeRoot;
  1233. };
  1234. /*:762*//*781:*/
  1235. #line 16225 "./typica.w"
  1236. Q_DECLARE_METATYPE(QModelIndex)
  1237. /*:781*//*789:*/
  1238. #line 16332 "./typica.w"
  1239. class NodeInserter:public QAction
  1240. {
  1241. Q_OBJECT
  1242. public:
  1243. NodeInserter(const QString&title,const QString&name,
  1244. const QString&driver,QObject*parent= NULL);
  1245. signals:
  1246. void triggered(QString name,QString driver);
  1247. private slots:
  1248. void onTriggered();
  1249. private:
  1250. QString defaultNodeName;
  1251. QString driverString;
  1252. };
  1253. /*:789*//*792:*/
  1254. #line 16387 "./typica.w"
  1255. class DeviceConfigurationWindow:public QWidget
  1256. {
  1257. Q_OBJECT
  1258. public:
  1259. DeviceConfigurationWindow();
  1260. public slots:
  1261. void addDevice();
  1262. void removeNode();
  1263. void newSelection(const QModelIndex&index);
  1264. private slots:
  1265. void resizeColumn();
  1266. private:
  1267. QDomDocument document;
  1268. DeviceTreeModel*model;
  1269. QTreeView*view;
  1270. QScrollArea*configArea;
  1271. };
  1272. /*:792*//*801:*/
  1273. #line 16557 "./typica.w"
  1274. class BasicDeviceConfigurationWidget:public QWidget
  1275. {
  1276. Q_OBJECT
  1277. public:
  1278. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1279. const QModelIndex&index);
  1280. public slots:
  1281. void insertChildNode(const QString&name,const QString&driver);
  1282. void updateAttribute(const QString&name,const QString&value);
  1283. protected:
  1284. DeviceTreeModel*deviceModel;
  1285. QModelIndex currentNode;
  1286. };
  1287. /*:801*//*805:*/
  1288. #line 16642 "./typica.w"
  1289. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1290. {
  1291. Q_OBJECT
  1292. public:
  1293. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1294. const QModelIndex&index);
  1295. private slots:
  1296. void updateRoasterId(int id);
  1297. void updateCapacityCheck(int value);
  1298. void updateCapacity(const QString&value);
  1299. void updateCapacityUnit(const QString&value);
  1300. };
  1301. /*:805*//*810:*/
  1302. #line 16847 "./typica.w"
  1303. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1304. {
  1305. Q_OBJECT
  1306. public:
  1307. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1308. const QModelIndex&index);
  1309. };
  1310. /*:810*//*812:*/
  1311. #line 16893 "./typica.w"
  1312. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1313. {
  1314. Q_OBJECT
  1315. public:
  1316. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1317. const QModelIndex&index);
  1318. private slots:
  1319. void addChannel();
  1320. void updateDeviceId(const QString&newId);
  1321. };
  1322. /*:812*//*816:*/
  1323. #line 16979 "./typica.w"
  1324. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1325. {
  1326. Q_OBJECT
  1327. public:
  1328. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1329. const QModelIndex&index);
  1330. private slots:
  1331. void updateThermocoupleType(const QString&type);
  1332. void updateColumnName(const QString&name);
  1333. void updateHidden(bool hidden);
  1334. };
  1335. /*:816*//*821:*/
  1336. #line 17095 "./typica.w"
  1337. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1338. {
  1339. Q_OBJECT
  1340. public:
  1341. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1342. const QModelIndex&index);
  1343. };
  1344. /*:821*//*823:*/
  1345. #line 17136 "./typica.w"
  1346. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1347. {
  1348. Q_OBJECT
  1349. public:
  1350. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1351. const QModelIndex&index);
  1352. private slots:
  1353. void addChannel();
  1354. void updateDeviceId(const QString&newId);
  1355. };
  1356. /*:823*//*825:*/
  1357. #line 17205 "./typica.w"
  1358. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1359. {
  1360. Q_OBJECT
  1361. public:
  1362. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1363. const QModelIndex&index);
  1364. private slots:
  1365. void updateDeviceId(const QString&newId);
  1366. void updateThermocoupleType(const QString&type);
  1367. void updateColumnName(const QString&name);
  1368. void updateHidden(bool hidden);
  1369. };
  1370. /*:825*//*830:*/
  1371. #line 17336 "./typica.w"
  1372. class PortSelector:public QComboBox
  1373. {
  1374. Q_OBJECT
  1375. public:
  1376. PortSelector(QWidget*parent= NULL);
  1377. private slots:
  1378. void addDevice(QextPortInfo port);
  1379. private:
  1380. QextSerialEnumerator*lister;
  1381. };
  1382. /*:830*//*832:*/
  1383. #line 17384 "./typica.w"
  1384. class BaudSelector:public QComboBox
  1385. {
  1386. Q_OBJECT
  1387. Q_ENUMS(BaudRateType)
  1388. public:
  1389. BaudSelector(QWidget*parent= NULL);
  1390. enum BaudRateType
  1391. {
  1392. #if defined(Q_OS_UNIX) || defined(qdoc)
  1393. BAUD50= 50,
  1394. BAUD75= 75,
  1395. BAUD134= 134,
  1396. BAUD150= 150,
  1397. BAUD200= 200,
  1398. BAUD1800= 1800,
  1399. #if defined(B76800) || defined(qdoc)
  1400. BAUD76800= 76800,
  1401. #endif
  1402. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1403. BAUD230400= 230400,
  1404. BAUD460800= 460800,
  1405. BAUD500000= 500000,
  1406. BAUD576000= 576000,
  1407. BAUD921600= 921600,
  1408. BAUD1000000= 1000000,
  1409. BAUD1152000= 1152000,
  1410. BAUD1500000= 1500000,
  1411. BAUD2000000= 2000000,
  1412. BAUD2500000= 2500000,
  1413. BAUD3000000= 3000000,
  1414. BAUD3500000= 3500000,
  1415. BAUD4000000= 4000000,
  1416. #endif
  1417. #endif
  1418. #if defined(Q_OS_WIN) || defined(qdoc)
  1419. BAUD14400= 14400,
  1420. BAUD56000= 56000,
  1421. BAUD128000= 128000,
  1422. BAUD256000= 256000,
  1423. #endif
  1424. BAUD110= 110,
  1425. BAUD300= 300,
  1426. BAUD600= 600,
  1427. BAUD1200= 1200,
  1428. BAUD2400= 2400,
  1429. BAUD4800= 4800,
  1430. BAUD9600= 9600,
  1431. BAUD19200= 19200,
  1432. BAUD38400= 38400,
  1433. BAUD57600= 57600,
  1434. BAUD115200= 115200
  1435. };
  1436. };
  1437. /*:832*//*834:*/
  1438. #line 17455 "./typica.w"
  1439. class ParitySelector:public QComboBox
  1440. {
  1441. Q_OBJECT
  1442. Q_ENUMS(ParityType)
  1443. public:
  1444. ParitySelector(QWidget*parent= NULL);
  1445. enum ParityType
  1446. {
  1447. PAR_NONE,
  1448. PAR_ODD,
  1449. PAR_EVEN,
  1450. #if defined(Q_OS_WIN) || defined(qdoc)
  1451. PAR_MARK,
  1452. #endif
  1453. PAR_SPACE
  1454. };
  1455. };
  1456. /*:834*//*836:*/
  1457. #line 17493 "./typica.w"
  1458. class FlowSelector:public QComboBox
  1459. {
  1460. Q_OBJECT
  1461. Q_ENUMS(FlowType)
  1462. public:
  1463. FlowSelector(QWidget*parent= NULL);
  1464. enum FlowType
  1465. {
  1466. FLOW_OFF,
  1467. FLOW_HARDWARE,
  1468. FLOW_XONXOFF
  1469. };
  1470. };
  1471. /*:836*//*838:*/
  1472. #line 17526 "./typica.w"
  1473. class StopSelector:public QComboBox
  1474. {
  1475. Q_OBJECT
  1476. Q_ENUMS(StopBitsType)
  1477. public:
  1478. StopSelector(QWidget*parent= NULL);
  1479. enum StopBitsType
  1480. {
  1481. STOP_1,
  1482. #if defined(Q_OS_WIN) || defined(qdoc)
  1483. STOP_1_5,
  1484. #endif
  1485. STOP_2
  1486. };
  1487. };
  1488. /*:838*//*841:*/
  1489. #line 17583 "./typica.w"
  1490. class ShortHexSpinBox:public QSpinBox
  1491. {
  1492. Q_OBJECT
  1493. public:
  1494. ShortHexSpinBox(QWidget*parent= NULL);
  1495. virtual QValidator::State validate(QString&input,int&pos)const;
  1496. protected:
  1497. virtual int valueFromText(const QString&text)const;
  1498. virtual QString textFromValue(int value)const;
  1499. };
  1500. /*:841*//*843:*/
  1501. #line 17645 "./typica.w"
  1502. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1503. {
  1504. Q_OBJECT
  1505. public:
  1506. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1507. const QModelIndex&index);
  1508. private slots:
  1509. void updatePort(const QString&newPort);
  1510. void updateBaudRate(const QString&newRate);
  1511. void updateParity(const QString&newParity);
  1512. void updateFlowControl(const QString&newFlow);
  1513. void updateStopBits(const QString&newStopBits);
  1514. };
  1515. /*:843*//*845:*/
  1516. #line 17796 "./typica.w"
  1517. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1518. {
  1519. Q_OBJECT
  1520. public:
  1521. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1522. const QModelIndex&index);
  1523. private slots:
  1524. void updateStationNumber(int newStation);
  1525. void updateFixedUnit(bool newFixed);
  1526. void updateFixedDecimal(bool newFixed);
  1527. void updateUnit(const QString&newUnit);
  1528. void updateUnitAddress(int newAddress);
  1529. void updateValueF(int newValue);
  1530. void updateValueC(int newValue);
  1531. void updatePrecisionAddress(int newAddress);
  1532. void updatePrecisionValue(int newValue);
  1533. private:
  1534. QStackedLayout*unitSpecificationLayout;
  1535. QStackedLayout*decimalSpecificationLayout;
  1536. };
  1537. /*:845*//*847:*/
  1538. #line 18055 "./typica.w"
  1539. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1540. {
  1541. Q_OBJECT
  1542. public:
  1543. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1544. const QModelIndex&index);
  1545. private slots:
  1546. void updateAddress(int newAddress);
  1547. };
  1548. /*:847*//*849:*/
  1549. #line 18101 "./typica.w"
  1550. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1551. {
  1552. Q_OBJECT
  1553. public:
  1554. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1555. const QModelIndex&index);
  1556. private slots:
  1557. void updateReadAddress(int newAddress);
  1558. void updateWriteAddress(int newAddress);
  1559. void updateFixedRange(bool fixed);
  1560. void updateLower(const QString&lower);
  1561. void updateUpper(const QString&upper);
  1562. void updateLowerAddress(int newAddress);
  1563. void updateUpperAddress(int newAddress);
  1564. private:
  1565. QStackedLayout*boundsLayout;
  1566. };
  1567. /*:849*//*853:*/
  1568. #line 18295 "./typica.w"
  1569. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1570. {
  1571. Q_OBJECT
  1572. public:
  1573. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1574. private slots:
  1575. void updateButtonText(const QString&text);
  1576. void updateAnnotationText(const QString&text);
  1577. };
  1578. /*:853*//*857:*/
  1579. #line 18363 "./typica.w"
  1580. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1581. {
  1582. Q_OBJECT
  1583. public:
  1584. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1585. private slots:
  1586. void updateButtonText(const QString&text);
  1587. void updateAnnotationText(const QString&text);
  1588. };
  1589. /*:857*//*860:*/
  1590. #line 18437 "./typica.w"
  1591. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1592. {
  1593. Q_OBJECT
  1594. public:
  1595. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1596. private slots:
  1597. void updateLabel(const QString&text);
  1598. void updateMinimum(const QString&minimum);
  1599. void updateMaximum(const QString&maximum);
  1600. void updatePrecision(int precision);
  1601. void updatePretext(const QString&text);
  1602. void updatePosttext(const QString&text);
  1603. };
  1604. /*:860*//*863:*/
  1605. #line 12 "./freeannotation.w"
  1606. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1607. {
  1608. Q_OBJECT
  1609. public:
  1610. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1611. private slots:
  1612. void updateLabel(const QString&text);
  1613. };
  1614. /*:863*//*867:*/
  1615. #line 11 "./settings.w"
  1616. class SettingsWindow:public QMainWindow
  1617. {
  1618. Q_OBJECT
  1619. public:
  1620. SettingsWindow();
  1621. };
  1622. /*:867*//*872:*/
  1623. #line 8 "./graphsettings.w"
  1624. class GraphSettingsWidget:public QWidget
  1625. {
  1626. Q_OBJECT
  1627. public:
  1628. GraphSettingsWidget();
  1629. };
  1630. /*:872*//*874:*/
  1631. #line 46 "./graphsettings.w"
  1632. class GraphSettingsRelativeTab:public QWidget
  1633. {
  1634. Q_OBJECT
  1635. public:
  1636. GraphSettingsRelativeTab();
  1637. public slots:
  1638. void updateEnableSetting(bool enable);
  1639. void updateColorSetting(const QString&color);
  1640. void updateAxisSetting(const QString&gridList);
  1641. void updateUnit(int unit);
  1642. void showColorPicker();
  1643. private:
  1644. QLineEdit*colorEdit;
  1645. };
  1646. /*:874*//*878:*/
  1647. #line 15 "./colorsettings.w"
  1648. class ColorSettingsWidget:public QWidget
  1649. {
  1650. Q_OBJECT
  1651. public:
  1652. ColorSettingsWidget();
  1653. public slots:
  1654. void updateEnable(bool enable);
  1655. void updateAddress(const QString&address);
  1656. void updateScale(int sccale);
  1657. };
  1658. /*:878*//*882:*/
  1659. #line 7 "./advancedsettings.w"
  1660. class AdvancedSettingsWidget:public QWidget
  1661. {
  1662. Q_OBJECT
  1663. public:
  1664. AdvancedSettingsWidget();
  1665. public slots:
  1666. void enableDiagnosticLogging(bool enabled);
  1667. };
  1668. /*:882*//*886:*/
  1669. #line 18562 "./typica.w"
  1670. class ModbusRTUDevice:public QObject
  1671. {
  1672. Q_OBJECT
  1673. public:
  1674. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1675. ~ModbusRTUDevice();
  1676. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1677. Q_INVOKABLE double SVLower();
  1678. Q_INVOKABLE double SVUpper();
  1679. Q_INVOKABLE int decimals();
  1680. QList<Channel*> channels;
  1681. public slots:
  1682. void outputSV(double sv);
  1683. signals:
  1684. void SVLowerChanged(double);
  1685. void SVUpperChanged(double);
  1686. void SVDecimalChanged(int);
  1687. void queueEmpty();
  1688. private slots:
  1689. void dataAvailable();
  1690. void sendNextMessage();
  1691. void decimalResponse(QByteArray response);
  1692. void unitResponse(QByteArray response);
  1693. void svlResponse(QByteArray response);
  1694. void svuResponse(QByteArray response);
  1695. void requestMeasurement();
  1696. void mResponse(QByteArray response);
  1697. void ignore(QByteArray response);
  1698. void timeout();
  1699. private:
  1700. QextSerialPort*port;
  1701. QByteArray responseBuffer;
  1702. QList<QByteArray> messageQueue;
  1703. QList<QObject*> retObjQueue;
  1704. QList<char*> callbackQueue;
  1705. quint16 calculateCRC(QByteArray data);
  1706. QTimer*messageDelayTimer;
  1707. QTimer*commTimeout;
  1708. int delayTime;
  1709. char station;
  1710. int decimalPosition;
  1711. int valueF;
  1712. int valueC;
  1713. bool unitIsF;
  1714. double outputSVLower;
  1715. double outputSVUpper;
  1716. QByteArray outputSVStub;
  1717. QByteArray pvStub;
  1718. QByteArray svStub;
  1719. QByteArray mStub;
  1720. quint16 pvaddress;
  1721. quint16 svaddress;
  1722. bool svenabled;
  1723. bool readingsv;
  1724. double savedpv;
  1725. bool waiting;
  1726. };
  1727. /*:886*//*902:*/
  1728. #line 19260 "./typica.w"
  1729. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1730. {
  1731. Q_OBJECT
  1732. public:
  1733. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1734. private slots:
  1735. void updatePort(const QString&newPort);
  1736. void updateBaudRate(const QString&newRate);
  1737. void updateParity(const QString&newParity);
  1738. void updateFlowControl(const QString&newFlow);
  1739. void updateStopBits(const QString&newStopBits);
  1740. void updateStation(int station);
  1741. void updateFixedDecimal(bool fixed);
  1742. void updateDecimalAddress(int address);
  1743. void updateDecimalPosition(int position);
  1744. void updateFixedUnit(bool fixed);
  1745. void updateUnitAddress(int address);
  1746. void updateValueForF(int value);
  1747. void updateValueForC(int value);
  1748. void updateUnit(const QString&newUnit);
  1749. void updatePVAddress(int address);
  1750. void updateSVEnabled(bool enabled);
  1751. void updateSVReadAddress(int address);
  1752. void updateDeviceLimit(bool query);
  1753. void updateSVLowerAddress(int address);
  1754. void updateSVUpperAddress(int address);
  1755. void updateSVLower(double value);
  1756. void updateSVUpper(double value);
  1757. void updateSVWritable(bool canWriteSV);
  1758. void updateSVWriteAddress(int address);
  1759. void updatePVColumnName(const QString&name);
  1760. void updateSVColumnName(const QString&name);
  1761. void updatePVHidden(bool hidden);
  1762. void updateSVHidden(bool hidden);
  1763. private:
  1764. PortSelector*port;
  1765. BaudSelector*baud;
  1766. ParitySelector*parity;
  1767. FlowSelector*flow;
  1768. StopSelector*stop;
  1769. QSpinBox*station;
  1770. QCheckBox*decimalQuery;
  1771. ShortHexSpinBox*decimalAddress;
  1772. QSpinBox*decimalPosition;
  1773. QCheckBox*unitQuery;
  1774. ShortHexSpinBox*unitAddress;
  1775. QSpinBox*valueF;
  1776. QSpinBox*valueC;
  1777. QComboBox*fixedUnit;
  1778. ShortHexSpinBox*pVAddress;
  1779. QCheckBox*sVEnabled;
  1780. ShortHexSpinBox*sVReadAddress;
  1781. QCheckBox*deviceLimit;
  1782. ShortHexSpinBox*sVLowerAddr;
  1783. ShortHexSpinBox*sVUpperAddr;
  1784. QDoubleSpinBox*sVLower;
  1785. QDoubleSpinBox*sVUpper;
  1786. QCheckBox*sVWritable;
  1787. ShortHexSpinBox*sVOutputAddr;
  1788. QLineEdit*pVColumnName;
  1789. QLineEdit*sVColumnName;
  1790. };
  1791. /*:902*//*906:*/
  1792. #line 22 "./modbus.w"
  1793. class ModbusNGConfWidget:public BasicDeviceConfigurationWidget
  1794. {
  1795. Q_OBJECT
  1796. public:
  1797. Q_INVOKABLE ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1798. private slots:
  1799. void updatePort(const QString&value);
  1800. void updateBaudRate(const QString&value);
  1801. void updateParity(int value);
  1802. void updateFlowControl(int value);
  1803. void updateStopBits(int value);
  1804. void addInput();
  1805. private:
  1806. ParitySelector*m_parity;
  1807. FlowSelector*m_flow;
  1808. StopSelector*m_stop;
  1809. };
  1810. /*:906*//*908:*/
  1811. #line 144 "./modbus.w"
  1812. class ModbusNGInputConfWidget:public BasicDeviceConfigurationWidget
  1813. {
  1814. Q_OBJECT
  1815. public:
  1816. Q_INVOKABLE ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1817. private slots:
  1818. void updateStation(int value);
  1819. void updateAddress(int value);
  1820. void updateFunction(int value);
  1821. void updateFormat(int value);
  1822. void updateDecimals(int value);
  1823. void updateUnit(int value);
  1824. void updateColumnName(const QString&value);
  1825. void updateHidden(bool value);
  1826. };
  1827. /*:908*//*912:*/
  1828. #line 342 "./modbus.w"
  1829. enum ModbusDataFormat
  1830. {
  1831. Int16,
  1832. FloatHL,
  1833. FloatLH
  1834. };
  1835. struct ModbusScanItem
  1836. {
  1837. QByteArray request;
  1838. ModbusDataFormat format;
  1839. int decimalPosition;
  1840. Units::Unit unit;
  1841. mutable double lastValue;
  1842. };
  1843. /*:912*//*913:*/
  1844. #line 362 "./modbus.w"
  1845. class ModbusNG:public QObject
  1846. {
  1847. Q_OBJECT
  1848. public:
  1849. ModbusNG(DeviceTreeModel*model,const QModelIndex&index);
  1850. ~ModbusNG();
  1851. Q_INVOKABLE int channelCount();
  1852. Channel*getChannel(int);
  1853. Q_INVOKABLE QString channelColumnName(int);
  1854. Q_INVOKABLE QString channelIndicatorText(int);
  1855. Q_INVOKABLE bool isChannelHidden(int);
  1856. Q_INVOKABLE QString channelType(int);
  1857. private slots:
  1858. void sendNextMessage();
  1859. void timeout();
  1860. void dataAvailable();
  1861. void rateLimitTimeout();
  1862. private:
  1863. quint16 calculateCRC(QByteArray data);
  1864. QextSerialPort*port;
  1865. int delayTime;
  1866. QTimer*messageDelayTimer;
  1867. QTimer*commTimeout;
  1868. QTimer*rateLimiter;
  1869. int scanPosition;
  1870. bool waiting;
  1871. QByteArray responseBuffer;
  1872. QList<Channel*> channels;
  1873. QList<ModbusScanItem> scanList;
  1874. QList<QString> channelNames;
  1875. QList<QString> channelLabels;
  1876. QList<bool> hiddenStates;
  1877. QList<QString> channelTypeList;
  1878. QVector<double> lastMeasurement;
  1879. };
  1880. /*:913*//*918:*/
  1881. #line 36 "./unsupportedserial.w"
  1882. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1883. {
  1884. Q_OBJECT
  1885. public:
  1886. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1887. const QModelIndex&index);
  1888. private slots:
  1889. void updateConfiguration();
  1890. void saveScript();
  1891. void addChannel();
  1892. private:
  1893. SaltModel*deviceSettingsModel;
  1894. QTextEdit*scriptEditor;
  1895. };
  1896. /*:918*//*923:*/
  1897. #line 166 "./unsupportedserial.w"
  1898. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1899. {
  1900. Q_OBJECT
  1901. public:
  1902. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1903. const QModelIndex&index);
  1904. private slots:
  1905. void updateColumnName(const QString&value);
  1906. void updateHidden(bool hidden);
  1907. void updateConfiguration();
  1908. private:
  1909. SaltModel*channelSettingsModel;
  1910. };
  1911. /*:923*//*928:*/
  1912. #line 298 "./unsupportedserial.w"
  1913. class JavaScriptDevice:public QObject
  1914. {
  1915. Q_OBJECT
  1916. public:
  1917. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1918. QScriptEngine*engine);
  1919. Q_INVOKABLE int channelCount();
  1920. Channel*getChannel(int channel);
  1921. Q_INVOKABLE bool isChannelHidden(int channel);
  1922. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1923. Q_INVOKABLE QString channelColumnName(int channel);
  1924. Q_INVOKABLE QString channelIndicatorText(int channel);
  1925. public slots:
  1926. void setTemperatureColumn(int tcol);
  1927. void setAnnotationColumn(int ncol);
  1928. void start();
  1929. void stop();
  1930. signals:
  1931. void annotation(QString note,int tcol,int ncol);
  1932. void triggerStartBatch();
  1933. void triggerStopBatch();
  1934. void deviceStopRequested();
  1935. private:
  1936. QVariantMap deviceSettings;
  1937. QString deviceScript;
  1938. QList<Channel*> channelList;
  1939. QList<bool> hiddenState;
  1940. QList<Units::Unit> channelUnits;
  1941. QList<QString> columnNames;
  1942. QList<QString> indicatorTexts;
  1943. QList<QVariantMap> channelSettings;
  1944. int annotationTemperatureColumn;
  1945. int annotationNoteColumn;
  1946. QScriptEngine*scriptengine;
  1947. };
  1948. /*:928*//*950:*/
  1949. #line 11 "./phidgets.w"
  1950. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1951. {
  1952. Q_OBJECT
  1953. public:
  1954. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1955. const QModelIndex&index);
  1956. private slots:
  1957. void addChannel();
  1958. void updateRate(int ms);
  1959. };
  1960. /*:950*//*954:*/
  1961. #line 82 "./phidgets.w"
  1962. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1963. {
  1964. Q_OBJECT
  1965. public:
  1966. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1967. const QModelIndex&index);
  1968. private slots:
  1969. void updateColumnName(const QString&value);
  1970. void updateHidden(bool hidden);
  1971. void updateTC(int index);
  1972. void updateChannel(int channel);
  1973. private:
  1974. QComboBox*tcType;
  1975. };
  1976. /*:954*//*959:*/
  1977. #line 213 "./phidgets.w"
  1978. class PhidgetsTemperatureSensor:public QObject
  1979. {
  1980. Q_OBJECT
  1981. public:
  1982. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1983. Q_INVOKABLE int channelCount();
  1984. Channel*getChannel(int channel);
  1985. Q_INVOKABLE bool isChannelHidden(int channel);
  1986. Q_INVOKABLE QString channelColumnName(int channel);
  1987. Q_INVOKABLE QString channelIndicatorText(int channel);
  1988. public slots:
  1989. void start();
  1990. void stop();
  1991. private slots:
  1992. void getMeasurements();
  1993. private:
  1994. QList<int> channelIndices;
  1995. QList<int> tctypes;
  1996. QList<Channel*> channelList;
  1997. QMap<int,Channel*> channelMap;
  1998. QList<bool> hiddenState;
  1999. QList<QString> columnNames;
  2000. QList<QString> indicatorTexts;
  2001. QLibrary driver;
  2002. QTimer sampleTimer;
  2003. void*device;
  2004. /*963:*/
  2005. #line 349 "./phidgets.w"
  2006. #ifdef _WIN32
  2007. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  2008. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  2009. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  2010. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  2011. #else
  2012. typedef int(*PhidgetHandleOnly)(void*);
  2013. typedef int(*PhidgetHandleInt)(void*,int);
  2014. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  2015. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  2016. #endif
  2017. PhidgetHandleOnly createDevice;
  2018. PhidgetHandleInt openDevice;
  2019. PhidgetHandleInt waitForOpen;
  2020. PhidgetHandleIntInt setTCType;
  2021. PhidgetHandleIntDoubleOut getTemperature;
  2022. PhidgetHandleOnly closeDevice;
  2023. PhidgetHandleOnly deleteDevice;
  2024. /*:963*/
  2025. #line 240 "./phidgets.w"
  2026. };
  2027. /*:959*//*974:*/
  2028. #line 46 "./phidget22.w"
  2029. class PhidgetConfWidget:public BasicDeviceConfigurationWidget
  2030. {
  2031. Q_OBJECT
  2032. public:
  2033. Q_INVOKABLE PhidgetConfWidget(DeviceTreeModel*model,
  2034. const QModelIndex&index);
  2035. private slots:
  2036. void addChannel();
  2037. };
  2038. /*:974*//*976:*/
  2039. #line 96 "./phidget22.w"
  2040. class PhidgetChannelSelector:public QComboBox
  2041. {
  2042. Q_OBJECT
  2043. public:
  2044. PhidgetChannelSelector();
  2045. ~PhidgetChannelSelector();
  2046. void addChannel(void*device);
  2047. void removeChannel(void*device);
  2048. private:
  2049. QLibrary driver;
  2050. void*manager;
  2051. /*978:*/
  2052. #line 141 "./phidget22.w"
  2053. PhidgetPointer createManager;
  2054. PhidgetPointerCallbackPointer setOnAttachManager;
  2055. PhidgetPointerCallbackPointer setOnDetachManager;
  2056. PhidgetPointer openManager;
  2057. PhidgetPointerStringOut getDeviceName;
  2058. PhidgetPointerIntOut getDeviceSerialNumber;
  2059. PhidgetPointerIntOut getChannel;
  2060. PhidgetPointerIntOut getChannelClass;
  2061. PhidgetPointerIntOut getChannelSubclass;
  2062. PhidgetPointerIntOut getHubPort;
  2063. PhidgetPointer closeManager;
  2064. PhidgetPointer deleteManager;
  2065. /*:978*/
  2066. #line 108 "./phidget22.w"
  2067. };
  2068. /*:976*//*986:*/
  2069. #line 298 "./phidget22.w"
  2070. class PhidgetChannelConfWidget:public BasicDeviceConfigurationWidget
  2071. {
  2072. Q_OBJECT
  2073. public:
  2074. Q_INVOKABLE PhidgetChannelConfWidget(DeviceTreeModel*model,
  2075. const QModelIndex&index);
  2076. public slots:
  2077. void changeSelectedChannel(int index);
  2078. void updateSerialNumber(const QString&value);
  2079. void updateChannel(const QString&value);
  2080. void updateHubPort(const QString&value);
  2081. void updateColumnName(const QString&value);
  2082. void updateChannelType(int value);
  2083. void updateTCType(int value);
  2084. void updateRTDType(int value);
  2085. void updateRTDWiring(int value);
  2086. void updateHidden(int value);
  2087. private:
  2088. PhidgetChannelSelector*channelSelector;
  2089. QLineEdit*serialNumber;
  2090. QLineEdit*channel;
  2091. QLineEdit*hubPort;
  2092. QComboBox*subtype;
  2093. QStackedLayout*subtypeLayout;
  2094. QComboBox*tctype;
  2095. QComboBox*rtdtype;
  2096. QComboBox*rtdwiring;
  2097. };
  2098. /*:986*//*990:*/
  2099. #line 538 "./phidget22.w"
  2100. struct PhidgetChannelData
  2101. {
  2102. Channel*channel;
  2103. QString columnName;
  2104. QString indicatorLabel;
  2105. int serialNumber;
  2106. int channelNumber;
  2107. int channelType;
  2108. int hubPort;
  2109. int tcType;
  2110. int rtdType;
  2111. int wiring;
  2112. bool hidden;
  2113. void*device;
  2114. };
  2115. /*:990*//*991:*/
  2116. #line 559 "./phidget22.w"
  2117. class Phidget22:public QObject
  2118. {
  2119. Q_OBJECT
  2120. public:
  2121. Q_INVOKABLE Phidget22(const QModelIndex&deviceIndex);
  2122. Q_INVOKABLE int channelCount();
  2123. Channel*getChannel(int channel);
  2124. Q_INVOKABLE bool isChannelHidden(int channel);
  2125. Q_INVOKABLE QString channelColumnName(int channel);
  2126. Q_INVOKABLE QString channelIndicatorText(int channel);
  2127. public slots:
  2128. void start();
  2129. void stop();
  2130. private:
  2131. QList<PhidgetChannelData*> channelConfiguration;
  2132. QLibrary driver;
  2133. PhidgetPointer p_createTemperatureSensor;
  2134. PhidgetPointerIntIn p_setSerialNumber;
  2135. PhidgetPointerIntIn p_setChannelNumber;
  2136. PhidgetPointerIntIn p_setHubPort;
  2137. PhidgetPointerIntIn p_setTCType;
  2138. PhidgetPointerIntIn p_setRTDType;
  2139. PhidgetPointerIntIn p_setRTDWiring;
  2140. PhidgetPointerVCPointer p_setNewDataCallback;
  2141. PhidgetPointerIntIn p_open;
  2142. PhidgetPointer p_close;
  2143. PhidgetPointer p_delete;
  2144. };
  2145. /*:991*//*1004:*/
  2146. #line 19802 "./typica.w"
  2147. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  2148. {
  2149. Q_OBJECT
  2150. public:
  2151. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  2152. const QModelIndex&index);
  2153. private slots:
  2154. void updateSourceColumn(const QString&source);
  2155. void updateDestinationColumn(const QString&dest);
  2156. void updateKnots();
  2157. private:
  2158. SaltModel*tablemodel;
  2159. };
  2160. /*:1004*//*1010:*/
  2161. #line 19932 "./typica.w"
  2162. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  2163. {
  2164. Q_OBJECT
  2165. public:
  2166. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  2167. const QModelIndex&index);
  2168. private slots:
  2169. void updateResetTime(QTime time);
  2170. };
  2171. /*:1010*//*1014:*/
  2172. #line 19998 "./typica.w"
  2173. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  2174. {
  2175. Q_OBJECT
  2176. public:
  2177. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2178. private slots:
  2179. void updateStartButtonText(const QString&text);
  2180. void updateStopButtonText(const QString&text);
  2181. void updateStartColumnName(const QString&text);
  2182. void updateStopColumnName(const QString&text);
  2183. void updateStartValue(const QString&text);
  2184. void updateStopValue(const QString&text);
  2185. void updateStartTrigger(int option);
  2186. void updateStopTrigger(int option);
  2187. };
  2188. /*:1014*//*1019:*/
  2189. #line 20250 "./typica.w"
  2190. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  2191. {
  2192. Q_OBJECT
  2193. public:
  2194. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  2195. const QModelIndex&index);
  2196. private slots:
  2197. void updateColumnName(const QString&text);
  2198. void updateRangeData();
  2199. private:
  2200. SaltModel*tablemodel;
  2201. };
  2202. /*:1019*//*1024:*/
  2203. #line 20352 "./typica.w"
  2204. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  2205. {
  2206. Q_OBJECT
  2207. public:
  2208. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2209. private slots:
  2210. void updateMatchingColumn(const QString&column);
  2211. void updateTemperature();
  2212. void updateDelay();
  2213. private:
  2214. QDoubleSpinBox*temperatureValue;
  2215. QComboBox*unitSelector;
  2216. QSpinBox*delaySelector;
  2217. };
  2218. /*:1024*//*1028:*/
  2219. #line 16 "./rate.w"
  2220. class RateOfChange:public QObject
  2221. {
  2222. Q_OBJECT
  2223. public:
  2224. RateOfChange(int cachetime= 1,int scaletime= 1);
  2225. public slots:
  2226. void newMeasurement(Measurement measure);
  2227. void setCacheTime(int seconds);
  2228. void setScaleTime(int seconds);
  2229. signals:
  2230. void newData(Measurement measure);
  2231. private:
  2232. int ct;
  2233. int st;
  2234. QList<Measurement> cache;
  2235. };
  2236. /*:1028*//*1036:*/
  2237. #line 177 "./rate.w"
  2238. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  2239. {
  2240. Q_OBJECT
  2241. public:
  2242. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2243. private slots:
  2244. void updateColumn(const QString&column);
  2245. void updateCacheTime(const QString&seconds);
  2246. void updateScaleTime(const QString&seconds);
  2247. };
  2248. /*:1036*//*1042:*/
  2249. #line 15 "./mergeseries.w"
  2250. class MergeSeries:public QObject
  2251. {
  2252. Q_OBJECT
  2253. public:
  2254. MergeSeries();
  2255. public slots:
  2256. void in1(Measurement measure);
  2257. void in2(Measurement measure);
  2258. signals:
  2259. void newData(Measurement measure);
  2260. protected:
  2261. virtual void calculate(Measurement m1,Measurement m2)= 0;
  2262. private:
  2263. Measurement last1;
  2264. Measurement last2;
  2265. bool received1;
  2266. bool received2;
  2267. };
  2268. class DifferenceSeries:public MergeSeries
  2269. {
  2270. Q_OBJECT
  2271. public:
  2272. DifferenceSeries();
  2273. protected:
  2274. void calculate(Measurement m1,Measurement m2);
  2275. };
  2276. class MeanSeries:public MergeSeries
  2277. {
  2278. Q_OBJECT
  2279. public:
  2280. MeanSeries();
  2281. protected:
  2282. void calculate(Measurement m1,Measurement m2);
  2283. };
  2284. /*:1042*//*1050:*/
  2285. #line 167 "./mergeseries.w"
  2286. class MergeSeriesConfWidget:public BasicDeviceConfigurationWidget
  2287. {
  2288. Q_OBJECT
  2289. public:
  2290. Q_INVOKABLE MergeSeriesConfWidget(DeviceTreeModel*model,
  2291. const QModelIndex&index);
  2292. private slots:
  2293. void updateColumn1(const QString&column);
  2294. void updateColumn2(const QString&column);
  2295. void updateOutput(const QString&column);
  2296. void updateType(int type);
  2297. };
  2298. /*:1050*//*1056:*/
  2299. #line 19 "./dataqsdk.w"
  2300. class DataqSdkDeviceImplementation;
  2301. class DataqSdkDevice:public QObject
  2302. {
  2303. Q_OBJECT
  2304. DataqSdkDeviceImplementation*imp;
  2305. private slots:
  2306. void threadFinished();
  2307. public:
  2308. DataqSdkDevice(QString device);
  2309. ~DataqSdkDevice();
  2310. Channel*newChannel(Units::Unit scale);
  2311. Q_INVOKABLE void setClockRate(double Hz);
  2312. Q_INVOKABLE void start();
  2313. static QStringList detectPorts();
  2314. static QStringList detectHardware();
  2315. };
  2316. /*:1056*//*1057:*/
  2317. #line 49 "./dataqsdk.w"
  2318. class DataqSdkDeviceImplementation:public QThread
  2319. {
  2320. Q_OBJECT
  2321. public:
  2322. DataqSdkDeviceImplementation();
  2323. ~DataqSdkDeviceImplementation();
  2324. void run();
  2325. /*1058:*/
  2326. #line 70 "./dataqsdk.w"
  2327. typedef struct di_inlist_struct{
  2328. unsigned short chan;
  2329. unsigned short diff;
  2330. unsigned short gain;
  2331. unsigned short unipolar;
  2332. unsigned short dig_out_enable;
  2333. unsigned short dig_out;
  2334. unsigned short ave;
  2335. unsigned short counter;
  2336. }DI_INLIST_STRUCT;
  2337. typedef int(PASCAL*FPDIOPEN)(unsigned);
  2338. typedef int(PASCAL*FPDICLOSE)(void);
  2339. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  2340. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  2341. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  2342. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  2343. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  2344. typedef int(PASCAL*FPDISTARTSCAN)(void);
  2345. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  2346. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  2347. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  2348. typedef int(PASCAL*FPDISTOPSCAN)(void);
  2349. FPDIOPEN di_open;
  2350. FPDICLOSE di_close;
  2351. FPDISAMPLERATE di_sample_rate;
  2352. FPDIMAXIMUMRATE di_maximum_rate;
  2353. FPDILISTLENGTH di_list_length;
  2354. FPDIINLIST di_inlist;
  2355. FPDIBUFFERALLOC di_buffer_alloc;
  2356. FPDISTARTSCAN di_start_scan;
  2357. FPDISTATUSREAD di_status_read;
  2358. FPDIBUFFERSTATUS di_buffer_status;
  2359. FPDIBURSTRATE di_burst_rate;
  2360. FPDISTOPSCAN di_stop_scan;
  2361. /*:1058*/
  2362. #line 57 "./dataqsdk.w"
  2363. /*1060:*/
  2364. #line 134 "./dataqsdk.w"
  2365. bool isOpen;
  2366. double sampleRate;
  2367. long oversample;
  2368. long burstDivisor;
  2369. QString device;
  2370. unsigned deviceNumber;
  2371. QVector<Channel*> channelMap;
  2372. int error;
  2373. int channels;
  2374. bool ready;
  2375. QLibrary*driver;
  2376. QVector<Units::Unit> unitMap;
  2377. int*input_buffer;
  2378. QTimer*eventClock;
  2379. QMultiMap<int,double> smoother;
  2380. /*:1060*/
  2381. #line 58 "./dataqsdk.w"
  2382. public slots:
  2383. void measure();
  2384. private:
  2385. qint16*buffer;
  2386. };
  2387. /*:1057*//*1077:*/
  2388. #line 663 "./dataqsdk.w"
  2389. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2390. {
  2391. Q_OBJECT
  2392. public:
  2393. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2394. const QModelIndex&index);
  2395. private slots:
  2396. void updateAutoSelect(bool automatic);
  2397. void updateDeviceNumber(int deviceNumber);
  2398. void updatePort(QString portId);
  2399. void addChannel();
  2400. private:
  2401. QStackedWidget*deviceIdStack;
  2402. };
  2403. /*:1077*//*1082:*/
  2404. #line 808 "./dataqsdk.w"
  2405. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2406. {
  2407. Q_OBJECT
  2408. public:
  2409. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2410. const QModelIndex&index);
  2411. private slots:
  2412. void updateUnits(const QString&unit);
  2413. void updateColumnName(const QString&value);
  2414. void updateMeasuredLower(const QString&value);
  2415. void updateMeasuredUpper(const QString&value);
  2416. void updateMappedLower(const QString&value);
  2417. void updateMappedUpper(const QString&value);
  2418. void updateClosedInterval(bool closed);
  2419. void updateSmoothingEnabled(bool enabled);
  2420. void updateSensitivity(const QString&value);
  2421. void startCalibration();
  2422. void stopCalibration();
  2423. void resetCalibration();
  2424. void updateInput(Measurement measure);
  2425. void updateOutput(Measurement measure);
  2426. void updateHidden(bool hidden);
  2427. private:
  2428. QPushButton*startButton;
  2429. QPushButton*resetButton;
  2430. QPushButton*stopButton;
  2431. /*1087:*/
  2432. #line 1098 "./dataqsdk.w"
  2433. bool autoSelect;
  2434. QString deviceID;
  2435. unsigned int channelOfInterest;
  2436. /*:1087*/
  2437. #line 835 "./dataqsdk.w"
  2438. DataqSdkDevice*calibrationDevice;
  2439. LinearCalibrator*calibrator;
  2440. QLineEdit*currentMeasurement;
  2441. QLineEdit*minimumMeasurement;
  2442. QLineEdit*maximumMeasurement;
  2443. QLineEdit*averageMeasurement;
  2444. QLineEdit*currentMapped;
  2445. QLineEdit*minimumMapped;
  2446. QLineEdit*maximumMapped;
  2447. QLineEdit*averageMapped;
  2448. int rmCount;
  2449. int cmCount;
  2450. double rmin;
  2451. double rmax;
  2452. double rmean;
  2453. double cmin;
  2454. double cmax;
  2455. double cmean;
  2456. };
  2457. /*:1082*//*1109:*/
  2458. #line 273 "./scales.w"
  2459. Q_DECLARE_METATYPE(BaudRateType)
  2460. Q_DECLARE_METATYPE(DataBitsType)
  2461. Q_DECLARE_METATYPE(ParityType)
  2462. Q_DECLARE_METATYPE(StopBitsType)
  2463. Q_DECLARE_METATYPE(FlowType)
  2464. /*:1109*//*1116:*/
  2465. #line 396 "./scales.w"
  2466. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2467. {
  2468. Q_OBJECT
  2469. public:
  2470. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2471. const QModelIndex&index);
  2472. private slots:
  2473. void updatePort(const QString&newPort);
  2474. void updateBaudRate(const QString&rate);
  2475. void updateParity(int index);
  2476. void updateFlowControl(int index);
  2477. void updateStopBits(int index);
  2478. void updateWeighCommand(const QString&command);
  2479. void updateCommandTerminator(const QString&terminator);
  2480. private:
  2481. PortSelector*port;
  2482. BaudSelector*baud;
  2483. ParitySelector*parity;
  2484. FlowSelector*flow;
  2485. StopSelector*stop;
  2486. QLineEdit*weighcommand;
  2487. QComboBox*commandterminator;
  2488. };
  2489. /*:1116*//*1121:*/
  2490. #line 14 "./valueannotation.w"
  2491. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2492. {
  2493. Q_OBJECT
  2494. public:
  2495. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2496. const QModelIndex&index);
  2497. private slots:
  2498. void updateSourceColumn(const QString&source);
  2499. void updateAnnotations();
  2500. void updateStart(bool noteOnStart);
  2501. private:
  2502. SaltModel*tablemodel;
  2503. };
  2504. /*:1121*//*1129:*/
  2505. #line 165 "./valueannotation.w"
  2506. class ValueAnnotation:public QObject
  2507. {
  2508. Q_OBJECT
  2509. public:
  2510. ValueAnnotation();
  2511. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2512. public slots:
  2513. void newMeasurement(Measurement measure);
  2514. void annotate();
  2515. void setAnnotationColumn(int column);
  2516. void setTemperatureColumn(int column);
  2517. void setTolerance(double epsilon);
  2518. signals:
  2519. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2520. private:
  2521. int lastIndex;
  2522. int annotationColumn;
  2523. int measurementColumn;
  2524. QList<double> values;
  2525. QStringList annotations;
  2526. double tolerance;
  2527. };
  2528. /*:1129*//*1138:*/
  2529. #line 14 "./thresholdannotation.w"
  2530. class ThresholdAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2531. {
  2532. Q_OBJECT
  2533. public:
  2534. Q_INVOKABLE ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  2535. const QModelIndex&index);
  2536. private slots:
  2537. void updateSourceColumn(const QString&source);
  2538. void updateThreshold(double value);
  2539. void updateDirection(int index);
  2540. void updateAnnotation(const QString&note);
  2541. };
  2542. /*:1138*//*1143:*/
  2543. #line 127 "./thresholdannotation.w"
  2544. class Annotator:public QObject
  2545. {
  2546. Q_OBJECT
  2547. QString note;
  2548. int tc;
  2549. int ac;
  2550. QTimer t;
  2551. public:
  2552. Annotator(const QString&text);
  2553. public slots:
  2554. void setAnnotation(const QString&annotation);
  2555. void setTemperatureColumn(int tempcolumn);
  2556. void setAnnotationColumn(int annotationcolumn);
  2557. void annotate();
  2558. private slots:
  2559. void catchTimer();
  2560. signals:
  2561. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2562. };
  2563. /*:1143*//*1154:*/
  2564. #line 78 "./user.w"
  2565. class LoginDialog:public QDialog
  2566. {
  2567. Q_OBJECT
  2568. public:
  2569. LoginDialog();
  2570. public slots:
  2571. void attemptLogin();
  2572. private:
  2573. QLineEdit*user;
  2574. QLineEdit*password;
  2575. QLabel*warning;
  2576. QPushButton*login;
  2577. };
  2578. /*:1154*//*1160:*/
  2579. #line 162 "./user.w"
  2580. class UserLabel:public QLabel
  2581. {
  2582. Q_OBJECT
  2583. public:
  2584. UserLabel();
  2585. public slots:
  2586. void updateLabel(const QString&user);
  2587. protected:
  2588. void mouseReleaseEvent(QMouseEvent*event);
  2589. };
  2590. /*:1160*//*1164:*/
  2591. #line 209 "./user.w"
  2592. class NewTypicaUser:public QDialog
  2593. {
  2594. Q_OBJECT
  2595. public:
  2596. NewTypicaUser();
  2597. public slots:
  2598. void createAndReset();
  2599. void createAndClose();
  2600. void validate();
  2601. void cancelValidate();
  2602. private:
  2603. void createNewUser();
  2604. QLineEdit*userField;
  2605. QLineEdit*passwordField;
  2606. QCheckBox*autoLogin;
  2607. QPushButton*saveAndCloseButton;
  2608. QPushButton*saveAndNewButton;
  2609. QPushButton*cancelButton;
  2610. };
  2611. /*:1164*//*1171:*/
  2612. #line 9 "./roastcoloredit.w"
  2613. class RoastColorEdit:public QWidget
  2614. {
  2615. Q_OBJECT
  2616. Q_PROPERTY(QString value READ value WRITE setValue)
  2617. public:
  2618. RoastColorEdit();
  2619. QString value();
  2620. public slots:
  2621. void setValue(const QString&color);
  2622. private slots:
  2623. void readColor();
  2624. void measureFinished();
  2625. void readFinished();
  2626. private:
  2627. QLineEdit*edit;
  2628. QNetworkReply*networkReply;
  2629. };
  2630. /*:1171*/
  2631. #line 528 "./typica.w"
  2632. /*981:*/
  2633. #line 203 "./phidget22.w"
  2634. void CCONV ChannelListAddChannel(void*,void*context,void*device)
  2635. {
  2636. PhidgetChannelSelector*list=
  2637. qobject_cast<PhidgetChannelSelector*> ((QObject*)context);
  2638. list->addChannel(device);
  2639. }
  2640. void CCONV ChannelListRemoveChannel(void*,void*context,void*device)
  2641. {
  2642. PhidgetChannelSelector*list=
  2643. qobject_cast<PhidgetChannelSelector*> ((QObject*)context);
  2644. list->removeChannel(device);
  2645. }
  2646. /*:981*//*996:*/
  2647. #line 762 "./phidget22.w"
  2648. void CCONV Phidget22ValueCallback(void*,void*context,double value)
  2649. {
  2650. Channel*channel= (Channel*)context;
  2651. QTime time= QTime::currentTime();
  2652. Measurement measure(value*9.0/5.0+32.0,time);
  2653. channel->input(measure);
  2654. }
  2655. /*:996*/
  2656. #line 529 "./typica.w"
  2657. /*12:*/
  2658. #line 820 "./typica.w"
  2659. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2660. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*engine);
  2661. /*:12*//*14:*/
  2662. #line 845 "./typica.w"
  2663. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2664. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2665. /*:14*//*19:*/
  2666. #line 905 "./typica.w"
  2667. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2668. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2669. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2670. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2671. QScriptEngine*engine);
  2672. /*:19*//*23:*/
  2673. #line 995 "./typica.w"
  2674. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2675. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2676. QScriptValue displayInfo(QScriptContext*context,QScriptEngine*engine);
  2677. /*:23*//*33:*/
  2678. #line 1229 "./typica.w"
  2679. QScriptValue constructQMainWindow(QScriptContext*context,
  2680. QScriptEngine*engine);
  2681. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2682. QScriptEngine*engine);
  2683. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2684. QScriptEngine*engine);
  2685. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2686. /*:33*//*38:*/
  2687. #line 1328 "./typica.w"
  2688. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2689. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2690. /*:38*//*41:*/
  2691. #line 1373 "./typica.w"
  2692. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2693. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2694. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2695. /*:41*//*44:*/
  2696. #line 1439 "./typica.w"
  2697. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2698. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2699. /*:44*//*47:*/
  2700. #line 1472 "./typica.w"
  2701. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2702. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2703. /*:47*//*50:*/
  2704. #line 1510 "./typica.w"
  2705. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2706. QScriptValue constructQSvgWidget(QScriptContext*context,
  2707. QScriptEngine*engine);
  2708. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2709. QScriptEngine*engine);
  2710. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2711. QStack<QLayout*> *layoutStack);
  2712. /*:50*//*56:*/
  2713. #line 1597 "./typica.w"
  2714. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2715. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2716. /*:56*//*60:*/
  2717. #line 1636 "./typica.w"
  2718. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2719. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2720. QScriptEngine*engine);
  2721. QScriptValue QSplitter_saveState(QScriptContext*context,
  2722. QScriptEngine*engine);
  2723. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2724. QScriptEngine*engine);
  2725. QScriptValue QSplitter_count(QScriptContext*context,
  2726. QScriptEngine*engine);
  2727. QScriptValue QSplitter_setCollapsible(QScriptContext*context,
  2728. QScriptEngine*engine);
  2729. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2730. /*:60*//*67:*/
  2731. #line 1797 "./typica.w"
  2732. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2733. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2734. /*:67*//*69:*/
  2735. #line 1852 "./typica.w"
  2736. QScriptValue constructQBoxLayout(QScriptContext*context,
  2737. QScriptEngine*engine);
  2738. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2739. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2740. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2741. /*:69*//*73:*/
  2742. #line 1965 "./typica.w"
  2743. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2744. QScriptValue QAction_setShortcut(QScriptContext*context,
  2745. QScriptEngine*engine);
  2746. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2747. /*:73*//*76:*/
  2748. #line 2021 "./typica.w"
  2749. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2750. QScriptEngine*engine);
  2751. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2752. QScriptEngine*engine);
  2753. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2754. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2755. /*:76*//*81:*/
  2756. #line 2132 "./typica.w"
  2757. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2758. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2759. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2760. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2761. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2762. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2763. QScriptValue QIODevice_readToString(QScriptContext*context,
  2764. QScriptEngine*engine);
  2765. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2766. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2767. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2768. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2769. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2770. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2771. /*:81*//*92:*/
  2772. #line 2358 "./typica.w"
  2773. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2774. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2775. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2776. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2777. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2778. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2779. /*:92*//*100:*/
  2780. #line 2476 "./typica.w"
  2781. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2782. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2783. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2784. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2785. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2786. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2787. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2788. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2789. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2790. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2791. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2792. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2793. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2794. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2795. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2796. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2797. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2798. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2799. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2800. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2801. /*:100*//*113:*/
  2802. #line 2750 "./typica.w"
  2803. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2804. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2805. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2806. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2807. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2808. /*:113*//*116:*/
  2809. #line 2855 "./typica.w"
  2810. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2811. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2812. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2813. QScriptValue QBuffer_data(QScriptContext*context,QScriptEngine*engine);
  2814. /*:116*//*119:*/
  2815. #line 2908 "./typica.w"
  2816. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2817. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2818. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2819. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2820. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2821. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2822. /*:119*//*125:*/
  2823. #line 2990 "./typica.w"
  2824. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2825. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2826. QScriptEngine*engine);
  2827. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2828. QScriptEngine*engine);
  2829. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2830. QScriptEngine*engine);
  2831. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2832. QScriptEngine*engine);
  2833. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2834. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2835. QScriptEngine*engine);
  2836. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2837. QScriptEngine*engine);
  2838. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2839. QScriptEngine*engine);
  2840. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2841. QScriptEngine*engine);
  2842. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2843. QScriptEngine*engine);
  2844. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2845. QScriptEngine*engine);
  2846. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2847. QScriptEngine*engine);
  2848. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2849. QScriptEngine*engine);
  2850. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2851. /*:125*//*134:*/
  2852. #line 3208 "./typica.w"
  2853. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2854. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2855. QScriptValue XmlReader_attribute(QScriptContext*context,
  2856. QScriptEngine*engine);
  2857. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2858. QScriptEngine*engine);
  2859. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2860. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2861. QScriptEngine*engine);
  2862. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2863. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2864. QScriptEngine*engine);
  2865. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2866. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2867. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2868. /*:134*//*141:*/
  2869. #line 3343 "./typica.w"
  2870. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2871. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2872. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2873. /*:141*//*145:*/
  2874. #line 3425 "./typica.w"
  2875. QScriptValue constructQLCDNumber(QScriptContext*context,
  2876. QScriptEngine*engine);
  2877. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2878. /*:145*//*148:*/
  2879. #line 3463 "./typica.w"
  2880. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2881. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2882. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2883. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2884. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2885. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2886. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2887. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2888. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2889. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2890. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2891. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2892. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2893. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2894. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2895. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2896. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2897. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2898. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2899. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2900. /*:148*//*164:*/
  2901. #line 3941 "./typica.w"
  2902. void setQAbstractScrollAreaProperties(QScriptValue value,
  2903. QScriptEngine*engine);
  2904. /*:164*//*166:*/
  2905. #line 3956 "./typica.w"
  2906. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2907. /*:166*//*168:*/
  2908. #line 3969 "./typica.w"
  2909. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2910. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2911. /*:168*//*170:*/
  2912. #line 3993 "./typica.w"
  2913. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2914. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2915. QScriptValue constructQPushButton(QScriptContext*context,
  2916. QScriptEngine*engine);
  2917. /*:170*//*177:*/
  2918. #line 4092 "./typica.w"
  2919. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2920. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2921. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2922. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2923. QScriptEngine*engine);
  2924. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2925. QScriptEngine*engine);
  2926. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2927. QScriptEngine*engine);
  2928. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2929. QScriptEngine*engine);
  2930. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2931. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2932. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2933. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2934. /*:177*//*184:*/
  2935. #line 4263 "./typica.w"
  2936. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2937. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2938. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2939. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2940. QScriptValue annotationFromRecord(QScriptContext*context,
  2941. QScriptEngine*engine);
  2942. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2943. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2944. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2945. /*:184*//*197:*/
  2946. #line 4610 "./typica.w"
  2947. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2948. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2949. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2950. QStack<QLayout*> *layoutStack);
  2951. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2952. QStack<QLayout*> *layoutStack);
  2953. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2954. QStack<QLayout*> *layoutStack);
  2955. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2956. QStack<QLayout*> *layoutStack);
  2957. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2958. QStack<QLayout*> *layoutStack);
  2959. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2960. QStack<QLayout*> *layoutStack);
  2961. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2962. QStack<QLayout*> *layoutStack);
  2963. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2964. QStack<QLayout*> *layoutStack);
  2965. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2966. QStack<QLayout*> *layoutStack);
  2967. void addTemperatureDisplayToSplitter(QDomElement element,
  2968. QStack<QWidget*> *widgetStack,
  2969. QStack<QLayout*> *layoutStack);
  2970. void addTemperatureDisplayToLayout(QDomElement element,
  2971. QStack<QWidget*> *widgetStack,
  2972. QStack<QLayout*> *layoutStack);
  2973. void addTimerDisplayToSplitter(QDomElement element,
  2974. QStack<QWidget*> *widgetStack,
  2975. QStack<QLayout*> *layoutStack);
  2976. void addTimerDisplayToLayout(QDomElement element,
  2977. QStack<QWidget*> *widgetStack,
  2978. QStack<QLayout*> *layoutStack);
  2979. void addDecorationToSplitter(QDomElement element,
  2980. QStack<QWidget*> *widgetStack,
  2981. QStack<QLayout*> *layoutStack);
  2982. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2983. QStack<QLayout*> *layoutStack);
  2984. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2985. QStack<QLayout*> *layoutStack);
  2986. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2987. QStack<QLayout*> *layoutStack);
  2988. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2989. QStack<QLayout*> *layoutStack);
  2990. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2991. QStack<QLayout*> *layoutStack);
  2992. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2993. QStack<QLayout*> *layoutStack);
  2994. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2995. QStack<QLayout*> *layoutStack);
  2996. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2997. QStack<QLayout*> *layoutStack);
  2998. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2999. QStack<QLayout*> *layoutStack);
  3000. void addSqlQueryViewToLayout(QDomElement element,
  3001. QStack<QWidget*> *widgetStack,
  3002. QStack<QLayout*> *layoutStack);
  3003. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3004. QStack<QLayout*> *layoutStack);
  3005. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3006. QStack<QLayout*> *layoutStack);
  3007. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3008. QStack<QLayout*> *layoutStack);
  3009. /*:197*//*226:*/
  3010. #line 5091 "./typica.w"
  3011. QScriptValue constructQTabBar(QScriptContext*context,QScriptEngine*engine);
  3012. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine);
  3013. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*engine);
  3014. /*:226*//*267:*/
  3015. #line 6394 "./typica.w"
  3016. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  3017. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  3018. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  3019. QScriptEngine*engine);
  3020. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  3021. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  3022. QScriptEngine*engine);
  3023. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  3024. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  3025. /*:267*//*270:*/
  3026. #line 6439 "./typica.w"
  3027. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  3028. /*:270*//*271:*/
  3029. #line 6447 "./typica.w"
  3030. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  3031. /*:271*//*275:*/
  3032. #line 6594 "./typica.w"
  3033. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  3034. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  3035. QScriptEngine*engine);
  3036. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  3037. QScriptEngine*engine);
  3038. QScriptValue SaltTable_columnSum(QScriptContext*context,
  3039. QScriptEngine*engine);
  3040. QScriptValue SaltTable_columnArray(QScriptContext*context,
  3041. QScriptEngine*engine);
  3042. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  3043. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  3044. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  3045. QScriptEngine*engine);
  3046. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  3047. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  3048. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  3049. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  3050. /*:275*//*285:*/
  3051. #line 6810 "./typica.w"
  3052. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  3053. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  3054. QScriptValue QComboBox_currentData(QScriptContext*context,
  3055. QScriptEngine*engine);
  3056. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  3057. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  3058. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  3059. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  3060. /*:285*//*297:*/
  3061. #line 379 "./units.w"
  3062. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  3063. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  3064. QScriptEngine*engine);
  3065. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  3066. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  3067. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  3068. /*:297*//*301:*/
  3069. #line 443 "./units.w"
  3070. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  3071. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  3072. /*:301*//*310:*/
  3073. #line 133 "./measurement.w"
  3074. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  3075. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  3076. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  3077. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  3078. /*:310*//*330:*/
  3079. #line 7445 "./typica.w"
  3080. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  3081. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  3082. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  3083. /*:330*//*339:*/
  3084. #line 7650 "./typica.w"
  3085. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  3086. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  3087. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  3088. /*:339*//*344:*/
  3089. #line 7751 "./typica.w"
  3090. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  3091. /*:344*//*350:*/
  3092. #line 7933 "./typica.w"
  3093. QScriptValue constructLinearCalibrator(QScriptContext*context,
  3094. QScriptEngine*engine);
  3095. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  3096. /*:350*//*355:*/
  3097. #line 8073 "./typica.w"
  3098. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  3099. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  3100. /*:355*//*365:*/
  3101. #line 8278 "./typica.w"
  3102. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  3103. QScriptEngine*engine);
  3104. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  3105. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  3106. QScriptEngine*engine);
  3107. /*:365*//*373:*/
  3108. #line 8437 "./typica.w"
  3109. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  3110. QScriptEngine*engine);
  3111. void setMeasurementTimeOffsetProperties(QScriptValue value,
  3112. QScriptEngine*engine);
  3113. /*:373*//*378:*/
  3114. #line 8560 "./typica.w"
  3115. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  3116. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  3117. /*:378*//*383:*/
  3118. #line 8658 "./typica.w"
  3119. QScriptValue constructZeroEmitter(QScriptContext*context,
  3120. QScriptEngine*engine);
  3121. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  3122. /*:383*//*388:*/
  3123. #line 8737 "./typica.w"
  3124. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  3125. QScriptEngine*engine);
  3126. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  3127. /*:388*//*405:*/
  3128. #line 9201 "./typica.w"
  3129. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  3130. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  3131. /*:405*//*428:*/
  3132. #line 9840 "./typica.w"
  3133. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  3134. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  3135. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  3136. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  3137. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  3138. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  3139. QScriptEngine*engine);
  3140. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  3141. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  3142. QScriptEngine*engnie);
  3143. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  3144. QScriptEngine*engine);
  3145. /*:428*//*466:*/
  3146. #line 10797 "./typica.w"
  3147. QScriptValue constructAnnotationButton(QScriptContext*context,
  3148. QScriptEngine*engine);
  3149. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  3150. /*:466*//*474:*/
  3151. #line 10937 "./typica.w"
  3152. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  3153. QScriptEngine*engine);
  3154. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3155. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3156. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3157. /*:474*//*495:*/
  3158. #line 11363 "./typica.w"
  3159. QScriptValue constructTimerDisplay(QScriptContext*context,
  3160. QScriptEngine*engine);
  3161. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  3162. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  3163. /*:495*//*523:*/
  3164. #line 11888 "./typica.w"
  3165. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  3166. QScriptValue constructWidgetDecorator(QScriptContext*context,
  3167. QScriptEngine*engine);
  3168. /*:523*//*536:*/
  3169. #line 12171 "./typica.w"
  3170. QScriptValue constructLogEditWindow(QScriptContext*context,
  3171. QScriptEngine*engine);
  3172. /*:536*//*555:*/
  3173. #line 12698 "./typica.w"
  3174. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  3175. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  3176. /*:555*//*574:*/
  3177. #line 204 "./webview.w"
  3178. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  3179. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  3180. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3181. QStack<QLayout*> *layoutStack);
  3182. /*:574*//*577:*/
  3183. #line 234 "./webview.w"
  3184. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  3185. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  3186. /*:577*//*581:*/
  3187. #line 292 "./webview.w"
  3188. QScriptValue constructWebElement(QScriptContext*context,
  3189. QScriptEngine*engine);
  3190. /*:581*//*593:*/
  3191. #line 67 "./printerselector.w"
  3192. QScriptValue constructPrinterSelector(QScriptContext*context,
  3193. QScriptEngine*engine);
  3194. void addPrinterSelectorToLayout(QDomElement element,
  3195. QStack<QWidget*> *widgetStack,
  3196. QStack<QLayout*> *layoutStack);
  3197. /*:593*//*608:*/
  3198. #line 13069 "./typica.w"
  3199. QScriptValue Application_subscribe(QScriptContext*context,
  3200. QScriptEngine*engine);
  3201. /*:608*//*666:*/
  3202. #line 14196 "./typica.w"
  3203. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  3204. QScriptValue constructSqlQueryView(QScriptContext*context,
  3205. QScriptEngine*engine);
  3206. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  3207. QScriptEngine*engine);
  3208. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  3209. QScriptEngine*engine);
  3210. /*:666*//*676:*/
  3211. #line 14435 "./typica.w"
  3212. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3213. QStack<QLayout*> *layoutStack);
  3214. /*:676*//*692:*/
  3215. #line 14720 "./typica.w"
  3216. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  3217. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  3218. /*:692*//*720:*/
  3219. #line 480 "./daterangeselector.w"
  3220. void addDateRangeToLayout(QDomElement element,
  3221. QStack<QWidget*> *widgetStack,
  3222. QStack<QLayout*> *layoutStack);
  3223. /*:720*//*729:*/
  3224. #line 14919 "./typica.w"
  3225. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3226. QStack<QLayout*> *layoutStack);
  3227. /*:729*//*750:*/
  3228. #line 15503 "./typica.w"
  3229. void addScaleControlToLayout(QDomElement element,
  3230. QStack<QWidget*> *widgetStack,
  3231. QStack<QLayout*> *layoutStack);
  3232. void addIntensityControlToLayout(QDomElement element,
  3233. QStack<QWidget*> *widgetStack,
  3234. QStack<QLayout*> *layoutStack);
  3235. /*:750*//*776:*/
  3236. #line 16089 "./typica.w"
  3237. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  3238. QScriptEngine*engine);
  3239. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  3240. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  3241. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  3242. QScriptEngine*engine);
  3243. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  3244. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  3245. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  3246. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  3247. /*:776*//*782:*/
  3248. #line 16231 "./typica.w"
  3249. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  3250. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  3251. /*:782*//*798:*/
  3252. #line 16529 "./typica.w"
  3253. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  3254. QScriptEngine*engine);
  3255. /*:798*//*869:*/
  3256. #line 44 "./settings.w"
  3257. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  3258. /*:869*//*897:*/
  3259. #line 19167 "./typica.w"
  3260. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  3261. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  3262. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  3263. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  3264. /*:897*//*915:*/
  3265. #line 698 "./modbus.w"
  3266. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine);
  3267. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine);
  3268. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine);
  3269. /*:915*//*929:*/
  3270. #line 345 "./unsupportedserial.w"
  3271. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  3272. /*:929*//*935:*/
  3273. #line 425 "./unsupportedserial.w"
  3274. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  3275. /*:935*//*941:*/
  3276. #line 617 "./unsupportedserial.w"
  3277. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  3278. /*:941*//*945:*/
  3279. #line 651 "./unsupportedserial.w"
  3280. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  3281. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  3282. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  3283. /*:945*//*969:*/
  3284. #line 457 "./phidgets.w"
  3285. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  3286. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  3287. /*:969*//*1001:*/
  3288. #line 805 "./phidget22.w"
  3289. QScriptValue constructPhidget22(QScriptContext*context,QScriptEngine*engine);
  3290. QScriptValue Phidget22_getChannel(QScriptContext*context,QScriptEngine*engine);
  3291. /*:1001*//*1033:*/
  3292. #line 138 "./rate.w"
  3293. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  3294. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  3295. /*:1033*//*1047:*/
  3296. #line 129 "./mergeseries.w"
  3297. QScriptValue constructDifferenceSeries(QScriptContext*context,
  3298. QScriptEngine*engine);
  3299. QScriptValue constructMeanSeries(QScriptContext*context,
  3300. QScriptEngine*engine);
  3301. /*:1047*//*1072:*/
  3302. #line 597 "./dataqsdk.w"
  3303. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  3304. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  3305. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  3306. /*:1072*//*1099:*/
  3307. #line 67 "./scales.w"
  3308. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  3309. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  3310. /*:1099*//*1107:*/
  3311. #line 259 "./scales.w"
  3312. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  3313. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  3314. /*:1107*//*1110:*/
  3315. #line 284 "./scales.w"
  3316. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  3317. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  3318. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  3319. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  3320. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  3321. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  3322. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  3323. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  3324. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  3325. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  3326. /*:1110*//*1135:*/
  3327. #line 265 "./valueannotation.w"
  3328. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  3329. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  3330. /*:1135*//*1146:*/
  3331. #line 194 "./thresholdannotation.w"
  3332. QScriptValue constructAnnotator(QScriptContext*context,
  3333. QScriptEngine*engine);
  3334. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine);
  3335. /*:1146*//*1159:*/
  3336. #line 151 "./user.w"
  3337. QScriptValue constructLoginDialog(QScriptContext*context,QScriptEngine*engine);
  3338. /*:1159*//*1169:*/
  3339. #line 339 "./user.w"
  3340. QScriptValue constructNewTypicaUser(QScriptContext*context,QScriptEngine*engine);
  3341. /*:1169*/
  3342. #line 530 "./typica.w"
  3343. /*646:*/
  3344. #line 13829 "./typica.w"
  3345. void messageFileOutput(QtMsgType type,const char*msg);
  3346. /*:646*/
  3347. #line 531 "./typica.w"
  3348. /*4:*/
  3349. #line 540 "./typica.w"
  3350. /*790:*/
  3351. #line 16352 "./typica.w"
  3352. NodeInserter::NodeInserter(const QString&title,const QString&name,
  3353. const QString&driver,QObject*parent):
  3354. QAction(title,parent),defaultNodeName(name),driverString(driver)
  3355. {
  3356. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  3357. }
  3358. void NodeInserter::onTriggered()
  3359. {
  3360. emit triggered(defaultNodeName,driverString);
  3361. }
  3362. /*:790*/
  3363. #line 541 "./typica.w"
  3364. /*306:*/
  3365. #line 40 "./measurement.w"
  3366. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  3367. {
  3368. insert("measurement",temperature);
  3369. insert("time",time);
  3370. insert("unit",sc);
  3371. }
  3372. Measurement::Measurement(double temperature)
  3373. {
  3374. insert("measurement",temperature);
  3375. insert("time",QTime::currentTime());
  3376. insert("unit",Units::Fahrenheit);
  3377. }
  3378. void Measurement::setTemperature(double temperature)
  3379. {
  3380. insert("measurement",temperature);
  3381. }
  3382. void Measurement::setTime(QTime time)
  3383. {
  3384. insert("time",time);
  3385. }
  3386. void Measurement::setUnit(Units::Unit scale)
  3387. {
  3388. insert("unit",scale);
  3389. }
  3390. double Measurement::temperature()const
  3391. {
  3392. return value("measurement").toDouble();
  3393. }
  3394. QTime Measurement::time()const
  3395. {
  3396. return value("time").toTime();
  3397. }
  3398. Units::Unit Measurement::scale()const
  3399. {
  3400. return(Units::Unit)(value("unit").toInt());
  3401. }
  3402. /*:306*//*307:*/
  3403. #line 88 "./measurement.w"
  3404. Measurement Measurement::toFahrenheit()
  3405. {
  3406. return Measurement(Units::convertTemperature(this->temperature(),
  3407. this->scale(),Units::Fahrenheit),
  3408. this->time(),Units::Fahrenheit);
  3409. }
  3410. Measurement Measurement::toCelsius()
  3411. {
  3412. return Measurement(Units::convertTemperature(this->temperature(),
  3413. this->scale(),Units::Celsius),
  3414. this->time(),Units::Celsius);
  3415. }
  3416. Measurement Measurement::toKelvin()
  3417. {
  3418. return Measurement(Units::convertTemperature(this->temperature(),
  3419. this->scale(),Units::Kelvin),
  3420. this->time(),Units::Kelvin);
  3421. }
  3422. Measurement Measurement::toRankine()
  3423. {
  3424. return Measurement(Units::convertTemperature(this->temperature(),
  3425. this->scale(),Units::Rankine),
  3426. this->time(),Units::Rankine);
  3427. }
  3428. /*:307*/
  3429. #line 542 "./typica.w"
  3430. /*320:*/
  3431. #line 7050 "./typica.w"
  3432. void DAQImplementation::measure()
  3433. {
  3434. int samplesRead= 0;
  3435. double buffer[channels];
  3436. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  3437. (unsigned long)(0),buffer,(unsigned long)(channels),
  3438. &samplesRead,(signed long)(0));
  3439. if(error)
  3440. {
  3441. ready= false;
  3442. }
  3443. else
  3444. {
  3445. if(samplesRead)
  3446. {
  3447. QTime time= QTime::currentTime();
  3448. for(int i= 0;i<samplesRead;i++)
  3449. {
  3450. for(int j= 0;j<channels;j++)
  3451. {
  3452. double measuredValue= buffer[j+(i*channels)];
  3453. Measurement measure(measuredValue,time,
  3454. unitMap[j]);
  3455. channelMap[j]->input(measure);
  3456. }
  3457. }
  3458. }
  3459. }
  3460. }
  3461. /*:320*//*321:*/
  3462. #line 7093 "./typica.w"
  3463. void DAQImplementation::run()
  3464. {
  3465. setPriority(QThread::TimeCriticalPriority);
  3466. while(ready)
  3467. {
  3468. measure();
  3469. }
  3470. }
  3471. /*:321*//*322:*/
  3472. #line 7109 "./typica.w"
  3473. void DAQ::threadFinished()
  3474. {
  3475. if(imp->error)
  3476. {
  3477. /*323:*/
  3478. #line 7160 "./typica.w"
  3479. imp->ready= false;
  3480. QMessageBox warning;
  3481. warning.setStandardButtons(QMessageBox::Cancel);
  3482. warning.setIcon(QMessageBox::Warning);
  3483. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3484. unsigned long bytes= imp->errorInfo(NULL,0);
  3485. char string[bytes];
  3486. imp->errorInfo(string,bytes);
  3487. warning.setInformativeText(QString(string));
  3488. warning.setWindowTitle(QString(PROGRAM_NAME));
  3489. warning.exec();
  3490. /*:323*/
  3491. #line 7114 "./typica.w"
  3492. }
  3493. }
  3494. /*:322*//*324:*/
  3495. #line 7185 "./typica.w"
  3496. void DAQ::start()
  3497. {
  3498. if(imp->ready)
  3499. {
  3500. imp->error= imp->startTask(imp->handle);
  3501. if(imp->error)
  3502. {
  3503. /*323:*/
  3504. #line 7160 "./typica.w"
  3505. imp->ready= false;
  3506. QMessageBox warning;
  3507. warning.setStandardButtons(QMessageBox::Cancel);
  3508. warning.setIcon(QMessageBox::Warning);
  3509. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3510. unsigned long bytes= imp->errorInfo(NULL,0);
  3511. char string[bytes];
  3512. imp->errorInfo(string,bytes);
  3513. warning.setInformativeText(QString(string));
  3514. warning.setWindowTitle(QString(PROGRAM_NAME));
  3515. warning.exec();
  3516. /*:323*/
  3517. #line 7193 "./typica.w"
  3518. }
  3519. else
  3520. {
  3521. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3522. imp->start();
  3523. }
  3524. }
  3525. }
  3526. void DAQ::stop()
  3527. {
  3528. if(imp->useBase)
  3529. {
  3530. imp->ready= false;
  3531. imp->wait(ULONG_MAX);
  3532. imp->stopTask(imp->handle);
  3533. }
  3534. else
  3535. {
  3536. imp->ready= false;
  3537. imp->error= imp->stopTask(imp->handle);
  3538. if(imp->error)
  3539. {
  3540. /*323:*/
  3541. #line 7160 "./typica.w"
  3542. imp->ready= false;
  3543. QMessageBox warning;
  3544. warning.setStandardButtons(QMessageBox::Cancel);
  3545. warning.setIcon(QMessageBox::Warning);
  3546. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3547. unsigned long bytes= imp->errorInfo(NULL,0);
  3548. char string[bytes];
  3549. imp->errorInfo(string,bytes);
  3550. warning.setInformativeText(QString(string));
  3551. warning.setWindowTitle(QString(PROGRAM_NAME));
  3552. warning.exec();
  3553. /*:323*/
  3554. #line 7217 "./typica.w"
  3555. }
  3556. imp->error= imp->clearTask(imp->handle);
  3557. if(imp->error)
  3558. {
  3559. /*323:*/
  3560. #line 7160 "./typica.w"
  3561. imp->ready= false;
  3562. QMessageBox warning;
  3563. warning.setStandardButtons(QMessageBox::Cancel);
  3564. warning.setIcon(QMessageBox::Warning);
  3565. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3566. unsigned long bytes= imp->errorInfo(NULL,0);
  3567. char string[bytes];
  3568. imp->errorInfo(string,bytes);
  3569. warning.setInformativeText(QString(string));
  3570. warning.setWindowTitle(QString(PROGRAM_NAME));
  3571. warning.exec();
  3572. /*:323*/
  3573. #line 7222 "./typica.w"
  3574. }
  3575. }
  3576. }
  3577. /*:324*//*325:*/
  3578. #line 7232 "./typica.w"
  3579. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3580. {
  3581. imp->device= device;
  3582. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3583. if(imp->error)
  3584. {
  3585. /*323:*/
  3586. #line 7160 "./typica.w"
  3587. imp->ready= false;
  3588. QMessageBox warning;
  3589. warning.setStandardButtons(QMessageBox::Cancel);
  3590. warning.setIcon(QMessageBox::Warning);
  3591. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3592. unsigned long bytes= imp->errorInfo(NULL,0);
  3593. char string[bytes];
  3594. imp->errorInfo(string,bytes);
  3595. warning.setInformativeText(QString(string));
  3596. warning.setWindowTitle(QString(PROGRAM_NAME));
  3597. warning.exec();
  3598. /*:323*/
  3599. #line 7239 "./typica.w"
  3600. }
  3601. else
  3602. {
  3603. imp->ready= true;
  3604. }
  3605. }
  3606. /*:325*//*326:*/
  3607. #line 7253 "./typica.w"
  3608. Channel*DAQ::newChannel(int units,int thermocouple)
  3609. {
  3610. Channel*retval= new Channel();
  3611. imp->channelMap[imp->channels]= retval;
  3612. imp->unitMap[imp->channels]= (Units::Unit)units;
  3613. imp->channels++;
  3614. if(imp->ready)
  3615. {
  3616. if(imp->useBase)
  3617. {
  3618. imp->error= imp->createChannel(imp->handle,
  3619. QString("%1/ai%2").arg(imp->device).
  3620. arg(imp->channels-1).
  3621. toAscii().data(),
  3622. "",(double)(-1.0),(double)(100.0),
  3623. (signed long)(units),
  3624. (signed long)(thermocouple),
  3625. (signed long)(10200),(double)(0),
  3626. "");
  3627. }
  3628. else
  3629. {
  3630. imp->error= imp->createChannel(imp->handle,
  3631. QString("%1/ai%2").arg(imp->device).
  3632. arg(imp->channels-1).
  3633. toAscii().data(),
  3634. "",(double)(50.0),(double)(500.0),
  3635. (signed long)(units),
  3636. (signed long)(thermocouple),
  3637. (signed long)(10200),(double)(0),
  3638. "");
  3639. }
  3640. if(imp->error)
  3641. {
  3642. /*323:*/
  3643. #line 7160 "./typica.w"
  3644. imp->ready= false;
  3645. QMessageBox warning;
  3646. warning.setStandardButtons(QMessageBox::Cancel);
  3647. warning.setIcon(QMessageBox::Warning);
  3648. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3649. unsigned long bytes= imp->errorInfo(NULL,0);
  3650. char string[bytes];
  3651. imp->errorInfo(string,bytes);
  3652. warning.setInformativeText(QString(string));
  3653. warning.setWindowTitle(QString(PROGRAM_NAME));
  3654. warning.exec();
  3655. /*:323*/
  3656. #line 7288 "./typica.w"
  3657. }
  3658. }
  3659. return retval;
  3660. }
  3661. /*:326*//*327:*/
  3662. #line 7302 "./typica.w"
  3663. void DAQ::setClockRate(double Hz)
  3664. {
  3665. if(imp->ready)
  3666. {
  3667. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3668. (signed long)(10280),(signed long)(10123),
  3669. (unsigned long long)(1));
  3670. if(imp->error)
  3671. {
  3672. /*323:*/
  3673. #line 7160 "./typica.w"
  3674. imp->ready= false;
  3675. QMessageBox warning;
  3676. warning.setStandardButtons(QMessageBox::Cancel);
  3677. warning.setIcon(QMessageBox::Warning);
  3678. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3679. unsigned long bytes= imp->errorInfo(NULL,0);
  3680. char string[bytes];
  3681. imp->errorInfo(string,bytes);
  3682. warning.setInformativeText(QString(string));
  3683. warning.setWindowTitle(QString(PROGRAM_NAME));
  3684. warning.exec();
  3685. /*:323*/
  3686. #line 7312 "./typica.w"
  3687. }
  3688. }
  3689. }
  3690. /*:327*//*328:*/
  3691. #line 7322 "./typica.w"
  3692. DAQ::~DAQ()
  3693. {
  3694. if(imp->useBase)
  3695. {
  3696. imp->resetDevice(imp->device.toAscii().data());
  3697. imp->clearTask(imp->handle);
  3698. }
  3699. else
  3700. {
  3701. if(imp->ready)
  3702. {
  3703. imp->ready= false;
  3704. imp->wait(ULONG_MAX);
  3705. imp->stopTask(imp->handle);
  3706. imp->resetDevice(imp->device.toAscii().data());
  3707. imp->clearTask(imp->handle);
  3708. }
  3709. }
  3710. delete imp;
  3711. }
  3712. /*:328*//*329:*/
  3713. #line 7353 "./typica.w"
  3714. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3715. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3716. unitMap(4)
  3717. {
  3718. if(driverinfo=="nidaqmxbase")
  3719. {
  3720. useBase= true;
  3721. }
  3722. else
  3723. {
  3724. useBase= false;
  3725. }
  3726. if(useBase)
  3727. {
  3728. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3729. if(!driver.load())
  3730. {
  3731. driver.setFileName("nidaqmxbase");
  3732. if(!driver.load())
  3733. {
  3734. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3735. tr("Failed to find nidaqmxbase. Please install it."));
  3736. QApplication::quit();
  3737. }
  3738. }
  3739. }
  3740. else
  3741. {
  3742. driver.setFileName("nicaiu");
  3743. if(!driver.load())
  3744. {
  3745. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3746. tr("Failed to find nidaqmx. Please install it."));
  3747. QApplication::quit();
  3748. }
  3749. }
  3750. if(useBase)
  3751. {
  3752. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3753. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3754. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3755. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3756. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3757. ==0||
  3758. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3759. 0||
  3760. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3761. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3762. 0||
  3763. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3764. {
  3765. waitForMeasurement= NULL;
  3766. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3767. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3768. QApplication::quit();
  3769. }
  3770. }
  3771. else
  3772. {
  3773. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3774. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3775. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3776. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3777. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3778. ==0||
  3779. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3780. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3781. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3782. 0||
  3783. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3784. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3785. {
  3786. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3787. tr("Failed to link a required symbol in NI-DAQmx."));
  3788. QApplication::quit();
  3789. }
  3790. }
  3791. }
  3792. DAQImplementation::~DAQImplementation()
  3793. {
  3794. driver.unload();
  3795. }
  3796. /*:329*/
  3797. #line 543 "./typica.w"
  3798. /*1061:*/
  3799. #line 197 "./dataqsdk.w"
  3800. void DataqSdkDeviceImplementation::measure()
  3801. {
  3802. unsigned count= channels*40;
  3803. di_status_read(buffer,count);
  3804. QTime time= QTime::currentTime();
  3805. for(unsigned int i= 0;i<count;i++)
  3806. {
  3807. buffer[i]= buffer[i]&0xFFFC;
  3808. }
  3809. QList<int> countList;
  3810. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3811. {
  3812. QList<double> channelBuffer;
  3813. for(unsigned int j= 0;j<40;j++)
  3814. {
  3815. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3816. if(i==0)
  3817. {
  3818. countList<<buffer[i+(channels*j)];
  3819. }
  3820. }
  3821. double value= 0.0;
  3822. for(unsigned int j= 0;j<40;j++)
  3823. {
  3824. value+= channelBuffer[j];
  3825. }
  3826. value/= 40.0;
  3827. if(i==0)
  3828. {
  3829. QList<double> smoothingList;
  3830. smoothingList<<value;
  3831. QList<int> smoothingKeys= smoother.uniqueKeys();
  3832. for(int j= 0;j<smoothingKeys.size();j++)
  3833. {
  3834. if(countList.contains(smoothingKeys[j]))
  3835. {
  3836. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3837. for(int k= 0;k<keyValues.size();k++)
  3838. {
  3839. smoothingList<<keyValues[k];
  3840. }
  3841. }
  3842. else
  3843. {
  3844. smoother.remove(smoothingKeys[j]);
  3845. }
  3846. }
  3847. qSort(countList);
  3848. int lastCount= 0;
  3849. for(int j= 0;j<countList.size();j++)
  3850. {
  3851. if(j==0||countList[j]!=lastCount)
  3852. {
  3853. smoother.insert(countList[j],value);
  3854. lastCount= countList[j];
  3855. }
  3856. }
  3857. value= 0.0;
  3858. for(int j= 0;j<smoothingList.size();j++)
  3859. {
  3860. value+= smoothingList[j];
  3861. }
  3862. value/= smoothingList.size();
  3863. }
  3864. Measurement measure(value,time,unitMap[i]);
  3865. channelMap[i]->input(measure);
  3866. }
  3867. }
  3868. /*:1061*//*1062:*/
  3869. #line 290 "./dataqsdk.w"
  3870. void DataqSdkDeviceImplementation::run()
  3871. {
  3872. if(!ready)
  3873. {
  3874. error= 9;
  3875. return;
  3876. }
  3877. driver= new QLibrary(device);
  3878. if(!driver->load())
  3879. {
  3880. error= 1;
  3881. qDebug()<<"Failed to load driver: "<<device;
  3882. return;
  3883. }
  3884. di_open= (FPDIOPEN)driver->resolve("di_open");
  3885. di_close= (FPDICLOSE)driver->resolve("di_close");
  3886. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3887. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3888. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3889. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3890. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3891. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3892. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3893. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3894. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3895. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3896. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3897. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3898. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3899. (!di_burst_rate)||(!di_stop_scan))
  3900. {
  3901. error= 2;
  3902. return;
  3903. }
  3904. error= di_open(deviceNumber);
  3905. if(error)
  3906. {
  3907. di_close();
  3908. error= di_open(deviceNumber);
  3909. if(error)
  3910. {
  3911. error= 3;
  3912. di_close();
  3913. return;
  3914. }
  3915. }
  3916. isOpen= true;
  3917. di_maximum_rate(240.0);
  3918. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3919. &burstDivisor);
  3920. buffer= new qint16[(int)sampleRate];
  3921. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3922. for(unsigned short i= 0;i<channels;i++)
  3923. {
  3924. inlist[i].chan= i;
  3925. inlist[i].gain= 0;
  3926. inlist[i].ave= 1;
  3927. inlist[i].counter= (oversample-1);
  3928. }
  3929. error= di_list_length(channels,0);
  3930. if(error)
  3931. {
  3932. error= 4;
  3933. return;
  3934. }
  3935. error= di_inlist(inlist);
  3936. if(error)
  3937. {
  3938. error= 5;
  3939. return;
  3940. }
  3941. input_buffer= di_buffer_alloc(0,4096);
  3942. if(input_buffer==NULL)
  3943. {
  3944. error= 6;
  3945. return;
  3946. }
  3947. error= di_start_scan();
  3948. if(error)
  3949. {
  3950. error= 7;
  3951. return;
  3952. }
  3953. while(ready)
  3954. {
  3955. measure();
  3956. }
  3957. }
  3958. /*:1062*//*1063:*/
  3959. #line 386 "./dataqsdk.w"
  3960. void DataqSdkDevice::threadFinished()
  3961. {
  3962. if(imp->error)
  3963. {
  3964. /*1064:*/
  3965. #line 400 "./dataqsdk.w"
  3966. imp->ready= false;
  3967. QMessageBox warning;
  3968. warning.setStandardButtons(QMessageBox::Cancel);
  3969. warning.setIcon(QMessageBox::Warning);
  3970. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3971. warning.setInformativeText(tr("An error occurred"));
  3972. warning.setWindowTitle(QString(PROGRAM_NAME));
  3973. warning.exec();
  3974. /*:1064*/
  3975. #line 391 "./dataqsdk.w"
  3976. }
  3977. }
  3978. /*:1063*//*1065:*/
  3979. #line 417 "./dataqsdk.w"
  3980. void DataqSdkDevice::start()
  3981. {
  3982. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3983. imp->start();
  3984. }
  3985. /*:1065*//*1066:*/
  3986. #line 428 "./dataqsdk.w"
  3987. QStringList DataqSdkDevice::detectHardware()
  3988. {
  3989. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3990. QSettings::NativeFormat);
  3991. QStringList keys= deviceLookup.childKeys();
  3992. QStringList devices;
  3993. for(int i= 0;i<keys.size();i++)
  3994. {
  3995. QString value= deviceLookup.value(keys.at(i)).toString();
  3996. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3997. {
  3998. devices.append(value.split("\\").at(2));
  3999. }
  4000. }
  4001. QStringList portList;
  4002. foreach(QString device,devices)
  4003. {
  4004. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  4005. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  4006. portList.append(deviceEntry.value("FriendlyName").toString());
  4007. }
  4008. return portList;
  4009. }
  4010. QStringList DataqSdkDevice::detectPorts()
  4011. {
  4012. QStringList friendlyNames= detectHardware();
  4013. QStringList portList;
  4014. foreach(QString name,friendlyNames)
  4015. {
  4016. name.remove(0,name.indexOf("COM"));
  4017. name.chop(1);
  4018. portList.append(name);
  4019. }
  4020. return portList;
  4021. }
  4022. /*:1066*//*1067:*/
  4023. #line 473 "./dataqsdk.w"
  4024. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  4025. {
  4026. bool usesAuto= false;
  4027. int autoIndex= device.toInt(&usesAuto);
  4028. QString finalizedPort;
  4029. if(usesAuto)
  4030. {
  4031. QStringList portList= detectPorts();
  4032. if(autoIndex> 0&&autoIndex<=portList.size())
  4033. {
  4034. finalizedPort= portList.at(autoIndex-1);
  4035. }
  4036. else
  4037. {
  4038. imp->error= 8;
  4039. qDebug()<<"Failed to detect port.";
  4040. }
  4041. }
  4042. else
  4043. {
  4044. finalizedPort= device;
  4045. }
  4046. int rstart= finalizedPort.indexOf("COM");
  4047. finalizedPort.remove(0,rstart+3);
  4048. bool chopFinished= false;
  4049. int finalizedPortNumber= 0;
  4050. while(finalizedPort.size()> 0&&!chopFinished)
  4051. {
  4052. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  4053. if(!chopFinished)
  4054. {
  4055. finalizedPort.chop(1);
  4056. }
  4057. }
  4058. if(finalizedPortNumber<10)
  4059. {
  4060. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  4061. }
  4062. else
  4063. {
  4064. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  4065. }
  4066. imp->deviceNumber= 0x12C02D00;
  4067. imp->deviceNumber+= finalizedPortNumber;
  4068. imp->ready= true;
  4069. }
  4070. /*:1067*//*1068:*/
  4071. #line 523 "./dataqsdk.w"
  4072. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  4073. {
  4074. Channel*retval= NULL;
  4075. if(imp->ready)
  4076. {
  4077. retval= new Channel();
  4078. imp->channelMap[imp->channels]= retval;
  4079. imp->unitMap[imp->channels]= scale;
  4080. imp->channels++;
  4081. }
  4082. return retval;
  4083. }
  4084. /*:1068*//*1069:*/
  4085. #line 547 "./dataqsdk.w"
  4086. void DataqSdkDevice::setClockRate(double Hz)
  4087. {
  4088. imp->sampleRate= Hz;
  4089. }
  4090. /*:1069*//*1070:*/
  4091. #line 557 "./dataqsdk.w"
  4092. DataqSdkDevice::~DataqSdkDevice()
  4093. {
  4094. if(imp->ready)
  4095. {
  4096. imp->ready= false;
  4097. }
  4098. imp->wait(ULONG_MAX);
  4099. delete imp;
  4100. }
  4101. /*:1070*//*1071:*/
  4102. #line 575 "./dataqsdk.w"
  4103. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  4104. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  4105. {
  4106. }
  4107. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  4108. {
  4109. if(isOpen)
  4110. {
  4111. di_stop_scan();
  4112. di_close();
  4113. }
  4114. if(driver->isLoaded())
  4115. {
  4116. driver->unload();
  4117. }
  4118. }
  4119. /*:1071*/
  4120. #line 544 "./typica.w"
  4121. /*336:*/
  4122. #line 7562 "./typica.w"
  4123. void FakeDAQImplementation::measure()
  4124. {
  4125. msleep((int)(1000/clockRate));
  4126. QTime time= QTime::currentTime();
  4127. for(int i= 0;i<channels;i++)
  4128. {
  4129. Measurement measure(qrand()%500,time);
  4130. channelMap[i]->input(measure);
  4131. }
  4132. }
  4133. /*:336*//*337:*/
  4134. #line 7576 "./typica.w"
  4135. void FakeDAQImplementation::run()
  4136. {
  4137. setPriority(QThread::TimeCriticalPriority);
  4138. while(ready)
  4139. {
  4140. measure();
  4141. }
  4142. }
  4143. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  4144. channels(0),ready(false),clockRate(1)
  4145. {
  4146. }
  4147. FakeDAQImplementation::~FakeDAQImplementation()
  4148. {
  4149. }
  4150. /*:337*//*338:*/
  4151. #line 7601 "./typica.w"
  4152. void FakeDAQ::start()
  4153. {
  4154. if(imp->ready)
  4155. {
  4156. imp->start();
  4157. }
  4158. }
  4159. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  4160. {
  4161. imp->ready= true;
  4162. }
  4163. Channel*FakeDAQ::newChannel(int,int)
  4164. {
  4165. Channel*retval;
  4166. if(imp->ready)
  4167. {
  4168. retval= new Channel();
  4169. imp->channelMap[imp->channels]= retval;
  4170. imp->channels++;
  4171. }
  4172. else
  4173. {
  4174. return NULL;
  4175. }
  4176. return retval;
  4177. }
  4178. void FakeDAQ::setClockRate(double Hz)
  4179. {
  4180. if(imp->ready)
  4181. {
  4182. imp->clockRate= Hz;
  4183. }
  4184. }
  4185. FakeDAQ::~FakeDAQ()
  4186. {
  4187. imp->ready= false;
  4188. imp->wait(ULONG_MAX);
  4189. delete imp;
  4190. }
  4191. /*:338*/
  4192. #line 545 "./typica.w"
  4193. /*343:*/
  4194. #line 7732 "./typica.w"
  4195. Channel::Channel():QObject(NULL)
  4196. {
  4197. }
  4198. Channel::~Channel()
  4199. {
  4200. }
  4201. void Channel::input(Measurement measurement)
  4202. {
  4203. emit newData(measurement);
  4204. }
  4205. /*:343*/
  4206. #line 546 "./typica.w"
  4207. /*359:*/
  4208. #line 8137 "./typica.w"
  4209. void TemperatureDisplay::setRelativeMode(bool relative)
  4210. {
  4211. r= relative;
  4212. }
  4213. /*:359*//*360:*/
  4214. #line 8154 "./typica.w"
  4215. void TemperatureDisplay::setValue(Measurement temperature)
  4216. {
  4217. QString number;
  4218. switch(unit)
  4219. {
  4220. case Units::Fahrenheit:
  4221. display(QString("%1'F").
  4222. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  4223. 2)));
  4224. break;
  4225. case Units::Celsius:
  4226. if(!r){
  4227. display(QString("%1'C").
  4228. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  4229. 2)));
  4230. }else{
  4231. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  4232. display(QString("%1'C").arg(number));
  4233. }
  4234. break;
  4235. case Units::Kelvin:
  4236. if(!r){
  4237. display(QString("%1").
  4238. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  4239. 2)));
  4240. }else{
  4241. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  4242. display(QString("%1").arg(number));
  4243. }
  4244. break;
  4245. case Units::Rankine:
  4246. display(QString("%1'r").
  4247. arg(number.setNum(temperature.toRankine().temperature(),'f',
  4248. 2)));
  4249. break;
  4250. case Units::Unitless:
  4251. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  4252. break;
  4253. default:
  4254. switch(temperature.scale())
  4255. {
  4256. case Units::Fahrenheit:
  4257. display(QString("%1'F").
  4258. arg(number.setNum(temperature.temperature(),'f',2)));
  4259. break;
  4260. case Units::Celsius:
  4261. display(QString("%1'C").
  4262. arg(number.setNum(temperature.temperature(),'f',2)));
  4263. break;
  4264. case Units::Kelvin:
  4265. display(QString("%1").
  4266. arg(number.setNum(temperature.temperature(),'f',2)));
  4267. break;
  4268. case Units::Rankine:
  4269. display(QString("%1'r").
  4270. arg(number.setNum(temperature.temperature(),'f',2)));
  4271. break;
  4272. case Units::Unitless:
  4273. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  4274. break;
  4275. default:
  4276. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  4277. break;
  4278. }
  4279. break;
  4280. }
  4281. }
  4282. /*:360*//*361:*/
  4283. #line 8233 "./typica.w"
  4284. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  4285. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  4286. {
  4287. setSegmentStyle(Filled);
  4288. display("---.--'F");
  4289. }
  4290. /*:361*//*362:*/
  4291. #line 8249 "./typica.w"
  4292. void TemperatureDisplay::invalidate()
  4293. {
  4294. display("---.--'F");
  4295. }
  4296. /*:362*//*363:*/
  4297. #line 8261 "./typica.w"
  4298. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  4299. {
  4300. unit= scale;
  4301. }
  4302. /*:363*//*364:*/
  4303. #line 8269 "./typica.w"
  4304. TemperatureDisplay::~TemperatureDisplay()
  4305. {
  4306. }
  4307. /*:364*/
  4308. #line 547 "./typica.w"
  4309. /*370:*/
  4310. #line 8369 "./typica.w"
  4311. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  4312. {
  4313. if(measure.time()<epoch)
  4314. {
  4315. if(hasPrevious)
  4316. {
  4317. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  4318. epoch.msec());
  4319. QTime jitComp(epoch.hour(),measure.time().minute(),
  4320. measure.time().second(),measure.time().msec());
  4321. int relTime= jitBase.msecsTo(jitComp);
  4322. /*371:*/
  4323. #line 8403 "./typica.w"
  4324. QTime newTime(0,0,0,0);
  4325. newTime= newTime.addMSecs(relTime);
  4326. if(newTime.hour()> 0)
  4327. {
  4328. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  4329. }
  4330. Measurement rel= measure;
  4331. rel.setTime(newTime);
  4332. emit measurement(rel);
  4333. /*:371*/
  4334. #line 8381 "./typica.w"
  4335. }
  4336. else
  4337. {
  4338. Measurement rel= measure;
  4339. rel.setTime(QTime(0,0,0,0));
  4340. emit measurement(rel);
  4341. }
  4342. }
  4343. else
  4344. {
  4345. int relTime= epoch.msecsTo(measure.time());
  4346. /*371:*/
  4347. #line 8403 "./typica.w"
  4348. QTime newTime(0,0,0,0);
  4349. newTime= newTime.addMSecs(relTime);
  4350. if(newTime.hour()> 0)
  4351. {
  4352. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  4353. }
  4354. Measurement rel= measure;
  4355. rel.setTime(newTime);
  4356. emit measurement(rel);
  4357. /*:371*/
  4358. #line 8393 "./typica.w"
  4359. }
  4360. hasPrevious= true;
  4361. previous= measure.time();
  4362. }
  4363. /*:370*//*372:*/
  4364. #line 8416 "./typica.w"
  4365. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  4366. previous(0,0,0,0),hasPrevious(false)
  4367. {
  4368. }
  4369. QTime MeasurementTimeOffset::zeroTime()
  4370. {
  4371. return epoch;
  4372. }
  4373. void MeasurementTimeOffset::setZeroTime(QTime zero)
  4374. {
  4375. epoch= zero;
  4376. hasPrevious= false;
  4377. }
  4378. /*:372*/
  4379. #line 548 "./typica.w"
  4380. /*382:*/
  4381. #line 8624 "./typica.w"
  4382. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  4383. {
  4384. }
  4385. int ZeroEmitter::column()
  4386. {
  4387. return col;
  4388. }
  4389. double ZeroEmitter::lastTemperature()
  4390. {
  4391. return cache.temperature();
  4392. }
  4393. void ZeroEmitter::newMeasurement(Measurement measure)
  4394. {
  4395. cache= measure;
  4396. }
  4397. void ZeroEmitter::setColumn(int column)
  4398. {
  4399. col= column;
  4400. }
  4401. void ZeroEmitter::emitZero()
  4402. {
  4403. cache.setTime(QTime(0,0,0,0));
  4404. emit measurement(cache,col);
  4405. }
  4406. /*:382*/
  4407. #line 549 "./typica.w"
  4408. /*387:*/
  4409. #line 8714 "./typica.w"
  4410. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  4411. {
  4412. }
  4413. int MeasurementAdapter::column()
  4414. {
  4415. return col;
  4416. }
  4417. void MeasurementAdapter::newMeasurement(Measurement measure)
  4418. {
  4419. emit measurement(measure,col);
  4420. }
  4421. void MeasurementAdapter::setColumn(int column)
  4422. {
  4423. col= column;
  4424. }
  4425. /*:387*/
  4426. #line 550 "./typica.w"
  4427. /*392:*/
  4428. #line 8836 "./typica.w"
  4429. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  4430. theScene(new QGraphicsScene),
  4431. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  4432. prevPoints(new QMap<int,QPointF> ),
  4433. translations(new QMap<int,double> ),
  4434. gridLinesF(new QList<QGraphicsItem*> ),
  4435. gridLinesC(new QList<QGraphicsItem*> ),
  4436. relativeGridLines(new QList<QGraphicsItem*> ),
  4437. relativeEnabled(false),
  4438. timeIndicatorEnabled(false),
  4439. timeLine(new QGraphicsLineItem),
  4440. relativeAdjuster(new LinearSplineInterpolator)
  4441. {
  4442. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4443. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4444. setScene(theScene);
  4445. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  4446. QPen timePen;
  4447. timePen.setColor(QColor(160,160,164,127));
  4448. timeLine->setPen(timePen);
  4449. timeLine->setLine(0,0,0,-500);
  4450. timeLine->hide();
  4451. theScene->addItem(timeLine);
  4452. /*393:*/
  4453. #line 8876 "./typica.w"
  4454. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  4455. tempaxis->setLine(-10,-500,-10,0);
  4456. theScene->addItem(tempaxis);
  4457. QGraphicsLineItem*gridLine;
  4458. QGraphicsTextItem*label;
  4459. for(int y= -100;y> -600;y-= 100)
  4460. {
  4461. gridLine= new QGraphicsLineItem;
  4462. gridLine->setLine(0,y,1200,y);
  4463. theScene->addItem(gridLine);
  4464. label= new QGraphicsTextItem;
  4465. label->setHtml(QString("%1&deg;F").arg(-y));
  4466. label->setPos(-55,y-(label->boundingRect().height()/2));
  4467. theScene->addItem(label);
  4468. gridLinesF->append(gridLine);
  4469. gridLinesF->append(label);
  4470. }
  4471. for(int degC= 50;degC<=250;degC+= 50)
  4472. {
  4473. gridLine= new QGraphicsLineItem;
  4474. int y= -(degC*(9.0/5.0)+32);
  4475. gridLine->setLine(0,y,1200,y);
  4476. gridLine->hide();
  4477. theScene->addItem(gridLine);
  4478. gridLinesC->append(gridLine);
  4479. label= new QGraphicsTextItem;
  4480. label->setHtml(QString("%1&deg;C").arg(degC));
  4481. label->setPos(-55,y-(label->boundingRect().height()/2));
  4482. label->hide();
  4483. theScene->addItem(label);
  4484. gridLinesC->append(label);
  4485. }
  4486. /*:393*/
  4487. #line 8860 "./typica.w"
  4488. ;
  4489. /*394:*/
  4490. #line 8917 "./typica.w"
  4491. QSettings settings;
  4492. if(settings.contains("settings/graph/relative/enable"))
  4493. {
  4494. if(settings.value("settings/graph/relative/enable").toBool())
  4495. {
  4496. relativeEnabled= true;
  4497. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  4498. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  4499. QMap<double,QString> relativeAxisPairs;
  4500. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  4501. foreach(QString item,relativeAxisLabels)
  4502. {
  4503. relativeAxisPairs.insert(item.toDouble(),item);
  4504. }
  4505. if(relativeAxisPairs.size()> 1)
  4506. {
  4507. double skip= 500.0/(relativeAxisPairs.size()-1);
  4508. double y= 0;
  4509. foreach(double key,relativeAxisPairs.keys())
  4510. {
  4511. gridLine= new QGraphicsLineItem;
  4512. gridLine->setLine(0,y,1205,y);
  4513. gridLine->setPen(QPen(relativeColor));
  4514. theScene->addItem(gridLine);
  4515. relativeGridLines->append(gridLine);
  4516. label= new QGraphicsTextItem;
  4517. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  4518. label->setPos(1210,y-(label->boundingRect().height()/2));
  4519. theScene->addItem(label);
  4520. relativeGridLines->append(label);
  4521. if(unit=="F")
  4522. {
  4523. relativeAdjuster->add_pair(key,-y);
  4524. }
  4525. else
  4526. {
  4527. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  4528. }
  4529. y-= skip;
  4530. }
  4531. }
  4532. }
  4533. }
  4534. /*:394*/
  4535. #line 8861 "./typica.w"
  4536. /*396:*/
  4537. #line 8994 "./typica.w"
  4538. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  4539. timeaxis->setLine(0,10,1200,10);
  4540. theScene->addItem(timeaxis);
  4541. for(int x= 0;x<1201;x+= 120)
  4542. {
  4543. QGraphicsLineItem*tick= new QGraphicsLineItem;
  4544. tick->setLine(x,0,x,20);
  4545. theScene->addItem(tick);
  4546. QGraphicsTextItem*label= new QGraphicsTextItem;
  4547. label->setPlainText(QString("%1").arg(x/60));
  4548. label->setPos(x-(label->boundingRect().width()/2),20);
  4549. theScene->addItem(label);
  4550. }
  4551. /*:396*/
  4552. #line 8862 "./typica.w"
  4553. ;
  4554. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4555. }
  4556. /*:392*//*395:*/
  4557. #line 8964 "./typica.w"
  4558. void GraphView::showF()
  4559. {
  4560. for(int i= 0;i<gridLinesF->size();i++)
  4561. {
  4562. gridLinesF->at(i)->show();
  4563. }
  4564. for(int i= 0;i<gridLinesC->size();i++)
  4565. {
  4566. gridLinesC->at(i)->hide();
  4567. }
  4568. }
  4569. void GraphView::showC()
  4570. {
  4571. for(int i= 0;i<gridLinesF->size();i++)
  4572. {
  4573. gridLinesF->at(i)->hide();
  4574. }
  4575. for(int i= 0;i<gridLinesC->size();i++)
  4576. {
  4577. gridLinesC->at(i)->show();
  4578. }
  4579. }
  4580. /*:395*//*397:*/
  4581. #line 9013 "./typica.w"
  4582. void GraphView::resizeEvent(QResizeEvent*)
  4583. {
  4584. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4585. }
  4586. /*:397*//*398:*/
  4587. #line 9027 "./typica.w"
  4588. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4589. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4590. {
  4591. double offset= 0;
  4592. if(measure.contains("relative"))
  4593. {
  4594. if(measure.value("relative").toBool())
  4595. {
  4596. if(relativeEnabled)
  4597. {
  4598. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4599. }
  4600. else
  4601. {
  4602. return;
  4603. }
  4604. }
  4605. }
  4606. if(translations->contains(tempcolumn))
  4607. {
  4608. offset= translations->value(tempcolumn);
  4609. }
  4610. if(prevPoints->contains(tempcolumn))
  4611. {
  4612. /*400:*/
  4613. #line 9104 "./typica.w"
  4614. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4615. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4616. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4617. -(prevPoints->value(tempcolumn).y()),
  4618. nextPoint.x()+offset,-(nextPoint.y()));
  4619. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4620. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4621. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4622. Qt::darkYellow};
  4623. segment->setPen(p[tempcolumn%12]);
  4624. theScene->addItem(segment);
  4625. prevPoints->insert(tempcolumn,nextPoint);
  4626. if(timeIndicatorEnabled)
  4627. {
  4628. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4629. }
  4630. /*:400*/
  4631. #line 9053 "./typica.w"
  4632. if(graphLines->contains(tempcolumn))
  4633. {
  4634. graphLines->value(tempcolumn)->append(segment);
  4635. }
  4636. else
  4637. {
  4638. QList<QGraphicsLineItem*> *newLine=
  4639. new QList<QGraphicsLineItem*> ;
  4640. newLine->append(segment);
  4641. graphLines->insert(tempcolumn,newLine);
  4642. }
  4643. }
  4644. else
  4645. {
  4646. /*399:*/
  4647. #line 9089 "./typica.w"
  4648. int x= FULLTIMETOINT(measure.time())/1000;
  4649. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4650. if(timeIndicatorEnabled)
  4651. {
  4652. timeLine->setLine(x,0,x,-500);
  4653. }
  4654. /*:399*/
  4655. #line 9070 "./typica.w"
  4656. }
  4657. }
  4658. /*:398*//*401:*/
  4659. #line 9125 "./typica.w"
  4660. void GraphView::clear()
  4661. {
  4662. int i;
  4663. foreach(i,prevPoints->keys())
  4664. {
  4665. removeSeries(i);
  4666. }
  4667. translations->clear();
  4668. }
  4669. /*:401*//*402:*/
  4670. #line 9139 "./typica.w"
  4671. void GraphView::removeSeries(int column)
  4672. {
  4673. if(graphLines->contains(column))
  4674. {
  4675. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4676. QGraphicsLineItem*segment;
  4677. foreach(segment,*series)
  4678. {
  4679. theScene->removeItem(segment);
  4680. }
  4681. qDeleteAll(*series);
  4682. }
  4683. graphLines->remove(column);
  4684. prevPoints->remove(column);
  4685. }
  4686. /*:402*//*403:*/
  4687. #line 9158 "./typica.w"
  4688. void GraphView::setSeriesTranslation(int column,double offset)
  4689. {
  4690. if(graphLines->contains(column))
  4691. {
  4692. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4693. QGraphicsLineItem*segment;
  4694. foreach(segment,*series)
  4695. {
  4696. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4697. }
  4698. }
  4699. if(translations->contains(column))
  4700. {
  4701. translations->insert(column,offset+translations->value(column));
  4702. }
  4703. else
  4704. {
  4705. translations->insert(column,offset);
  4706. }
  4707. }
  4708. /*:403*//*404:*/
  4709. #line 9185 "./typica.w"
  4710. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4711. {
  4712. timeIndicatorEnabled= enabled;
  4713. if(enabled)
  4714. {
  4715. timeLine->show();
  4716. }
  4717. else
  4718. {
  4719. timeLine->hide();
  4720. }
  4721. }
  4722. /*:404*/
  4723. #line 551 "./typica.w"
  4724. /*410:*/
  4725. #line 9332 "./typica.w"
  4726. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4727. {
  4728. if(measure.time()!=QTime(0,0,0,0))
  4729. {
  4730. /*412:*/
  4731. #line 9406 "./typica.w"
  4732. if(lastMeasurement.contains(tempcolumn))
  4733. {
  4734. if(lastMeasurement[tempcolumn].time()<measure.time())
  4735. {
  4736. QList<QTime> timelist;
  4737. QList<double> templist;
  4738. QTime z= QTime(0,0,0,0);
  4739. double ptime= (double)(z.secsTo(lastMeasurement[tempcolumn].time()));
  4740. double ptemp= lastMeasurement[tempcolumn].temperature();
  4741. double ctime= (double)(z.secsTo(measure.time()));
  4742. double ctemp= measure.temperature();
  4743. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4744. {
  4745. timelist.append(i);
  4746. double v= ((ptemp*(ctime-z.secsTo(i)))+(ctemp*(z.secsTo(i)-ptime)))/(ctime-ptime);
  4747. templist.append(v);
  4748. }
  4749. for(int i= 0;i<timelist.size();i++)
  4750. {
  4751. Measurement synthesized= measure;
  4752. synthesized.setTime(timelist[i]);
  4753. synthesized.setTemperature(templist[i]);
  4754. newMeasurement(synthesized,tempcolumn);
  4755. }
  4756. }
  4757. }
  4758. /*:412*/
  4759. #line 9337 "./typica.w"
  4760. }
  4761. model_ms->newMeasurement(measure,tempcolumn);
  4762. if(lastMeasurement.contains(tempcolumn))
  4763. {
  4764. if(measure.time().second()!=
  4765. lastMeasurement.value(tempcolumn).time().second())
  4766. {
  4767. Measurement adjusted= measure;
  4768. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4769. adjusted.setTime(adjtime);
  4770. model_1s->newMeasurement(adjusted,tempcolumn);
  4771. if(adjusted.time().second()%5==0)
  4772. {
  4773. model_5s->newMeasurement(adjusted,tempcolumn);
  4774. if(adjusted.time().second()%10==0)
  4775. {
  4776. model_10s->newMeasurement(adjusted,tempcolumn);
  4777. }
  4778. if(adjusted.time().second()%15==0)
  4779. {
  4780. model_15s->newMeasurement(adjusted,tempcolumn);
  4781. if(adjusted.time().second()%30==0)
  4782. {
  4783. model_30s->newMeasurement(adjusted,tempcolumn);
  4784. if(adjusted.time().second()==0)
  4785. {
  4786. model_1m->newMeasurement(adjusted,tempcolumn);
  4787. }
  4788. }
  4789. }
  4790. }
  4791. }
  4792. /*414:*/
  4793. #line 9459 "./typica.w"
  4794. if(currentColumnSet.contains(tempcolumn))
  4795. {
  4796. int replicationcolumn;
  4797. foreach(replicationcolumn,currentColumnSet)
  4798. {
  4799. if(replicationcolumn!=tempcolumn)
  4800. {
  4801. if(lastMeasurement.contains(replicationcolumn))
  4802. {
  4803. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4804. {
  4805. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4806. synthetic.setTime(measure.time());
  4807. model_ms->newMeasurement(synthetic,replicationcolumn);
  4808. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4809. {
  4810. Measurement adjusted= synthetic;
  4811. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4812. model_1s->newMeasurement(adjusted,replicationcolumn);
  4813. if(adjusted.time().second()%5==0)
  4814. {
  4815. model_5s->newMeasurement(adjusted,replicationcolumn);
  4816. if(adjusted.time().second()%10==0)
  4817. {
  4818. model_10s->newMeasurement(adjusted,replicationcolumn);
  4819. }
  4820. if(adjusted.time().second()%15==0)
  4821. {
  4822. model_15s->newMeasurement(adjusted,replicationcolumn);
  4823. if(adjusted.time().second()%30==0)
  4824. {
  4825. model_30s->newMeasurement(adjusted,replicationcolumn);
  4826. if(adjusted.time().second()==0)
  4827. {
  4828. model_1m->newMeasurement(adjusted,replicationcolumn);
  4829. }
  4830. }
  4831. }
  4832. }
  4833. }
  4834. lastMeasurement[replicationcolumn]= synthetic;
  4835. }
  4836. }
  4837. }
  4838. }
  4839. }
  4840. /*:414*/
  4841. #line 9370 "./typica.w"
  4842. }
  4843. else
  4844. {
  4845. /*411:*/
  4846. #line 9382 "./typica.w"
  4847. MeasurementModel*m;
  4848. foreach(m,modelSet)
  4849. {
  4850. m->newMeasurement(measure,tempcolumn);
  4851. }
  4852. /*:411*/
  4853. #line 9374 "./typica.w"
  4854. }
  4855. lastMeasurement.insert(tempcolumn,measure);
  4856. }
  4857. /*:410*//*413:*/
  4858. #line 9445 "./typica.w"
  4859. void ZoomLog::addToCurrentColumnSet(int column)
  4860. {
  4861. currentColumnSet.append(column);
  4862. }
  4863. void ZoomLog::clearCurrentColumnSet()
  4864. {
  4865. currentColumnSet.clear();
  4866. }
  4867. /*:413*//*415:*/
  4868. #line 9529 "./typica.w"
  4869. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4870. int annotationcolumn)
  4871. {
  4872. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4873. MeasurementModel*m;
  4874. if(lastMeasurement.contains(tempcolumn))
  4875. {
  4876. foreach(m,modelSet)
  4877. {
  4878. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4879. }
  4880. }
  4881. foreach(m,modelSet)
  4882. {
  4883. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4884. }
  4885. }
  4886. /*:415*//*416:*/
  4887. #line 9553 "./typica.w"
  4888. void ZoomLog::centerOn(int row)
  4889. {
  4890. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4891. }
  4892. /*:416*//*417:*/
  4893. #line 9563 "./typica.w"
  4894. void ZoomLog::clear()
  4895. {
  4896. MeasurementModel*m;
  4897. foreach(m,modelSet)
  4898. {
  4899. m->clear();
  4900. }
  4901. lastMeasurement.clear();
  4902. saveTempCols.clear();
  4903. saveControlCols.clear();
  4904. saveNoteCols.clear();
  4905. }
  4906. /*:417*//*418:*/
  4907. #line 9581 "./typica.w"
  4908. QVariant ZoomLog::data(int row,int column)const
  4909. {
  4910. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4911. Qt::DisplayRole);
  4912. }
  4913. int ZoomLog::rowCount()
  4914. {
  4915. return model_ms->rowCount();
  4916. }
  4917. /*:418*//*419:*/
  4918. #line 9604 "./typica.w"
  4919. bool ZoomLog::saveXML(QIODevice*device)
  4920. {
  4921. Units::Unit prevUnits= model_ms->displayUnits();
  4922. if(prevUnits!=Units::Fahrenheit)
  4923. {
  4924. model_ms->setDisplayUnits(Units::Fahrenheit);
  4925. }
  4926. XMLOutput writer(model_ms,device,0);
  4927. int c;
  4928. foreach(c,saveTempCols)
  4929. {
  4930. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4931. toString(),c);
  4932. }
  4933. foreach(c,saveControlCols)
  4934. {
  4935. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4936. toString(),c);
  4937. }
  4938. foreach(c,saveNoteCols)
  4939. {
  4940. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4941. toString(),c);
  4942. }
  4943. bool retval= writer.output();
  4944. if(prevUnits!=Units::Fahrenheit)
  4945. {
  4946. model_ms->setDisplayUnits(prevUnits);
  4947. }
  4948. return retval;
  4949. }
  4950. /*:419*//*420:*/
  4951. #line 9640 "./typica.w"
  4952. bool ZoomLog::saveCSV(QIODevice*device)
  4953. {
  4954. CSVOutput writer(currentModel,device,0);
  4955. int c;
  4956. foreach(c,saveTempCols)
  4957. {
  4958. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4959. toString(),c);
  4960. }
  4961. foreach(c,saveControlCols)
  4962. {
  4963. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4964. toString(),c);
  4965. }
  4966. foreach(c,saveNoteCols)
  4967. {
  4968. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4969. toString(),c);
  4970. }
  4971. return writer.output();
  4972. }
  4973. /*:420*//*421:*/
  4974. #line 9669 "./typica.w"
  4975. void ZoomLog::switchLOD(MeasurementModel*m)
  4976. {
  4977. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4978. setModel(m);
  4979. currentModel= m;
  4980. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4981. }
  4982. void ZoomLog::LOD_ms()
  4983. {
  4984. switchLOD(model_ms);
  4985. }
  4986. void ZoomLog::LOD_1s()
  4987. {
  4988. switchLOD(model_1s);
  4989. }
  4990. void ZoomLog::LOD_5s()
  4991. {
  4992. switchLOD(model_5s);
  4993. }
  4994. void ZoomLog::LOD_10s()
  4995. {
  4996. switchLOD(model_10s);
  4997. }
  4998. void ZoomLog::LOD_15s()
  4999. {
  5000. switchLOD(model_15s);
  5001. }
  5002. void ZoomLog::LOD_30s()
  5003. {
  5004. switchLOD(model_30s);
  5005. }
  5006. void ZoomLog::LOD_1m()
  5007. {
  5008. switchLOD(model_1m);
  5009. }
  5010. /*:421*//*422:*/
  5011. #line 9717 "./typica.w"
  5012. void ZoomLog::setDisplayUnits(Units::Unit scale)
  5013. {
  5014. model_ms->setDisplayUnits(scale);
  5015. model_1s->setDisplayUnits(scale);
  5016. model_5s->setDisplayUnits(scale);
  5017. model_10s->setDisplayUnits(scale);
  5018. model_15s->setDisplayUnits(scale);
  5019. model_30s->setDisplayUnits(scale);
  5020. model_1m->setDisplayUnits(scale);
  5021. }
  5022. Units::Unit ZoomLog::displayUnits()
  5023. {
  5024. return model_ms->displayUnits();
  5025. }
  5026. /*:422*//*423:*/
  5027. #line 9737 "./typica.w"
  5028. QString ZoomLog::lastTime(int series)
  5029. {
  5030. Measurement measure= lastMeasurement.value(series);
  5031. QTime time= measure.time();
  5032. return time.toString("h:mm:ss.zzz");
  5033. }
  5034. /*:423*//*424:*/
  5035. #line 9747 "./typica.w"
  5036. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  5037. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  5038. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  5039. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  5040. {
  5041. setEditTriggers(QAbstractItemView::NoEditTriggers);
  5042. setSelectionMode(QAbstractItemView::NoSelection);
  5043. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  5044. model_30s<<model_1m;
  5045. currentModel= model_30s;
  5046. setModel(currentModel);
  5047. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  5048. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  5049. this,SLOT(persistColumnResize(int,int,int)));
  5050. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  5051. this,SLOT(restoreColumnWidths()));
  5052. }
  5053. /*:424*//*425:*/
  5054. #line 9770 "./typica.w"
  5055. void ZoomLog::setHeaderData(int section,QString text)
  5056. {
  5057. MeasurementModel*m;
  5058. foreach(m,modelSet)
  5059. {
  5060. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  5061. }
  5062. }
  5063. /*:425*//*426:*/
  5064. #line 9788 "./typica.w"
  5065. void ZoomLog::addOutputTemperatureColumn(int column)
  5066. {
  5067. saveTempCols.append(column);
  5068. }
  5069. void ZoomLog::addOutputControlColumn(int column)
  5070. {
  5071. saveControlCols.append(column);
  5072. }
  5073. void ZoomLog::addOutputAnnotationColumn(int column)
  5074. {
  5075. saveNoteCols.append(column);
  5076. }
  5077. void ZoomLog::clearOutputColumns()
  5078. {
  5079. saveTempCols.clear();
  5080. saveControlCols.clear();
  5081. saveNoteCols.clear();
  5082. }
  5083. /*:426*//*427:*/
  5084. #line 9814 "./typica.w"
  5085. void ZoomLog::persistColumnResize(int column,int,int newsize)
  5086. {
  5087. /*659:*/
  5088. #line 14105 "./typica.w"
  5089. QSettings settings;
  5090. /*660:*/
  5091. #line 14118 "./typica.w"
  5092. QWidget*topLevelWidget= this;
  5093. while(topLevelWidget->parentWidget())
  5094. {
  5095. topLevelWidget= topLevelWidget->parentWidget();
  5096. }
  5097. /*:660*/
  5098. #line 14107 "./typica.w"
  5099. settings.setValue(QString("columnWidths/%1/%2/%3").
  5100. arg(topLevelWidget->objectName()).
  5101. arg(objectName()).arg(column),
  5102. QVariant(newsize));
  5103. /*:659*/
  5104. #line 9817 "./typica.w"
  5105. }
  5106. void ZoomLog::restoreColumnWidths()
  5107. {
  5108. /*662:*/
  5109. #line 14138 "./typica.w"
  5110. QSettings settings;
  5111. /*660:*/
  5112. #line 14118 "./typica.w"
  5113. QWidget*topLevelWidget= this;
  5114. while(topLevelWidget->parentWidget())
  5115. {
  5116. topLevelWidget= topLevelWidget->parentWidget();
  5117. }
  5118. /*:660*/
  5119. #line 14140 "./typica.w"
  5120. QString baseKey=
  5121. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  5122. arg(objectName());
  5123. for(int i= 0;i<model()->columnCount();i++)
  5124. {
  5125. QString key= QString("%1/%2").arg(baseKey).arg(i);
  5126. if(settings.contains(key))
  5127. {
  5128. setColumnWidth(i,settings.value(key).toInt());
  5129. }
  5130. }
  5131. /*:662*/
  5132. #line 9822 "./typica.w"
  5133. }
  5134. void ZoomLog::setVisible(bool visibility)
  5135. {
  5136. QTableView::setVisible(visibility);
  5137. }
  5138. void ZoomLog::showEvent(QShowEvent*)
  5139. {
  5140. /*662:*/
  5141. #line 14138 "./typica.w"
  5142. QSettings settings;
  5143. /*660:*/
  5144. #line 14118 "./typica.w"
  5145. QWidget*topLevelWidget= this;
  5146. while(topLevelWidget->parentWidget())
  5147. {
  5148. topLevelWidget= topLevelWidget->parentWidget();
  5149. }
  5150. /*:660*/
  5151. #line 14140 "./typica.w"
  5152. QString baseKey=
  5153. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  5154. arg(objectName());
  5155. for(int i= 0;i<model()->columnCount();i++)
  5156. {
  5157. QString key= QString("%1/%2").arg(baseKey).arg(i);
  5158. if(settings.contains(key))
  5159. {
  5160. setColumnWidth(i,settings.value(key).toInt());
  5161. }
  5162. }
  5163. /*:662*/
  5164. #line 9832 "./typica.w"
  5165. }
  5166. /*:427*/
  5167. #line 552 "./typica.w"
  5168. /*436:*/
  5169. #line 10065 "./typica.w"
  5170. bool MeasurementList::operator<(const MeasurementList&other)const
  5171. {
  5172. return this->first().toTime()<other.first().toTime();
  5173. }
  5174. bool MeasurementList::operator==(const MeasurementList&other)const
  5175. {
  5176. return this->first().toTime()==other.first().toTime();
  5177. }
  5178. /*:436*//*437:*/
  5179. #line 10081 "./typica.w"
  5180. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  5181. {
  5182. return QModelIndex();
  5183. }
  5184. /*:437*//*438:*/
  5185. #line 10091 "./typica.w"
  5186. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  5187. {
  5188. if(measure.scale()==Units::Unitless)
  5189. {
  5190. controlColumns->insert(tempcolumn,true);
  5191. }
  5192. else
  5193. {
  5194. controlColumns->insert(tempcolumn,false);
  5195. }
  5196. MeasurementList*temp;
  5197. temp= new MeasurementList;
  5198. temp->append(QVariant(measure.time()));
  5199. /*439:*/
  5200. #line 10150 "./typica.w"
  5201. /*440:*/
  5202. #line 10195 "./typica.w"
  5203. QList<MeasurementList*> ::iterator i= lastInsertion;
  5204. bool quickscan= false;
  5205. if(entries->size()> 5)
  5206. {
  5207. if(**i<*temp)
  5208. {
  5209. i+= 1;
  5210. for(int j= 10;j> 0;j--)
  5211. {
  5212. if(i!=entries->end())
  5213. {
  5214. if(**i<*temp)
  5215. {
  5216. i+= 1;
  5217. }
  5218. else
  5219. {
  5220. quickscan= true;
  5221. break;
  5222. }
  5223. }
  5224. else
  5225. {
  5226. quickscan= true;
  5227. break;
  5228. }
  5229. }
  5230. }
  5231. else
  5232. {
  5233. if(**i==*temp)
  5234. {
  5235. quickscan= true;
  5236. }
  5237. }
  5238. }
  5239. /*:440*/
  5240. #line 10151 "./typica.w"
  5241. if(quickscan==false)
  5242. {
  5243. i= entries->begin();
  5244. QList<MeasurementList*> ::iterator u= entries->end();
  5245. QList<MeasurementList*> ::iterator midpoint;
  5246. int n= u-i;
  5247. int rA;
  5248. while(n> 0)
  5249. {
  5250. rA= n>>1;
  5251. midpoint= i+rA;
  5252. if(**midpoint<*temp)
  5253. {
  5254. i= midpoint+1;
  5255. n-= rA+1;
  5256. }
  5257. else
  5258. {
  5259. n= rA;
  5260. }
  5261. }
  5262. }
  5263. /*:439*/
  5264. #line 10105 "./typica.w"
  5265. MeasurementList*newEntry;
  5266. int insertion;
  5267. if(i!=entries->end())
  5268. {
  5269. insertion= entries->indexOf(*i);
  5270. if((*i)->first().toTime()==measure.time())
  5271. {
  5272. /*441:*/
  5273. #line 10237 "./typica.w"
  5274. if((*i)->size()<tempcolumn+1)
  5275. {
  5276. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  5277. {
  5278. (*i)->append(QVariant());
  5279. }
  5280. }
  5281. (*i)->replace(tempcolumn,measure);
  5282. lastInsertion= i;
  5283. emit dataChanged(createIndex(insertion,tempcolumn),
  5284. createIndex(insertion,tempcolumn));
  5285. lastTemperature->insert(tempcolumn,insertion);
  5286. /*:441*/
  5287. #line 10113 "./typica.w"
  5288. }
  5289. else
  5290. {
  5291. /*442:*/
  5292. #line 10255 "./typica.w"
  5293. beginInsertRows(QModelIndex(),insertion,insertion);
  5294. newEntry= new MeasurementList;
  5295. newEntry->append(QVariant(measure.time()));
  5296. for(int j= 0;j<tempcolumn+1;j++)
  5297. {
  5298. newEntry->append(QVariant());
  5299. }
  5300. newEntry->replace(tempcolumn,measure);
  5301. lastInsertion= entries->insert(i,newEntry);
  5302. endInsertRows();
  5303. lastTemperature->insert(tempcolumn,insertion);
  5304. /*:442*/
  5305. #line 10117 "./typica.w"
  5306. }
  5307. }
  5308. else
  5309. {
  5310. /*443:*/
  5311. #line 10273 "./typica.w"
  5312. insertion= entries->size();
  5313. /*442:*/
  5314. #line 10255 "./typica.w"
  5315. beginInsertRows(QModelIndex(),insertion,insertion);
  5316. newEntry= new MeasurementList;
  5317. newEntry->append(QVariant(measure.time()));
  5318. for(int j= 0;j<tempcolumn+1;j++)
  5319. {
  5320. newEntry->append(QVariant());
  5321. }
  5322. newEntry->replace(tempcolumn,measure);
  5323. lastInsertion= entries->insert(i,newEntry);
  5324. endInsertRows();
  5325. lastTemperature->insert(tempcolumn,insertion);
  5326. /*:442*/
  5327. #line 10275 "./typica.w"
  5328. /*:443*/
  5329. #line 10122 "./typica.w"
  5330. }
  5331. if(tempcolumn>=colcount)
  5332. {
  5333. colcount= tempcolumn+1;
  5334. }
  5335. emit rowChanged(insertion);
  5336. delete temp;
  5337. }
  5338. /*:438*//*444:*/
  5339. #line 10285 "./typica.w"
  5340. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  5341. int annotationColumn)
  5342. {
  5343. int r;
  5344. if(lastTemperature->contains(tempcolumn))
  5345. {
  5346. r= lastTemperature->value(tempcolumn);
  5347. }
  5348. else
  5349. {
  5350. r= 0;
  5351. }
  5352. if(r==0&&entries->size()==0)
  5353. {
  5354. /*445:*/
  5355. #line 10323 "./typica.w"
  5356. beginInsertRows(QModelIndex(),0,0);
  5357. MeasurementList*newEntry= new MeasurementList;
  5358. newEntry->append(QVariant(QTime(0,0,0,0)));
  5359. entries->append(newEntry);
  5360. endInsertRows();
  5361. /*:445*/
  5362. #line 10300 "./typica.w"
  5363. }
  5364. MeasurementList*row= entries->at(r);
  5365. if(row->size()<=annotationColumn)
  5366. {
  5367. for(int i= row->size()-1;i<annotationColumn+1;i++)
  5368. {
  5369. row->append(QVariant());
  5370. }
  5371. }
  5372. row->replace(annotationColumn,annotation);
  5373. emit dataChanged(createIndex(r,annotationColumn),
  5374. createIndex(r,annotationColumn));
  5375. emit rowChanged(r);
  5376. if(annotationColumn> colcount-1)
  5377. {
  5378. colcount= annotationColumn+1;
  5379. }
  5380. }
  5381. /*:444*//*446:*/
  5382. #line 10334 "./typica.w"
  5383. void MeasurementModel::clear()
  5384. {
  5385. beginRemoveRows(QModelIndex(),0,entries->size());
  5386. while(entries->size()!=0)
  5387. {
  5388. MeasurementList*row= entries->takeFirst();
  5389. delete row;
  5390. }
  5391. endRemoveRows();
  5392. colcount= hData->size();
  5393. lastTemperature->clear();
  5394. reset();
  5395. }
  5396. /*:446*//*447:*/
  5397. #line 10367 "./typica.w"
  5398. bool MeasurementModel::setData(const QModelIndex&index,
  5399. const QVariant&value,int role)
  5400. {
  5401. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  5402. {
  5403. return false;
  5404. }
  5405. /*448:*/
  5406. #line 10399 "./typica.w"
  5407. bool valid= false;
  5408. if(index.isValid())
  5409. {
  5410. if(index.row()<entries->size())
  5411. {
  5412. if(index.column()<colcount)
  5413. {
  5414. valid= true;
  5415. }
  5416. }
  5417. }
  5418. /*:448*/
  5419. #line 10375 "./typica.w"
  5420. if(!valid)
  5421. {
  5422. return false;
  5423. }
  5424. MeasurementList*row= entries->at(index.row());
  5425. if(index.column()>=row->size())
  5426. {
  5427. /*449:*/
  5428. #line 10416 "./typica.w"
  5429. for(int i= row->size()-1;i<index.column();i++)
  5430. {
  5431. row->append(QVariant());
  5432. }
  5433. /*:449*/
  5434. #line 10383 "./typica.w"
  5435. }
  5436. if(index.column()==0)
  5437. {
  5438. /*450:*/
  5439. #line 10431 "./typica.w"
  5440. QTime time;
  5441. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  5442. {
  5443. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  5444. {
  5445. return false;
  5446. }
  5447. }
  5448. row= entries->takeAt(index.row());
  5449. row->replace(index.column(),QVariant(time));
  5450. MeasurementList*temp= row;
  5451. /*439:*/
  5452. #line 10150 "./typica.w"
  5453. /*440:*/
  5454. #line 10195 "./typica.w"
  5455. QList<MeasurementList*> ::iterator i= lastInsertion;
  5456. bool quickscan= false;
  5457. if(entries->size()> 5)
  5458. {
  5459. if(**i<*temp)
  5460. {
  5461. i+= 1;
  5462. for(int j= 10;j> 0;j--)
  5463. {
  5464. if(i!=entries->end())
  5465. {
  5466. if(**i<*temp)
  5467. {
  5468. i+= 1;
  5469. }
  5470. else
  5471. {
  5472. quickscan= true;
  5473. break;
  5474. }
  5475. }
  5476. else
  5477. {
  5478. quickscan= true;
  5479. break;
  5480. }
  5481. }
  5482. }
  5483. else
  5484. {
  5485. if(**i==*temp)
  5486. {
  5487. quickscan= true;
  5488. }
  5489. }
  5490. }
  5491. /*:440*/
  5492. #line 10151 "./typica.w"
  5493. if(quickscan==false)
  5494. {
  5495. i= entries->begin();
  5496. QList<MeasurementList*> ::iterator u= entries->end();
  5497. QList<MeasurementList*> ::iterator midpoint;
  5498. int n= u-i;
  5499. int rA;
  5500. while(n> 0)
  5501. {
  5502. rA= n>>1;
  5503. midpoint= i+rA;
  5504. if(**midpoint<*temp)
  5505. {
  5506. i= midpoint+1;
  5507. n-= rA+1;
  5508. }
  5509. else
  5510. {
  5511. n= rA;
  5512. }
  5513. }
  5514. }
  5515. /*:439*/
  5516. #line 10443 "./typica.w"
  5517. entries->insert(i,row);
  5518. int newRow= entries->indexOf(*i);
  5519. if(newRow<index.row())
  5520. {
  5521. emit dataChanged(createIndex(newRow,index.column()),index);
  5522. }
  5523. else
  5524. {
  5525. emit dataChanged(index,createIndex(newRow,index.column()));
  5526. }
  5527. /*:450*/
  5528. #line 10387 "./typica.w"
  5529. }
  5530. else
  5531. {
  5532. /*451:*/
  5533. #line 10457 "./typica.w"
  5534. row->replace(index.column(),value);
  5535. emit dataChanged(index,index);
  5536. /*:451*/
  5537. #line 10391 "./typica.w"
  5538. }
  5539. return true;
  5540. }
  5541. /*:447*//*452:*/
  5542. #line 10465 "./typica.w"
  5543. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  5544. unit(Units::Fahrenheit),hData(new QStringList),
  5545. lastTemperature(new QHash<int,int> ),
  5546. controlColumns(new QHash<int,bool> )
  5547. {
  5548. colcount= 1;
  5549. entries= new QList<MeasurementList*> ;
  5550. lastInsertion= entries->begin();
  5551. hData->append(tr("Time"));
  5552. }
  5553. /*:452*//*453:*/
  5554. #line 10479 "./typica.w"
  5555. MeasurementModel::~MeasurementModel()
  5556. {
  5557. clear();
  5558. delete entries;
  5559. delete hData;
  5560. }
  5561. /*:453*//*454:*/
  5562. #line 10491 "./typica.w"
  5563. int MeasurementModel::rowCount(const QModelIndex&parent)const
  5564. {
  5565. if(parent==QModelIndex())
  5566. {
  5567. return entries->size();
  5568. }
  5569. return 0;
  5570. }
  5571. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5572. {
  5573. if(parent==QModelIndex())
  5574. {
  5575. return colcount;
  5576. }
  5577. return 0;
  5578. }
  5579. /*:454*//*455:*/
  5580. #line 10518 "./typica.w"
  5581. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5582. const QVariant&value,int)
  5583. {
  5584. if(orientation==Qt::Horizontal)
  5585. {
  5586. if(hData->size()<section+1)
  5587. {
  5588. for(int i= hData->size();i<section+1;i++)
  5589. {
  5590. if(colcount<i)
  5591. {
  5592. beginInsertColumns(QModelIndex(),i,i);
  5593. }
  5594. hData->append(QString());
  5595. if(colcount<i)
  5596. {
  5597. endInsertColumns();
  5598. }
  5599. }
  5600. }
  5601. hData->replace(section,value.toString());
  5602. emit headerDataChanged(orientation,section,section);
  5603. if(colcount<section+1)
  5604. {
  5605. colcount= section+1;
  5606. }
  5607. return true;
  5608. }
  5609. return false;
  5610. }
  5611. /*:455*//*456:*/
  5612. #line 10558 "./typica.w"
  5613. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5614. {
  5615. beginResetModel();
  5616. unit= scale;
  5617. endResetModel();
  5618. }
  5619. Units::Unit MeasurementModel::displayUnits()
  5620. {
  5621. return unit;
  5622. }
  5623. /*:456*//*457:*/
  5624. #line 10584 "./typica.w"
  5625. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5626. {
  5627. /*448:*/
  5628. #line 10399 "./typica.w"
  5629. bool valid= false;
  5630. if(index.isValid())
  5631. {
  5632. if(index.row()<entries->size())
  5633. {
  5634. if(index.column()<colcount)
  5635. {
  5636. valid= true;
  5637. }
  5638. }
  5639. }
  5640. /*:448*/
  5641. #line 10587 "./typica.w"
  5642. if(!valid)
  5643. {
  5644. return QVariant();
  5645. }
  5646. MeasurementList*row= entries->at(index.row());
  5647. if(role==Qt::UserRole)
  5648. {
  5649. return QVariant(row->at(index.column()));
  5650. }
  5651. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5652. {
  5653. if(index.column()> row->size())
  5654. {
  5655. return QVariant();
  5656. }
  5657. else
  5658. {
  5659. if(index.column()==0)
  5660. {
  5661. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5662. }
  5663. else if(lastTemperature->contains(index.column()))
  5664. {
  5665. QVariantMap v= row->at(index.column()).toMap();
  5666. if(!v.contains("measurement"))
  5667. {
  5668. return QVariant();
  5669. }
  5670. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5671. {
  5672. return v.value("measurement");
  5673. }
  5674. else
  5675. {
  5676. if(v.contains("relative"))
  5677. {
  5678. if(v.value("relative").toBool())
  5679. {
  5680. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5681. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5682. }
  5683. }
  5684. return QVariant(QString("%1").
  5685. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5686. (Units::Unit)(v.value("unit").toInt()),unit)));
  5687. }
  5688. }
  5689. return QVariant(row->at(index.column()).toString());
  5690. }
  5691. }
  5692. return QVariant();
  5693. }
  5694. /*:457*//*458:*/
  5695. #line 10643 "./typica.w"
  5696. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5697. int role)const
  5698. {
  5699. if(orientation==Qt::Horizontal)
  5700. {
  5701. if(role==Qt::DisplayRole)
  5702. {
  5703. if(section<hData->size())
  5704. {
  5705. return QVariant(hData->at(section));
  5706. }
  5707. }
  5708. }
  5709. return QVariant();
  5710. }
  5711. /*:458*//*459:*/
  5712. #line 10670 "./typica.w"
  5713. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5714. {
  5715. /*448:*/
  5716. #line 10399 "./typica.w"
  5717. bool valid= false;
  5718. if(index.isValid())
  5719. {
  5720. if(index.row()<entries->size())
  5721. {
  5722. if(index.column()<colcount)
  5723. {
  5724. valid= true;
  5725. }
  5726. }
  5727. }
  5728. /*:448*/
  5729. #line 10673 "./typica.w"
  5730. if(valid)
  5731. {
  5732. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5733. }
  5734. return 0;
  5735. }
  5736. /*:459*//*460:*/
  5737. #line 10685 "./typica.w"
  5738. QModelIndex MeasurementModel::index(int row,int column,
  5739. const QModelIndex&parent)const
  5740. {
  5741. if(parent==QModelIndex())
  5742. {
  5743. if(row<entries->size()&&entries->isEmpty()==false)
  5744. {
  5745. if(column<entries->at(row)->size())
  5746. {
  5747. return createIndex(row,column);
  5748. }
  5749. }
  5750. }
  5751. return QModelIndex();
  5752. }
  5753. /*:460*/
  5754. #line 553 "./typica.w"
  5755. /*462:*/
  5756. #line 10736 "./typica.w"
  5757. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5758. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5759. {
  5760. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5761. }
  5762. /*:462*//*463:*/
  5763. #line 10751 "./typica.w"
  5764. void AnnotationButton::annotate()
  5765. {
  5766. if(note.contains("%1"))
  5767. {
  5768. count++;
  5769. emit annotation(note.arg(count),tc,ac);
  5770. }
  5771. else
  5772. {
  5773. emit annotation(note,tc,ac);
  5774. }
  5775. }
  5776. /*:463*//*464:*/
  5777. #line 10769 "./typica.w"
  5778. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5779. {
  5780. tc= tempcolumn;
  5781. }
  5782. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5783. {
  5784. ac= annotationcolumn;
  5785. }
  5786. void AnnotationButton::setAnnotation(const QString&annotation)
  5787. {
  5788. note= annotation;
  5789. }
  5790. /*:464*//*465:*/
  5791. #line 10788 "./typica.w"
  5792. void AnnotationButton::resetCount()
  5793. {
  5794. count= 0;
  5795. }
  5796. /*:465*/
  5797. #line 554 "./typica.w"
  5798. /*470:*/
  5799. #line 10871 "./typica.w"
  5800. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5801. const QString&postt,
  5802. QWidget*parent)
  5803. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5804. {
  5805. resetChange();
  5806. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5807. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5808. }
  5809. /*:470*//*471:*/
  5810. #line 10888 "./typica.w"
  5811. void AnnotationSpinBox::resetChange()
  5812. {
  5813. change= true;
  5814. }
  5815. /*:471*//*472:*/
  5816. #line 10899 "./typica.w"
  5817. void AnnotationSpinBox::annotate()
  5818. {
  5819. if(change)
  5820. {
  5821. change= false;
  5822. emit annotation(QString("%1%2%3").arg(pretext).
  5823. arg(value()).arg(posttext),tc,ac);
  5824. }
  5825. }
  5826. /*:472*//*473:*/
  5827. #line 10912 "./typica.w"
  5828. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5829. {
  5830. tc= tempcolumn;
  5831. }
  5832. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5833. {
  5834. ac= annotationcolumn;
  5835. }
  5836. void AnnotationSpinBox::setPretext(const QString&pret)
  5837. {
  5838. pretext= pret;
  5839. }
  5840. void AnnotationSpinBox::setPosttext(const QString&postt)
  5841. {
  5842. posttext= postt;
  5843. }
  5844. /*:473*/
  5845. #line 555 "./typica.w"
  5846. /*480:*/
  5847. #line 11081 "./typica.w"
  5848. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5849. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5850. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5851. stopAction(new QAction(tr("Stop"),NULL)),
  5852. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5853. relative(QTime::currentTime()),base(QTime(0,0,0))
  5854. {
  5855. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5856. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5857. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5858. clock.setInterval(500);
  5859. clock.setSingleShot(false);
  5860. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5861. setSegmentStyle(Filled);
  5862. updateDisplay();
  5863. }
  5864. /*:480*//*481:*/
  5865. #line 11102 "./typica.w"
  5866. void TimerDisplay::updateTime()
  5867. {
  5868. QTime time;
  5869. int cseconds= 0;
  5870. int oseconds= 0;
  5871. int r= 0;
  5872. QTime nt= QTime(0,0,0);
  5873. int n= 0;
  5874. int bseconds= 0;
  5875. switch(m)
  5876. {
  5877. case TimerDisplay::CountUp:
  5878. /*482:*/
  5879. #line 11134 "./typica.w"
  5880. /*483:*/
  5881. #line 11147 "./typica.w"
  5882. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5883. time= QTime::currentTime();
  5884. cseconds= TIMETOINT(time);
  5885. oseconds= TIMETOINT(relative);
  5886. r= cseconds-oseconds;
  5887. /*:483*/
  5888. #line 11135 "./typica.w"
  5889. nt= nt.addSecs(r);
  5890. if(nt!=s)
  5891. {
  5892. s= nt;
  5893. emit valueChanged(s);
  5894. }
  5895. /*:482*/
  5896. #line 11115 "./typica.w"
  5897. ;
  5898. break;
  5899. case TimerDisplay::CountDown:
  5900. /*484:*/
  5901. #line 11159 "./typica.w"
  5902. if(s> QTime(0,0,0))
  5903. {
  5904. /*483:*/
  5905. #line 11147 "./typica.w"
  5906. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5907. time= QTime::currentTime();
  5908. cseconds= TIMETOINT(time);
  5909. oseconds= TIMETOINT(relative);
  5910. r= cseconds-oseconds;
  5911. /*:483*/
  5912. #line 11162 "./typica.w"
  5913. bseconds= TIMETOINT(base);
  5914. n= bseconds-r;
  5915. nt= nt.addSecs(n);
  5916. if(nt!=s)
  5917. {
  5918. s= nt;
  5919. emit valueChanged(s);
  5920. }
  5921. }else{
  5922. stopTimer();
  5923. }
  5924. /*:484*/
  5925. #line 11118 "./typica.w"
  5926. ;
  5927. break;
  5928. case TimerDisplay::Clock:
  5929. /*485:*/
  5930. #line 11178 "./typica.w"
  5931. time= QTime::currentTime();
  5932. if(time!=s)
  5933. {
  5934. s= time;
  5935. emit valueChanged(s);
  5936. }
  5937. /*:485*/
  5938. #line 11121 "./typica.w"
  5939. ;
  5940. break;
  5941. default:
  5942. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5943. break;
  5944. }
  5945. updateDisplay();
  5946. }
  5947. /*:481*//*486:*/
  5948. #line 11190 "./typica.w"
  5949. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5950. void TimerDisplay::startTimer()
  5951. {
  5952. if(!running)
  5953. {
  5954. relative= QTime::currentTime();
  5955. if(ar)
  5956. {
  5957. reset();
  5958. }
  5959. else
  5960. {
  5961. relative= TIMESUBTRACT(relative,s);
  5962. }
  5963. if(m==Clock)
  5964. {
  5965. updateTime();
  5966. }
  5967. base= s;
  5968. clock.start();
  5969. running= true;
  5970. emit runStateChanged(true);
  5971. }
  5972. }
  5973. /*:486*//*487:*/
  5974. #line 11220 "./typica.w"
  5975. void TimerDisplay::stopTimer()
  5976. {
  5977. if(running)
  5978. {
  5979. clock.stop();
  5980. running= false;
  5981. emit runStateChanged(false);
  5982. }
  5983. }
  5984. /*:487*//*488:*/
  5985. #line 11233 "./typica.w"
  5986. TimerDisplay::~TimerDisplay()
  5987. {
  5988. clock.stop();
  5989. }
  5990. /*:488*//*489:*/
  5991. #line 11242 "./typica.w"
  5992. void TimerDisplay::setCountUpMode()
  5993. {
  5994. m= TimerDisplay::CountUp;
  5995. }
  5996. void TimerDisplay::setCountDownMode()
  5997. {
  5998. m= TimerDisplay::CountDown;
  5999. }
  6000. void TimerDisplay::setClockMode()
  6001. {
  6002. m= TimerDisplay::Clock;
  6003. }
  6004. /*:489*//*490:*/
  6005. #line 11260 "./typica.w"
  6006. QString TimerDisplay::value()
  6007. {
  6008. return s.toString(f);
  6009. }
  6010. QTime TimerDisplay::seconds()
  6011. {
  6012. return s;
  6013. }
  6014. TimerDisplay::TimerMode TimerDisplay::mode()
  6015. {
  6016. return m;
  6017. }
  6018. bool TimerDisplay::isRunning()
  6019. {
  6020. return running;
  6021. }
  6022. QTime TimerDisplay::resetValue()
  6023. {
  6024. return r;
  6025. }
  6026. QString TimerDisplay::displayFormat()
  6027. {
  6028. return f;
  6029. }
  6030. bool TimerDisplay::autoReset()
  6031. {
  6032. return ar;
  6033. }
  6034. /*:490*//*491:*/
  6035. #line 11298 "./typica.w"
  6036. void TimerDisplay::setTimer(QTime value)
  6037. {
  6038. if(value.isValid())
  6039. {
  6040. s= value;
  6041. updateDisplay();
  6042. emit valueChanged(value);
  6043. }
  6044. }
  6045. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  6046. {
  6047. m= mode;
  6048. }
  6049. void TimerDisplay::setResetValue(QTime value)
  6050. {
  6051. r= value;
  6052. }
  6053. void TimerDisplay::setDisplayFormat(QString format)
  6054. {
  6055. f= format;
  6056. setNumDigits(format.length());
  6057. }
  6058. void TimerDisplay::setAutoReset(bool reset)
  6059. {
  6060. ar= reset;
  6061. }
  6062. /*:491*//*492:*/
  6063. #line 11333 "./typica.w"
  6064. void TimerDisplay::copyTimer()
  6065. {
  6066. QApplication::clipboard()->setText(value());
  6067. }
  6068. /*:492*//*493:*/
  6069. #line 11342 "./typica.w"
  6070. void TimerDisplay::reset()
  6071. {
  6072. if(!running)
  6073. {
  6074. s= r;
  6075. updateDisplay();
  6076. }
  6077. }
  6078. /*:493*//*494:*/
  6079. #line 11355 "./typica.w"
  6080. void TimerDisplay::updateDisplay()
  6081. {
  6082. display(value());
  6083. }
  6084. /*:494*/
  6085. #line 556 "./typica.w"
  6086. /*501:*/
  6087. #line 11480 "./typica.w"
  6088. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  6089. {
  6090. int x= rect.x();
  6091. int y= rect.y();
  6092. QLayoutItem*item;
  6093. if(orientation==Qt::Horizontal)
  6094. {
  6095. /*502:*/
  6096. #line 11504 "./typica.w"
  6097. foreach(item,itemList)
  6098. {
  6099. int nextX= x+item->sizeHint().width()+spacing();
  6100. int right= x+item->sizeHint().width();
  6101. if(item==itemList.last())
  6102. {
  6103. right= rect.right();
  6104. }
  6105. int bottom= rect.bottom();
  6106. if(!testOnly)
  6107. {
  6108. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  6109. }
  6110. x= nextX;
  6111. }
  6112. /*:502*/
  6113. #line 11488 "./typica.w"
  6114. }
  6115. else
  6116. {
  6117. /*503:*/
  6118. #line 11523 "./typica.w"
  6119. foreach(item,itemList)
  6120. {
  6121. int nextY= y+item->sizeHint().height()+spacing();
  6122. int bottom= y+item->sizeHint().height();
  6123. if(item==itemList.last())
  6124. {
  6125. bottom= rect.bottom();
  6126. }
  6127. int right= rect.right();
  6128. if(!testOnly)
  6129. {
  6130. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  6131. }
  6132. y= nextY;
  6133. }
  6134. /*:503*/
  6135. #line 11492 "./typica.w"
  6136. }
  6137. return y;
  6138. }
  6139. /*:501*//*504:*/
  6140. #line 11547 "./typica.w"
  6141. QSize PackLayout::minimumSize()const
  6142. {
  6143. QSize size;
  6144. QLayoutItem*item;
  6145. foreach(item,itemList)
  6146. {
  6147. if(orientation==Qt::Horizontal)
  6148. {
  6149. size+= QSize(item->minimumSize().width(),0);
  6150. if(size.height()<item->minimumSize().height())
  6151. {
  6152. size.setHeight(item->minimumSize().height());
  6153. }
  6154. }
  6155. else
  6156. {
  6157. size+= QSize(0,item->minimumSize().height());
  6158. if(size.width()<item->minimumSize().width())
  6159. {
  6160. size.setWidth(item->minimumSize().width());
  6161. }
  6162. }
  6163. }
  6164. size+= QSize(2*margin(),2*margin());
  6165. return size;
  6166. }
  6167. /*:504*//*505:*/
  6168. #line 11579 "./typica.w"
  6169. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  6170. QLayout(parent)
  6171. {
  6172. setMargin(margin);
  6173. setSpacing(spacing);
  6174. setOrientation(Qt::Horizontal);
  6175. }
  6176. PackLayout::PackLayout(int spacing)
  6177. {
  6178. setSpacing(spacing);
  6179. setOrientation(Qt::Horizontal);
  6180. }
  6181. /*:505*//*506:*/
  6182. #line 11597 "./typica.w"
  6183. PackLayout::~PackLayout()
  6184. {
  6185. QLayoutItem*item;
  6186. while((item= takeAt(0)))
  6187. {
  6188. delete item;
  6189. }
  6190. }
  6191. /*:506*//*507:*/
  6192. #line 11611 "./typica.w"
  6193. QLayoutItem*PackLayout::takeAt(int index)
  6194. {
  6195. if(index>=0&&index<itemList.size())
  6196. {
  6197. return itemList.takeAt(index);
  6198. }
  6199. else
  6200. {
  6201. return NULL;
  6202. }
  6203. }
  6204. /*:507*//*508:*/
  6205. #line 11627 "./typica.w"
  6206. QLayoutItem*PackLayout::itemAt(int index)const
  6207. {
  6208. if(index>=0&&index<itemList.size())
  6209. {
  6210. return itemList.at(index);
  6211. }
  6212. else
  6213. {
  6214. return NULL;
  6215. }
  6216. }
  6217. /*:508*//*509:*/
  6218. #line 11650 "./typica.w"
  6219. void PackLayout::addItem(QLayoutItem*item)
  6220. {
  6221. itemList.append(item);
  6222. }
  6223. /*:509*//*510:*/
  6224. #line 11658 "./typica.w"
  6225. int PackLayout::count()const
  6226. {
  6227. return itemList.size();
  6228. }
  6229. /*:510*//*511:*/
  6230. #line 11670 "./typica.w"
  6231. Qt::Orientations PackLayout::expandingDirections()const
  6232. {
  6233. return Qt::Vertical|Qt::Horizontal;
  6234. }
  6235. bool PackLayout::hasHeightForWidth()const
  6236. {
  6237. return false;
  6238. }
  6239. int PackLayout::heightForWidth(int width)const
  6240. {
  6241. return doLayout(QRect(0,0,width,0),true);
  6242. }
  6243. void PackLayout::setGeometry(const QRect&rect)
  6244. {
  6245. QLayout::setGeometry(rect);
  6246. doLayout(rect,false);
  6247. }
  6248. QSize PackLayout::sizeHint()const
  6249. {
  6250. return minimumSize();
  6251. }
  6252. /*:511*//*512:*/
  6253. #line 11701 "./typica.w"
  6254. void PackLayout::setOrientation(Qt::Orientations direction)
  6255. {
  6256. orientation= direction;
  6257. doLayout(geometry(),false);
  6258. }
  6259. /*:512*/
  6260. #line 557 "./typica.w"
  6261. /*514:*/
  6262. #line 11740 "./typica.w"
  6263. SceneButton::SceneButton():QGraphicsScene()
  6264. {
  6265. }
  6266. SceneButton::~SceneButton()
  6267. {
  6268. }
  6269. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  6270. {
  6271. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  6272. }
  6273. /*:514*/
  6274. #line 558 "./typica.w"
  6275. /*516:*/
  6276. #line 11786 "./typica.w"
  6277. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  6278. Qt::Orientations orientation,
  6279. QWidget*parent,Qt::WindowFlags f):
  6280. QWidget(parent,f),label(new QGraphicsView()),
  6281. scene(new SceneButton())
  6282. {
  6283. layout= new PackLayout(this);
  6284. layout->setOrientation(orientation);
  6285. /*517:*/
  6286. #line 11806 "./typica.w"
  6287. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6288. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6289. label->setFrameShape(QFrame::NoFrame);
  6290. label->setInteractive(true);
  6291. /*:517*/
  6292. #line 11795 "./typica.w"
  6293. /*518:*/
  6294. #line 11817 "./typica.w"
  6295. scene->setBackgroundBrush(Qt::cyan);
  6296. text= scene->addText(labeltext);
  6297. if(orientation==Qt::Horizontal)
  6298. {
  6299. text->rotate(270.0);
  6300. }
  6301. label->setScene(scene);
  6302. /*:518*/
  6303. #line 11796 "./typica.w"
  6304. /*519:*/
  6305. #line 11835 "./typica.w"
  6306. if(orientation==Qt::Horizontal)
  6307. {
  6308. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  6309. }
  6310. else
  6311. {
  6312. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  6313. }
  6314. label->centerOn(text);
  6315. /*:519*/
  6316. #line 11797 "./typica.w"
  6317. /*520:*/
  6318. #line 11850 "./typica.w"
  6319. layout->addWidget(label);
  6320. layout->addWidget(widget);
  6321. if(orientation==Qt::Horizontal)
  6322. {
  6323. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  6324. widget->sizeHint().height());
  6325. }
  6326. else
  6327. {
  6328. setMinimumSize(widget->sizeHint().width(),
  6329. widget->sizeHint().height()+label->sizeHint().height());
  6330. }
  6331. /*:520*/
  6332. #line 11798 "./typica.w"
  6333. }
  6334. /*:516*//*521:*/
  6335. #line 11867 "./typica.w"
  6336. void WidgetDecorator::setBackgroundBrush(QBrush background)
  6337. {
  6338. scene->setBackgroundBrush(background);
  6339. }
  6340. void WidgetDecorator::setTextColor(QColor color)
  6341. {
  6342. text->setDefaultTextColor(color);
  6343. }
  6344. /*:521*//*522:*/
  6345. #line 11880 "./typica.w"
  6346. WidgetDecorator::~WidgetDecorator()
  6347. {
  6348. }
  6349. /*:522*/
  6350. #line 559 "./typica.w"
  6351. /*527:*/
  6352. #line 11979 "./typica.w"
  6353. void LogEditWindow::addTheRows()
  6354. {
  6355. QTime s= startTime->time();
  6356. while(s<endTime->time())
  6357. {
  6358. model->newMeasurement(Measurement(0,s),1);
  6359. s= s.addSecs(interval->value());
  6360. }
  6361. model->newMeasurement(Measurement(0,endTime->time()),1);
  6362. }
  6363. /*:527*//*528:*/
  6364. #line 11993 "./typica.w"
  6365. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  6366. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  6367. addRowsLayout(new QHBoxLayout(NULL)),
  6368. startTimeLabel(new QLabel("Start Time")),
  6369. startTime(new QTimeEdit(QTime(0,0,0,0))),
  6370. endTimeLabel(new QLabel("End Time")),
  6371. endTime(new QTimeEdit(QTime(0,20,0,0))),
  6372. intervalLabel(new QLabel("Interval (seconds)")),
  6373. interval(new QSpinBox()),
  6374. addRows(new QPushButton("Add Rows")),
  6375. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  6376. saveCsv(new QAction(tr("Export CSV"),NULL)),
  6377. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  6378. model(new MeasurementModel()),
  6379. log(new QTableView())
  6380. {
  6381. /*529:*/
  6382. #line 12030 "./typica.w"
  6383. QSettings settings;
  6384. resize(settings.value("logSize",QSize(620,400)).toSize());
  6385. move(settings.value("logPos",QPoint(200,60)).toPoint());
  6386. /*:529*/
  6387. #line 12010 "./typica.w"
  6388. /*530:*/
  6389. #line 12043 "./typica.w"
  6390. mainLayout->setOrientation(Qt::Vertical);
  6391. addRowsLayout->addSpacing(10);
  6392. addRowsLayout->addWidget(startTimeLabel);
  6393. addRowsLayout->addWidget(startTime);
  6394. addRowsLayout->addSpacing(10);
  6395. startTime->setDisplayFormat("mm:ss");
  6396. addRowsLayout->addWidget(endTimeLabel);
  6397. addRowsLayout->addWidget(endTime);
  6398. addRowsLayout->addSpacing(10);
  6399. endTime->setDisplayFormat("mm:ss");
  6400. addRowsLayout->addWidget(intervalLabel);
  6401. addRowsLayout->addWidget(interval);
  6402. addRowsLayout->addSpacing(10);
  6403. interval->setRange(0,60);
  6404. interval->setValue(30);
  6405. addRowsLayout->addWidget(addRows);
  6406. addRowsLayout->addSpacing(10);
  6407. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  6408. /*:530*/
  6409. #line 12011 "./typica.w"
  6410. /*531:*/
  6411. #line 12066 "./typica.w"
  6412. model->setHeaderData(0,Qt::Horizontal,"Time");
  6413. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  6414. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  6415. model->clear();
  6416. /*:531*/
  6417. #line 12012 "./typica.w"
  6418. /*532:*/
  6419. #line 12075 "./typica.w"
  6420. log->setModel(model);
  6421. log->setColumnWidth(0,100);
  6422. log->setColumnWidth(1,100);
  6423. log->setColumnWidth(2,100);
  6424. /*:532*/
  6425. #line 12013 "./typica.w"
  6426. mainLayout->addItem(addRowsLayout);
  6427. mainLayout->addWidget(log);
  6428. centralWidget->setLayout(mainLayout);
  6429. setCentralWidget(centralWidget);
  6430. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  6431. fileMenu->addAction(openXml);
  6432. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  6433. fileMenu->addAction(saveXml);
  6434. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  6435. fileMenu->addAction(saveCsv);
  6436. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  6437. }
  6438. /*:528*//*533:*/
  6439. #line 12086 "./typica.w"
  6440. void LogEditWindow::saveXML()
  6441. {
  6442. QSettings settings;
  6443. QString lastDir= settings.value("lastDirectory").toString();
  6444. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  6445. lastDir,"",0);
  6446. QFile file(filename);
  6447. XMLOutput writer(model,&file,0);
  6448. writer.addTemperatureColumn("Temperature",1);
  6449. writer.addAnnotationColumn("Annotation",2);
  6450. if(writer.output())
  6451. {
  6452. QFileInfo info(filename);
  6453. QDir directory= info.dir();
  6454. lastDir= directory.path();
  6455. settings.setValue("lastDirectory",lastDir);
  6456. }
  6457. }
  6458. void LogEditWindow::saveCSV()
  6459. {
  6460. QSettings settings;
  6461. QString lastDir= settings.value("lastDirectory").toString();
  6462. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  6463. lastDir,"",0);
  6464. QFile file(filename);
  6465. CSVOutput writer(model,&file,0);
  6466. writer.addTemperatureColumn("Temperature",1);
  6467. writer.addAnnotationColumn("Annotation",2);
  6468. if(writer.output())
  6469. {
  6470. QFileInfo info(filename);
  6471. QDir directory= info.dir();
  6472. lastDir= directory.path();
  6473. settings.setValue("lastDirectory",lastDir);
  6474. }
  6475. }
  6476. /*:533*//*534:*/
  6477. #line 12129 "./typica.w"
  6478. void LogEditWindow::openXML()
  6479. {
  6480. QSettings settings;
  6481. QString lastDir= settings.value("lastDirectory").toString();
  6482. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  6483. lastDir,"",0);
  6484. if(filename.isNull())
  6485. {
  6486. return;
  6487. }
  6488. QFile file(filename);
  6489. XMLInput reader(&file,1);
  6490. connect(&reader,SIGNAL(measure(Measurement,int)),
  6491. model,SLOT(newMeasurement(Measurement,int)));
  6492. connect(&reader,SIGNAL(annotation(QString,int,int)),
  6493. model,SLOT(newAnnotation(QString,int,int)));
  6494. if(reader.input())
  6495. {
  6496. QFileInfo info(filename);
  6497. setWindowTitle(QString(tr("%1 - %2")).
  6498. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  6499. QDir directory= info.dir();
  6500. lastDir= directory.path();
  6501. settings.setValue("lastDirectory",lastDir);
  6502. }
  6503. }
  6504. /*:534*//*535:*/
  6505. #line 12160 "./typica.w"
  6506. void LogEditWindow::closeEvent(QCloseEvent*event)
  6507. {
  6508. QSettings settings;
  6509. settings.setValue("logSize",size());
  6510. settings.setValue("logPos",pos());
  6511. event->accept();
  6512. }
  6513. /*:535*/
  6514. #line 560 "./typica.w"
  6515. /*541:*/
  6516. #line 12275 "./typica.w"
  6517. bool XMLOutput::output()
  6518. {
  6519. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6520. {
  6521. return false;
  6522. }
  6523. QXmlStreamWriter xmlout(out);
  6524. xmlout.writeStartDocument("1.0");
  6525. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  6526. xmlout.writeStartElement("roastlog");
  6527. /*542:*/
  6528. #line 12308 "./typica.w"
  6529. foreach(int c,temperatureColumns.keys())
  6530. {
  6531. xmlout.writeStartElement("tempseries");
  6532. xmlout.writeAttribute("name",temperatureColumns.value(c));
  6533. xmlout.writeEndElement();
  6534. }
  6535. foreach(int c,controlColumns.keys())
  6536. {
  6537. xmlout.writeStartElement("controlseries");
  6538. xmlout.writeAttribute("name",controlColumns.value(c));
  6539. xmlout.writeEndElement();
  6540. }
  6541. foreach(int c,annotationColumns.keys())
  6542. {
  6543. xmlout.writeStartElement("noteseries");
  6544. xmlout.writeAttribute("name",annotationColumns.value(c));
  6545. xmlout.writeEndElement();
  6546. }
  6547. /*:542*/
  6548. #line 12286 "./typica.w"
  6549. xmlout.writeStartElement("roast");
  6550. bool oresult;
  6551. for(int i= 0;i<data->rowCount();i++)
  6552. {
  6553. /*543:*/
  6554. #line 12333 "./typica.w"
  6555. oresult= false;
  6556. foreach(int c,temperatureColumns.keys())
  6557. {
  6558. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6559. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6560. {
  6561. oresult= true;
  6562. break;
  6563. }
  6564. }
  6565. foreach(int c,controlColumns.keys())
  6566. {
  6567. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6568. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6569. {
  6570. oresult= true;
  6571. break;
  6572. }
  6573. }
  6574. if(oresult==false)
  6575. {
  6576. foreach(int c,annotationColumns.keys())
  6577. {
  6578. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6579. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6580. isEmpty()))
  6581. {
  6582. oresult= true;
  6583. break;
  6584. }
  6585. }
  6586. }
  6587. /*:543*/
  6588. #line 12291 "./typica.w"
  6589. if(oresult)
  6590. {
  6591. /*544:*/
  6592. #line 12372 "./typica.w"
  6593. xmlout.writeStartElement("tuple");
  6594. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6595. Qt::DisplayRole).toString());
  6596. foreach(int c,temperatureColumns.keys())
  6597. {
  6598. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6599. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6600. {
  6601. xmlout.writeStartElement("temperature");
  6602. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6603. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6604. {
  6605. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6606. {
  6607. xmlout.writeAttribute("relative","true");
  6608. }
  6609. }
  6610. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6611. toString());
  6612. xmlout.writeEndElement();
  6613. }
  6614. }
  6615. foreach(int c,controlColumns.keys())
  6616. {
  6617. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6618. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6619. {
  6620. xmlout.writeStartElement("control");
  6621. xmlout.writeAttribute("series",controlColumns.value(c));
  6622. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6623. xmlout.writeEndElement();
  6624. }
  6625. }
  6626. foreach(int c,annotationColumns.keys())
  6627. {
  6628. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6629. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6630. {
  6631. xmlout.writeStartElement("annotation");
  6632. xmlout.writeAttribute("series",annotationColumns.value(c));
  6633. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6634. toString());
  6635. xmlout.writeEndElement();
  6636. }
  6637. }
  6638. xmlout.writeEndElement();
  6639. /*:544*/
  6640. #line 12294 "./typica.w"
  6641. }
  6642. }
  6643. xmlout.writeEndElement();
  6644. xmlout.writeEndElement();
  6645. xmlout.writeEndDocument();
  6646. out->close();
  6647. return true;
  6648. }
  6649. /*:541*//*545:*/
  6650. #line 12422 "./typica.w"
  6651. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6652. :QObject(NULL),data(model),out(device),time(timec)
  6653. {
  6654. }
  6655. void XMLOutput::setModel(MeasurementModel*model)
  6656. {
  6657. data= model;
  6658. }
  6659. void XMLOutput::setTimeColumn(int column)
  6660. {
  6661. time= column;
  6662. }
  6663. void XMLOutput::setDevice(QIODevice*device)
  6664. {
  6665. out= device;
  6666. }
  6667. /*:545*//*546:*/
  6668. #line 12451 "./typica.w"
  6669. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6670. {
  6671. temperatureColumns.insert(column,series);
  6672. }
  6673. void XMLOutput::addControlColumn(const QString&series,int column)
  6674. {
  6675. controlColumns.insert(column,series);
  6676. }
  6677. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6678. {
  6679. annotationColumns.insert(column,series);
  6680. }
  6681. /*:546*/
  6682. #line 561 "./typica.w"
  6683. /*548:*/
  6684. #line 12508 "./typica.w"
  6685. bool XMLInput::input()
  6686. {
  6687. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6688. {
  6689. return false;
  6690. }
  6691. QXmlStreamReader xmlin(in);
  6692. QMap<QString,int> temperatureColumns;
  6693. QMap<QString,int> annotationColumns;
  6694. int nextColumn= firstc;
  6695. /*549:*/
  6696. #line 12539 "./typica.w"
  6697. while(!xmlin.isDTD())
  6698. {
  6699. xmlin.readNext();
  6700. }
  6701. if(xmlin.isDTD())
  6702. {
  6703. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6704. {
  6705. /*550:*/
  6706. #line 12561 "./typica.w"
  6707. emit newTemperatureColumn(firstc,"Bean");
  6708. emit newAnnotationColumn(firstc+1,"Note");
  6709. emit lastColumn(firstc+1);
  6710. /*:550*/
  6711. #line 12548 "./typica.w"
  6712. }
  6713. else
  6714. {
  6715. xmlin.readNext();
  6716. /*551:*/
  6717. #line 12570 "./typica.w"
  6718. while(xmlin.name()!="roast")
  6719. {
  6720. if(xmlin.isStartElement())
  6721. {
  6722. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6723. {
  6724. temperatureColumns.insert(xmlin.attributes().value("name").
  6725. toString(),
  6726. nextColumn);
  6727. emit newTemperatureColumn(nextColumn,
  6728. xmlin.attributes().value("name").
  6729. toString());
  6730. nextColumn++;
  6731. }
  6732. else if(xmlin.name()=="noteseries")
  6733. {
  6734. annotationColumns.insert(xmlin.attributes().value("name").
  6735. toString(),nextColumn);
  6736. emit newAnnotationColumn(nextColumn,
  6737. xmlin.attributes().value("name").
  6738. toString());
  6739. nextColumn++;
  6740. }
  6741. }
  6742. xmlin.readNext();
  6743. }
  6744. emit lastColumn(nextColumn-1);
  6745. /*:551*/
  6746. #line 12553 "./typica.w"
  6747. }
  6748. }
  6749. /*:549*/
  6750. #line 12519 "./typica.w"
  6751. QTime timeval= QTime();
  6752. double tempval= 0;
  6753. QString noteval= QString();
  6754. int column;
  6755. int counter= 0;
  6756. while(!xmlin.atEnd())
  6757. {
  6758. /*552:*/
  6759. #line 12611 "./typica.w"
  6760. xmlin.readNext();
  6761. if(xmlin.isStartElement())
  6762. {
  6763. /*553:*/
  6764. #line 12637 "./typica.w"
  6765. if(xmlin.name()=="time")
  6766. {
  6767. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6768. }
  6769. else if(xmlin.name()=="temperature")
  6770. {
  6771. column= xmlin.attributes().hasAttribute("series")?
  6772. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6773. bool relative= (xmlin.attributes().value("relative")=="true");
  6774. tempval= xmlin.readElementText().toDouble();
  6775. Measurement measurement(tempval,timeval);
  6776. if(relative)
  6777. {
  6778. measurement.insert("relative",true);
  6779. }
  6780. emit measure(measurement,column);
  6781. }
  6782. else if(xmlin.name()=="control")
  6783. {
  6784. column= xmlin.attributes().value("series").toString().isEmpty()?
  6785. firstc:temperatureColumns.value(xmlin.attributes().
  6786. value("series").toString());
  6787. tempval= xmlin.readElementText().toDouble();
  6788. Measurement measurement(tempval,timeval,Units::Unitless);
  6789. emit measure(measurement,column);
  6790. }
  6791. else if(xmlin.name()=="annotation")
  6792. {
  6793. column= xmlin.attributes().value("series").toString().isEmpty()?
  6794. firstc+1:annotationColumns.value(xmlin.attributes().
  6795. value("series").toString());
  6796. noteval= xmlin.readElementText();
  6797. if(!noteval.isEmpty())
  6798. {
  6799. emit annotation(noteval,firstc,column);
  6800. }
  6801. }
  6802. /*:553*/
  6803. #line 12615 "./typica.w"
  6804. }
  6805. counter++;
  6806. if(counter%100==0)
  6807. {
  6808. QCoreApplication::processEvents();
  6809. }
  6810. /*:552*/
  6811. #line 12527 "./typica.w"
  6812. }
  6813. return true;
  6814. }
  6815. /*:548*//*554:*/
  6816. #line 12678 "./typica.w"
  6817. XMLInput::XMLInput(QIODevice*input,int c):
  6818. firstc(c),in(input)
  6819. {
  6820. }
  6821. void XMLInput::setFirstColumn(int column)
  6822. {
  6823. firstc= column;
  6824. }
  6825. void XMLInput::setDevice(QIODevice*device)
  6826. {
  6827. in= device;
  6828. }
  6829. /*:554*/
  6830. #line 562 "./typica.w"
  6831. /*559:*/
  6832. #line 12769 "./typica.w"
  6833. bool CSVOutput::output()
  6834. {
  6835. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6836. {
  6837. return false;
  6838. }
  6839. QTextStream output(out);
  6840. /*560:*/
  6841. #line 12793 "./typica.w"
  6842. output<<"Time";
  6843. foreach(int c,temperatureColumns.keys())
  6844. {
  6845. output<<','<<temperatureColumns.value(c);
  6846. }
  6847. foreach(int c,controlColumns.keys())
  6848. {
  6849. output<<','<<controlColumns.value(c);
  6850. }
  6851. foreach(int c,annotationColumns.keys())
  6852. {
  6853. output<<','<<annotationColumns.value(c);
  6854. }
  6855. output<<'\n';
  6856. /*:560*/
  6857. #line 12777 "./typica.w"
  6858. bool oresult;
  6859. for(int i= 0;i<data->rowCount();i++)
  6860. {
  6861. /*543:*/
  6862. #line 12333 "./typica.w"
  6863. oresult= false;
  6864. foreach(int c,temperatureColumns.keys())
  6865. {
  6866. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6867. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6868. {
  6869. oresult= true;
  6870. break;
  6871. }
  6872. }
  6873. foreach(int c,controlColumns.keys())
  6874. {
  6875. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6876. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6877. {
  6878. oresult= true;
  6879. break;
  6880. }
  6881. }
  6882. if(oresult==false)
  6883. {
  6884. foreach(int c,annotationColumns.keys())
  6885. {
  6886. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6887. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6888. isEmpty()))
  6889. {
  6890. oresult= true;
  6891. break;
  6892. }
  6893. }
  6894. }
  6895. /*:543*/
  6896. #line 12781 "./typica.w"
  6897. if(oresult)
  6898. {
  6899. /*561:*/
  6900. #line 12818 "./typica.w"
  6901. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6902. foreach(int c,temperatureColumns.keys())
  6903. {
  6904. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6905. }
  6906. foreach(int c,controlColumns.keys())
  6907. {
  6908. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6909. }
  6910. foreach(int c,annotationColumns.keys())
  6911. {
  6912. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6913. }
  6914. output<<'\n';
  6915. /*:561*/
  6916. #line 12784 "./typica.w"
  6917. }
  6918. }
  6919. out->close();
  6920. return true;
  6921. }
  6922. /*:559*//*562:*/
  6923. #line 12837 "./typica.w"
  6924. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6925. data(model),out(device),time(timec)
  6926. {
  6927. }
  6928. void CSVOutput::setModel(MeasurementModel*model)
  6929. {
  6930. data= model;
  6931. }
  6932. void CSVOutput::setTimeColumn(int column)
  6933. {
  6934. time= column;
  6935. }
  6936. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6937. {
  6938. temperatureColumns.insert(column,series);
  6939. }
  6940. void CSVOutput::addControlColumn(const QString&series,int column)
  6941. {
  6942. controlColumns.insert(column,series);
  6943. }
  6944. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6945. {
  6946. annotationColumns.insert(column,series);
  6947. }
  6948. void CSVOutput::setDevice(QIODevice*device)
  6949. {
  6950. out= device;
  6951. }
  6952. #line 1 "./webview.w"
  6953. /*:562*/
  6954. #line 563 "./typica.w"
  6955. /*614:*/
  6956. #line 13233 "./typica.w"
  6957. QString SaltModel::arrayLiteral(int column,int role)const
  6958. {
  6959. QString literal= "'{";
  6960. for(int i= 0;i<rowCount();i++)
  6961. {
  6962. QString datum= data(index(i,column),role).toString();
  6963. if(!datum.isEmpty())
  6964. {
  6965. literal.append(datum);
  6966. literal.append(", ");
  6967. }
  6968. }
  6969. if(literal.size()> 2)
  6970. {
  6971. literal.chop(2);
  6972. }
  6973. literal.append("}'");
  6974. return literal;
  6975. }
  6976. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6977. {
  6978. QString literal= "'{";
  6979. for(int i= 0;i<rowCount();i++)
  6980. {
  6981. QString datum= data(index(i,column),role).toString();
  6982. if(!datum.isEmpty())
  6983. {
  6984. literal.append("\"");
  6985. literal.append(datum);
  6986. literal.append("\", ");
  6987. }
  6988. }
  6989. if(literal.size()> 2)
  6990. {
  6991. literal.chop(2);
  6992. }
  6993. literal.append("}'");
  6994. return literal;
  6995. }
  6996. /*:614*//*615:*/
  6997. #line 13277 "./typica.w"
  6998. QModelIndex SaltModel::parent(const QModelIndex&)const
  6999. {
  7000. return QModelIndex();
  7001. }
  7002. /*:615*//*616:*/
  7003. #line 13296 "./typica.w"
  7004. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  7005. int role)
  7006. {
  7007. /*617:*/
  7008. #line 13327 "./typica.w"
  7009. bool valid= false;
  7010. if(index.isValid())
  7011. {
  7012. if(index.row()<modelData.size())
  7013. {
  7014. if(index.column()<colcount)
  7015. {
  7016. valid= true;
  7017. }
  7018. }
  7019. }
  7020. /*:617*/
  7021. #line 13300 "./typica.w"
  7022. if(!valid)
  7023. {
  7024. return false;
  7025. }
  7026. if(index.row()==modelData.size()-1)
  7027. {
  7028. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  7029. /*618:*/
  7030. #line 13343 "./typica.w"
  7031. QList<QMap<int,QVariant> > newRow;
  7032. QMap<int,QVariant> defaults;
  7033. for(int i= 0;i<colcount;i++)
  7034. {
  7035. newRow.append(defaults);
  7036. }
  7037. modelData.append(newRow);
  7038. /*:618*/
  7039. #line 13308 "./typica.w"
  7040. endInsertRows();
  7041. }
  7042. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  7043. QMap<int,QVariant> cell= row.at(index.column());
  7044. cell.insert(role,value);
  7045. if(role==Qt::EditRole)
  7046. {
  7047. cell.insert(Qt::DisplayRole,value);
  7048. }
  7049. row.replace(index.column(),cell);
  7050. modelData.replace(index.row(),row);
  7051. emit dataChanged(index,index);
  7052. return true;
  7053. }
  7054. /*:616*//*619:*/
  7055. #line 13354 "./typica.w"
  7056. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  7057. {
  7058. for(int i= 0;i<columns;i++)
  7059. {
  7060. hData<<"";
  7061. }
  7062. /*618:*/
  7063. #line 13343 "./typica.w"
  7064. QList<QMap<int,QVariant> > newRow;
  7065. QMap<int,QVariant> defaults;
  7066. for(int i= 0;i<colcount;i++)
  7067. {
  7068. newRow.append(defaults);
  7069. }
  7070. modelData.append(newRow);
  7071. /*:618*/
  7072. #line 13361 "./typica.w"
  7073. }
  7074. /*:619*//*620:*/
  7075. #line 13366 "./typica.w"
  7076. SaltModel::~SaltModel()
  7077. {
  7078. }
  7079. /*:620*//*621:*/
  7080. #line 13376 "./typica.w"
  7081. int SaltModel::rowCount(const QModelIndex&parent)const
  7082. {
  7083. return(parent==QModelIndex()?modelData.size():0);
  7084. }
  7085. int SaltModel::columnCount(const QModelIndex&parent)const
  7086. {
  7087. return(parent==QModelIndex()?colcount:0);
  7088. }
  7089. /*:621*//*622:*/
  7090. #line 13389 "./typica.w"
  7091. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  7092. const QVariant&value,int)
  7093. {
  7094. if(orientation==Qt::Horizontal&&section<colcount)
  7095. {
  7096. hData.replace(section,value.toString());
  7097. emit headerDataChanged(orientation,section,section);
  7098. return true;
  7099. }
  7100. return false;
  7101. }
  7102. /*:622*//*623:*/
  7103. #line 13404 "./typica.w"
  7104. QVariant SaltModel::data(const QModelIndex&index,int role)const
  7105. {
  7106. /*617:*/
  7107. #line 13327 "./typica.w"
  7108. bool valid= false;
  7109. if(index.isValid())
  7110. {
  7111. if(index.row()<modelData.size())
  7112. {
  7113. if(index.column()<colcount)
  7114. {
  7115. valid= true;
  7116. }
  7117. }
  7118. }
  7119. /*:617*/
  7120. #line 13407 "./typica.w"
  7121. if(!valid)
  7122. {
  7123. return QVariant();
  7124. }
  7125. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  7126. QMap<int,QVariant> cell= row.at(index.column());
  7127. return cell.value(role,QVariant());
  7128. }
  7129. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  7130. int role)const
  7131. {
  7132. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  7133. section<colcount)
  7134. {
  7135. return QVariant(hData.at(section));
  7136. }
  7137. return QVariant();
  7138. }
  7139. /*:623*//*624:*/
  7140. #line 13431 "./typica.w"
  7141. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  7142. {
  7143. /*617:*/
  7144. #line 13327 "./typica.w"
  7145. bool valid= false;
  7146. if(index.isValid())
  7147. {
  7148. if(index.row()<modelData.size())
  7149. {
  7150. if(index.column()<colcount)
  7151. {
  7152. valid= true;
  7153. }
  7154. }
  7155. }
  7156. /*:617*/
  7157. #line 13434 "./typica.w"
  7158. if(valid)
  7159. {
  7160. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  7161. }
  7162. return 0;
  7163. }
  7164. /*:624*//*625:*/
  7165. #line 13445 "./typica.w"
  7166. QModelIndex SaltModel::index(int row,int column,
  7167. const QModelIndex&parent)const
  7168. {
  7169. if(parent==QModelIndex())
  7170. {
  7171. if(row<modelData.size()&&column<colcount)
  7172. {
  7173. return createIndex(row,column);
  7174. }
  7175. }
  7176. return QModelIndex();
  7177. }
  7178. /*:625*//*626:*/
  7179. #line 13463 "./typica.w"
  7180. void SaltModel::clear()
  7181. {
  7182. beginResetModel();
  7183. modelData.clear();
  7184. /*618:*/
  7185. #line 13343 "./typica.w"
  7186. QList<QMap<int,QVariant> > newRow;
  7187. QMap<int,QVariant> defaults;
  7188. for(int i= 0;i<colcount;i++)
  7189. {
  7190. newRow.append(defaults);
  7191. }
  7192. modelData.append(newRow);
  7193. /*:618*/
  7194. #line 13468 "./typica.w"
  7195. endResetModel();
  7196. }
  7197. /*:626*//*627:*/
  7198. #line 13477 "./typica.w"
  7199. bool SaltModel::removeRows(int row,int count,
  7200. const QModelIndex&parent)
  7201. {
  7202. if(parent==QModelIndex())
  7203. {
  7204. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  7205. {
  7206. beginRemoveRows(parent,row,row+count-1);
  7207. for(int i= 0;i<count;i++)
  7208. {
  7209. modelData.removeAt(row);
  7210. }
  7211. endRemoveRows();
  7212. if(modelData.size()==0)
  7213. {
  7214. beginInsertRows(parent,0,0);
  7215. /*618:*/
  7216. #line 13343 "./typica.w"
  7217. QList<QMap<int,QVariant> > newRow;
  7218. QMap<int,QVariant> defaults;
  7219. for(int i= 0;i<colcount;i++)
  7220. {
  7221. newRow.append(defaults);
  7222. }
  7223. modelData.append(newRow);
  7224. /*:618*/
  7225. #line 13494 "./typica.w"
  7226. endInsertRows();
  7227. }
  7228. return true;
  7229. }
  7230. }
  7231. return false;
  7232. }
  7233. /*:627*//*628:*/
  7234. #line 13508 "./typica.w"
  7235. int SaltModel::findData(const QVariant&value,int column,int role)
  7236. {
  7237. for(int i= 0;i<modelData.size();i++)
  7238. {
  7239. if(modelData.at(i).size()> column)
  7240. {
  7241. if(modelData.at(i).at(column).contains(role))
  7242. {
  7243. if(modelData.at(i).at(column).value(role)==value)
  7244. {
  7245. return i;
  7246. }
  7247. }
  7248. }
  7249. }
  7250. return-1;
  7251. }
  7252. /*:628*/
  7253. #line 564 "./typica.w"
  7254. /*630:*/
  7255. #line 13572 "./typica.w"
  7256. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  7257. {
  7258. SqlComboBox*widget= new SqlComboBox();
  7259. widget->setParent(parent);
  7260. for(int i= 0;i<count();i++)
  7261. {
  7262. widget->addItem(itemText(i),itemData(i));
  7263. }
  7264. return widget;
  7265. }
  7266. /*:630*//*631:*/
  7267. #line 13589 "./typica.w"
  7268. void SqlComboBox::showData(bool show)
  7269. {
  7270. dataColumnShown= show;
  7271. }
  7272. /*:631*//*632:*/
  7273. #line 13603 "./typica.w"
  7274. void SqlComboBox::addNullOption()
  7275. {
  7276. addItem(specialNullText,specialNullData);
  7277. }
  7278. void SqlComboBox::setNullText(QString nullText)
  7279. {
  7280. specialNullText= nullText;
  7281. }
  7282. void SqlComboBox::setNullData(QVariant nullData)
  7283. {
  7284. specialNullData= nullData;
  7285. }
  7286. /*:632*//*633:*/
  7287. #line 13626 "./typica.w"
  7288. void SqlComboBox::setDataColumn(int column)
  7289. {
  7290. dataColumn= column;
  7291. }
  7292. void SqlComboBox::setDisplayColumn(int column)
  7293. {
  7294. displayColumn= column;
  7295. }
  7296. /*:633*//*634:*/
  7297. #line 13640 "./typica.w"
  7298. void SqlComboBox::addSqlOptions(QString query)
  7299. {
  7300. SqlQueryConnection h;
  7301. QSqlQuery*dbquery= h.operator->();
  7302. if(!dbquery->exec(query))
  7303. {
  7304. QSqlError error= dbquery->lastError();
  7305. qDebug()<<error.databaseText();
  7306. qDebug()<<error.driverText();
  7307. qDebug()<<error.text();
  7308. qDebug()<<dbquery->lastQuery();
  7309. }
  7310. while(dbquery->next())
  7311. {
  7312. QString displayValue(dbquery->value(displayColumn).toString());
  7313. QString dataValue(dbquery->value(dataColumn).toString());
  7314. if(dataColumnShown)
  7315. {
  7316. displayValue.append(QString(" (%1)").arg(dataValue));
  7317. }
  7318. addItem(displayValue,dataValue);
  7319. }
  7320. }
  7321. /*:634*//*635:*/
  7322. #line 13676 "./typica.w"
  7323. SqlComboBox::SqlComboBox():
  7324. dataColumn(0),displayColumn(0),dataColumnShown(false),
  7325. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  7326. {
  7327. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  7328. }
  7329. SqlComboBox::~SqlComboBox()
  7330. {
  7331. }
  7332. /*:635*/
  7333. #line 565 "./typica.w"
  7334. /*637:*/
  7335. #line 13715 "./typica.w"
  7336. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  7337. {
  7338. delegate= widget;
  7339. }
  7340. /*:637*//*638:*/
  7341. #line 13724 "./typica.w"
  7342. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  7343. const QStyleOptionViewItem&,
  7344. const QModelIndex&)const
  7345. {
  7346. return delegate->clone(parent);
  7347. }
  7348. /*:638*//*639:*/
  7349. #line 13735 "./typica.w"
  7350. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  7351. const QModelIndex&index)const
  7352. {
  7353. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  7354. self->setCurrentIndex(self->findData(
  7355. index.model()->data(index,
  7356. Qt::UserRole).toString()));
  7357. }
  7358. /*:639*//*640:*/
  7359. #line 13748 "./typica.w"
  7360. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  7361. QAbstractItemModel*model,
  7362. const QModelIndex&index)const
  7363. {
  7364. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  7365. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  7366. Qt::UserRole);
  7367. model->setData(index,self->currentText(),Qt::DisplayRole);
  7368. }
  7369. /*:640*//*641:*/
  7370. #line 13761 "./typica.w"
  7371. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  7372. const QStyleOptionViewItem&option,
  7373. const QModelIndex&)const
  7374. {
  7375. editor->setGeometry(option.rect);
  7376. }
  7377. /*:641*//*642:*/
  7378. #line 13772 "./typica.w"
  7379. QSize SqlComboBoxDelegate::sizeHint()const
  7380. {
  7381. return delegate->sizeHint();
  7382. }
  7383. /*:642*//*643:*/
  7384. #line 13780 "./typica.w"
  7385. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  7386. :QItemDelegate(parent)
  7387. {
  7388. }
  7389. /*:643*/
  7390. #line 566 "./typica.w"
  7391. /*599:*/
  7392. #line 12925 "./typica.w"
  7393. Application::Application(int&argc,char**argv):QApplication(argc,argv),
  7394. connectionStatus(false),currentUser(QString())
  7395. {
  7396. network= new QNetworkAccessManager(this);
  7397. /*600:*/
  7398. #line 12942 "./typica.w"
  7399. setOrganizationName("Wilson's Coffee & Tea");
  7400. setOrganizationDomain("wilsonscoffee.com");
  7401. setApplicationName(PROGRAM_NAME);
  7402. /*:600*/
  7403. #line 12930 "./typica.w"
  7404. /*601:*/
  7405. #line 12951 "./typica.w"
  7406. QTranslator*base= new QTranslator;
  7407. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7408. {
  7409. installTranslator(base);
  7410. }
  7411. QTranslator*app= new QTranslator;
  7412. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7413. {
  7414. installTranslator(app);
  7415. }
  7416. /*:601*/
  7417. #line 12931 "./typica.w"
  7418. /*308:*/
  7419. #line 123 "./measurement.w"
  7420. qRegisterMetaType<Measurement> ("Measurement");
  7421. /*:308*/
  7422. #line 12932 "./typica.w"
  7423. /*820:*/
  7424. #line 17079 "./typica.w"
  7425. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  7426. tr("NI DAQmx Base"),
  7427. "nidaqmxbase",NULL);
  7428. topLevelNodeInserters.append(inserter);
  7429. /*:820*//*828:*/
  7430. #line 17310 "./typica.w"
  7431. #ifdef Q_OS_WIN32
  7432. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  7433. topLevelNodeInserters.append(inserter);
  7434. #endif
  7435. /*:828*//*852:*/
  7436. #line 18277 "./typica.w"
  7437. #if 0
  7438. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  7439. topLevelNodeInserters.append(inserter);
  7440. #endif
  7441. /*:852*//*905:*/
  7442. #line 19785 "./typica.w"
  7443. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  7444. topLevelNodeInserters.append(inserter);
  7445. #line 1 "./modbus.w"
  7446. /*:905*//*911:*/
  7447. #line 328 "./modbus.w"
  7448. inserter= new NodeInserter(tr("ModbusNG Port"),tr("Modbus RTU Port"),"modbusngport",NULL);
  7449. topLevelNodeInserters.append(inserter);
  7450. /*:911*//*927:*/
  7451. #line 272 "./unsupportedserial.w"
  7452. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  7453. "unsupporteddevice",NULL);
  7454. topLevelNodeInserters.append(inserter);
  7455. /*:927*//*958:*/
  7456. #line 190 "./phidgets.w"
  7457. QLibrary phidgetsCheck("phidget21");
  7458. if(phidgetsCheck.load())
  7459. {
  7460. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7461. "phidgets1048",NULL);
  7462. topLevelNodeInserters.append(inserter);
  7463. phidgetsCheck.unload();
  7464. }
  7465. else
  7466. {
  7467. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  7468. if(phidgetsCheck.load())
  7469. {
  7470. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7471. "phidgets1048",NULL);
  7472. topLevelNodeInserters.append(inserter);
  7473. phidgetsCheck.unload();
  7474. }
  7475. }
  7476. /*:958*//*972:*/
  7477. #line 17 "./phidget22.w"
  7478. #if __APPLE__
  7479. QLibrary phidget22check("Phidget22.framework/Phidget22");
  7480. #else
  7481. QLibrary phidget22check("phidget22");
  7482. #endif
  7483. if(phidget22check.load())
  7484. {
  7485. inserter= new NodeInserter(tr("Phidget22"),tr("Phidget22"),"phidget22",
  7486. NULL);
  7487. topLevelNodeInserters.append(inserter);
  7488. phidget22check.unload();
  7489. }
  7490. /*:972*//*1095:*/
  7491. #line 1241 "./dataqsdk.w"
  7492. #ifdef Q_OS_WIN32
  7493. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  7494. "dataqsdk",NULL);
  7495. topLevelNodeInserters.append(inserter);
  7496. #endif
  7497. #line 20456 "./typica.w"
  7498. #line 1 "./scales.w"
  7499. /*:1095*//*1120:*/
  7500. #line 557 "./scales.w"
  7501. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  7502. topLevelNodeInserters.append(inserter);
  7503. #line 20458 "./typica.w"
  7504. #line 1 "./valueannotation.w"
  7505. /*:1120*/
  7506. #line 12933 "./typica.w"
  7507. }
  7508. /*:599*//*603:*/
  7509. #line 12974 "./typica.w"
  7510. QDomDocument*Application::configuration()
  7511. {
  7512. return&conf;
  7513. }
  7514. /*:603*//*604:*/
  7515. #line 12983 "./typica.w"
  7516. QSqlDatabase Application::database()
  7517. {
  7518. QString connectionName;
  7519. QSqlDatabase connection=
  7520. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  7521. do
  7522. {
  7523. connectionName= QUuid::createUuid().toString();
  7524. }while(QSqlDatabase::connectionNames().contains(connectionName));
  7525. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  7526. }
  7527. /*:604*//*605:*/
  7528. #line 12999 "./typica.w"
  7529. void Application::setDatabaseConnected(bool status)
  7530. {
  7531. connectionStatus= status;
  7532. }
  7533. bool Application::databaseConnected()
  7534. {
  7535. return connectionStatus;
  7536. }
  7537. /*:605*//*606:*/
  7538. #line 13022 "./typica.w"
  7539. DatabaseNotification*Application::subscribe(const QString&notification)
  7540. {
  7541. DatabaseNotification*retval;
  7542. if(notifiers.contains(notification))
  7543. {
  7544. retval= notifiers.value(notification);
  7545. }
  7546. else
  7547. {
  7548. if(notifiers.size()==0)
  7549. {
  7550. notificationDriver= QSqlDatabase::database().driver();
  7551. connect(notificationDriver,SIGNAL(notification(QString)),this,SLOT(notify(QString)));
  7552. }
  7553. retval= new DatabaseNotification;
  7554. connect(this,SIGNAL(aboutToQuit()),retval,SLOT(deleteLater()));
  7555. if(notifiers.size()!=
  7556. notificationDriver->subscribedToNotifications().size())
  7557. {
  7558. for(int i= 0;i<notifiers.size();i++)
  7559. {
  7560. notificationDriver->subscribeToNotification(notifiers.keys().at(i));
  7561. }
  7562. }
  7563. notifiers.insert(notification,retval);
  7564. notificationDriver->subscribeToNotification(notification);
  7565. }
  7566. return retval;
  7567. }
  7568. /*:606*//*607:*/
  7569. #line 13058 "./typica.w"
  7570. void Application::notify(const QString&notification)
  7571. {
  7572. if(notifiers.contains(notification))
  7573. {
  7574. DatabaseNotification*notifier= notifiers.value(notification);
  7575. notifier->forwardNotification(notification);
  7576. }
  7577. }
  7578. /*:607*//*755:*/
  7579. #line 15612 "./typica.w"
  7580. void Application::saveDeviceConfiguration()
  7581. {
  7582. QSettings settings;
  7583. settings.setValue("DeviceConfiguration",
  7584. QVariant(deviceConfigurationDocument.toByteArray()));
  7585. }
  7586. /*:755*//*756:*/
  7587. #line 15624 "./typica.w"
  7588. QDomDocument Application::deviceConfiguration()
  7589. {
  7590. if(deviceConfigurationDocument.isNull())
  7591. {
  7592. /*757:*/
  7593. #line 15638 "./typica.w"
  7594. QSettings settings;
  7595. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  7596. QString etext;
  7597. int eline;
  7598. int ecol;
  7599. if(document.length()==0)
  7600. {
  7601. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  7602. /*758:*/
  7603. #line 15662 "./typica.w"
  7604. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7605. emptyDocument.open(QIODevice::ReadOnly);
  7606. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7607. &etext,&eline,&ecol))
  7608. {
  7609. /*759:*/
  7610. #line 15679 "./typica.w"
  7611. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7612. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7613. qDebug()<<etext;
  7614. /*:759*/
  7615. #line 15668 "./typica.w"
  7616. }
  7617. else
  7618. {
  7619. saveDeviceConfiguration();
  7620. }
  7621. /*:758*/
  7622. #line 15647 "./typica.w"
  7623. }
  7624. else
  7625. {
  7626. if(!deviceConfigurationDocument.setContent(document,false,
  7627. &etext,&eline,&ecol))
  7628. {
  7629. /*759:*/
  7630. #line 15679 "./typica.w"
  7631. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7632. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7633. qDebug()<<etext;
  7634. /*:759*/
  7635. #line 15654 "./typica.w"
  7636. /*758:*/
  7637. #line 15662 "./typica.w"
  7638. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7639. emptyDocument.open(QIODevice::ReadOnly);
  7640. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7641. &etext,&eline,&ecol))
  7642. {
  7643. /*759:*/
  7644. #line 15679 "./typica.w"
  7645. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7646. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7647. qDebug()<<etext;
  7648. /*:759*/
  7649. #line 15668 "./typica.w"
  7650. }
  7651. else
  7652. {
  7653. saveDeviceConfiguration();
  7654. }
  7655. /*:758*/
  7656. #line 15655 "./typica.w"
  7657. }
  7658. }
  7659. /*:757*/
  7660. #line 15629 "./typica.w"
  7661. }
  7662. return deviceConfigurationDocument;
  7663. }
  7664. /*:756*//*787:*/
  7665. #line 16280 "./typica.w"
  7666. void Application::registerDeviceConfigurationWidget(QString driver,
  7667. QMetaObject widget)
  7668. {
  7669. deviceConfigurationWidgets.insert(driver,widget);
  7670. }
  7671. /*:787*//*788:*/
  7672. #line 16296 "./typica.w"
  7673. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7674. const QModelIndex&index)
  7675. {
  7676. QVariant nodeReference= index.data(Qt::UserRole);
  7677. QDomElement referenceElement= model->referenceElement(
  7678. model->data(index,Qt::UserRole).toString());
  7679. QMetaObject metaObject=
  7680. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7681. QWidget::staticMetaObject);
  7682. QWidget*editor;
  7683. if(metaObject.className()==QWidget::staticMetaObject.className())
  7684. {
  7685. editor= NULL;
  7686. }
  7687. else
  7688. {
  7689. editor= qobject_cast<QWidget*> (
  7690. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7691. Q_ARG(QModelIndex,index)));
  7692. }
  7693. return editor;
  7694. }
  7695. /*:788*//*1150:*/
  7696. #line 16 "./user.w"
  7697. QString Application::currentTypicaUser()
  7698. {
  7699. return currentUser;
  7700. }
  7701. /*:1150*//*1151:*/
  7702. #line 26 "./user.w"
  7703. void Application::setCurrentTypicaUser(const QString&user)
  7704. {
  7705. currentUser= user;
  7706. emit userChanged(currentUser);
  7707. }
  7708. /*:1151*//*1152:*/
  7709. #line 37 "./user.w"
  7710. bool Application::login(const QString&user,const QString&password)
  7711. {
  7712. SqlQueryConnection h;
  7713. QSqlQuery*dbquery= h.operator->();
  7714. dbquery->prepare("SELECT 1 FROM typica_users WHERE name = :name AND password = :password AND active = TRUE");
  7715. dbquery->bindValue(":name",user);
  7716. dbquery->bindValue(":password",password);
  7717. dbquery->exec();
  7718. if(dbquery->next())
  7719. {
  7720. currentUser= user;
  7721. emit userChanged(currentUser);
  7722. return true;
  7723. }
  7724. return false;
  7725. }
  7726. /*:1152*//*1153:*/
  7727. #line 58 "./user.w"
  7728. bool Application::autoLogin()
  7729. {
  7730. SqlQueryConnection h;
  7731. QSqlQuery*dbquery= h.operator->();
  7732. dbquery->exec("SELECT name FROM typica_users WHERE auto_login = TRUE");
  7733. if(dbquery->next())
  7734. {
  7735. currentUser= dbquery->value(0).toString();
  7736. emit userChanged(currentUser);
  7737. return true;
  7738. }
  7739. return false;
  7740. }
  7741. /*:1153*/
  7742. #line 567 "./typica.w"
  7743. /*652:*/
  7744. #line 13928 "./typica.w"
  7745. SqlConnectionSetup::SqlConnectionSetup():
  7746. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7747. portnumber(new QLineEdit),
  7748. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7749. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7750. cancelButton(new QPushButton(tr("Cancel"))),
  7751. connectButton(new QPushButton(tr("Connect")))
  7752. {
  7753. QSettings settings;
  7754. driver->addItem("PostgreSQL","QPSQL");
  7755. formLayout->addRow(tr("Database driver:"),driver);
  7756. formLayout->addRow(tr("Host name:"),hostname);
  7757. hostname->setText(settings.value("database/hostname").toString());
  7758. formLayout->addRow(tr("Port number:"),portnumber);
  7759. portnumber->setText(settings.value("database/portnumber","5432").toString());
  7760. formLayout->addRow(tr("Database name:"),dbname);
  7761. dbname->setText(settings.value("database/dbname").toString());
  7762. formLayout->addRow(tr("User name:"),user);
  7763. user->setText(settings.value("database/user").toString());
  7764. password->setEchoMode(QLineEdit::Password);
  7765. formLayout->addRow(tr("Password:"),password);
  7766. password->setText(settings.value("database/password").toString());
  7767. layout->addLayout(formLayout);
  7768. buttons->addStretch(1);
  7769. buttons->addWidget(cancelButton);
  7770. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7771. buttons->addWidget(connectButton);
  7772. layout->addLayout(buttons);
  7773. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7774. connectButton->setDefault(true);
  7775. setLayout(layout);
  7776. setModal(true);
  7777. }
  7778. SqlConnectionSetup::~SqlConnectionSetup()
  7779. {
  7780. }
  7781. /*:652*//*653:*/
  7782. #line 13971 "./typica.w"
  7783. void SqlConnectionSetup::testConnection()
  7784. {
  7785. QSqlDatabase database=
  7786. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7787. toString());
  7788. database.setConnectOptions("application_name=Typica");
  7789. database.setHostName(hostname->text());
  7790. database.setPort(portnumber->text().toInt());
  7791. database.setDatabaseName(dbname->text());
  7792. database.setUserName(user->text());
  7793. database.setPassword(password->text());
  7794. if(database.open())
  7795. {
  7796. QSettings settings;
  7797. settings.setValue("database/exists","true");
  7798. settings.setValue("database/driver",
  7799. driver->itemData(driver->currentIndex()).toString());
  7800. settings.setValue("database/hostname",hostname->text());
  7801. settings.setValue("database/portnumber",portnumber->text());
  7802. settings.setValue("database/dbname",dbname->text());
  7803. settings.setValue("database/user",user->text());
  7804. settings.setValue("database/password",password->text());
  7805. AppInstance->setDatabaseConnected(true);
  7806. accept();
  7807. }
  7808. else
  7809. {
  7810. QMessageBox::information(this,tr("Database connection failed"),
  7811. tr("Failed to connect to database."));
  7812. }
  7813. }
  7814. /*:653*/
  7815. #line 568 "./typica.w"
  7816. /*657:*/
  7817. #line 14079 "./typica.w"
  7818. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7819. {
  7820. setModel(new QSqlQueryModel);
  7821. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7822. this,SLOT(openRow(QModelIndex)));
  7823. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7824. this,SLOT(persistColumnResize(int,int,int)));
  7825. connect(this,SIGNAL(activated(QModelIndex)),
  7826. this,SLOT(selectRow(QModelIndex)));
  7827. }
  7828. /*:657*//*658:*/
  7829. #line 14096 "./typica.w"
  7830. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7831. {
  7832. /*659:*/
  7833. #line 14105 "./typica.w"
  7834. QSettings settings;
  7835. /*660:*/
  7836. #line 14118 "./typica.w"
  7837. QWidget*topLevelWidget= this;
  7838. while(topLevelWidget->parentWidget())
  7839. {
  7840. topLevelWidget= topLevelWidget->parentWidget();
  7841. }
  7842. /*:660*/
  7843. #line 14107 "./typica.w"
  7844. settings.setValue(QString("columnWidths/%1/%2/%3").
  7845. arg(topLevelWidget->objectName()).
  7846. arg(objectName()).arg(column),
  7847. QVariant(newsize));
  7848. /*:659*/
  7849. #line 14099 "./typica.w"
  7850. }
  7851. /*:658*//*661:*/
  7852. #line 14128 "./typica.w"
  7853. void SqlQueryView::showEvent(QShowEvent*event)
  7854. {
  7855. /*662:*/
  7856. #line 14138 "./typica.w"
  7857. QSettings settings;
  7858. /*660:*/
  7859. #line 14118 "./typica.w"
  7860. QWidget*topLevelWidget= this;
  7861. while(topLevelWidget->parentWidget())
  7862. {
  7863. topLevelWidget= topLevelWidget->parentWidget();
  7864. }
  7865. /*:660*/
  7866. #line 14140 "./typica.w"
  7867. QString baseKey=
  7868. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7869. arg(objectName());
  7870. for(int i= 0;i<model()->columnCount();i++)
  7871. {
  7872. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7873. if(settings.contains(key))
  7874. {
  7875. setColumnWidth(i,settings.value(key).toInt());
  7876. }
  7877. }
  7878. /*:662*/
  7879. #line 14131 "./typica.w"
  7880. event->accept();
  7881. }
  7882. /*:661*//*663:*/
  7883. #line 14155 "./typica.w"
  7884. void SqlQueryView::openRow(const QModelIndex&index)
  7885. {
  7886. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7887. emit openEntryRow(index.row());
  7888. }
  7889. void SqlQueryView::selectRow(const QModelIndex&index)
  7890. {
  7891. emit selectEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7892. emit selectEntryRow(index.row());
  7893. }
  7894. /*:663*//*664:*/
  7895. #line 14170 "./typica.w"
  7896. void SqlQueryView::setQuery(const QString&query)
  7897. {
  7898. QSqlDatabase database= AppInstance->database();
  7899. database.open();
  7900. QSqlQuery q(query,database);
  7901. ((QSqlQueryModel*)model())->setQuery(q);
  7902. database.close();
  7903. }
  7904. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7905. const QVariant&value,int role)
  7906. {
  7907. return model()->setHeaderData(section,orientation,value,role);
  7908. }
  7909. /*:664*//*665:*/
  7910. #line 14188 "./typica.w"
  7911. QVariant SqlQueryView::data(int row,int column,int role)
  7912. {
  7913. return model()->data(model()->index(row,column),role);
  7914. }
  7915. /*:665*/
  7916. #line 569 "./typica.w"
  7917. /*174:*/
  7918. #line 4056 "./typica.w"
  7919. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7920. {
  7921. QSqlDatabase database= AppInstance->database();
  7922. database.open();
  7923. q= new QSqlQuery(query,database);
  7924. connection= database.connectionName();
  7925. }
  7926. /*:174*//*175:*/
  7927. #line 4069 "./typica.w"
  7928. SqlQueryConnection::~SqlQueryConnection()
  7929. {
  7930. delete q;
  7931. {
  7932. QSqlDatabase database= QSqlDatabase::database(connection);
  7933. database.close();
  7934. }
  7935. QSqlDatabase::removeDatabase(connection);
  7936. }
  7937. /*:175*//*176:*/
  7938. #line 4083 "./typica.w"
  7939. QSqlQuery*SqlQueryConnection::operator->()const
  7940. {
  7941. return q;
  7942. }
  7943. /*:176*/
  7944. #line 570 "./typica.w"
  7945. /*684:*/
  7946. #line 14547 "./typica.w"
  7947. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7948. area(frame),configuration(description)
  7949. {
  7950. refresh();
  7951. }
  7952. ReportTable::~ReportTable()
  7953. {
  7954. }
  7955. /*:684*//*685:*/
  7956. #line 14563 "./typica.w"
  7957. void ReportTable::bind(QString placeholder,QVariant value)
  7958. {
  7959. bindings.insert(placeholder,value);
  7960. }
  7961. /*:685*//*686:*/
  7962. #line 14573 "./typica.w"
  7963. void ReportTable::refresh()
  7964. {
  7965. /*687:*/
  7966. #line 14594 "./typica.w"
  7967. QTextCursor cursor= area->firstCursorPosition();
  7968. while(cursor<area->lastCursorPosition())
  7969. {
  7970. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7971. }
  7972. cursor.removeSelectedText();
  7973. /*:687*/
  7974. #line 14576 "./typica.w"
  7975. int rows= 1;
  7976. int columns= 1;
  7977. int currentRow= 0;
  7978. QTextTable*table= cursor.insertTable(rows,columns);
  7979. /*688:*/
  7980. #line 14607 "./typica.w"
  7981. QTextTableFormat format= table->format();
  7982. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7983. if(configuration.hasAttribute("align"))
  7984. {
  7985. if(configuration.attribute("align")=="center")
  7986. {
  7987. format.setAlignment(Qt::AlignHCenter);
  7988. }
  7989. }
  7990. table->setFormat(format);
  7991. /*:688*/
  7992. #line 14581 "./typica.w"
  7993. /*689:*/
  7994. #line 14621 "./typica.w"
  7995. QDomNodeList children= configuration.childNodes();
  7996. for(int i= 0;i<children.count();i++)
  7997. {
  7998. QDomNode current;
  7999. QDomElement currentElement;
  8000. current= children.at(i);
  8001. if(current.isElement())
  8002. {
  8003. currentElement= current.toElement();
  8004. if(currentElement.tagName()=="query")
  8005. {
  8006. /*690:*/
  8007. #line 14648 "./typica.w"
  8008. SqlQueryConnection h;
  8009. QSqlQuery*query= h.operator->();
  8010. query->prepare(currentElement.text());
  8011. foreach(QString key,bindings.uniqueKeys())
  8012. {
  8013. if(currentElement.text().contains(key))
  8014. {
  8015. query->bindValue(key,bindings.value(key));
  8016. }
  8017. }
  8018. query->exec();
  8019. if(!query->next())
  8020. {
  8021. continue;
  8022. }
  8023. if(query->record().count()> columns)
  8024. {
  8025. table->appendColumns(query->record().count()-columns);
  8026. }
  8027. do
  8028. {
  8029. table->appendRows(1);
  8030. rows++;
  8031. currentRow++;
  8032. for(int j= 0;j<query->record().count();j++)
  8033. {
  8034. QTextTableCell cell= table->cellAt(currentRow,j);
  8035. cursor= cell.firstCursorPosition();
  8036. cursor.insertText(query->value(j).toString());
  8037. }
  8038. }while(query->next());
  8039. /*:690*/
  8040. #line 14633 "./typica.w"
  8041. }
  8042. else if(currentElement.tagName()=="row")
  8043. {
  8044. /*691:*/
  8045. #line 14688 "./typica.w"
  8046. table->appendRows(1);
  8047. currentRow++;
  8048. rows++;
  8049. QDomNodeList rowChildren= currentElement.childNodes();
  8050. int currentColumn= 0;
  8051. for(int j= 0;j<rowChildren.count();j++)
  8052. {
  8053. QDomNode node;
  8054. QDomElement nodeElement;
  8055. node= rowChildren.at(j);
  8056. if(node.isElement())
  8057. {
  8058. nodeElement= node.toElement();
  8059. if(nodeElement.tagName()=="cell")
  8060. {
  8061. if(currentColumn==columns)
  8062. {
  8063. table->appendColumns(1);
  8064. columns++;
  8065. }
  8066. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  8067. cursor= cell.firstCursorPosition();
  8068. cursor.insertText(nodeElement.text());
  8069. currentColumn++;
  8070. }
  8071. }
  8072. }
  8073. /*:691*/
  8074. #line 14637 "./typica.w"
  8075. }
  8076. }
  8077. }
  8078. /*:689*/
  8079. #line 14582 "./typica.w"
  8080. if(rows> 1)
  8081. {
  8082. table->removeRows(0,1);
  8083. }
  8084. }
  8085. /*:686*/
  8086. #line 571 "./typica.w"
  8087. /*723:*/
  8088. #line 14794 "./typica.w"
  8089. FormArray::FormArray(QDomElement description):configuration(description),
  8090. maxwidth(-1),maxheight(-1)
  8091. {
  8092. setWidget(&itemContainer);
  8093. itemContainer.setLayout(&itemLayout);
  8094. }
  8095. /*:723*//*724:*/
  8096. #line 14811 "./typica.w"
  8097. void FormArray::addElements(int copies)
  8098. {
  8099. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  8100. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  8101. QWidget*widget;
  8102. for(int i= 0;i<copies;i++)
  8103. {
  8104. widget= new QWidget;
  8105. if(maxwidth> -1)
  8106. {
  8107. widget->setMaximumWidth(maxwidth);
  8108. }
  8109. if(maxheight> -1)
  8110. {
  8111. widget->setMaximumHeight(maxheight);
  8112. }
  8113. if(configuration.hasChildNodes())
  8114. {
  8115. widgetStack->push(widget);
  8116. populateWidget(configuration,widgetStack,layoutStack);
  8117. widgetStack->pop();
  8118. widget->setMinimumHeight(widget->sizeHint().height());
  8119. itemLayout.addWidget(widget);
  8120. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  8121. {
  8122. itemContainer.setMinimumHeight(maxheight*elements()+50);
  8123. }
  8124. else
  8125. {
  8126. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  8127. +widget->sizeHint().height());
  8128. }
  8129. if(maxwidth> -1)
  8130. {
  8131. itemContainer.setMinimumWidth(maxwidth+50);
  8132. }
  8133. else
  8134. {
  8135. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  8136. }
  8137. }
  8138. }
  8139. }
  8140. /*:724*//*725:*/
  8141. #line 14861 "./typica.w"
  8142. QWidget*FormArray::elementAt(int index)
  8143. {
  8144. if(index<itemLayout.count())
  8145. {
  8146. QLayoutItem*item= itemLayout.itemAt(index);
  8147. return item->widget();
  8148. }
  8149. else
  8150. {
  8151. return NULL;
  8152. }
  8153. }
  8154. /*:725*//*726:*/
  8155. #line 14878 "./typica.w"
  8156. void FormArray::removeAllElements()
  8157. {
  8158. while(itemLayout.count()> 0)
  8159. {
  8160. QLayoutItem*item;
  8161. item= itemLayout.itemAt(0);
  8162. item->widget()->hide();
  8163. itemLayout.removeWidget(item->widget());
  8164. }
  8165. itemContainer.setMinimumHeight(0);
  8166. }
  8167. /*:726*//*727:*/
  8168. #line 14894 "./typica.w"
  8169. int FormArray::elements()
  8170. {
  8171. return itemLayout.count();
  8172. }
  8173. /*:727*//*728:*/
  8174. #line 14905 "./typica.w"
  8175. void FormArray::setMaximumElementWidth(int width)
  8176. {
  8177. maxwidth= width;
  8178. }
  8179. void FormArray::setMaximumElementHeight(int height)
  8180. {
  8181. maxheight= height;
  8182. }
  8183. /*:728*/
  8184. #line 572 "./typica.w"
  8185. /*734:*/
  8186. #line 15036 "./typica.w"
  8187. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  8188. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  8189. {
  8190. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  8191. QPointF(0,5);
  8192. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  8193. QPointF(10,5);
  8194. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  8195. QPointF(0,0);
  8196. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  8197. initialBrush.setColor(QColor(170,170,255));
  8198. initialBrush.setStyle(Qt::SolidPattern);
  8199. finalBrush.setColor(Qt::blue);
  8200. finalBrush.setStyle(Qt::SolidPattern);
  8201. initialDecrement.setPolygon(left);
  8202. initialDecrement.setBrush(initialBrush);
  8203. initialDecrement.setPos(0,0);
  8204. scene.addItem(&initialDecrement);
  8205. initialIncrement.setPolygon(right);
  8206. initialIncrement.setBrush(initialBrush);
  8207. initialIncrement.setPos(122,0);
  8208. scene.addItem(&initialIncrement);
  8209. finalDecrement.setPolygon(left);
  8210. finalDecrement.setBrush(finalBrush);
  8211. finalDecrement.setPos(0,12);
  8212. scene.addItem(&finalDecrement);
  8213. finalIncrement.setPolygon(right);
  8214. finalIncrement.setBrush(finalBrush);
  8215. finalIncrement.setPos(122,12);
  8216. scene.addItem(&finalIncrement);
  8217. scalePath.moveTo(0,10);
  8218. scalePath.lineTo(100,10);
  8219. scalePath.moveTo(0,0);
  8220. scalePath.lineTo(0,20);
  8221. scalePath.moveTo(10,5);
  8222. scalePath.lineTo(10,15);
  8223. scalePath.moveTo(20,5);
  8224. scalePath.lineTo(20,15);
  8225. scalePath.moveTo(30,5);
  8226. scalePath.lineTo(30,15);
  8227. scalePath.moveTo(40,5);
  8228. scalePath.lineTo(40,15);
  8229. scalePath.moveTo(50,0);
  8230. scalePath.lineTo(50,20);
  8231. scalePath.moveTo(60,5);
  8232. scalePath.lineTo(60,15);
  8233. scalePath.moveTo(70,5);
  8234. scalePath.lineTo(70,15);
  8235. scalePath.moveTo(80,5);
  8236. scalePath.lineTo(80,15);
  8237. scalePath.moveTo(90,5);
  8238. scalePath.lineTo(90,15);
  8239. scalePath.moveTo(100,0);
  8240. scalePath.lineTo(100,20);
  8241. scaleLine.setPath(scalePath);
  8242. scaleLine.setPos(16,1);
  8243. scene.addItem(&scaleLine);
  8244. setScene(&scene);
  8245. initialIndicator.setPolygon(down);
  8246. initialIndicator.setBrush(initialBrush);
  8247. finalIndicator.setPolygon(up);
  8248. finalIndicator.setBrush(finalBrush);
  8249. setMinimumSize(sizeHint());
  8250. setMaximumSize(sizeHint());
  8251. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8252. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8253. setMinimumSize(sizeHint());
  8254. }
  8255. /*:734*//*735:*/
  8256. #line 15109 "./typica.w"
  8257. QSize ScaleControl::sizeHint()const
  8258. {
  8259. return QSize(140,30);
  8260. }
  8261. /*:735*//*736:*/
  8262. #line 15118 "./typica.w"
  8263. void ScaleControl::setInitialValue(double value)
  8264. {
  8265. if(value>=0&&value<=10)
  8266. {
  8267. nonScoredValue= value;
  8268. if(!initialSet)
  8269. {
  8270. scene.addItem(&initialIndicator);
  8271. }
  8272. initialSet= true;
  8273. initialIndicator.setPos(value*10+16,10);
  8274. emit initialChanged(value);
  8275. if(!finalSet)
  8276. {
  8277. setFinalValue(value);
  8278. }
  8279. }
  8280. }
  8281. void ScaleControl::setFinalValue(double value)
  8282. {
  8283. if(value>=0&&value<=10)
  8284. {
  8285. scoredValue= value;
  8286. if(!finalSet)
  8287. {
  8288. scene.addItem(&finalIndicator);
  8289. }
  8290. finalSet= true;
  8291. finalIndicator.setPos(value*10+16,11);
  8292. emit finalChanged(value);
  8293. }
  8294. }
  8295. /*:736*//*737:*/
  8296. #line 15155 "./typica.w"
  8297. double ScaleControl::initialValue(void)
  8298. {
  8299. return nonScoredValue;
  8300. }
  8301. double ScaleControl::finalValue(void)
  8302. {
  8303. return scoredValue;
  8304. }
  8305. /*:737*//*738:*/
  8306. #line 15176 "./typica.w"
  8307. void ScaleControl::mousePressEvent(QMouseEvent*event)
  8308. {
  8309. /*739:*/
  8310. #line 15188 "./typica.w"
  8311. if(event->button()!=Qt::LeftButton)
  8312. {
  8313. event->ignore();
  8314. return;
  8315. }
  8316. /*:739*/
  8317. #line 15179 "./typica.w"
  8318. scaleDown= true;
  8319. event->accept();
  8320. }
  8321. /*:738*//*740:*/
  8322. #line 15199 "./typica.w"
  8323. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  8324. {
  8325. /*739:*/
  8326. #line 15188 "./typica.w"
  8327. if(event->button()!=Qt::LeftButton)
  8328. {
  8329. event->ignore();
  8330. return;
  8331. }
  8332. /*:739*/
  8333. #line 15202 "./typica.w"
  8334. if(!scaleDown)
  8335. {
  8336. event->ignore();
  8337. return;
  8338. }
  8339. scaleDown= false;
  8340. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8341. /*741:*/
  8342. #line 15224 "./typica.w"
  8343. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  8344. {
  8345. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8346. {
  8347. if(initialSet)
  8348. {
  8349. setInitialValue(nonScoredValue-0.05);
  8350. }
  8351. event->accept();
  8352. return;
  8353. }
  8354. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  8355. {
  8356. if(finalSet)
  8357. {
  8358. setFinalValue(scoredValue-0.05);
  8359. event->accept();
  8360. return;
  8361. }
  8362. }
  8363. }
  8364. /*:741*/
  8365. #line 15210 "./typica.w"
  8366. /*742:*/
  8367. #line 15250 "./typica.w"
  8368. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  8369. {
  8370. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8371. {
  8372. if(initialSet)
  8373. {
  8374. setInitialValue(nonScoredValue+0.05);
  8375. event->accept();
  8376. return;
  8377. }
  8378. }
  8379. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  8380. {
  8381. if(finalSet)
  8382. {
  8383. setFinalValue(scoredValue+0.05);
  8384. event->accept();
  8385. return;
  8386. }
  8387. }
  8388. }
  8389. /*:742*/
  8390. #line 15211 "./typica.w"
  8391. /*743:*/
  8392. #line 15276 "./typica.w"
  8393. double relativeX= sceneCoordinate.x()-16;
  8394. if(initialSet)
  8395. {
  8396. if(relativeX>=0&&relativeX<=100)
  8397. {
  8398. setFinalValue(relativeX/10.0);
  8399. event->accept();
  8400. return;
  8401. }
  8402. }
  8403. else
  8404. {
  8405. if(relativeX>=0&&relativeX<=100)
  8406. {
  8407. setInitialValue(relativeX/10.0);
  8408. event->accept();
  8409. return;
  8410. }
  8411. }
  8412. /*:743*/
  8413. #line 15212 "./typica.w"
  8414. event->ignore();
  8415. return;
  8416. }
  8417. /*:740*/
  8418. #line 573 "./typica.w"
  8419. /*745:*/
  8420. #line 15342 "./typica.w"
  8421. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  8422. valueSet(false),scaleDown(false)
  8423. {
  8424. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8425. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8426. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  8427. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  8428. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  8429. theBrush.setColor(Qt::blue);
  8430. theBrush.setStyle(Qt::SolidPattern);
  8431. increment.setPolygon(up);
  8432. increment.setBrush(theBrush);
  8433. increment.setPos(0,0);
  8434. scene.addItem(&increment);
  8435. decrement.setPolygon(down);
  8436. decrement.setBrush(theBrush);
  8437. decrement.setPos(0,122);
  8438. scene.addItem(&decrement);
  8439. scalePath.moveTo(5,0);
  8440. scalePath.lineTo(5,100);
  8441. scalePath.moveTo(0,0);
  8442. scalePath.lineTo(10,0);
  8443. scalePath.moveTo(0,10);
  8444. scalePath.lineTo(10,10);
  8445. scalePath.moveTo(0,20);
  8446. scalePath.lineTo(10,20);
  8447. scalePath.moveTo(0,30);
  8448. scalePath.lineTo(10,30);
  8449. scalePath.moveTo(0,40);
  8450. scalePath.lineTo(10,40);
  8451. scalePath.moveTo(0,50);
  8452. scalePath.lineTo(10,50);
  8453. scalePath.moveTo(0,60);
  8454. scalePath.lineTo(10,60);
  8455. scalePath.moveTo(0,70);
  8456. scalePath.lineTo(10,70);
  8457. scalePath.moveTo(0,80);
  8458. scalePath.lineTo(10,80);
  8459. scalePath.moveTo(0,90);
  8460. scalePath.lineTo(10,90);
  8461. scalePath.moveTo(0,100);
  8462. scalePath.lineTo(10,100);
  8463. scaleLine.setPath(scalePath);
  8464. scaleLine.setPos(0,16);
  8465. scene.addItem(&scaleLine);
  8466. setScene(&scene);
  8467. indicator.setPolygon(left);
  8468. indicator.setBrush(theBrush);
  8469. setMinimumSize(sizeHint());
  8470. setMaximumSize(sizeHint());
  8471. }
  8472. /*:745*//*746:*/
  8473. #line 15397 "./typica.w"
  8474. QSize IntensityControl::sizeHint()const
  8475. {
  8476. return QSize(25,160);
  8477. }
  8478. /*:746*//*747:*/
  8479. #line 15412 "./typica.w"
  8480. void IntensityControl::setValue(double val)
  8481. {
  8482. if(val>=0&&val<=10)
  8483. {
  8484. theValue= val;
  8485. if(!valueSet)
  8486. {
  8487. scene.addItem(&indicator);
  8488. }
  8489. valueSet= true;
  8490. indicator.setPos(6,(100-(val*10))+16);
  8491. emit(valueChanged(val));
  8492. }
  8493. else if(val<1)
  8494. {
  8495. setValue(0);
  8496. }
  8497. else
  8498. {
  8499. setValue(10);
  8500. }
  8501. }
  8502. double IntensityControl::value()
  8503. {
  8504. return theValue;
  8505. }
  8506. /*:747*//*748:*/
  8507. #line 15444 "./typica.w"
  8508. void IntensityControl::mousePressEvent(QMouseEvent*event)
  8509. {
  8510. /*739:*/
  8511. #line 15188 "./typica.w"
  8512. if(event->button()!=Qt::LeftButton)
  8513. {
  8514. event->ignore();
  8515. return;
  8516. }
  8517. /*:739*/
  8518. #line 15447 "./typica.w"
  8519. scaleDown= true;
  8520. event->accept();
  8521. }
  8522. /*:748*//*749:*/
  8523. #line 15458 "./typica.w"
  8524. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  8525. {
  8526. /*739:*/
  8527. #line 15188 "./typica.w"
  8528. if(event->button()!=Qt::LeftButton)
  8529. {
  8530. event->ignore();
  8531. return;
  8532. }
  8533. /*:739*/
  8534. #line 15461 "./typica.w"
  8535. if(!scaleDown)
  8536. {
  8537. event->ignore();
  8538. return;
  8539. }
  8540. scaleDown= false;
  8541. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8542. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  8543. {
  8544. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8545. {
  8546. if(valueSet)
  8547. {
  8548. setValue(theValue+0.05);
  8549. }
  8550. event->accept();
  8551. return;
  8552. }
  8553. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  8554. {
  8555. if(valueSet)
  8556. {
  8557. setValue(theValue-0.05);
  8558. }
  8559. event->accept();
  8560. return;
  8561. }
  8562. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  8563. {
  8564. setValue(10-((sceneCoordinate.y()-16)/10.0));
  8565. event->accept();
  8566. return;
  8567. }
  8568. }
  8569. }
  8570. /*:749*/
  8571. #line 574 "./typica.w"
  8572. /*377:*/
  8573. #line 8520 "./typica.w"
  8574. void ThresholdDetector::newMeasurement(Measurement measure)
  8575. {
  8576. if((currentDirection==Ascending&&previousValue<threshold&&
  8577. previousValueValid)||(currentDirection==Descending&&
  8578. previousValue> threshold&&previousValueValid))
  8579. {
  8580. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  8581. (currentDirection==Descending&&measure.temperature()<=threshold))
  8582. {
  8583. double offset= measure.time().hour()*60*60;
  8584. offset+= measure.time().minute()*60;
  8585. offset+= measure.time().second();
  8586. offset+= measure.time().msec()/1000;
  8587. emit timeForValue(offset);
  8588. }
  8589. }
  8590. previousValue= measure.temperature();
  8591. previousValueValid= true;
  8592. }
  8593. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  8594. previousValueValid(false),
  8595. previousValue(-1),threshold(value),currentDirection(Ascending)
  8596. {
  8597. }
  8598. void ThresholdDetector::setThreshold(double value)
  8599. {
  8600. threshold= value;
  8601. }
  8602. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  8603. {
  8604. currentDirection= direction;
  8605. }
  8606. /*:377*/
  8607. #line 575 "./typica.w"
  8608. /*831:*/
  8609. #line 17350 "./typica.w"
  8610. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  8611. lister(new QextSerialEnumerator)
  8612. {
  8613. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  8614. QextPortInfo port;
  8615. foreach(port,ports)
  8616. {
  8617. #ifdef Q_OS_WIN32
  8618. addItem(port.portName);
  8619. #else
  8620. addItem(port.physName);
  8621. #endif
  8622. }
  8623. lister->setUpNotifications();
  8624. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  8625. this,SLOT(addDevice(QextPortInfo)));
  8626. setEditable(true);
  8627. }
  8628. void PortSelector::addDevice(QextPortInfo port)
  8629. {
  8630. addItem(port.portName);
  8631. }
  8632. /*:831*/
  8633. #line 576 "./typica.w"
  8634. /*833:*/
  8635. #line 17442 "./typica.w"
  8636. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  8637. {
  8638. QMetaObject meta= BaudSelector::staticMetaObject;
  8639. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  8640. for(int i= 0;i<type.keyCount();i++)
  8641. {
  8642. addItem(QString("%1").arg(type.value(i)));
  8643. }
  8644. }
  8645. /*:833*/
  8646. #line 577 "./typica.w"
  8647. /*835:*/
  8648. #line 17480 "./typica.w"
  8649. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  8650. {
  8651. QMetaObject meta= ParitySelector::staticMetaObject;
  8652. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  8653. for(int i= 0;i<type.keyCount();i++)
  8654. {
  8655. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8656. }
  8657. }
  8658. /*:835*/
  8659. #line 578 "./typica.w"
  8660. /*837:*/
  8661. #line 17510 "./typica.w"
  8662. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  8663. {
  8664. QMetaObject meta= FlowSelector::staticMetaObject;
  8665. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  8666. for(int i= 0;i<type.keyCount();i++)
  8667. {
  8668. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8669. }
  8670. }
  8671. /*:837*/
  8672. #line 579 "./typica.w"
  8673. /*839:*/
  8674. #line 17545 "./typica.w"
  8675. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  8676. {
  8677. QMetaObject meta= StopSelector::staticMetaObject;
  8678. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  8679. for(int i= 0;i<type.keyCount();i++)
  8680. {
  8681. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8682. }
  8683. }
  8684. /*:839*/
  8685. #line 580 "./typica.w"
  8686. /*903:*/
  8687. #line 19326 "./typica.w"
  8688. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  8689. :BasicDeviceConfigurationWidget(model,index),
  8690. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  8691. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  8692. decimalQuery(new QCheckBox(tr("Enable"))),
  8693. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  8694. unitQuery(new QCheckBox(tr("Enable"))),
  8695. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  8696. valueC(new QSpinBox),fixedUnit(new QComboBox),
  8697. pVAddress(new ShortHexSpinBox),
  8698. sVEnabled(new QCheckBox(tr("Enable"))),
  8699. sVReadAddress(new ShortHexSpinBox),
  8700. deviceLimit(new QCheckBox(tr("Enable"))),
  8701. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8702. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8703. sVWritable(new QCheckBox(tr("Enable"))),
  8704. sVOutputAddr(new ShortHexSpinBox),
  8705. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8706. {
  8707. QHBoxLayout*layout= new QHBoxLayout;
  8708. QWidget*form= new QWidget;
  8709. QHBoxLayout*masterLayout= new QHBoxLayout;
  8710. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8711. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8712. QFormLayout*serialSection= new QFormLayout;
  8713. serialSection->addRow(QString(tr("Port:")),port);
  8714. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8715. serialSection->addRow(QString(tr("Parity:")),parity);
  8716. serialSection->addRow(QString(tr("Flow control:")),flow);
  8717. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8718. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8719. serialSectionBox->setLayout(serialSection);
  8720. portAndDeviceLayout->addWidget(serialSectionBox);
  8721. QFormLayout*deviceSection= new QFormLayout;
  8722. station->setMinimum(1);
  8723. station->setMaximum(255);
  8724. decimalPosition->setMinimum(0);
  8725. decimalPosition->setMaximum(9);
  8726. valueF->setMinimum(0);
  8727. valueF->setMaximum(0xFFFF);
  8728. valueC->setMinimum(0);
  8729. valueC->setMaximum(0xFFFF);
  8730. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8731. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8732. deviceSection->addRow(tr("Station:"),station);
  8733. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8734. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8735. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8736. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8737. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8738. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8739. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8740. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8741. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8742. deviceSectionBox->setLayout(deviceSection);
  8743. portAndDeviceLayout->addWidget(deviceSectionBox);
  8744. QFormLayout*pVSection= new QFormLayout;
  8745. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8746. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8747. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8748. pVSection->addRow(pVHideBox);
  8749. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8750. processValueBox->setLayout(pVSection);
  8751. seriesLayout->addWidget(processValueBox);
  8752. QFormLayout*sVSection= new QFormLayout;
  8753. sVLower->setDecimals(1);
  8754. sVLower->setMinimum(0.0);
  8755. sVLower->setMaximum(999.9);
  8756. sVUpper->setDecimals(1);
  8757. sVUpper->setMinimum(0.0);
  8758. sVUpper->setMaximum(999.9);
  8759. sVSection->addRow(tr("Set value:"),sVEnabled);
  8760. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8761. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8762. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8763. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8764. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8765. sVSection->addRow(tr("Lower limit:"),sVLower);
  8766. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8767. sVSection->addRow(tr("Output set value:"),sVWritable);
  8768. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8769. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8770. sVSection->addRow(sVHideBox);
  8771. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8772. setValueBox->setLayout(sVSection);
  8773. seriesLayout->addWidget(setValueBox);
  8774. masterLayout->addLayout(portAndDeviceLayout);
  8775. masterLayout->addLayout(seriesLayout);
  8776. form->setLayout(masterLayout);
  8777. /*807:*/
  8778. #line 16791 "./typica.w"
  8779. QDomElement referenceElement=
  8780. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8781. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8782. QDomElement node;
  8783. /*:807*/
  8784. #line 19416 "./typica.w"
  8785. for(int i= 0;i<configData.size();i++)
  8786. {
  8787. node= configData.at(i).toElement();
  8788. if(node.attribute("name")=="port")
  8789. {
  8790. QString portname= node.attribute("value");
  8791. int idx= port->findText(portname);
  8792. if(idx>=0)
  8793. {
  8794. port->setCurrentIndex(idx);
  8795. }
  8796. else
  8797. {
  8798. port->addItem(portname);
  8799. }
  8800. }
  8801. else if(node.attribute("name")=="baud")
  8802. {
  8803. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8804. }
  8805. else if(node.attribute("name")=="parity")
  8806. {
  8807. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8808. }
  8809. else if(node.attribute("name")=="flow")
  8810. {
  8811. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8812. }
  8813. else if(node.attribute("name")=="stop")
  8814. {
  8815. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8816. }
  8817. else if(node.attribute("name")=="station")
  8818. {
  8819. station->setValue(node.attribute("value").toInt());
  8820. }
  8821. else if(node.attribute("name")=="decimalQuery")
  8822. {
  8823. if(node.attribute("value")=="true")
  8824. {
  8825. decimalQuery->setChecked(true);
  8826. }
  8827. else
  8828. {
  8829. decimalQuery->setChecked(false);
  8830. }
  8831. }
  8832. else if(node.attribute("name")=="decimalAddress")
  8833. {
  8834. decimalAddress->setValue(node.attribute("value").toInt());
  8835. }
  8836. else if(node.attribute("name")=="decimalPosition")
  8837. {
  8838. decimalPosition->setValue(node.attribute("value").toInt());
  8839. }
  8840. else if(node.attribute("name")=="unitQuery")
  8841. {
  8842. if(node.attribute("value")=="true")
  8843. {
  8844. unitQuery->setChecked(true);
  8845. }
  8846. else
  8847. {
  8848. unitQuery->setChecked(false);
  8849. }
  8850. }
  8851. else if(node.attribute("name")=="unitAddress")
  8852. {
  8853. unitAddress->setValue(node.attribute("value").toInt());
  8854. }
  8855. else if(node.attribute("name")=="valueF")
  8856. {
  8857. valueF->setValue(node.attribute("value").toInt());
  8858. }
  8859. else if(node.attribute("name")=="valueC")
  8860. {
  8861. valueC->setValue(node.attribute("value").toInt());
  8862. }
  8863. else if(node.attribute("name")=="fixedUnit")
  8864. {
  8865. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8866. }
  8867. else if(node.attribute("name")=="pVAddress")
  8868. {
  8869. pVAddress->setValue(node.attribute("value").toInt());
  8870. }
  8871. else if(node.attribute("name")=="sVEnabled")
  8872. {
  8873. if(node.attribute("value")=="true")
  8874. {
  8875. sVEnabled->setChecked(true);
  8876. }
  8877. else
  8878. {
  8879. sVEnabled->setChecked(false);
  8880. }
  8881. }
  8882. else if(node.attribute("name")=="sVReadAddress")
  8883. {
  8884. sVReadAddress->setValue(node.attribute("value").toInt());
  8885. }
  8886. else if(node.attribute("name")=="deviceLimit")
  8887. {
  8888. if(node.attribute("value")=="true")
  8889. {
  8890. deviceLimit->setChecked(true);
  8891. }
  8892. else
  8893. {
  8894. deviceLimit->setChecked(false);
  8895. }
  8896. }
  8897. else if(node.attribute("name")=="sVLowerAddr")
  8898. {
  8899. sVLowerAddr->setValue(node.attribute("value").toInt());
  8900. }
  8901. else if(node.attribute("name")=="sVUpperAddr")
  8902. {
  8903. sVUpperAddr->setValue(node.attribute("value").toInt());
  8904. }
  8905. else if(node.attribute("name")=="sVLower")
  8906. {
  8907. sVLower->setValue(node.attribute("value").toDouble());
  8908. }
  8909. else if(node.attribute("name")=="sVUpper")
  8910. {
  8911. sVUpper->setValue(node.attribute("value").toDouble());
  8912. }
  8913. else if(node.attribute("name")=="sVWritable")
  8914. {
  8915. if(node.attribute("value")=="true")
  8916. {
  8917. sVWritable->setChecked(true);
  8918. }
  8919. else
  8920. {
  8921. sVWritable->setChecked(false);
  8922. }
  8923. }
  8924. else if(node.attribute("name")=="sVOutputAddr")
  8925. {
  8926. sVOutputAddr->setValue(node.attribute("value").toInt());
  8927. }
  8928. else if(node.attribute("name")=="pvcolname")
  8929. {
  8930. pVColumnName->setText(node.attribute("value"));
  8931. }
  8932. else if(node.attribute("name")=="svcolname")
  8933. {
  8934. sVColumnName->setText(node.attribute("value"));
  8935. }
  8936. else if(node.attribute("name")=="pvhidden")
  8937. {
  8938. pVHideBox->setChecked(node.attribute("value")=="true");
  8939. }
  8940. else if(node.attribute("name")=="svhidden")
  8941. {
  8942. sVHideBox->setChecked(node.attribute("value")=="true");
  8943. }
  8944. }
  8945. updatePort(port->currentText());
  8946. updateBaudRate(baud->currentText());
  8947. updateParity(parity->itemData(parity->currentIndex()).toString());
  8948. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8949. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8950. updateStation(station->value());
  8951. updateFixedDecimal(decimalQuery->isChecked());
  8952. updateDecimalAddress(decimalAddress->value());
  8953. updateDecimalPosition(decimalPosition->value());
  8954. updateFixedUnit(unitQuery->isChecked());
  8955. updateUnitAddress(unitAddress->value());
  8956. updateValueForF(valueF->value());
  8957. updateValueForC(valueC->value());
  8958. updateUnit(fixedUnit->currentText());
  8959. updatePVAddress(pVAddress->value());
  8960. updateSVEnabled(sVEnabled->isChecked());
  8961. updateSVReadAddress(sVReadAddress->value());
  8962. updateDeviceLimit(deviceLimit->isChecked());
  8963. updateSVLowerAddress(sVLowerAddr->value());
  8964. updateSVUpperAddress(sVUpperAddr->value());
  8965. updateSVLower(sVLower->value());
  8966. updateSVUpper(sVUpper->value());
  8967. updateSVWritable(sVWritable->isChecked());
  8968. updateSVWriteAddress(sVOutputAddr->value());
  8969. updatePVColumnName(pVColumnName->text());
  8970. updateSVColumnName(sVColumnName->text());
  8971. updatePVHidden(pVHideBox->isChecked());
  8972. updateSVHidden(sVHideBox->isChecked());
  8973. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8974. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8975. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8976. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8977. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8978. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8979. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8980. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8981. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8982. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8983. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8984. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8985. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8986. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8987. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8988. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8989. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8990. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8991. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8992. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8993. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8994. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8995. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8996. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8997. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8998. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8999. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  9000. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  9001. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  9002. layout->addWidget(form);
  9003. setLayout(layout);
  9004. }
  9005. void ModbusConfigurator::updatePort(const QString&newPort)
  9006. {
  9007. updateAttribute("port",newPort);
  9008. }
  9009. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  9010. {
  9011. updateAttribute("baud",newRate);
  9012. }
  9013. void ModbusConfigurator::updateParity(const QString&)
  9014. {
  9015. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  9016. }
  9017. void ModbusConfigurator::updateFlowControl(const QString&)
  9018. {
  9019. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  9020. }
  9021. void ModbusConfigurator::updateStopBits(const QString&)
  9022. {
  9023. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  9024. }
  9025. void ModbusConfigurator::updateStation(int station)
  9026. {
  9027. updateAttribute("station",QString("%1").arg(station));
  9028. }
  9029. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  9030. {
  9031. updateAttribute("decimalQuery",fixed?"true":"false");
  9032. }
  9033. void ModbusConfigurator::updateDecimalAddress(int address)
  9034. {
  9035. updateAttribute("decimalAddress",QString("%1").arg(address));
  9036. }
  9037. void ModbusConfigurator::updateDecimalPosition(int position)
  9038. {
  9039. updateAttribute("decimalPosition",QString("%1").arg(position));
  9040. }
  9041. void ModbusConfigurator::updateFixedUnit(bool fixed)
  9042. {
  9043. updateAttribute("unitQuery",fixed?"true":"false");
  9044. }
  9045. void ModbusConfigurator::updateUnitAddress(int address)
  9046. {
  9047. updateAttribute("unitAddress",QString("%1").arg(address));
  9048. }
  9049. void ModbusConfigurator::updateValueForF(int value)
  9050. {
  9051. updateAttribute("valueF",QString("%1").arg(value));
  9052. }
  9053. void ModbusConfigurator::updateValueForC(int value)
  9054. {
  9055. updateAttribute("valueC",QString("%1").arg(value));
  9056. }
  9057. void ModbusConfigurator::updateUnit(const QString&newUnit)
  9058. {
  9059. updateAttribute("fixedUnit",newUnit);
  9060. }
  9061. void ModbusConfigurator::updatePVAddress(int address)
  9062. {
  9063. updateAttribute("pVAddress",QString("%1").arg(address));
  9064. }
  9065. void ModbusConfigurator::updateSVEnabled(bool enabled)
  9066. {
  9067. updateAttribute("sVEnabled",enabled?"true":"false");
  9068. }
  9069. void ModbusConfigurator::updateSVReadAddress(int address)
  9070. {
  9071. updateAttribute("sVReadAddress",QString("%1").arg(address));
  9072. }
  9073. void ModbusConfigurator::updateDeviceLimit(bool query)
  9074. {
  9075. updateAttribute("deviceLimit",query?"true":"false");
  9076. }
  9077. void ModbusConfigurator::updateSVLowerAddress(int address)
  9078. {
  9079. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  9080. }
  9081. void ModbusConfigurator::updateSVUpperAddress(int address)
  9082. {
  9083. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  9084. }
  9085. void ModbusConfigurator::updateSVLower(double value)
  9086. {
  9087. updateAttribute("sVLower",QString("%1").arg(value));
  9088. }
  9089. void ModbusConfigurator::updateSVUpper(double value)
  9090. {
  9091. updateAttribute("sVUpper",QString("%1").arg(value));
  9092. }
  9093. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  9094. {
  9095. updateAttribute("sVWritable",canWriteSV?"true":"false");
  9096. }
  9097. void ModbusConfigurator::updateSVWriteAddress(int address)
  9098. {
  9099. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  9100. }
  9101. void ModbusConfigurator::updatePVColumnName(const QString&name)
  9102. {
  9103. updateAttribute("pvcolname",name);
  9104. }
  9105. void ModbusConfigurator::updateSVColumnName(const QString&name)
  9106. {
  9107. updateAttribute("svcolname",name);
  9108. }
  9109. void ModbusConfigurator::updatePVHidden(bool hidden)
  9110. {
  9111. updateAttribute("pvhidden",hidden?"true":"false");
  9112. }
  9113. void ModbusConfigurator::updateSVHidden(bool hidden)
  9114. {
  9115. updateAttribute("svhidden",hidden?"true":"false");
  9116. }
  9117. /*:903*/
  9118. #line 581 "./typica.w"
  9119. /*842:*/
  9120. #line 17598 "./typica.w"
  9121. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  9122. {
  9123. setMinimum(0);
  9124. setMaximum(0xFFFF);
  9125. setPrefix("0x");
  9126. setMinimumWidth(65);
  9127. }
  9128. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  9129. {
  9130. if(input.size()==2)
  9131. {
  9132. return QValidator::Intermediate;
  9133. }
  9134. bool okay;
  9135. input.toInt(&okay,16);
  9136. if(okay)
  9137. {
  9138. return QValidator::Acceptable;
  9139. }
  9140. return QValidator::Invalid;
  9141. }
  9142. int ShortHexSpinBox::valueFromText(const QString&text)const
  9143. {
  9144. return text.toInt(NULL,16);
  9145. }
  9146. QString ShortHexSpinBox::textFromValue(int value)const
  9147. {
  9148. QString retval;
  9149. retval.setNum(value,16);
  9150. while(retval.size()<4)
  9151. {
  9152. retval.prepend("0");
  9153. }
  9154. return retval.toUpper();
  9155. }
  9156. /*:842*/
  9157. #line 582 "./typica.w"
  9158. /*887:*/
  9159. #line 18630 "./typica.w"
  9160. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  9161. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  9162. waiting(false)
  9163. {
  9164. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  9165. Qt::UserRole).toString());
  9166. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  9167. QDomElement node;
  9168. QVariantMap attributes;
  9169. for(int i= 0;i<portConfigData.size();i++)
  9170. {
  9171. node= portConfigData.at(i).toElement();
  9172. attributes.insert(node.attribute("name"),node.attribute("value"));
  9173. }
  9174. port= new QextSerialPort(attributes.value("port").toString(),
  9175. QextSerialPort::EventDriven);
  9176. int baudRate= attributes.value("baud").toInt();
  9177. port->setBaudRate((BaudRateType)baudRate);
  9178. double temp= ((double)(1)/(double)(baudRate))*48;
  9179. delayTime= (int)(temp*3000);
  9180. messageDelayTimer->setSingleShot(true);
  9181. commTimeout->setSingleShot(true);
  9182. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  9183. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  9184. port->setDataBits(DATA_8);
  9185. port->setParity((ParityType)attributes.value("parity").toInt());
  9186. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  9187. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  9188. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  9189. port->open(QIODevice::ReadWrite);
  9190. station= (char)attributes.value("station").toInt();
  9191. if(attributes.value("decimalQuery")=="true")
  9192. {
  9193. decimalPosition= 0;
  9194. QByteArray message;
  9195. message.append(station);
  9196. message.append((char)0x03);
  9197. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  9198. char*addressBytes= (char*)&address;
  9199. message.append(addressBytes[1]);
  9200. message.append(addressBytes[0]);
  9201. message.append((char)0x00);
  9202. message.append((char)0x01);
  9203. queueMessage(message,this,"decimalResponse(QByteArray)");
  9204. }
  9205. else
  9206. {
  9207. decimalPosition= attributes.value("decimalPosition").toInt();
  9208. }
  9209. valueF= attributes.value("valueF").toInt();
  9210. valueC= attributes.value("valueC").toInt();
  9211. if(attributes.value("unitQuery")=="true")
  9212. {
  9213. QByteArray message;
  9214. message.append(station);
  9215. message.append((char)0x03);
  9216. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  9217. char*addressBytes= (char*)&address;
  9218. message.append(addressBytes[1]);
  9219. message.append(addressBytes[0]);
  9220. message.append((char)0x00);
  9221. message.append((char)0x01);
  9222. queueMessage(message,this,"unitResponse(QByteArray)");
  9223. }
  9224. else
  9225. {
  9226. if(attributes.value("fixedUnit")=="Celsius")
  9227. {
  9228. unitIsF= false;
  9229. }
  9230. }
  9231. if(attributes.value("sVWritable")=="true")
  9232. {
  9233. if(attributes.value("deviceLimit")=="true")
  9234. {
  9235. QByteArray lmessage;
  9236. lmessage.append(station);
  9237. lmessage.append((char)0x03);
  9238. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  9239. char*addressBytes= (char*)&laddress;
  9240. lmessage.append(addressBytes[1]);
  9241. lmessage.append(addressBytes[0]);
  9242. lmessage.append((char)0x00);
  9243. lmessage.append((char)0x01);
  9244. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  9245. QByteArray umessage;
  9246. umessage.append(station);
  9247. umessage.append((char)0x03);
  9248. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  9249. addressBytes= (char*)&uaddress;
  9250. umessage.append(addressBytes[1]);
  9251. umessage.append(addressBytes[0]);
  9252. umessage.append((char)0x00);
  9253. umessage.append((char)0x01);
  9254. queueMessage(umessage,this,"svuResponse(QByteArray)");
  9255. }
  9256. else
  9257. {
  9258. outputSVLower= attributes.value("sVLower").toDouble();
  9259. outputSVUpper= attributes.value("sVUpper").toDouble();
  9260. }
  9261. outputSVStub.append(station);
  9262. outputSVStub.append((char)0x06);
  9263. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  9264. char*addressBytes= (char*)&address;
  9265. outputSVStub.append(addressBytes[1]);
  9266. outputSVStub.append(addressBytes[0]);
  9267. }
  9268. Channel*pv= new Channel;
  9269. channels.append(pv);
  9270. pvStub.append(station);
  9271. pvStub.append((char)0x04);
  9272. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  9273. char*pvac= (char*)&pvaddress;
  9274. pvStub.append(pvac[1]);
  9275. pvStub.append(pvac[0]);
  9276. pvStub.append((char)0x00);
  9277. pvStub.append((char)0x01);
  9278. svenabled= attributes.value("sVEnabled").toBool();
  9279. if(svenabled)
  9280. {
  9281. Channel*sv= new Channel;
  9282. channels.append(sv);
  9283. svStub.append(station);
  9284. svStub.append((char)0x04);
  9285. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  9286. char*svac= (char*)&svaddress;
  9287. svStub.append(svac[1]);
  9288. svStub.append(svac[0]);
  9289. svStub.append((char)0x00);
  9290. svStub.append((char)0x01);
  9291. if(svaddress-pvaddress==1)
  9292. {
  9293. mStub.append(station);
  9294. mStub.append((char)0x04);
  9295. mStub.append(pvac[1]);
  9296. mStub.append(pvac[0]);
  9297. mStub.append((char)0x00);
  9298. mStub.append((char)0x02);
  9299. }
  9300. }
  9301. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  9302. requestMeasurement();
  9303. }
  9304. double ModbusRTUDevice::SVLower()
  9305. {
  9306. return outputSVLower;
  9307. }
  9308. double ModbusRTUDevice::SVUpper()
  9309. {
  9310. return outputSVUpper;
  9311. }
  9312. int ModbusRTUDevice::decimals()
  9313. {
  9314. return decimalPosition;
  9315. }
  9316. void ModbusRTUDevice::decimalResponse(QByteArray response)
  9317. {
  9318. quint16 temp;
  9319. char*tchar= (char*)&temp;
  9320. tchar[1]= response.at(3);
  9321. tchar[0]= response.at(4);
  9322. decimalPosition= temp;
  9323. emit SVDecimalChanged(decimalPosition);
  9324. }
  9325. void ModbusRTUDevice::unitResponse(QByteArray response)
  9326. {
  9327. quint16 temp;
  9328. char*tchar= (char*)&temp;
  9329. tchar[1]= response.at(3);
  9330. tchar[0]= response.at(4);
  9331. int value= temp;
  9332. if(value==valueF)
  9333. {
  9334. unitIsF= true;
  9335. }
  9336. else
  9337. {
  9338. unitIsF= false;
  9339. }
  9340. }
  9341. void ModbusRTUDevice::svlResponse(QByteArray response)
  9342. {
  9343. quint16 temp;
  9344. char*tchar= (char*)&temp;
  9345. tchar[1]= response.at(3);
  9346. tchar[0]= response.at(4);
  9347. outputSVLower= (double)temp;
  9348. for(int i= 0;i<decimalPosition;i++)
  9349. {
  9350. outputSVLower/= 10;
  9351. }
  9352. emit SVLowerChanged(outputSVLower);
  9353. }
  9354. void ModbusRTUDevice::svuResponse(QByteArray response)
  9355. {
  9356. quint16 temp;
  9357. char*tchar= (char*)&temp;
  9358. tchar[1]= response.at(3);
  9359. tchar[0]= response.at(4);
  9360. outputSVUpper= (double)temp;
  9361. for(int i= 0;i<decimalPosition;i++)
  9362. {
  9363. outputSVUpper/= 10;
  9364. }
  9365. emit SVUpperChanged(outputSVUpper);
  9366. }
  9367. void ModbusRTUDevice::requestMeasurement()
  9368. {
  9369. if(mStub.length()> 0)
  9370. {
  9371. queueMessage(mStub,this,"mResponse(QByteArray)");
  9372. }
  9373. else
  9374. {
  9375. queueMessage(pvStub,this,"mResponse(QByteArray)");
  9376. if(svenabled)
  9377. {
  9378. queueMessage(svStub,this,"mResponse(QByteArray)");
  9379. }
  9380. }
  9381. }
  9382. void ModbusRTUDevice::mResponse(QByteArray response)
  9383. {
  9384. QTime time= QTime::currentTime();
  9385. if(response.at(2)==0x04)
  9386. {
  9387. /*888:*/
  9388. #line 18880 "./typica.w"
  9389. quint16 pv;
  9390. quint16 sv;
  9391. char*pvBytes= (char*)&pv;
  9392. char*svBytes= (char*)&sv;
  9393. pvBytes[1]= response.at(3);
  9394. pvBytes[0]= response.at(4);
  9395. svBytes[1]= response.at(5);
  9396. svBytes[0]= response.at(6);
  9397. double pvOut= (double)pv;
  9398. double svOut= (double)sv;
  9399. for(int i= 0;i<decimalPosition;i++)
  9400. {
  9401. pvOut/= 10;
  9402. svOut/= 10;
  9403. }
  9404. if(!unitIsF)
  9405. {
  9406. pvOut= pvOut*9/5+32;
  9407. svOut= svOut*9/5+32;
  9408. }
  9409. Measurement pvm(pvOut,time,Units::Fahrenheit);
  9410. Measurement svm(svOut,time,Units::Fahrenheit);
  9411. channels.at(0)->input(pvm);
  9412. channels.at(1)->input(svm);
  9413. /*:888*/
  9414. #line 18867 "./typica.w"
  9415. }
  9416. else
  9417. {
  9418. /*889:*/
  9419. #line 18910 "./typica.w"
  9420. quint16 value;
  9421. char*valueBytes= (char*)&value;
  9422. valueBytes[1]= response.at(3);
  9423. valueBytes[0]= response.at(4);
  9424. double valueOut= (double)value;
  9425. for(int i= 0;i<decimalPosition;i++)
  9426. {
  9427. valueOut/= 10;
  9428. }
  9429. if(!unitIsF)
  9430. {
  9431. valueOut= valueOut*9/5+32;
  9432. }
  9433. if(!svenabled)
  9434. {
  9435. Measurement vm(valueOut,time,Units::Fahrenheit);
  9436. channels.at(0)->input(vm);
  9437. }
  9438. else
  9439. {
  9440. if(readingsv)
  9441. {
  9442. Measurement pvm(savedpv,time,Units::Fahrenheit);
  9443. Measurement svm(valueOut,time,Units::Fahrenheit);
  9444. channels.at(0)->input(pvm);
  9445. channels.at(1)->input(svm);
  9446. readingsv= false;
  9447. }
  9448. else
  9449. {
  9450. savedpv= valueOut;
  9451. readingsv= true;
  9452. }
  9453. }
  9454. /*:889*/
  9455. #line 18871 "./typica.w"
  9456. }
  9457. }
  9458. /*:887*//*890:*/
  9459. #line 18948 "./typica.w"
  9460. ModbusRTUDevice::~ModbusRTUDevice()
  9461. {
  9462. commTimeout->stop();
  9463. messageDelayTimer->stop();
  9464. port->close();
  9465. }
  9466. /*:890*//*891:*/
  9467. #line 18975 "./typica.w"
  9468. void ModbusRTUDevice::dataAvailable()
  9469. {
  9470. if(messageDelayTimer->isActive())
  9471. {
  9472. messageDelayTimer->stop();
  9473. }
  9474. responseBuffer.append(port->readAll());
  9475. /*892:*/
  9476. #line 19021 "./typica.w"
  9477. if(responseBuffer.size()<5)
  9478. {
  9479. return;
  9480. }
  9481. switch(responseBuffer.at(1))
  9482. {
  9483. case 0x01:
  9484. case 0x02:
  9485. if(responseBuffer.size()<6)
  9486. {
  9487. return;
  9488. }
  9489. responseBuffer= responseBuffer.left(6);
  9490. break;
  9491. case 0x03:
  9492. case 0x04:
  9493. if(responseBuffer.size()<5+responseBuffer.at(2))
  9494. {
  9495. return;
  9496. }
  9497. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  9498. break;
  9499. case 0x05:
  9500. case 0x06:
  9501. case 0x10:
  9502. if(responseBuffer.size()<8)
  9503. {
  9504. return;
  9505. }
  9506. responseBuffer= responseBuffer.left(8);
  9507. break;
  9508. }
  9509. /*:892*/
  9510. #line 18983 "./typica.w"
  9511. commTimeout->stop();
  9512. if(calculateCRC(responseBuffer)==0)
  9513. {
  9514. QObject*object= retObjQueue.at(0);
  9515. char*method= callbackQueue.at(0);
  9516. QMetaMethod metamethod= object->metaObject()->
  9517. method(object->metaObject()->
  9518. indexOfMethod(QMetaObject::normalizedSignature(method)));
  9519. metamethod.invoke(object,Qt::QueuedConnection,
  9520. Q_ARG(QByteArray,responseBuffer));
  9521. messageQueue.removeAt(0);
  9522. retObjQueue.removeAt(0);
  9523. callbackQueue.removeAt(0);
  9524. }
  9525. else
  9526. {
  9527. qDebug()<<"CRC failed";
  9528. }
  9529. messageDelayTimer->start(delayTime);
  9530. waiting= false;
  9531. responseBuffer.clear();
  9532. }
  9533. /*:891*//*893:*/
  9534. #line 19063 "./typica.w"
  9535. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  9536. {
  9537. quint16 retval= 0xFFFF;
  9538. int i= 0;
  9539. while(i<data.size())
  9540. {
  9541. retval^= 0x00FF&(quint16)data.at(i);
  9542. for(int j= 0;j<8;j++)
  9543. {
  9544. if(retval&1)
  9545. {
  9546. retval= (retval>>1)^0xA001;
  9547. }
  9548. else
  9549. {
  9550. retval>>= 1;
  9551. }
  9552. }
  9553. i++;
  9554. }
  9555. return retval;
  9556. }
  9557. /*:893*//*894:*/
  9558. #line 19094 "./typica.w"
  9559. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  9560. const char*callback)
  9561. {
  9562. messageQueue.append(request);
  9563. retObjQueue.append(object);
  9564. callbackQueue.append(const_cast<char*> (callback));
  9565. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  9566. {
  9567. sendNextMessage();
  9568. }
  9569. }
  9570. void ModbusRTUDevice::sendNextMessage()
  9571. {
  9572. if(messageQueue.size()> 0&&!waiting)
  9573. {
  9574. QByteArray message= messageQueue.at(0);
  9575. quint16 crc= calculateCRC(message);
  9576. char*check= (char*)&crc;
  9577. message.append(check[0]);
  9578. message.append(check[1]);
  9579. port->write(message);
  9580. commTimeout->start(2000);
  9581. messageDelayTimer->start(delayTime);
  9582. waiting= true;
  9583. }
  9584. else
  9585. {
  9586. emit queueEmpty();
  9587. }
  9588. }
  9589. void ModbusRTUDevice::outputSV(double value)
  9590. {
  9591. for(int i= 0;i<decimalPosition;i++)
  9592. {
  9593. value*= 10;
  9594. }
  9595. quint16 outval= (quint16)value;
  9596. QByteArray message(outputSVStub);
  9597. char*valBytes= (char*)&outval;
  9598. message.append(valBytes[1]);
  9599. message.append(valBytes[0]);
  9600. queueMessage(message,this,"ignore(QByteArray)");
  9601. }
  9602. /*:894*//*895:*/
  9603. #line 19143 "./typica.w"
  9604. void ModbusRTUDevice::ignore(QByteArray)
  9605. {
  9606. return;
  9607. }
  9608. /*:895*//*896:*/
  9609. #line 19156 "./typica.w"
  9610. void ModbusRTUDevice::timeout()
  9611. {
  9612. qDebug()<<"Communications timeout.";
  9613. responseBuffer.clear();
  9614. waiting= false;
  9615. messageDelayTimer->start();
  9616. }
  9617. /*:896*/
  9618. #line 583 "./typica.w"
  9619. /*761:*/
  9620. #line 15716 "./typica.w"
  9621. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  9622. DeviceTreeModelNode*parent)
  9623. :domNode(node),rowNumber(row),parentItem(parent)
  9624. {
  9625. }
  9626. DeviceTreeModelNode::~DeviceTreeModelNode()
  9627. {
  9628. QHash<int,DeviceTreeModelNode*> ::iterator i;
  9629. for(i= children.begin();i!=children.end();i++)
  9630. {
  9631. delete i.value();
  9632. }
  9633. }
  9634. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  9635. {
  9636. return parentItem;
  9637. }
  9638. int DeviceTreeModelNode::row()
  9639. {
  9640. return rowNumber;
  9641. }
  9642. QDomNode DeviceTreeModelNode::node()const
  9643. {
  9644. return domNode;
  9645. }
  9646. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  9647. {
  9648. if(children.contains(index))
  9649. {
  9650. return children[index];
  9651. }
  9652. if(index>=0&&index<domNode.childNodes().count())
  9653. {
  9654. QDomNode childNode= domNode.childNodes().item(index);
  9655. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  9656. index,this);
  9657. children[index]= childItem;
  9658. return childItem;
  9659. }
  9660. return NULL;
  9661. }
  9662. /*:761*/
  9663. #line 584 "./typica.w"
  9664. /*763:*/
  9665. #line 15805 "./typica.w"
  9666. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  9667. :QAbstractItemModel(parent)
  9668. {
  9669. document= AppInstance->deviceConfiguration();
  9670. QDomNodeList elements= document.elementsByTagName("devices");
  9671. if(elements.size()!=1)
  9672. {
  9673. qDebug()<<"Unexpected result when loading device map.";
  9674. }
  9675. treeRoot= elements.at(0);
  9676. root= new DeviceTreeModelNode(treeRoot,0);
  9677. elements= document.elementsByTagName("references");
  9678. if(elements.size()!=1)
  9679. {
  9680. qDebug()<<"No references section. Creating.";
  9681. referenceSection= document.createElement("references");
  9682. document.appendChild(referenceSection);
  9683. }
  9684. else
  9685. {
  9686. referenceSection= elements.at(0);
  9687. }
  9688. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  9689. AppInstance,SLOT(saveDeviceConfiguration()));
  9690. connect(this,SIGNAL(modelReset()),
  9691. AppInstance,SLOT(saveDeviceConfiguration()));
  9692. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9693. AppInstance,SLOT(saveDeviceConfiguration()));
  9694. }
  9695. /*:763*//*764:*/
  9696. #line 15840 "./typica.w"
  9697. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9698. {
  9699. return 1;
  9700. }
  9701. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9702. {
  9703. if(parent.column()> 0)
  9704. {
  9705. return 0;
  9706. }
  9707. /*765:*/
  9708. #line 15859 "./typica.w"
  9709. DeviceTreeModelNode*parentItem;
  9710. if(!parent.isValid())
  9711. {
  9712. parentItem= root;
  9713. }
  9714. else
  9715. {
  9716. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9717. }
  9718. /*:765*/
  9719. #line 15852 "./typica.w"
  9720. return parentItem->node().childNodes().count();
  9721. }
  9722. /*:764*//*766:*/
  9723. #line 15873 "./typica.w"
  9724. QModelIndex DeviceTreeModel::index(int row,int column,
  9725. const QModelIndex&parent)const
  9726. {
  9727. if(!hasIndex(row,column,parent))
  9728. {
  9729. return QModelIndex();
  9730. }
  9731. /*765:*/
  9732. #line 15859 "./typica.w"
  9733. DeviceTreeModelNode*parentItem;
  9734. if(!parent.isValid())
  9735. {
  9736. parentItem= root;
  9737. }
  9738. else
  9739. {
  9740. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9741. }
  9742. /*:765*/
  9743. #line 15881 "./typica.w"
  9744. DeviceTreeModelNode*childItem= parentItem->child(row);
  9745. if(childItem)
  9746. {
  9747. return createIndex(row,column,childItem);
  9748. }
  9749. return QModelIndex();
  9750. }
  9751. /*:766*//*767:*/
  9752. #line 15892 "./typica.w"
  9753. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9754. {
  9755. if(!child.isValid())
  9756. {
  9757. return QModelIndex();
  9758. }
  9759. DeviceTreeModelNode*childItem=
  9760. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9761. DeviceTreeModelNode*parentItem= childItem->parent();
  9762. if(!parentItem||parentItem==root)
  9763. {
  9764. return QModelIndex();
  9765. }
  9766. return createIndex(parentItem->row(),0,parentItem);
  9767. }
  9768. /*:767*//*768:*/
  9769. #line 15911 "./typica.w"
  9770. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9771. {
  9772. if(!index.isValid())
  9773. {
  9774. return 0;
  9775. }
  9776. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9777. }
  9778. /*:768*//*769:*/
  9779. #line 15926 "./typica.w"
  9780. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9781. {
  9782. if(!index.isValid())
  9783. {
  9784. return QVariant();
  9785. }
  9786. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9787. {
  9788. return QVariant();
  9789. }
  9790. DeviceTreeModelNode*item=
  9791. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9792. QDomNode node= item->node();
  9793. QDomElement element= node.toElement();
  9794. switch(role)
  9795. {
  9796. case Qt::DisplayRole:
  9797. case Qt::EditRole:
  9798. return QVariant(element.attribute("name"));
  9799. case Qt::UserRole:
  9800. return QVariant(element.attribute("reference"));
  9801. default:
  9802. return QVariant();
  9803. }
  9804. return QVariant();
  9805. }
  9806. /*:769*//*770:*/
  9807. #line 15958 "./typica.w"
  9808. bool DeviceTreeModel::setData(const QModelIndex&index,
  9809. const QVariant&value,int)
  9810. {
  9811. if(!index.isValid())
  9812. {
  9813. return false;
  9814. }
  9815. DeviceTreeModelNode*item=
  9816. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9817. QDomNode node= item->node();
  9818. QDomElement element= node.toElement();
  9819. element.setAttribute("name",value.toString());
  9820. emit dataChanged(index,index);
  9821. return true;
  9822. }
  9823. /*:770*//*771:*/
  9824. #line 15981 "./typica.w"
  9825. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9826. const QModelIndex&parent)
  9827. {
  9828. QString referenceID= QUuid::createUuid().toString();
  9829. /*765:*/
  9830. #line 15859 "./typica.w"
  9831. DeviceTreeModelNode*parentItem;
  9832. if(!parent.isValid())
  9833. {
  9834. parentItem= root;
  9835. }
  9836. else
  9837. {
  9838. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9839. }
  9840. /*:765*/
  9841. #line 15986 "./typica.w"
  9842. QDomNode parentNode= parentItem->node();
  9843. int newRowNumber= rowCount(parent);
  9844. beginInsertRows(parent,newRowNumber,newRowNumber);
  9845. QDomElement deviceElement= document.createElement("node");
  9846. deviceElement.setAttribute("name",name);
  9847. deviceElement.setAttribute("reference",referenceID);
  9848. parentNode.appendChild(deviceElement);
  9849. QDomElement referenceElement= document.createElement("reference");
  9850. referenceElement.setAttribute("id",referenceID);
  9851. referenceElement.setAttribute("driver",driver);
  9852. referenceSection.appendChild(referenceElement);
  9853. endInsertRows();
  9854. }
  9855. /*:771*//*772:*/
  9856. #line 16004 "./typica.w"
  9857. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9858. {
  9859. /*765:*/
  9860. #line 15859 "./typica.w"
  9861. DeviceTreeModelNode*parentItem;
  9862. if(!parent.isValid())
  9863. {
  9864. parentItem= root;
  9865. }
  9866. else
  9867. {
  9868. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9869. }
  9870. /*:765*/
  9871. #line 16007 "./typica.w"
  9872. QDomNode parentNode= parentItem->node();
  9873. QDomNodeList childNodes= parentNode.childNodes();
  9874. if(childNodes.size()<row+count)
  9875. {
  9876. return false;
  9877. }
  9878. beginRemoveRows(parent,row,row+count-1);
  9879. QList<QDomElement> removalList;
  9880. for(int i= row;i<row+count;i++)
  9881. {
  9882. removalList.append(childNodes.at(i).toElement());
  9883. }
  9884. QDomElement element;
  9885. QDomElement reference;
  9886. for(int i= 0;i<count;i++)
  9887. {
  9888. element= removalList.at(i);
  9889. if(element.hasAttribute("reference"))
  9890. {
  9891. reference= referenceElement(element.attribute("reference"));
  9892. if(!reference.isNull())
  9893. {
  9894. referenceSection.removeChild(reference);
  9895. }
  9896. }
  9897. parentNode.removeChild(element);
  9898. }
  9899. endRemoveRows();
  9900. beginResetModel();
  9901. delete root;
  9902. root= new DeviceTreeModelNode(treeRoot,0);
  9903. endResetModel();
  9904. return true;
  9905. }
  9906. /*:772*//*773:*/
  9907. #line 16046 "./typica.w"
  9908. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9909. {
  9910. QDomNodeList childNodes= referenceSection.childNodes();
  9911. QDomElement element;
  9912. for(int i= 0;i<childNodes.size();i++)
  9913. {
  9914. element= childNodes.at(i).toElement();
  9915. if(element.hasAttribute("id"))
  9916. {
  9917. if(element.attribute("id")==id)
  9918. {
  9919. return element;
  9920. }
  9921. }
  9922. }
  9923. return QDomElement();
  9924. }
  9925. /*:773*//*774:*/
  9926. #line 16067 "./typica.w"
  9927. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9928. {
  9929. return QVariant();
  9930. }
  9931. /*:774*//*775:*/
  9932. #line 16076 "./typica.w"
  9933. DeviceTreeModel::~DeviceTreeModel()
  9934. {
  9935. delete root;
  9936. }
  9937. /*:775*/
  9938. #line 585 "./typica.w"
  9939. /*802:*/
  9940. #line 16576 "./typica.w"
  9941. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9942. DeviceTreeModel*model,const QModelIndex&index)
  9943. :QWidget(NULL),deviceModel(model),currentNode(index)
  9944. {
  9945. }
  9946. /*:802*//*803:*/
  9947. #line 16588 "./typica.w"
  9948. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9949. const QString&value)
  9950. {
  9951. QDomElement referenceElement= deviceModel->referenceElement(
  9952. deviceModel->data(currentNode,Qt::UserRole).toString());
  9953. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9954. QDomElement node;
  9955. bool found= false;
  9956. for(int i= 0;i<configData.size();i++)
  9957. {
  9958. node= configData.at(i).toElement();
  9959. if(node.attribute("name")==name)
  9960. {
  9961. node.setAttribute("value",value);
  9962. found= true;
  9963. break;
  9964. }
  9965. }
  9966. if(!found)
  9967. {
  9968. node= AppInstance->deviceConfiguration().createElement("attribute");
  9969. node.setAttribute("name",name);
  9970. node.setAttribute("value",value);
  9971. referenceElement.appendChild(node);
  9972. }
  9973. AppInstance->saveDeviceConfiguration();
  9974. }
  9975. /*:803*//*804:*/
  9976. #line 16622 "./typica.w"
  9977. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9978. const QString&driver)
  9979. {
  9980. deviceModel->newNode(name,driver,currentNode);
  9981. }
  9982. /*:804*/
  9983. #line 586 "./typica.w"
  9984. /*793:*/
  9985. #line 16420 "./typica.w"
  9986. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9987. view(new QTreeView),configArea(new QScrollArea)
  9988. {
  9989. QSplitter*splitter= new QSplitter;
  9990. QWidget*leftWidget= new QWidget;
  9991. leftWidget->setMinimumWidth(200);
  9992. QVBoxLayout*left= new QVBoxLayout;
  9993. view->setAnimated(true);
  9994. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9995. document= AppInstance->deviceConfiguration();
  9996. model= new DeviceTreeModel;
  9997. view->setModel(model);
  9998. view->setTextElideMode(Qt::ElideNone);
  9999. view->expandAll();
  10000. view->resizeColumnToContents(0);
  10001. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  10002. QHBoxLayout*treeButtons= new QHBoxLayout;
  10003. QToolButton*addDeviceButton= new QToolButton;
  10004. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  10005. addDeviceButton->setToolTip(tr("New Roaster"));
  10006. connect(addDeviceButton,SIGNAL(clicked()),
  10007. this,SLOT(addDevice()));
  10008. QToolButton*removeNodeButton= new QToolButton;
  10009. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  10010. removeNodeButton->setToolTip(tr("Delete Selection"));
  10011. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  10012. treeButtons->addWidget(addDeviceButton);
  10013. treeButtons->addWidget(removeNodeButton);
  10014. left->addWidget(view);
  10015. left->addLayout(treeButtons);
  10016. leftWidget->setLayout(left);
  10017. splitter->addWidget(leftWidget);
  10018. configArea->setMinimumWidth(580);
  10019. configArea->setMinimumHeight(460);
  10020. configArea->setWidgetResizable(true);
  10021. splitter->addWidget(configArea);
  10022. QVBoxLayout*centralLayout= new QVBoxLayout;
  10023. centralLayout->addWidget(splitter);
  10024. setLayout(centralLayout);
  10025. connect(view,SIGNAL(activated(QModelIndex)),
  10026. this,SLOT(newSelection(QModelIndex)));
  10027. connect(view,SIGNAL(clicked(QModelIndex)),
  10028. this,SLOT(newSelection(QModelIndex)));
  10029. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  10030. view,SLOT(expand(QModelIndex)));
  10031. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  10032. this,SLOT(resizeColumn()));
  10033. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  10034. this,SLOT(resizeColumn()));
  10035. }
  10036. /*:793*//*794:*/
  10037. #line 16475 "./typica.w"
  10038. void DeviceConfigurationWindow::addDevice()
  10039. {
  10040. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  10041. }
  10042. /*:794*//*795:*/
  10043. #line 16483 "./typica.w"
  10044. void DeviceConfigurationWindow::removeNode()
  10045. {
  10046. QModelIndex index= view->currentIndex();
  10047. if(index.isValid())
  10048. {
  10049. int row= index.row();
  10050. QModelIndex parent= index.parent();
  10051. model->removeRow(row,parent);
  10052. }
  10053. }
  10054. /*:795*//*796:*/
  10055. #line 16499 "./typica.w"
  10056. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  10057. {
  10058. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  10059. if(editor)
  10060. {
  10061. configArea->setWidget(editor);
  10062. editor->show();
  10063. }
  10064. }
  10065. /*:796*//*797:*/
  10066. #line 16516 "./typica.w"
  10067. void DeviceConfigurationWindow::resizeColumn()
  10068. {
  10069. view->resizeColumnToContents(0);
  10070. }
  10071. /*:797*/
  10072. #line 587 "./typica.w"
  10073. /*817:*/
  10074. #line 16997 "./typica.w"
  10075. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  10076. const QModelIndex&index):
  10077. BasicDeviceConfigurationWidget(model,index)
  10078. {
  10079. QFormLayout*layout= new QFormLayout;
  10080. QLineEdit*columnName= new QLineEdit;
  10081. layout->addRow(tr("Column Name:"),columnName);
  10082. QComboBox*typeSelector= new QComboBox;
  10083. typeSelector->addItem("J");
  10084. typeSelector->addItem("K");
  10085. typeSelector->addItem("T");
  10086. typeSelector->addItem("B");
  10087. typeSelector->addItem("E");
  10088. typeSelector->addItem("N");
  10089. typeSelector->addItem("R");
  10090. typeSelector->addItem("S");
  10091. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10092. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  10093. layout->addRow(hideSeries);
  10094. setLayout(layout);
  10095. /*807:*/
  10096. #line 16791 "./typica.w"
  10097. QDomElement referenceElement=
  10098. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10099. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10100. QDomElement node;
  10101. /*:807*/
  10102. #line 17018 "./typica.w"
  10103. for(int i= 0;i<configData.size();i++)
  10104. {
  10105. node= configData.at(i).toElement();
  10106. if(node.attribute("name")=="type")
  10107. {
  10108. typeSelector->setCurrentIndex(
  10109. typeSelector->findText(node.attribute("value")));
  10110. }
  10111. else if(node.attribute("name")=="columnname")
  10112. {
  10113. columnName->setText(node.attribute("value"));
  10114. }
  10115. else if(node.attribute("name")=="hidden")
  10116. {
  10117. hideSeries->setChecked(node.attribute("value")=="true");
  10118. }
  10119. }
  10120. updateThermocoupleType(typeSelector->currentText());
  10121. updateColumnName(columnName->text());
  10122. updateHidden(hideSeries->isChecked());
  10123. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  10124. this,SLOT(updateThermocoupleType(QString)));
  10125. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10126. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10127. }
  10128. /*:817*//*818:*/
  10129. #line 17048 "./typica.w"
  10130. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  10131. {
  10132. updateAttribute("type",type);
  10133. }
  10134. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  10135. {
  10136. updateAttribute("columnname",name);
  10137. }
  10138. void Ni9211TcConfWidget::updateHidden(bool hidden)
  10139. {
  10140. updateAttribute("hidden",hidden?"true":"false");
  10141. }
  10142. /*:818*/
  10143. #line 588 "./typica.w"
  10144. /*813:*/
  10145. #line 16911 "./typica.w"
  10146. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  10147. const QModelIndex&index)
  10148. :BasicDeviceConfigurationWidget(model,index)
  10149. {
  10150. QVBoxLayout*layout= new QVBoxLayout;
  10151. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  10152. QLabel*label= new QLabel(tr("Device ID:"));
  10153. QLineEdit*deviceId= new QLineEdit;
  10154. deviceIdLayout->addWidget(label);
  10155. deviceIdLayout->addWidget(deviceId);
  10156. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10157. layout->addLayout(deviceIdLayout);
  10158. layout->addWidget(addChannelButton);
  10159. /*807:*/
  10160. #line 16791 "./typica.w"
  10161. QDomElement referenceElement=
  10162. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10163. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10164. QDomElement node;
  10165. /*:807*/
  10166. #line 16925 "./typica.w"
  10167. for(int i= 0;i<configData.size();i++)
  10168. {
  10169. node= configData.at(i).toElement();
  10170. if(node.attribute("name")=="deviceID")
  10171. {
  10172. deviceId->setText(node.attribute("value","Dev1"));
  10173. break;
  10174. }
  10175. }
  10176. updateDeviceId(deviceId->text());
  10177. connect(addChannelButton,SIGNAL(clicked()),
  10178. this,SLOT(addChannel()));
  10179. connect(deviceId,SIGNAL(textEdited(QString)),
  10180. this,SLOT(updateDeviceId(QString)));
  10181. setLayout(layout);
  10182. }
  10183. /*:813*//*814:*/
  10184. #line 16947 "./typica.w"
  10185. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  10186. {
  10187. updateAttribute("deviceID",newId);
  10188. }
  10189. /*:814*//*815:*/
  10190. #line 16955 "./typica.w"
  10191. void NiDaqMxBase9211ConfWidget::addChannel()
  10192. {
  10193. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10194. }
  10195. /*:815*/
  10196. #line 589 "./typica.w"
  10197. /*811:*/
  10198. #line 16862 "./typica.w"
  10199. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  10200. DeviceTreeModel*model,const QModelIndex&index):
  10201. BasicDeviceConfigurationWidget(model,index)
  10202. {
  10203. QHBoxLayout*layout= new QHBoxLayout;
  10204. QToolButton*addDeviceButton= new QToolButton;
  10205. addDeviceButton->setText(tr("Add Device"));
  10206. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  10207. "nidaqmxbase9211series");
  10208. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  10209. "nidaqmxbase9211series");
  10210. connect(add9211,SIGNAL(triggered(QString,QString)),
  10211. this,SLOT(insertChildNode(QString,QString)));
  10212. connect(add9211a,SIGNAL(triggered(QString,QString)),
  10213. this,SLOT(insertChildNode(QString,QString)));
  10214. QMenu*deviceMenu= new QMenu;
  10215. deviceMenu->addAction(add9211);
  10216. deviceMenu->addAction(add9211a);
  10217. addDeviceButton->setMenu(deviceMenu);
  10218. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10219. layout->addWidget(addDeviceButton);
  10220. setLayout(layout);
  10221. }
  10222. /*:811*/
  10223. #line 590 "./typica.w"
  10224. /*672:*/
  10225. #line 14334 "./typica.w"
  10226. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  10227. QObject*parent):
  10228. QAction(reportName,parent),reportFile(fileName)
  10229. {
  10230. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  10231. }
  10232. /*:672*//*673:*/
  10233. #line 14350 "./typica.w"
  10234. void ReportAction::createReport()
  10235. {
  10236. QFile file(reportFile);
  10237. QDomDocument document;
  10238. if(file.open(QIODevice::ReadOnly))
  10239. {
  10240. document.setContent(&file,true);
  10241. QDomElement element= document.documentElement();
  10242. QScriptEngine*engine= AppInstance->engine;
  10243. QScriptContext*context= engine->pushContext();
  10244. QScriptValue object;
  10245. QString targetID= reportFile;
  10246. /*202:*/
  10247. #line 4766 "./typica.w"
  10248. ScriptQMainWindow*window= new ScriptQMainWindow;
  10249. window->setObjectName(targetID);
  10250. object= engine->newQObject(window);
  10251. setQMainWindowProperties(object,engine);
  10252. QWidget*central= new(QWidget);
  10253. central->setParent(window);
  10254. central->setObjectName("centralWidget");
  10255. window->setCentralWidget(central);
  10256. if(element.hasChildNodes())
  10257. {
  10258. /*203:*/
  10259. #line 4802 "./typica.w"
  10260. QStack<QWidget*> widgetStack;
  10261. QStack<QLayout*> layoutStack;
  10262. QString windowScript;
  10263. widgetStack.push(central);
  10264. QDomNodeList windowChildren= element.childNodes();
  10265. int i= 0;
  10266. while(i<windowChildren.count())
  10267. {
  10268. QDomNode current;
  10269. QDomElement element;
  10270. current= windowChildren.at(i);
  10271. if(current.isElement())
  10272. {
  10273. element= current.toElement();
  10274. if(element.tagName()=="program")
  10275. {
  10276. windowScript.append(element.text());
  10277. }
  10278. else if(element.tagName()=="layout")
  10279. {
  10280. element.setAttribute("trcontext","configuration");
  10281. addLayoutToWidget(element,&widgetStack,&layoutStack);
  10282. }
  10283. else if(element.tagName()=="menu")
  10284. {
  10285. /*204:*/
  10286. #line 4850 "./typica.w"
  10287. QMenuBar*bar= window->menuBar();
  10288. bar->setParent(window);
  10289. bar->setObjectName("menuBar");
  10290. if(element.hasAttribute("name"))
  10291. {
  10292. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  10293. element.attribute("name").toUtf8().data()));
  10294. menu->setParent(bar);
  10295. if(element.hasAttribute("type"))
  10296. {
  10297. if(element.attribute("type")=="reports")
  10298. {
  10299. if(element.hasAttribute("src"))
  10300. {
  10301. /*670:*/
  10302. #line 14294 "./typica.w"
  10303. QSettings settings;
  10304. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  10305. toString()).
  10306. arg(element.attribute("src"));
  10307. QDir::addSearchPath("reports",reportDirectory);
  10308. QDir directory(reportDirectory);
  10309. directory.setFilter(QDir::Files);
  10310. directory.setSorting(QDir::Name);
  10311. QStringList nameFilter;
  10312. nameFilter<<"*.xml";
  10313. directory.setNameFilters(nameFilter);
  10314. QFileInfoList reportFiles= directory.entryInfoList();
  10315. for(int i= 0;i<reportFiles.size();i++)
  10316. {
  10317. QFileInfo reportFile= reportFiles.at(i);
  10318. /*674:*/
  10319. #line 14374 "./typica.w"
  10320. QString path= reportFile.absoluteFilePath();
  10321. QFile file(path);
  10322. if(file.open(QIODevice::ReadOnly))
  10323. {
  10324. QDomDocument document;
  10325. document.setContent(&file,true);
  10326. QDomElement root= document.documentElement();
  10327. QString translationContext= root.attribute("id");
  10328. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  10329. if(!titleNode.isNull())
  10330. {
  10331. QDomElement titleElement= titleNode.toElement();
  10332. QString title= QCoreApplication::translate("configuration",
  10333. titleElement.text().toUtf8().data());
  10334. if(!title.isEmpty())
  10335. {
  10336. QStringList hierarchy= title.split(":->");
  10337. QMenu*insertionPoint= menu;
  10338. /*675:*/
  10339. #line 14403 "./typica.w"
  10340. for(int j= 0;j<hierarchy.size()-1;j++)
  10341. {
  10342. QObjectList menuList= insertionPoint->children();
  10343. bool menuFound= false;
  10344. for(int k= 0;k<menuList.size();k++)
  10345. {
  10346. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  10347. if(currentItem)
  10348. {
  10349. if(currentItem->title()==hierarchy.at(j))
  10350. {
  10351. menuFound= true;
  10352. insertionPoint= currentItem;
  10353. break;
  10354. }
  10355. }
  10356. }
  10357. if(!menuFound)
  10358. {
  10359. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  10360. }
  10361. }
  10362. /*:675*/
  10363. #line 14393 "./typica.w"
  10364. ReportAction*action= new ReportAction(path,hierarchy.last());
  10365. insertionPoint->addAction(action);
  10366. }
  10367. }
  10368. }
  10369. /*:674*/
  10370. #line 14310 "./typica.w"
  10371. }
  10372. /*:670*/
  10373. #line 4865 "./typica.w"
  10374. }
  10375. }
  10376. }
  10377. if(element.hasChildNodes())
  10378. {
  10379. /*205:*/
  10380. #line 4878 "./typica.w"
  10381. QDomNodeList menuItems= element.childNodes();
  10382. int j= 0;
  10383. while(j<menuItems.count())
  10384. {
  10385. QDomNode item= menuItems.at(j);
  10386. if(item.isElement())
  10387. {
  10388. QDomElement itemElement= item.toElement();
  10389. if(itemElement.tagName()=="item")
  10390. {
  10391. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  10392. itemElement.text().toUtf8().data()),menu);
  10393. if(itemElement.hasAttribute("id"))
  10394. {
  10395. itemAction->setObjectName(itemElement.attribute("id"));
  10396. }
  10397. if(itemElement.hasAttribute("shortcut"))
  10398. {
  10399. itemAction->setShortcut(itemElement.attribute("shortcut"));
  10400. }
  10401. menu->addAction(itemAction);
  10402. }
  10403. else if(itemElement.tagName()=="separator")
  10404. {
  10405. menu->addSeparator();
  10406. }
  10407. else if(itemElement.tagName()=="plugins")
  10408. {
  10409. /*695:*/
  10410. #line 21 "./plugins.w"
  10411. QMenu*pluginMenu= new QMenu(menu);
  10412. if(itemElement.hasAttribute("id"))
  10413. {
  10414. pluginMenu->setObjectName(itemElement.attribute("id"));
  10415. }
  10416. if(itemElement.hasAttribute("title"))
  10417. {
  10418. pluginMenu->setTitle(itemElement.attribute("title"));
  10419. }
  10420. if(itemElement.hasAttribute("src"))
  10421. {
  10422. QSettings settings;
  10423. QString pluginDirectory= QString("%1/%2").
  10424. arg(settings.value("config").toString()).
  10425. arg(itemElement.attribute("src"));
  10426. QDir directory(pluginDirectory);
  10427. directory.setFilter(QDir::Files);
  10428. directory.setSorting(QDir::Name);
  10429. QStringList nameFilter;
  10430. nameFilter<<"*.js";
  10431. directory.setNameFilters(nameFilter);
  10432. QFileInfoList pluginFiles= directory.entryInfoList();
  10433. for(int k= 0;k<pluginFiles.size();k++)
  10434. {
  10435. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  10436. if(itemElement.hasAttribute("preRun"))
  10437. {
  10438. pa->setPreRun(itemElement.attribute("preRun"));
  10439. }
  10440. if(itemElement.hasAttribute("postRun"))
  10441. {
  10442. pa->setPostRun(itemElement.attribute("postRun"));
  10443. }
  10444. pluginMenu->addAction(pa);
  10445. }
  10446. }
  10447. menu->addMenu(pluginMenu);
  10448. /*:695*/
  10449. #line 4907 "./typica.w"
  10450. }
  10451. }
  10452. j++;
  10453. }
  10454. #line 1 "./helpmenu.w"
  10455. /*:205*/
  10456. #line 4871 "./typica.w"
  10457. }
  10458. }
  10459. /*:204*/
  10460. #line 4828 "./typica.w"
  10461. }
  10462. }
  10463. i++;
  10464. }
  10465. QScriptValue oldThis= context->thisObject();
  10466. context->setThisObject(object);
  10467. QScriptValue result= engine->evaluate(windowScript);
  10468. /*196:*/
  10469. #line 4581 "./typica.w"
  10470. if(engine->hasUncaughtException())
  10471. {
  10472. int line= engine->uncaughtExceptionLineNumber();
  10473. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  10474. result.toString();
  10475. QString trace;
  10476. foreach(trace,engine->uncaughtExceptionBacktrace())
  10477. {
  10478. qDebug()<<trace;
  10479. }
  10480. }
  10481. /*:196*/
  10482. #line 4836 "./typica.w"
  10483. context->setThisObject(oldThis);
  10484. /*:203*/
  10485. #line 4777 "./typica.w"
  10486. }
  10487. /*206:*/
  10488. #line 9 "./helpmenu.w"
  10489. HelpMenu*helpMenu= new HelpMenu();
  10490. window->menuBar()->addMenu(helpMenu);
  10491. /*:206*/
  10492. #line 4779 "./typica.w"
  10493. window->show();
  10494. window->setupFinished();
  10495. /*:202*/
  10496. #line 14363 "./typica.w"
  10497. file.close();
  10498. engine->popContext();
  10499. }
  10500. }
  10501. /*:673*/
  10502. #line 591 "./typica.w"
  10503. /*251:*/
  10504. #line 6063 "./typica.w"
  10505. NumericDelegate::NumericDelegate(QObject*parent):
  10506. QItemDelegate(parent)
  10507. {
  10508. }
  10509. /*:251*//*252:*/
  10510. #line 6075 "./typica.w"
  10511. void NumericDelegate::setEditorData(QWidget*editor,
  10512. const QModelIndex&index)const
  10513. {
  10514. QString value= index.model()->data(index,Qt::EditRole).toString();
  10515. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10516. line->setText(value);
  10517. }
  10518. /*:252*//*253:*/
  10519. #line 6090 "./typica.w"
  10520. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  10521. const QModelIndex&index)const
  10522. {
  10523. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10524. model->setData(index,line->text(),Qt::EditRole);
  10525. QScriptEngine*engine= AppInstance->engine;
  10526. engine->pushContext();
  10527. QString script= QString("Number(%1)").arg(line->text());
  10528. QScriptValue result= engine->evaluate(line->text());
  10529. if(result.isNumber())
  10530. {
  10531. model->setData(index,result.toVariant(),Qt::DisplayRole);
  10532. }
  10533. else
  10534. {
  10535. model->setData(index,QVariant(),Qt::DisplayRole);
  10536. }
  10537. engine->popContext();
  10538. }
  10539. /*:253*//*254:*/
  10540. #line 6113 "./typica.w"
  10541. QWidget*NumericDelegate::createEditor(QWidget*parent,
  10542. const QStyleOptionViewItem&,
  10543. const QModelIndex&)const
  10544. {
  10545. return(new QLineEdit(parent));
  10546. }
  10547. /*:254*//*255:*/
  10548. #line 6124 "./typica.w"
  10549. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  10550. const QStyleOptionViewItem&option,
  10551. const QModelIndex&)const
  10552. {
  10553. editor->setGeometry(option.rect);
  10554. }
  10555. /*:255*/
  10556. #line 592 "./typica.w"
  10557. /*822:*/
  10558. #line 17107 "./typica.w"
  10559. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  10560. const QModelIndex&index)
  10561. :BasicDeviceConfigurationWidget(model,index)
  10562. {
  10563. QHBoxLayout*layout= new QHBoxLayout;
  10564. QToolButton*addDeviceButton= new QToolButton;
  10565. addDeviceButton->setText(tr("Add Device"));
  10566. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  10567. "nidaqmx9211series");
  10568. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  10569. "nidaqmxtc01");
  10570. connect(add9211a,SIGNAL(triggered(QString,QString)),
  10571. this,SLOT(insertChildNode(QString,QString)));
  10572. connect(addtc01,SIGNAL(triggered(QString,QString)),
  10573. this,SLOT(insertChildNode(QString,QString)));
  10574. QMenu*deviceMenu= new QMenu;
  10575. deviceMenu->addAction(add9211a);
  10576. deviceMenu->addAction(addtc01);
  10577. addDeviceButton->setMenu(deviceMenu);
  10578. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10579. layout->addWidget(addDeviceButton);
  10580. setLayout(layout);
  10581. }
  10582. /*:822*/
  10583. #line 593 "./typica.w"
  10584. /*824:*/
  10585. #line 17156 "./typica.w"
  10586. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  10587. const QModelIndex&index)
  10588. :BasicDeviceConfigurationWidget(model,index)
  10589. {
  10590. QVBoxLayout*layout= new QVBoxLayout;
  10591. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  10592. QLabel*label= new QLabel(tr("Device ID:"));
  10593. QLineEdit*deviceId= new QLineEdit;
  10594. deviceIdLayout->addWidget(label);
  10595. deviceIdLayout->addWidget(deviceId);
  10596. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10597. layout->addLayout(deviceIdLayout);
  10598. layout->addWidget(addChannelButton);
  10599. /*807:*/
  10600. #line 16791 "./typica.w"
  10601. QDomElement referenceElement=
  10602. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10603. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10604. QDomElement node;
  10605. /*:807*/
  10606. #line 17170 "./typica.w"
  10607. for(int i= 0;i<configData.size();i++)
  10608. {
  10609. node= configData.at(i).toElement();
  10610. if(node.attribute("name")=="deviceID")
  10611. {
  10612. deviceId->setText(node.attribute("value","Dev1"));
  10613. break;
  10614. }
  10615. }
  10616. updateDeviceId(deviceId->text());
  10617. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  10618. connect(deviceId,SIGNAL(textEdited(QString)),
  10619. this,SLOT(updateDeviceId(QString)));
  10620. setLayout(layout);
  10621. }
  10622. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  10623. {
  10624. updateAttribute("deviceID",newId);
  10625. }
  10626. void NiDaqMx9211ConfWidget::addChannel()
  10627. {
  10628. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10629. }
  10630. /*:824*/
  10631. #line 594 "./typica.w"
  10632. /*826:*/
  10633. #line 17221 "./typica.w"
  10634. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  10635. const QModelIndex&index)
  10636. :BasicDeviceConfigurationWidget(model,index)
  10637. {
  10638. QFormLayout*layout= new QFormLayout;
  10639. QLineEdit*deviceId= new QLineEdit;
  10640. layout->addRow(tr("Device ID:"),deviceId);
  10641. QLineEdit*columnName= new QLineEdit;
  10642. layout->addRow(tr("Column Name:"),columnName);
  10643. QComboBox*typeSelector= new QComboBox;
  10644. typeSelector->addItem("J");
  10645. typeSelector->addItem("K");
  10646. typeSelector->addItem("T");
  10647. typeSelector->addItem("B");
  10648. typeSelector->addItem("E");
  10649. typeSelector->addItem("N");
  10650. typeSelector->addItem("R");
  10651. typeSelector->addItem("S");
  10652. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10653. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  10654. layout->addRow(hideSeries);
  10655. /*807:*/
  10656. #line 16791 "./typica.w"
  10657. QDomElement referenceElement=
  10658. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10659. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10660. QDomElement node;
  10661. /*:807*/
  10662. #line 17243 "./typica.w"
  10663. for(int i= 0;i<configData.size();i++)
  10664. {
  10665. node= configData.at(i).toElement();
  10666. if(node.attribute("name")=="deviceID")
  10667. {
  10668. deviceId->setText(node.attribute("value"));
  10669. }
  10670. else if(node.attribute("name")=="type")
  10671. {
  10672. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  10673. }
  10674. else if(node.attribute("name")=="columnname")
  10675. {
  10676. columnName->setText(node.attribute("value"));
  10677. }
  10678. else if(node.attribute("name")=="hidden")
  10679. {
  10680. hideSeries->setChecked(node.attribute("value")=="true");
  10681. }
  10682. }
  10683. updateDeviceId(deviceId->text());
  10684. updateThermocoupleType(typeSelector->currentText());
  10685. updateColumnName(columnName->text());
  10686. updateHidden(hideSeries->isChecked());
  10687. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  10688. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  10689. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10690. setLayout(layout);
  10691. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10692. }
  10693. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  10694. {
  10695. updateAttribute("deviceID",newId);
  10696. }
  10697. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  10698. {
  10699. updateAttribute("type",type);
  10700. }
  10701. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  10702. {
  10703. updateAttribute("columnname",name);
  10704. }
  10705. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  10706. {
  10707. updateAttribute("hidden",hidden?"true":"false");
  10708. }
  10709. /*:826*/
  10710. #line 595 "./typica.w"
  10711. /*844:*/
  10712. #line 17663 "./typica.w"
  10713. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  10714. const QModelIndex&index)
  10715. :BasicDeviceConfigurationWidget(model,index)
  10716. {
  10717. QFormLayout*layout= new QFormLayout;
  10718. QToolButton*addDeviceButton= new QToolButton;
  10719. addDeviceButton->setText(tr("Add Device"));
  10720. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  10721. "Modbus RTU Device",
  10722. "modbusrtudevice");
  10723. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  10724. this,SLOT(insertChildNode(QString,QString)));
  10725. QMenu*deviceMenu= new QMenu;
  10726. deviceMenu->addAction(addModbusRtuDevice);
  10727. addDeviceButton->setMenu(deviceMenu);
  10728. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10729. layout->addRow(QString(),addDeviceButton);
  10730. PortSelector*port= new PortSelector;
  10731. layout->addRow(tr("Port:"),port);
  10732. connect(port,SIGNAL(currentIndexChanged(QString)),
  10733. this,SLOT(updatePort(QString)));
  10734. connect(port,SIGNAL(editTextChanged(QString)),
  10735. this,SLOT(updatePort(QString)));
  10736. BaudSelector*rate= new BaudSelector;
  10737. layout->addRow(tr("Baud:"),rate);
  10738. connect(rate,SIGNAL(currentIndexChanged(QString)),
  10739. this,SLOT(updateBaudRate(QString)));
  10740. ParitySelector*parity= new ParitySelector;
  10741. layout->addRow(tr("Parity:"),parity);
  10742. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10743. this,SLOT(updateParity(QString)));
  10744. FlowSelector*flow= new FlowSelector;
  10745. layout->addRow(tr("Flow Control:"),flow);
  10746. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10747. this,SLOT(updateFlowControl(QString)));
  10748. StopSelector*stop= new StopSelector;
  10749. layout->addRow(tr("Stop Bits:"),stop);
  10750. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10751. this,SLOT(updateStopBits(QString)));
  10752. /*807:*/
  10753. #line 16791 "./typica.w"
  10754. QDomElement referenceElement=
  10755. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10756. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10757. QDomElement node;
  10758. /*:807*/
  10759. #line 17703 "./typica.w"
  10760. for(int i= 0;i<configData.size();i++)
  10761. {
  10762. node= configData.at(i).toElement();
  10763. if(node.attribute("name")=="port")
  10764. {
  10765. int j= port->findText(node.attribute("value"));
  10766. if(j>=0)
  10767. {
  10768. port->setCurrentIndex(j);
  10769. }
  10770. else
  10771. {
  10772. port->insertItem(0,node.attribute("value"));
  10773. port->setCurrentIndex(0);
  10774. }
  10775. }
  10776. else if(node.attribute("name")=="baudrate")
  10777. {
  10778. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10779. }
  10780. else if(node.attribute("name")=="parity")
  10781. {
  10782. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10783. }
  10784. else if(node.attribute("name")=="flowcontrol")
  10785. {
  10786. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10787. }
  10788. else if(node.attribute("name")=="stopbits")
  10789. {
  10790. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10791. }
  10792. }
  10793. updatePort(port->currentText());
  10794. updateBaudRate(rate->currentText());
  10795. updateParity(parity->currentText());
  10796. updateFlowControl(flow->currentText());
  10797. updateStopBits(stop->currentText());
  10798. setLayout(layout);
  10799. }
  10800. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10801. {
  10802. updateAttribute("port",newPort);
  10803. }
  10804. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10805. {
  10806. updateAttribute("baudrate",newRate);
  10807. }
  10808. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10809. {
  10810. updateAttribute("parity",newParity);
  10811. }
  10812. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10813. {
  10814. updateAttribute("flowcontrol",newFlow);
  10815. }
  10816. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10817. {
  10818. updateAttribute("stopbits",newStopBits);
  10819. }
  10820. /*:844*/
  10821. #line 596 "./typica.w"
  10822. /*846:*/
  10823. #line 17826 "./typica.w"
  10824. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10825. const QModelIndex&index)
  10826. :BasicDeviceConfigurationWidget(model,index),
  10827. unitSpecificationLayout(new QStackedLayout),
  10828. decimalSpecificationLayout(new QStackedLayout)
  10829. {
  10830. QVBoxLayout*layout= new QVBoxLayout;
  10831. QToolButton*addChannelButton= new QToolButton;
  10832. addChannelButton->setText(tr("Add Channel"));
  10833. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10834. "Temperature Process Value",
  10835. "modbustemperaturepv");
  10836. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10837. "Temperature Set Value",
  10838. "modbustemperaturesv");
  10839. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10840. this,SLOT(insertChildNode(QString,QString)));
  10841. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10842. this,SLOT(insertChildNode(QString,QString)));
  10843. QMenu*channelMenu= new QMenu;
  10844. channelMenu->addAction(addTemperaturePV);
  10845. channelMenu->addAction(addTemperatureSV);
  10846. addChannelButton->setMenu(channelMenu);
  10847. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10848. layout->addWidget(addChannelButton);
  10849. QHBoxLayout*stationLayout= new QHBoxLayout;
  10850. QLabel*stationLabel= new QLabel(tr("Station:"));
  10851. QSpinBox*stationNumber= new QSpinBox;
  10852. stationNumber->setMinimum(0);
  10853. stationNumber->setMaximum(255);
  10854. stationLayout->addWidget(stationLabel);
  10855. stationLayout->addWidget(stationNumber);
  10856. layout->addLayout(stationLayout);
  10857. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10858. layout->addWidget(fixedUnit);
  10859. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10860. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10861. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10862. QComboBox*fixedUnitSelector= new QComboBox;
  10863. fixedUnitSelector->addItem("Fahrenheit");
  10864. fixedUnitSelector->addItem("Celsius");
  10865. fixedUnitLayout->addWidget(fixedUnitLabel);
  10866. fixedUnitLayout->addWidget(fixedUnitSelector);
  10867. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10868. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10869. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10870. QFormLayout*queriedUnitLayout= new QFormLayout;
  10871. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10872. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10873. QSpinBox*valueF= new QSpinBox;
  10874. valueF->setMinimum(0);
  10875. valueF->setMaximum(65535);
  10876. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10877. QSpinBox*valueC= new QSpinBox;
  10878. valueC->setMinimum(0);
  10879. valueC->setMaximum(65535);
  10880. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10881. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10882. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10883. layout->addLayout(unitSpecificationLayout);
  10884. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10885. layout->addWidget(fixedPrecision);
  10886. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10887. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10888. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10889. fixedPrecisionValue->setMinimum(0);
  10890. fixedPrecisionValue->setMaximum(9);
  10891. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10892. fixedPrecisionValue);
  10893. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10894. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10895. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10896. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10897. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10898. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10899. precisionAddress);
  10900. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10901. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10902. layout->addLayout(decimalSpecificationLayout);
  10903. /*807:*/
  10904. #line 16791 "./typica.w"
  10905. QDomElement referenceElement=
  10906. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10907. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10908. QDomElement node;
  10909. /*:807*/
  10910. #line 17906 "./typica.w"
  10911. for(int i= 0;i<configData.size();i++)
  10912. {
  10913. node= configData.at(i).toElement();
  10914. if(node.attribute("name")=="station")
  10915. {
  10916. stationNumber->setValue(node.attribute("value").toInt());
  10917. }
  10918. else if(node.attribute("name")=="fixedunit")
  10919. {
  10920. if(node.attribute("value")=="true")
  10921. {
  10922. fixedUnit->setCheckState(Qt::Checked);
  10923. }
  10924. else if(node.attribute("value")=="false")
  10925. {
  10926. fixedUnit->setCheckState(Qt::Unchecked);
  10927. }
  10928. }
  10929. else if(node.attribute("name")=="fixedprecision")
  10930. {
  10931. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10932. }
  10933. else if(node.attribute("name")=="unit")
  10934. {
  10935. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10936. }
  10937. else if(node.attribute("name")=="unitaddress")
  10938. {
  10939. unitAddress->setValue(node.attribute("value").toInt());
  10940. }
  10941. else if(node.attribute("name")=="fvalue")
  10942. {
  10943. valueF->setValue(node.attribute("value").toInt());
  10944. }
  10945. else if(node.attribute("name")=="cvalue")
  10946. {
  10947. valueC->setValue(node.attribute("value").toInt());
  10948. }
  10949. else if(node.attribute("name")=="precisionaddress")
  10950. {
  10951. precisionAddress->setValue(node.attribute("value").toInt());
  10952. }
  10953. else if(node.attribute("name")=="precision")
  10954. {
  10955. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10956. }
  10957. }
  10958. updateStationNumber(stationNumber->value());
  10959. updateFixedUnit(fixedUnit->isChecked());
  10960. updateFixedDecimal(fixedPrecision->isChecked());
  10961. updateUnit(fixedUnitSelector->currentText());
  10962. updateUnitAddress(unitAddress->value());
  10963. updateValueF(valueF->value());
  10964. updateValueC(valueC->value());
  10965. updatePrecisionAddress(precisionAddress->value());
  10966. updatePrecisionValue(fixedPrecisionValue->value());
  10967. connect(stationNumber,SIGNAL(valueChanged(int)),
  10968. this,SLOT(updateStationNumber(int)));
  10969. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10970. this,SLOT(updateUnit(QString)));
  10971. connect(unitAddress,SIGNAL(valueChanged(int)),
  10972. this,SLOT(updateUnitAddress(int)));
  10973. connect(valueF,SIGNAL(valueChanged(int)),
  10974. this,SLOT(updateValueF(int)));
  10975. connect(valueC,SIGNAL(valueChanged(int)),
  10976. this,SLOT(updateValueC(int)));
  10977. connect(fixedUnit,SIGNAL(toggled(bool)),
  10978. this,SLOT(updateFixedUnit(bool)));
  10979. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10980. this,SLOT(updateFixedDecimal(bool)));
  10981. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10982. this,SLOT(updatePrecisionValue(int)));
  10983. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10984. this,SLOT(updatePrecisionAddress(int)));
  10985. setLayout(layout);
  10986. }
  10987. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10988. {
  10989. updateAttribute("station",QString("%1").arg(newStation));
  10990. }
  10991. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10992. {
  10993. if(newFixed)
  10994. {
  10995. unitSpecificationLayout->setCurrentIndex(0);
  10996. updateAttribute("fixedunit","true");
  10997. }
  10998. else
  10999. {
  11000. unitSpecificationLayout->setCurrentIndex(1);
  11001. updateAttribute("fixedunit","false");
  11002. }
  11003. }
  11004. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  11005. {
  11006. if(newFixed)
  11007. {
  11008. decimalSpecificationLayout->setCurrentIndex(0);
  11009. updateAttribute("fixedprecision","true");
  11010. }
  11011. else
  11012. {
  11013. decimalSpecificationLayout->setCurrentIndex(1);
  11014. updateAttribute("fixedprecision","false");
  11015. }
  11016. }
  11017. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  11018. {
  11019. updateAttribute("unit",newUnit);
  11020. }
  11021. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  11022. {
  11023. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  11024. }
  11025. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  11026. {
  11027. updateAttribute("fvalue",QString("%1").arg(newValue));
  11028. }
  11029. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  11030. {
  11031. updateAttribute("cvalue",QString("%1").arg(newValue));
  11032. }
  11033. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  11034. {
  11035. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  11036. }
  11037. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  11038. {
  11039. updateAttribute("precision",QString("%1").arg(newValue));
  11040. }
  11041. /*:846*/
  11042. #line 597 "./typica.w"
  11043. /*848:*/
  11044. #line 18069 "./typica.w"
  11045. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  11046. const QModelIndex&index)
  11047. :BasicDeviceConfigurationWidget(model,index)
  11048. {
  11049. QFormLayout*layout= new QFormLayout;
  11050. ShortHexSpinBox*address= new ShortHexSpinBox;
  11051. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  11052. /*807:*/
  11053. #line 16791 "./typica.w"
  11054. QDomElement referenceElement=
  11055. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11056. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11057. QDomElement node;
  11058. /*:807*/
  11059. #line 18077 "./typica.w"
  11060. for(int i= 0;i<configData.size();i++)
  11061. {
  11062. node= configData.at(i).toElement();
  11063. if(node.attribute("name")=="address")
  11064. {
  11065. address->setValue(node.attribute("value").toInt());
  11066. break;
  11067. }
  11068. }
  11069. updateAddress(address->value());
  11070. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  11071. setLayout(layout);
  11072. }
  11073. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  11074. {
  11075. updateAttribute("address",QString("%1").arg(newAddress));
  11076. }
  11077. /*:848*/
  11078. #line 598 "./typica.w"
  11079. /*850:*/
  11080. #line 18125 "./typica.w"
  11081. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  11082. const QModelIndex&index)
  11083. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  11084. {
  11085. QVBoxLayout*layout= new QVBoxLayout;
  11086. QFormLayout*addressLayout= new QFormLayout;
  11087. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  11088. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  11089. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  11090. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  11091. layout->addLayout(addressLayout);
  11092. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  11093. layout->addWidget(fixedRange);
  11094. QWidget*queriedRangePlaceholder= new QWidget(this);
  11095. QFormLayout*queriedRangeLayout= new QFormLayout;
  11096. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  11097. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  11098. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  11099. lowerAddress);
  11100. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  11101. upperAddress);
  11102. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  11103. boundsLayout->addWidget(queriedRangePlaceholder);
  11104. QWidget*fixedRangePlaceholder= new QWidget(this);
  11105. QFormLayout*fixedRangeLayout= new QFormLayout;
  11106. QLineEdit*fixedLower= new QLineEdit;
  11107. QLineEdit*fixedUpper= new QLineEdit;
  11108. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  11109. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  11110. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  11111. boundsLayout->addWidget(fixedRangePlaceholder);
  11112. layout->addLayout(boundsLayout);
  11113. /*807:*/
  11114. #line 16791 "./typica.w"
  11115. QDomElement referenceElement=
  11116. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11117. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11118. QDomElement node;
  11119. /*:807*/
  11120. #line 18158 "./typica.w"
  11121. for(int i= 0;i<configData.size();i++)
  11122. {
  11123. node= configData.at(i).toElement();
  11124. if(node.attribute("name")=="readaddress")
  11125. {
  11126. readAddress->setValue(node.attribute("value").toInt());
  11127. }
  11128. else if(node.attribute("name")=="writeaddress")
  11129. {
  11130. writeAddress->setValue(node.attribute("value").toInt());
  11131. }
  11132. else if(node.attribute("name")=="fixedrange")
  11133. {
  11134. if(node.attribute("value")=="true")
  11135. {
  11136. fixedRange->setCheckState(Qt::Checked);
  11137. }
  11138. else if(node.attribute("value")=="false")
  11139. {
  11140. fixedRange->setCheckState(Qt::Unchecked);
  11141. }
  11142. }
  11143. else if(node.attribute("name")=="fixedlower")
  11144. {
  11145. fixedLower->setText(node.attribute("value"));
  11146. }
  11147. else if(node.attribute("name")=="fixedupper")
  11148. {
  11149. fixedUpper->setText(node.attribute("value"));
  11150. }
  11151. else if(node.attribute("name")=="loweraddress")
  11152. {
  11153. lowerAddress->setValue(node.attribute("value").toInt());
  11154. }
  11155. else if(node.attribute("name")=="upperaddress")
  11156. {
  11157. upperAddress->setValue(node.attribute("value").toInt());
  11158. }
  11159. }
  11160. updateReadAddress(readAddress->value());
  11161. updateWriteAddress(writeAddress->value());
  11162. updateFixedRange(fixedRange->isChecked());
  11163. updateLower(fixedLower->text());
  11164. updateUpper(fixedUpper->text());
  11165. updateLowerAddress(lowerAddress->value());
  11166. updateUpperAddress(upperAddress->value());
  11167. connect(readAddress,SIGNAL(valueChanged(int)),
  11168. this,SLOT(updateReadAddress(int)));
  11169. connect(writeAddress,SIGNAL(valueChanged(int)),
  11170. this,SLOT(updateWriteAddress(int)));
  11171. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  11172. connect(fixedLower,SIGNAL(textChanged(QString)),
  11173. this,SLOT(updateLower(QString)));
  11174. connect(fixedUpper,SIGNAL(textChanged(QString)),
  11175. this,SLOT(updateUpper(QString)));
  11176. connect(lowerAddress,SIGNAL(valueChanged(int)),
  11177. this,SLOT(updateLowerAddress(int)));
  11178. connect(upperAddress,SIGNAL(valueChanged(int)),
  11179. this,SLOT(updateUpperAddress(int)));
  11180. setLayout(layout);
  11181. }
  11182. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  11183. {
  11184. updateAttribute("readaddress",QString("%1").arg(newAddress));
  11185. }
  11186. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  11187. {
  11188. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  11189. }
  11190. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  11191. {
  11192. if(fixed)
  11193. {
  11194. updateAttribute("fixedrange","true");
  11195. boundsLayout->setCurrentIndex(1);
  11196. }
  11197. else
  11198. {
  11199. updateAttribute("fixedrange","false");
  11200. boundsLayout->setCurrentIndex(0);
  11201. }
  11202. }
  11203. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  11204. {
  11205. updateAttribute("fixedlower",lower);
  11206. }
  11207. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  11208. {
  11209. updateAttribute("fixedupper",upper);
  11210. }
  11211. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  11212. {
  11213. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  11214. }
  11215. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  11216. {
  11217. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  11218. }
  11219. /*:850*/
  11220. #line 599 "./typica.w"
  11221. /*806:*/
  11222. #line 16661 "./typica.w"
  11223. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11224. :BasicDeviceConfigurationWidget(model,index)
  11225. {
  11226. QVBoxLayout*layout= new QVBoxLayout;
  11227. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  11228. QMenu*deviceMenu= new QMenu;
  11229. NodeInserter*insertAction;
  11230. foreach(insertAction,AppInstance->topLevelNodeInserters)
  11231. {
  11232. connect(insertAction,SIGNAL(triggered(QString,QString)),
  11233. this,SLOT(insertChildNode(QString,QString)));
  11234. deviceMenu->addAction(insertAction);
  11235. }
  11236. addDeviceButton->setMenu(deviceMenu);
  11237. layout->addWidget(addDeviceButton);
  11238. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  11239. QMenu*annotationMenu= new QMenu;
  11240. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  11241. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  11242. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  11243. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  11244. tr("Free Text"),
  11245. "freeannotation");
  11246. annotationMenu->addAction(basicButtonInserter);
  11247. annotationMenu->addAction(countingButtonInserter);
  11248. annotationMenu->addAction(spinBoxInserter);
  11249. annotationMenu->addAction(freeAnnotationInserter);
  11250. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  11251. this,SLOT(insertChildNode(QString,QString)));
  11252. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  11253. this,SLOT(insertChildNode(QString,QString)));
  11254. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  11255. this,SLOT(insertChildNode(QString,QString)));
  11256. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11257. this,SLOT(insertChildNode(QString,QString)));
  11258. /*1128:*/
  11259. #line 144 "./valueannotation.w"
  11260. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  11261. tr("Value Annotation"),
  11262. "valueannotation");
  11263. annotationMenu->addAction(valueAnnotationInserter);
  11264. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11265. this,SLOT(insertChildNode(QString,QString)));
  11266. /*:1128*//*1142:*/
  11267. #line 115 "./thresholdannotation.w"
  11268. NodeInserter*thresholdAnnotationInserter= new NodeInserter(tr("Threshold Annotation"),
  11269. tr("Threshold Annotation"),
  11270. "thresholdannotation");
  11271. annotationMenu->addAction(thresholdAnnotationInserter);
  11272. connect(thresholdAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11273. this,SLOT(insertChildNode(QString,QString)));
  11274. /*:1142*/
  11275. #line 16697 "./typica.w"
  11276. addAnnotationControlButton->setMenu(annotationMenu);
  11277. layout->addWidget(addAnnotationControlButton);
  11278. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  11279. QMenu*timersMenu= new QMenu;
  11280. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  11281. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  11282. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  11283. timersMenu->addAction(coolingTimerInserter);
  11284. timersMenu->addAction(rangeTimerInserter);
  11285. timersMenu->addAction(multirangeTimerInserter);
  11286. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  11287. this,SLOT(insertChildNode(QString,QString)));
  11288. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  11289. this,SLOT(insertChildNode(QString,QString)));
  11290. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  11291. this,SLOT(insertChildNode(QString,QString)));
  11292. timersButton->setMenu(timersMenu);
  11293. layout->addWidget(timersButton);
  11294. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  11295. QMenu*advancedMenu= new QMenu;
  11296. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  11297. advancedMenu->addAction(linearsplineinserter);
  11298. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  11299. advancedMenu->addAction(translationinserter);
  11300. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11301. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11302. /*1040:*/
  11303. #line 258 "./rate.w"
  11304. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  11305. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11306. advancedMenu->addAction(rateOfChangeInserter);
  11307. /*:1040*//*1054:*/
  11308. #line 272 "./mergeseries.w"
  11309. NodeInserter*mergeSeriesInserter= new NodeInserter(tr("Merge Series"),
  11310. tr("Merge"),
  11311. "mergeseries");
  11312. connect(mergeSeriesInserter,SIGNAL(triggered(QString,QString)),
  11313. this,SLOT(insertChildNode(QString,QString)));
  11314. advancedMenu->addAction(mergeSeriesInserter);
  11315. /*:1054*/
  11316. #line 16726 "./typica.w"
  11317. advancedButton->setMenu(advancedMenu);
  11318. layout->addWidget(advancedButton);
  11319. QHBoxLayout*idLayout= new QHBoxLayout;
  11320. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  11321. idLayout->addWidget(idLabel);
  11322. QSpinBox*id= new QSpinBox;
  11323. idLayout->addWidget(id);
  11324. idLayout->addStretch();
  11325. layout->addLayout(idLayout);
  11326. QHBoxLayout*capacityLayout= new QHBoxLayout;
  11327. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  11328. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  11329. capacity->setMinimum(0.0);
  11330. capacity->setDecimals(3);
  11331. capacity->setMaximum(999999.999);
  11332. QComboBox*capacityUnit= new QComboBox;
  11333. capacityUnit->addItem("g");
  11334. capacityUnit->addItem("Kg");
  11335. capacityUnit->addItem("oz");
  11336. capacityUnit->addItem("Lb");
  11337. capacityUnit->setCurrentIndex(3);
  11338. capacityLayout->addWidget(capacityCheckEnabled);
  11339. capacityLayout->addWidget(capacity);
  11340. capacityLayout->addWidget(capacityUnit);
  11341. capacityLayout->addStretch();
  11342. layout->addLayout(capacityLayout);
  11343. layout->addStretch();
  11344. /*807:*/
  11345. #line 16791 "./typica.w"
  11346. QDomElement referenceElement=
  11347. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11348. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11349. QDomElement node;
  11350. /*:807*/
  11351. #line 16755 "./typica.w"
  11352. for(int i= 0;i<configData.size();i++)
  11353. {
  11354. node= configData.at(i).toElement();
  11355. if(node.attribute("name")=="databaseid")
  11356. {
  11357. id->setValue(node.attribute("value").toInt());
  11358. }
  11359. else if(node.attribute("name")=="checkcapacity")
  11360. {
  11361. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  11362. }
  11363. else if(node.attribute("name")=="capacity")
  11364. {
  11365. capacity->setValue(node.attribute("value").toDouble());
  11366. }
  11367. else if(node.attribute("name")=="capacityunit")
  11368. {
  11369. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  11370. }
  11371. }
  11372. updateRoasterId(id->value());
  11373. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  11374. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  11375. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  11376. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  11377. setLayout(layout);
  11378. }
  11379. /*:806*//*808:*/
  11380. #line 16801 "./typica.w"
  11381. void RoasterConfWidget::updateRoasterId(int id)
  11382. {
  11383. updateAttribute("databaseid",QString("%1").arg(id));
  11384. }
  11385. void RoasterConfWidget::updateCapacityCheck(int value)
  11386. {
  11387. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  11388. }
  11389. void RoasterConfWidget::updateCapacity(const QString&value)
  11390. {
  11391. updateAttribute("capacity",value);
  11392. }
  11393. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  11394. {
  11395. updateAttribute("capacityunit",value);
  11396. }
  11397. /*:808*/
  11398. #line 600 "./typica.w"
  11399. /*854:*/
  11400. #line 18308 "./typica.w"
  11401. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11402. :BasicDeviceConfigurationWidget(model,index)
  11403. {
  11404. QFormLayout*layout= new QFormLayout;
  11405. QLineEdit*buttonTextEdit= new QLineEdit;
  11406. QLineEdit*annotationTextEdit= new QLineEdit;
  11407. layout->addRow(tr("Button Text:"),buttonTextEdit);
  11408. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  11409. /*807:*/
  11410. #line 16791 "./typica.w"
  11411. QDomElement referenceElement=
  11412. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11413. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11414. QDomElement node;
  11415. /*:807*/
  11416. #line 18317 "./typica.w"
  11417. for(int i= 0;i<configData.size();i++)
  11418. {
  11419. node= configData.at(i).toElement();
  11420. if(node.attribute("name")=="buttontext")
  11421. {
  11422. buttonTextEdit->setText(node.attribute("value"));
  11423. }
  11424. else if(node.attribute("name")=="annotationtext")
  11425. {
  11426. annotationTextEdit->setText(node.attribute("value"));
  11427. }
  11428. }
  11429. updateButtonText(buttonTextEdit->text());
  11430. updateAnnotationText(annotationTextEdit->text());
  11431. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  11432. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  11433. setLayout(layout);
  11434. }
  11435. /*:854*//*855:*/
  11436. #line 18339 "./typica.w"
  11437. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  11438. {
  11439. updateAttribute("buttontext",text);
  11440. }
  11441. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  11442. {
  11443. updateAttribute("annotationtext",text);
  11444. }
  11445. /*:855*//*858:*/
  11446. #line 18377 "./typica.w"
  11447. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11448. :BasicDeviceConfigurationWidget(model,index)
  11449. {
  11450. QFormLayout*layout= new QFormLayout;
  11451. QLineEdit*buttonTextEdit= new QLineEdit;
  11452. QLineEdit*annotationTextEdit= new QLineEdit;
  11453. layout->addRow(tr("Button Text:"),buttonTextEdit);
  11454. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  11455. /*807:*/
  11456. #line 16791 "./typica.w"
  11457. QDomElement referenceElement=
  11458. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11459. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11460. QDomElement node;
  11461. /*:807*/
  11462. #line 18386 "./typica.w"
  11463. for(int i= 0;i<configData.size();i++)
  11464. {
  11465. node= configData.at(i).toElement();
  11466. if(node.attribute("name")=="buttontext")
  11467. {
  11468. buttonTextEdit->setText(node.attribute("value"));
  11469. }
  11470. else if(node.attribute("name")=="annotationtext")
  11471. {
  11472. annotationTextEdit->setText(node.attribute("value"));
  11473. }
  11474. }
  11475. updateButtonText(buttonTextEdit->text());
  11476. updateAnnotationText(annotationTextEdit->text());
  11477. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  11478. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  11479. QTextEdit*documentation= new QTextEdit;
  11480. 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."));
  11481. documentation->setReadOnly(true);
  11482. layout->addRow("",documentation);
  11483. setLayout(layout);
  11484. }
  11485. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  11486. {
  11487. updateAttribute("buttontext",text);
  11488. }
  11489. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  11490. {
  11491. updateAttribute("annotationtext",text);
  11492. }
  11493. /*:858*/
  11494. #line 601 "./typica.w"
  11495. /*861:*/
  11496. #line 18454 "./typica.w"
  11497. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11498. :BasicDeviceConfigurationWidget(model,index)
  11499. {
  11500. QFormLayout*layout= new QFormLayout;
  11501. QLineEdit*labelEdit= new QLineEdit;
  11502. layout->addRow(tr("Control Label: "),labelEdit);
  11503. QLineEdit*minimumEdit= new QLineEdit;
  11504. layout->addRow(tr("Minimum Value: "),minimumEdit);
  11505. QLineEdit*maximumEdit= new QLineEdit;
  11506. layout->addRow(tr("Maximum Value: "),maximumEdit);
  11507. QSpinBox*precisionEdit= new QSpinBox;
  11508. precisionEdit->setMinimum(0);
  11509. precisionEdit->setMaximum(9);
  11510. layout->addRow(tr("Precision"),precisionEdit);
  11511. QLineEdit*pretext= new QLineEdit;
  11512. layout->addRow(tr("Prefix text"),pretext);
  11513. QLineEdit*posttext= new QLineEdit;
  11514. layout->addRow(tr("Suffix text"),posttext);
  11515. /*807:*/
  11516. #line 16791 "./typica.w"
  11517. QDomElement referenceElement=
  11518. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11519. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11520. QDomElement node;
  11521. /*:807*/
  11522. #line 18473 "./typica.w"
  11523. for(int i= 0;i<configData.size();i++)
  11524. {
  11525. node= configData.at(i).toElement();
  11526. if(node.attribute("name")=="label")
  11527. {
  11528. labelEdit->setText(node.attribute("value"));
  11529. }
  11530. else if(node.attribute("name")=="minimum")
  11531. {
  11532. minimumEdit->setText(node.attribute("value"));
  11533. }
  11534. else if(node.attribute("name")=="maximum")
  11535. {
  11536. maximumEdit->setText(node.attribute("value"));
  11537. }
  11538. else if(node.attribute("name")=="precision")
  11539. {
  11540. precisionEdit->setValue(node.attribute("value").toInt());
  11541. }
  11542. else if(node.attribute("name")=="pretext")
  11543. {
  11544. pretext->setText(node.attribute("value"));
  11545. }
  11546. else if(node.attribute("name")=="posttext")
  11547. {
  11548. posttext->setText(node.attribute("value"));
  11549. }
  11550. }
  11551. updateLabel(labelEdit->text());
  11552. updateMinimum(minimumEdit->text());
  11553. updateMaximum(maximumEdit->text());
  11554. updatePrecision(precisionEdit->value());
  11555. updatePretext(pretext->text());
  11556. updatePosttext(posttext->text());
  11557. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  11558. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  11559. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  11560. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  11561. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  11562. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  11563. setLayout(layout);
  11564. }
  11565. void NoteSpinConfWidget::updateLabel(const QString&text)
  11566. {
  11567. updateAttribute("label",text);
  11568. }
  11569. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  11570. {
  11571. updateAttribute("minimum",minimum);
  11572. }
  11573. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  11574. {
  11575. updateAttribute("maximum",maximum);
  11576. }
  11577. void NoteSpinConfWidget::updatePrecision(int precision)
  11578. {
  11579. updateAttribute("precision",QString("%1").arg(precision));
  11580. }
  11581. void NoteSpinConfWidget::updatePretext(const QString&text)
  11582. {
  11583. updateAttribute("pretext",text);
  11584. }
  11585. void NoteSpinConfWidget::updatePosttext(const QString&text)
  11586. {
  11587. updateAttribute("posttext",text);
  11588. }
  11589. /*:861*/
  11590. #line 602 "./typica.w"
  11591. /*347:*/
  11592. #line 7828 "./typica.w"
  11593. LinearCalibrator::LinearCalibrator(QObject*parent):
  11594. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  11595. {
  11596. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11597. }
  11598. /*:347*//*348:*/
  11599. #line 7842 "./typica.w"
  11600. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  11601. {
  11602. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  11603. if(clamp)
  11604. {
  11605. if(outval<Lo1)
  11606. {
  11607. outval= Lo1;
  11608. }
  11609. else if(outval> Up1)
  11610. {
  11611. outval= Up1;
  11612. }
  11613. }
  11614. if(sensitivitySetting>=0.05)
  11615. {
  11616. int temp= qRound(outval/sensitivitySetting);
  11617. outval= temp*sensitivitySetting;
  11618. }
  11619. Measurement adjusted(outval,measure.time(),measure.scale());
  11620. emit measurement(adjusted);
  11621. return adjusted;
  11622. }
  11623. /*:348*//*349:*/
  11624. #line 7869 "./typica.w"
  11625. double LinearCalibrator::measuredLower()
  11626. {
  11627. return Lo2;
  11628. }
  11629. double LinearCalibrator::measuredUpper()
  11630. {
  11631. return Up2;
  11632. }
  11633. double LinearCalibrator::mappedLower()
  11634. {
  11635. return Lo1;
  11636. }
  11637. double LinearCalibrator::mappedUpper()
  11638. {
  11639. return Up1;
  11640. }
  11641. bool LinearCalibrator::isClosedRange()
  11642. {
  11643. return clamp;
  11644. }
  11645. void LinearCalibrator::setMeasuredLower(double lower)
  11646. {
  11647. Lo2= lower;
  11648. }
  11649. void LinearCalibrator::setMeasuredUpper(double upper)
  11650. {
  11651. Up2= upper;
  11652. }
  11653. void LinearCalibrator::setMappedLower(double lower)
  11654. {
  11655. Lo1= lower;
  11656. }
  11657. void LinearCalibrator::setMappedUpper(double upper)
  11658. {
  11659. Up1= upper;
  11660. }
  11661. void LinearCalibrator::setClosedRange(bool closed)
  11662. {
  11663. clamp= closed;
  11664. }
  11665. void LinearCalibrator::setSensitivity(double sensitivity)
  11666. {
  11667. sensitivitySetting= sensitivity;
  11668. }
  11669. double LinearCalibrator::sensitivity()
  11670. {
  11671. return sensitivitySetting;
  11672. }
  11673. /*:349*/
  11674. #line 603 "./typica.w"
  11675. /*354:*/
  11676. #line 8002 "./typica.w"
  11677. void LinearSplineInterpolator::add_pair(double source,double destination)
  11678. {
  11679. pairs->insert(source,destination);
  11680. make_interpolators();
  11681. }
  11682. void LinearSplineInterpolator::make_interpolators()
  11683. {
  11684. if(pairs->size()> 1)
  11685. {
  11686. while(interpolators->size()> 0)
  11687. {
  11688. LinearCalibrator*removed= interpolators->takeFirst();
  11689. removed->deleteLater();
  11690. }
  11691. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11692. QMap<double,double> ::const_iterator j= i+1;
  11693. while(j!=pairs->constEnd())
  11694. {
  11695. LinearCalibrator*segment= new LinearCalibrator();
  11696. segment->setMeasuredLower(i.key());
  11697. segment->setMappedLower(i.value());
  11698. segment->setMeasuredUpper(j.key());
  11699. segment->setMappedUpper(j.value());
  11700. segment->setClosedRange(false);
  11701. interpolators->append(segment);
  11702. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11703. i++;
  11704. j++;
  11705. }
  11706. }
  11707. }
  11708. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  11709. QObject(parent),pairs(new QMap<double,double> ),
  11710. interpolators(new QList<LinearCalibrator*> )
  11711. {
  11712. }
  11713. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  11714. {
  11715. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11716. int index= -1;
  11717. while(i!=pairs->constEnd())
  11718. {
  11719. if(measure.temperature()<=i.key())
  11720. {
  11721. break;
  11722. }
  11723. i++;
  11724. index++;
  11725. }
  11726. if(index<0)
  11727. {
  11728. index= 0;
  11729. }
  11730. if(index>=interpolators->size())
  11731. {
  11732. index= interpolators->size()-1;
  11733. }
  11734. if(interpolators->at(index)!=NULL)
  11735. {
  11736. return interpolators->at(index)->newMeasurement(measure);
  11737. }
  11738. return Measurement();
  11739. }
  11740. /*:354*/
  11741. #line 604 "./typica.w"
  11742. /*1005:*/
  11743. #line 19821 "./typica.w"
  11744. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11745. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  11746. {
  11747. QFormLayout*layout= new QFormLayout;
  11748. QLineEdit*source= new QLineEdit;
  11749. layout->addRow(tr("Source column name:"),source);
  11750. QLineEdit*destination= new QLineEdit;
  11751. layout->addRow(tr("Destination column name:"),destination);
  11752. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  11753. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  11754. QTableView*mappingTable= new QTableView;
  11755. mappingTable->setModel(tablemodel);
  11756. NumericDelegate*delegate= new NumericDelegate;
  11757. mappingTable->setItemDelegate(delegate);
  11758. layout->addRow(tr("Mapping data:"),mappingTable);
  11759. /*807:*/
  11760. #line 16791 "./typica.w"
  11761. QDomElement referenceElement=
  11762. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11763. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11764. QDomElement node;
  11765. /*:807*/
  11766. #line 19837 "./typica.w"
  11767. for(int i= 0;i<configData.size();i++)
  11768. {
  11769. node= configData.at(i).toElement();
  11770. if(node.attribute("name")=="source")
  11771. {
  11772. source->setText(node.attribute("value"));
  11773. }
  11774. else if(node.attribute("name")=="destination")
  11775. {
  11776. destination->setText(node.attribute("value"));
  11777. }
  11778. else if(node.attribute("name")=="sourcevalues")
  11779. {
  11780. /*1006:*/
  11781. #line 19876 "./typica.w"
  11782. QString data= node.attribute("value");
  11783. if(data.length()> 3)
  11784. {
  11785. data.chop(2);
  11786. data= data.remove(0,2);
  11787. }
  11788. QStringList itemList= data.split(",");
  11789. /*:1006*/
  11790. #line 19851 "./typica.w"
  11791. int column= 0;
  11792. /*1007:*/
  11793. #line 19888 "./typica.w"
  11794. for(int j= 0;j<itemList.size();j++)
  11795. {
  11796. tablemodel->setData(tablemodel->index(j,column),
  11797. QVariant(itemList.at(j).toDouble()),
  11798. Qt::DisplayRole);
  11799. }
  11800. /*:1007*/
  11801. #line 19853 "./typica.w"
  11802. }
  11803. else if(node.attribute("name")=="destinationvalues")
  11804. {
  11805. /*1006:*/
  11806. #line 19876 "./typica.w"
  11807. QString data= node.attribute("value");
  11808. if(data.length()> 3)
  11809. {
  11810. data.chop(2);
  11811. data= data.remove(0,2);
  11812. }
  11813. QStringList itemList= data.split(",");
  11814. /*:1006*/
  11815. #line 19858 "./typica.w"
  11816. int column= 1;
  11817. /*1007:*/
  11818. #line 19888 "./typica.w"
  11819. for(int j= 0;j<itemList.size();j++)
  11820. {
  11821. tablemodel->setData(tablemodel->index(j,column),
  11822. QVariant(itemList.at(j).toDouble()),
  11823. Qt::DisplayRole);
  11824. }
  11825. /*:1007*/
  11826. #line 19860 "./typica.w"
  11827. }
  11828. }
  11829. updateSourceColumn(source->text());
  11830. updateDestinationColumn(destination->text());
  11831. updateKnots();
  11832. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11833. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11834. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11835. setLayout(layout);
  11836. }
  11837. /*:1005*//*1008:*/
  11838. #line 19899 "./typica.w"
  11839. void LinearSplineInterpolationConfWidget::updateKnots()
  11840. {
  11841. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11842. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11843. }
  11844. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11845. {
  11846. updateAttribute("source",source);
  11847. }
  11848. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11849. {
  11850. updateAttribute("destination",dest);
  11851. }
  11852. /*:1008*/
  11853. #line 605 "./typica.w"
  11854. /*1025:*/
  11855. #line 20370 "./typica.w"
  11856. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11857. :BasicDeviceConfigurationWidget(model,index),
  11858. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox),
  11859. delaySelector(new QSpinBox)
  11860. {
  11861. unitSelector->addItem("Fahrenheit");
  11862. unitSelector->addItem("Celsius");
  11863. temperatureValue->setMinimum(0);
  11864. temperatureValue->setMaximum(1000);
  11865. QFormLayout*layout= new QFormLayout;
  11866. QLineEdit*column= new QLineEdit;
  11867. layout->addRow(tr("Column to match:"),column);
  11868. layout->addRow(tr("Unit:"),unitSelector);
  11869. layout->addRow(tr("Value:"),temperatureValue);
  11870. layout->addRow(tr("Start of batch safety delay:"),delaySelector);
  11871. /*807:*/
  11872. #line 16791 "./typica.w"
  11873. QDomElement referenceElement=
  11874. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11875. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11876. QDomElement node;
  11877. /*:807*/
  11878. #line 20386 "./typica.w"
  11879. for(int i= 0;i<configData.size();i++)
  11880. {
  11881. node= configData.at(i).toElement();
  11882. if(node.attribute("name")=="column")
  11883. {
  11884. column->setText(node.attribute("value"));
  11885. }
  11886. else if(node.attribute("name")=="unit")
  11887. {
  11888. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11889. }
  11890. else if(node.attribute("name")=="value")
  11891. {
  11892. temperatureValue->setValue(node.attribute("value").toDouble());
  11893. }
  11894. else if(node.attribute("name")=="delay")
  11895. {
  11896. delaySelector->setValue(node.attribute("value").toInt());
  11897. }
  11898. }
  11899. updateMatchingColumn(column->text());
  11900. updateTemperature();
  11901. updateDelay();
  11902. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  11903. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  11904. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  11905. connect(delaySelector,SIGNAL(valueChanged(int)),this,SLOT(updateDelay()));
  11906. setLayout(layout);
  11907. }
  11908. /*:1025*//*1026:*/
  11909. #line 20421 "./typica.w"
  11910. void TranslationConfWidget::updateTemperature()
  11911. {
  11912. updateAttribute("unit",unitSelector->currentText());
  11913. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  11914. if(unitSelector->currentText()=="Fahrenheit")
  11915. {
  11916. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  11917. }
  11918. else
  11919. {
  11920. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11921. }
  11922. }
  11923. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11924. {
  11925. updateAttribute("column",column);
  11926. }
  11927. void TranslationConfWidget::updateDelay()
  11928. {
  11929. updateAttribute("delay",QString("%1").arg(delaySelector->value()));
  11930. }
  11931. /*:1026*/
  11932. #line 606 "./typica.w"
  11933. /*864:*/
  11934. #line 24 "./freeannotation.w"
  11935. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11936. const QModelIndex&index)
  11937. :BasicDeviceConfigurationWidget(model,index)
  11938. {
  11939. QFormLayout*layout= new QFormLayout;
  11940. QLineEdit*labelEdit= new QLineEdit;
  11941. layout->addRow(tr("Label Text:"),labelEdit);
  11942. /*807:*/
  11943. #line 16791 "./typica.w"
  11944. QDomElement referenceElement=
  11945. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11946. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11947. QDomElement node;
  11948. /*:807*/
  11949. #line 32 "./freeannotation.w"
  11950. for(int i= 0;i<configData.size();i++)
  11951. {
  11952. node= configData.at(i).toElement();
  11953. if(node.attribute("name")=="labeltext")
  11954. {
  11955. labelEdit->setText(node.attribute("value"));
  11956. }
  11957. }
  11958. updateLabel(labelEdit->text());
  11959. connect(labelEdit,SIGNAL(textEdited(QString)),
  11960. this,SLOT(updateLabel(QString)));
  11961. setLayout(layout);
  11962. }
  11963. /*:864*//*865:*/
  11964. #line 49 "./freeannotation.w"
  11965. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11966. {
  11967. updateAttribute("labeltext",text);
  11968. }
  11969. /*:865*/
  11970. #line 607 "./typica.w"
  11971. /*1029:*/
  11972. #line 39 "./rate.w"
  11973. void RateOfChange::newMeasurement(Measurement measure)
  11974. {
  11975. cache.append(measure);
  11976. /*1030:*/
  11977. #line 64 "./rate.w"
  11978. if(cache.size()> 2)
  11979. {
  11980. bool done= false;
  11981. while(!done)
  11982. {
  11983. if(cache.front().time().secsTo(cache.back().time())> ct)
  11984. {
  11985. cache.removeFirst();
  11986. }
  11987. else if(cache.back().time()<cache.front().time())
  11988. {
  11989. cache.removeFirst();
  11990. done= true;
  11991. }
  11992. else
  11993. {
  11994. done= true;
  11995. }
  11996. if(cache.size()<3)
  11997. {
  11998. done= true;
  11999. }
  12000. }
  12001. }
  12002. /*:1030*/
  12003. #line 43 "./rate.w"
  12004. if(cache.size()>=2)
  12005. {
  12006. /*1031:*/
  12007. #line 96 "./rate.w"
  12008. int N= cache.size();
  12009. double SXY= 0;
  12010. double SX= 0;
  12011. double SXX= 0;
  12012. double SY= 0;
  12013. double y;
  12014. double x;
  12015. for(int i= 0;i<N;i++)
  12016. {
  12017. y= cache.at(i).temperature();
  12018. SY+= y;
  12019. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  12020. SX+= x;
  12021. SXX+= (x*x);
  12022. SXY+= (x*y);
  12023. }
  12024. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  12025. Measurement value(M*st,cache.back().time(),cache.back().scale());
  12026. value.insert("relative",true);
  12027. emit newData(value);
  12028. /*:1031*/
  12029. #line 46 "./rate.w"
  12030. }
  12031. }
  12032. /*:1029*//*1032:*/
  12033. #line 120 "./rate.w"
  12034. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  12035. {
  12036. setScaleTime(scaletime);
  12037. }
  12038. void RateOfChange::setCacheTime(int seconds)
  12039. {
  12040. ct= seconds;
  12041. }
  12042. void RateOfChange::setScaleTime(int seconds)
  12043. {
  12044. st= (seconds> 0?seconds:1);
  12045. }
  12046. /*:1032*/
  12047. #line 608 "./typica.w"
  12048. /*868:*/
  12049. #line 26 "./settings.w"
  12050. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  12051. {
  12052. QTabWidget*settingsTab= new QTabWidget;
  12053. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  12054. settingsTab->addTab(deviceSettings,tr("Roasters"));
  12055. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  12056. settingsTab->addTab(graphSettings,tr("Graph"));
  12057. ColorSettingsWidget*colorSettings= new ColorSettingsWidget;
  12058. settingsTab->addTab(colorSettings,tr("Color"));
  12059. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  12060. settingsTab->addTab(advancedSettings,tr("Advanced"));
  12061. setCentralWidget(settingsTab);
  12062. }
  12063. /*:868*/
  12064. #line 609 "./typica.w"
  12065. /*873:*/
  12066. #line 27 "./graphsettings.w"
  12067. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  12068. {
  12069. QTabWidget*graphCategories= new QTabWidget;
  12070. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  12071. graphCategories->addTab(relative,tr("Relative Temperatures"));
  12072. QVBoxLayout*layout= new QVBoxLayout;
  12073. layout->addWidget(graphCategories);
  12074. setLayout(layout);
  12075. }
  12076. /*:873*//*875:*/
  12077. #line 69 "./graphsettings.w"
  12078. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  12079. colorEdit(new QLineEdit)
  12080. {
  12081. QSettings settings;
  12082. QVBoxLayout*layout= new QVBoxLayout;
  12083. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  12084. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  12085. updateEnableSetting(enable->isChecked());
  12086. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  12087. layout->addWidget(enable);
  12088. QHBoxLayout*colorLayout= new QHBoxLayout;
  12089. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  12090. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  12091. updateColorSetting(colorEdit->text());
  12092. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  12093. QToolButton*colorPickerButton= new QToolButton();
  12094. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  12095. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  12096. colorLayout->addWidget(colorLabel);
  12097. colorLayout->addWidget(colorEdit);
  12098. colorLayout->addWidget(colorPickerButton);
  12099. colorLayout->addStretch();
  12100. layout->addLayout(colorLayout);
  12101. QHBoxLayout*unitLayout= new QHBoxLayout;
  12102. QLabel*unitLabel= new QLabel(tr("Unit"));
  12103. QComboBox*unitSelector= new QComboBox;
  12104. unitSelector->addItem(tr("Fahrenheit"));
  12105. unitSelector->addItem(tr("Celsius"));
  12106. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  12107. updateUnit(unitSelector->currentIndex());
  12108. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  12109. unitLayout->addWidget(unitLabel);
  12110. unitLayout->addWidget(unitSelector);
  12111. unitLayout->addStretch();
  12112. layout->addLayout(unitLayout);
  12113. QHBoxLayout*axisLayout= new QHBoxLayout;
  12114. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  12115. QLineEdit*axisEdit= new QLineEdit;
  12116. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, 0, 30, 65, 100").toString());
  12117. updateAxisSetting(axisEdit->text());
  12118. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  12119. axisLayout->addWidget(axisLabel);
  12120. axisLayout->addWidget(axisEdit);
  12121. layout->addLayout(axisLayout);
  12122. layout->addStretch();
  12123. setLayout(layout);
  12124. }
  12125. /*:875*//*876:*/
  12126. #line 120 "./graphsettings.w"
  12127. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  12128. {
  12129. QSettings settings;
  12130. settings.setValue("settings/graph/relative/enable",enabled);
  12131. }
  12132. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  12133. {
  12134. QSettings settings;
  12135. settings.setValue("settings/graph/relative/color",color);
  12136. }
  12137. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  12138. {
  12139. QSettings settings;
  12140. QString settingValue;
  12141. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  12142. QStringList numbers;
  12143. foreach(QString text,points)
  12144. {
  12145. bool okay= false;
  12146. text.toDouble(&okay);
  12147. if(okay)
  12148. {
  12149. numbers.append(text);
  12150. }
  12151. }
  12152. numbers.removeDuplicates();
  12153. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  12154. }
  12155. void GraphSettingsRelativeTab::updateUnit(int unit)
  12156. {
  12157. QSettings settings;
  12158. settings.setValue("settings/graph/relative/unit",unit);
  12159. }
  12160. /*:876*//*877:*/
  12161. #line 163 "./graphsettings.w"
  12162. void GraphSettingsRelativeTab::showColorPicker()
  12163. {
  12164. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  12165. colorEdit->setText(color.name());
  12166. }
  12167. #line 64 "./settings.w"
  12168. #line 1 "./colorsettings.w"
  12169. /*:877*/
  12170. #line 610 "./typica.w"
  12171. /*1078:*/
  12172. #line 682 "./dataqsdk.w"
  12173. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  12174. const QModelIndex&index)
  12175. :BasicDeviceConfigurationWidget(model,index),
  12176. deviceIdStack(new QStackedWidget)
  12177. {
  12178. QVBoxLayout*layout= new QVBoxLayout;
  12179. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  12180. layout->addWidget(autoDetect);
  12181. QWidget*autoLayerWidget= new QWidget;
  12182. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  12183. QLabel*autoLabel= new QLabel(tr("Device number"));
  12184. QSpinBox*autoNumber= new QSpinBox;
  12185. autoNumber->setMinimum(1);
  12186. autoNumber->setMaximum(99);
  12187. autoLayerLayout->addWidget(autoLabel);
  12188. autoLayerLayout->addWidget(autoNumber);
  12189. autoLayerWidget->setLayout(autoLayerLayout);
  12190. QWidget*fixedLayerWidget= new QWidget;
  12191. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  12192. QLabel*fixedLabel= new QLabel(tr("Device port"));
  12193. QComboBox*portSelection= new QComboBox;
  12194. portSelection->setEditable(true);
  12195. portSelection->addItems(DataqSdkDevice::detectHardware());
  12196. fixedLayerLayout->addWidget(fixedLabel);
  12197. fixedLayerLayout->addWidget(portSelection);
  12198. fixedLayerWidget->setLayout(fixedLayerLayout);
  12199. deviceIdStack->addWidget(autoLayerWidget);
  12200. deviceIdStack->addWidget(fixedLayerWidget);
  12201. layout->addWidget(deviceIdStack);
  12202. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12203. layout->addWidget(addChannelButton);
  12204. /*807:*/
  12205. #line 16791 "./typica.w"
  12206. QDomElement referenceElement=
  12207. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12208. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12209. QDomElement node;
  12210. /*:807*/
  12211. #line 714 "./dataqsdk.w"
  12212. for(int i= 0;i<configData.size();i++)
  12213. {
  12214. node= configData.at(i).toElement();
  12215. if(node.attribute("name")=="autoSelect")
  12216. {
  12217. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  12218. }
  12219. else if(node.attribute("name")=="deviceNumber")
  12220. {
  12221. autoNumber->setValue(node.attribute("value").toInt());
  12222. }
  12223. else if(node.attribute("name")=="port")
  12224. {
  12225. int index= portSelection->findText(node.attribute("value"));
  12226. if(index> -1)
  12227. {
  12228. portSelection->setCurrentIndex(index);
  12229. }
  12230. else
  12231. {
  12232. portSelection->setEditText(node.attribute("value"));
  12233. }
  12234. }
  12235. }
  12236. updateAutoSelect(autoDetect->isChecked());
  12237. updateDeviceNumber(autoNumber->value());
  12238. updatePort(portSelection->currentText());
  12239. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  12240. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  12241. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12242. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12243. setLayout(layout);
  12244. }
  12245. /*:1078*//*1079:*/
  12246. #line 758 "./dataqsdk.w"
  12247. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  12248. {
  12249. if(automatic)
  12250. {
  12251. updateAttribute("autoSelect","true");
  12252. deviceIdStack->setCurrentIndex(0);
  12253. }
  12254. else
  12255. {
  12256. updateAttribute("autoSelect","false");
  12257. deviceIdStack->setCurrentIndex(1);
  12258. }
  12259. }
  12260. /*:1079*//*1080:*/
  12261. #line 775 "./dataqsdk.w"
  12262. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  12263. {
  12264. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  12265. }
  12266. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  12267. {
  12268. updateAttribute("port",portId);
  12269. }
  12270. /*:1080*//*1081:*/
  12271. #line 788 "./dataqsdk.w"
  12272. void DataqSdkDeviceConfWidget::addChannel()
  12273. {
  12274. insertChildNode(tr("Channel"),"dataqsdkchannel");
  12275. }
  12276. /*:1081*//*1084:*/
  12277. #line 868 "./dataqsdk.w"
  12278. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  12279. const QModelIndex&index)
  12280. :BasicDeviceConfigurationWidget(model,index),
  12281. startButton(new QPushButton(tr("Start"))),
  12282. resetButton(new QPushButton(tr("Reset"))),
  12283. stopButton(new QPushButton(tr("Stop"))),
  12284. calibrator(new LinearCalibrator),
  12285. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  12286. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  12287. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  12288. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  12289. rmCount(0),cmCount(0),
  12290. rmin(std::numeric_limits<double> ::max()),
  12291. rmax(std::numeric_limits<double> ::min()),rmean(0),
  12292. cmin(std::numeric_limits<double> ::max()),
  12293. cmax(std::numeric_limits<double> ::min()),cmean(0)
  12294. {
  12295. /*1088:*/
  12296. #line 1107 "./dataqsdk.w"
  12297. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  12298. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  12299. QDomElement deviceNode;
  12300. QString configPort;
  12301. QString configAuto;
  12302. for(int i= 0;i<deviceConfigData.size();i++)
  12303. {
  12304. deviceNode= deviceConfigData.at(i).toElement();
  12305. if(deviceNode.attribute("name")=="autoSelect")
  12306. {
  12307. autoSelect= (deviceNode.attribute("value")=="true");
  12308. }
  12309. else if(deviceNode.attribute("name")=="deviceNumber")
  12310. {
  12311. configAuto= deviceNode.attribute("value");
  12312. }
  12313. else if(deviceNode.attribute("name")=="port")
  12314. {
  12315. configPort= deviceNode.attribute("value");
  12316. }
  12317. }
  12318. deviceID= autoSelect?configAuto:configPort;
  12319. channelOfInterest= index.row();
  12320. /*:1088*/
  12321. #line 886 "./dataqsdk.w"
  12322. resetButton->setEnabled(false);
  12323. stopButton->setEnabled(false);
  12324. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  12325. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  12326. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  12327. QVBoxLayout*layout= new QVBoxLayout;
  12328. QFormLayout*topLayout= new QFormLayout;
  12329. QLineEdit*columnEdit= new QLineEdit;
  12330. topLayout->addRow(tr("Column name"),columnEdit);
  12331. QComboBox*unitSelector= new QComboBox;
  12332. unitSelector->addItem(tr("Temperature"));
  12333. unitSelector->addItem(tr("Control"));
  12334. topLayout->addRow(tr("Measurement type"),unitSelector);
  12335. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  12336. topLayout->addRow(smoothingBox);
  12337. layout->addLayout(topLayout);
  12338. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  12339. topLayout->addRow(hideSeries);
  12340. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  12341. layout->addWidget(calibrationLabel);
  12342. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  12343. QFormLayout*calibrationControlsLayout= new QFormLayout;
  12344. QLineEdit*measuredLowerEdit= new QLineEdit;
  12345. measuredLowerEdit->setText("0");
  12346. QLineEdit*measuredUpperEdit= new QLineEdit;
  12347. measuredUpperEdit->setText("10");
  12348. QLineEdit*mappedLowerEdit= new QLineEdit;
  12349. mappedLowerEdit->setText("0");
  12350. QLineEdit*mappedUpperEdit= new QLineEdit;
  12351. mappedUpperEdit->setText("10");
  12352. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  12353. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  12354. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  12355. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  12356. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  12357. calibrationControlsLayout->addRow(closedBox);
  12358. QLineEdit*sensitivityEdit= new QLineEdit;
  12359. sensitivityEdit->setText("0");
  12360. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  12361. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  12362. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  12363. deviceControlLayout->addWidget(startButton);
  12364. deviceControlLayout->addWidget(resetButton);
  12365. deviceControlLayout->addWidget(stopButton);
  12366. QFormLayout*indicatorLayout= new QFormLayout;
  12367. currentMeasurement->setReadOnly(true);
  12368. minimumMeasurement->setReadOnly(true);
  12369. maximumMeasurement->setReadOnly(true);
  12370. averageMeasurement->setReadOnly(true);
  12371. currentMapped->setReadOnly(true);
  12372. minimumMapped->setReadOnly(true);
  12373. maximumMapped->setReadOnly(true);
  12374. averageMapped->setReadOnly(true);
  12375. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  12376. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  12377. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  12378. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  12379. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  12380. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  12381. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  12382. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  12383. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  12384. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  12385. calibrationTestLayout->addLayout(deviceControlLayout);
  12386. calibrationTestLayout->addLayout(indicatorLayout);
  12387. calibrationLayout->addLayout(calibrationControlsLayout);
  12388. calibrationLayout->addLayout(calibrationTestLayout);
  12389. layout->addLayout(calibrationLayout);
  12390. /*807:*/
  12391. #line 16791 "./typica.w"
  12392. QDomElement referenceElement=
  12393. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12394. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12395. QDomElement node;
  12396. /*:807*/
  12397. #line 955 "./dataqsdk.w"
  12398. for(int i= 0;i<configData.size();i++)
  12399. {
  12400. node= configData.at(i).toElement();
  12401. if(node.attribute("name")=="column")
  12402. {
  12403. columnEdit->setText(node.attribute("value"));
  12404. }
  12405. else if(node.attribute("name")=="type")
  12406. {
  12407. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  12408. }
  12409. else if(node.attribute("name")=="smoothing")
  12410. {
  12411. smoothingBox->setChecked(node.attribute("value")=="true");
  12412. }
  12413. else if(node.attribute("name")=="calibrationMeasuredLower")
  12414. {
  12415. measuredLowerEdit->setText(node.attribute("value"));
  12416. }
  12417. else if(node.attribute("name")=="calibrationMeasuredUpper")
  12418. {
  12419. measuredUpperEdit->setText(node.attribute("value"));
  12420. }
  12421. else if(node.attribute("name")=="calibrationMappedLower")
  12422. {
  12423. mappedLowerEdit->setText(node.attribute("value"));
  12424. }
  12425. else if(node.attribute("name")=="calibrationMappedUpper")
  12426. {
  12427. mappedUpperEdit->setText(node.attribute("value"));
  12428. }
  12429. else if(node.attribute("name")=="calibrationClosedInterval")
  12430. {
  12431. closedBox->setChecked(node.attribute("value")=="true");
  12432. }
  12433. else if(node.attribute("name")=="calibrationSensitivity")
  12434. {
  12435. sensitivityEdit->setText(node.attribute("value"));
  12436. }
  12437. else if(node.attribute("name")=="hidden")
  12438. {
  12439. hideSeries->setChecked(node.attribute("value")=="true");
  12440. }
  12441. }
  12442. updateColumnName(columnEdit->text());
  12443. updateUnits(unitSelector->currentText());
  12444. updateSmoothingEnabled(smoothingBox->isChecked());
  12445. updateMeasuredLower(measuredLowerEdit->text());
  12446. updateMeasuredUpper(measuredUpperEdit->text());
  12447. updateMappedLower(mappedLowerEdit->text());
  12448. updateMappedUpper(mappedUpperEdit->text());
  12449. updateClosedInterval(closedBox->isChecked());
  12450. updateSensitivity(sensitivityEdit->text());
  12451. updateHidden(hideSeries->isChecked());
  12452. connect(columnEdit,SIGNAL(textChanged(QString)),
  12453. this,SLOT(updateColumnName(QString)));
  12454. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  12455. this,SLOT(updateUnits(QString)));
  12456. connect(smoothingBox,SIGNAL(toggled(bool)),
  12457. this,SLOT(updateSmoothingEnabled(bool)));
  12458. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  12459. this,SLOT(updateMeasuredLower(QString)));
  12460. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  12461. this,SLOT(updateMappedLower(QString)));
  12462. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  12463. this,SLOT(updateMeasuredUpper(QString)));
  12464. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  12465. this,SLOT(updateMappedUpper(QString)));
  12466. connect(closedBox,SIGNAL(toggled(bool)),
  12467. this,SLOT(updateClosedInterval(bool)));
  12468. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  12469. this,SLOT(updateSensitivity(QString)));
  12470. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12471. setLayout(layout);
  12472. }
  12473. /*:1084*//*1085:*/
  12474. #line 1038 "./dataqsdk.w"
  12475. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  12476. {
  12477. updateAttribute("type",unit);
  12478. }
  12479. /*:1085*//*1086:*/
  12480. #line 1047 "./dataqsdk.w"
  12481. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  12482. {
  12483. updateAttribute("calibrationMeasuredLower",value);
  12484. calibrator->setMeasuredLower(value.toDouble());
  12485. }
  12486. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  12487. {
  12488. updateAttribute("calibrationMeasuredUpper",value);
  12489. calibrator->setMeasuredUpper(value.toDouble());
  12490. }
  12491. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  12492. {
  12493. updateAttribute("calibrationMappedLower",value);
  12494. calibrator->setMappedLower(value.toDouble());
  12495. }
  12496. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  12497. {
  12498. updateAttribute("calibrationMappedUpper",value);
  12499. calibrator->setMappedUpper(value.toDouble());
  12500. }
  12501. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  12502. {
  12503. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  12504. calibrator->setClosedRange(closed);
  12505. }
  12506. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  12507. {
  12508. updateAttribute("smoothing",enabled?"true":"false");
  12509. }
  12510. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  12511. {
  12512. updateAttribute("calibrationSensitivity",value);
  12513. calibrator->setSensitivity(value.toDouble());
  12514. }
  12515. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  12516. {
  12517. updateAttribute("hidden",hidden?"true":"false");
  12518. }
  12519. /*:1086*//*1089:*/
  12520. #line 1136 "./dataqsdk.w"
  12521. void DataqSdkChannelConfWidget::startCalibration()
  12522. {
  12523. startButton->setEnabled(false);
  12524. stopButton->setEnabled(true);
  12525. resetButton->setEnabled(true);
  12526. calibrationDevice= new DataqSdkDevice(deviceID);
  12527. Channel*channel;
  12528. for(unsigned int i= 0;i<=channelOfInterest;i++)
  12529. {
  12530. channel= calibrationDevice->newChannel(Units::Unitless);
  12531. }
  12532. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  12533. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  12534. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  12535. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  12536. calibrationDevice->start();
  12537. }
  12538. void DataqSdkChannelConfWidget::stopCalibration()
  12539. {
  12540. startButton->setEnabled(true);
  12541. stopButton->setEnabled(false);
  12542. resetButton->setEnabled(false);
  12543. calibrationDevice->deleteLater();
  12544. /*1091:*/
  12545. #line 1181 "./dataqsdk.w"
  12546. rmCount= 0;
  12547. cmCount= 0;
  12548. rmin= std::numeric_limits<double> ::max();
  12549. rmax= std::numeric_limits<double> ::min();
  12550. rmean= 0;
  12551. cmin= std::numeric_limits<double> ::max();
  12552. cmax= std::numeric_limits<double> ::min();
  12553. cmean= 0;
  12554. /*:1091*/
  12555. #line 1161 "./dataqsdk.w"
  12556. }
  12557. /*:1089*//*1090:*/
  12558. #line 1172 "./dataqsdk.w"
  12559. void DataqSdkChannelConfWidget::resetCalibration()
  12560. {
  12561. /*1091:*/
  12562. #line 1181 "./dataqsdk.w"
  12563. rmCount= 0;
  12564. cmCount= 0;
  12565. rmin= std::numeric_limits<double> ::max();
  12566. rmax= std::numeric_limits<double> ::min();
  12567. rmean= 0;
  12568. cmin= std::numeric_limits<double> ::max();
  12569. cmax= std::numeric_limits<double> ::min();
  12570. cmean= 0;
  12571. /*:1091*/
  12572. #line 1175 "./dataqsdk.w"
  12573. }
  12574. /*:1090*//*1092:*/
  12575. #line 1195 "./dataqsdk.w"
  12576. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  12577. {
  12578. double nv= measure.temperature();
  12579. currentMeasurement->setText(QString("%1").arg(nv));
  12580. rmin= qMin(nv,rmin);
  12581. minimumMeasurement->setText(QString("%1").arg(rmin));
  12582. rmax= qMax(nv,rmax);
  12583. maximumMeasurement->setText(QString("%1").arg(rmax));
  12584. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  12585. rmCount++;
  12586. averageMeasurement->setText(QString("%1").arg(rmean));
  12587. }
  12588. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  12589. {
  12590. double nv= measure.temperature();
  12591. currentMapped->setText(QString("%1").arg(nv));
  12592. cmin= qMin(nv,cmin);
  12593. minimumMapped->setText(QString("%1").arg(cmin));
  12594. cmax= qMax(nv,cmax);
  12595. maximumMapped->setText(QString("%1").arg(cmax));
  12596. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  12597. cmCount++;
  12598. averageMapped->setText(QString("%1").arg(cmean));
  12599. }
  12600. /*:1092*//*1093:*/
  12601. #line 1224 "./dataqsdk.w"
  12602. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  12603. {
  12604. updateAttribute("column",value);
  12605. }
  12606. /*:1093*/
  12607. #line 611 "./typica.w"
  12608. /*1117:*/
  12609. #line 423 "./scales.w"
  12610. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  12611. const QModelIndex&index)
  12612. :BasicDeviceConfigurationWidget(model,index),
  12613. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  12614. flow(new FlowSelector),stop(new StopSelector),
  12615. weighcommand(new QLineEdit("!KP")),commandterminator(new QComboBox)
  12616. {
  12617. QFormLayout*layout= new QFormLayout;
  12618. layout->addRow(tr("Port:"),port);
  12619. connect(port,SIGNAL(currentIndexChanged(QString)),
  12620. this,SLOT(updatePort(QString)));
  12621. connect(port,SIGNAL(editTextChanged(QString)),
  12622. this,SLOT(updatePort(QString)));
  12623. layout->addRow(tr("Baud:"),baud);
  12624. connect(baud,SIGNAL(currentIndexChanged(QString)),
  12625. this,SLOT(updateBaudRate(QString)));
  12626. layout->addRow(tr("Parity:"),parity);
  12627. connect(parity,SIGNAL(currentIndexChanged(int)),
  12628. this,SLOT(updateParity(int)));
  12629. layout->addRow(tr("Flow Control:"),flow);
  12630. connect(flow,SIGNAL(currentIndexChanged(int)),
  12631. this,SLOT(updateFlowControl(int)));
  12632. layout->addRow(tr("Stop Bits:"),stop);
  12633. connect(stop,SIGNAL(currentIndexChanged(int)),
  12634. this,SLOT(updateStopBits(int)));
  12635. layout->addRow(tr("Weigh Command:"),weighcommand);
  12636. connect(weighcommand,SIGNAL(textChanged(QString)),
  12637. this,SLOT(updateWeighCommand(QString)));
  12638. commandterminator->addItem("CRLF");
  12639. commandterminator->addItem("CR");
  12640. commandterminator->addItem("LF");
  12641. layout->addRow(tr("Command Terminator:"),commandterminator);
  12642. connect(commandterminator,SIGNAL(currentIndexChanged(QString)),
  12643. this,SLOT(updateCommandTerminator(QString)));
  12644. /*807:*/
  12645. #line 16791 "./typica.w"
  12646. QDomElement referenceElement=
  12647. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12648. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12649. QDomElement node;
  12650. /*:807*/
  12651. #line 459 "./scales.w"
  12652. for(int i= 0;i<configData.size();i++)
  12653. {
  12654. node= configData.at(i).toElement();
  12655. if(node.attribute("name")=="port")
  12656. {
  12657. int j= port->findText(node.attribute("value"));
  12658. if(j>=0)
  12659. {
  12660. port->setCurrentIndex(j);
  12661. }
  12662. else
  12663. {
  12664. port->insertItem(0,node.attribute("value"));
  12665. port->setCurrentIndex(0);
  12666. }
  12667. }
  12668. else if(node.attribute("name")=="baudrate")
  12669. {
  12670. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12671. }
  12672. else if(node.attribute("name")=="parity")
  12673. {
  12674. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  12675. }
  12676. else if(node.attribute("name")=="flowcontrol")
  12677. {
  12678. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  12679. }
  12680. else if(node.attribute("name")=="stopbits")
  12681. {
  12682. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  12683. }
  12684. else if(node.attribute("name")=="weighcommand")
  12685. {
  12686. weighcommand->setText(node.attribute("value"));
  12687. }
  12688. else if(node.attribute("name")=="commandterminator")
  12689. {
  12690. commandterminator->setCurrentIndex(
  12691. commandterminator->findText(node.attribute("value")));
  12692. }
  12693. }
  12694. updatePort(port->currentText());
  12695. updateBaudRate(baud->currentText());
  12696. updateParity(parity->currentIndex());
  12697. updateFlowControl(flow->currentIndex());
  12698. updateStopBits(stop->currentIndex());
  12699. updateWeighCommand(weighcommand->text());
  12700. updateCommandTerminator(commandterminator->currentText());
  12701. setLayout(layout);
  12702. }
  12703. /*:1117*//*1118:*/
  12704. #line 514 "./scales.w"
  12705. void SerialScaleConfWidget::updatePort(const QString&newPort)
  12706. {
  12707. updateAttribute("port",newPort);
  12708. }
  12709. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  12710. {
  12711. updateAttribute("baudrate",rate);
  12712. }
  12713. void SerialScaleConfWidget::updateParity(int index)
  12714. {
  12715. updateAttribute("parity",parity->itemData(index).toString());
  12716. }
  12717. void SerialScaleConfWidget::updateFlowControl(int index)
  12718. {
  12719. updateAttribute("flowcontrol",flow->itemData(index).toString());
  12720. }
  12721. void SerialScaleConfWidget::updateStopBits(int index)
  12722. {
  12723. updateAttribute("stopbits",stop->itemData(index).toString());
  12724. }
  12725. void SerialScaleConfWidget::updateWeighCommand(const QString&command)
  12726. {
  12727. updateAttribute("weighcommand",command);
  12728. }
  12729. void SerialScaleConfWidget::updateCommandTerminator(const QString&terminator)
  12730. {
  12731. updateAttribute("commandterminator",terminator);
  12732. }
  12733. /*:1118*/
  12734. #line 612 "./typica.w"
  12735. /*1130:*/
  12736. #line 195 "./valueannotation.w"
  12737. void ValueAnnotation::newMeasurement(Measurement measure)
  12738. {
  12739. for(int i= 0;i<values.size();i++)
  12740. {
  12741. if(measure.temperature()> values.at(i)-tolerance&&
  12742. measure.temperature()<values.at(i)+tolerance)
  12743. {
  12744. if(i!=lastIndex)
  12745. {
  12746. lastIndex= i;
  12747. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  12748. }
  12749. }
  12750. }
  12751. }
  12752. /*:1130*//*1131:*/
  12753. #line 216 "./valueannotation.w"
  12754. void ValueAnnotation::annotate()
  12755. {
  12756. if(lastIndex> -1)
  12757. {
  12758. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  12759. }
  12760. }
  12761. /*:1131*//*1132:*/
  12762. #line 228 "./valueannotation.w"
  12763. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  12764. {
  12765. values.append(value);
  12766. annotations.append(annotation);
  12767. }
  12768. /*:1132*//*1133:*/
  12769. #line 237 "./valueannotation.w"
  12770. void ValueAnnotation::setAnnotationColumn(int column)
  12771. {
  12772. annotationColumn= column;
  12773. }
  12774. void ValueAnnotation::setTemperatureColumn(int column)
  12775. {
  12776. measurementColumn= column;
  12777. }
  12778. void ValueAnnotation::setTolerance(double epsilon)
  12779. {
  12780. tolerance= epsilon;
  12781. }
  12782. /*:1133*//*1134:*/
  12783. #line 255 "./valueannotation.w"
  12784. ValueAnnotation::ValueAnnotation():QObject(),
  12785. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  12786. {
  12787. }
  12788. /*:1134*/
  12789. #line 613 "./typica.w"
  12790. /*1122:*/
  12791. #line 33 "./valueannotation.w"
  12792. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  12793. const QModelIndex&index)
  12794. :BasicDeviceConfigurationWidget(model,index),
  12795. tablemodel(new SaltModel(2))
  12796. {
  12797. QFormLayout*layout= new QFormLayout;
  12798. QLineEdit*source= new QLineEdit;
  12799. layout->addRow(tr("Source column name:"),source);
  12800. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12801. noteOnStart->setChecked(true);
  12802. layout->addRow(noteOnStart);
  12803. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12804. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12805. QTableView*annotationTable= new QTableView;
  12806. annotationTable->setModel(tablemodel);
  12807. NumericDelegate*delegate= new NumericDelegate;
  12808. annotationTable->setItemDelegateForColumn(0,delegate);
  12809. layout->addRow(tr("Annotations for values:"),annotationTable);
  12810. /*807:*/
  12811. #line 16791 "./typica.w"
  12812. QDomElement referenceElement=
  12813. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12814. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12815. QDomElement node;
  12816. /*:807*/
  12817. #line 52 "./valueannotation.w"
  12818. for(int i= 0;i<configData.size();i++)
  12819. {
  12820. node= configData.at(i).toElement();
  12821. if(node.attribute("name")=="source")
  12822. {
  12823. source->setText(node.attribute("value"));
  12824. }
  12825. else if(node.attribute("name")=="emitOnStart")
  12826. {
  12827. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12828. }
  12829. else if(node.attribute("name")=="measuredValues")
  12830. {
  12831. /*1006:*/
  12832. #line 19876 "./typica.w"
  12833. QString data= node.attribute("value");
  12834. if(data.length()> 3)
  12835. {
  12836. data.chop(2);
  12837. data= data.remove(0,2);
  12838. }
  12839. QStringList itemList= data.split(",");
  12840. /*:1006*/
  12841. #line 66 "./valueannotation.w"
  12842. int column= 0;
  12843. /*1007:*/
  12844. #line 19888 "./typica.w"
  12845. for(int j= 0;j<itemList.size();j++)
  12846. {
  12847. tablemodel->setData(tablemodel->index(j,column),
  12848. QVariant(itemList.at(j).toDouble()),
  12849. Qt::DisplayRole);
  12850. }
  12851. /*:1007*/
  12852. #line 68 "./valueannotation.w"
  12853. }
  12854. else if(node.attribute("name")=="annotations")
  12855. {
  12856. /*1123:*/
  12857. #line 89 "./valueannotation.w"
  12858. QString data= node.attribute("value");
  12859. if(data.length()> 3)
  12860. {
  12861. data.chop(2);
  12862. data= data.remove(0,2);
  12863. }
  12864. QStringList itemList= data.split(",");
  12865. for(int i= 0;i<itemList.size();i++)
  12866. {
  12867. itemList[i]= itemList[i].simplified();
  12868. }
  12869. /*:1123*/
  12870. #line 72 "./valueannotation.w"
  12871. int column= 1;
  12872. /*1124:*/
  12873. #line 104 "./valueannotation.w"
  12874. for(int i= 0;i<itemList.size();i++)
  12875. {
  12876. tablemodel->setData(tablemodel->index(i,column),
  12877. QVariant(itemList.at(i)),
  12878. Qt::DisplayRole);
  12879. }
  12880. /*:1124*/
  12881. #line 74 "./valueannotation.w"
  12882. }
  12883. }
  12884. updateSourceColumn(source->text());
  12885. updateStart(noteOnStart->isChecked());
  12886. updateAnnotations();
  12887. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12888. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12889. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12890. setLayout(layout);
  12891. }
  12892. /*:1122*//*1125:*/
  12893. #line 115 "./valueannotation.w"
  12894. void ValueAnnotationConfWidget::updateAnnotations()
  12895. {
  12896. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12897. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12898. }
  12899. /*:1125*//*1126:*/
  12900. #line 125 "./valueannotation.w"
  12901. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  12902. {
  12903. updateAttribute("source",source);
  12904. }
  12905. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  12906. {
  12907. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  12908. }
  12909. /*:1126*/
  12910. #line 614 "./typica.w"
  12911. /*907:*/
  12912. #line 44 "./modbus.w"
  12913. ModbusNGConfWidget::ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index):
  12914. BasicDeviceConfigurationWidget(model,index),m_parity(new ParitySelector),
  12915. m_flow(new FlowSelector),m_stop(new StopSelector)
  12916. {
  12917. QFormLayout*layout= new QFormLayout;
  12918. PortSelector*port= new PortSelector;
  12919. BaudSelector*baud= new BaudSelector;
  12920. QPushButton*newInput= new QPushButton(tr("Add Input Channel"));
  12921. layout->addRow(QString(tr("Port:")),port);
  12922. layout->addRow(QString(tr("Baud rate:")),baud);
  12923. layout->addRow(QString(tr("Parity:")),m_parity);
  12924. layout->addRow(QString(tr("Flow control:")),m_flow);
  12925. layout->addRow(QString(tr("Stop bits:")),m_stop);
  12926. layout->addRow(newInput);
  12927. /*807:*/
  12928. #line 16791 "./typica.w"
  12929. QDomElement referenceElement=
  12930. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12931. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12932. QDomElement node;
  12933. /*:807*/
  12934. #line 60 "./modbus.w"
  12935. for(int i= 0;i<configData.size();i++)
  12936. {
  12937. node= configData.at(i).toElement();
  12938. if(node.attribute("name")=="port")
  12939. {
  12940. int idx= port->findText(node.attribute("value"));
  12941. if(idx>=0)
  12942. {
  12943. port->setCurrentIndex(idx);
  12944. }
  12945. else
  12946. {
  12947. port->addItem(node.attribute("value"));
  12948. }
  12949. }
  12950. else if(node.attribute("name")=="baud")
  12951. {
  12952. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12953. }
  12954. else if(node.attribute("name")=="parity")
  12955. {
  12956. m_parity->setCurrentIndex(m_parity->findData(node.attribute("value")));
  12957. }
  12958. else if(node.attribute("name")=="flow")
  12959. {
  12960. m_flow->setCurrentIndex(m_flow->findData(node.attribute("value")));
  12961. }
  12962. else if(node.attribute("name")=="stop")
  12963. {
  12964. m_stop->setCurrentIndex(m_stop->findData(node.attribute("value")));
  12965. }
  12966. }
  12967. updatePort(port->currentText());
  12968. updateBaudRate(baud->currentText());
  12969. updateParity(m_parity->currentIndex());
  12970. updateFlowControl(m_flow->currentIndex());
  12971. updateStopBits(m_stop->currentIndex());
  12972. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12973. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  12974. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  12975. connect(m_parity,SIGNAL(currentIndexChanged(int)),this,SLOT(updateParity(int)));
  12976. connect(m_flow,SIGNAL(currentIndexChanged(int)),
  12977. this,SLOT(updateFlowControl(int)));
  12978. connect(m_stop,SIGNAL(currentIndexChanged(int)),this,SLOT(updateStopBits(int)));
  12979. connect(newInput,SIGNAL(clicked()),this,SLOT(addInput()));
  12980. setLayout(layout);
  12981. }
  12982. void ModbusNGConfWidget::updatePort(const QString&value)
  12983. {
  12984. updateAttribute("port",value);
  12985. }
  12986. void ModbusNGConfWidget::updateBaudRate(const QString&value)
  12987. {
  12988. updateAttribute("baud",value);
  12989. }
  12990. void ModbusNGConfWidget::updateParity(int value)
  12991. {
  12992. updateAttribute("parity",m_parity->itemData(value).toString());
  12993. }
  12994. void ModbusNGConfWidget::updateFlowControl(int value)
  12995. {
  12996. updateAttribute("flow",m_flow->itemData(value).toString());
  12997. }
  12998. void ModbusNGConfWidget::updateStopBits(int value)
  12999. {
  13000. updateAttribute("stop",m_stop->itemData(value).toString());
  13001. }
  13002. void ModbusNGConfWidget::addInput()
  13003. {
  13004. insertChildNode(tr("Input"),"modbusnginput");
  13005. }
  13006. /*:907*//*909:*/
  13007. #line 164 "./modbus.w"
  13008. ModbusNGInputConfWidget::ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index):BasicDeviceConfigurationWidget(model,index)
  13009. {
  13010. QFormLayout*layout= new QFormLayout;
  13011. QSpinBox*station= new QSpinBox;
  13012. station->setMinimum(1);
  13013. station->setMaximum(247);
  13014. layout->addRow(tr("Station ID"),station);
  13015. QComboBox*function= new QComboBox;
  13016. function->addItem("3","3");
  13017. function->addItem("4","4");
  13018. function->setCurrentIndex(1);
  13019. layout->addRow(tr("Function"),function);
  13020. ShortHexSpinBox*address= new ShortHexSpinBox;
  13021. layout->addRow(tr("Address"),address);
  13022. QComboBox*format= new QComboBox;
  13023. format->addItem(tr("16 bits fixed point"),"16fixedint");
  13024. format->addItem(tr("32 bits floating point (High Low)"),"32floathl");
  13025. format->addItem(tr("32 bits floating point (Low High)"),"32floatlh");
  13026. layout->addRow(tr("Data format"),format);
  13027. QSpinBox*decimals= new QSpinBox;
  13028. decimals->setMinimum(0);
  13029. decimals->setMaximum(9);
  13030. layout->addRow(tr("Decimal places"),decimals);
  13031. QComboBox*unit= new QComboBox;
  13032. unit->addItem("Celsius","C");
  13033. unit->addItem("Fahrenheit","F");
  13034. unit->addItem("Control","Control");
  13035. unit->setCurrentIndex(1);
  13036. layout->addRow(tr("Unit"),unit);
  13037. QLineEdit*column= new QLineEdit;
  13038. layout->addRow(tr("Column name"),column);
  13039. QCheckBox*hidden= new QCheckBox(tr("Hide this channel"));
  13040. layout->addRow(hidden);
  13041. /*807:*/
  13042. #line 16791 "./typica.w"
  13043. QDomElement referenceElement=
  13044. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13045. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13046. QDomElement node;
  13047. /*:807*/
  13048. #line 199 "./modbus.w"
  13049. for(int i= 0;i<configData.size();i++)
  13050. {
  13051. node= configData.at(i).toElement();
  13052. if(node.attribute("name")=="station")
  13053. {
  13054. station->setValue(node.attribute("value").toInt());
  13055. }
  13056. else if(node.attribute("name")=="function")
  13057. {
  13058. function->setCurrentIndex(function->findText(node.attribute("value")));
  13059. }
  13060. else if(node.attribute("name")=="address")
  13061. {
  13062. address->setValue(node.attribute("value").toInt());
  13063. }
  13064. else if(node.attribute("name")=="format")
  13065. {
  13066. format->setCurrentIndex(format->findData(node.attribute("value")));
  13067. }
  13068. else if(node.attribute("name")=="decimals")
  13069. {
  13070. decimals->setValue(node.attribute("value").toInt());
  13071. }
  13072. else if(node.attribute("name")=="unit")
  13073. {
  13074. unit->setCurrentIndex(unit->findData(node.attribute("value")));
  13075. }
  13076. else if(node.attribute("name")=="column")
  13077. {
  13078. column->setText(node.attribute("value"));
  13079. }
  13080. else if(node.attribute("name")=="hidden")
  13081. {
  13082. hidden->setChecked(node.attribute("value")=="true"?true:false);
  13083. }
  13084. }
  13085. updateStation(station->value());
  13086. updateFunction(function->currentIndex());
  13087. updateAddress(address->value());
  13088. updateFormat(format->currentIndex());
  13089. updateDecimals(decimals->value());
  13090. updateUnit(unit->currentIndex());
  13091. updateColumnName(column->text());
  13092. updateHidden(hidden->isChecked());
  13093. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  13094. connect(function,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFunction(int)));
  13095. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  13096. connect(format,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFormat(int)));
  13097. connect(decimals,SIGNAL(valueChanged(int)),this,SLOT(updateDecimals(int)));
  13098. connect(unit,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  13099. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13100. connect(hidden,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13101. setLayout(layout);
  13102. }
  13103. void ModbusNGInputConfWidget::updateStation(int value)
  13104. {
  13105. updateAttribute("station",QString("%1").arg(value));
  13106. }
  13107. void ModbusNGInputConfWidget::updateFunction(int value)
  13108. {
  13109. updateAttribute("function",QString("%1").arg(value==0?"3":"4"));
  13110. }
  13111. void ModbusNGInputConfWidget::updateAddress(int value)
  13112. {
  13113. updateAttribute("address",QString("%1").arg(value));
  13114. }
  13115. void ModbusNGInputConfWidget::updateFormat(int value)
  13116. {
  13117. switch(value)
  13118. {
  13119. case 0:
  13120. updateAttribute("format","16fixedint");
  13121. break;
  13122. case 1:
  13123. updateAttribute("format","32floathl");
  13124. break;
  13125. case 2:
  13126. updateAttribute("format","32floatlh");
  13127. break;
  13128. }
  13129. }
  13130. void ModbusNGInputConfWidget::updateDecimals(int value)
  13131. {
  13132. updateAttribute("decimals",QString("%1").arg(value));
  13133. }
  13134. void ModbusNGInputConfWidget::updateUnit(int value)
  13135. {
  13136. switch(value)
  13137. {
  13138. case 0:
  13139. updateAttribute("unit","C");
  13140. break;
  13141. case 1:
  13142. updateAttribute("unit","F");
  13143. break;
  13144. case 2:
  13145. updateAttribute("unit","Control");
  13146. break;
  13147. }
  13148. }
  13149. void ModbusNGInputConfWidget::updateColumnName(const QString&value)
  13150. {
  13151. updateAttribute("column",value);
  13152. }
  13153. void ModbusNGInputConfWidget::updateHidden(bool value)
  13154. {
  13155. updateAttribute("hidden",value?"true":"false");
  13156. }
  13157. /*:909*//*914:*/
  13158. #line 403 "./modbus.w"
  13159. ModbusNG::ModbusNG(DeviceTreeModel*model,const QModelIndex&index):
  13160. QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),
  13161. rateLimiter(new QTimer),scanPosition(0),waiting(false)
  13162. {
  13163. QDomElement portReferenceElement=
  13164. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13165. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  13166. QDomElement node;
  13167. QVariantMap attributes;
  13168. for(int i= 0;i<portConfigData.size();i++)
  13169. {
  13170. node= portConfigData.at(i).toElement();
  13171. attributes.insert(node.attribute("name"),node.attribute("value"));
  13172. }
  13173. port= new QextSerialPort(attributes.value("port").toString(),
  13174. QextSerialPort::EventDriven);
  13175. port->setBaudRate((BaudRateType)(attributes.value("baud").toInt()));
  13176. port->setDataBits(DATA_8);
  13177. port->setParity((ParityType)attributes.value("parity").toInt());
  13178. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  13179. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  13180. delayTime= (int)(((double)(1)/(double)(attributes.value("baud").toInt()))*144000.0);
  13181. messageDelayTimer->setSingleShot(true);
  13182. commTimeout->setSingleShot(true);
  13183. rateLimiter->setSingleShot(true);
  13184. rateLimiter->setInterval(0);
  13185. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  13186. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  13187. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  13188. connect(rateLimiter,SIGNAL(timeout()),this,SLOT(rateLimitTimeout()));
  13189. if(!port->open(QIODevice::ReadWrite))
  13190. {
  13191. qDebug()<<"Failed to open serial port";
  13192. }
  13193. for(int i= 0;i<model->rowCount(index);i++)
  13194. {
  13195. QModelIndex channelIndex= model->index(i,0,index);
  13196. QDomElement channelReferenceElement=
  13197. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13198. QDomNodeList channelConfigData=
  13199. channelReferenceElement.elementsByTagName("attribute");
  13200. QDomElement channelNode;
  13201. QVariantMap channelAttributes;
  13202. for(int j= 0;j<channelConfigData.size();j++)
  13203. {
  13204. channelNode= channelConfigData.at(j).toElement();
  13205. channelAttributes.insert(channelNode.attribute("name"),
  13206. channelNode.attribute("value"));
  13207. }
  13208. ModbusScanItem scanItem;
  13209. QString format= channelAttributes.value("format").toString();
  13210. if(format=="16fixedint")
  13211. {
  13212. scanItem.format= Int16;
  13213. }
  13214. else if(format=="32floathl")
  13215. {
  13216. scanItem.format= FloatHL;
  13217. }
  13218. else if(format=="32floatlh")
  13219. {
  13220. scanItem.format= FloatLH;
  13221. }
  13222. scanItem.request.append((char)channelAttributes.value("station").toInt());
  13223. scanItem.request.append((char)channelAttributes.value("function").toInt());
  13224. quint16 startAddress= (quint16)channelAttributes.value("address").toInt();
  13225. char*startAddressBytes= (char*)&startAddress;
  13226. scanItem.request.append(startAddressBytes[1]);
  13227. scanItem.request.append(startAddressBytes[0]);
  13228. scanItem.request.append((char)0x00);
  13229. if(scanItem.format==Int16)
  13230. {
  13231. scanItem.request.append((char)0x01);
  13232. }
  13233. else
  13234. {
  13235. scanItem.request.append((char)0x02);
  13236. }
  13237. quint16 crc= calculateCRC(scanItem.request);
  13238. char*crcBytes= (char*)&crc;
  13239. scanItem.request.append(crcBytes[0]);
  13240. scanItem.request.append(crcBytes[1]);
  13241. scanItem.decimalPosition= channelAttributes.value("decimals").toInt();
  13242. if(channelAttributes.value("unit").toString()=="C")
  13243. {
  13244. scanItem.unit= Units::Celsius;
  13245. channelTypeList.append("T");
  13246. }
  13247. else if(channelAttributes.value("unit").toString()=="F")
  13248. {
  13249. scanItem.unit= Units::Fahrenheit;
  13250. channelTypeList.append("T");
  13251. }
  13252. else
  13253. {
  13254. scanItem.unit= Units::Unitless;
  13255. channelTypeList.append("C");
  13256. }
  13257. scanList.append(scanItem);
  13258. lastMeasurement.append(0.0);
  13259. channels.append(new Channel);
  13260. channelNames.append(channelAttributes.value("column").toString());
  13261. hiddenStates.append(
  13262. channelAttributes.value("hidden").toString()=="true"?true:false);
  13263. channelLabels.append(model->data(channelIndex,0).toString());
  13264. }
  13265. messageDelayTimer->start();
  13266. }
  13267. ModbusNG::~ModbusNG()
  13268. {
  13269. commTimeout->stop();
  13270. messageDelayTimer->stop();
  13271. port->close();
  13272. }
  13273. void ModbusNG::sendNextMessage()
  13274. {
  13275. if(scanList.length()> 0&&!waiting)
  13276. {
  13277. port->write(scanList.at(scanPosition).request);
  13278. commTimeout->start(2000);
  13279. messageDelayTimer->start(delayTime);
  13280. waiting= true;
  13281. }
  13282. }
  13283. void ModbusNG::timeout()
  13284. {
  13285. qDebug()<<"Communications timeout.";
  13286. messageDelayTimer->start();
  13287. }
  13288. void ModbusNG::rateLimitTimeout()
  13289. {
  13290. messageDelayTimer->start();
  13291. }
  13292. void ModbusNG::dataAvailable()
  13293. {
  13294. if(messageDelayTimer->isActive())
  13295. {
  13296. messageDelayTimer->stop();
  13297. }
  13298. responseBuffer.append(port->readAll());
  13299. if(responseBuffer.size()<5)
  13300. {
  13301. return;
  13302. }
  13303. if(responseBuffer.size()<5+responseBuffer.at(2))
  13304. {
  13305. return;
  13306. }
  13307. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  13308. commTimeout->stop();
  13309. if(calculateCRC(responseBuffer)==0)
  13310. {
  13311. quint16 intresponse;
  13312. float floatresponse;
  13313. char*ibytes= (char*)&intresponse;
  13314. char*fbytes= (char*)&floatresponse;
  13315. double output;
  13316. switch(scanList.at(scanPosition).format)
  13317. {
  13318. case Int16:
  13319. ibytes[0]= responseBuffer.at(4);
  13320. ibytes[1]= responseBuffer.at(3);
  13321. output= intresponse;
  13322. for(int i= 0;i<scanList.at(scanPosition).decimalPosition;i++)
  13323. {
  13324. output/= 10;
  13325. }
  13326. break;
  13327. case FloatHL:
  13328. fbytes[0]= responseBuffer.at(4);
  13329. fbytes[1]= responseBuffer.at(3);
  13330. fbytes[2]= responseBuffer.at(6);
  13331. fbytes[3]= responseBuffer.at(5);
  13332. output= floatresponse;
  13333. break;
  13334. case FloatLH:
  13335. fbytes[0]= responseBuffer.at(6);
  13336. fbytes[1]= responseBuffer.at(5);
  13337. fbytes[2]= responseBuffer.at(4);
  13338. fbytes[3]= responseBuffer.at(3);
  13339. output= floatresponse;
  13340. break;
  13341. }
  13342. if(scanList.at(scanPosition).unit==Units::Celsius)
  13343. {
  13344. output= output*9.0/5.0+32.0;
  13345. }
  13346. scanList.at(scanPosition).lastValue= output;
  13347. }
  13348. else
  13349. {
  13350. qDebug()<<"CRC failed";
  13351. }
  13352. scanPosition= (scanPosition+1)%scanList.size();
  13353. if(scanPosition==0)
  13354. {
  13355. QTime time= QTime::currentTime();
  13356. bool doOutput= false;
  13357. for(int i= 0;i<scanList.size();i++)
  13358. {
  13359. if(scanList.at(i).lastValue!=lastMeasurement.at(i))
  13360. {
  13361. doOutput= true;
  13362. break;
  13363. }
  13364. }
  13365. if(doOutput)
  13366. {
  13367. for(int i= 0;i<scanList.size();i++)
  13368. {
  13369. lastMeasurement[i]= scanList.at(i).lastValue;
  13370. if(scanList.at(scanPosition).unit==Units::Unitless)
  13371. {
  13372. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Unitless));
  13373. }
  13374. else
  13375. {
  13376. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Fahrenheit));
  13377. }
  13378. }
  13379. }
  13380. }
  13381. responseBuffer.clear();
  13382. waiting= false;
  13383. if(scanPosition==0)
  13384. {
  13385. rateLimiter->start();
  13386. }
  13387. else
  13388. {
  13389. messageDelayTimer->start(delayTime);
  13390. }
  13391. }
  13392. quint16 ModbusNG::calculateCRC(QByteArray data)
  13393. {
  13394. quint16 retval= 0xFFFF;
  13395. int i= 0;
  13396. while(i<data.size())
  13397. {
  13398. retval^= 0x00FF&(quint16)data.at(i);
  13399. for(int j= 0;j<8;j++)
  13400. {
  13401. if(retval&1)
  13402. {
  13403. retval= (retval>>1)^0xA001;
  13404. }
  13405. else
  13406. {
  13407. retval>>= 1;
  13408. }
  13409. }
  13410. i++;
  13411. }
  13412. return retval;
  13413. }
  13414. int ModbusNG::channelCount()
  13415. {
  13416. return channels.size();
  13417. }
  13418. Channel*ModbusNG::getChannel(int channel)
  13419. {
  13420. return channels.at(channel);
  13421. }
  13422. QString ModbusNG::channelColumnName(int channel)
  13423. {
  13424. return channelNames.at(channel);
  13425. }
  13426. QString ModbusNG::channelIndicatorText(int channel)
  13427. {
  13428. return channelLabels.at(channel);
  13429. }
  13430. bool ModbusNG::isChannelHidden(int channel)
  13431. {
  13432. return hiddenStates.at(channel);
  13433. }
  13434. QString ModbusNG::channelType(int channel)
  13435. {
  13436. return channelTypeList.at(channel);
  13437. }
  13438. /*:914*/
  13439. #line 615 "./typica.w"
  13440. /*1139:*/
  13441. #line 33 "./thresholdannotation.w"
  13442. ThresholdAnnotationConfWidget::ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  13443. const QModelIndex&index)
  13444. :BasicDeviceConfigurationWidget(model,index)
  13445. {
  13446. QFormLayout*layout= new QFormLayout;
  13447. QLineEdit*source= new QLineEdit;
  13448. layout->addRow(tr("Source column name:"),source);
  13449. QDoubleSpinBox*value= new QDoubleSpinBox;
  13450. value->setMinimum(-9999.99);
  13451. value->setMaximum(9999.99);
  13452. value->setDecimals(2);
  13453. layout->addRow(tr("Threshold value:"),value);
  13454. QComboBox*direction= new QComboBox;
  13455. direction->addItem(tr("Ascending"));
  13456. direction->addItem(tr("Descending"));
  13457. layout->addRow(tr("Direction:"),direction);
  13458. QLineEdit*annotation= new QLineEdit;
  13459. layout->addRow(tr("Annotation:"),annotation);
  13460. /*807:*/
  13461. #line 16791 "./typica.w"
  13462. QDomElement referenceElement=
  13463. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13464. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13465. QDomElement node;
  13466. /*:807*/
  13467. #line 52 "./thresholdannotation.w"
  13468. for(int i= 0;i<configData.size();i++)
  13469. {
  13470. node= configData.at(i).toElement();
  13471. if(node.attribute("name")=="source")
  13472. {
  13473. source->setText(node.attribute("value"));
  13474. }
  13475. else if(node.attribute("name")=="value")
  13476. {
  13477. value->setValue(node.attribute("value").toDouble());
  13478. }
  13479. else if(node.attribute("name")=="direction")
  13480. {
  13481. direction->setCurrentIndex(node.attribute("value").toInt());
  13482. }
  13483. else if(node.attribute("name")=="annotation")
  13484. {
  13485. annotation->setText(node.attribute("value"));
  13486. }
  13487. }
  13488. updateSourceColumn(source->text());
  13489. updateThreshold(value->value());
  13490. updateDirection(direction->currentIndex());
  13491. updateAnnotation(annotation->text());
  13492. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  13493. connect(value,SIGNAL(valueChanged(double)),this,SLOT(updateThreshold(double)));
  13494. connect(direction,SIGNAL(currentIndexChanged(int)),this,SLOT(updateDirection(int)));
  13495. connect(annotation,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotation(QString)));
  13496. setLayout(layout);
  13497. }
  13498. /*:1139*//*1140:*/
  13499. #line 86 "./thresholdannotation.w"
  13500. void ThresholdAnnotationConfWidget::updateSourceColumn(const QString&source)
  13501. {
  13502. updateAttribute("source",source);
  13503. }
  13504. void ThresholdAnnotationConfWidget::updateThreshold(double value)
  13505. {
  13506. updateAttribute("value",QString("%1").arg(value));
  13507. }
  13508. void ThresholdAnnotationConfWidget::updateDirection(int direction)
  13509. {
  13510. updateAttribute("direction",QString("%1").arg(direction));
  13511. }
  13512. void ThresholdAnnotationConfWidget::updateAnnotation(const QString&annotation)
  13513. {
  13514. updateAttribute("annotation",annotation);
  13515. }
  13516. /*:1140*/
  13517. #line 616 "./typica.w"
  13518. /*1144:*/
  13519. #line 152 "./thresholdannotation.w"
  13520. Annotator::Annotator(const QString&text):QObject(NULL),note(text)
  13521. {
  13522. t.setInterval(0);
  13523. t.setSingleShot(true);
  13524. connect(&t,SIGNAL(timeout()),this,SLOT(catchTimer()));
  13525. }
  13526. void Annotator::setAnnotation(const QString&annotation)
  13527. {
  13528. note= annotation;
  13529. }
  13530. void Annotator::setTemperatureColumn(int tempcolumn)
  13531. {
  13532. tc= tempcolumn;
  13533. }
  13534. void Annotator::setAnnotationColumn(int annotationcolumn)
  13535. {
  13536. ac= annotationcolumn;
  13537. }
  13538. /*:1144*//*1145:*/
  13539. #line 181 "./thresholdannotation.w"
  13540. void Annotator::catchTimer()
  13541. {
  13542. emit annotation(note,tc,ac);
  13543. }
  13544. void Annotator::annotate()
  13545. {
  13546. t.start();
  13547. }
  13548. /*:1145*/
  13549. #line 617 "./typica.w"
  13550. /*:4*//*260:*/
  13551. #line 6189 "./typica.w"
  13552. /*257:*/
  13553. #line 6152 "./typica.w"
  13554. void ScriptValidator::fixup(QString&input)const
  13555. {
  13556. QScriptEngine*engine= AppInstance->engine;
  13557. engine->pushContext();
  13558. input= engine->evaluate(input).toString();
  13559. engine->popContext();
  13560. }
  13561. /*:257*//*258:*/
  13562. #line 6165 "./typica.w"
  13563. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  13564. {
  13565. if(v)
  13566. {
  13567. if(v->validate(input,pos)==QValidator::Acceptable)
  13568. {
  13569. return QValidator::Acceptable;
  13570. }
  13571. }
  13572. return QValidator::Intermediate;
  13573. }
  13574. /*:258*//*259:*/
  13575. #line 6180 "./typica.w"
  13576. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  13577. :QValidator(parent),v(validator)
  13578. {
  13579. }
  13580. /*:259*/
  13581. #line 6190 "./typica.w"
  13582. /*:260*//*700:*/
  13583. #line 160 "./plugins.w"
  13584. /*697:*/
  13585. #line 92 "./plugins.w"
  13586. PluginAction::PluginAction(const QFileInfo&info,QObject*parent):
  13587. QAction(parent),preRunScript(""),postRunScript("")
  13588. {
  13589. pluginFile= info.absoluteFilePath();
  13590. setText(info.baseName());
  13591. connect(this,SIGNAL(triggered()),this,SLOT(runScript()));
  13592. }
  13593. void PluginAction::runScript()
  13594. {
  13595. QFile file(pluginFile);
  13596. if(file.open(QIODevice::ReadOnly))
  13597. {
  13598. QScriptEngine*engine= AppInstance->engine;
  13599. QScriptContext*context= engine->pushContext();
  13600. if(parent()->dynamicPropertyNames().contains("activationObject"))
  13601. {
  13602. QScriptValue activationObject=
  13603. parent()->property("activationObject").value<QScriptValue> ();
  13604. context->setActivationObject(activationObject);
  13605. }
  13606. QString script(file.readAll());
  13607. QScriptValue retval= engine->evaluate(preRunScript+script+postRunScript,pluginFile);
  13608. if(engine->hasUncaughtException())
  13609. {
  13610. qDebug()<<"Uncaught exception: "<<
  13611. engine->uncaughtException().toString()<<
  13612. " in "<<pluginFile<<" line: "<<
  13613. engine->uncaughtExceptionLineNumber();
  13614. }
  13615. engine->popContext();
  13616. file.close();
  13617. }
  13618. }
  13619. /*:697*//*698:*/
  13620. #line 131 "./plugins.w"
  13621. QString PluginAction::preRun()
  13622. {
  13623. return preRunScript;
  13624. }
  13625. QString PluginAction::postRun()
  13626. {
  13627. return postRunScript;
  13628. }
  13629. void PluginAction::setPreRun(const QString&script)
  13630. {
  13631. preRunScript= script;
  13632. }
  13633. void PluginAction::setPostRun(const QString&script)
  13634. {
  13635. postRunScript= script;
  13636. }
  13637. /*:698*/
  13638. #line 161 "./plugins.w"
  13639. #line 14752 "./typica.w"
  13640. #line 1 "./daterangeselector.w"
  13641. /*:700*//*881:*/
  13642. #line 89 "./colorsettings.w"
  13643. /*879:*/
  13644. #line 40 "./colorsettings.w"
  13645. ColorSettingsWidget::ColorSettingsWidget():QWidget(NULL)
  13646. {
  13647. QFormLayout*layout= new QFormLayout;
  13648. QCheckBox*enable= new QCheckBox(tr("Enable Javalytics communication"));
  13649. QSettings settings;
  13650. enable->setChecked(settings.value("settings/color/javalytics/enable",false).toBool());
  13651. QLineEdit*address= new QLineEdit();
  13652. address->setText(settings.value("settings/color/javalytics/address","192.168.1.10").toString());
  13653. QSpinBox*scale= new QSpinBox();
  13654. scale->setMinimum(1);
  13655. scale->setMaximum(4);
  13656. scale->setValue(settings.value("settings/color/javalytics/scale",1).toInt());
  13657. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnable(bool)));
  13658. connect(address,SIGNAL(textChanged(QString)),this,SLOT(updateAddress(QString)));
  13659. connect(scale,SIGNAL(valueChanged(int)),this,SLOT(updateScale(int)));
  13660. layout->addRow(enable);
  13661. layout->addRow(tr("IP Address:"),address);
  13662. layout->addRow(tr("Scale Number:"),scale);
  13663. updateEnable(enable->isChecked());
  13664. updateAddress(address->text());
  13665. updateScale(scale->value());
  13666. setLayout(layout);
  13667. }
  13668. /*:879*//*880:*/
  13669. #line 68 "./colorsettings.w"
  13670. void ColorSettingsWidget::updateEnable(bool enable)
  13671. {
  13672. QSettings settings;
  13673. settings.setValue("settings/color/javalytics/enable",enable);
  13674. }
  13675. void ColorSettingsWidget::updateAddress(const QString&address)
  13676. {
  13677. QSettings settings;
  13678. settings.setValue("settings/color/javalytics/address",address);
  13679. }
  13680. void ColorSettingsWidget::updateScale(int scale)
  13681. {
  13682. QSettings settings;
  13683. settings.setValue("settings/color/javalytics/scale",scale);
  13684. }
  13685. /*:880*/
  13686. #line 90 "./colorsettings.w"
  13687. #line 66 "./settings.w"
  13688. #line 1 "./advancedsettings.w"
  13689. /*:881*//*885:*/
  13690. #line 60 "./advancedsettings.w"
  13691. /*883:*/
  13692. #line 26 "./advancedsettings.w"
  13693. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  13694. {
  13695. QSettings settings;
  13696. QFormLayout*layout= new QFormLayout;
  13697. QCheckBox*logDiagnostics= new QCheckBox;
  13698. logDiagnostics->setCheckState(
  13699. settings.value("settings/advanced/logging",false).toBool()?
  13700. Qt::Checked:Qt::Unchecked);
  13701. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  13702. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  13703. setLayout(layout);
  13704. }
  13705. /*:883*//*884:*/
  13706. #line 43 "./advancedsettings.w"
  13707. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  13708. {
  13709. QSettings settings;
  13710. settings.setValue("settings/advanced/logging",enabled);
  13711. if(enabled)
  13712. {
  13713. qInstallMsgHandler(messageFileOutput);
  13714. }
  13715. else
  13716. {
  13717. qInstallMsgHandler(0);
  13718. }
  13719. }
  13720. /*:884*/
  13721. #line 61 "./advancedsettings.w"
  13722. #line 18555 "./typica.w"
  13723. /*:885*//*944:*/
  13724. #line 639 "./unsupportedserial.w"
  13725. /*919:*/
  13726. #line 58 "./unsupportedserial.w"
  13727. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  13728. const QModelIndex&index)
  13729. :BasicDeviceConfigurationWidget(model,index),
  13730. deviceSettingsModel(new SaltModel(2)),
  13731. scriptEditor(new QTextEdit)
  13732. {
  13733. scriptEditor->setTabStopWidth(20);
  13734. QVBoxLayout*dummyLayout= new QVBoxLayout;
  13735. QTabWidget*central= new QTabWidget;
  13736. QWidget*deviceConfigurationWidget= new QWidget;
  13737. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  13738. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13739. deviceConfigurationLayout->addWidget(addChannelButton);
  13740. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13741. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  13742. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  13743. QTableView*deviceSettingsView= new QTableView;
  13744. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  13745. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  13746. deviceSettingsView->setModel(deviceSettingsModel);
  13747. deviceConfigurationLayout->addWidget(deviceSettingsView);
  13748. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  13749. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  13750. central->addTab(scriptEditor,tr("Script"));
  13751. dummyLayout->addWidget(central);
  13752. /*807:*/
  13753. #line 16791 "./typica.w"
  13754. QDomElement referenceElement=
  13755. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13756. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13757. QDomElement node;
  13758. /*:807*/
  13759. #line 86 "./unsupportedserial.w"
  13760. for(int i= 0;i<configData.size();i++)
  13761. {
  13762. node= configData.at(i).toElement();
  13763. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13764. {
  13765. int column= 0;
  13766. if(node.attribute("name")=="values")
  13767. {
  13768. column= 1;
  13769. }
  13770. QString data= node.attribute("value");
  13771. if(data.length()> 3)
  13772. {
  13773. data.chop(2);
  13774. data= data.remove(0,2);
  13775. }
  13776. QStringList keyList= data.split(", ");
  13777. for(int j= 0;j<keyList.size();j++)
  13778. {
  13779. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  13780. QVariant(keyList.at(j)),
  13781. Qt::EditRole);
  13782. }
  13783. }
  13784. else if(node.attribute("name")=="script")
  13785. {
  13786. scriptEditor->setPlainText(node.attribute("value"));
  13787. }
  13788. }
  13789. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13790. this,SLOT(updateConfiguration()));
  13791. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  13792. setLayout(dummyLayout);
  13793. }
  13794. /*:919*//*920:*/
  13795. #line 131 "./unsupportedserial.w"
  13796. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  13797. {
  13798. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13799. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13800. }
  13801. /*:920*//*921:*/
  13802. #line 144 "./unsupportedserial.w"
  13803. void UnsupportedSerialDeviceConfWidget::saveScript()
  13804. {
  13805. updateAttribute("script",scriptEditor->toPlainText());
  13806. }
  13807. /*:921*//*922:*/
  13808. #line 155 "./unsupportedserial.w"
  13809. void UnsupportedSerialDeviceConfWidget::addChannel()
  13810. {
  13811. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  13812. }
  13813. /*:922*//*924:*/
  13814. #line 183 "./unsupportedserial.w"
  13815. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  13816. const QModelIndex&index)
  13817. :BasicDeviceConfigurationWidget(model,index),
  13818. channelSettingsModel(new SaltModel(2))
  13819. {
  13820. QFormLayout*layout= new QFormLayout;
  13821. QLineEdit*columnName= new QLineEdit;
  13822. layout->addRow(tr("Column Name:"),columnName);
  13823. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13824. layout->addRow(hideSeries);
  13825. QTableView*channelSettings= new QTableView;
  13826. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  13827. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  13828. channelSettings->setModel(channelSettingsModel);
  13829. layout->addRow(channelSettings);
  13830. setLayout(layout);
  13831. /*807:*/
  13832. #line 16791 "./typica.w"
  13833. QDomElement referenceElement=
  13834. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13835. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13836. QDomElement node;
  13837. /*:807*/
  13838. #line 200 "./unsupportedserial.w"
  13839. for(int i= 0;i<configData.size();i++)
  13840. {
  13841. node= configData.at(i).toElement();
  13842. if(node.attribute("name")=="columnname")
  13843. {
  13844. columnName->setText(node.attribute("value"));
  13845. }
  13846. else if(node.attribute("name")=="hidden")
  13847. {
  13848. hideSeries->setChecked(node.attribute("value")=="true");
  13849. }
  13850. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13851. {
  13852. int column= 0;
  13853. if(node.attribute("name")=="values")
  13854. {
  13855. column= 1;
  13856. }
  13857. QString data= node.attribute("value");
  13858. if(data.length()> 3)
  13859. {
  13860. data.chop(2);
  13861. data= data.remove(0,2);
  13862. }
  13863. QStringList keyList= data.split(", ");
  13864. for(int j= 0;j<keyList.size();j++)
  13865. {
  13866. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  13867. QVariant(keyList.at(j)),
  13868. Qt::EditRole);
  13869. }
  13870. }
  13871. }
  13872. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13873. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13874. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13875. this,SLOT(updateConfiguration()));
  13876. }
  13877. /*:924*//*925:*/
  13878. #line 244 "./unsupportedserial.w"
  13879. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  13880. {
  13881. updateAttribute("columnname",value);
  13882. }
  13883. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  13884. {
  13885. updateAttribute("hidden",hidden?"true":"false");
  13886. }
  13887. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  13888. {
  13889. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13890. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13891. }
  13892. /*:925*/
  13893. #line 640 "./unsupportedserial.w"
  13894. /*932:*/
  13895. #line 371 "./unsupportedserial.w"
  13896. void JavaScriptDevice::start()
  13897. {
  13898. QScriptValue object= scriptengine->newQObject(this);
  13899. /*933:*/
  13900. #line 390 "./unsupportedserial.w"
  13901. QScriptValue settingsObject= scriptengine->newObject();
  13902. QVariantMap::const_iterator i= deviceSettings.constBegin();
  13903. while(i!=deviceSettings.constEnd())
  13904. {
  13905. settingsObject.setProperty(i.key(),i.value().toString());
  13906. i++;
  13907. }
  13908. object.setProperty("settings",settingsObject);
  13909. /*:933*/
  13910. #line 375 "./unsupportedserial.w"
  13911. /*934:*/
  13912. #line 405 "./unsupportedserial.w"
  13913. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  13914. for(int i= 0;i<channelCount();i++)
  13915. {
  13916. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  13917. QScriptValue channelSettingsObject= scriptengine->newObject();
  13918. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  13919. while(j!=channelSettings.at(i).constEnd())
  13920. {
  13921. channelSettingsObject.setProperty(j.key(),j.value().toString());
  13922. j++;
  13923. }
  13924. channelObject.setProperty("settings",channelSettingsObject);
  13925. channelsArray.setProperty(i,channelObject);
  13926. }
  13927. object.setProperty("channels",channelsArray);
  13928. /*:934*/
  13929. #line 376 "./unsupportedserial.w"
  13930. QScriptContext*context= scriptengine->currentContext();
  13931. QScriptValue oldThis= context->thisObject();
  13932. context->setThisObject(object);
  13933. QScriptValue result= scriptengine->evaluate(deviceScript);
  13934. QScriptEngine*engine= scriptengine;
  13935. /*196:*/
  13936. #line 4581 "./typica.w"
  13937. if(engine->hasUncaughtException())
  13938. {
  13939. int line= engine->uncaughtExceptionLineNumber();
  13940. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  13941. result.toString();
  13942. QString trace;
  13943. foreach(trace,engine->uncaughtExceptionBacktrace())
  13944. {
  13945. qDebug()<<trace;
  13946. }
  13947. }
  13948. /*:196*/
  13949. #line 382 "./unsupportedserial.w"
  13950. context->setThisObject(oldThis);
  13951. }
  13952. /*:932*//*937:*/
  13953. #line 446 "./unsupportedserial.w"
  13954. void JavaScriptDevice::stop()
  13955. {
  13956. emit deviceStopRequested();
  13957. }
  13958. /*:937*//*938:*/
  13959. #line 459 "./unsupportedserial.w"
  13960. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  13961. QScriptEngine*engine):
  13962. QObject(NULL),scriptengine(engine)
  13963. {
  13964. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13965. QDomElement deviceReferenceElement=
  13966. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13967. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13968. QDomElement node;
  13969. QStringList deviceKeys;
  13970. QStringList deviceValues;
  13971. for(int i= 0;i<deviceConfigData.size();i++)
  13972. {
  13973. node= deviceConfigData.at(i).toElement();
  13974. if(node.attribute("name")=="keys")
  13975. {
  13976. QString data= node.attribute("value");
  13977. if(data.length()> 3)
  13978. {
  13979. data.chop(2);
  13980. data= data.remove(0,2);
  13981. }
  13982. deviceKeys= data.split(", ");
  13983. }
  13984. else if(node.attribute("name")=="values")
  13985. {
  13986. QString data= node.attribute("value");
  13987. if(data.length()> 3)
  13988. {
  13989. data.chop(2);
  13990. data= data.remove(0,2);
  13991. }
  13992. deviceValues= data.split(", ");
  13993. }
  13994. else if(node.attribute("name")=="script")
  13995. {
  13996. deviceScript= node.attribute("value");
  13997. }
  13998. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  13999. }
  14000. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  14001. {
  14002. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  14003. }
  14004. if(model->hasChildren(index))
  14005. {
  14006. for(int i= 0;i<model->rowCount(index);i++)
  14007. {
  14008. QModelIndex channelIndex= model->index(i,0,index);
  14009. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  14010. channelList.append(new Channel);
  14011. QDomElement channelReferenceElement=
  14012. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  14013. QDomNodeList channelConfigData=
  14014. channelReferenceElement.elementsByTagName("attribute");
  14015. QStringList channelKeys;
  14016. QStringList channelValues;
  14017. for(int j= 0;j<channelConfigData.size();j++)
  14018. {
  14019. node= channelConfigData.at(j).toElement();
  14020. if(node.attribute("name")=="keys")
  14021. {
  14022. QString data= node.attribute("value");
  14023. if(data.length()> 3)
  14024. {
  14025. data.chop(2);
  14026. data= data.remove(0,2);
  14027. }
  14028. channelKeys= data.split(", ");
  14029. }
  14030. else if(node.attribute("name")=="values")
  14031. {
  14032. QString data= node.attribute("value");
  14033. if(data.length()> 3)
  14034. {
  14035. data.chop(2);
  14036. data= data.remove(0,2);
  14037. }
  14038. channelValues= data.split(", ");
  14039. }
  14040. else if(node.attribute("name")=="hidden")
  14041. {
  14042. hiddenState.append(node.attribute("value")=="true");
  14043. }
  14044. else if(node.attribute("name")=="columnname")
  14045. {
  14046. columnNames.append(node.attribute("value"));
  14047. }
  14048. }
  14049. QVariantMap cs;
  14050. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  14051. {
  14052. cs.insert(channelKeys[j],channelValues[j]);
  14053. }
  14054. channelSettings.append(cs);
  14055. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  14056. channelUnits.append(Units::Fahrenheit);
  14057. }
  14058. }
  14059. }
  14060. /*:938*//*939:*/
  14061. #line 564 "./unsupportedserial.w"
  14062. int JavaScriptDevice::channelCount()
  14063. {
  14064. return channelList.length();
  14065. }
  14066. Channel*JavaScriptDevice::getChannel(int channel)
  14067. {
  14068. return channelList.at(channel);
  14069. }
  14070. bool JavaScriptDevice::isChannelHidden(int channel)
  14071. {
  14072. return hiddenState.at(channel);
  14073. }
  14074. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  14075. {
  14076. return channelUnits.at(channel);
  14077. }
  14078. QString JavaScriptDevice::channelColumnName(int channel)
  14079. {
  14080. if(channel>=0&&channel<columnNames.length())
  14081. {
  14082. return columnNames.at(channel);
  14083. }
  14084. return QString();
  14085. }
  14086. QString JavaScriptDevice::channelIndicatorText(int channel)
  14087. {
  14088. return indicatorTexts.at(channel);
  14089. }
  14090. /*:939*//*940:*/
  14091. #line 601 "./unsupportedserial.w"
  14092. void JavaScriptDevice::setTemperatureColumn(int tcol)
  14093. {
  14094. annotationTemperatureColumn= tcol;
  14095. }
  14096. void JavaScriptDevice::setAnnotationColumn(int ncol)
  14097. {
  14098. annotationNoteColumn= ncol;
  14099. }
  14100. /*:940*/
  14101. #line 641 "./unsupportedserial.w"
  14102. /*:944*//*967:*/
  14103. #line 444 "./phidgets.w"
  14104. /*951:*/
  14105. #line 31 "./phidgets.w"
  14106. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  14107. const QModelIndex&index)
  14108. :BasicDeviceConfigurationWidget(model,index)
  14109. {
  14110. QFormLayout*layout= new QFormLayout;
  14111. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  14112. QSpinBox*sampleRate= new QSpinBox;
  14113. sampleRate->setMinimum(40);
  14114. sampleRate->setMaximum(600);
  14115. sampleRate->setSingleStep(40);
  14116. sampleRate->setValue(360);
  14117. /*807:*/
  14118. #line 16791 "./typica.w"
  14119. QDomElement referenceElement=
  14120. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14121. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14122. QDomElement node;
  14123. /*:807*/
  14124. #line 44 "./phidgets.w"
  14125. for(int i= 0;i<configData.size();i++)
  14126. {
  14127. node= configData.at(i).toElement();
  14128. if(node.attribute("name")=="sampleRate")
  14129. {
  14130. sampleRate->setValue(node.attribute("value").toInt());
  14131. }
  14132. }
  14133. updateRate(sampleRate->value());
  14134. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  14135. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  14136. layout->addRow(addChannelButton);
  14137. layout->addRow(tr("Sample rate:"),sampleRate);
  14138. setLayout(layout);
  14139. }
  14140. /*:951*//*952:*/
  14141. #line 66 "./phidgets.w"
  14142. void PhidgetsTemperatureSensorConfWidget::addChannel()
  14143. {
  14144. insertChildNode(tr("Channel"),"phidgets1048channel");
  14145. }
  14146. /*:952*//*953:*/
  14147. #line 74 "./phidgets.w"
  14148. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  14149. {
  14150. updateAttribute("sampleRate",QString("%1").arg(ms));
  14151. }
  14152. /*:953*//*955:*/
  14153. #line 103 "./phidgets.w"
  14154. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  14155. DeviceTreeModel*model,const QModelIndex&index)
  14156. :BasicDeviceConfigurationWidget(model,index),
  14157. tcType(new QComboBox)
  14158. {
  14159. QFormLayout*layout= new QFormLayout;
  14160. QLineEdit*columnName= new QLineEdit;
  14161. layout->addRow(tr("Column Name:"),columnName);
  14162. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  14163. layout->addRow(hideSeries);
  14164. layout->addRow(tr("Thermocouple Type:"),tcType);
  14165. tcType->addItem("Type K","1");
  14166. tcType->addItem("Type J","2");
  14167. tcType->addItem("Type E","3");
  14168. tcType->addItem("Type T","4");
  14169. QSpinBox*channel= new QSpinBox;
  14170. layout->addRow(tr("Channel:"),channel);
  14171. channel->setMinimum(0);
  14172. channel->setMaximum(3);
  14173. setLayout(layout);
  14174. /*807:*/
  14175. #line 16791 "./typica.w"
  14176. QDomElement referenceElement=
  14177. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14178. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14179. QDomElement node;
  14180. /*:807*/
  14181. #line 124 "./phidgets.w"
  14182. for(int i= 0;i<configData.size();i++)
  14183. {
  14184. node= configData.at(i).toElement();
  14185. if(node.attribute("name")=="columnname")
  14186. {
  14187. columnName->setText(node.attribute("value"));
  14188. }
  14189. else if(node.attribute("name")=="hidden")
  14190. {
  14191. hideSeries->setChecked(node.attribute("value")=="true");
  14192. }
  14193. else if(node.attribute("name")=="tctype")
  14194. {
  14195. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  14196. }
  14197. else if(node.attribute("name")=="channel")
  14198. {
  14199. channel->setValue(node.attribute("value").toInt());
  14200. }
  14201. }
  14202. updateColumnName(columnName->text());
  14203. updateHidden(hideSeries->isChecked());
  14204. updateTC(tcType->currentIndex());
  14205. updateChannel(channel->value());
  14206. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  14207. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  14208. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  14209. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  14210. }
  14211. /*:955*//*956:*/
  14212. #line 157 "./phidgets.w"
  14213. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  14214. {
  14215. updateAttribute("columnname",value);
  14216. }
  14217. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  14218. {
  14219. updateAttribute("hidden",hidden?"true":"false");
  14220. }
  14221. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  14222. {
  14223. updateAttribute("tctype",tcType->itemData(index).toString());
  14224. }
  14225. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  14226. {
  14227. updateAttribute("channel",QString("%1").arg(channel));
  14228. }
  14229. /*:956*//*960:*/
  14230. #line 246 "./phidgets.w"
  14231. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  14232. :QObject(NULL),driver("phidget21"),device(NULL)
  14233. {
  14234. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  14235. QDomElement deviceReferenceElement=
  14236. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14237. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  14238. QDomElement node;
  14239. for(int i= 0;i<deviceConfigData.size();i++)
  14240. {
  14241. node= deviceConfigData.at(i).toElement();
  14242. if(node.attribute("name")=="sampleRate")
  14243. {
  14244. sampleTimer.setInterval(node.attribute("value").toInt());
  14245. }
  14246. }
  14247. if(model->hasChildren(index))
  14248. {
  14249. for(int i= 0;i<model->rowCount(index);i++)
  14250. {
  14251. QModelIndex channelIndex= model->index(i,0,index);
  14252. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  14253. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  14254. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  14255. for(int j= 0;j<channelConfigData.size();j++)
  14256. {
  14257. node= channelConfigData.at(j).toElement();
  14258. if(node.attribute("name")=="channel")
  14259. {
  14260. int channelID= node.attribute("value").toInt();
  14261. channelIndices.append(channelID);
  14262. Channel*channel= new Channel;
  14263. channelList.append(channel);
  14264. channelMap.insert(channelID,channel);
  14265. }
  14266. else if(node.attribute("name")=="hidden")
  14267. {
  14268. hiddenState.append(node.attribute("value")=="true");
  14269. }
  14270. else if(node.attribute("name")=="columnname")
  14271. {
  14272. columnNames.append(node.attribute("value"));
  14273. }
  14274. else if(node.attribute("name")=="tctype")
  14275. {
  14276. tctypes.append(node.attribute("value").toInt());
  14277. }
  14278. }
  14279. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  14280. }
  14281. }
  14282. }
  14283. /*:960*//*961:*/
  14284. #line 306 "./phidgets.w"
  14285. int PhidgetsTemperatureSensor::channelCount()
  14286. {
  14287. return channelList.length();
  14288. }
  14289. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  14290. {
  14291. return channelList.at(channel);
  14292. }
  14293. /*:961*//*962:*/
  14294. #line 319 "./phidgets.w"
  14295. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  14296. {
  14297. return hiddenState.at(channel);
  14298. }
  14299. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  14300. {
  14301. if(channel>=0&&channel<columnNames.length())
  14302. {
  14303. return columnNames.at(channel);
  14304. }
  14305. return QString();
  14306. }
  14307. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  14308. {
  14309. if(channel>=0&&channel<indicatorTexts.length())
  14310. {
  14311. return indicatorTexts.at(channel);
  14312. }
  14313. return QString();
  14314. }
  14315. /*:962*//*964:*/
  14316. #line 371 "./phidgets.w"
  14317. void PhidgetsTemperatureSensor::start()
  14318. {
  14319. if(!driver.load())
  14320. {
  14321. driver.setFileName("Phidget21.framework/Phidget21");
  14322. if(!driver.load())
  14323. {
  14324. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14325. tr("Failed to find phidget21. Please install it."));
  14326. return;
  14327. }
  14328. }
  14329. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  14330. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  14331. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  14332. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  14333. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  14334. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  14335. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  14336. {
  14337. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14338. tr("Failed to link a required symbol in phidget21."));
  14339. return;
  14340. }
  14341. createDevice(&device);
  14342. openDevice(device,-1);
  14343. int error;
  14344. if((error= waitForOpen(device,10000)))
  14345. {
  14346. closeDevice(device);
  14347. deleteDevice(device);
  14348. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  14349. tr("CPhidget_waitForAttachment returns error %n",0,error));
  14350. return;
  14351. }
  14352. for(int i= 0;i<channelIndices.length();i++)
  14353. {
  14354. setTCType(device,channelIndices.at(i),tctypes.at(i));
  14355. }
  14356. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  14357. sampleTimer.start();
  14358. }
  14359. /*:964*//*965:*/
  14360. #line 418 "./phidgets.w"
  14361. void PhidgetsTemperatureSensor::getMeasurements()
  14362. {
  14363. double value= 0.0;
  14364. QTime time= QTime::currentTime();
  14365. foreach(int i,channelIndices)
  14366. {
  14367. getTemperature(device,i,&value);
  14368. Measurement measure(value*9.0/5.0+32.0,time);
  14369. channelMap[i]->input(measure);
  14370. }
  14371. }
  14372. /*:965*//*966:*/
  14373. #line 433 "./phidgets.w"
  14374. void PhidgetsTemperatureSensor::stop()
  14375. {
  14376. sampleTimer.stop();
  14377. closeDevice(device);
  14378. deleteDevice(device);
  14379. driver.unload();
  14380. }
  14381. /*:966*/
  14382. #line 445 "./phidgets.w"
  14383. /*:967*//*999:*/
  14384. #line 792 "./phidget22.w"
  14385. /*975:*/
  14386. #line 60 "./phidget22.w"
  14387. PhidgetConfWidget::PhidgetConfWidget(DeviceTreeModel*model,
  14388. const QModelIndex&index)
  14389. :BasicDeviceConfigurationWidget(model,index)
  14390. {
  14391. QHBoxLayout*layout= new QHBoxLayout;
  14392. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  14393. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  14394. layout->addWidget(addChannelButton);
  14395. setLayout(layout);
  14396. }
  14397. void PhidgetConfWidget::addChannel()
  14398. {
  14399. insertChildNode(tr("Channel"),"phidgetchannel");
  14400. }
  14401. /*:975*//*980:*/
  14402. #line 179 "./phidget22.w"
  14403. PhidgetChannelSelector::PhidgetChannelSelector():QComboBox(),manager(NULL)
  14404. {
  14405. #if __APPLE__
  14406. driver.setFileName("Phidget22.framework/Phidget22");
  14407. #else
  14408. driver.setFileName("phidget22");
  14409. #endif
  14410. if(!driver.load())
  14411. {
  14412. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14413. tr("Failed to find phidget22. Please install it."));
  14414. return;
  14415. }
  14416. /*979:*/
  14417. #line 157 "./phidget22.w"
  14418. if((createManager= (PhidgetPointer)driver.resolve("PhidgetManager_create"))==0||
  14419. (setOnAttachManager= (PhidgetPointerCallbackPointer)driver.resolve("PhidgetManager_setOnAttachHandler"))==0||
  14420. (setOnDetachManager= (PhidgetPointerCallbackPointer)driver.resolve("PhidgetManager_setOnDetachHandler"))==0||
  14421. (openManager= (PhidgetPointer)driver.resolve("PhidgetManager_open"))==0||
  14422. (getDeviceName= (PhidgetPointerStringOut)driver.resolve("Phidget_getDeviceName"))==0||
  14423. (getDeviceSerialNumber= (PhidgetPointerIntOut)driver.resolve("Phidget_getDeviceSerialNumber"))==0||
  14424. (getChannel= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannel"))==0||
  14425. (getChannelClass= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannelClass"))==0||
  14426. (getChannelSubclass= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannelSubclass"))==0||
  14427. (getHubPort= (PhidgetPointerIntOut)driver.resolve("Phidget_getHubPort"))==0||
  14428. (closeManager= (PhidgetPointer)driver.resolve("PhidgetManager_close"))==0||
  14429. (deleteManager= (PhidgetPointer)driver.resolve("PhidgetManager_delete"))==0)
  14430. {
  14431. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14432. tr("Failed to link a required symbol in phidget22."));
  14433. return;
  14434. }
  14435. /*:979*/
  14436. #line 193 "./phidget22.w"
  14437. createManager(&manager);
  14438. setOnAttachManager(manager,ChannelListAddChannel,this);
  14439. setOnDetachManager(manager,ChannelListRemoveChannel,this);
  14440. openManager(manager);
  14441. }
  14442. /*:980*//*983:*/
  14443. #line 228 "./phidget22.w"
  14444. void PhidgetChannelSelector::addChannel(void*device)
  14445. {
  14446. char*deviceName;
  14447. int deviceSerialNumber;
  14448. int channel;
  14449. int channelClass;
  14450. int channelSubclass;
  14451. int hubPort;
  14452. getDeviceName(device,&deviceName);
  14453. getDeviceSerialNumber(device,&deviceSerialNumber);
  14454. getChannel(device,&channel);
  14455. getChannelClass(device,&channelClass);
  14456. getChannelSubclass(device,&channelSubclass);
  14457. getHubPort(device,&hubPort);
  14458. QMap<QString,QVariant> itemData;
  14459. if(channelClass==28)
  14460. {
  14461. itemData.insert("serialNumber",QString("%1").arg(deviceSerialNumber));
  14462. itemData.insert("channel",QString("%1").arg(channel));
  14463. itemData.insert("class",QString("%1").arg(channelClass));
  14464. itemData.insert("subclass",QString("%1").arg(channelSubclass));
  14465. itemData.insert("hubport",QString("%1").arg(hubPort));
  14466. addItem(QString("%1: %2").arg(deviceName).arg(channel),QVariant(itemData));
  14467. }
  14468. }
  14469. /*:983*//*984:*/
  14470. #line 266 "./phidget22.w"
  14471. void PhidgetChannelSelector::removeChannel(void*device)
  14472. {
  14473. int deviceSerialNumber;
  14474. getDeviceSerialNumber(device,&deviceSerialNumber);
  14475. for(int i= count()-1;i>=0;i--)
  14476. {
  14477. QMap<QString,QVariant> data= itemData(i).toMap();
  14478. if(data.value("serialNumber").toInt()==deviceSerialNumber)
  14479. {
  14480. removeItem(i);
  14481. }
  14482. }
  14483. }
  14484. /*:984*//*985:*/
  14485. #line 285 "./phidget22.w"
  14486. PhidgetChannelSelector::~PhidgetChannelSelector()
  14487. {
  14488. if(manager!=NULL)
  14489. {
  14490. closeManager(manager);
  14491. deleteManager(&manager);
  14492. }
  14493. }
  14494. /*:985*//*987:*/
  14495. #line 330 "./phidget22.w"
  14496. PhidgetChannelConfWidget::PhidgetChannelConfWidget(DeviceTreeModel*model,
  14497. const QModelIndex&index)
  14498. :BasicDeviceConfigurationWidget(model,index),
  14499. channelSelector(new PhidgetChannelSelector),
  14500. serialNumber(new QLineEdit),
  14501. channel(new QLineEdit),
  14502. hubPort(new QLineEdit),
  14503. subtype(new QComboBox),
  14504. subtypeLayout(new QStackedLayout),
  14505. tctype(new QComboBox),
  14506. rtdtype(new QComboBox),
  14507. rtdwiring(new QComboBox)
  14508. {
  14509. QVBoxLayout*outerLayout= new QVBoxLayout;
  14510. QFormLayout*layout= new QFormLayout;
  14511. QLineEdit*columnName= new QLineEdit;
  14512. subtype->addItem(tr("IC"),QVariant(1));
  14513. subtype->addItem(tr("RTD"),QVariant(32));
  14514. subtype->addItem(tr("Thermocouple"),QVariant(33));
  14515. layout->addRow(tr("Channels:"),channelSelector);
  14516. layout->addRow(tr("Column Name:"),columnName);
  14517. QCheckBox*hidden= new QCheckBox(tr("Hide channel"));
  14518. layout->addRow(hidden);
  14519. layout->addRow(tr("Serial Number:"),serialNumber);
  14520. layout->addRow(tr("Hub Port:"),hubPort);
  14521. layout->addRow(tr("Channel Number:"),channel);
  14522. layout->addRow(tr("Channel Type:"),subtype);
  14523. serialNumber->setEnabled(false);
  14524. channel->setEnabled(false);
  14525. subtype->setEnabled(false);
  14526. outerLayout->addLayout(layout);
  14527. QWidget*icconfiguration= new QWidget;
  14528. QWidget*rtdconfiguration= new QWidget;
  14529. QFormLayout*rtdconfigurationLayout= new QFormLayout;
  14530. rtdtype->addItem(tr("PT100 with .00385 curve"),QVariant(1));
  14531. rtdtype->addItem(tr("PT1000 with .00385 curve"),QVariant(2));
  14532. rtdtype->addItem(tr("PT100 with .00392 curve"),QVariant(3));
  14533. rtdtype->addItem(tr("PT1000 with .00392 curve"),QVariant(4));
  14534. rtdconfigurationLayout->addRow(tr("RTD type:"),rtdtype);
  14535. rtdwiring->addItem(tr("2 wire"),QVariant(1));
  14536. rtdwiring->addItem(tr("3 wire"),QVariant(2));
  14537. rtdwiring->addItem(tr("4 wire"),QVariant(3));
  14538. rtdconfigurationLayout->addRow(tr("RTD wiring:"),rtdwiring);
  14539. rtdconfiguration->setLayout(rtdconfigurationLayout);
  14540. QWidget*tcconfiguration= new QWidget;
  14541. QFormLayout*tcconfigurationLayout= new QFormLayout;
  14542. tctype->addItem(tr("Type J"),QVariant(1));
  14543. tctype->addItem(tr("Type K"),QVariant(2));
  14544. tctype->addItem(tr("Type E"),QVariant(3));
  14545. tctype->addItem(tr("Type T"),QVariant(4));
  14546. tcconfigurationLayout->addRow(tr("Thermocouple type:"),tctype);
  14547. tcconfiguration->setLayout(tcconfigurationLayout);
  14548. subtypeLayout->addWidget(icconfiguration);
  14549. subtypeLayout->addWidget(rtdconfiguration);
  14550. subtypeLayout->addWidget(tcconfiguration);
  14551. /*807:*/
  14552. #line 16791 "./typica.w"
  14553. QDomElement referenceElement=
  14554. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14555. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14556. QDomElement node;
  14557. /*:807*/
  14558. #line 387 "./phidget22.w"
  14559. for(int i= 0;i<configData.size();i++)
  14560. {
  14561. node= configData.at(i).toElement();
  14562. if(node.attribute("name")=="serialnumber")
  14563. {
  14564. serialNumber->setText(node.attribute("value"));
  14565. }
  14566. else if(node.attribute("name")=="channel")
  14567. {
  14568. channel->setText(node.attribute("value"));
  14569. }
  14570. else if(node.attribute("name")=="columnname")
  14571. {
  14572. columnName->setText(node.attribute("value"));
  14573. }
  14574. else if(node.attribute("name")=="channeltype")
  14575. {
  14576. subtype->setCurrentIndex(subtype->
  14577. findData(QVariant(node.attribute("value").toInt())));
  14578. subtypeLayout->setCurrentIndex(subtype->currentIndex());
  14579. }
  14580. else if(node.attribute("name")=="tctype")
  14581. {
  14582. tctype->setCurrentIndex(tctype->
  14583. findData(QVariant(node.attribute("value").toInt())));
  14584. }
  14585. else if(node.attribute("name")=="rtdtype")
  14586. {
  14587. rtdtype->setCurrentIndex(rtdtype->
  14588. findData(QVariant(node.attribute("value").toInt())));
  14589. }
  14590. else if(node.attribute("name")=="rtdwiring")
  14591. {
  14592. rtdwiring->setCurrentIndex(rtdwiring->
  14593. findData(QVariant(node.attribute("value").toInt())));
  14594. }
  14595. else if(node.attribute("name")=="hubport")
  14596. {
  14597. hubPort->setText(node.attribute("value"));
  14598. }
  14599. else if(node.attribute("name")=="hidden")
  14600. {
  14601. hidden->setCheckState(node.attribute("value")=="true"?Qt::Checked:Qt::Unchecked);
  14602. }
  14603. }
  14604. outerLayout->addLayout(subtypeLayout);
  14605. setLayout(outerLayout);
  14606. updateSerialNumber(serialNumber->text());
  14607. updateChannel(channel->text());
  14608. updateColumnName(columnName->text());
  14609. updateChannelType(subtype->currentIndex());
  14610. updateTCType(tctype->currentIndex());
  14611. updateRTDType(rtdtype->currentIndex());
  14612. updateRTDWiring(rtdwiring->currentIndex());
  14613. updateHubPort(hubPort->text());
  14614. updateHidden(hidden->checkState());
  14615. connect(channelSelector,SIGNAL(currentIndexChanged(int)),
  14616. this,SLOT(changeSelectedChannel(int)));
  14617. connect(subtype,SIGNAL(currentIndexChanged(int)),
  14618. subtypeLayout,SLOT(setCurrentIndex(int)));
  14619. connect(serialNumber,SIGNAL(textChanged(QString)),
  14620. this,SLOT(updateSerialNumber(QString)));
  14621. connect(channel,SIGNAL(textChanged(QString)),
  14622. this,SLOT(updateChannel(QString)));
  14623. connect(columnName,SIGNAL(textEdited(QString)),
  14624. this,SLOT(updateColumnName(QString)));
  14625. connect(subtype,SIGNAL(currentIndexChanged(int)),
  14626. this,SLOT(updateChannelType(int)));
  14627. connect(tctype,SIGNAL(currentIndexChanged(int)),
  14628. this,SLOT(updateTCType(int)));
  14629. connect(rtdtype,SIGNAL(currentIndexChanged(int)),
  14630. this,SLOT(updateRTDType(int)));
  14631. connect(rtdwiring,SIGNAL(currentIndexChanged(int)),
  14632. this,SLOT(updateRTDWiring(int)));
  14633. connect(hubPort,SIGNAL(textChanged(QString)),
  14634. this,SLOT(updateHubPort(QString)));
  14635. connect(hidden,SIGNAL(stateChanged(int)),
  14636. this,SLOT(updateHidden(int)));
  14637. }
  14638. /*:987*//*988:*/
  14639. #line 471 "./phidget22.w"
  14640. void PhidgetChannelConfWidget::changeSelectedChannel(int index)
  14641. {
  14642. QMap<QString,QVariant> data= channelSelector->itemData(index).toMap();
  14643. serialNumber->setText(data.value("serialNumber").toString());
  14644. channel->setText(data.value("channel").toString());
  14645. subtype->setCurrentIndex(subtype->
  14646. findData(QVariant(data.value("subclass").toString().toInt())));
  14647. hubPort->setText(data.value("hubport").toString());
  14648. }
  14649. /*:988*//*989:*/
  14650. #line 484 "./phidget22.w"
  14651. void PhidgetChannelConfWidget::updateSerialNumber(const QString&value)
  14652. {
  14653. updateAttribute("serialnumber",value);
  14654. }
  14655. void PhidgetChannelConfWidget::updateChannel(const QString&value)
  14656. {
  14657. updateAttribute("channel",value);
  14658. }
  14659. void PhidgetChannelConfWidget::updateColumnName(const QString&value)
  14660. {
  14661. updateAttribute("columnname",value);
  14662. }
  14663. void PhidgetChannelConfWidget::updateChannelType(int value)
  14664. {
  14665. updateAttribute("channeltype",subtype->itemData(value).toString());
  14666. }
  14667. void PhidgetChannelConfWidget::updateTCType(int value)
  14668. {
  14669. updateAttribute("tctype",tctype->itemData(value).toString());
  14670. }
  14671. void PhidgetChannelConfWidget::updateRTDType(int value)
  14672. {
  14673. updateAttribute("rtdtype",rtdtype->itemData(value).toString());
  14674. }
  14675. void PhidgetChannelConfWidget::updateRTDWiring(int value)
  14676. {
  14677. updateAttribute("rtdwiring",rtdwiring->itemData(value).toString());
  14678. }
  14679. void PhidgetChannelConfWidget::updateHubPort(const QString&value)
  14680. {
  14681. updateAttribute("hubport",value);
  14682. }
  14683. void PhidgetChannelConfWidget::updateHidden(int value)
  14684. {
  14685. updateAttribute("hidden",value==0?"false":"true");
  14686. }
  14687. /*:989*//*992:*/
  14688. #line 593 "./phidget22.w"
  14689. Phidget22::Phidget22(const QModelIndex&index):QObject(NULL)
  14690. {
  14691. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  14692. if(model->hasChildren(index))
  14693. {
  14694. for(int i= 0;i<model->rowCount(index);i++)
  14695. {
  14696. QModelIndex channelIndex= model->index(i,0,index);
  14697. QDomElement channelReference= model->
  14698. referenceElement(model->data(channelIndex,32).toString());
  14699. QDomElement channelReferenceElement= model->
  14700. referenceElement(model->
  14701. data(channelIndex,Qt::UserRole).toString());
  14702. QDomNodeList channelConfigData=
  14703. channelReferenceElement.elementsByTagName("attribute");
  14704. PhidgetChannelData*c= new PhidgetChannelData;
  14705. c->channel= new Channel;
  14706. c->indicatorLabel=
  14707. model->data(channelIndex,Qt::DisplayRole).toString();
  14708. c->device= NULL;
  14709. c->hubPort= -1;
  14710. for(int j= 0;j<channelConfigData.size();j++)
  14711. {
  14712. QDomElement node= channelConfigData.at(j).toElement();
  14713. if(node.attribute("name")=="serialnumber")
  14714. {
  14715. c->serialNumber= node.attribute("value").toInt();
  14716. }
  14717. else if(node.attribute("name")=="channel")
  14718. {
  14719. c->channelNumber= node.attribute("value").toInt();
  14720. }
  14721. else if(node.attribute("name")=="channeltype")
  14722. {
  14723. c->channelType= node.attribute("value").toInt();
  14724. }
  14725. else if(node.attribute("name")=="tctype")
  14726. {
  14727. c->tcType= node.attribute("value").toInt();
  14728. }
  14729. else if(node.attribute("name")=="rtdtype")
  14730. {
  14731. c->rtdType= node.attribute("value").toInt();
  14732. }
  14733. else if(node.attribute("name")=="rtdwiring")
  14734. {
  14735. c->wiring= node.attribute("value").toInt();
  14736. }
  14737. else if(node.attribute("name")=="hidden")
  14738. {
  14739. c->hidden= (node.attribute("value")=="true");
  14740. }
  14741. else if(node.attribute("name")=="columnname")
  14742. {
  14743. c->columnName= node.attribute("value");
  14744. }
  14745. else if(node.attribute("name")=="hubport")
  14746. {
  14747. c->hubPort= node.attribute("value").toInt();
  14748. }
  14749. }
  14750. channelConfiguration.append(c);
  14751. }
  14752. }
  14753. }
  14754. /*:992*//*993:*/
  14755. #line 663 "./phidget22.w"
  14756. int Phidget22::channelCount()
  14757. {
  14758. return channelConfiguration.length();
  14759. }
  14760. Channel*Phidget22::getChannel(int channel)
  14761. {
  14762. return channelConfiguration.at(channel)->channel;
  14763. }
  14764. /*:993*//*994:*/
  14765. #line 677 "./phidget22.w"
  14766. bool Phidget22::isChannelHidden(int channel)
  14767. {
  14768. return channelConfiguration.at(channel)->hidden;
  14769. }
  14770. QString Phidget22::channelColumnName(int channel)
  14771. {
  14772. return channelConfiguration.at(channel)->columnName;
  14773. }
  14774. QString Phidget22::channelIndicatorText(int channel)
  14775. {
  14776. return channelConfiguration.at(channel)->indicatorLabel;
  14777. }
  14778. /*:994*//*995:*/
  14779. #line 696 "./phidget22.w"
  14780. void Phidget22::start()
  14781. {
  14782. #if __APPLE__
  14783. driver.setFileName("Phidget22.framework/Phidget22");
  14784. #else
  14785. driver.setFileName("phidget22");
  14786. #endif
  14787. if(!driver.load())
  14788. {
  14789. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14790. tr("Failed to find phidget22. Please install it."));
  14791. return;
  14792. }
  14793. if((p_createTemperatureSensor= (PhidgetPointer)driver.resolve("PhidgetTemperatureSensor_create"))==0||
  14794. (p_setSerialNumber= (PhidgetPointerIntIn)driver.resolve("Phidget_setDeviceSerialNumber"))==0||
  14795. (p_setChannelNumber= (PhidgetPointerIntIn)driver.resolve("Phidget_setChannel"))==0||
  14796. (p_setTCType= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setThermocoupleType"))==0||
  14797. (p_setRTDType= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setRTDType"))==0||
  14798. (p_setRTDWiring= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setRTDWireSetup"))==0||
  14799. (p_setNewDataCallback= (PhidgetPointerVCPointer)driver.resolve("PhidgetTemperatureSensor_setOnTemperatureChangeHandler"))==0||
  14800. (p_open= (PhidgetPointerIntIn)driver.resolve("Phidget_openWaitForAttachment"))==0||
  14801. (p_close= (PhidgetPointer)driver.resolve("Phidget_close"))==0||
  14802. (p_delete= (PhidgetPointer)driver.resolve("PhidgetTemperatureSensor_delete"))==0||
  14803. (p_setHubPort= (PhidgetPointerIntIn)driver.resolve("Phidget_setHubPort"))==0)
  14804. {
  14805. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14806. tr("Failed to link a required symbol in phidget22."));
  14807. return;
  14808. }
  14809. for(int i= 0;i<channelConfiguration.length();i++)
  14810. {
  14811. PhidgetChannelData*c= channelConfiguration.at(i);
  14812. p_createTemperatureSensor(&(c->device));
  14813. p_setSerialNumber(c->device,c->serialNumber);
  14814. p_setChannelNumber(c->device,c->channelNumber);
  14815. switch(c->channelType)
  14816. {
  14817. case 32:
  14818. p_setRTDType(c->device,c->rtdType);
  14819. p_setRTDWiring(c->device,c->wiring);
  14820. break;
  14821. case 33:
  14822. p_setTCType(c->device,c->tcType);
  14823. break;
  14824. default:
  14825. break;
  14826. }
  14827. if(c->hubPort>=0)
  14828. {
  14829. p_setHubPort(c->device,c->hubPort);
  14830. }
  14831. p_setNewDataCallback(c->device,Phidget22ValueCallback,c->channel);
  14832. p_open(c->device,5000);
  14833. }
  14834. }
  14835. /*:995*//*998:*/
  14836. #line 779 "./phidget22.w"
  14837. void Phidget22::stop()
  14838. {
  14839. for(int i= 0;i<channelConfiguration.length();i++)
  14840. {
  14841. PhidgetChannelData*c= channelConfiguration.at(i);
  14842. p_close(c->device);
  14843. p_delete(&(c->device));
  14844. }
  14845. }
  14846. /*:998*/
  14847. #line 793 "./phidget22.w"
  14848. /*:999*//*1013:*/
  14849. #line 19984 "./typica.w"
  14850. /*1011:*/
  14851. #line 19946 "./typica.w"
  14852. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  14853. const QModelIndex&index)
  14854. :BasicDeviceConfigurationWidget(model,index)
  14855. {
  14856. QHBoxLayout*layout= new QHBoxLayout;
  14857. QLabel*label= new QLabel(tr("Cooling Time: "));
  14858. QTimeEdit*editor= new QTimeEdit;
  14859. editor->setDisplayFormat("mm:ss");
  14860. /*807:*/
  14861. #line 16791 "./typica.w"
  14862. QDomElement referenceElement=
  14863. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14864. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14865. QDomElement node;
  14866. /*:807*/
  14867. #line 19955 "./typica.w"
  14868. for(int i= 0;i<configData.size();i++)
  14869. {
  14870. node= configData.at(i).toElement();
  14871. if(node.attribute("name")=="reset")
  14872. {
  14873. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  14874. }
  14875. }
  14876. updateResetTime(editor->time());
  14877. connect(editor,SIGNAL(timeChanged(QTime)),
  14878. this,SLOT(updateResetTime(QTime)));
  14879. layout->addWidget(label);
  14880. layout->addWidget(editor);
  14881. setLayout(layout);
  14882. }
  14883. void CoolingTimerConfWidget::updateResetTime(QTime time)
  14884. {
  14885. updateAttribute("reset",time.toString("mm:ss"));
  14886. }
  14887. /*:1011*/
  14888. #line 19985 "./typica.w"
  14889. /*:1013*//*1018:*/
  14890. #line 20243 "./typica.w"
  14891. /*1015:*/
  14892. #line 20017 "./typica.w"
  14893. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  14894. :BasicDeviceConfigurationWidget(model,index)
  14895. {
  14896. QVBoxLayout*layout= new QVBoxLayout;
  14897. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  14898. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  14899. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  14900. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  14901. QButtonGroup*startOptionGroup= new QButtonGroup;
  14902. startOptionGroup->addButton(startBatchOption,1);
  14903. startOptionGroup->addButton(buttonOption,2);
  14904. startOptionGroup->addButton(thresholdOption,3);
  14905. startBatchOption->setChecked(true);
  14906. QGridLayout*startOptions= new QGridLayout;
  14907. startOptions->addWidget(startBatchOption,0,0);
  14908. startOptions->addWidget(buttonOption,1,0);
  14909. startOptions->addWidget(thresholdOption,2,0);
  14910. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  14911. QLineEdit*buttonTextEdit= new QLineEdit;
  14912. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  14913. buttonTextOptions->addWidget(buttonTextLabel);
  14914. buttonTextOptions->addWidget(buttonTextEdit);
  14915. startOptions->addLayout(buttonTextOptions,1,1);
  14916. QFormLayout*thresholdOptions= new QFormLayout;
  14917. QLineEdit*startColumnName= new QLineEdit;
  14918. QLineEdit*startValue= new QLineEdit;
  14919. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  14920. thresholdOptions->addRow(tr("Value: "),startValue);
  14921. startOptions->addLayout(thresholdOptions,2,1);
  14922. startConfigurationGroup->setLayout(startOptions);
  14923. layout->addWidget(startConfigurationGroup);
  14924. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  14925. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  14926. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  14927. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  14928. QButtonGroup*stopOptionGroup= new QButtonGroup;
  14929. stopOptionGroup->addButton(stopBatchOption,1);
  14930. stopOptionGroup->addButton(stopButtonOption,2);
  14931. stopOptionGroup->addButton(stopThresholdOption,3);
  14932. stopBatchOption->setChecked(true);
  14933. QGridLayout*stopOptions= new QGridLayout;
  14934. stopOptions->addWidget(stopBatchOption,0,0);
  14935. stopOptions->addWidget(stopButtonOption,1,0);
  14936. stopOptions->addWidget(stopThresholdOption,2,0);
  14937. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  14938. QLineEdit*stopButtonEdit= new QLineEdit;
  14939. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  14940. stopButtonTextOptions->addWidget(stopButtonLabel);
  14941. stopButtonTextOptions->addWidget(stopButtonEdit);
  14942. stopOptions->addLayout(stopButtonTextOptions,1,1);
  14943. QLineEdit*stopColumnName= new QLineEdit;
  14944. QLineEdit*stopValue= new QLineEdit;
  14945. QFormLayout*stopThresholdOptions= new QFormLayout;
  14946. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  14947. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  14948. stopOptions->addLayout(stopThresholdOptions,2,1);
  14949. stopConfigurationGroup->setLayout(stopOptions);
  14950. layout->addWidget(stopConfigurationGroup);
  14951. /*807:*/
  14952. #line 16791 "./typica.w"
  14953. QDomElement referenceElement=
  14954. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14955. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14956. QDomElement node;
  14957. /*:807*/
  14958. #line 20079 "./typica.w"
  14959. for(int i= 0;i<configData.size();i++)
  14960. {
  14961. node= configData.at(i).toElement();
  14962. if(node.attribute("name")=="startbuttontext")
  14963. {
  14964. buttonTextEdit->setText(node.attribute("value"));
  14965. }
  14966. else if(node.attribute("name")=="stopbuttontext")
  14967. {
  14968. stopButtonEdit->setText(node.attribute("value"));
  14969. }
  14970. else if(node.attribute("name")=="startcolumnname")
  14971. {
  14972. startColumnName->setText(node.attribute("value"));
  14973. }
  14974. else if(node.attribute("name")=="stopcolumnname")
  14975. {
  14976. stopColumnName->setText(node.attribute("value"));
  14977. }
  14978. else if(node.attribute("name")=="startvalue")
  14979. {
  14980. startValue->setText(node.attribute("value"));
  14981. }
  14982. else if(node.attribute("name")=="stopvalue")
  14983. {
  14984. stopValue->setText(node.attribute("value"));
  14985. }
  14986. else if(node.attribute("name")=="starttrigger")
  14987. {
  14988. if(node.attribute("value")=="batch")
  14989. {
  14990. startBatchOption->setChecked(true);
  14991. }
  14992. else if(node.attribute("value")=="manual")
  14993. {
  14994. buttonOption->setChecked(true);
  14995. }
  14996. else if(node.attribute("value")=="value")
  14997. {
  14998. thresholdOption->setChecked(true);
  14999. }
  15000. }
  15001. else if(node.attribute("name")=="stoptrigger")
  15002. {
  15003. if(node.attribute("value")=="batch")
  15004. {
  15005. stopBatchOption->setChecked(true);
  15006. }
  15007. else if(node.attribute("value")=="manual")
  15008. {
  15009. stopButtonOption->setChecked(true);
  15010. }
  15011. else if(node.attribute("value")=="value")
  15012. {
  15013. stopThresholdOption->setChecked(true);
  15014. }
  15015. }
  15016. }
  15017. updateStartButtonText(buttonTextEdit->text());
  15018. updateStopButtonText(stopButtonEdit->text());
  15019. updateStartColumnName(startColumnName->text());
  15020. updateStopColumnName(stopColumnName->text());
  15021. updateStartValue(startValue->text());
  15022. updateStopValue(stopValue->text());
  15023. updateStartTrigger(startOptionGroup->checkedId());
  15024. updateStopTrigger(stopOptionGroup->checkedId());
  15025. setLayout(layout);
  15026. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  15027. this,SLOT(updateStartButtonText(QString)));
  15028. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  15029. this,SLOT(updateStopButtonText(QString)));
  15030. connect(startColumnName,SIGNAL(textChanged(QString)),
  15031. this,SLOT(updateStartColumnName(QString)));
  15032. connect(stopColumnName,SIGNAL(textChanged(QString)),
  15033. this,SLOT(updateStopColumnName(QString)));
  15034. connect(startValue,SIGNAL(textChanged(QString)),
  15035. this,SLOT(updateStartValue(QString)));
  15036. connect(stopValue,SIGNAL(textChanged(QString)),
  15037. this,SLOT(updateStopValue(QString)));
  15038. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  15039. this,SLOT(updateStartTrigger(int)));
  15040. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  15041. this,SLOT(updateStopTrigger(int)));
  15042. }
  15043. /*:1015*//*1016:*/
  15044. #line 20169 "./typica.w"
  15045. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  15046. {
  15047. updateAttribute("startbuttontext",text);
  15048. }
  15049. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  15050. {
  15051. updateAttribute("stopbuttontext",text);
  15052. }
  15053. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  15054. {
  15055. updateAttribute("startcolumnname",text);
  15056. }
  15057. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  15058. {
  15059. updateAttribute("stopcolumnname",text);
  15060. }
  15061. void RangeTimerConfWidget::updateStartValue(const QString&text)
  15062. {
  15063. updateAttribute("startvalue",text);
  15064. }
  15065. void RangeTimerConfWidget::updateStopValue(const QString&text)
  15066. {
  15067. updateAttribute("stopvalue",text);
  15068. }
  15069. void RangeTimerConfWidget::updateStartTrigger(int option)
  15070. {
  15071. switch(option)
  15072. {
  15073. case 1:
  15074. updateAttribute("starttrigger","batch");
  15075. break;
  15076. case 2:
  15077. updateAttribute("starttrigger","manual");
  15078. break;
  15079. case 3:
  15080. updateAttribute("starttrigger","value");
  15081. break;
  15082. default:
  15083. break;
  15084. }
  15085. }
  15086. void RangeTimerConfWidget::updateStopTrigger(int option)
  15087. {
  15088. switch(option)
  15089. {
  15090. case 1:
  15091. updateAttribute("stoptrigger","batch");
  15092. break;
  15093. case 2:
  15094. updateAttribute("stoptrigger","manual");
  15095. break;
  15096. case 3:
  15097. updateAttribute("stoptrigger","value");
  15098. break;
  15099. default:
  15100. break;
  15101. }
  15102. }
  15103. /*:1016*/
  15104. #line 20244 "./typica.w"
  15105. /*:1018*//*1023:*/
  15106. #line 20344 "./typica.w"
  15107. /*1020:*/
  15108. #line 20268 "./typica.w"
  15109. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  15110. const QModelIndex&index)
  15111. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  15112. {
  15113. QFormLayout*layout= new QFormLayout;
  15114. QLineEdit*trigger= new QLineEdit;
  15115. layout->addRow(tr("Trigger column name:"),trigger);
  15116. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  15117. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  15118. QTableView*rangeTable= new QTableView;
  15119. rangeTable->setModel(tablemodel);
  15120. layout->addRow(tr("Range data:"),rangeTable);
  15121. /*807:*/
  15122. #line 16791 "./typica.w"
  15123. QDomElement referenceElement=
  15124. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15125. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15126. QDomElement node;
  15127. /*:807*/
  15128. #line 20281 "./typica.w"
  15129. for(int i= 0;i<configData.size();i++)
  15130. {
  15131. node= configData.at(i).toElement();
  15132. if(node.attribute("name")=="trigger")
  15133. {
  15134. trigger->setText(node.attribute("value"));
  15135. }
  15136. else if(node.attribute("name")=="rangenames")
  15137. {
  15138. QString data= node.attribute("value");
  15139. if(data.length()> 3)
  15140. {
  15141. data.chop(2);
  15142. data= data.remove(0,2);
  15143. }
  15144. QStringList itemList= data.split(", ");
  15145. for(int j= 0;j<itemList.size();j++)
  15146. {
  15147. QString item= itemList.at(j);
  15148. item.chop(1);
  15149. item= item.remove(0,1);
  15150. tablemodel->setData(tablemodel->index(j,0),
  15151. QVariant(item),Qt::DisplayRole);
  15152. }
  15153. }
  15154. else if(node.attribute("name")=="endtemps")
  15155. {
  15156. /*1006:*/
  15157. #line 19876 "./typica.w"
  15158. QString data= node.attribute("value");
  15159. if(data.length()> 3)
  15160. {
  15161. data.chop(2);
  15162. data= data.remove(0,2);
  15163. }
  15164. QStringList itemList= data.split(",");
  15165. /*:1006*/
  15166. #line 20309 "./typica.w"
  15167. int column= 1;
  15168. /*1007:*/
  15169. #line 19888 "./typica.w"
  15170. for(int j= 0;j<itemList.size();j++)
  15171. {
  15172. tablemodel->setData(tablemodel->index(j,column),
  15173. QVariant(itemList.at(j).toDouble()),
  15174. Qt::DisplayRole);
  15175. }
  15176. /*:1007*/
  15177. #line 20311 "./typica.w"
  15178. }
  15179. }
  15180. updateColumnName(trigger->text());
  15181. updateRangeData();
  15182. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  15183. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  15184. setLayout(layout);
  15185. }
  15186. /*:1020*//*1021:*/
  15187. #line 20325 "./typica.w"
  15188. void MultiRangeTimerConfWidget::updateRangeData()
  15189. {
  15190. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  15191. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  15192. }
  15193. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  15194. {
  15195. updateAttribute("trigger",text);
  15196. }
  15197. /*:1021*/
  15198. #line 20345 "./typica.w"
  15199. /*:1023*//*1041:*/
  15200. #line 265 "./rate.w"
  15201. /*1037:*/
  15202. #line 191 "./rate.w"
  15203. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  15204. :BasicDeviceConfigurationWidget(model,index)
  15205. {
  15206. QFormLayout*layout= new QFormLayout;
  15207. QLineEdit*column= new QLineEdit;
  15208. layout->addRow(tr("Primary series column name:"),column);
  15209. QSpinBox*cacheTime= new QSpinBox;
  15210. cacheTime->setMinimum(0);
  15211. cacheTime->setMaximum(300);
  15212. layout->addRow(tr("Cache time:"),cacheTime);
  15213. QSpinBox*scaleTime= new QSpinBox;
  15214. scaleTime->setMinimum(1);
  15215. scaleTime->setMaximum(300);
  15216. layout->addRow(tr("Scale time:"),scaleTime);
  15217. /*807:*/
  15218. #line 16791 "./typica.w"
  15219. QDomElement referenceElement=
  15220. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15221. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15222. QDomElement node;
  15223. /*:807*/
  15224. #line 206 "./rate.w"
  15225. for(int i= 0;i<configData.size();i++)
  15226. {
  15227. node= configData.at(i).toElement();
  15228. if(node.attribute("name")=="column")
  15229. {
  15230. column->setText(node.attribute("value"));
  15231. }
  15232. else if(node.attribute("name")=="cache")
  15233. {
  15234. cacheTime->setValue(node.attribute("value").toInt());
  15235. }
  15236. else if(node.attribute("name")=="scale")
  15237. {
  15238. scaleTime->setValue(node.attribute("value").toInt());
  15239. }
  15240. }
  15241. updateColumn(column->text());
  15242. updateCacheTime(cacheTime->text());
  15243. updateScaleTime(scaleTime->text());
  15244. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  15245. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  15246. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  15247. setLayout(layout);
  15248. }
  15249. /*:1037*//*1038:*/
  15250. #line 235 "./rate.w"
  15251. void RateOfChangeConfWidget::updateColumn(const QString&column)
  15252. {
  15253. updateAttribute("column",column);
  15254. }
  15255. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  15256. {
  15257. updateAttribute("cache",seconds);
  15258. }
  15259. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  15260. {
  15261. updateAttribute("scale",seconds);
  15262. }
  15263. /*:1038*/
  15264. #line 266 "./rate.w"
  15265. #line 20452 "./typica.w"
  15266. #line 1 "./mergeseries.w"
  15267. /*:1041*//*1055:*/
  15268. #line 282 "./mergeseries.w"
  15269. /*1051:*/
  15270. #line 183 "./mergeseries.w"
  15271. MergeSeriesConfWidget::MergeSeriesConfWidget(DeviceTreeModel*model,
  15272. const QModelIndex&index)
  15273. :BasicDeviceConfigurationWidget(model,index)
  15274. {
  15275. QFormLayout*layout= new QFormLayout;
  15276. QComboBox*type= new QComboBox;
  15277. type->addItem(tr("Difference"),QVariant("Difference"));
  15278. type->addItem(tr("Mean"),QVariant("Mean"));
  15279. layout->addRow(tr("Series type:"),type);
  15280. QLineEdit*column1= new QLineEdit;
  15281. layout->addRow(tr("First input column name:"),column1);
  15282. QLineEdit*column2= new QLineEdit;
  15283. layout->addRow(tr("Second input column name:"),column2);
  15284. QLineEdit*output= new QLineEdit;
  15285. layout->addRow(tr("Output column name:"),output);
  15286. /*807:*/
  15287. #line 16791 "./typica.w"
  15288. QDomElement referenceElement=
  15289. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15290. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15291. QDomElement node;
  15292. /*:807*/
  15293. #line 199 "./mergeseries.w"
  15294. for(int i= 0;i<configData.size();i++)
  15295. {
  15296. node= configData.at(i).toElement();
  15297. if(node.attribute("name")=="type")
  15298. {
  15299. type->setCurrentIndex(type->findData(node.attribute("value")));
  15300. }
  15301. else if(node.attribute("name")=="column1")
  15302. {
  15303. column1->setText(node.attribute("value"));
  15304. }
  15305. else if(node.attribute("name")=="column2")
  15306. {
  15307. column2->setText(node.attribute("value"));
  15308. }
  15309. else if(node.attribute("name")=="output")
  15310. {
  15311. output->setText(node.attribute("value"));
  15312. }
  15313. }
  15314. updateColumn1(column1->text());
  15315. updateColumn2(column2->text());
  15316. updateOutput(output->text());
  15317. updateType(type->currentIndex());
  15318. connect(column1,SIGNAL(textEdited(QString)),this,SLOT(updateColumn1(QString)));
  15319. connect(column2,SIGNAL(textEdited(QString)),this,SLOT(updateColumn2(QString)));
  15320. connect(output,SIGNAL(textEdited(QString)),this,SLOT(updateOutput(QString)));
  15321. connect(type,SIGNAL(currentIndexChanged(int)),this,SLOT(updateType(int)));
  15322. setLayout(layout);
  15323. }
  15324. /*:1051*//*1052:*/
  15325. #line 233 "./mergeseries.w"
  15326. void MergeSeriesConfWidget::updateColumn1(const QString&column)
  15327. {
  15328. updateAttribute("column1",column);
  15329. }
  15330. void MergeSeriesConfWidget::updateColumn2(const QString&column)
  15331. {
  15332. updateAttribute("column2",column);
  15333. }
  15334. void MergeSeriesConfWidget::updateOutput(const QString&column)
  15335. {
  15336. updateAttribute("output",column);
  15337. }
  15338. void MergeSeriesConfWidget::updateType(int index)
  15339. {
  15340. switch(index)
  15341. {
  15342. case 0:
  15343. updateAttribute("type","Difference");
  15344. break;
  15345. case 1:
  15346. updateAttribute("type","Mean");
  15347. break;
  15348. default:
  15349. break;
  15350. }
  15351. }
  15352. /*:1052*/
  15353. #line 283 "./mergeseries.w"
  15354. /*1043:*/
  15355. #line 59 "./mergeseries.w"
  15356. void MergeSeries::in1(Measurement measure)
  15357. {
  15358. last1= measure;
  15359. received1= true;
  15360. if(received1&&received2)
  15361. {
  15362. calculate(last1,last2);
  15363. received1= false;
  15364. received2= false;
  15365. }
  15366. }
  15367. void MergeSeries::in2(Measurement measure)
  15368. {
  15369. last2= measure;
  15370. received2= true;
  15371. if(received1&&received2)
  15372. {
  15373. calculate(last1,last2);
  15374. received1= false;
  15375. received2= false;
  15376. }
  15377. }
  15378. /*:1043*//*1044:*/
  15379. #line 86 "./mergeseries.w"
  15380. MergeSeries::MergeSeries():QObject(NULL),received1(false),received2(false)
  15381. {
  15382. }
  15383. /*:1044*//*1045:*/
  15384. #line 97 "./mergeseries.w"
  15385. void DifferenceSeries::calculate(Measurement m1,Measurement m2)
  15386. {
  15387. Measurement outval(m1.temperature()-m2.temperature(),
  15388. (m1.time()> m2.time()?m1.time():m2.time()));
  15389. outval.insert("relative",true);
  15390. emit newData(outval);
  15391. }
  15392. void MeanSeries::calculate(Measurement m1,Measurement m2)
  15393. {
  15394. Measurement outval((m1.temperature()+m2.temperature())/2,
  15395. (m1.time()> m2.time()?m1.time():m2.time()));
  15396. emit newData(outval);
  15397. }
  15398. /*:1045*//*1046:*/
  15399. #line 115 "./mergeseries.w"
  15400. DifferenceSeries::DifferenceSeries():MergeSeries()
  15401. {
  15402. }
  15403. MeanSeries::MeanSeries():MergeSeries()
  15404. {
  15405. }
  15406. /*:1046*/
  15407. #line 284 "./mergeseries.w"
  15408. #line 20454 "./typica.w"
  15409. #line 1 "./dataqsdk.w"
  15410. /*:1055*//*1170:*/
  15411. #line 344 "./user.w"
  15412. /*1165:*/
  15413. #line 232 "./user.w"
  15414. NewTypicaUser::NewTypicaUser():QDialog(),
  15415. userField(new QLineEdit),passwordField(new QLineEdit),
  15416. autoLogin(new QCheckBox(tr("Log in automatically"))),
  15417. saveAndCloseButton(new QPushButton(tr("Save and Close"))),
  15418. saveAndNewButton(new QPushButton(tr("Save and Create Another"))),
  15419. cancelButton(new QPushButton(tr("Cancel")))
  15420. {
  15421. setModal(true);
  15422. QVBoxLayout*mainLayout= new QVBoxLayout;
  15423. QFormLayout*form= new QFormLayout;
  15424. QHBoxLayout*buttons= new QHBoxLayout;
  15425. form->addRow(tr("Name:"),userField);
  15426. passwordField->setEchoMode(QLineEdit::Password);
  15427. form->addRow(tr("Password:"),passwordField);
  15428. form->addRow(autoLogin);
  15429. buttons->addWidget(cancelButton);
  15430. buttons->addStretch();
  15431. buttons->addWidget(saveAndNewButton);
  15432. buttons->addWidget(saveAndCloseButton);
  15433. mainLayout->addLayout(form);
  15434. mainLayout->addLayout(buttons);
  15435. setLayout(mainLayout);
  15436. setWindowTitle(tr("Create New User"));
  15437. connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
  15438. connect(saveAndCloseButton,SIGNAL(clicked()),this,SLOT(createAndClose()));
  15439. connect(saveAndNewButton,SIGNAL(clicked()),this,SLOT(createAndReset()));
  15440. connect(userField,SIGNAL(textChanged(QString)),this,SLOT(validate()));
  15441. }
  15442. /*:1165*//*1166:*/
  15443. #line 264 "./user.w"
  15444. void NewTypicaUser::createAndReset()
  15445. {
  15446. createNewUser();
  15447. userField->setText("");
  15448. passwordField->setText("");
  15449. autoLogin->setChecked(false);
  15450. }
  15451. void NewTypicaUser::createAndClose()
  15452. {
  15453. createNewUser();
  15454. accept();
  15455. }
  15456. void NewTypicaUser::createNewUser()
  15457. {
  15458. SqlQueryConnection h;
  15459. QSqlQuery*dbquery= h.operator->();
  15460. dbquery->prepare("INSERT INTO typica_users (name, password, active, auto_login) VALUES (:name, :password, true, :auto)");
  15461. dbquery->bindValue(":name",userField->text());
  15462. dbquery->bindValue(":password",passwordField->text());
  15463. dbquery->bindValue(":auto",autoLogin->isChecked());
  15464. dbquery->exec();
  15465. cancelButton->setEnabled(true);
  15466. }
  15467. void NewTypicaUser::validate()
  15468. {
  15469. if(!userField->text().isEmpty())
  15470. {
  15471. saveAndCloseButton->setEnabled(true);
  15472. saveAndNewButton->setEnabled(true);
  15473. }
  15474. else
  15475. {
  15476. saveAndCloseButton->setEnabled(false);
  15477. saveAndNewButton->setEnabled(false);
  15478. }
  15479. }
  15480. void NewTypicaUser::cancelValidate()
  15481. {
  15482. SqlQueryConnection h;
  15483. QSqlQuery*dbquery= h.operator->();
  15484. dbquery->exec("SELECT count(1) FROM typica_users");
  15485. if(dbquery->next())
  15486. {
  15487. if(dbquery->value(0).toInt()> 0)
  15488. {
  15489. cancelButton->setEnabled(true);
  15490. return;
  15491. }
  15492. }
  15493. cancelButton->setEnabled(false);
  15494. }
  15495. /*:1166*/
  15496. #line 345 "./user.w"
  15497. /*1161:*/
  15498. #line 177 "./user.w"
  15499. UserLabel::UserLabel():QLabel()
  15500. {
  15501. setTextFormat(Qt::PlainText);
  15502. updateLabel(AppInstance->currentTypicaUser());
  15503. connect(AppInstance,SIGNAL(userChanged(QString)),
  15504. this,SLOT(updateLabel(QString)));
  15505. }
  15506. /*:1161*//*1162:*/
  15507. #line 188 "./user.w"
  15508. void UserLabel::updateLabel(const QString&user)
  15509. {
  15510. setText(QString(tr("Current operator: %1").arg(user)));
  15511. }
  15512. /*:1162*//*1163:*/
  15513. #line 196 "./user.w"
  15514. void UserLabel::mouseReleaseEvent(QMouseEvent*)
  15515. {
  15516. LoginDialog*dialog= new LoginDialog;
  15517. dialog->exec();
  15518. }
  15519. /*:1163*/
  15520. #line 346 "./user.w"
  15521. /*1155:*/
  15522. #line 95 "./user.w"
  15523. LoginDialog::LoginDialog():QDialog(),
  15524. user(new QLineEdit),password(new QLineEdit),
  15525. warning(new QLabel(tr("Log in failed."))),
  15526. login(new QPushButton(tr("Log In")))
  15527. {
  15528. setModal(true);
  15529. QVBoxLayout*mainLayout= new QVBoxLayout;
  15530. warning->setVisible(false);
  15531. password->setEchoMode(QLineEdit::Password);
  15532. QFormLayout*form= new QFormLayout;
  15533. form->addRow(tr("Name:"),user);
  15534. form->addRow(tr("Password:"),password);
  15535. form->addRow(warning);
  15536. QHBoxLayout*buttonBox= new QHBoxLayout;
  15537. buttonBox->addStretch();
  15538. buttonBox->addWidget(login);
  15539. mainLayout->addLayout(form);
  15540. mainLayout->addLayout(buttonBox);
  15541. connect(login,SIGNAL(clicked()),this,SLOT(attemptLogin()));
  15542. setLayout(mainLayout);
  15543. }
  15544. /*:1155*//*1156:*/
  15545. #line 120 "./user.w"
  15546. void LoginDialog::attemptLogin()
  15547. {
  15548. if(AppInstance->login(user->text(),password->text()))
  15549. {
  15550. accept();
  15551. }
  15552. else
  15553. {
  15554. warning->setVisible(true);
  15555. }
  15556. }
  15557. /*:1156*/
  15558. #line 347 "./user.w"
  15559. #line 20464 "./typica.w"
  15560. #line 1 "./roastcoloredit.w"
  15561. /*:1170*//*1178:*/
  15562. #line 149 "./roastcoloredit.w"
  15563. /*1172:*/
  15564. #line 31 "./roastcoloredit.w"
  15565. RoastColorEdit::RoastColorEdit():edit(new QLineEdit)
  15566. {
  15567. QHBoxLayout*layout= new QHBoxLayout;
  15568. layout->setContentsMargins(0,0,0,0);
  15569. layout->addWidget(edit);
  15570. QSettings settings;
  15571. if(settings.value("settings/color/javalytics/enable",false).toBool())
  15572. {
  15573. QPushButton*button= new QPushButton(tr("Measure"));
  15574. layout->addWidget(button);
  15575. connect(button,SIGNAL(clicked()),this,SLOT(readColor()));
  15576. }
  15577. setLayout(layout);
  15578. }
  15579. /*:1172*//*1173:*/
  15580. #line 50 "./roastcoloredit.w"
  15581. void RoastColorEdit::readColor()
  15582. {
  15583. QSettings settings;
  15584. QUrl postData;
  15585. postData.addQueryItem("calscale",settings.value("settings/color/javalytics/scale",1).toString());
  15586. postData.addQueryItem("webcontrol","20");
  15587. QNetworkRequest request(QUrl("http://"+settings.value("settings/color/javalytics/address","192.168.1.10").toString()+"/index.zhtml"));
  15588. request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
  15589. networkReply= AppInstance->network->post(request,postData.encodedQuery());
  15590. connect(networkReply,SIGNAL(finished()),this,SLOT(measureFinished()));
  15591. }
  15592. /*:1173*//*1174:*/
  15593. #line 66 "./roastcoloredit.w"
  15594. void RoastColorEdit::measureFinished()
  15595. {
  15596. QSettings settings;
  15597. networkReply->deleteLater();
  15598. networkReply= AppInstance->network->get(QNetworkRequest(QUrl("http://"+settings.value("settings/color/javalytics/address","192.168.1.10").toString()+"/data.csv")));
  15599. connect(networkReply,SIGNAL(finished()),this,SLOT(readFinished()));
  15600. }
  15601. /*:1174*//*1175:*/
  15602. #line 93 "./roastcoloredit.w"
  15603. void RoastColorEdit::readFinished()
  15604. {
  15605. QByteArray response= networkReply->readAll();
  15606. networkReply->deleteLater();
  15607. networkReply= 0;
  15608. if(response.size()==0)
  15609. {
  15610. return;
  15611. }
  15612. QList<QByteArray> lines= response.split('\n');
  15613. if(lines.last().size()==0)
  15614. {
  15615. lines.removeLast();
  15616. }
  15617. if(lines.size()==0)
  15618. {
  15619. return;
  15620. }
  15621. QList<QByteArray> fields= lines.last().split(',');
  15622. if(fields.size()<3)
  15623. {
  15624. return;
  15625. }
  15626. edit->setText(QString(fields.at(2)));
  15627. }
  15628. /*:1175*//*1176:*/
  15629. #line 122 "./roastcoloredit.w"
  15630. void RoastColorEdit::setValue(const QString&color)
  15631. {
  15632. edit->setText(color);
  15633. }
  15634. QString RoastColorEdit::value()
  15635. {
  15636. return edit->text();
  15637. }
  15638. /*:1176*/
  15639. #line 150 "./roastcoloredit.w"
  15640. #line 20466 "./typica.w"
  15641. /*:1178*/
  15642. #line 532 "./typica.w"
  15643. /*8:*/
  15644. #line 679 "./typica.w"
  15645. template<class TYPE> TYPE getself(QScriptContext*context)
  15646. {
  15647. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  15648. return self;
  15649. }
  15650. template<> QTime getself(QScriptContext*context)
  15651. {
  15652. QTime self= context->thisObject().toVariant().toTime();
  15653. return self;
  15654. }
  15655. template<> QByteArray getself(QScriptContext*context)
  15656. {
  15657. QByteArray self= context->thisObject().toVariant().toByteArray();
  15658. return self;
  15659. }
  15660. template<> SqlQueryConnection*getself(QScriptContext*context)
  15661. {
  15662. SqlQueryConnection*self=
  15663. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  15664. return self;
  15665. }
  15666. template<> QXmlQuery*getself(QScriptContext*context)
  15667. {
  15668. QXmlQuery*self=
  15669. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  15670. return self;
  15671. }
  15672. template<> QXmlStreamWriter*getself(QScriptContext*context)
  15673. {
  15674. QXmlStreamWriter*self=
  15675. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  15676. return self;
  15677. }
  15678. template<> QXmlStreamReader*getself(QScriptContext*context)
  15679. {
  15680. QXmlStreamReader*self=
  15681. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  15682. return self;
  15683. }
  15684. /*:8*//*9:*/
  15685. #line 730 "./typica.w"
  15686. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  15687. {
  15688. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  15689. return argument;
  15690. }
  15691. template<> QString argument(int arg,QScriptContext*context)
  15692. {
  15693. return context->argument(arg).toString();
  15694. }
  15695. template<> QVariant argument(int arg,QScriptContext*context)
  15696. {
  15697. return context->argument(arg).toVariant();
  15698. }
  15699. template<> int argument(int arg,QScriptContext*context)
  15700. {
  15701. return context->argument(arg).toInt32();
  15702. }
  15703. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  15704. {
  15705. return(SqlQueryConnection*)
  15706. qscriptvalue_cast<void*> (context->argument(arg));
  15707. }
  15708. template<> QModelIndex argument(int arg,QScriptContext*context)
  15709. {
  15710. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  15711. }
  15712. template<> double argument(int arg,QScriptContext*context)
  15713. {
  15714. return(double)(context->argument(arg).toNumber());
  15715. }
  15716. template<> Units::Unit argument(int arg,QScriptContext*context)
  15717. {
  15718. return(Units::Unit)(context->argument(arg).toInt32());
  15719. }
  15720. template<> QByteArray argument(int arg,QScriptContext*context)
  15721. {
  15722. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  15723. }
  15724. template<> bool argument(int arg,QScriptContext*context)
  15725. {
  15726. return context->argument(arg).toBool();
  15727. }
  15728. /*:9*//*13:*/
  15729. #line 829 "./typica.w"
  15730. void setQObjectProperties(QScriptValue value,QScriptEngine*engine)
  15731. {
  15732. value.setProperty("setProperty",engine->newFunction(QObject_setProperty));
  15733. }
  15734. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*)
  15735. {
  15736. QObject*self= getself<QObject*> (context);
  15737. self->setProperty(argument<QString> (0,context).toUtf8().constData(),
  15738. argument<QVariant> (1,context));
  15739. return QScriptValue();
  15740. }
  15741. /*:13*//*15:*/
  15742. #line 851 "./typica.w"
  15743. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  15744. {
  15745. }
  15746. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  15747. {
  15748. }
  15749. /*:15*//*18:*/
  15750. #line 883 "./typica.w"
  15751. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  15752. {
  15753. setQObjectProperties(value,engine);
  15754. }
  15755. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  15756. {
  15757. QScriptValue object= engine->newQObject(new QTimer);
  15758. setQTimerProperties(object,engine);
  15759. return object;
  15760. }
  15761. /*:18*//*21:*/
  15762. #line 925 "./typica.w"
  15763. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  15764. {
  15765. QScriptValue object= engine->newQObject(new QWidget);
  15766. setQWidgetProperties(object,engine);
  15767. return object;
  15768. }
  15769. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  15770. {
  15771. setQObjectProperties(value,engine);
  15772. setQPaintDeviceProperties(value,engine);
  15773. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  15774. value.setProperty("activateWindow",
  15775. engine->newFunction(QWidget_activateWindow));
  15776. }
  15777. /*:21*//*22:*/
  15778. #line 947 "./typica.w"
  15779. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  15780. {
  15781. if(context->argumentCount()==1)
  15782. {
  15783. QWidget*self= getself<QWidget*> (context);
  15784. QLayout*layout= argument<QLayout*> (0,context);
  15785. if(layout)
  15786. {
  15787. self->setLayout(layout);
  15788. }
  15789. else
  15790. {
  15791. context->throwError("Incorrect argument type passed to "
  15792. "QWidget::setLayout(). This method requires "
  15793. "a QLayout.");
  15794. }
  15795. }
  15796. else
  15797. {
  15798. context->throwError("Incorrect number of arguments passed to "
  15799. "QWidget::setLayout(). This method takes one "
  15800. "QLayout as an argument.");
  15801. }
  15802. return QScriptValue();
  15803. }
  15804. QScriptValue QWidget_activateWindow(QScriptContext*context,
  15805. QScriptEngine*)
  15806. {
  15807. QWidget*self= getself<QWidget*> (context);
  15808. self->activateWindow();
  15809. return QScriptValue();
  15810. }
  15811. /*:22*//*25:*/
  15812. #line 1012 "./typica.w"
  15813. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  15814. {
  15815. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  15816. argument<QString> (0,context),
  15817. argument<QString> (1,context),
  15818. QMessageBox::Ok|QMessageBox::Cancel);
  15819. if(selection==QMessageBox::Ok){
  15820. return QScriptValue(true);
  15821. }
  15822. return QScriptValue(false);
  15823. }
  15824. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  15825. {
  15826. QMessageBox::critical(NULL,argument<QString> (0,context),
  15827. argument<QString> (1,context));
  15828. return QScriptValue();
  15829. }
  15830. QScriptValue displayInfo(QScriptContext*context,QScriptEngine*)
  15831. {
  15832. QMessageBox::information(NULL,argument<QString> (0,context),
  15833. argument<QString> (1,context));
  15834. return QScriptValue();
  15835. }
  15836. /*:25*//*27:*/
  15837. #line 1097 "./typica.w"
  15838. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  15839. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  15840. {
  15841. if(!AppInstance->databaseConnected())
  15842. {
  15843. statusBar()->addWidget(new QLabel(tr("Not connected to database")));
  15844. }
  15845. else
  15846. {
  15847. statusBar()->addWidget(new UserLabel);
  15848. }
  15849. }
  15850. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  15851. {
  15852. QSettings settings;
  15853. settings.beginGroup(key);
  15854. settings.setValue("pos",pos());
  15855. settings.setValue("size",size());
  15856. settings.endGroup();
  15857. }
  15858. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  15859. {
  15860. QSettings settings;
  15861. settings.beginGroup(key);
  15862. if(settings.contains("size"))
  15863. {
  15864. resize(settings.value("size").toSize());
  15865. }
  15866. if(settings.contains("pos"))
  15867. {
  15868. move(settings.value("pos").toPoint());
  15869. }
  15870. settings.endGroup();
  15871. }
  15872. void ScriptQMainWindow::displayStatus(const QString&message)
  15873. {
  15874. statusBar()->showMessage(message);
  15875. }
  15876. void ScriptQMainWindow::showEvent(QShowEvent*event)
  15877. {
  15878. if(!event->spontaneous())
  15879. {
  15880. /*32:*/
  15881. #line 1221 "./typica.w"
  15882. QSettings settings;
  15883. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  15884. toByteArray());
  15885. /*:32*/
  15886. #line 1144 "./typica.w"
  15887. event->accept();
  15888. }
  15889. else
  15890. {
  15891. event->ignore();
  15892. }
  15893. }
  15894. void ScriptQMainWindow::show()
  15895. {
  15896. QMainWindow::show();
  15897. }
  15898. void ScriptQMainWindow::setupFinished()
  15899. {
  15900. emit windowReady();
  15901. }
  15902. /*:27*//*28:*/
  15903. #line 1170 "./typica.w"
  15904. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  15905. {
  15906. if(isWindowModified()){
  15907. /*29:*/
  15908. #line 1184 "./typica.w"
  15909. QMessageBox::StandardButton result;
  15910. result= QMessageBox::warning(this,"Typica",closePrompt(),
  15911. QMessageBox::Ok|QMessageBox::Cancel);
  15912. if(result==QMessageBox::Cancel)
  15913. {
  15914. event->ignore();
  15915. return;
  15916. }
  15917. /*:29*/
  15918. #line 1174 "./typica.w"
  15919. }
  15920. emit aboutToClose();
  15921. /*31:*/
  15922. #line 1215 "./typica.w"
  15923. QSettings settings;
  15924. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  15925. /*:31*/
  15926. #line 1177 "./typica.w"
  15927. event->accept();
  15928. }
  15929. /*:28*//*30:*/
  15930. #line 1196 "./typica.w"
  15931. QString ScriptQMainWindow::closePrompt()
  15932. {
  15933. return cprompt;
  15934. }
  15935. void ScriptQMainWindow::setClosePrompt(QString prompt)
  15936. {
  15937. cprompt= prompt;
  15938. }
  15939. /*:30*//*35:*/
  15940. #line 1249 "./typica.w"
  15941. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  15942. {
  15943. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  15944. setQMainWindowProperties(object,engine);
  15945. return object;
  15946. }
  15947. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  15948. {
  15949. setQWidgetProperties(value,engine);
  15950. value.setProperty("setCentralWidget",
  15951. engine->newFunction(QMainWindow_setCentralWidget));
  15952. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  15953. }
  15954. /*:35*//*36:*/
  15955. #line 1271 "./typica.w"
  15956. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  15957. QScriptEngine*)
  15958. {
  15959. if(context->argumentCount()==1)
  15960. {
  15961. QMainWindow*self= getself<QMainWindow*> (context);
  15962. QWidget*widget= argument<QWidget*> (0,context);
  15963. if(widget)
  15964. {
  15965. self->setCentralWidget(widget);
  15966. }
  15967. else
  15968. {
  15969. context->throwError("Incorrect argument type passed to "
  15970. "QMainWindow::setCentralWidget(). This "
  15971. "method requires a QWidget.");
  15972. }
  15973. }
  15974. else
  15975. {
  15976. context->throwError("Incorrect number of arguments passed to "
  15977. "QMainWindow::setCentralWidget(). This method "
  15978. "takes one QWidget as an argument.");
  15979. }
  15980. return QScriptValue();
  15981. }
  15982. /*:36*//*37:*/
  15983. #line 1305 "./typica.w"
  15984. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  15985. {
  15986. QScriptValue object;
  15987. if(context->argumentCount()==0)
  15988. {
  15989. QMainWindow*self= getself<QMainWindow*> (context);
  15990. QMenuBar*bar= self->menuBar();
  15991. object= engine->newQObject(bar);
  15992. setQMenuBarProperties(object,engine);
  15993. }
  15994. else
  15995. {
  15996. context->throwError("Incorrect number of arguments passed to "
  15997. "QMainWindow::menuBar(). This method takes no "
  15998. "arguments.");
  15999. }
  16000. return object;
  16001. }
  16002. /*:37*//*39:*/
  16003. #line 1335 "./typica.w"
  16004. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  16005. {
  16006. setQWidgetProperties(value,engine);
  16007. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  16008. }
  16009. /*:39*//*40:*/
  16010. #line 1350 "./typica.w"
  16011. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  16012. {
  16013. QScriptValue object;
  16014. if(context->argumentCount()==1)
  16015. {
  16016. QMenuBar*self= getself<QMenuBar*> (context);
  16017. QString title= argument<QString> (0,context);
  16018. object= engine->newQObject(self->addMenu(title));
  16019. setQMenuProperties(object,engine);
  16020. }
  16021. else
  16022. {
  16023. context->throwError("Incorrect number of arguments passed to "
  16024. "QMenuBar::addMenu(). This method takes one "
  16025. "string as an argument.");
  16026. }
  16027. return object;
  16028. }
  16029. /*:40*//*42:*/
  16030. #line 1380 "./typica.w"
  16031. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  16032. {
  16033. setQWidgetProperties(value,engine);
  16034. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  16035. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  16036. }
  16037. /*:42*//*43:*/
  16038. #line 1390 "./typica.w"
  16039. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  16040. {
  16041. if(context->argumentCount()==1)
  16042. {
  16043. QMenu*self= getself<QMenu*> (context);
  16044. QAction*action= argument<QAction*> (0,context);
  16045. if(action)
  16046. {
  16047. self->addAction(action);
  16048. }
  16049. else
  16050. {
  16051. context->throwError("Incorrect argument type passed to "
  16052. "QMenu::addAction(). This method requires a "
  16053. "QAction.");
  16054. }
  16055. }
  16056. else
  16057. {
  16058. context->throwError("Incorrect number of arguments passed to "
  16059. "QMenu::addAction(). This method takes one "
  16060. "QAction as an argument.");
  16061. }
  16062. return QScriptValue();
  16063. }
  16064. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  16065. {
  16066. if(context->argumentCount()==0)
  16067. {
  16068. QMenu*self= getself<QMenu*> (context);
  16069. self->addSeparator();
  16070. }
  16071. else
  16072. {
  16073. context->throwError("Incorrect number of arguments passed to "
  16074. "QMenu::addSeparator(). This method takes no "
  16075. "arguments.");
  16076. }
  16077. return QScriptValue();
  16078. }
  16079. /*:43*//*46:*/
  16080. #line 1452 "./typica.w"
  16081. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  16082. {
  16083. QScriptValue object= engine->newQObject(new QFrame);
  16084. setQFrameProperties(object,engine);
  16085. return object;
  16086. }
  16087. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  16088. {
  16089. setQWidgetProperties(value,engine);
  16090. }
  16091. /*:46*//*49:*/
  16092. #line 1486 "./typica.w"
  16093. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  16094. {
  16095. QString text;
  16096. if(context->argumentCount()==1)
  16097. {
  16098. text= argument<QString> (0,context);
  16099. }
  16100. QScriptValue object= engine->newQObject(new QLabel(text));
  16101. setQLabelProperties(object,engine);
  16102. return object;
  16103. }
  16104. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  16105. {
  16106. setQFrameProperties(value,engine);
  16107. }
  16108. /*:49*//*52:*/
  16109. #line 1528 "./typica.w"
  16110. QScriptValue constructQSvgWidget(QScriptContext*,
  16111. QScriptEngine*engine)
  16112. {
  16113. QScriptValue object= engine->newQObject(new QSvgWidget);
  16114. setQSvgWidgetProperties(object,engine);
  16115. return object;
  16116. }
  16117. /*:52*//*53:*/
  16118. #line 1539 "./typica.w"
  16119. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  16120. {
  16121. setQWidgetProperties(value,engine);
  16122. value.setProperty("loadDevice",
  16123. engine->newFunction(QSvgWidget_loadDevice));
  16124. }
  16125. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  16126. {
  16127. if(context->argumentCount()==1)
  16128. {
  16129. QSvgWidget*self= getself<QSvgWidget*> (context);
  16130. QIODevice*device= argument<QIODevice*> (0,context);
  16131. device->reset();
  16132. QByteArray data= device->readAll();
  16133. self->load(data);
  16134. }
  16135. else
  16136. {
  16137. context->throwError("Incorrect number of arguments passed to "
  16138. "QSvgWidget::loadData(). This method takes one "
  16139. "QIODevice as an argument.");
  16140. }
  16141. return QScriptValue();
  16142. }
  16143. /*:53*//*55:*/
  16144. #line 1577 "./typica.w"
  16145. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  16146. QStack<QLayout*> *layoutStack)
  16147. {
  16148. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16149. QSvgWidget*widget= new QSvgWidget;
  16150. layout->addWidget(widget);
  16151. QString id= element.attribute("id");
  16152. if(!id.isEmpty())
  16153. {
  16154. widget->setObjectName(id);
  16155. }
  16156. }
  16157. /*:55*//*58:*/
  16158. #line 1610 "./typica.w"
  16159. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  16160. {
  16161. QScriptValue object= engine->newQObject(new QLineEdit());
  16162. setQLineEditProperties(object,engine);
  16163. return object;
  16164. }
  16165. /*:58*//*59:*/
  16166. #line 1621 "./typica.w"
  16167. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  16168. {
  16169. setQWidgetProperties(value,engine);
  16170. }
  16171. /*:59*//*62:*/
  16172. #line 1659 "./typica.w"
  16173. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  16174. {
  16175. QScriptValue object= engine->newQObject(new QSplitter);
  16176. setQSplitterProperties(object,engine);
  16177. return object;
  16178. }
  16179. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  16180. {
  16181. setQFrameProperties(value,engine);
  16182. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  16183. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  16184. value.setProperty("restoreState",
  16185. engine->newFunction(QSplitter_restoreState));
  16186. value.setProperty("count",engine->newFunction(QSplitter_count));
  16187. value.setProperty("setCollapsible",engine->newFunction(QSplitter_setCollapsible));
  16188. }
  16189. /*:62*//*63:*/
  16190. #line 1681 "./typica.w"
  16191. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  16192. {
  16193. if(context->argumentCount()==1)
  16194. {
  16195. QSplitter*self= getself<QSplitter*> (context);
  16196. QWidget*widget= argument<QWidget*> (0,context);
  16197. if(widget)
  16198. {
  16199. self->addWidget(widget);
  16200. }
  16201. else
  16202. {
  16203. context->throwError("Incorrect argument type passed to "
  16204. "QSplitter::addWidget(). This method "
  16205. "requires a QWidget.");
  16206. }
  16207. }
  16208. else
  16209. {
  16210. context->throwError("Incorrect number of arguments passed to "
  16211. "QSplitter::addWidget(). This method takes one "
  16212. "QWidget as an argument.");
  16213. }
  16214. return QScriptValue();
  16215. }
  16216. /*:63*//*64:*/
  16217. #line 1718 "./typica.w"
  16218. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  16219. {
  16220. QSplitter*self= getself<QSplitter*> (context);
  16221. return QScriptValue(self->count());
  16222. }
  16223. /*:64*//*65:*/
  16224. #line 1731 "./typica.w"
  16225. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  16226. {
  16227. if(context->argumentCount()==1)
  16228. {
  16229. QSplitter*self= getself<QSplitter*> (context);
  16230. QString key= argument<QString> (0,context);
  16231. QSettings settings;
  16232. settings.setValue(key,self->saveState());
  16233. }
  16234. else
  16235. {
  16236. context->throwError("Incorrect number of arguments passed to "
  16237. "QSplitter::saveState(). This method takes one "
  16238. "string as an argument.");
  16239. }
  16240. return QScriptValue();
  16241. }
  16242. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  16243. {
  16244. if(context->argumentCount()==1)
  16245. {
  16246. QSplitter*self= getself<QSplitter*> (context);
  16247. QString key= argument<QString> (0,context);
  16248. QSettings settings;
  16249. self->restoreState(settings.value(key).toByteArray());
  16250. }
  16251. else
  16252. {
  16253. context->throwError("Incorrect number of arguments passed to "
  16254. "QSplitter::restoreState(). This method takes "
  16255. "one string as an argument.");
  16256. }
  16257. return QScriptValue();
  16258. }
  16259. /*:65*//*66:*/
  16260. #line 1772 "./typica.w"
  16261. QScriptValue QSplitter_setCollapsible(QScriptContext*context,QScriptEngine*)
  16262. {
  16263. if(context->argumentCount()==2)
  16264. {
  16265. QSplitter*self= getself<QSplitter*> (context);
  16266. self->setCollapsible(argument<int> (0,context),argument<bool> (1,context));
  16267. }
  16268. else
  16269. {
  16270. context->throwError("Incorrect number of arguments");
  16271. }
  16272. return QScriptValue();
  16273. }
  16274. /*:66*//*68:*/
  16275. #line 1803 "./typica.w"
  16276. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  16277. {
  16278. setQLayoutItemProperties(value,engine);
  16279. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  16280. }
  16281. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  16282. {
  16283. if(context->argumentCount()==1)
  16284. {
  16285. QLayout*self= getself<QLayout*> (context);
  16286. QWidget*widget= argument<QWidget*> (0,context);
  16287. if(widget)
  16288. {
  16289. self->addWidget(widget);
  16290. }
  16291. else
  16292. {
  16293. context->throwError("Incorrect argument type passed to "
  16294. "QLayout::addWidget(). This method requires "
  16295. "a QWidget.");
  16296. }
  16297. }
  16298. else
  16299. {
  16300. context->throwError("Incorrect number of arguments passed to "
  16301. "QLayout::addWidget(). This method takes one "
  16302. "QWidget as an argument.");
  16303. }
  16304. return QScriptValue();
  16305. }
  16306. /*:68*//*71:*/
  16307. #line 1870 "./typica.w"
  16308. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  16309. {
  16310. QScriptValue object=
  16311. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  16312. setQBoxLayoutProperties(object,engine);
  16313. return object;
  16314. }
  16315. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  16316. {
  16317. setQLayoutProperties(value,engine);
  16318. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  16319. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  16320. }
  16321. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  16322. {
  16323. if(context->argumentCount()> 0&&context->argumentCount()<3)
  16324. {
  16325. QBoxLayout*self= getself<QBoxLayout*> (context);
  16326. QLayout*layout= argument<QLayout*> (0,context);
  16327. int stretch= 0;
  16328. if(context->argumentCount()==2)
  16329. {
  16330. stretch= argument<int> (1,context);
  16331. }
  16332. if(layout)
  16333. {
  16334. self->addLayout(layout,stretch);
  16335. }
  16336. else
  16337. {
  16338. context->throwError("Incorrect argument type passed to "
  16339. "QLayout::addLayout(). This method requires "
  16340. "a QLayout.");
  16341. }
  16342. }
  16343. else
  16344. {
  16345. context->throwError("Incorrect number of arguments passed to "
  16346. "QLayout::addLayout(). This method takes one "
  16347. "QLayout as an argument and optionally one integer.");
  16348. }
  16349. return QScriptValue();
  16350. }
  16351. /*:71*//*72:*/
  16352. #line 1921 "./typica.w"
  16353. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  16354. {
  16355. if(context->argumentCount()> 0&&context->argumentCount()<4)
  16356. {
  16357. QBoxLayout*self= getself<QBoxLayout*> (context);
  16358. QWidget*widget= argument<QWidget*> (0,context);
  16359. int stretch= 0;
  16360. Qt::Alignment alignment= 0;
  16361. if(context->argumentCount()> 1)
  16362. {
  16363. stretch= argument<int> (1,context);
  16364. }
  16365. if(context->argumentCount()> 2)
  16366. {
  16367. alignment= (Qt::Alignment)(argument<int> (2,context));
  16368. }
  16369. if(widget)
  16370. {
  16371. self->addWidget(widget,stretch,alignment);
  16372. }
  16373. else
  16374. {
  16375. context->throwError("Incorrect argument type passed to "
  16376. "QBoxLayout::addWidget(). This method requires "
  16377. "a QWidget.");
  16378. }
  16379. }
  16380. else
  16381. {
  16382. context->throwError("Incorrect number of arguments passed to "
  16383. "QBoxLayout::addWidget(). This method takes one "
  16384. "QWidget and optionally up to two integers as "
  16385. "arguments.");
  16386. }
  16387. return QScriptValue();
  16388. }
  16389. /*:72*//*75:*/
  16390. #line 1985 "./typica.w"
  16391. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  16392. {
  16393. QScriptValue object= engine->newQObject(new QAction(NULL));
  16394. setQActionProperties(object,engine);
  16395. return object;
  16396. }
  16397. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  16398. {
  16399. setQObjectProperties(value,engine);
  16400. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  16401. }
  16402. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  16403. {
  16404. if(context->argumentCount()==1)
  16405. {
  16406. QAction*self= getself<QAction*> (context);
  16407. self->setShortcut(argument<QString> (0,context));
  16408. }
  16409. else
  16410. {
  16411. context->throwError("Incorrect number of arguments passed to "
  16412. "QAction::setShortcut(). This method takes one "
  16413. "string as an argument.");
  16414. }
  16415. return QScriptValue();
  16416. }
  16417. /*:75*//*78:*/
  16418. #line 2043 "./typica.w"
  16419. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  16420. QScriptEngine*engine)
  16421. {
  16422. QScriptValue retval;
  16423. if(context->argumentCount()==3)
  16424. {
  16425. QWidget*widget= argument<QWidget*> (0,context);
  16426. if(widget)
  16427. {
  16428. QString caption= argument<QString> (1,context);
  16429. QString dir= argument<QString> (2,context);
  16430. retval= QScriptValue(engine,
  16431. QFileDialog::getOpenFileName(widget,caption,
  16432. dir,"",0,0));
  16433. setQFileDialogProperties(retval,engine);
  16434. }
  16435. else
  16436. {
  16437. context->throwError("Incorrect argument type passed to "
  16438. "QFileDialog::getOpenFileName(). The first "
  16439. "argument to this method must be a QWidget.");
  16440. }
  16441. }
  16442. else
  16443. {
  16444. context->throwError("Incorrect number of arguments passed to "
  16445. "QFileDialog::getOpenFileName(). This method "
  16446. "takes one QWidget followed by two strings for a "
  16447. "total of three arguments.");
  16448. }
  16449. return retval;
  16450. }
  16451. /*:78*//*79:*/
  16452. #line 2079 "./typica.w"
  16453. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  16454. QScriptEngine*engine)
  16455. {
  16456. QScriptValue retval;
  16457. if(context->argumentCount()==3)
  16458. {
  16459. QWidget*widget= argument<QWidget*> (0,context);
  16460. if(widget)
  16461. {
  16462. QString caption= argument<QString> (1,context);
  16463. QString dir= argument<QString> (2,context);
  16464. retval= QScriptValue(engine,
  16465. QFileDialog::getSaveFileName(widget,caption,
  16466. dir,"",0,0));
  16467. setQFileDialogProperties(retval,engine);
  16468. }
  16469. else
  16470. {
  16471. context->throwError("Incorrect argument type passed to "
  16472. "QFileDialog::getSaveFileName(). The first "
  16473. "argument to this method must be a QWidget.");
  16474. }
  16475. }
  16476. else
  16477. {
  16478. context->throwError("Incorrect number of arguments passed to "
  16479. "QFileDialog::getSaveFileName(). This method "
  16480. "takes one QWidget followed by two strings for a "
  16481. "total of three arguments.");
  16482. }
  16483. return retval;
  16484. }
  16485. /*:79*//*80:*/
  16486. #line 2116 "./typica.w"
  16487. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  16488. {
  16489. setQDialogProperties(value,engine);
  16490. }
  16491. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  16492. {
  16493. setQWidgetProperties(value,engine);
  16494. }
  16495. /*:80*//*83:*/
  16496. #line 2157 "./typica.w"
  16497. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  16498. {
  16499. QScriptValue object=
  16500. engine->newQObject(new QFile(argument<QString> (0,context)));
  16501. setQFileProperties(object,engine);
  16502. return object;
  16503. }
  16504. /*:83*//*84:*/
  16505. #line 2168 "./typica.w"
  16506. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  16507. {
  16508. setQIODeviceProperties(value,engine);
  16509. value.setProperty("remove",engine->newFunction(QFile_remove));
  16510. }
  16511. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  16512. {
  16513. QFile*self= getself<QFile*> (context);
  16514. bool retval= self->remove();
  16515. return QScriptValue(engine,retval);
  16516. }
  16517. /*:84*//*85:*/
  16518. #line 2190 "./typica.w"
  16519. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  16520. {
  16521. setQObjectProperties(value,engine);
  16522. value.setProperty("open",engine->newFunction(QIODevice_open));
  16523. value.setProperty("close",engine->newFunction(QIODevice_close));
  16524. value.setProperty("readToString",
  16525. engine->newFunction(QIODevice_readToString));
  16526. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  16527. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  16528. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  16529. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  16530. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  16531. value.setProperty("read",engine->newFunction(QIODevice_read));
  16532. }
  16533. /*:85*//*86:*/
  16534. #line 2211 "./typica.w"
  16535. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  16536. {
  16537. QIODevice*self= getself<QIODevice*> (context);
  16538. bool retval= false;
  16539. if(context->argumentCount()==1)
  16540. {
  16541. switch(argument<int> (0,context))
  16542. {
  16543. case 1:
  16544. retval= self->open(QIODevice::ReadOnly);
  16545. break;
  16546. case 2:
  16547. retval= self->open(QIODevice::WriteOnly);
  16548. break;
  16549. case 3:
  16550. retval= self->open(QIODevice::ReadWrite);
  16551. break;
  16552. default:
  16553. break;
  16554. }
  16555. }
  16556. else
  16557. {
  16558. retval= self->open(QIODevice::ReadWrite);
  16559. }
  16560. return QScriptValue(retval);
  16561. }
  16562. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  16563. {
  16564. QIODevice*self= getself<QIODevice*> (context);
  16565. self->close();
  16566. return QScriptValue();
  16567. }
  16568. /*:86*//*87:*/
  16569. #line 2251 "./typica.w"
  16570. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  16571. {
  16572. QIODevice*self= getself<QIODevice*> (context);
  16573. self->reset();
  16574. return QScriptValue(QString(self->readAll()));
  16575. }
  16576. /*:87*//*88:*/
  16577. #line 2267 "./typica.w"
  16578. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  16579. {
  16580. QIODevice*self= getself<QIODevice*> (context);
  16581. if(context->argumentCount()==1)
  16582. {
  16583. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  16584. }
  16585. context->throwError("Incorrect number of arguments passed to "
  16586. "QIODevice::putChar()");
  16587. return QScriptValue();
  16588. }
  16589. /*:88*//*89:*/
  16590. #line 2285 "./typica.w"
  16591. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  16592. {
  16593. QIODevice*self= getself<QIODevice*> (context);
  16594. if(context->argumentCount()==1)
  16595. {
  16596. self->write(argument<QString> (0,context).toUtf8());
  16597. }
  16598. else
  16599. {
  16600. context->throwError("Incorrect number of arguments passed to "
  16601. "QIODevice::writeString()");
  16602. }
  16603. return QScriptValue();
  16604. }
  16605. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  16606. {
  16607. QIODevice*self= getself<QIODevice*> (context);
  16608. if(context->argumentCount()==1)
  16609. {
  16610. self->write(argument<QByteArray> (0,context));
  16611. }
  16612. else
  16613. {
  16614. context->throwError("Incorrect number of arguments passed to "
  16615. "QIODevice::writeBytes()");
  16616. }
  16617. return QScriptValue();
  16618. }
  16619. /*:89*//*90:*/
  16620. #line 2319 "./typica.w"
  16621. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  16622. {
  16623. QIODevice*self= getself<QIODevice*> (context);
  16624. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  16625. setQByteArrayProperties(value,engine);
  16626. return value;
  16627. }
  16628. /*:90*//*91:*/
  16629. #line 2330 "./typica.w"
  16630. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  16631. {
  16632. QIODevice*self= getself<QIODevice*> (context);
  16633. QScriptValue value= engine->toScriptValue<QByteArray> (
  16634. self->peek(argument<int> (0,context)));
  16635. setQByteArrayProperties(value,engine);
  16636. return value;
  16637. }
  16638. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  16639. {
  16640. QIODevice*self= getself<QIODevice*> (context);
  16641. QScriptValue value= engine->toScriptValue<QByteArray> (
  16642. self->read(argument<int> (0,context)));
  16643. setQByteArrayProperties(value,engine);
  16644. return value;
  16645. }
  16646. /*:91*//*94:*/
  16647. #line 2375 "./typica.w"
  16648. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  16649. {
  16650. QScriptValue object= engine->newQObject(new QProcess);
  16651. setQProcessProperties(object,engine);
  16652. return object;
  16653. }
  16654. /*:94*//*95:*/
  16655. #line 2386 "./typica.w"
  16656. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  16657. {
  16658. setQIODeviceProperties(value,engine);
  16659. value.setProperty("execute",engine->newFunction(QProcess_execute));
  16660. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  16661. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  16662. value.setProperty("start",engine->newFunction(QProcess_start));
  16663. }
  16664. /*:95*//*96:*/
  16665. #line 2400 "./typica.w"
  16666. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  16667. {
  16668. QProcess*self= getself<QProcess*> (context);
  16669. QString program= argument<QString> (0,context);
  16670. QStringList arguments= QStringList();
  16671. if(context->argumentCount()> 1){
  16672. arguments= argument<QVariant> (1,context).toStringList();
  16673. }
  16674. int retval= self->execute(program,arguments);
  16675. return QScriptValue(retval);
  16676. }
  16677. /*:96*//*97:*/
  16678. #line 2415 "./typica.w"
  16679. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  16680. {
  16681. QProcess*self= getself<QProcess*> (context);
  16682. QString program= argument<QString> (0,context);
  16683. QStringList arguments= QStringList();
  16684. if(context->argumentCount()> 1){
  16685. arguments= argument<QVariant> (1,context).toStringList();
  16686. }
  16687. QString workingDirectory= "";
  16688. if(context->argumentCount()> 2){
  16689. workingDirectory= argument<QString> (2,context);
  16690. }
  16691. bool retval;
  16692. switch(context->argumentCount())
  16693. {
  16694. case 1:
  16695. retval= self->startDetached(program);
  16696. break;
  16697. case 2:
  16698. retval= self->startDetached(program,arguments);
  16699. break;
  16700. case 3:
  16701. retval= self->startDetached(program,arguments,workingDirectory);
  16702. break;
  16703. default:
  16704. retval= false;
  16705. }
  16706. return QScriptValue(retval);
  16707. }
  16708. /*:97*//*98:*/
  16709. #line 2448 "./typica.w"
  16710. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  16711. {
  16712. QProcess*self= getself<QProcess*> (context);
  16713. QString directory= argument<QString> (0,context);
  16714. self->setWorkingDirectory(directory);
  16715. return QScriptValue();
  16716. }
  16717. /*:98*//*99:*/
  16718. #line 2460 "./typica.w"
  16719. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  16720. {
  16721. QProcess*self= getself<QProcess*> (context);
  16722. QString program= argument<QString> (0,context);
  16723. QStringList arguments= QStringList();
  16724. if(context->argumentCount()> 1){
  16725. arguments= argument<QVariant> (1,context).toStringList();
  16726. }
  16727. self->start(program,arguments);
  16728. return QScriptValue();
  16729. }
  16730. /*:99*//*101:*/
  16731. #line 2501 "./typica.w"
  16732. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  16733. {
  16734. QScriptValue object= engine->newVariant(QVariant(bytes));
  16735. setQByteArrayProperties(object,engine);
  16736. return object;
  16737. }
  16738. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  16739. {
  16740. bytes= value.toVariant().toByteArray();
  16741. }
  16742. /*:101*//*103:*/
  16743. #line 2524 "./typica.w"
  16744. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  16745. {
  16746. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  16747. setQByteArrayProperties(object,engine);
  16748. return object;
  16749. }
  16750. /*:103*//*104:*/
  16751. #line 2535 "./typica.w"
  16752. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  16753. {
  16754. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  16755. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  16756. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  16757. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  16758. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  16759. value.setProperty("size",engine->newFunction(QByteArray_size));
  16760. value.setProperty("left",engine->newFunction(QByteArray_left));
  16761. value.setProperty("right",engine->newFunction(QByteArray_right));
  16762. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  16763. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  16764. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  16765. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  16766. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  16767. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  16768. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  16769. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  16770. }
  16771. /*:104*//*105:*/
  16772. #line 2559 "./typica.w"
  16773. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  16774. {
  16775. QByteArray self= getself<QByteArray> (context);
  16776. QByteArray retval;
  16777. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  16778. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  16779. setQByteArrayProperties(value,engine);
  16780. return value;
  16781. }
  16782. /*:105*//*106:*/
  16783. #line 2573 "./typica.w"
  16784. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  16785. {
  16786. QByteArray self= getself<QByteArray> (context);
  16787. return QScriptValue((int)(self.at(argument<int> (0,context))));
  16788. }
  16789. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  16790. {
  16791. QByteArray self= getself<QByteArray> (context);
  16792. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  16793. return QScriptValue();
  16794. }
  16795. /*:106*//*107:*/
  16796. #line 2591 "./typica.w"
  16797. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  16798. {
  16799. QByteArray self= getself<QByteArray> (context);
  16800. QScriptValue value=
  16801. engine->toScriptValue<QByteArray> (
  16802. self.append(argument<QByteArray> (0,context)));
  16803. setQByteArrayProperties(value,engine);
  16804. return value;
  16805. }
  16806. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  16807. {
  16808. QByteArray self= getself<QByteArray> (context);
  16809. QScriptValue value= engine->toScriptValue<QByteArray> (
  16810. self.append(argument<QString> (0,context)));
  16811. setQByteArrayProperties(value,engine);
  16812. return value;
  16813. }
  16814. /*:107*//*108:*/
  16815. #line 2613 "./typica.w"
  16816. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  16817. {
  16818. QByteArray self= getself<QByteArray> (context);
  16819. return QScriptValue(self.size());
  16820. }
  16821. /*:108*//*109:*/
  16822. #line 2623 "./typica.w"
  16823. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  16824. {
  16825. QByteArray self= getself<QByteArray> (context);
  16826. QScriptValue value= engine->toScriptValue<QByteArray> (
  16827. self.left(argument<int> (0,context)));
  16828. setQByteArrayProperties(value,engine);
  16829. return value;
  16830. }
  16831. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  16832. {
  16833. QByteArray self= getself<QByteArray> (context);
  16834. QScriptValue value= engine->toScriptValue<QByteArray> (
  16835. self.right(argument<int> (0,context)));
  16836. setQByteArrayProperties(value,engine);
  16837. return value;
  16838. }
  16839. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  16840. {
  16841. QByteArray self= getself<QByteArray> (context);
  16842. int length= -1;
  16843. if(context->argumentCount()> 1)
  16844. {
  16845. length= argument<int> (1,context);
  16846. }
  16847. QScriptValue value= engine->toScriptValue<QByteArray> (
  16848. self.mid(argument<int> (0,context),length));
  16849. setQByteArrayProperties(value,engine);
  16850. return value;
  16851. }
  16852. /*:109*//*110:*/
  16853. #line 2658 "./typica.w"
  16854. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  16855. {
  16856. QByteArray self= getself<QByteArray> (context);
  16857. self.chop(argument<int> (0,context));
  16858. return QScriptValue();
  16859. }
  16860. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  16861. {
  16862. QByteArray self= getself<QByteArray> (context);
  16863. QScriptValue value= engine->toScriptValue<QByteArray> (
  16864. self.remove(argument<int> (0,context),argument<int> (1,context)));
  16865. setQByteArrayProperties(value,engine);
  16866. return value;
  16867. }
  16868. /*:110*//*111:*/
  16869. #line 2681 "./typica.w"
  16870. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  16871. {
  16872. QByteArray self= getself<QByteArray> (context);
  16873. int value= 0;
  16874. char*bytes= (char*)&value;
  16875. bytes[0]= self[0];
  16876. return QScriptValue(value);
  16877. }
  16878. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  16879. {
  16880. QByteArray self= getself<QByteArray> (context);
  16881. int value= 0;
  16882. char*bytes= (char*)&value;
  16883. bytes[0]= self[0];
  16884. bytes[1]= self[1];
  16885. return QScriptValue(value);
  16886. }
  16887. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  16888. {
  16889. QByteArray self= getself<QByteArray> (context);
  16890. int value= 0;
  16891. char*bytes= (char*)&value;
  16892. bytes[0]= self[0];
  16893. bytes[1]= self[1];
  16894. bytes[2]= self[2];
  16895. bytes[3]= self[3];
  16896. return QScriptValue(value);
  16897. }
  16898. /*:111*//*112:*/
  16899. #line 2717 "./typica.w"
  16900. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  16901. {
  16902. QByteArray self= getself<QByteArray> (context);
  16903. float value= 0.0;
  16904. char*bytes= (char*)&value;
  16905. bytes[0]= self[0];
  16906. bytes[1]= self[1];
  16907. bytes[2]= self[2];
  16908. bytes[3]= self[3];
  16909. return QScriptValue(value);
  16910. }
  16911. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  16912. {
  16913. QByteArray self= getself<QByteArray> (context);
  16914. double value= 0.0;
  16915. char*bytes= (char*)&value;
  16916. bytes[0]= self[0];
  16917. bytes[1]= self[1];
  16918. bytes[2]= self[2];
  16919. bytes[3]= self[3];
  16920. bytes[4]= self[4];
  16921. bytes[5]= self[5];
  16922. bytes[6]= self[6];
  16923. bytes[7]= self[7];
  16924. return QScriptValue(value);
  16925. }
  16926. /*:112*//*115:*/
  16927. #line 2772 "./typica.w"
  16928. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  16929. {
  16930. qint8 value= (qint8)(argument<int> (0,context));
  16931. char*bytes= (char*)&value;
  16932. QByteArray retval;
  16933. retval.resize(1);
  16934. retval[0]= bytes[0];
  16935. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16936. setQByteArrayProperties(v,engine);
  16937. return v;
  16938. }
  16939. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  16940. {
  16941. qint16 value= (qint16)(argument<int> (0,context));
  16942. char*bytes= (char*)&value;
  16943. QByteArray retval;
  16944. retval.resize(2);
  16945. retval[0]= bytes[0];
  16946. retval[1]= bytes[1];
  16947. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16948. setQByteArrayProperties(v,engine);
  16949. return v;
  16950. }
  16951. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  16952. {
  16953. qint32 value= (qint32)(argument<int> (0,context));
  16954. char*bytes= (char*)&value;
  16955. QByteArray retval;
  16956. retval.resize(4);
  16957. retval[0]= bytes[0];
  16958. retval[1]= bytes[1];
  16959. retval[2]= bytes[2];
  16960. retval[3]= bytes[3];
  16961. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16962. setQByteArrayProperties(v,engine);
  16963. return v;
  16964. }
  16965. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  16966. {
  16967. float value= (float)(argument<double> (0,context));
  16968. char*bytes= (char*)&value;
  16969. QByteArray retval;
  16970. retval.resize(4);
  16971. retval[0]= bytes[0];
  16972. retval[1]= bytes[1];
  16973. retval[2]= bytes[2];
  16974. retval[3]= bytes[3];
  16975. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16976. setQByteArrayProperties(v,engine);
  16977. return v;
  16978. }
  16979. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  16980. {
  16981. double value= (double)(argument<double> (0,context));
  16982. char*bytes= (char*)&value;
  16983. QByteArray retval;
  16984. retval.resize(8);
  16985. retval[0]= bytes[0];
  16986. retval[1]= bytes[1];
  16987. retval[2]= bytes[2];
  16988. retval[3]= bytes[3];
  16989. retval[4]= bytes[4];
  16990. retval[5]= bytes[5];
  16991. retval[6]= bytes[6];
  16992. retval[7]= bytes[7];
  16993. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16994. setQByteArrayProperties(v,engine);
  16995. return v;
  16996. }
  16997. /*:115*//*118:*/
  16998. #line 2870 "./typica.w"
  16999. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  17000. {
  17001. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  17002. QScriptValue object= engine->newQObject(new QBuffer(array));
  17003. setQBufferProperties(object,engine);
  17004. return object;
  17005. }
  17006. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  17007. {
  17008. setQIODeviceProperties(value,engine);
  17009. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  17010. value.setProperty("data",engine->newFunction(QBuffer_data));
  17011. }
  17012. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  17013. {
  17014. QBuffer*self= getself<QBuffer*> (context);
  17015. self->setData(argument<QString> (0,context).toAscii());
  17016. return QScriptValue();
  17017. }
  17018. QScriptValue QBuffer_data(QScriptContext*context,QScriptEngine*)
  17019. {
  17020. QBuffer*self= getself<QBuffer*> (context);
  17021. return QScriptValue(QString(self->data()));
  17022. }
  17023. /*:118*//*121:*/
  17024. #line 2926 "./typica.w"
  17025. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  17026. {
  17027. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  17028. setXQueryProperties(object,engine);
  17029. return object;
  17030. }
  17031. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  17032. {
  17033. QXmlQuery*self= getself<QXmlQuery*> (context);
  17034. delete self;
  17035. return QScriptValue();
  17036. }
  17037. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  17038. {
  17039. value.setProperty("bind",engine->newFunction(XQuery_bind));
  17040. value.setProperty("exec",engine->newFunction(XQuery_exec));
  17041. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  17042. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  17043. }
  17044. /*:121*//*122:*/
  17045. #line 2952 "./typica.w"
  17046. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  17047. {
  17048. QXmlQuery*self= getself<QXmlQuery*> (context);
  17049. QIODevice*buffer= argument<QIODevice*> (1,context);
  17050. self->bindVariable(argument<QString> (0,context),buffer);
  17051. return QScriptValue();
  17052. }
  17053. /*:122*//*123:*/
  17054. #line 2963 "./typica.w"
  17055. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  17056. {
  17057. QXmlQuery*self= getself<QXmlQuery*> (context);
  17058. self->setQuery(argument<QString> (0,context));
  17059. return QScriptValue();
  17060. }
  17061. /*:123*//*124:*/
  17062. #line 2973 "./typica.w"
  17063. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  17064. {
  17065. QXmlQuery*self= getself<QXmlQuery*> (context);
  17066. QString result;
  17067. self->evaluateTo(&result);
  17068. return QScriptValue(result);
  17069. }
  17070. /*:124*//*127:*/
  17071. #line 3028 "./typica.w"
  17072. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  17073. {
  17074. QXmlStreamWriter*retval;
  17075. if(context->argumentCount()==1)
  17076. {
  17077. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  17078. }
  17079. else
  17080. {
  17081. retval= new QXmlStreamWriter;
  17082. }
  17083. QScriptValue object= engine->toScriptValue<void*> (retval);
  17084. setXmlWriterProperties(object,engine);
  17085. return object;
  17086. }
  17087. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  17088. {
  17089. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  17090. value.setProperty("writeAttribute",
  17091. engine->newFunction(XmlWriter_writeAttribute));
  17092. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  17093. value.setProperty("writeCharacters",
  17094. engine->newFunction(XmlWriter_writeCharacters));
  17095. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  17096. value.setProperty("writeEmptyElement",
  17097. engine->newFunction(XmlWriter_writeEmptyElement));
  17098. value.setProperty("writeEndDocument",
  17099. engine->newFunction(XmlWriter_writeEndDocument));
  17100. value.setProperty("writeEndElement",
  17101. engine->newFunction(XmlWriter_writeEndElement));
  17102. value.setProperty("writeEntityReference",
  17103. engine->newFunction(XmlWriter_writeEntityReference));
  17104. value.setProperty("writeProcessingInstruction",
  17105. engine->newFunction(XmlWriter_writeProcessingInstruction));
  17106. value.setProperty("writeStartDocument",
  17107. engine->newFunction(XmlWriter_writeStartDocument));
  17108. value.setProperty("writeStartElement",
  17109. engine->newFunction(XmlWriter_writeStartElement));
  17110. value.setProperty("writeTextElement",
  17111. engine->newFunction(XmlWriter_writeTextElement));
  17112. }
  17113. /*:127*//*128:*/
  17114. #line 3075 "./typica.w"
  17115. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  17116. {
  17117. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17118. QIODevice*device= argument<QIODevice*> (0,context);
  17119. self->setDevice(device);
  17120. return QScriptValue();
  17121. }
  17122. /*:128*//*129:*/
  17123. #line 3089 "./typica.w"
  17124. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  17125. QScriptEngine*)
  17126. {
  17127. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17128. self->writeStartDocument(argument<QString> (0,context));
  17129. return QScriptValue();
  17130. }
  17131. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  17132. QScriptEngine*)
  17133. {
  17134. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17135. self->writeEndDocument();
  17136. return QScriptValue();
  17137. }
  17138. /*:129*//*130:*/
  17139. #line 3108 "./typica.w"
  17140. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  17141. {
  17142. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17143. self->writeDTD(argument<QString> (0,context));
  17144. return QScriptValue();
  17145. }
  17146. /*:130*//*131:*/
  17147. #line 3119 "./typica.w"
  17148. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  17149. QScriptEngine*)
  17150. {
  17151. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17152. self->writeStartElement(argument<QString> (0,context));
  17153. return QScriptValue();
  17154. }
  17155. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  17156. {
  17157. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17158. self->writeAttribute(argument<QString> (0,context),
  17159. argument<QString> (1,context));
  17160. return QScriptValue();
  17161. }
  17162. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  17163. {
  17164. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17165. self->writeCharacters(argument<QString> (0,context));
  17166. return QScriptValue();
  17167. }
  17168. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  17169. {
  17170. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17171. self->writeEndElement();
  17172. return QScriptValue();
  17173. }
  17174. /*:131*//*132:*/
  17175. #line 3155 "./typica.w"
  17176. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  17177. QScriptEngine*)
  17178. {
  17179. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17180. self->writeEmptyElement(argument<QString> (0,context));
  17181. return QScriptValue();
  17182. }
  17183. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  17184. QScriptEngine*)
  17185. {
  17186. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17187. self->writeTextElement(argument<QString> (0,context),
  17188. argument<QString> (1,context));
  17189. return QScriptValue();
  17190. }
  17191. /*:132*//*133:*/
  17192. #line 3176 "./typica.w"
  17193. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  17194. {
  17195. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17196. self->writeCDATA(argument<QString> (0,context));
  17197. return QScriptValue();
  17198. }
  17199. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  17200. QScriptEngine*)
  17201. {
  17202. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17203. self->writeEntityReference(argument<QString> (0,context));
  17204. return QScriptValue();
  17205. }
  17206. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  17207. QScriptEngine*)
  17208. {
  17209. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17210. self->writeProcessingInstruction(argument<QString> (0,context),
  17211. argument<QString> (1,context));
  17212. return QScriptValue();
  17213. }
  17214. /*:133*//*136:*/
  17215. #line 3235 "./typica.w"
  17216. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  17217. {
  17218. QXmlStreamReader*retval=
  17219. new QXmlStreamReader(argument<QIODevice*> (0,context));
  17220. QScriptValue object= engine->toScriptValue<void*> (retval);
  17221. setXmlReaderProperties(object,engine);
  17222. return object;
  17223. }
  17224. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  17225. {
  17226. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  17227. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  17228. value.setProperty("hasAttribute",
  17229. engine->newFunction(XmlReader_hasAttribute));
  17230. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  17231. value.setProperty("isStartElement",
  17232. engine->newFunction(XmlReader_isStartElement));
  17233. value.setProperty("name",engine->newFunction(XmlReader_name));
  17234. value.setProperty("readElementText",
  17235. engine->newFunction(XmlReader_readElementText));
  17236. value.setProperty("readNext",
  17237. engine->newFunction(XmlReader_readNext));
  17238. value.setProperty("text",engine->newFunction(XmlReader_text));
  17239. }
  17240. /*:136*//*137:*/
  17241. #line 3265 "./typica.w"
  17242. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  17243. {
  17244. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17245. QString retval=
  17246. self->attributes().value(argument<QString> (0,context)).toString();
  17247. return QScriptValue(retval);
  17248. }
  17249. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  17250. {
  17251. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17252. bool retval=
  17253. self->attributes().hasAttribute(argument<QString> (0,context));
  17254. return QScriptValue(retval);
  17255. }
  17256. /*:137*//*138:*/
  17257. #line 3285 "./typica.w"
  17258. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  17259. {
  17260. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17261. return QScriptValue(self->atEnd());
  17262. }
  17263. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  17264. {
  17265. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17266. return QScriptValue(self->isDTD());
  17267. }
  17268. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  17269. {
  17270. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17271. return QScriptValue(self->isStartElement());
  17272. }
  17273. /*:138*//*139:*/
  17274. #line 3306 "./typica.w"
  17275. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  17276. {
  17277. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17278. self->readNext();
  17279. return QScriptValue();
  17280. }
  17281. /*:139*//*140:*/
  17282. #line 3316 "./typica.w"
  17283. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  17284. {
  17285. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17286. return QScriptValue(self->name().toString());
  17287. }
  17288. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  17289. {
  17290. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17291. return QScriptValue(self->readElementText());
  17292. }
  17293. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  17294. {
  17295. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17296. return QScriptValue(self->text().toString());
  17297. }
  17298. /*:140*//*143:*/
  17299. #line 3358 "./typica.w"
  17300. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  17301. {
  17302. setQObjectProperties(value,engine);
  17303. value.setProperty("value",engine->newFunction(QSettings_value));
  17304. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  17305. }
  17306. /*:143*//*144:*/
  17307. #line 3370 "./typica.w"
  17308. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  17309. {
  17310. QScriptValue object;
  17311. if(context->argumentCount()==1||context->argumentCount()==2)
  17312. {
  17313. QSettings settings;
  17314. QString key= argument<QString> (0,context);
  17315. QVariant value;
  17316. QVariant retval;
  17317. if(context->argumentCount()> 1)
  17318. {
  17319. value= argument<QVariant> (1,context);
  17320. retval= settings.value(key,value);
  17321. }
  17322. else
  17323. {
  17324. retval= settings.value(key);
  17325. }
  17326. object= engine->newVariant(retval);
  17327. }
  17328. else
  17329. {
  17330. context->throwError("Incorrect number of arguments passed to "
  17331. "QSettings::value(). This method takes one "
  17332. "string and one optional variant type.");
  17333. }
  17334. return object;
  17335. }
  17336. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  17337. {
  17338. if(context->argumentCount()==2)
  17339. {
  17340. QSettings settings;
  17341. QString key= argument<QString> (0,context);
  17342. QVariant value= argument<QVariant> (1,context);
  17343. settings.setValue(key,value);
  17344. }
  17345. else
  17346. {
  17347. context->throwError("Incorrect number of arguments passed to "
  17348. "QSettings::setValue(). This method takes one "
  17349. "string and one variant type for a total of two "
  17350. "arguments.");
  17351. }
  17352. return QScriptValue();
  17353. }
  17354. /*:144*//*147:*/
  17355. #line 3439 "./typica.w"
  17356. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  17357. {
  17358. QScriptValue object= engine->newQObject(new QLCDNumber());
  17359. setQLCDNumberProperties(object,engine);
  17360. return object;
  17361. }
  17362. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  17363. {
  17364. setQFrameProperties(value,engine);
  17365. }
  17366. /*:147*//*150:*/
  17367. #line 3497 "./typica.w"
  17368. QScriptValue constructQTime(QScriptContext*context,
  17369. QScriptEngine*engine)
  17370. {
  17371. QScriptValue object;
  17372. if(context->argumentCount()==0||
  17373. (context->argumentCount()>=2&&context->argumentCount()<=4))
  17374. {
  17375. int arg1= 0;
  17376. int arg2= 0;
  17377. int arg3= 0;
  17378. int arg4= 0;
  17379. switch(context->argumentCount())
  17380. {
  17381. case 4:
  17382. arg4= argument<int> (3,context);
  17383. case 3:
  17384. arg3= argument<int> (2,context);
  17385. case 2:
  17386. arg2= argument<int> (1,context);
  17387. arg1= argument<int> (0,context);
  17388. default:
  17389. break;
  17390. }
  17391. if(context->argumentCount())
  17392. {
  17393. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  17394. arg4));
  17395. }
  17396. else
  17397. {
  17398. object= engine->toScriptValue<QTime> (QTime());
  17399. }
  17400. setQTimeProperties(object,engine);
  17401. }
  17402. else
  17403. {
  17404. context->throwError("Incorrect number of arguments passed to "
  17405. "QTime::QTime(). This method takes zero, two, "
  17406. "three, or four integer arguments.");
  17407. }
  17408. return object;
  17409. }
  17410. /*:150*//*151:*/
  17411. #line 3545 "./typica.w"
  17412. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  17413. {
  17414. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  17415. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  17416. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  17417. value.setProperty("hour",engine->newFunction(QTime_hour));
  17418. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  17419. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  17420. value.setProperty("minute",engine->newFunction(QTime_minute));
  17421. value.setProperty("msec",engine->newFunction(QTime_msec));
  17422. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  17423. value.setProperty("restart",engine->newFunction(QTime_restart));
  17424. value.setProperty("second",engine->newFunction(QTime_second));
  17425. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  17426. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  17427. value.setProperty("start",engine->newFunction(QTime_start));
  17428. value.setProperty("toString",engine->newFunction(QTime_toString));
  17429. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  17430. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  17431. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  17432. }
  17433. /*:151*//*152:*/
  17434. #line 3574 "./typica.w"
  17435. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  17436. {
  17437. QTime self= getself<QTime> (context);
  17438. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  17439. (self.second()*1000)+self.msec();
  17440. return QScriptValue(retval);
  17441. }
  17442. /*:152*//*153:*/
  17443. #line 3588 "./typica.w"
  17444. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  17445. {
  17446. QTime time;
  17447. QScriptValue retval;
  17448. if(context->argumentCount()==1)
  17449. {
  17450. QTime self= getself<QTime> (context);
  17451. time= self.addMSecs(argument<int> (0,context));
  17452. retval= engine->toScriptValue<QTime> (time);
  17453. setQTimeProperties(retval,engine);
  17454. }
  17455. else
  17456. {
  17457. context->throwError("Incorrect number of arguments passed to "
  17458. "QTime::addMSecs(). This method takes one "
  17459. "integer as an argument.");
  17460. }
  17461. return retval;
  17462. }
  17463. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  17464. {
  17465. QTime time;
  17466. QScriptValue retval;
  17467. if(context->argumentCount()==1)
  17468. {
  17469. QTime self= getself<QTime> (context);
  17470. time= self.addSecs(argument<int> (0,context));
  17471. retval= engine->toScriptValue<QTime> (time);
  17472. setQTimeProperties(retval,engine);
  17473. }
  17474. else
  17475. {
  17476. context->throwError("Incorrect number of arguments passed to "
  17477. "QTime::addSecs(). This method takes one "
  17478. "integer as an argument.");
  17479. }
  17480. return retval;
  17481. }
  17482. /*:153*//*154:*/
  17483. #line 3631 "./typica.w"
  17484. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  17485. {
  17486. QScriptValue retval;
  17487. if(context->argumentCount()==0)
  17488. {
  17489. QTime self= getself<QTime> (context);
  17490. retval= QScriptValue(engine,self.elapsed());
  17491. }
  17492. else
  17493. {
  17494. context->throwError("Incorrect number of arguments passed to "
  17495. "QTime::elapsed(). This method takes no "
  17496. "arguments.");
  17497. }
  17498. return retval;
  17499. }
  17500. /*:154*//*155:*/
  17501. #line 3652 "./typica.w"
  17502. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  17503. {
  17504. QScriptValue retval;
  17505. if(context->argumentCount()==0)
  17506. {
  17507. QTime self= getself<QTime> (context);
  17508. retval= QScriptValue(engine,self.hour());
  17509. }
  17510. else
  17511. {
  17512. context->throwError("Incorrect number of arguments passed to "
  17513. "QTime::hour(). This method takes no "
  17514. "arguments.");
  17515. }
  17516. return retval;
  17517. }
  17518. /*:155*//*156:*/
  17519. #line 3672 "./typica.w"
  17520. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  17521. {
  17522. QScriptValue retval;
  17523. if(context->argumentCount()==0)
  17524. {
  17525. QTime self= getself<QTime> (context);
  17526. retval= QScriptValue(engine,self.minute());
  17527. }
  17528. else
  17529. {
  17530. context->throwError("Incorrect number of arguments passed to "
  17531. "QTime::minute(). This method takes no "
  17532. "arguments.");
  17533. }
  17534. return retval;
  17535. }
  17536. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  17537. {
  17538. QScriptValue retval;
  17539. if(context->argumentCount()==0)
  17540. {
  17541. QTime self= getself<QTime> (context);
  17542. retval= QScriptValue(engine,self.second());
  17543. }
  17544. else
  17545. {
  17546. context->throwError("Incorrect number of arguments passed to "
  17547. "QTime::second(). This method takes no "
  17548. "arguments.");
  17549. }
  17550. return retval;
  17551. }
  17552. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  17553. {
  17554. QScriptValue retval;
  17555. if(context->argumentCount()==0)
  17556. {
  17557. QTime self= getself<QTime> (context);
  17558. retval= QScriptValue(engine,self.msec());
  17559. }
  17560. else
  17561. {
  17562. context->throwError("Incorrect number of arguments passed to "
  17563. "QTime::msec(). This method takes no "
  17564. "arguments.");
  17565. }
  17566. return retval;
  17567. }
  17568. /*:156*//*157:*/
  17569. #line 3728 "./typica.w"
  17570. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  17571. {
  17572. QScriptValue retval;
  17573. if(context->argumentCount()==0)
  17574. {
  17575. QTime self= getself<QTime> (context);
  17576. retval= QScriptValue(engine,self.isNull());
  17577. }
  17578. else
  17579. {
  17580. context->throwError("Incorrect number of arguments passed to "
  17581. "QTime::isNull(). This method takes no "
  17582. "arguments.");
  17583. }
  17584. return retval;
  17585. }
  17586. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  17587. {
  17588. QScriptValue retval;
  17589. if(context->argumentCount()==0)
  17590. {
  17591. QTime self= getself<QTime> (context);
  17592. retval= QScriptValue(engine,self.isValid());
  17593. }
  17594. else
  17595. {
  17596. context->throwError("Incorrect number of arguments passed to "
  17597. "QTime::isValid(). This method takes no "
  17598. "arguments.");
  17599. }
  17600. return retval;
  17601. }
  17602. /*:157*//*158:*/
  17603. #line 3766 "./typica.w"
  17604. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  17605. {
  17606. QScriptValue retval;
  17607. if(context->argumentCount()==1)
  17608. {
  17609. QTime self= getself<QTime> (context);
  17610. QTime arg= argument<QVariant> (0,context).toTime();
  17611. retval= QScriptValue(engine,self.msecsTo(arg));
  17612. }
  17613. else
  17614. {
  17615. context->throwError("Incorrect number of arguments passed to "
  17616. "QTime::msecsTo(). This method takes one QTime.");
  17617. }
  17618. return retval;
  17619. }
  17620. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  17621. {
  17622. QScriptValue retval;
  17623. if(context->argumentCount()==1)
  17624. {
  17625. QTime self= getself<QTime> (context);
  17626. QTime arg= argument<QVariant> (0,context).toTime();
  17627. retval= QScriptValue(engine,self.secsTo(arg));
  17628. }
  17629. else
  17630. {
  17631. context->throwError("Incorrect number of arguments passed to "
  17632. "QTime::secsTo(). This method takes one QTime.");
  17633. }
  17634. return retval;
  17635. }
  17636. /*:158*//*159:*/
  17637. #line 3805 "./typica.w"
  17638. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  17639. {
  17640. QScriptValue retval;
  17641. if(context->argumentCount()==0)
  17642. {
  17643. QTime self= getself<QTime> (context);
  17644. retval= QScriptValue(engine,self.restart());
  17645. }
  17646. else
  17647. {
  17648. context->throwError("Incorrect number of arguments passed to "
  17649. "QTime::restart(). This method takes no "
  17650. "arguments.");
  17651. }
  17652. return retval;
  17653. }
  17654. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  17655. {
  17656. if(context->argumentCount()==0)
  17657. {
  17658. QTime self= getself<QTime> (context);
  17659. self.start();
  17660. }
  17661. else
  17662. {
  17663. context->throwError("Incorrect number of arguments passed to "
  17664. "QTime::start(). This method takes no arguments.");
  17665. }
  17666. return QScriptValue();
  17667. }
  17668. /*:159*//*160:*/
  17669. #line 3841 "./typica.w"
  17670. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  17671. {
  17672. QScriptValue retval;
  17673. if(context->argumentCount()==3||context->argumentCount()==4)
  17674. {
  17675. QTime self= getself<QTime> (context);
  17676. int arg1= 0;
  17677. int arg2= 0;
  17678. int arg3= 0;
  17679. int arg4= 0;
  17680. switch(context->argumentCount())
  17681. {
  17682. case 4:
  17683. arg4= argument<int> (3,context);
  17684. case 3:
  17685. arg3= argument<int> (2,context);
  17686. arg2= argument<int> (1,context);
  17687. arg1= argument<int> (0,context);
  17688. default:
  17689. break;
  17690. }
  17691. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  17692. }
  17693. else
  17694. {
  17695. context->throwError("Incorrect number of arguments passed to "
  17696. "QTime::setHMS(). This method takes three or "
  17697. "four integer arguments.");
  17698. }
  17699. return retval;
  17700. }
  17701. /*:160*//*161:*/
  17702. #line 3877 "./typica.w"
  17703. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  17704. {
  17705. QScriptValue retval;
  17706. if(context->argumentCount()==1)
  17707. {
  17708. QTime self= getself<QTime> (context);
  17709. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  17710. }
  17711. else
  17712. {
  17713. context->throwError("Incorrect number of arguments passed to "
  17714. "QTime::toString(). This method takes one QString "
  17715. "as an argument.");
  17716. }
  17717. return retval;
  17718. }
  17719. /*:161*//*162:*/
  17720. #line 3898 "./typica.w"
  17721. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  17722. {
  17723. QScriptValue object;
  17724. object= engine->toScriptValue<QTime> (QTime::currentTime());
  17725. setQTimeProperties(object,engine);
  17726. return object;
  17727. }
  17728. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  17729. {
  17730. QScriptValue object;
  17731. if(context->argumentCount()==2)
  17732. {
  17733. QString time= argument<QString> (0,context);
  17734. QString format= argument<QString> (1,context);
  17735. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  17736. setQTimeProperties(object,engine);
  17737. }
  17738. else
  17739. {
  17740. context->throwError("Incorrect number of arguments passed to "
  17741. "QTime::fromString(). This method takes two "
  17742. "string arguments.");
  17743. }
  17744. return object;
  17745. }
  17746. /*:162*//*163:*/
  17747. #line 3929 "./typica.w"
  17748. template<> QTime argument(int arg,QScriptContext*context)
  17749. {
  17750. return qscriptvalue_cast<QTime> (context->argument(arg));
  17751. }
  17752. /*:163*//*165:*/
  17753. #line 3947 "./typica.w"
  17754. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  17755. {
  17756. setQFrameProperties(value,engine);
  17757. }
  17758. /*:165*//*167:*/
  17759. #line 3961 "./typica.w"
  17760. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  17761. {
  17762. setQAbstractScrollAreaProperties(value,engine);
  17763. }
  17764. /*:167*//*169:*/
  17765. #line 3975 "./typica.w"
  17766. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  17767. {
  17768. setQAbstractScrollAreaProperties(value,engine);
  17769. }
  17770. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  17771. {
  17772. setQAbstractItemViewProperties(value,engine);
  17773. }
  17774. /*:169*//*172:*/
  17775. #line 4008 "./typica.w"
  17776. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  17777. {
  17778. QScriptValue object= engine->newQObject(new QPushButton());
  17779. setQPushButtonProperties(object,engine);
  17780. return object;
  17781. }
  17782. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  17783. {
  17784. setQAbstractButtonProperties(value,engine);
  17785. }
  17786. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  17787. {
  17788. setQWidgetProperties(value,engine);
  17789. }
  17790. /*:172*//*179:*/
  17791. #line 4120 "./typica.w"
  17792. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  17793. {
  17794. SqlQueryConnection*obj= new SqlQueryConnection();
  17795. QScriptValue object=
  17796. engine->toScriptValue<void*> (obj);
  17797. setQSqlQueryProperties(object,engine);
  17798. return object;
  17799. }
  17800. /*:179*//*180:*/
  17801. #line 4133 "./typica.w"
  17802. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  17803. {
  17804. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  17805. value.setProperty("bindFileData",
  17806. engine->newFunction(QSqlQuery_bindFileData));
  17807. value.setProperty("bindDeviceData",
  17808. engine->newFunction(QSqlQuery_bindDeviceData));
  17809. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  17810. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  17811. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  17812. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  17813. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  17814. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  17815. }
  17816. /*:180*//*181:*/
  17817. #line 4151 "./typica.w"
  17818. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  17819. {
  17820. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  17821. QScriptValue retval;
  17822. if(context->argumentCount()==1)
  17823. {
  17824. retval= QScriptValue(engine,
  17825. q->exec(argument<QString> (0,context)));
  17826. }
  17827. else
  17828. {
  17829. retval= QScriptValue(engine,q->exec());
  17830. }
  17831. if(q->lastError().isValid())
  17832. {
  17833. qDebug()<<q->lastQuery();
  17834. qDebug()<<q->lastError().text();
  17835. }
  17836. return retval;
  17837. }
  17838. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  17839. {
  17840. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17841. return QScriptValue(query->lastQuery());
  17842. }
  17843. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  17844. {
  17845. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17846. return QScriptValue(engine,query->next());
  17847. }
  17848. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  17849. {
  17850. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17851. return QScriptValue(engine,
  17852. query->value(argument<int> (0,context)).toString());
  17853. }
  17854. /*:181*//*182:*/
  17855. #line 4195 "./typica.w"
  17856. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  17857. {
  17858. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17859. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  17860. }
  17861. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  17862. {
  17863. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17864. query->bindValue(argument<QString> (0,context),
  17865. argument<QVariant> (1,context));
  17866. return QScriptValue();
  17867. }
  17868. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  17869. QScriptEngine*)
  17870. {
  17871. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17872. QString placeholder= argument<QString> (0,context);
  17873. QString filename= argument<QString> (1,context);
  17874. QFile file(filename);
  17875. QByteArray data;
  17876. if(file.open(QIODevice::ReadOnly))
  17877. {
  17878. data= file.readAll();
  17879. file.close();
  17880. }
  17881. query->bindValue(placeholder,data);
  17882. return QScriptValue();
  17883. }
  17884. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  17885. QScriptEngine*)
  17886. {
  17887. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17888. QString placeholder= argument<QString> (0,context);
  17889. QIODevice*device= argument<QIODevice*> (1,context);
  17890. device->reset();
  17891. QByteArray data;
  17892. data= device->readAll();
  17893. query->bindValue(placeholder,data);
  17894. return QScriptValue();
  17895. }
  17896. /*:182*//*183:*/
  17897. #line 4247 "./typica.w"
  17898. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  17899. {
  17900. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  17901. delete query;
  17902. return QScriptValue::UndefinedValue;
  17903. }
  17904. /*:183*//*186:*/
  17905. #line 4294 "./typica.w"
  17906. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  17907. {
  17908. QFileInfo info(argument<QString> (0,context));
  17909. QScriptValue retval(engine,info.baseName());
  17910. return retval;
  17911. }
  17912. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  17913. {
  17914. QFileInfo info(argument<QString> (0,context));
  17915. QDir dir= info.dir();
  17916. QScriptValue retval(engine,dir.path());
  17917. return retval;
  17918. }
  17919. /*:186*//*187:*/
  17920. #line 4313 "./typica.w"
  17921. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  17922. {
  17923. SqlQueryConnection h;
  17924. QSqlQuery*query= h.operator->();
  17925. QString q= "SELECT file FROM files WHERE id = :file";
  17926. query->prepare(q);
  17927. query->bindValue(":file",argument<int> (0,context));
  17928. query->exec();
  17929. query->next();
  17930. QByteArray array= query->value(0).toByteArray();
  17931. QFile file(argument<QString> (1,context));
  17932. file.open(QIODevice::WriteOnly);
  17933. file.write(array);
  17934. file.close();
  17935. return QScriptValue();
  17936. }
  17937. /*:187*//*188:*/
  17938. #line 4334 "./typica.w"
  17939. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  17940. {
  17941. QString source= argument<QString> (0,context);
  17942. source.remove(0,1);
  17943. source.chop(1);
  17944. QStringList elements= source.split(",");
  17945. QString element;
  17946. QScriptValue dest= engine->newArray(elements.size());
  17947. int i= 0;
  17948. foreach(element,elements)
  17949. {
  17950. if(element.startsWith("\"")&&element.endsWith("\""))
  17951. {
  17952. element.chop(1);
  17953. element= element.remove(0,1);
  17954. }
  17955. dest.setProperty(i,QScriptValue(engine,element));
  17956. i++;
  17957. }
  17958. return dest;
  17959. }
  17960. /*:188*//*189:*/
  17961. #line 4360 "./typica.w"
  17962. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  17963. {
  17964. QString font= argument<QString> (0,context);
  17965. QString classname;
  17966. if(context->argumentCount()> 1)
  17967. {
  17968. classname= argument<QString> (1,context);
  17969. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  17970. }
  17971. else
  17972. {
  17973. QApplication::setFont(QFont(font));
  17974. }
  17975. return QScriptValue();
  17976. }
  17977. /*:189*//*190:*/
  17978. #line 4380 "./typica.w"
  17979. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  17980. {
  17981. SqlQueryConnection h;
  17982. QSqlQuery*query= h.operator->();
  17983. QString q= "SELECT file FROM files WHERE id = :file";
  17984. query->prepare(q);
  17985. query->bindValue(":file",argument<int> (0,context));
  17986. query->exec();
  17987. query->next();
  17988. QByteArray array= query->value(0).toByteArray();
  17989. QBuffer buffer(&array);
  17990. buffer.open(QIODevice::ReadOnly);
  17991. QXmlQuery xquery;
  17992. xquery.bindVariable("profile",&buffer);
  17993. QString xq;
  17994. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  17995. xquery.setQuery(xq);
  17996. QString result;
  17997. xquery.evaluateTo(&result);
  17998. return QScriptValue(result);
  17999. }
  18000. /*:190*//*191:*/
  18001. #line 4407 "./typica.w"
  18002. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  18003. {
  18004. QWidget::setTabOrder(argument<QWidget*> (0,context),
  18005. argument<QWidget*> (1,context));
  18006. return QScriptValue();
  18007. }
  18008. /*:191*//*192:*/
  18009. #line 4418 "./typica.w"
  18010. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  18011. {
  18012. return QScriptValue(QCoreApplication::translate(
  18013. "configuration",
  18014. argument<QString> (1,context).toUtf8().data()));
  18015. }
  18016. /*:192*//*199:*/
  18017. #line 4687 "./typica.w"
  18018. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  18019. {
  18020. QString targetID= argument<QString> (0,context);
  18021. QDomNode element;
  18022. QScriptValue object;
  18023. /*201:*/
  18024. #line 4734 "./typica.w"
  18025. QDomNodeList windows=
  18026. AppInstance->configuration()->documentElement().elementsByTagName("window");
  18027. QDomNode nullNode;
  18028. int i= 0;
  18029. element= nullNode;
  18030. while(i<windows.count())
  18031. {
  18032. element= windows.at(i);
  18033. QDomNamedNodeMap attributes= element.attributes();
  18034. if(attributes.contains("id"))
  18035. {
  18036. if(attributes.namedItem("id").toAttr().value()==targetID)
  18037. {
  18038. break;
  18039. }
  18040. }
  18041. element= nullNode;
  18042. i++;
  18043. }
  18044. /*:201*/
  18045. #line 4693 "./typica.w"
  18046. if(!element.isNull())
  18047. {
  18048. /*202:*/
  18049. #line 4766 "./typica.w"
  18050. ScriptQMainWindow*window= new ScriptQMainWindow;
  18051. window->setObjectName(targetID);
  18052. object= engine->newQObject(window);
  18053. setQMainWindowProperties(object,engine);
  18054. QWidget*central= new(QWidget);
  18055. central->setParent(window);
  18056. central->setObjectName("centralWidget");
  18057. window->setCentralWidget(central);
  18058. if(element.hasChildNodes())
  18059. {
  18060. /*203:*/
  18061. #line 4802 "./typica.w"
  18062. QStack<QWidget*> widgetStack;
  18063. QStack<QLayout*> layoutStack;
  18064. QString windowScript;
  18065. widgetStack.push(central);
  18066. QDomNodeList windowChildren= element.childNodes();
  18067. int i= 0;
  18068. while(i<windowChildren.count())
  18069. {
  18070. QDomNode current;
  18071. QDomElement element;
  18072. current= windowChildren.at(i);
  18073. if(current.isElement())
  18074. {
  18075. element= current.toElement();
  18076. if(element.tagName()=="program")
  18077. {
  18078. windowScript.append(element.text());
  18079. }
  18080. else if(element.tagName()=="layout")
  18081. {
  18082. element.setAttribute("trcontext","configuration");
  18083. addLayoutToWidget(element,&widgetStack,&layoutStack);
  18084. }
  18085. else if(element.tagName()=="menu")
  18086. {
  18087. /*204:*/
  18088. #line 4850 "./typica.w"
  18089. QMenuBar*bar= window->menuBar();
  18090. bar->setParent(window);
  18091. bar->setObjectName("menuBar");
  18092. if(element.hasAttribute("name"))
  18093. {
  18094. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  18095. element.attribute("name").toUtf8().data()));
  18096. menu->setParent(bar);
  18097. if(element.hasAttribute("type"))
  18098. {
  18099. if(element.attribute("type")=="reports")
  18100. {
  18101. if(element.hasAttribute("src"))
  18102. {
  18103. /*670:*/
  18104. #line 14294 "./typica.w"
  18105. QSettings settings;
  18106. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  18107. toString()).
  18108. arg(element.attribute("src"));
  18109. QDir::addSearchPath("reports",reportDirectory);
  18110. QDir directory(reportDirectory);
  18111. directory.setFilter(QDir::Files);
  18112. directory.setSorting(QDir::Name);
  18113. QStringList nameFilter;
  18114. nameFilter<<"*.xml";
  18115. directory.setNameFilters(nameFilter);
  18116. QFileInfoList reportFiles= directory.entryInfoList();
  18117. for(int i= 0;i<reportFiles.size();i++)
  18118. {
  18119. QFileInfo reportFile= reportFiles.at(i);
  18120. /*674:*/
  18121. #line 14374 "./typica.w"
  18122. QString path= reportFile.absoluteFilePath();
  18123. QFile file(path);
  18124. if(file.open(QIODevice::ReadOnly))
  18125. {
  18126. QDomDocument document;
  18127. document.setContent(&file,true);
  18128. QDomElement root= document.documentElement();
  18129. QString translationContext= root.attribute("id");
  18130. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  18131. if(!titleNode.isNull())
  18132. {
  18133. QDomElement titleElement= titleNode.toElement();
  18134. QString title= QCoreApplication::translate("configuration",
  18135. titleElement.text().toUtf8().data());
  18136. if(!title.isEmpty())
  18137. {
  18138. QStringList hierarchy= title.split(":->");
  18139. QMenu*insertionPoint= menu;
  18140. /*675:*/
  18141. #line 14403 "./typica.w"
  18142. for(int j= 0;j<hierarchy.size()-1;j++)
  18143. {
  18144. QObjectList menuList= insertionPoint->children();
  18145. bool menuFound= false;
  18146. for(int k= 0;k<menuList.size();k++)
  18147. {
  18148. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  18149. if(currentItem)
  18150. {
  18151. if(currentItem->title()==hierarchy.at(j))
  18152. {
  18153. menuFound= true;
  18154. insertionPoint= currentItem;
  18155. break;
  18156. }
  18157. }
  18158. }
  18159. if(!menuFound)
  18160. {
  18161. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  18162. }
  18163. }
  18164. /*:675*/
  18165. #line 14393 "./typica.w"
  18166. ReportAction*action= new ReportAction(path,hierarchy.last());
  18167. insertionPoint->addAction(action);
  18168. }
  18169. }
  18170. }
  18171. /*:674*/
  18172. #line 14310 "./typica.w"
  18173. }
  18174. /*:670*/
  18175. #line 4865 "./typica.w"
  18176. }
  18177. }
  18178. }
  18179. if(element.hasChildNodes())
  18180. {
  18181. /*205:*/
  18182. #line 4878 "./typica.w"
  18183. QDomNodeList menuItems= element.childNodes();
  18184. int j= 0;
  18185. while(j<menuItems.count())
  18186. {
  18187. QDomNode item= menuItems.at(j);
  18188. if(item.isElement())
  18189. {
  18190. QDomElement itemElement= item.toElement();
  18191. if(itemElement.tagName()=="item")
  18192. {
  18193. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  18194. itemElement.text().toUtf8().data()),menu);
  18195. if(itemElement.hasAttribute("id"))
  18196. {
  18197. itemAction->setObjectName(itemElement.attribute("id"));
  18198. }
  18199. if(itemElement.hasAttribute("shortcut"))
  18200. {
  18201. itemAction->setShortcut(itemElement.attribute("shortcut"));
  18202. }
  18203. menu->addAction(itemAction);
  18204. }
  18205. else if(itemElement.tagName()=="separator")
  18206. {
  18207. menu->addSeparator();
  18208. }
  18209. else if(itemElement.tagName()=="plugins")
  18210. {
  18211. /*695:*/
  18212. #line 21 "./plugins.w"
  18213. QMenu*pluginMenu= new QMenu(menu);
  18214. if(itemElement.hasAttribute("id"))
  18215. {
  18216. pluginMenu->setObjectName(itemElement.attribute("id"));
  18217. }
  18218. if(itemElement.hasAttribute("title"))
  18219. {
  18220. pluginMenu->setTitle(itemElement.attribute("title"));
  18221. }
  18222. if(itemElement.hasAttribute("src"))
  18223. {
  18224. QSettings settings;
  18225. QString pluginDirectory= QString("%1/%2").
  18226. arg(settings.value("config").toString()).
  18227. arg(itemElement.attribute("src"));
  18228. QDir directory(pluginDirectory);
  18229. directory.setFilter(QDir::Files);
  18230. directory.setSorting(QDir::Name);
  18231. QStringList nameFilter;
  18232. nameFilter<<"*.js";
  18233. directory.setNameFilters(nameFilter);
  18234. QFileInfoList pluginFiles= directory.entryInfoList();
  18235. for(int k= 0;k<pluginFiles.size();k++)
  18236. {
  18237. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  18238. if(itemElement.hasAttribute("preRun"))
  18239. {
  18240. pa->setPreRun(itemElement.attribute("preRun"));
  18241. }
  18242. if(itemElement.hasAttribute("postRun"))
  18243. {
  18244. pa->setPostRun(itemElement.attribute("postRun"));
  18245. }
  18246. pluginMenu->addAction(pa);
  18247. }
  18248. }
  18249. menu->addMenu(pluginMenu);
  18250. /*:695*/
  18251. #line 4907 "./typica.w"
  18252. }
  18253. }
  18254. j++;
  18255. }
  18256. #line 1 "./helpmenu.w"
  18257. /*:205*/
  18258. #line 4871 "./typica.w"
  18259. }
  18260. }
  18261. /*:204*/
  18262. #line 4828 "./typica.w"
  18263. }
  18264. }
  18265. i++;
  18266. }
  18267. QScriptValue oldThis= context->thisObject();
  18268. context->setThisObject(object);
  18269. QScriptValue result= engine->evaluate(windowScript);
  18270. /*196:*/
  18271. #line 4581 "./typica.w"
  18272. if(engine->hasUncaughtException())
  18273. {
  18274. int line= engine->uncaughtExceptionLineNumber();
  18275. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  18276. result.toString();
  18277. QString trace;
  18278. foreach(trace,engine->uncaughtExceptionBacktrace())
  18279. {
  18280. qDebug()<<trace;
  18281. }
  18282. }
  18283. /*:196*/
  18284. #line 4836 "./typica.w"
  18285. context->setThisObject(oldThis);
  18286. /*:203*/
  18287. #line 4777 "./typica.w"
  18288. }
  18289. /*206:*/
  18290. #line 9 "./helpmenu.w"
  18291. HelpMenu*helpMenu= new HelpMenu();
  18292. window->menuBar()->addMenu(helpMenu);
  18293. /*:206*/
  18294. #line 4779 "./typica.w"
  18295. window->show();
  18296. window->setupFinished();
  18297. /*:202*/
  18298. #line 4696 "./typica.w"
  18299. }
  18300. return object;
  18301. }
  18302. /*:199*//*200:*/
  18303. #line 4707 "./typica.w"
  18304. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  18305. {
  18306. QString targetID= argument<QString> (0,context);
  18307. QFile file(QString("reports:%1").arg(targetID));
  18308. QScriptValue object;
  18309. if(file.open(QIODevice::ReadOnly))
  18310. {
  18311. QDomDocument document;
  18312. document.setContent(&file,true);
  18313. QDomElement element= document.documentElement();
  18314. if(!element.isNull())
  18315. {
  18316. /*202:*/
  18317. #line 4766 "./typica.w"
  18318. ScriptQMainWindow*window= new ScriptQMainWindow;
  18319. window->setObjectName(targetID);
  18320. object= engine->newQObject(window);
  18321. setQMainWindowProperties(object,engine);
  18322. QWidget*central= new(QWidget);
  18323. central->setParent(window);
  18324. central->setObjectName("centralWidget");
  18325. window->setCentralWidget(central);
  18326. if(element.hasChildNodes())
  18327. {
  18328. /*203:*/
  18329. #line 4802 "./typica.w"
  18330. QStack<QWidget*> widgetStack;
  18331. QStack<QLayout*> layoutStack;
  18332. QString windowScript;
  18333. widgetStack.push(central);
  18334. QDomNodeList windowChildren= element.childNodes();
  18335. int i= 0;
  18336. while(i<windowChildren.count())
  18337. {
  18338. QDomNode current;
  18339. QDomElement element;
  18340. current= windowChildren.at(i);
  18341. if(current.isElement())
  18342. {
  18343. element= current.toElement();
  18344. if(element.tagName()=="program")
  18345. {
  18346. windowScript.append(element.text());
  18347. }
  18348. else if(element.tagName()=="layout")
  18349. {
  18350. element.setAttribute("trcontext","configuration");
  18351. addLayoutToWidget(element,&widgetStack,&layoutStack);
  18352. }
  18353. else if(element.tagName()=="menu")
  18354. {
  18355. /*204:*/
  18356. #line 4850 "./typica.w"
  18357. QMenuBar*bar= window->menuBar();
  18358. bar->setParent(window);
  18359. bar->setObjectName("menuBar");
  18360. if(element.hasAttribute("name"))
  18361. {
  18362. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  18363. element.attribute("name").toUtf8().data()));
  18364. menu->setParent(bar);
  18365. if(element.hasAttribute("type"))
  18366. {
  18367. if(element.attribute("type")=="reports")
  18368. {
  18369. if(element.hasAttribute("src"))
  18370. {
  18371. /*670:*/
  18372. #line 14294 "./typica.w"
  18373. QSettings settings;
  18374. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  18375. toString()).
  18376. arg(element.attribute("src"));
  18377. QDir::addSearchPath("reports",reportDirectory);
  18378. QDir directory(reportDirectory);
  18379. directory.setFilter(QDir::Files);
  18380. directory.setSorting(QDir::Name);
  18381. QStringList nameFilter;
  18382. nameFilter<<"*.xml";
  18383. directory.setNameFilters(nameFilter);
  18384. QFileInfoList reportFiles= directory.entryInfoList();
  18385. for(int i= 0;i<reportFiles.size();i++)
  18386. {
  18387. QFileInfo reportFile= reportFiles.at(i);
  18388. /*674:*/
  18389. #line 14374 "./typica.w"
  18390. QString path= reportFile.absoluteFilePath();
  18391. QFile file(path);
  18392. if(file.open(QIODevice::ReadOnly))
  18393. {
  18394. QDomDocument document;
  18395. document.setContent(&file,true);
  18396. QDomElement root= document.documentElement();
  18397. QString translationContext= root.attribute("id");
  18398. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  18399. if(!titleNode.isNull())
  18400. {
  18401. QDomElement titleElement= titleNode.toElement();
  18402. QString title= QCoreApplication::translate("configuration",
  18403. titleElement.text().toUtf8().data());
  18404. if(!title.isEmpty())
  18405. {
  18406. QStringList hierarchy= title.split(":->");
  18407. QMenu*insertionPoint= menu;
  18408. /*675:*/
  18409. #line 14403 "./typica.w"
  18410. for(int j= 0;j<hierarchy.size()-1;j++)
  18411. {
  18412. QObjectList menuList= insertionPoint->children();
  18413. bool menuFound= false;
  18414. for(int k= 0;k<menuList.size();k++)
  18415. {
  18416. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  18417. if(currentItem)
  18418. {
  18419. if(currentItem->title()==hierarchy.at(j))
  18420. {
  18421. menuFound= true;
  18422. insertionPoint= currentItem;
  18423. break;
  18424. }
  18425. }
  18426. }
  18427. if(!menuFound)
  18428. {
  18429. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  18430. }
  18431. }
  18432. /*:675*/
  18433. #line 14393 "./typica.w"
  18434. ReportAction*action= new ReportAction(path,hierarchy.last());
  18435. insertionPoint->addAction(action);
  18436. }
  18437. }
  18438. }
  18439. /*:674*/
  18440. #line 14310 "./typica.w"
  18441. }
  18442. /*:670*/
  18443. #line 4865 "./typica.w"
  18444. }
  18445. }
  18446. }
  18447. if(element.hasChildNodes())
  18448. {
  18449. /*205:*/
  18450. #line 4878 "./typica.w"
  18451. QDomNodeList menuItems= element.childNodes();
  18452. int j= 0;
  18453. while(j<menuItems.count())
  18454. {
  18455. QDomNode item= menuItems.at(j);
  18456. if(item.isElement())
  18457. {
  18458. QDomElement itemElement= item.toElement();
  18459. if(itemElement.tagName()=="item")
  18460. {
  18461. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  18462. itemElement.text().toUtf8().data()),menu);
  18463. if(itemElement.hasAttribute("id"))
  18464. {
  18465. itemAction->setObjectName(itemElement.attribute("id"));
  18466. }
  18467. if(itemElement.hasAttribute("shortcut"))
  18468. {
  18469. itemAction->setShortcut(itemElement.attribute("shortcut"));
  18470. }
  18471. menu->addAction(itemAction);
  18472. }
  18473. else if(itemElement.tagName()=="separator")
  18474. {
  18475. menu->addSeparator();
  18476. }
  18477. else if(itemElement.tagName()=="plugins")
  18478. {
  18479. /*695:*/
  18480. #line 21 "./plugins.w"
  18481. QMenu*pluginMenu= new QMenu(menu);
  18482. if(itemElement.hasAttribute("id"))
  18483. {
  18484. pluginMenu->setObjectName(itemElement.attribute("id"));
  18485. }
  18486. if(itemElement.hasAttribute("title"))
  18487. {
  18488. pluginMenu->setTitle(itemElement.attribute("title"));
  18489. }
  18490. if(itemElement.hasAttribute("src"))
  18491. {
  18492. QSettings settings;
  18493. QString pluginDirectory= QString("%1/%2").
  18494. arg(settings.value("config").toString()).
  18495. arg(itemElement.attribute("src"));
  18496. QDir directory(pluginDirectory);
  18497. directory.setFilter(QDir::Files);
  18498. directory.setSorting(QDir::Name);
  18499. QStringList nameFilter;
  18500. nameFilter<<"*.js";
  18501. directory.setNameFilters(nameFilter);
  18502. QFileInfoList pluginFiles= directory.entryInfoList();
  18503. for(int k= 0;k<pluginFiles.size();k++)
  18504. {
  18505. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  18506. if(itemElement.hasAttribute("preRun"))
  18507. {
  18508. pa->setPreRun(itemElement.attribute("preRun"));
  18509. }
  18510. if(itemElement.hasAttribute("postRun"))
  18511. {
  18512. pa->setPostRun(itemElement.attribute("postRun"));
  18513. }
  18514. pluginMenu->addAction(pa);
  18515. }
  18516. }
  18517. menu->addMenu(pluginMenu);
  18518. /*:695*/
  18519. #line 4907 "./typica.w"
  18520. }
  18521. }
  18522. j++;
  18523. }
  18524. #line 1 "./helpmenu.w"
  18525. /*:205*/
  18526. #line 4871 "./typica.w"
  18527. }
  18528. }
  18529. /*:204*/
  18530. #line 4828 "./typica.w"
  18531. }
  18532. }
  18533. i++;
  18534. }
  18535. QScriptValue oldThis= context->thisObject();
  18536. context->setThisObject(object);
  18537. QScriptValue result= engine->evaluate(windowScript);
  18538. /*196:*/
  18539. #line 4581 "./typica.w"
  18540. if(engine->hasUncaughtException())
  18541. {
  18542. int line= engine->uncaughtExceptionLineNumber();
  18543. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  18544. result.toString();
  18545. QString trace;
  18546. foreach(trace,engine->uncaughtExceptionBacktrace())
  18547. {
  18548. qDebug()<<trace;
  18549. }
  18550. }
  18551. /*:196*/
  18552. #line 4836 "./typica.w"
  18553. context->setThisObject(oldThis);
  18554. /*:203*/
  18555. #line 4777 "./typica.w"
  18556. }
  18557. /*206:*/
  18558. #line 9 "./helpmenu.w"
  18559. HelpMenu*helpMenu= new HelpMenu();
  18560. window->menuBar()->addMenu(helpMenu);
  18561. /*:206*/
  18562. #line 4779 "./typica.w"
  18563. window->show();
  18564. window->setupFinished();
  18565. /*:202*/
  18566. #line 4720 "./typica.w"
  18567. }
  18568. file.close();
  18569. }
  18570. return object;
  18571. }
  18572. /*:200*//*218:*/
  18573. #line 4927 "./typica.w"
  18574. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  18575. QStack<QLayout*> *layoutStack)
  18576. {
  18577. if(element.hasAttribute("type"))
  18578. {
  18579. /*219:*/
  18580. #line 4948 "./typica.w"
  18581. QLayout*layout;
  18582. QString layoutType= element.attribute("type");
  18583. if(layoutType=="horizontal")
  18584. {
  18585. layout= new QHBoxLayout;
  18586. layoutStack->push(layout);
  18587. populateBoxLayout(element,widgetStack,layoutStack);
  18588. }
  18589. else if(layoutType=="vertical")
  18590. {
  18591. layout= new QVBoxLayout;
  18592. layoutStack->push(layout);
  18593. populateBoxLayout(element,widgetStack,layoutStack);
  18594. }
  18595. else if(layoutType=="grid")
  18596. {
  18597. layout= new QGridLayout;
  18598. layoutStack->push(layout);
  18599. populateGridLayout(element,widgetStack,layoutStack);
  18600. }
  18601. else if(layoutType=="stack")
  18602. {
  18603. layout= new QStackedLayout;
  18604. layoutStack->push(layout);
  18605. populateStackedLayout(element,widgetStack,layoutStack);
  18606. }
  18607. if(element.hasAttribute("id"))
  18608. {
  18609. layout->setObjectName(element.attribute("id"));
  18610. }
  18611. if(element.hasAttribute("spacing"))
  18612. {
  18613. layout->setSpacing(element.attribute("spacing").toInt());
  18614. }
  18615. if(element.hasAttribute("margin"))
  18616. {
  18617. int m= element.attribute("margin").toInt();
  18618. layout->setContentsMargins(m,m,m,m);
  18619. }
  18620. /*:219*/
  18621. #line 4933 "./typica.w"
  18622. QWidget*widget= widgetStack->top();
  18623. if(layout)
  18624. {
  18625. widget->setLayout(layout);
  18626. }
  18627. layoutStack->pop();
  18628. }
  18629. }
  18630. /*:218*//*220:*/
  18631. #line 4995 "./typica.w"
  18632. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18633. QStack<QLayout*> *layoutStack)
  18634. {
  18635. QDomNodeList children= element.childNodes();
  18636. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  18637. for(int i= 0;i<children.count();i++)
  18638. {
  18639. QDomNode current;
  18640. QDomElement currentElement;
  18641. current= children.at(i);
  18642. if(current.isElement())
  18643. {
  18644. currentElement= current.toElement();
  18645. if(currentElement.tagName()=="page")
  18646. {
  18647. QWidget*widget= new QWidget;
  18648. layout->addWidget(widget);
  18649. widgetStack->push(widget);
  18650. currentElement.setAttribute("trcontext","configuration");
  18651. populateWidget(currentElement,widgetStack,layoutStack);
  18652. widgetStack->pop();
  18653. }
  18654. }
  18655. }
  18656. }
  18657. /*:220*//*222:*/
  18658. #line 5034 "./typica.w"
  18659. void addTabBarToLayout(QDomElement element,QStack<QWidget*> *,QStack<QLayout*> *layoutStack)
  18660. {
  18661. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18662. QTabBar*widget= new QTabBar;
  18663. layout->addWidget(widget);
  18664. if(!element.attribute("id").isEmpty())
  18665. {
  18666. widget->setObjectName(element.attribute("id"));
  18667. }
  18668. }
  18669. /*:222*//*224:*/
  18670. #line 5056 "./typica.w"
  18671. QScriptValue constructQTabBar(QScriptContext*,QScriptEngine*engine)
  18672. {
  18673. QScriptValue object= engine->newQObject(new QTabBar);
  18674. setQTabBarProperties(object,engine);
  18675. return object;
  18676. }
  18677. /*:224*//*225:*/
  18678. #line 5067 "./typica.w"
  18679. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine)
  18680. {
  18681. setQWidgetProperties(value,engine);
  18682. value.setProperty("addTab",engine->newFunction(QTabBar_addTab));
  18683. }
  18684. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*)
  18685. {
  18686. QTabBar*self= getself<QTabBar*> (context);
  18687. if(context->argumentCount()> 0)
  18688. {
  18689. self->addTab(argument<QString> (0,context));
  18690. }
  18691. else
  18692. {
  18693. context->throwError("Incorrect number of arguments passed to "
  18694. "QTabBar::addTab().");
  18695. }
  18696. return QScriptValue();
  18697. }
  18698. /*:225*//*227:*/
  18699. #line 5102 "./typica.w"
  18700. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18701. QStack<QLayout*> *layoutStack)
  18702. {
  18703. QDomNodeList children= element.childNodes();
  18704. int row= -1;
  18705. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  18706. for(int i= 0;i<children.count();i++)
  18707. {
  18708. QDomNode current;
  18709. QDomElement currentElement;
  18710. current= children.at(i);
  18711. if(current.isElement())
  18712. {
  18713. currentElement= current.toElement();
  18714. if(currentElement.tagName()=="row")
  18715. {
  18716. row++;
  18717. if(currentElement.hasAttribute("height"))
  18718. {
  18719. layout->setRowMinimumHeight(row,
  18720. currentElement.attribute("height").toInt());
  18721. }
  18722. if(currentElement.hasAttribute("stretch"))
  18723. {
  18724. layout->setRowStretch(row,
  18725. currentElement.attribute("stretch").toInt());
  18726. }
  18727. /*228:*/
  18728. #line 5158 "./typica.w"
  18729. int column= -1;
  18730. QDomNodeList rowChildren= currentElement.childNodes();
  18731. for(int j= 0;j<rowChildren.count();j++)
  18732. {
  18733. QDomNode columnNode;
  18734. QDomElement columnElement;
  18735. columnNode= rowChildren.at(j);
  18736. if(columnNode.isElement())
  18737. {
  18738. columnElement= columnNode.toElement();
  18739. if(columnElement.tagName()=="column")
  18740. {
  18741. column++;
  18742. if(columnElement.hasAttribute("column"))
  18743. {
  18744. column= columnElement.attribute("column").toInt();
  18745. }
  18746. if(columnElement.hasAttribute("width"))
  18747. {
  18748. layout->setColumnMinimumWidth(column,
  18749. columnElement.attribute("width").toInt());
  18750. }
  18751. if(columnElement.hasAttribute("stretch"))
  18752. {
  18753. layout->setColumnStretch(column,
  18754. columnElement.attribute("stretch").toInt());
  18755. }
  18756. int hspan= 1;
  18757. int vspan= 1;
  18758. if(columnElement.hasAttribute("rowspan"))
  18759. {
  18760. vspan= columnElement.attribute("rowspan").toInt();
  18761. }
  18762. if(columnElement.hasAttribute("colspan"))
  18763. {
  18764. hspan= columnElement.attribute("colspan").toInt();
  18765. }
  18766. QHBoxLayout*cell= new QHBoxLayout;
  18767. layout->addLayout(cell,row,column,vspan,hspan);
  18768. layoutStack->push(cell);
  18769. columnElement.setAttribute("trcontext","configuration");
  18770. populateBoxLayout(columnElement,widgetStack,layoutStack);
  18771. layoutStack->pop();
  18772. }
  18773. }
  18774. }
  18775. /*:228*/
  18776. #line 5130 "./typica.w"
  18777. }
  18778. }
  18779. }
  18780. }
  18781. /*:227*//*229:*/
  18782. #line 5209 "./typica.w"
  18783. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18784. QStack<QLayout*> *layoutStack)
  18785. {
  18786. QDomNodeList children= element.childNodes();
  18787. for(int i= 0;i<children.count();i++)
  18788. {
  18789. QDomNode current;
  18790. QDomElement currentElement;
  18791. current= children.at(i);
  18792. if(current.isElement())
  18793. {
  18794. currentElement= current.toElement();
  18795. currentElement.setAttribute("trcontext","configuration");
  18796. if(currentElement.tagName()=="button")
  18797. {
  18798. addButtonToLayout(currentElement,widgetStack,layoutStack);
  18799. }
  18800. else if(currentElement.tagName()=="calendar")
  18801. {
  18802. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  18803. }
  18804. else if(currentElement.tagName()=="timeedit")
  18805. {
  18806. addTimeEditToLayout(currentElement,widgetStack,layoutStack);
  18807. }
  18808. else if(currentElement.tagName()=="decoration")
  18809. {
  18810. addDecorationToLayout(currentElement,widgetStack,
  18811. layoutStack);
  18812. }
  18813. else if(currentElement.tagName()=="layout")
  18814. {
  18815. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  18816. }
  18817. else if(currentElement.tagName()=="splitter")
  18818. {
  18819. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  18820. }
  18821. else if(currentElement.tagName()=="label")
  18822. {
  18823. QBoxLayout*layout=
  18824. qobject_cast<QBoxLayout*> (layoutStack->top());
  18825. QLabel*label= new QLabel(QCoreApplication::translate(
  18826. "configuration",
  18827. currentElement.text().toUtf8().data()));
  18828. if(currentElement.hasAttribute("id"))
  18829. {
  18830. label->setObjectName(currentElement.attribute("id"));
  18831. }
  18832. layout->addWidget(label);
  18833. }
  18834. else if(currentElement.tagName()=="lcdtemperature")
  18835. {
  18836. addTemperatureDisplayToLayout(currentElement,widgetStack,
  18837. layoutStack);
  18838. }
  18839. else if(currentElement.tagName()=="lcdtimer")
  18840. {
  18841. addTimerDisplayToLayout(currentElement,widgetStack,
  18842. layoutStack);
  18843. }
  18844. else if(currentElement.tagName()=="line")
  18845. {
  18846. addLineToLayout(currentElement,widgetStack,layoutStack);
  18847. }
  18848. else if(currentElement.tagName()=="report")
  18849. {
  18850. addReportToLayout(currentElement,widgetStack,layoutStack);
  18851. }
  18852. else if(currentElement.tagName()=="sqldrop")
  18853. {
  18854. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  18855. }
  18856. else if(currentElement.tagName()=="sqltablearray")
  18857. {
  18858. addSaltToLayout(currentElement,widgetStack,layoutStack);
  18859. }
  18860. else if(currentElement.tagName()=="sqlview")
  18861. {
  18862. addSqlQueryViewToLayout(currentElement,widgetStack,
  18863. layoutStack);
  18864. }
  18865. else if(currentElement.tagName()=="textarea")
  18866. {
  18867. addTextToLayout(currentElement,widgetStack,layoutStack);
  18868. }
  18869. else if(currentElement.tagName()=="spinbox")
  18870. {
  18871. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  18872. }
  18873. else if(currentElement.tagName()=="formarray")
  18874. {
  18875. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  18876. }
  18877. else if(currentElement.tagName()=="hscale")
  18878. {
  18879. addScaleControlToLayout(currentElement,widgetStack,
  18880. layoutStack);
  18881. }
  18882. else if(currentElement.tagName()=="vscale")
  18883. {
  18884. addIntensityControlToLayout(currentElement,widgetStack,
  18885. layoutStack);
  18886. }
  18887. else if(currentElement.tagName()=="webview")
  18888. {
  18889. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  18890. }
  18891. else if(currentElement.tagName()=="stretch")
  18892. {
  18893. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18894. layout->addStretch();
  18895. }
  18896. /*54:*/
  18897. #line 1569 "./typica.w"
  18898. else if(currentElement.tagName()=="svgwidget")
  18899. {
  18900. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  18901. }
  18902. /*:54*//*221:*/
  18903. #line 5026 "./typica.w"
  18904. else if(currentElement.tagName()=="tabbar")
  18905. {
  18906. addTabBarToLayout(currentElement,widgetStack,layoutStack);
  18907. }
  18908. /*:221*//*597:*/
  18909. #line 111 "./printerselector.w"
  18910. else if(currentElement.tagName()=="printerselector")
  18911. {
  18912. addPrinterSelectorToLayout(currentElement,widgetStack,layoutStack);
  18913. }
  18914. #line 12877 "./typica.w"
  18915. /*:597*//*718:*/
  18916. #line 451 "./daterangeselector.w"
  18917. else if(currentElement.tagName()=="daterange")
  18918. {
  18919. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  18920. }
  18921. /*:718*//*1177:*/
  18922. #line 135 "./roastcoloredit.w"
  18923. else if(currentElement.tagName()=="roastcoloredit")
  18924. {
  18925. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18926. RoastColorEdit*edit= new RoastColorEdit;
  18927. if(currentElement.hasAttribute("id"))
  18928. {
  18929. edit->setObjectName(currentElement.attribute("id"));
  18930. }
  18931. layout->addWidget(edit);
  18932. }
  18933. /*:1177*/
  18934. #line 5323 "./typica.w"
  18935. }
  18936. }
  18937. }
  18938. /*:229*//*230:*/
  18939. #line 5331 "./typica.w"
  18940. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18941. QStack<QLayout*> *layoutStack)
  18942. {
  18943. QLayout*targetLayout= layoutStack->pop();
  18944. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  18945. if(element.hasAttribute("type"))
  18946. {
  18947. /*219:*/
  18948. #line 4948 "./typica.w"
  18949. QLayout*layout;
  18950. QString layoutType= element.attribute("type");
  18951. if(layoutType=="horizontal")
  18952. {
  18953. layout= new QHBoxLayout;
  18954. layoutStack->push(layout);
  18955. populateBoxLayout(element,widgetStack,layoutStack);
  18956. }
  18957. else if(layoutType=="vertical")
  18958. {
  18959. layout= new QVBoxLayout;
  18960. layoutStack->push(layout);
  18961. populateBoxLayout(element,widgetStack,layoutStack);
  18962. }
  18963. else if(layoutType=="grid")
  18964. {
  18965. layout= new QGridLayout;
  18966. layoutStack->push(layout);
  18967. populateGridLayout(element,widgetStack,layoutStack);
  18968. }
  18969. else if(layoutType=="stack")
  18970. {
  18971. layout= new QStackedLayout;
  18972. layoutStack->push(layout);
  18973. populateStackedLayout(element,widgetStack,layoutStack);
  18974. }
  18975. if(element.hasAttribute("id"))
  18976. {
  18977. layout->setObjectName(element.attribute("id"));
  18978. }
  18979. if(element.hasAttribute("spacing"))
  18980. {
  18981. layout->setSpacing(element.attribute("spacing").toInt());
  18982. }
  18983. if(element.hasAttribute("margin"))
  18984. {
  18985. int m= element.attribute("margin").toInt();
  18986. layout->setContentsMargins(m,m,m,m);
  18987. }
  18988. /*:219*/
  18989. #line 5339 "./typica.w"
  18990. boxLayout->addLayout(layout);
  18991. layoutStack->pop();
  18992. }
  18993. layoutStack->push(targetLayout);
  18994. }
  18995. /*:230*//*231:*/
  18996. #line 5350 "./typica.w"
  18997. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18998. QStack<QLayout*> *layoutStack)
  18999. {
  19000. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19001. QSplitter*splitter= new(QSplitter);
  19002. layout->addWidget(splitter);
  19003. /*232:*/
  19004. #line 5363 "./typica.w"
  19005. QString orientation= element.attribute("type");
  19006. if(orientation=="horizontal")
  19007. {
  19008. splitter->setOrientation(Qt::Horizontal);
  19009. }
  19010. else if(orientation=="vertical")
  19011. {
  19012. splitter->setOrientation(Qt::Vertical);
  19013. }
  19014. QString id= element.attribute("id");
  19015. if(!id.isEmpty())
  19016. {
  19017. splitter->setObjectName(id);
  19018. }
  19019. if(element.hasChildNodes())
  19020. {
  19021. widgetStack->push(splitter);
  19022. populateSplitter(element,widgetStack,layoutStack);
  19023. widgetStack->pop();
  19024. }
  19025. /*:232*/
  19026. #line 5357 "./typica.w"
  19027. }
  19028. /*:231*//*233:*/
  19029. #line 5389 "./typica.w"
  19030. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19031. QStack<QLayout*> *layoutStack)
  19032. {
  19033. QDomNodeList children= element.childNodes();
  19034. for(int i= 0;i<children.count();i++)
  19035. {
  19036. QDomNode current;
  19037. QDomElement currentElement;
  19038. current= children.at(i);
  19039. if(current.isElement())
  19040. {
  19041. currentElement= current.toElement();
  19042. currentElement.setAttribute("trcontext","configuration");
  19043. if(currentElement.tagName()=="decoration")
  19044. {
  19045. addDecorationToSplitter(currentElement,widgetStack,
  19046. layoutStack);
  19047. }
  19048. else if(currentElement.tagName()=="graph")
  19049. {
  19050. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  19051. }
  19052. else if(currentElement.tagName()=="splitter")
  19053. {
  19054. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  19055. }
  19056. else if(currentElement.tagName()=="lcdtemperature")
  19057. {
  19058. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  19059. layoutStack);
  19060. }
  19061. else if(currentElement.tagName()=="lcdtimer")
  19062. {
  19063. addTimerDisplayToSplitter(currentElement,widgetStack,
  19064. layoutStack);
  19065. }
  19066. else if(currentElement.tagName()=="measurementtable")
  19067. {
  19068. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  19069. }
  19070. else if(currentElement.tagName()=="widget")
  19071. {
  19072. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  19073. }
  19074. }
  19075. }
  19076. }
  19077. /*:233*//*234:*/
  19078. #line 5440 "./typica.w"
  19079. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19080. QStack<QLayout*> *layoutStack)
  19081. {
  19082. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  19083. QSplitter*splitter= new(QSplitter);
  19084. splitter->setParent(parent);
  19085. parent->addWidget(splitter);
  19086. /*232:*/
  19087. #line 5363 "./typica.w"
  19088. QString orientation= element.attribute("type");
  19089. if(orientation=="horizontal")
  19090. {
  19091. splitter->setOrientation(Qt::Horizontal);
  19092. }
  19093. else if(orientation=="vertical")
  19094. {
  19095. splitter->setOrientation(Qt::Vertical);
  19096. }
  19097. QString id= element.attribute("id");
  19098. if(!id.isEmpty())
  19099. {
  19100. splitter->setObjectName(id);
  19101. }
  19102. if(element.hasChildNodes())
  19103. {
  19104. widgetStack->push(splitter);
  19105. populateSplitter(element,widgetStack,layoutStack);
  19106. widgetStack->pop();
  19107. }
  19108. /*:232*/
  19109. #line 5448 "./typica.w"
  19110. }
  19111. /*:234*//*235:*/
  19112. #line 5457 "./typica.w"
  19113. void addTemperatureDisplayToSplitter(QDomElement element,
  19114. QStack<QWidget*> *widgetStack,
  19115. QStack<QLayout*> *)
  19116. {
  19117. TemperatureDisplay*display= new(TemperatureDisplay);
  19118. if(element.hasAttribute("id"))
  19119. {
  19120. display->setObjectName(element.attribute("id"));
  19121. }
  19122. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19123. splitter->addWidget(display);
  19124. }
  19125. void addTemperatureDisplayToLayout(QDomElement element,
  19126. QStack<QWidget*> *,
  19127. QStack<QLayout*> *layoutStack)
  19128. {
  19129. TemperatureDisplay*display= new(TemperatureDisplay);
  19130. if(element.hasAttribute("id"))
  19131. {
  19132. display->setObjectName(element.attribute("id"));
  19133. }
  19134. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19135. layout->addWidget(display);
  19136. }
  19137. /*:235*//*236:*/
  19138. #line 5488 "./typica.w"
  19139. void addTimerDisplayToSplitter(QDomElement element,
  19140. QStack<QWidget*> *widgetStack,
  19141. QStack<QLayout*> *)
  19142. {
  19143. TimerDisplay*display= new(TimerDisplay);
  19144. if(element.hasAttribute("id"))
  19145. {
  19146. display->setObjectName(element.attribute("id"));
  19147. }
  19148. if(element.hasAttribute("format"))
  19149. {
  19150. display->setDisplayFormat(element.attribute("format"));
  19151. }
  19152. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19153. splitter->addWidget(display);
  19154. }
  19155. void addTimerDisplayToLayout(QDomElement element,
  19156. QStack<QWidget*> *,
  19157. QStack<QLayout*> *layoutStack)
  19158. {
  19159. TimerDisplay*display= new(TimerDisplay);
  19160. if(element.hasAttribute("id"))
  19161. {
  19162. display->setObjectName(element.attribute("id"));
  19163. }
  19164. if(element.hasAttribute("format"))
  19165. {
  19166. display->setDisplayFormat(element.attribute("format"));
  19167. }
  19168. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19169. layout->addWidget(display);
  19170. }
  19171. /*:236*//*237:*/
  19172. #line 5526 "./typica.w"
  19173. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  19174. QStack<QLayout*> *layoutStack)
  19175. {
  19176. /*238:*/
  19177. #line 5547 "./typica.w"
  19178. QString labelText=
  19179. QCoreApplication::translate("configuration",
  19180. element.attribute("name").toUtf8().data());
  19181. Qt::Orientations orientation= Qt::Horizontal;
  19182. if(element.hasAttribute("type"))
  19183. {
  19184. if(element.attribute("type")=="horizontal")
  19185. {
  19186. orientation= Qt::Horizontal;
  19187. }
  19188. else if(element.attribute("type")=="vertical")
  19189. {
  19190. orientation= Qt::Vertical;
  19191. }
  19192. }
  19193. /*239:*/
  19194. #line 5574 "./typica.w"
  19195. QWidget*theWidget= NULL;
  19196. QDomNodeList children= element.childNodes();
  19197. for(int i= 0;i<children.count();i++)
  19198. {
  19199. QDomNode item= children.at(i);
  19200. if(item.isElement())
  19201. {
  19202. QDomElement itemElement= item.toElement();
  19203. if(itemElement.tagName()=="lcdtemperature")
  19204. {
  19205. TemperatureDisplay*display= new TemperatureDisplay;
  19206. if(itemElement.hasAttribute("id"))
  19207. {
  19208. display->setObjectName(itemElement.attribute("id"));
  19209. }
  19210. theWidget= display;
  19211. }
  19212. else if(itemElement.tagName()=="lcdtimer")
  19213. {
  19214. TimerDisplay*display= new TimerDisplay;
  19215. if(itemElement.hasAttribute("id"))
  19216. {
  19217. display->setObjectName(itemElement.attribute("id"));
  19218. }
  19219. if(itemElement.hasAttribute("format"))
  19220. {
  19221. display->setDisplayFormat(itemElement.attribute("format"));
  19222. }
  19223. theWidget= display;
  19224. }
  19225. }
  19226. }
  19227. /*:239*/
  19228. #line 5563 "./typica.w"
  19229. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  19230. orientation);
  19231. if(element.hasAttribute("id"))
  19232. {
  19233. decoration->setObjectName(element.attribute("id"));
  19234. }
  19235. /*:238*/
  19236. #line 5530 "./typica.w"
  19237. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19238. layout->addWidget(decoration);
  19239. }
  19240. void addDecorationToSplitter(QDomElement element,
  19241. QStack<QWidget*> *widgetStack,
  19242. QStack<QLayout*> *)
  19243. {
  19244. /*238:*/
  19245. #line 5547 "./typica.w"
  19246. QString labelText=
  19247. QCoreApplication::translate("configuration",
  19248. element.attribute("name").toUtf8().data());
  19249. Qt::Orientations orientation= Qt::Horizontal;
  19250. if(element.hasAttribute("type"))
  19251. {
  19252. if(element.attribute("type")=="horizontal")
  19253. {
  19254. orientation= Qt::Horizontal;
  19255. }
  19256. else if(element.attribute("type")=="vertical")
  19257. {
  19258. orientation= Qt::Vertical;
  19259. }
  19260. }
  19261. /*239:*/
  19262. #line 5574 "./typica.w"
  19263. QWidget*theWidget= NULL;
  19264. QDomNodeList children= element.childNodes();
  19265. for(int i= 0;i<children.count();i++)
  19266. {
  19267. QDomNode item= children.at(i);
  19268. if(item.isElement())
  19269. {
  19270. QDomElement itemElement= item.toElement();
  19271. if(itemElement.tagName()=="lcdtemperature")
  19272. {
  19273. TemperatureDisplay*display= new TemperatureDisplay;
  19274. if(itemElement.hasAttribute("id"))
  19275. {
  19276. display->setObjectName(itemElement.attribute("id"));
  19277. }
  19278. theWidget= display;
  19279. }
  19280. else if(itemElement.tagName()=="lcdtimer")
  19281. {
  19282. TimerDisplay*display= new TimerDisplay;
  19283. if(itemElement.hasAttribute("id"))
  19284. {
  19285. display->setObjectName(itemElement.attribute("id"));
  19286. }
  19287. if(itemElement.hasAttribute("format"))
  19288. {
  19289. display->setDisplayFormat(itemElement.attribute("format"));
  19290. }
  19291. theWidget= display;
  19292. }
  19293. }
  19294. }
  19295. /*:239*/
  19296. #line 5563 "./typica.w"
  19297. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  19298. orientation);
  19299. if(element.hasAttribute("id"))
  19300. {
  19301. decoration->setObjectName(element.attribute("id"));
  19302. }
  19303. /*:238*/
  19304. #line 5539 "./typica.w"
  19305. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19306. splitter->addWidget(decoration);
  19307. }
  19308. /*:237*//*240:*/
  19309. #line 5619 "./typica.w"
  19310. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19311. QStack<QLayout*> *layoutStack)
  19312. {
  19313. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19314. QWidget*widget= new QWidget;
  19315. if(element.hasAttribute("id"))
  19316. {
  19317. widget->setObjectName(element.attribute("id"));
  19318. }
  19319. if(element.hasAttribute("ignoreSizePolicy"))
  19320. {
  19321. if(element.attribute("ignoreSizePolicy")=="true")
  19322. {
  19323. widget->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
  19324. }
  19325. }
  19326. splitter->addWidget(widget);
  19327. if(element.hasChildNodes())
  19328. {
  19329. widgetStack->push(widget);
  19330. populateWidget(element,widgetStack,layoutStack);
  19331. widgetStack->pop();
  19332. }
  19333. }
  19334. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  19335. QStack<QLayout*> *layoutStack)
  19336. {
  19337. QDomNodeList children= element.childNodes();
  19338. for(int i= 0;i<children.count();i++)
  19339. {
  19340. QDomNode current;
  19341. QDomElement currentElement;
  19342. current= children.at(i);
  19343. if(current.isElement())
  19344. {
  19345. currentElement= current.toElement();
  19346. if(currentElement.tagName()=="layout")
  19347. {
  19348. currentElement.setAttribute("trcontext","configuration");
  19349. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  19350. }
  19351. }
  19352. }
  19353. }
  19354. /*:240*//*241:*/
  19355. #line 5670 "./typica.w"
  19356. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  19357. QStack<QLayout*> *layoutStack)
  19358. {
  19359. QAbstractButton*button= NULL;
  19360. QString text=
  19361. QCoreApplication::translate("configuration",
  19362. element.attribute("name").toUtf8().data());
  19363. if(element.hasAttribute("type"))
  19364. {
  19365. QString type= element.attribute("type");
  19366. if(type=="annotation")
  19367. {
  19368. AnnotationButton*abutton= new AnnotationButton(text);
  19369. if(element.hasAttribute("annotation"))
  19370. {
  19371. abutton->setAnnotation(element.attribute("annotation"));
  19372. }
  19373. if(element.hasAttribute("series"))
  19374. {
  19375. abutton->setTemperatureColumn(element.attribute("series").
  19376. toInt());
  19377. }
  19378. if(element.hasAttribute("column"))
  19379. {
  19380. abutton->setAnnotationColumn(element.attribute("column").
  19381. toInt());
  19382. }
  19383. button= abutton;
  19384. }
  19385. else if(type=="check")
  19386. {
  19387. button= new QCheckBox(text);
  19388. }
  19389. else if(type=="push")
  19390. {
  19391. button= new QPushButton(text);
  19392. }
  19393. }
  19394. if(element.hasAttribute("id"))
  19395. {
  19396. button->setObjectName(element.attribute("id"));
  19397. }
  19398. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19399. layout->addWidget(button);
  19400. }
  19401. /*:241*//*242:*/
  19402. #line 5724 "./typica.w"
  19403. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  19404. QStack<QLayout*> *layoutStack)
  19405. {
  19406. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  19407. if(element.hasAttribute("pretext"))
  19408. {
  19409. box->setPretext(QCoreApplication::translate(
  19410. "configuration",
  19411. element.attribute("pretext").toUtf8().data()));
  19412. }
  19413. if(element.hasAttribute("posttext"))
  19414. {
  19415. box->setPosttext(QCoreApplication::translate(
  19416. "configuration",
  19417. element.attribute("posttext").toUtf8().data()));
  19418. }
  19419. if(element.hasAttribute("series"))
  19420. {
  19421. box->setTemperatureColumn(element.attribute("series").toInt());
  19422. }
  19423. if(element.hasAttribute("column"))
  19424. {
  19425. box->setAnnotationColumn(element.attribute("column").toInt());
  19426. }
  19427. if(element.hasAttribute("min"))
  19428. {
  19429. box->setMinimum(element.attribute("min").toDouble());
  19430. }
  19431. if(element.hasAttribute("max"))
  19432. {
  19433. box->setMaximum(element.attribute("max").toDouble());
  19434. }
  19435. if(element.hasAttribute("decimals"))
  19436. {
  19437. box->setDecimals(element.attribute("decimals").toInt());
  19438. }
  19439. if(element.hasAttribute("step"))
  19440. {
  19441. box->setSingleStep(element.attribute("step").toDouble());
  19442. }
  19443. if(element.hasAttribute("id"))
  19444. {
  19445. box->setObjectName(element.attribute("id"));
  19446. }
  19447. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19448. layout->addWidget(box);
  19449. }
  19450. /*:242*//*243:*/
  19451. #line 5784 "./typica.w"
  19452. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19453. QStack<QLayout*> *)
  19454. {
  19455. ZoomLog*widget= new ZoomLog;
  19456. if(element.hasAttribute("id"))
  19457. {
  19458. widget->setObjectName(element.attribute("id"));
  19459. }
  19460. if(element.hasChildNodes())
  19461. {
  19462. QDomNodeList children= element.childNodes();
  19463. int column= 0;
  19464. for(int i= 0;i<children.count();i++)
  19465. {
  19466. QDomNode current;
  19467. QDomElement currentElement;
  19468. current= children.at(i);
  19469. if(current.isElement())
  19470. {
  19471. currentElement= current.toElement();
  19472. if(currentElement.tagName()=="column")
  19473. {
  19474. QString text=
  19475. QCoreApplication::translate(
  19476. "configuration",
  19477. currentElement.text().toUtf8().data());
  19478. widget->setHeaderData(column,text);
  19479. column++;
  19480. }
  19481. }
  19482. }
  19483. }
  19484. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19485. if(splitter)
  19486. {
  19487. splitter->addWidget(widget);
  19488. }
  19489. else
  19490. {
  19491. qDebug()<<"Splitter not found at top of widget stack!";
  19492. }
  19493. }
  19494. /*:243*//*244:*/
  19495. #line 5831 "./typica.w"
  19496. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19497. QStack<QLayout*> *)
  19498. {
  19499. GraphView*view= new GraphView;
  19500. if(element.hasAttribute("id"))
  19501. {
  19502. view->setObjectName(element.attribute("id"));
  19503. }
  19504. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19505. splitter->addWidget(view);
  19506. }
  19507. /*:244*//*245:*/
  19508. #line 5848 "./typica.w"
  19509. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  19510. QStack<QLayout*> *layoutStack)
  19511. {
  19512. SqlComboBox*box= new SqlComboBox();
  19513. if(element.hasAttribute("data"))
  19514. {
  19515. box->setDataColumn(element.attribute("data").toInt());
  19516. }
  19517. if(element.hasAttribute("display"))
  19518. {
  19519. box->setDisplayColumn(element.attribute("display").toInt());
  19520. }
  19521. if(element.hasAttribute("showdata"))
  19522. {
  19523. if(element.attribute("showdata")=="true")
  19524. {
  19525. box->showData(true);
  19526. }
  19527. }
  19528. if(element.hasAttribute("editable"))
  19529. {
  19530. if(element.attribute("editable")=="true")
  19531. {
  19532. box->setEditable(true);
  19533. }
  19534. }
  19535. if(element.hasChildNodes())
  19536. {
  19537. QDomNodeList children= element.childNodes();
  19538. for(int i= 0;i<children.count();i++)
  19539. {
  19540. QDomNode current;
  19541. QDomElement currentElement;
  19542. current= children.at(i);
  19543. if(current.isElement())
  19544. {
  19545. currentElement= current.toElement();
  19546. if(currentElement.tagName()=="null")
  19547. {
  19548. box->addNullOption();
  19549. }
  19550. else if(currentElement.tagName()=="query")
  19551. {
  19552. box->addSqlOptions(currentElement.text());
  19553. }
  19554. }
  19555. }
  19556. }
  19557. if(element.hasAttribute("id"))
  19558. {
  19559. box->setObjectName(element.attribute("id"));
  19560. }
  19561. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19562. layout->addWidget(box);
  19563. }
  19564. /*:245*//*246:*/
  19565. #line 5927 "./typica.w"
  19566. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  19567. QStack<QLayout*> *layoutStack)
  19568. {
  19569. QTableView*view= new QTableView;
  19570. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  19571. SaltModel*model= new SaltModel(element.childNodes().count());
  19572. if(element.hasAttribute("id"))
  19573. {
  19574. view->setObjectName(element.attribute("id"));
  19575. }
  19576. if(element.hasChildNodes())
  19577. {
  19578. QDomNodeList children= element.childNodes();
  19579. int currentColumn= 0;
  19580. for(int i= 0;i<children.count();i++)
  19581. {
  19582. QDomNode current;
  19583. QDomElement currentElement;
  19584. current= children.at(i);
  19585. if(current.isElement())
  19586. {
  19587. currentElement= current.toElement();
  19588. if(currentElement.tagName()=="column")
  19589. {
  19590. if(currentElement.hasAttribute("name"))
  19591. {
  19592. model->setHeaderData(currentColumn,
  19593. Qt::Horizontal,
  19594. QCoreApplication::translate(
  19595. "configuration",
  19596. currentElement.attribute("name").toUtf8().data()));
  19597. }
  19598. if(currentElement.hasAttribute("delegate"))
  19599. {
  19600. /*247:*/
  19601. #line 5978 "./typica.w"
  19602. if(currentElement.attribute("delegate")=="sql")
  19603. {
  19604. /*248:*/
  19605. #line 5994 "./typica.w"
  19606. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  19607. SqlComboBox*widget= new SqlComboBox();
  19608. if(currentElement.hasAttribute("nulltext"))
  19609. {
  19610. widget->setNullText(currentElement.attribute("nulltext"));
  19611. }
  19612. if(currentElement.hasAttribute("nulldata"))
  19613. {
  19614. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  19615. }
  19616. if(currentElement.hasAttribute("null"))
  19617. {
  19618. if(currentElement.attribute("null")=="true")
  19619. {
  19620. widget->addNullOption();
  19621. }
  19622. }
  19623. if(currentElement.hasAttribute("showdata"))
  19624. {
  19625. if(currentElement.attribute("showdata")=="true")
  19626. {
  19627. widget->showData(true);
  19628. }
  19629. }
  19630. if(currentElement.hasAttribute("data"))
  19631. {
  19632. widget->setDataColumn(currentElement.attribute("data").toInt());
  19633. }
  19634. if(currentElement.hasAttribute("display"))
  19635. {
  19636. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  19637. }
  19638. widget->addSqlOptions(currentElement.text());
  19639. delegate->setWidget(widget);
  19640. view->setItemDelegateForColumn(currentColumn,delegate);
  19641. /*:248*/
  19642. #line 5981 "./typica.w"
  19643. }
  19644. else if(currentElement.attribute("delegate")=="numeric")
  19645. {
  19646. /*249:*/
  19647. #line 6035 "./typica.w"
  19648. NumericDelegate*delegate= new NumericDelegate;
  19649. view->setItemDelegateForColumn(currentColumn,delegate);
  19650. /*:249*/
  19651. #line 5985 "./typica.w"
  19652. }
  19653. /*:247*/
  19654. #line 5962 "./typica.w"
  19655. }
  19656. currentColumn++;
  19657. }
  19658. }
  19659. }
  19660. }
  19661. view->setModel(model);
  19662. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19663. layout->addWidget(view);
  19664. }
  19665. /*:246*//*261:*/
  19666. #line 6208 "./typica.w"
  19667. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  19668. QStack<QLayout*> *layoutStack)
  19669. {
  19670. QLineEdit*widget= new QLineEdit(element.text());
  19671. if(element.hasAttribute("id"))
  19672. {
  19673. widget->setObjectName(element.attribute("id"));
  19674. }
  19675. if(element.hasAttribute("writable"))
  19676. {
  19677. if(element.attribute("writable")=="false")
  19678. {
  19679. widget->setReadOnly(true);
  19680. }
  19681. }
  19682. if(element.hasAttribute("validator"))
  19683. {
  19684. if(element.attribute("validator")=="numeric")
  19685. {
  19686. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  19687. }
  19688. else if(element.attribute("validator")=="integer")
  19689. {
  19690. widget->setValidator(new ScriptValidator(new QIntValidator));
  19691. }
  19692. else if(element.attribute("validator")=="expression"&&
  19693. element.hasAttribute("expression"))
  19694. {
  19695. widget->setValidator(new QRegExpValidator(
  19696. QRegExp(element.attribute("expression")),
  19697. NULL));
  19698. }
  19699. }
  19700. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19701. layout->addWidget(widget);
  19702. }
  19703. /*:261*//*262:*/
  19704. #line 6249 "./typica.w"
  19705. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  19706. QStack<QLayout*> *layoutStack)
  19707. {
  19708. QTextEdit*widget= new QTextEdit;
  19709. if(element.hasAttribute("id"))
  19710. {
  19711. widget->setObjectName(element.attribute("id"));
  19712. }
  19713. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19714. layout->addWidget(widget);
  19715. }
  19716. /*:262*//*263:*/
  19717. #line 6266 "./typica.w"
  19718. void addSqlQueryViewToLayout(QDomElement element,
  19719. QStack<QWidget*> *,
  19720. QStack<QLayout*> *layoutStack)
  19721. {
  19722. SqlQueryView*view= new SqlQueryView;
  19723. if(element.hasAttribute("id"))
  19724. {
  19725. view->setObjectName(element.attribute("id"));
  19726. }
  19727. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19728. layout->addWidget(view);
  19729. }
  19730. /*:263*//*264:*/
  19731. #line 6283 "./typica.w"
  19732. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  19733. QStack<QLayout*> *layoutStack)
  19734. {
  19735. QWidget*widget;
  19736. if(element.hasAttribute("time"))
  19737. {
  19738. if(element.attribute("time")=="true")
  19739. {
  19740. QDateTimeEdit*edit= new QDateTimeEdit;
  19741. edit->setDateTime(QDateTime::currentDateTime());
  19742. edit->setCalendarPopup(true);
  19743. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  19744. widget= qobject_cast<QWidget*> (edit);
  19745. }
  19746. else
  19747. {
  19748. QDateEdit*edit= new QDateEdit;
  19749. edit->setDate(QDate::currentDate());
  19750. edit->setCalendarPopup(true);
  19751. edit->setDisplayFormat("yyyy-MM-dd");
  19752. widget= qobject_cast<QWidget*> (edit);
  19753. }
  19754. }
  19755. else
  19756. {
  19757. QDateEdit*edit= new QDateEdit;
  19758. edit->setDate(QDate::currentDate());
  19759. edit->setCalendarPopup(true);
  19760. edit->setDisplayFormat("yyyy-MM-dd");
  19761. widget= qobject_cast<QWidget*> (edit);
  19762. }
  19763. if(element.hasAttribute("id"))
  19764. {
  19765. widget->setObjectName(element.attribute("id"));
  19766. }
  19767. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19768. layout->addWidget(widget);
  19769. }
  19770. /*:264*//*265:*/
  19771. #line 6326 "./typica.w"
  19772. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  19773. {
  19774. setQDateTimeEditProperties(value,engine);
  19775. }
  19776. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  19777. {
  19778. setQAbstractSpinBoxProperties(value,engine);
  19779. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  19780. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  19781. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  19782. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  19783. value.setProperty("setToCurrentTime",
  19784. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  19785. }
  19786. /*:265*//*266:*/
  19787. #line 6348 "./typica.w"
  19788. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  19789. {
  19790. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19791. if(context->argumentCount()==3)
  19792. {
  19793. self->setDate(QDate(argument<int> (0,context),
  19794. argument<int> (1,context),
  19795. argument<int> (2,context)));
  19796. }
  19797. else
  19798. {
  19799. context->throwError("Incorrect number of arguments passed to "
  19800. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  19801. "specifying the year, month, and day.");
  19802. }
  19803. return QScriptValue();
  19804. }
  19805. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  19806. {
  19807. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19808. return QScriptValue(self->date().day());
  19809. }
  19810. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  19811. {
  19812. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19813. return QScriptValue(self->date().month());
  19814. }
  19815. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  19816. {
  19817. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19818. return QScriptValue(self->date().year());
  19819. }
  19820. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  19821. {
  19822. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19823. self->setDateTime(QDateTime::currentDateTime());
  19824. return QScriptValue();
  19825. }
  19826. /*:266*//*268:*/
  19827. #line 6408 "./typica.w"
  19828. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *,
  19829. QStack<QLayout*> *layoutStack)
  19830. {
  19831. QTimeEdit*edit= new QTimeEdit;
  19832. if(element.hasAttribute("displayFormat"))
  19833. {
  19834. edit->setDisplayFormat(element.attribute("displayFormat"));
  19835. }
  19836. else
  19837. {
  19838. edit->setDisplayFormat("mm:ss.zzz");
  19839. }
  19840. if(element.hasAttribute("id"))
  19841. {
  19842. edit->setObjectName(element.attribute("id"));
  19843. }
  19844. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19845. layout->addWidget(edit);
  19846. }
  19847. /*:268*//*269:*/
  19848. #line 6431 "./typica.w"
  19849. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  19850. {
  19851. setQDateTimeEditProperties(value,engine);
  19852. }
  19853. /*:269*//*273:*/
  19854. #line 6460 "./typica.w"
  19855. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  19856. {
  19857. QObject*parent= argument<QObject*> (0,context);
  19858. QString name= argument<QString> (1,context);
  19859. QObject*object= parent->findChild<QObject*> (name);
  19860. QScriptValue value;
  19861. if(object)
  19862. {
  19863. value= engine->newQObject(object);
  19864. QString className= object->metaObject()->className();
  19865. /*274:*/
  19866. #line 6478 "./typica.w"
  19867. if(className=="TemperatureDisplay")
  19868. {
  19869. setTemperatureDisplayProperties(value,engine);
  19870. }
  19871. else if(className=="TimerDisplay")
  19872. {
  19873. setTimerDisplayProperties(value,engine);
  19874. }
  19875. else if(className=="QAction")
  19876. {
  19877. setQActionProperties(value,engine);
  19878. }
  19879. else if(className=="QBoxLayout")
  19880. {
  19881. setQBoxLayoutProperties(value,engine);
  19882. }
  19883. else if(className=="QDateEdit")
  19884. {
  19885. setQDateEditProperties(value,engine);
  19886. }
  19887. else if(className=="QDateTimeEdit")
  19888. {
  19889. setQDateTimeEditProperties(value,engine);
  19890. }
  19891. else if(className=="QFrame")
  19892. {
  19893. setQFrameProperties(value,engine);
  19894. }
  19895. else if(className=="QHBoxLayout")
  19896. {
  19897. setQBoxLayoutProperties(value,engine);
  19898. }
  19899. else if(className=="QLCDNumber")
  19900. {
  19901. setQLCDNumberProperties(value,engine);
  19902. }
  19903. else if(className=="QMenu")
  19904. {
  19905. setQMenuProperties(value,engine);
  19906. }
  19907. else if(className=="QMenuBar")
  19908. {
  19909. setQMenuBarProperties(value,engine);
  19910. }
  19911. else if(className=="QPushButton")
  19912. {
  19913. setQPushButtonProperties(value,engine);
  19914. }
  19915. else if(className=="QSplitter")
  19916. {
  19917. setQSplitterProperties(value,engine);
  19918. }
  19919. else if(className=="QTableView")
  19920. {
  19921. if(object->property("tabletype").isValid())
  19922. {
  19923. if(object->property("tabletype").toString()=="SaltTable")
  19924. {
  19925. setSaltTableProperties(value,engine);
  19926. }
  19927. }
  19928. }
  19929. else if(className=="QVBoxLayout")
  19930. {
  19931. setQBoxLayoutProperties(value,engine);
  19932. }
  19933. else if(className=="QWidget")
  19934. {
  19935. setQWidgetProperties(value,engine);
  19936. }
  19937. else if(className=="ScriptQMainWindow")
  19938. {
  19939. setQMainWindowProperties(value,engine);
  19940. }
  19941. else if(className=="SqlComboBox")
  19942. {
  19943. setSqlComboBoxProperties(value,engine);
  19944. }
  19945. else if(className=="SqlQueryView")
  19946. {
  19947. setSqlQueryViewProperties(value,engine);
  19948. }
  19949. else if(className=="ZoomLog")
  19950. {
  19951. setZoomLogProperties(value,engine);
  19952. }
  19953. else if(className=="QTextEdit")
  19954. {
  19955. setQTextEditProperties(value,engine);
  19956. }
  19957. else if(className=="QWebView")
  19958. {
  19959. setQWebViewProperties(value,engine);
  19960. }
  19961. else if(className=="QLineEdit")
  19962. {
  19963. setQLineEditProperties(value,engine);
  19964. }
  19965. else if(className=="QSvgWidget")
  19966. {
  19967. setQSvgWidgetProperties(value,engine);
  19968. }
  19969. else if(className=="QTabBar")
  19970. {
  19971. setQTabBarProperties(value,engine);
  19972. }
  19973. else if(className=="PrinterSelector")
  19974. {
  19975. setQComboBoxProperties(value,engine);
  19976. }
  19977. /*:274*/
  19978. #line 6471 "./typica.w"
  19979. }
  19980. return value;
  19981. }
  19982. /*:273*//*276:*/
  19983. #line 6619 "./typica.w"
  19984. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  19985. {
  19986. QTableView*self= getself<QTableView*> (context);
  19987. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19988. QString datum;
  19989. double total= 0.0;
  19990. int column= argument<int> (0,context);
  19991. int role= argument<int> (1,context);
  19992. for(int i= 0;i<model->rowCount();i++)
  19993. {
  19994. datum= model->data(model->index(i,column),role).toString();
  19995. if(!datum.isEmpty())
  19996. {
  19997. total+= datum.toDouble();
  19998. }
  19999. }
  20000. return QScriptValue(engine,total);
  20001. }
  20002. /*:276*//*277:*/
  20003. #line 6643 "./typica.w"
  20004. QScriptValue SaltTable_columnArray(QScriptContext*context,
  20005. QScriptEngine*engine)
  20006. {
  20007. QTableView*self= getself<QTableView*> (context);
  20008. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20009. int column= argument<int> (0,context);
  20010. int role= argument<int> (1,context);
  20011. QString literal= model->arrayLiteral(column,role);
  20012. return QScriptValue(engine,literal);
  20013. }
  20014. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  20015. QScriptEngine*engine)
  20016. {
  20017. QTableView*self= getself<QTableView*> (context);
  20018. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20019. int column= argument<int> (0,context);
  20020. int role= argument<int> (1,context);
  20021. QString literal= model->quotedArrayLiteral(column,role);
  20022. return QScriptValue(engine,literal);
  20023. }
  20024. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  20025. QScriptEngine*engine)
  20026. {
  20027. QTableView*self= getself<QTableView*> (context);
  20028. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20029. int column= argument<int> (0,context);
  20030. int role= argument<int> (1,context);
  20031. QString literal= model->arrayLiteral(column,role);
  20032. literal.chop(1);
  20033. literal= literal.remove(0,1);
  20034. return QScriptValue(engine,literal);
  20035. }
  20036. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  20037. QScriptEngine*engine)
  20038. {
  20039. QTableView*self= getself<QTableView*> (context);
  20040. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20041. int column= argument<int> (0,context);
  20042. int role= argument<int> (1,context);
  20043. QString literal= model->quotedArrayLiteral(column,role);
  20044. literal.chop(1);
  20045. literal= literal.remove(0,1);
  20046. return QScriptValue(engine,literal);
  20047. }
  20048. /*:277*//*278:*/
  20049. #line 6695 "./typica.w"
  20050. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  20051. {
  20052. QTableView*self= getself<QTableView*> (context);
  20053. QScriptValue value= engine->newQObject(self->model());
  20054. return value;
  20055. }
  20056. /*:278*//*279:*/
  20057. #line 6709 "./typica.w"
  20058. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  20059. {
  20060. QTableView*self= getself<QTableView*> (context);
  20061. int row= argument<int> (0,context);
  20062. int column= argument<int> (1,context);
  20063. QVariant value= argument<QVariant> (2,context);
  20064. int role= argument<int> (3,context);
  20065. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20066. QModelIndex cell= model->index(row,column);
  20067. model->setData(cell,value,role);
  20068. self->update(cell);
  20069. return QScriptValue();
  20070. }
  20071. /*:279*//*280:*/
  20072. #line 6727 "./typica.w"
  20073. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  20074. {
  20075. QTableView*self= getself<QTableView*> (context);
  20076. int row= argument<int> (0,context);
  20077. int column= argument<int> (1,context);
  20078. int role= argument<int> (2,context);
  20079. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20080. QModelIndex cell= model->index(row,column);
  20081. QVariant value= model->data(cell,role);
  20082. QScriptValue retval= engine->newVariant(value);
  20083. retval.setProperty("value",QScriptValue(value.toString()));
  20084. return retval;
  20085. }
  20086. /*:280*//*281:*/
  20087. #line 6747 "./typica.w"
  20088. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  20089. {
  20090. QTableView*self= getself<QTableView*> (context);
  20091. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20092. model->clear();
  20093. return QScriptValue();
  20094. }
  20095. /*:281*//*282:*/
  20096. #line 6759 "./typica.w"
  20097. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  20098. {
  20099. QTableView*self= getself<QTableView*> (context);
  20100. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20101. int row= argument<int> (0,context);
  20102. return engine->newVariant(model->removeRow(row));
  20103. }
  20104. /*:282*//*283:*/
  20105. #line 6772 "./typica.w"
  20106. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  20107. {
  20108. QTableView*self= getself<QTableView*> (context);
  20109. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20110. QVariant value= argument<QVariant> (0,context);
  20111. int column= argument<int> (1,context);
  20112. return engine->newVariant(model->findData(value,column));
  20113. }
  20114. /*:283*//*284:*/
  20115. #line 6785 "./typica.w"
  20116. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  20117. {
  20118. setQWidgetProperties(value,engine);
  20119. value.setProperty("columnArray",
  20120. engine->newFunction(SaltTable_columnArray));
  20121. value.setProperty("quotedColumnArray",
  20122. engine->newFunction(SaltTable_quotedColumnArray));
  20123. value.setProperty("bindableColumnArray",
  20124. engine->newFunction(SaltTable_bindableColumnArray));
  20125. value.setProperty("bindableQuotedColumnArray",
  20126. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  20127. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  20128. value.setProperty("data",engine->newFunction(SaltTable_data));
  20129. value.setProperty("model",engine->newFunction(SaltTable_model));
  20130. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  20131. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  20132. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  20133. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  20134. }
  20135. /*:284*//*286:*/
  20136. #line 6822 "./typica.w"
  20137. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  20138. {
  20139. setQComboBoxProperties(value,engine);
  20140. }
  20141. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  20142. {
  20143. setQWidgetProperties(value,engine);
  20144. value.setProperty("currentData",
  20145. engine->newFunction(QComboBox_currentData));
  20146. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  20147. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  20148. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  20149. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  20150. }
  20151. QScriptValue QComboBox_currentData(QScriptContext*context,
  20152. QScriptEngine*engine)
  20153. {
  20154. QComboBox*self= getself<QComboBox*> (context);
  20155. return QScriptValue(engine,
  20156. self->itemData(self->currentIndex()).toString());
  20157. }
  20158. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  20159. {
  20160. QComboBox*self= getself<QComboBox*> (context);
  20161. self->addItem(argument<QString> (0,context));
  20162. return QScriptValue();
  20163. }
  20164. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  20165. {
  20166. QComboBox*self= getself<QComboBox*> (context);
  20167. self->setModel(argument<QAbstractItemModel*> (0,context));
  20168. return QScriptValue();
  20169. }
  20170. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  20171. {
  20172. QComboBox*self= getself<QComboBox*> (context);
  20173. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  20174. }
  20175. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  20176. {
  20177. QComboBox*self= getself<QComboBox*> (context);
  20178. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  20179. }
  20180. #line 1 "./abouttypica.w"
  20181. /*:286*//*299:*/
  20182. #line 401 "./units.w"
  20183. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  20184. {
  20185. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  20186. argument<Units::Unit> (1,context),
  20187. argument<Units::Unit> (2,context)));
  20188. }
  20189. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  20190. QScriptEngine*)
  20191. {
  20192. return QScriptValue(Units::convertRelativeTemperature(
  20193. argument<double> (0,context),
  20194. argument<Units::Unit> (1,context),
  20195. argument<Units::Unit> (2,context)));
  20196. }
  20197. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  20198. {
  20199. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  20200. }
  20201. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  20202. {
  20203. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  20204. argument<Units::Unit> (1,context),
  20205. argument<Units::Unit> (2,context)));
  20206. }
  20207. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  20208. {
  20209. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  20210. }
  20211. /*:299*//*302:*/
  20212. #line 449 "./units.w"
  20213. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  20214. {
  20215. return engine->newVariant(QVariant(value));
  20216. }
  20217. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  20218. {
  20219. value= sv.toVariant().value<Units::Unit> ();
  20220. }
  20221. /*:302*//*312:*/
  20222. #line 149 "./measurement.w"
  20223. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  20224. {
  20225. QScriptValue object;
  20226. if(context->argumentCount()==2||context->argumentCount()==3)
  20227. {
  20228. double measurement= argument<double> (0,context);
  20229. QTime timestamp= argument<QTime> (1,context);
  20230. Units::Unit unit= Units::Fahrenheit;
  20231. if(context->argumentCount()==3)
  20232. {
  20233. unit= argument<Units::Unit> (2,context);
  20234. }
  20235. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  20236. setMeasurementProperties(object,engine);
  20237. }
  20238. else
  20239. {
  20240. context->throwError("Incorrect number of arguments passed to "
  20241. "Measurement::Measurement(). This method takes two "
  20242. "or three arguments.");
  20243. }
  20244. return object;
  20245. }
  20246. /*:312*//*313:*/
  20247. #line 176 "./measurement.w"
  20248. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  20249. {
  20250. }
  20251. /*:313*//*314:*/
  20252. #line 184 "./measurement.w"
  20253. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  20254. {
  20255. QVariant var;
  20256. var.setValue(measurement);
  20257. return engine->newVariant(var);
  20258. }
  20259. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  20260. {
  20261. measurement= value.toVariant().value<Measurement> ();
  20262. }
  20263. #line 6891 "./typica.w"
  20264. /*:314*//*332:*/
  20265. #line 7469 "./typica.w"
  20266. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  20267. {
  20268. QScriptValue object;
  20269. if(context->argumentCount()==1)
  20270. {
  20271. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  20272. QScriptEngine::ScriptOwnership);
  20273. setDAQProperties(object,engine);
  20274. }
  20275. else if(context->argumentCount()==2)
  20276. {
  20277. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  20278. argument<QString> (1,context)),
  20279. QScriptEngine::ScriptOwnership);
  20280. setDAQProperties(object,engine);
  20281. }
  20282. else
  20283. {
  20284. context->throwError("Incorrect number of arguments passed to DAQ"
  20285. "constructor. The DAQ constructor takes one"
  20286. "string as an argument specifying a device name."
  20287. "Example: Dev1");
  20288. }
  20289. return object;
  20290. }
  20291. /*:332*//*333:*/
  20292. #line 7499 "./typica.w"
  20293. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  20294. {
  20295. setQObjectProperties(value,engine);
  20296. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  20297. }
  20298. /*:333*//*334:*/
  20299. #line 7509 "./typica.w"
  20300. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  20301. {
  20302. DAQ*self= getself<DAQ*> (context);
  20303. QScriptValue object;
  20304. if(self)
  20305. {
  20306. object=
  20307. engine->newQObject(self->newChannel(argument<int> (0,context),
  20308. argument<int> (1,context)));
  20309. setChannelProperties(object,engine);
  20310. }
  20311. return object;
  20312. }
  20313. /*:334*//*341:*/
  20314. #line 7665 "./typica.w"
  20315. QScriptValue constructFakeDAQ(QScriptContext*context,
  20316. QScriptEngine*engine)
  20317. {
  20318. QScriptValue object;
  20319. if(context->argumentCount()==1)
  20320. {
  20321. object=
  20322. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  20323. QScriptEngine::ScriptOwnership);
  20324. setFakeDAQProperties(object,engine);
  20325. }
  20326. else
  20327. {
  20328. context->throwError("Incorrect number of arguments passed to DAQ"
  20329. "constructor. The DAQ constructor takes one"
  20330. "string as an argument specifying a device name."
  20331. "Example: Dev1");
  20332. }
  20333. return object;
  20334. }
  20335. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  20336. {
  20337. setQObjectProperties(value,engine);
  20338. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  20339. }
  20340. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  20341. {
  20342. FakeDAQ*self= getself<FakeDAQ*> (context);
  20343. QScriptValue object;
  20344. if(self)
  20345. {
  20346. object=
  20347. engine->newQObject(self->newChannel(argument<int> (0,context),
  20348. argument<int> (1,context)));
  20349. setChannelProperties(object,engine);
  20350. }
  20351. return object;
  20352. }
  20353. /*:341*//*345:*/
  20354. #line 7756 "./typica.w"
  20355. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  20356. {
  20357. setQObjectProperties(value,engine);
  20358. }
  20359. /*:345*//*352:*/
  20360. #line 7948 "./typica.w"
  20361. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  20362. {
  20363. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  20364. setLinearCalibratorProperties(object,engine);
  20365. return object;
  20366. }
  20367. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  20368. {
  20369. setQObjectProperties(value,engine);
  20370. }
  20371. /*:352*//*357:*/
  20372. #line 8086 "./typica.w"
  20373. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  20374. {
  20375. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  20376. setLinearSplineInterpolatorProperties(object,engine);
  20377. return object;
  20378. }
  20379. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  20380. {
  20381. setQObjectProperties(value,engine);
  20382. }
  20383. /*:357*//*367:*/
  20384. #line 8295 "./typica.w"
  20385. QScriptValue constructTemperatureDisplay(QScriptContext*,
  20386. QScriptEngine*engine)
  20387. {
  20388. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  20389. setTemperatureDisplayProperties(object,engine);
  20390. return object;
  20391. }
  20392. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  20393. {
  20394. setQLCDNumberProperties(value,engine);
  20395. value.setProperty("setDisplayUnits",
  20396. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  20397. }
  20398. /*:367*//*368:*/
  20399. #line 8319 "./typica.w"
  20400. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  20401. {
  20402. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  20403. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  20404. return QScriptValue();
  20405. }
  20406. /*:368*//*375:*/
  20407. #line 8456 "./typica.w"
  20408. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  20409. QScriptEngine*engine)
  20410. {
  20411. QScriptValue object=
  20412. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  20413. setMeasurementTimeOffsetProperties(object,engine);
  20414. return object;
  20415. }
  20416. void setMeasurementTimeOffsetProperties(QScriptValue value,
  20417. QScriptEngine*engine)
  20418. {
  20419. setQObjectProperties(value,engine);
  20420. }
  20421. /*:375*//*380:*/
  20422. #line 8575 "./typica.w"
  20423. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  20424. {
  20425. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  20426. return object;
  20427. }
  20428. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  20429. {
  20430. setQObjectProperties(value,engine);
  20431. }
  20432. /*:380*//*385:*/
  20433. #line 8672 "./typica.w"
  20434. QScriptValue constructZeroEmitter(QScriptContext*context,
  20435. QScriptEngine*engine)
  20436. {
  20437. QScriptValue object=
  20438. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  20439. setZeroEmitterProperties(object,engine);
  20440. return object;
  20441. }
  20442. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  20443. {
  20444. setQObjectProperties(value,engine);
  20445. }
  20446. /*:385*//*390:*/
  20447. #line 8752 "./typica.w"
  20448. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  20449. QScriptEngine*engine)
  20450. {
  20451. QScriptValue object=
  20452. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  20453. setMeasurementAdapterProperties(object,engine);
  20454. return object;
  20455. }
  20456. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  20457. {
  20458. setQObjectProperties(value,engine);
  20459. }
  20460. /*:390*//*407:*/
  20461. #line 9214 "./typica.w"
  20462. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  20463. {
  20464. QScriptValue object= engine->newQObject(new GraphView);
  20465. setGraphViewProperties(object,engine);
  20466. return object;
  20467. }
  20468. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  20469. {
  20470. setQGraphicsViewProperties(value,engine);
  20471. }
  20472. /*:407*//*430:*/
  20473. #line 9864 "./typica.w"
  20474. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  20475. {
  20476. QScriptValue object= engine->newQObject(new ZoomLog);
  20477. setZoomLogProperties(object,engine);
  20478. return object;
  20479. }
  20480. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  20481. {
  20482. setQTableViewProperties(value,engine);
  20483. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  20484. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  20485. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  20486. value.setProperty("restoreState",
  20487. engine->newFunction(ZoomLog_restoreState));
  20488. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  20489. value.setProperty("saveTemporary",
  20490. engine->newFunction(ZoomLog_saveTemporary));
  20491. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  20492. }
  20493. /*:430*//*431:*/
  20494. #line 9891 "./typica.w"
  20495. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  20496. {
  20497. ZoomLog*self= getself<ZoomLog*> (context);
  20498. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  20499. return QScriptValue(engine,retval);
  20500. }
  20501. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  20502. {
  20503. ZoomLog*self= getself<ZoomLog*> (context);
  20504. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  20505. return QScriptValue(engine,retval);
  20506. }
  20507. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  20508. QScriptEngine*engine)
  20509. {
  20510. ZoomLog*self= getself<ZoomLog*> (context);
  20511. QString filename= QDir::tempPath();
  20512. filename.append("/");
  20513. filename.append(QUuid::createUuid().toString());
  20514. filename.append(".xml");
  20515. QFile*file= new QFile(filename);
  20516. self->saveXML(file);
  20517. file->close();
  20518. delete file;
  20519. return QScriptValue(engine,filename);
  20520. }
  20521. /*:431*//*432:*/
  20522. #line 9939 "./typica.w"
  20523. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  20524. {
  20525. ZoomLog*self= getself<ZoomLog*> (context);
  20526. QString key= argument<QString> (0,context);
  20527. int columns= argument<int> (1,context);
  20528. QSettings settings;
  20529. for(int i= 0;i<columns;i++)
  20530. {
  20531. if(self->columnWidth(i))
  20532. {
  20533. settings.beginGroup(key);
  20534. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  20535. settings.endGroup();
  20536. }
  20537. }
  20538. return QScriptValue();
  20539. }
  20540. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  20541. {
  20542. ZoomLog*self= getself<ZoomLog*> (context);
  20543. QString key= argument<QString> (0,context);
  20544. int columns= argument<int> (1,context);
  20545. QSettings settings;
  20546. for(int i= 0;i<columns;i++)
  20547. {
  20548. settings.beginGroup(key);
  20549. self->setColumnWidth(i,
  20550. settings.value(QString("%1").arg(i),80).toInt());
  20551. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  20552. {
  20553. self->setColumnWidth(i,80);
  20554. }
  20555. settings.endGroup();
  20556. }
  20557. return QScriptValue();
  20558. }
  20559. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  20560. {
  20561. ZoomLog*self= getself<ZoomLog*> (context);
  20562. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  20563. }
  20564. /*:432*//*433:*/
  20565. #line 9992 "./typica.w"
  20566. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  20567. {
  20568. ZoomLog*self= getself<ZoomLog*> (context);
  20569. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  20570. return QScriptValue();
  20571. }
  20572. /*:433*//*468:*/
  20573. #line 10812 "./typica.w"
  20574. QScriptValue constructAnnotationButton(QScriptContext*context,
  20575. QScriptEngine*engine)
  20576. {
  20577. QScriptValue object=
  20578. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  20579. setAnnotationButtonProperties(object,engine);
  20580. return object;
  20581. }
  20582. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  20583. {
  20584. setQPushButtonProperties(value,engine);
  20585. }
  20586. /*:468*//*476:*/
  20587. #line 10955 "./typica.w"
  20588. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  20589. QScriptEngine*engine)
  20590. {
  20591. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  20592. argument<QString> (0,context),argument<QString> (1,context)));
  20593. setAnnotationSpinBoxProperties(object,engine);
  20594. return object;
  20595. }
  20596. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20597. {
  20598. setQDoubleSpinBoxProperties(value,engine);
  20599. }
  20600. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20601. {
  20602. setQAbstractSpinBoxProperties(value,engine);
  20603. }
  20604. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20605. {
  20606. setQWidgetProperties(value,engine);
  20607. }
  20608. /*:476*//*497:*/
  20609. #line 11378 "./typica.w"
  20610. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  20611. {
  20612. QScriptValue object= engine->newQObject(new TimerDisplay);
  20613. setTimerDisplayProperties(object,engine);
  20614. return object;
  20615. }
  20616. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  20617. {
  20618. setQLCDNumberProperties(value,engine);
  20619. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  20620. }
  20621. /*:497*//*498:*/
  20622. #line 11397 "./typica.w"
  20623. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  20624. {
  20625. TimerDisplay*self= getself<TimerDisplay*> (context);
  20626. if(self)
  20627. {
  20628. switch(argument<int> (0,context))
  20629. {
  20630. case 0:
  20631. self->setMode(TimerDisplay::CountUp);
  20632. break;
  20633. case 1:
  20634. self->setMode(TimerDisplay::CountDown);
  20635. break;
  20636. case 2:
  20637. self->setMode(TimerDisplay::Clock);
  20638. break;
  20639. default:
  20640. break;
  20641. }
  20642. }
  20643. return QScriptValue();
  20644. }
  20645. /*:498*//*525:*/
  20646. #line 11903 "./typica.w"
  20647. QScriptValue constructWidgetDecorator(QScriptContext*context,
  20648. QScriptEngine*engine)
  20649. {
  20650. QWidget*widget= argument<QWidget*> (0,context);
  20651. QString text= argument<QString> (1,context);
  20652. Qt::Orientations orientation;
  20653. switch(argument<int> (2,context))
  20654. {
  20655. case 2:
  20656. orientation= Qt::Vertical;
  20657. break;
  20658. default:
  20659. orientation= Qt::Horizontal;
  20660. break;
  20661. }
  20662. QScriptValue object=
  20663. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  20664. setWidgetDecoratorProperties(object,engine);
  20665. return object;
  20666. }
  20667. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  20668. {
  20669. setQWidgetProperties(value,engine);
  20670. }
  20671. /*:525*//*538:*/
  20672. #line 12184 "./typica.w"
  20673. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  20674. {
  20675. QScriptValue object= engine->newQObject(new LogEditWindow);
  20676. return object;
  20677. }
  20678. /*:538*//*557:*/
  20679. #line 12711 "./typica.w"
  20680. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  20681. {
  20682. QIODevice*device= argument<QIODevice*> (0,context);
  20683. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  20684. argument<int> (1,context)));
  20685. object.setProperty("input",engine->newFunction(XMLInput_input));
  20686. return object;
  20687. }
  20688. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  20689. {
  20690. XMLInput*self= getself<XMLInput*> (context);
  20691. self->input();
  20692. return QScriptValue();
  20693. }
  20694. /*:557*//*572:*/
  20695. #line 172 "./webview.w"
  20696. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  20697. {
  20698. QScriptValue object= engine->newQObject(new TypicaWebView);
  20699. setQWebViewProperties(object,engine);
  20700. return object;
  20701. }
  20702. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  20703. {
  20704. setQWidgetProperties(value,engine);
  20705. }
  20706. /*:572*//*573:*/
  20707. #line 189 "./webview.w"
  20708. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  20709. QStack<QLayout*> *layoutStack)
  20710. {
  20711. TypicaWebView*view= new TypicaWebView;
  20712. if(element.hasAttribute("id"))
  20713. {
  20714. view->setObjectName(element.attribute("id"));
  20715. }
  20716. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20717. layout->addWidget(view);
  20718. }
  20719. /*:573*//*578:*/
  20720. #line 240 "./webview.w"
  20721. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  20722. {
  20723. QVariant var;
  20724. var.setValue(element);
  20725. QScriptValue object= engine->newVariant(var);
  20726. return object;
  20727. }
  20728. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  20729. {
  20730. element= value.toVariant().value<QWebElement> ();
  20731. }
  20732. /*:578*//*583:*/
  20733. #line 305 "./webview.w"
  20734. template<> QWebElement argument(int arg,QScriptContext*context)
  20735. {
  20736. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  20737. }
  20738. /*:583*//*584:*/
  20739. #line 314 "./webview.w"
  20740. QScriptValue constructWebElement(QScriptContext*context,
  20741. QScriptEngine*engine)
  20742. {
  20743. QWebElement element= argument<QWebElement> (0,context);
  20744. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  20745. return object;
  20746. }
  20747. /*:584*//*595:*/
  20748. #line 85 "./printerselector.w"
  20749. QScriptValue constructPrinterSelector(QScriptContext*,QScriptEngine*engine)
  20750. {
  20751. QScriptValue object= engine->newQObject(new PrinterSelector);
  20752. setQComboBoxProperties(object,engine);
  20753. return object;
  20754. }
  20755. /*:595*//*596:*/
  20756. #line 96 "./printerselector.w"
  20757. void addPrinterSelectorToLayout(QDomElement element,QStack<QWidget*> *,
  20758. QStack<QLayout*> *layoutStack)
  20759. {
  20760. PrinterSelector*selector= new PrinterSelector;
  20761. if(element.hasAttribute("id"))
  20762. {
  20763. selector->setObjectName(element.attribute("id"));
  20764. }
  20765. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20766. layout->addWidget(selector);
  20767. }
  20768. /*:596*//*609:*/
  20769. #line 13075 "./typica.w"
  20770. QScriptValue Application_subscribe(QScriptContext*context,
  20771. QScriptEngine*engine)
  20772. {
  20773. return engine->newQObject(
  20774. AppInstance->subscribe(argument<QString> (0,context)));
  20775. }
  20776. /*:609*//*668:*/
  20777. #line 14215 "./typica.w"
  20778. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  20779. {
  20780. QScriptValue object= engine->newQObject(new SqlQueryView);
  20781. setSqlQueryViewProperties(object,engine);
  20782. return object;
  20783. }
  20784. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  20785. {
  20786. setQTableViewProperties(value,engine);
  20787. value.setProperty("setHeaderData",
  20788. engine->newFunction(SqlQueryView_setHeaderData));
  20789. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  20790. }
  20791. /*:668*//*669:*/
  20792. #line 14233 "./typica.w"
  20793. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  20794. {
  20795. SqlQueryView*self= getself<SqlQueryView*> (context);
  20796. QString query= argument<QString> (0,context);
  20797. self->setQuery(query);
  20798. self->reset();
  20799. return QScriptValue();
  20800. }
  20801. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  20802. QScriptEngine*)
  20803. {
  20804. SqlQueryView*self= getself<SqlQueryView*> (context);
  20805. int section= argument<int> (0,context);
  20806. QString data= argument<QString> (1,context);
  20807. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  20808. return QScriptValue();
  20809. }
  20810. /*:669*//*677:*/
  20811. #line 14442 "./typica.w"
  20812. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  20813. QStack<QLayout*> *layoutStack)
  20814. {
  20815. QTextEdit*widget= new QTextEdit;
  20816. if(element.hasAttribute("id"))
  20817. {
  20818. widget->setObjectName(element.attribute("id"));
  20819. }
  20820. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20821. layout->addWidget(widget);
  20822. QTextDocument*document= new QTextDocument;
  20823. QFont defaultFont;
  20824. defaultFont.setPointSize(11);
  20825. document->setDefaultFont(defaultFont);
  20826. QTextCursor cursor(document);
  20827. /*678:*/
  20828. #line 14465 "./typica.w"
  20829. QDomNodeList children= element.childNodes();
  20830. for(int i= 0;i<children.count();i++)
  20831. {
  20832. QDomNode current;
  20833. QDomElement currentElement;
  20834. current= children.at(i);
  20835. if(current.isElement())
  20836. {
  20837. currentElement= current.toElement();
  20838. /*679:*/
  20839. #line 14482 "./typica.w"
  20840. if(currentElement.tagName()=="style")
  20841. {
  20842. document->setDefaultStyleSheet(currentElement.text());
  20843. }
  20844. /*:679*//*680:*/
  20845. #line 14493 "./typica.w"
  20846. if(currentElement.tagName()=="html")
  20847. {
  20848. cursor.insertHtml(currentElement.text());
  20849. }
  20850. /*:680*//*681:*/
  20851. #line 14503 "./typica.w"
  20852. if(currentElement.tagName()=="text")
  20853. {
  20854. cursor.insertText(currentElement.text());
  20855. }
  20856. /*:681*//*682:*/
  20857. #line 14513 "./typica.w"
  20858. if(currentElement.tagName()=="table")
  20859. {
  20860. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  20861. ReportTable*table= new ReportTable(frame,currentElement);
  20862. table->setParent(widget);
  20863. if(currentElement.hasAttribute("id"))
  20864. {
  20865. table->setObjectName(currentElement.attribute("id"));
  20866. }
  20867. }
  20868. /*:682*/
  20869. #line 14475 "./typica.w"
  20870. }
  20871. }
  20872. /*:678*/
  20873. #line 14458 "./typica.w"
  20874. widget->setDocument(document);
  20875. }
  20876. /*:677*//*693:*/
  20877. #line 14726 "./typica.w"
  20878. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  20879. {
  20880. QTextEdit*self= getself<QTextEdit*> (context);
  20881. QTextDocument*document= self->document();
  20882. QPrinter printer;
  20883. QPrintDialog printwindow(&printer,self);
  20884. if(printwindow.exec()!=QDialog::Accepted)
  20885. {
  20886. return QScriptValue();
  20887. }
  20888. document->print(&printer);
  20889. return QScriptValue();
  20890. }
  20891. /*:693*//*694:*/
  20892. #line 14744 "./typica.w"
  20893. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  20894. {
  20895. setQAbstractScrollAreaProperties(value,engine);
  20896. value.setProperty("print",engine->newFunction(QTextEdit_print));
  20897. }
  20898. #line 1 "./plugins.w"
  20899. /*:694*//*719:*/
  20900. #line 461 "./daterangeselector.w"
  20901. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  20902. QStack<QLayout*> *layoutStack)
  20903. {
  20904. DateRangeSelector*widget= new DateRangeSelector;
  20905. if(element.hasAttribute("id"))
  20906. {
  20907. widget->setObjectName(element.attribute("id"));
  20908. }
  20909. if(element.hasAttribute("initial"))
  20910. {
  20911. widget->setCurrentIndex(element.attribute("initial").toInt());
  20912. }
  20913. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20914. layout->addWidget(widget);
  20915. }
  20916. /*:719*//*730:*/
  20917. #line 14926 "./typica.w"
  20918. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  20919. QStack<QLayout*> *layoutStack)
  20920. {
  20921. FormArray*widget= new FormArray(element);
  20922. if(element.hasAttribute("id"))
  20923. {
  20924. widget->setObjectName(element.attribute("id"));
  20925. }
  20926. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20927. layout->addWidget(widget);
  20928. }
  20929. /*:730*//*751:*/
  20930. #line 15513 "./typica.w"
  20931. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  20932. QStack<QLayout*> *layoutStack)
  20933. {
  20934. ScaleControl*scale= new ScaleControl;
  20935. if(element.hasAttribute("id"))
  20936. {
  20937. scale->setObjectName(element.attribute("id"));
  20938. }
  20939. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20940. layout->addWidget(scale);
  20941. }
  20942. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  20943. QStack<QLayout*> *layoutStack)
  20944. {
  20945. IntensityControl*scale= new IntensityControl;
  20946. if(element.hasAttribute("id"))
  20947. {
  20948. scale->setObjectName(element.attribute("id"));
  20949. }
  20950. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20951. layout->addWidget(scale);
  20952. }
  20953. /*:751*//*777:*/
  20954. #line 16103 "./typica.w"
  20955. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  20956. {
  20957. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  20958. setDeviceTreeModelProperties(object,engine);
  20959. return object;
  20960. }
  20961. /*:777*//*779:*/
  20962. #line 16126 "./typica.w"
  20963. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  20964. {
  20965. setQAbstractItemModelProperties(value,engine);
  20966. value.setProperty("referenceElement",
  20967. engine->newFunction(DeviceTreeModel_referenceElement));
  20968. }
  20969. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  20970. {
  20971. setQObjectProperties(value,engine);
  20972. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  20973. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  20974. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  20975. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  20976. }
  20977. /*:779*//*780:*/
  20978. #line 16153 "./typica.w"
  20979. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  20980. QScriptEngine*engine)
  20981. {
  20982. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  20983. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  20984. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  20985. QDomElement node;
  20986. QVariantMap retval;
  20987. retval.insert("driver",referenceElement.attribute("driver"));
  20988. for(int i= 0;i<configData.size();i++)
  20989. {
  20990. node= configData.at(i).toElement();
  20991. retval.insert(node.attribute("name"),node.attribute("value"));
  20992. }
  20993. return engine->toScriptValue(retval);
  20994. }
  20995. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  20996. {
  20997. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20998. QModelIndex index= argument<QModelIndex> (0,context);
  20999. int role= argument<int> (1,context);
  21000. return engine->toScriptValue(model->data(index,role));
  21001. }
  21002. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  21003. {
  21004. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  21005. int row= 0;
  21006. int column= 0;
  21007. QModelIndex index;
  21008. if(context->argumentCount()> 1)
  21009. {
  21010. row= argument<int> (0,context);
  21011. column= argument<int> (1,context);
  21012. }
  21013. if(context->argumentCount()> 2)
  21014. {
  21015. index= argument<QModelIndex> (2,context);
  21016. }
  21017. QModelIndex retval= model->index(row,column,index);
  21018. return engine->toScriptValue(retval);
  21019. }
  21020. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  21021. QScriptEngine*)
  21022. {
  21023. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  21024. QModelIndex index;
  21025. if(context->argumentCount()==1)
  21026. {
  21027. index= argument<QModelIndex> (0,context);
  21028. }
  21029. return QScriptValue(model->rowCount(index));
  21030. }
  21031. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  21032. QScriptEngine*engine)
  21033. {
  21034. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  21035. QModelIndex index;
  21036. if(context->argumentCount()==1)
  21037. {
  21038. index= argument<QModelIndex> (0,context);
  21039. }
  21040. return QScriptValue(engine,model->hasChildren(index));
  21041. }
  21042. /*:780*//*783:*/
  21043. #line 16237 "./typica.w"
  21044. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  21045. {
  21046. QVariant var;
  21047. var.setValue(index);
  21048. QScriptValue object= engine->newVariant(var);
  21049. return object;
  21050. }
  21051. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  21052. {
  21053. index= value.toVariant().value<QModelIndex> ();
  21054. }
  21055. /*:783*//*799:*/
  21056. #line 16535 "./typica.w"
  21057. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  21058. QScriptEngine*engine)
  21059. {
  21060. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  21061. return object;
  21062. }
  21063. /*:799*//*870:*/
  21064. #line 49 "./settings.w"
  21065. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  21066. {
  21067. QScriptValue object= engine->newQObject(new SettingsWindow);
  21068. return object;
  21069. }
  21070. /*:870*//*899:*/
  21071. #line 19184 "./typica.w"
  21072. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  21073. {
  21074. QScriptValue object;
  21075. if(context->argumentCount()==2)
  21076. {
  21077. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  21078. argument<QModelIndex> (1,context)),
  21079. QScriptEngine::ScriptOwnership);
  21080. setModbusRTUDeviceProperties(object,engine);
  21081. }
  21082. else
  21083. {
  21084. context->throwError("Incorrect number of arguments passed to "
  21085. "ModbusRTUDevice constructor. This takes the configuration model "
  21086. "and an index.");
  21087. }
  21088. return object;
  21089. }
  21090. /*:899*//*900:*/
  21091. #line 19206 "./typica.w"
  21092. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  21093. {
  21094. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  21095. QScriptValue object;
  21096. if(self)
  21097. {
  21098. if(self->channels.size()> 0)
  21099. {
  21100. object= engine->newQObject(self->channels.at(0));
  21101. setChannelProperties(object,engine);
  21102. }
  21103. }
  21104. return object;
  21105. }
  21106. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  21107. {
  21108. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  21109. QScriptValue object;
  21110. if(self)
  21111. {
  21112. if(self->channels.size()> 1)
  21113. {
  21114. object= engine->newQObject(self->channels.at(1));
  21115. setChannelProperties(object,engine);
  21116. }
  21117. }
  21118. return object;
  21119. }
  21120. /*:900*//*901:*/
  21121. #line 19239 "./typica.w"
  21122. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  21123. {
  21124. setQObjectProperties(value,engine);
  21125. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  21126. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  21127. }
  21128. /*:901*//*917:*/
  21129. #line 713 "./modbus.w"
  21130. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine)
  21131. {
  21132. QScriptValue object;
  21133. if(context->argumentCount()==2)
  21134. {
  21135. object= engine->newQObject(new ModbusNG(argument<DeviceTreeModel*> (0,context),
  21136. argument<QModelIndex> (1,context)),
  21137. QScriptEngine::ScriptOwnership);
  21138. setModbusNGProperties(object,engine);
  21139. }
  21140. else
  21141. {
  21142. context->throwError("Incorrect number of arguments passed to "
  21143. "ModbusNG constructor.");
  21144. }
  21145. return object;
  21146. }
  21147. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine)
  21148. {
  21149. setQObjectProperties(value,engine);
  21150. value.setProperty("getChannel",engine->newFunction(ModbusNG_getChannel));
  21151. }
  21152. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine)
  21153. {
  21154. ModbusNG*self= getself<ModbusNG*> (context);
  21155. QScriptValue object;
  21156. if(self)
  21157. {
  21158. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  21159. setChannelProperties(object,engine);
  21160. }
  21161. return object;
  21162. }
  21163. #line 19790 "./typica.w"
  21164. #line 1 "./unsupportedserial.w"
  21165. /*:917*//*931:*/
  21166. #line 357 "./unsupportedserial.w"
  21167. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  21168. {
  21169. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  21170. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  21171. QScriptValue object= engine->newQObject(device);
  21172. setQObjectProperties(object,engine);
  21173. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  21174. return object;
  21175. }
  21176. /*:931*//*936:*/
  21177. #line 430 "./unsupportedserial.w"
  21178. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  21179. {
  21180. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  21181. QScriptValue object;
  21182. if(self)
  21183. {
  21184. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  21185. setChannelProperties(object,engine);
  21186. }
  21187. return object;
  21188. }
  21189. /*:936*//*943:*/
  21190. #line 630 "./unsupportedserial.w"
  21191. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  21192. {
  21193. return engine->toScriptValue<QTime> (QTime::currentTime());
  21194. }
  21195. /*:943*//*947:*/
  21196. #line 667 "./unsupportedserial.w"
  21197. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  21198. {
  21199. QScriptValue object= engine->newQObject(new QextSerialPort());
  21200. setSerialPortProperties(object,engine);
  21201. return object;
  21202. }
  21203. /*:947*//*948:*/
  21204. #line 678 "./unsupportedserial.w"
  21205. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  21206. {
  21207. setQIODeviceProperties(value,engine);
  21208. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  21209. }
  21210. /*:948*//*949:*/
  21211. #line 687 "./unsupportedserial.w"
  21212. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  21213. {
  21214. QextSerialPort*self= getself<QextSerialPort*> (context);
  21215. self->flush();
  21216. return QScriptValue();
  21217. }
  21218. #line 19792 "./typica.w"
  21219. #line 1 "./phidgets.w"
  21220. /*:949*//*970:*/
  21221. #line 463 "./phidgets.w"
  21222. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  21223. {
  21224. if(context->argumentCount()!=1)
  21225. {
  21226. context->throwError("Incorrect number of arguments passed to "
  21227. "PhidgetsTemperatureSensor constructor. This takes "
  21228. "a QModelIndex.");
  21229. }
  21230. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  21231. setQObjectProperties(object,engine);
  21232. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  21233. return object;
  21234. }
  21235. /*:970*//*971:*/
  21236. #line 480 "./phidgets.w"
  21237. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  21238. {
  21239. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  21240. QScriptValue object;
  21241. if(self)
  21242. {
  21243. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  21244. setChannelProperties(object,engine);
  21245. }
  21246. return object;
  21247. }
  21248. #line 19794 "./typica.w"
  21249. #line 1 "./phidget22.w"
  21250. /*:971*//*1002:*/
  21251. #line 811 "./phidget22.w"
  21252. QScriptValue constructPhidget22(QScriptContext*context,QScriptEngine*engine)
  21253. {
  21254. if(context->argumentCount()!=1)
  21255. {
  21256. context->throwError("Incorrect number of arguments");
  21257. }
  21258. QScriptValue object= engine->newQObject(new Phidget22(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  21259. setQObjectProperties(object,engine);
  21260. object.setProperty("getChannel",engine->newFunction(Phidget22_getChannel));
  21261. return object;
  21262. }
  21263. /*:1002*//*1003:*/
  21264. #line 826 "./phidget22.w"
  21265. QScriptValue Phidget22_getChannel(QScriptContext*context,QScriptEngine*engine)
  21266. {
  21267. Phidget22*self= getself<Phidget22*> (context);
  21268. QScriptValue object;
  21269. if(self)
  21270. {
  21271. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  21272. setChannelProperties(object,engine);
  21273. }
  21274. return object;
  21275. }
  21276. #line 19796 "./typica.w"
  21277. /*:1003*//*1035:*/
  21278. #line 151 "./rate.w"
  21279. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  21280. {
  21281. int cachetime= 1;
  21282. int scaletime= 1;
  21283. if(context->argumentCount()> 0)
  21284. {
  21285. cachetime= argument<int> (0,context);
  21286. if(context->argumentCount()> 1)
  21287. {
  21288. scaletime= argument<int> (1,context);
  21289. }
  21290. }
  21291. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  21292. setRateOfChangeProperties(object,engine);
  21293. return object;
  21294. }
  21295. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  21296. {
  21297. setQObjectProperties(value,engine);
  21298. }
  21299. /*:1035*//*1049:*/
  21300. #line 148 "./mergeseries.w"
  21301. QScriptValue constructDifferenceSeries(QScriptContext*,QScriptEngine*engine)
  21302. {
  21303. QScriptValue object= engine->newQObject(new DifferenceSeries);
  21304. setQObjectProperties(object,engine);
  21305. return object;
  21306. }
  21307. QScriptValue constructMeanSeries(QScriptContext*,QScriptEngine*engine)
  21308. {
  21309. QScriptValue object= engine->newQObject(new MeanSeries);
  21310. setQObjectProperties(object,engine);
  21311. return object;
  21312. }
  21313. /*:1049*//*1074:*/
  21314. #line 614 "./dataqsdk.w"
  21315. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  21316. {
  21317. QScriptValue object;
  21318. if(context->argumentCount()==1)
  21319. {
  21320. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  21321. QScriptEngine::ScriptOwnership);
  21322. setDataqSdkDeviceProperties(object,engine);
  21323. }
  21324. else
  21325. {
  21326. context->throwError("Incorrect number of arguments passed to "
  21327. "DataqSdkDevice. The constructor takes one string "
  21328. "as an argument specifying a device name. "
  21329. "Example: Dev1");
  21330. }
  21331. return object;
  21332. }
  21333. /*:1074*//*1075:*/
  21334. #line 637 "./dataqsdk.w"
  21335. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  21336. {
  21337. setQObjectProperties(value,engine);
  21338. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  21339. }
  21340. /*:1075*//*1076:*/
  21341. #line 647 "./dataqsdk.w"
  21342. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  21343. {
  21344. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  21345. QScriptValue object;
  21346. if(self)
  21347. {
  21348. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  21349. setChannelProperties(object,engine);
  21350. }
  21351. return object;
  21352. }
  21353. /*:1076*//*1101:*/
  21354. #line 80 "./scales.w"
  21355. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  21356. {
  21357. QScriptValue object;
  21358. QString labelText= "";
  21359. if(context->argumentCount()==1)
  21360. {
  21361. labelText= argument<QString> (0,context);
  21362. }
  21363. object= engine->newQObject(new DragLabel(labelText));
  21364. setDragLabelProperties(object,engine);
  21365. return object;
  21366. }
  21367. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  21368. {
  21369. setQLabelProperties(value,engine);
  21370. }
  21371. /*:1101*//*1111:*/
  21372. #line 298 "./scales.w"
  21373. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  21374. {
  21375. return engine->newVariant(QVariant((int)(value)));
  21376. }
  21377. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  21378. {
  21379. value= (BaudRateType)(sv.toVariant().toInt());
  21380. }
  21381. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  21382. {
  21383. return engine->newVariant(QVariant((int)(value)));
  21384. }
  21385. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  21386. {
  21387. value= (DataBitsType)(sv.toVariant().toInt());
  21388. }
  21389. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  21390. {
  21391. return engine->newVariant(QVariant((int)(value)));
  21392. }
  21393. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  21394. {
  21395. value= (ParityType)(sv.toVariant().toInt());
  21396. }
  21397. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  21398. {
  21399. return engine->newVariant(QVariant((int)(value)));
  21400. }
  21401. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  21402. {
  21403. value= (StopBitsType)(sv.toVariant().toInt());
  21404. }
  21405. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  21406. {
  21407. return engine->newVariant(QVariant((int)(value)));
  21408. }
  21409. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  21410. {
  21411. value= (FlowType)(sv.toVariant().toInt());
  21412. }
  21413. /*:1111*//*1114:*/
  21414. #line 367 "./scales.w"
  21415. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  21416. {
  21417. setQIODeviceProperties(value,engine);
  21418. }
  21419. /*:1114*//*1115:*/
  21420. #line 375 "./scales.w"
  21421. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  21422. {
  21423. QScriptValue object;
  21424. if(context->argumentCount()==1)
  21425. {
  21426. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  21427. setSerialScaleProperties(object,engine);
  21428. }
  21429. else
  21430. {
  21431. context->throwError("Incorrect number of arguments passed to "
  21432. "SerialScale. The constructor takes one string "
  21433. "as an argument specifying a port name.");
  21434. }
  21435. return object;
  21436. }
  21437. /*:1115*//*1137:*/
  21438. #line 278 "./valueannotation.w"
  21439. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  21440. {
  21441. QScriptValue object= engine->newQObject(new ValueAnnotation);
  21442. setValueAnnotationProperties(object,engine);
  21443. return object;
  21444. }
  21445. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  21446. {
  21447. setQObjectProperties(value,engine);
  21448. }
  21449. #line 20460 "./typica.w"
  21450. #line 1 "./thresholdannotation.w"
  21451. /*:1137*//*1148:*/
  21452. #line 208 "./thresholdannotation.w"
  21453. QScriptValue constructAnnotator(QScriptContext*context,QScriptEngine*engine)
  21454. {
  21455. QScriptValue object= engine->newQObject(new Annotator(argument<QString> (0,context)));
  21456. setAnnotatorProperties(object,engine);
  21457. return object;
  21458. }
  21459. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine)
  21460. {
  21461. setQObjectProperties(value,engine);
  21462. }
  21463. #line 20462 "./typica.w"
  21464. #line 1 "./user.w"
  21465. /*:1148*//*1158:*/
  21466. #line 142 "./user.w"
  21467. QScriptValue constructLoginDialog(QScriptContext*,QScriptEngine*engine)
  21468. {
  21469. QScriptValue object= engine->newQObject(new LoginDialog);
  21470. return object;
  21471. }
  21472. /*:1158*//*1168:*/
  21473. #line 330 "./user.w"
  21474. QScriptValue constructNewTypicaUser(QScriptContext*,QScriptEngine*engine)
  21475. {
  21476. QScriptValue object= engine->newQObject(new NewTypicaUser);
  21477. return object;
  21478. }
  21479. /*:1168*/
  21480. #line 533 "./typica.w"
  21481. /*647:*/
  21482. #line 13834 "./typica.w"
  21483. void messageFileOutput(QtMsgType,const char*msg)
  21484. {
  21485. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  21486. output.open(QIODevice::WriteOnly|QIODevice::Append);
  21487. QTextStream outstream(&output);
  21488. outstream<<msg<<"\r\n";
  21489. }
  21490. /*:647*/
  21491. #line 534 "./typica.w"
  21492. /*644:*/
  21493. #line 13795 "./typica.w"
  21494. int main(int argc,char**argv)
  21495. {
  21496. int*c= &argc;
  21497. Application app(*c,argv);
  21498. QSettings settings;
  21499. /*645:*/
  21500. #line 13821 "./typica.w"
  21501. if(settings.value("settings/advanced/logging",false).toBool())
  21502. {
  21503. qInstallMsgHandler(messageFileOutput);
  21504. }
  21505. /*:645*/
  21506. #line 13801 "./typica.w"
  21507. /*648:*/
  21508. #line 13847 "./typica.w"
  21509. QStringList themeSearchPath= QIcon::themeSearchPaths();
  21510. themeSearchPath.append(":/resources/icons/tango");
  21511. QIcon::setThemeSearchPaths(themeSearchPath);
  21512. QIcon::setThemeName(":/resources/icons/tango");
  21513. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  21514. /*:648*/
  21515. #line 13802 "./typica.w"
  21516. /*649:*/
  21517. #line 13867 "./typica.w"
  21518. QFile entypo(":/resources/fonts/entypo.ttf");
  21519. entypo.open(QIODevice::ReadOnly);
  21520. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  21521. entypo.close();
  21522. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  21523. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  21524. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  21525. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  21526. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  21527. /*:649*/
  21528. #line 13803 "./typica.w"
  21529. /*809:*/
  21530. #line 16825 "./typica.w"
  21531. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  21532. /*:809*//*819:*/
  21533. #line 17067 "./typica.w"
  21534. app.registerDeviceConfigurationWidget("nidaqmxbase",
  21535. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  21536. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  21537. NiDaqMxBase9211ConfWidget::staticMetaObject);
  21538. app.registerDeviceConfigurationWidget("ni9211seriestc",
  21539. Ni9211TcConfWidget::staticMetaObject);
  21540. /*:819*//*827:*/
  21541. #line 17298 "./typica.w"
  21542. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  21543. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  21544. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  21545. /*:827*//*851:*/
  21546. #line 18267 "./typica.w"
  21547. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  21548. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  21549. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  21550. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  21551. /*:851*//*856:*/
  21552. #line 18352 "./typica.w"
  21553. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  21554. /*:856*//*859:*/
  21555. #line 18422 "./typica.w"
  21556. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  21557. /*:859*//*862:*/
  21558. #line 18549 "./typica.w"
  21559. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  21560. #line 1 "./freeannotation.w"
  21561. /*:862*//*866:*/
  21562. #line 57 "./freeannotation.w"
  21563. app.registerDeviceConfigurationWidget("freeannotation",
  21564. FreeAnnotationConfWidget::staticMetaObject);
  21565. #line 18553 "./typica.w"
  21566. #line 1 "./settings.w"
  21567. /*:866*//*904:*/
  21568. #line 19780 "./typica.w"
  21569. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  21570. /*:904*//*910:*/
  21571. #line 321 "./modbus.w"
  21572. app.registerDeviceConfigurationWidget("modbusngport",ModbusNGConfWidget::staticMetaObject);
  21573. app.registerDeviceConfigurationWidget("modbusnginput",
  21574. ModbusNGInputConfWidget::staticMetaObject);
  21575. /*:910*//*926:*/
  21576. #line 264 "./unsupportedserial.w"
  21577. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  21578. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  21579. app.registerDeviceConfigurationWidget("unsupporteddevice",
  21580. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  21581. /*:926*//*957:*/
  21582. #line 181 "./phidgets.w"
  21583. app.registerDeviceConfigurationWidget("phidgets1048",
  21584. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  21585. app.registerDeviceConfigurationWidget("phidgets1048channel",
  21586. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  21587. /*:957*//*973:*/
  21588. #line 35 "./phidget22.w"
  21589. app.registerDeviceConfigurationWidget("phidget22",
  21590. PhidgetConfWidget::staticMetaObject);
  21591. app.registerDeviceConfigurationWidget("phidgetchannel",
  21592. PhidgetChannelConfWidget::staticMetaObject);
  21593. /*:973*//*1009:*/
  21594. #line 19918 "./typica.w"
  21595. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  21596. /*:1009*//*1012:*/
  21597. #line 19978 "./typica.w"
  21598. app.registerDeviceConfigurationWidget("coolingtimer",
  21599. CoolingTimerConfWidget::staticMetaObject);
  21600. /*:1012*//*1017:*/
  21601. #line 20237 "./typica.w"
  21602. app.registerDeviceConfigurationWidget("rangetimer",
  21603. RangeTimerConfWidget::staticMetaObject);
  21604. /*:1017*//*1022:*/
  21605. #line 20338 "./typica.w"
  21606. app.registerDeviceConfigurationWidget("multirangetimer",
  21607. MultiRangeTimerConfWidget::staticMetaObject);
  21608. /*:1022*//*1027:*/
  21609. #line 20448 "./typica.w"
  21610. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  21611. #line 1 "./rate.w"
  21612. /*:1027*//*1039:*/
  21613. #line 253 "./rate.w"
  21614. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  21615. /*:1039*//*1053:*/
  21616. #line 266 "./mergeseries.w"
  21617. app.registerDeviceConfigurationWidget("mergeseries",
  21618. MergeSeriesConfWidget::staticMetaObject);
  21619. /*:1053*//*1094:*/
  21620. #line 1233 "./dataqsdk.w"
  21621. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  21622. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  21623. DataqSdkChannelConfWidget::staticMetaObject);
  21624. /*:1094*//*1119:*/
  21625. #line 552 "./scales.w"
  21626. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  21627. /*:1119*//*1127:*/
  21628. #line 138 "./valueannotation.w"
  21629. app.registerDeviceConfigurationWidget("valueannotation",
  21630. ValueAnnotationConfWidget::staticMetaObject);
  21631. /*:1127*//*1141:*/
  21632. #line 109 "./thresholdannotation.w"
  21633. app.registerDeviceConfigurationWidget("thresholdannotation",
  21634. ThresholdAnnotationConfWidget::staticMetaObject);
  21635. /*:1141*/
  21636. #line 13805 "./typica.w"
  21637. /*650:*/
  21638. #line 13884 "./typica.w"
  21639. if(settings.value("database/exists","false").toString()=="true")
  21640. {
  21641. /*655:*/
  21642. #line 14018 "./typica.w"
  21643. QSqlDatabase database=
  21644. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  21645. database.setConnectOptions("application_name=Typica");
  21646. database.setHostName(settings.value("database/hostname").toString());
  21647. database.setPort(settings.value("database/portnumber",5432).toInt());
  21648. database.setDatabaseName(settings.value("database/dbname").toString());
  21649. database.setUserName(settings.value("database/user").toString());
  21650. database.setPassword(settings.value("database/password").toString());
  21651. if(!database.open())
  21652. {
  21653. settings.setValue("database/exists","false");
  21654. }
  21655. else
  21656. {
  21657. AppInstance->setDatabaseConnected(true);
  21658. }
  21659. /*:655*/
  21660. #line 13887 "./typica.w"
  21661. }
  21662. if(settings.value("database/exists","false").toString()=="false")
  21663. {
  21664. /*654:*/
  21665. #line 14009 "./typica.w"
  21666. SqlConnectionSetup dialog;
  21667. dialog.exec();
  21668. /*:654*/
  21669. #line 13891 "./typica.w"
  21670. }
  21671. /*:650*/
  21672. #line 13806 "./typica.w"
  21673. /*193:*/
  21674. #line 4455 "./typica.w"
  21675. QStringList arguments= QCoreApplication::arguments();
  21676. int position= arguments.indexOf("-c");
  21677. QString filename= QString();
  21678. if(position!=-1)
  21679. {
  21680. if(arguments.size()>=position+1)
  21681. {
  21682. filename= arguments.at(position+1);
  21683. }
  21684. }else{
  21685. QDir checkPath(QCoreApplication::applicationDirPath()+"/../config/");
  21686. if(checkPath.exists("config.xml")){
  21687. filename= checkPath.filePath("config.xml");
  21688. }else{
  21689. checkPath= QDir(QCoreApplication::applicationDirPath()+"/config/");
  21690. if(checkPath.exists("config.xml")){
  21691. filename= checkPath.filePath("config.xml");
  21692. }
  21693. }
  21694. }
  21695. if(filename.isEmpty())
  21696. {
  21697. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  21698. settings.value("config","").toString());
  21699. }
  21700. QDir directory;
  21701. if(!filename.isEmpty())
  21702. {
  21703. QFile file(filename);
  21704. QFileInfo info(filename);
  21705. directory= info.dir();
  21706. QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
  21707. QTranslator*configtr= new QTranslator;
  21708. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  21709. QString("%1/Translations").arg(directory.canonicalPath())))
  21710. {
  21711. QCoreApplication::installTranslator(configtr);
  21712. }
  21713. settings.setValue("config",directory.path());
  21714. if(file.open(QIODevice::ReadOnly))
  21715. {
  21716. app.configuration()->setContent(&file,true);
  21717. }
  21718. }else{
  21719. return 1;
  21720. }
  21721. /*194:*/
  21722. #line 4508 "./typica.w"
  21723. QDomElement root= app.configuration()->documentElement();
  21724. QDomNodeList children= root.childNodes();
  21725. QString replacementDoc;
  21726. QDomDocument includedDoc;
  21727. QDomDocumentFragment fragment;
  21728. for(int i= 0;i<children.size();i++)
  21729. {
  21730. QDomNode currentNode= children.at(i);
  21731. QDomElement currentElement;
  21732. if(currentNode.nodeName()=="include")
  21733. {
  21734. currentElement= currentNode.toElement();
  21735. if(currentElement.hasAttribute("src"))
  21736. {
  21737. replacementDoc= directory.path();
  21738. replacementDoc.append('/');
  21739. replacementDoc.append(currentElement.attribute("src"));
  21740. QFile doc(replacementDoc);
  21741. if(doc.open(QIODevice::ReadOnly))
  21742. {
  21743. includedDoc.setContent(&doc,true);
  21744. fragment= includedDoc.createDocumentFragment();
  21745. fragment.appendChild(includedDoc.documentElement());
  21746. root.replaceChild(fragment,currentNode);
  21747. doc.close();
  21748. }
  21749. }
  21750. }
  21751. }
  21752. /*:194*/
  21753. #line 4502 "./typica.w"
  21754. /*:193*/
  21755. #line 13807 "./typica.w"
  21756. /*7:*/
  21757. #line 667 "./typica.w"
  21758. QScriptEngine*engine= new QScriptEngine;
  21759. QScriptValue constructor;
  21760. QScriptValue value;
  21761. /*:7*//*17:*/
  21762. #line 875 "./typica.w"
  21763. constructor= engine->newFunction(constructQTimer);
  21764. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  21765. engine->globalObject().setProperty("Timer",value);
  21766. /*:17*//*20:*/
  21767. #line 914 "./typica.w"
  21768. constructor= engine->newFunction(constructQWidget);
  21769. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  21770. engine->globalObject().setProperty("QWidget",value);
  21771. /*:20*//*24:*/
  21772. #line 1002 "./typica.w"
  21773. constructor= engine->newFunction(displayWarning);
  21774. engine->globalObject().setProperty("displayWarning",constructor);
  21775. constructor= engine->newFunction(displayError);
  21776. engine->globalObject().setProperty("displayError",constructor);
  21777. constructor= engine->newFunction(displayInfo);
  21778. engine->globalObject().setProperty("displayInfo",constructor);
  21779. /*:24*//*34:*/
  21780. #line 1240 "./typica.w"
  21781. constructor= engine->newFunction(constructQMainWindow);
  21782. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  21783. constructor);
  21784. engine->globalObject().setProperty("QMainWindow",value);
  21785. /*:34*//*45:*/
  21786. #line 1445 "./typica.w"
  21787. constructor= engine->newFunction(constructQFrame);
  21788. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  21789. engine->globalObject().setProperty("QFrame",value);
  21790. /*:45*//*48:*/
  21791. #line 1478 "./typica.w"
  21792. constructor= engine->newFunction(constructQLabel);
  21793. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  21794. engine->globalObject().setProperty("QLabel",value);
  21795. /*:48*//*51:*/
  21796. #line 1521 "./typica.w"
  21797. constructor= engine->newFunction(constructQSvgWidget);
  21798. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  21799. engine->globalObject().setProperty("QSvgWidget",value);
  21800. /*:51*//*57:*/
  21801. #line 1603 "./typica.w"
  21802. constructor= engine->newFunction(constructQLineEdit);
  21803. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  21804. engine->globalObject().setProperty("QLineEdit",value);
  21805. /*:57*//*61:*/
  21806. #line 1652 "./typica.w"
  21807. constructor= engine->newFunction(constructQSplitter);
  21808. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  21809. engine->globalObject().setProperty("QSplitter",value);
  21810. /*:61*//*70:*/
  21811. #line 1861 "./typica.w"
  21812. constructor= engine->newFunction(constructQBoxLayout);
  21813. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  21814. engine->globalObject().setProperty("QBoxLayout",value);
  21815. /*:70*//*74:*/
  21816. #line 1973 "./typica.w"
  21817. constructor= engine->newFunction(constructQAction);
  21818. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  21819. engine->globalObject().setProperty("QAction",value);
  21820. /*:74*//*77:*/
  21821. #line 2032 "./typica.w"
  21822. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  21823. value.setProperty("getOpenFileName",
  21824. engine->newFunction(QFileDialog_getOpenFileName));
  21825. value.setProperty("getSaveFileName",
  21826. engine->newFunction(QFileDialog_getSaveFileName));
  21827. engine->globalObject().setProperty("QFileDialog",value);
  21828. /*:77*//*82:*/
  21829. #line 2150 "./typica.w"
  21830. constructor= engine->newFunction(constructQFile);
  21831. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  21832. engine->globalObject().setProperty("QFile",value);
  21833. /*:82*//*93:*/
  21834. #line 2368 "./typica.w"
  21835. constructor= engine->newFunction(constructQProcess);
  21836. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  21837. engine->globalObject().setProperty("QProcess",value);
  21838. /*:93*//*102:*/
  21839. #line 2517 "./typica.w"
  21840. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  21841. constructor= engine->newFunction(constructQByteArray);
  21842. engine->globalObject().setProperty("QByteArray",constructor);
  21843. /*:102*//*114:*/
  21844. #line 2759 "./typica.w"
  21845. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  21846. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  21847. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  21848. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  21849. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  21850. /*:114*//*117:*/
  21851. #line 2863 "./typica.w"
  21852. constructor= engine->newFunction(constructQBuffer);
  21853. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  21854. engine->globalObject().setProperty("QBuffer",value);
  21855. /*:117*//*120:*/
  21856. #line 2919 "./typica.w"
  21857. constructor= engine->newFunction(constructXQuery);
  21858. engine->globalObject().setProperty("XQuery",constructor);
  21859. /*:120*//*126:*/
  21860. #line 3021 "./typica.w"
  21861. constructor= engine->newFunction(constructXmlWriter);
  21862. engine->globalObject().setProperty("XmlWriter",constructor);
  21863. /*:126*//*135:*/
  21864. #line 3227 "./typica.w"
  21865. constructor= engine->newFunction(constructXmlReader);
  21866. engine->globalObject().setProperty("XmlReader",constructor);
  21867. /*:135*//*142:*/
  21868. #line 3351 "./typica.w"
  21869. value= engine->newQObject(&settings);
  21870. setQSettingsProperties(value,engine);
  21871. engine->globalObject().setProperty("QSettings",value);
  21872. /*:142*//*146:*/
  21873. #line 3432 "./typica.w"
  21874. constructor= engine->newFunction(constructQLCDNumber);
  21875. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  21876. engine->globalObject().setProperty("QLCDNumber",value);
  21877. /*:146*//*149:*/
  21878. #line 3488 "./typica.w"
  21879. constructor= engine->newFunction(constructQTime);
  21880. engine->globalObject().setProperty("QTime",constructor);
  21881. /*:149*//*171:*/
  21882. #line 4001 "./typica.w"
  21883. constructor= engine->newFunction(constructQPushButton);
  21884. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  21885. engine->globalObject().setProperty("QPushButton",value);
  21886. /*:171*//*178:*/
  21887. #line 4112 "./typica.w"
  21888. constructor= engine->newFunction(constructQSqlQuery);
  21889. engine->globalObject().setProperty("QSqlQuery",constructor);
  21890. /*:178*//*185:*/
  21891. #line 4276 "./typica.w"
  21892. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  21893. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  21894. engine->globalObject().setProperty("sqlToArray",
  21895. engine->newFunction(sqlToArray));
  21896. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  21897. engine->globalObject().setProperty("annotationFromRecord",
  21898. engine->newFunction(annotationFromRecord));
  21899. engine->globalObject().setProperty("setTabOrder",
  21900. engine->newFunction(setTabOrder));
  21901. engine->globalObject().setProperty("saveFileFromDatabase",
  21902. engine->newFunction(saveFileFromDatabase));
  21903. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  21904. /*:185*//*198:*/
  21905. #line 4677 "./typica.w"
  21906. engine->globalObject().setProperty("createWindow",
  21907. engine->newFunction(createWindow));
  21908. engine->globalObject().setProperty("createReport",
  21909. engine->newFunction(createReport));
  21910. /*:198*//*223:*/
  21911. #line 5049 "./typica.w"
  21912. constructor= engine->newFunction(constructQTabBar);
  21913. value= engine->newQMetaObject(&QTabBar::staticMetaObject,constructor);
  21914. engine->globalObject().setProperty("QTabBar",value);
  21915. /*:223*//*272:*/
  21916. #line 6452 "./typica.w"
  21917. engine->globalObject().setProperty("findChildObject",
  21918. engine->newFunction(findChildObject));
  21919. /*:272*//*298:*/
  21920. #line 389 "./units.w"
  21921. value= engine->newQMetaObject(&Units::staticMetaObject);
  21922. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  21923. value.setProperty("convertRelativeTemperature",
  21924. engine->newFunction(Units_convertRelativeTemperature));
  21925. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  21926. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  21927. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  21928. engine->globalObject().setProperty("Units",value);
  21929. /*:298*//*303:*/
  21930. #line 462 "./units.w"
  21931. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  21932. #line 6884 "./typica.w"
  21933. /*:303*//*311:*/
  21934. #line 141 "./measurement.w"
  21935. constructor= engine->newFunction(constructMeasurement);
  21936. engine->globalObject().setProperty("Measurement",constructor);
  21937. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  21938. /*:311*//*331:*/
  21939. #line 7455 "./typica.w"
  21940. constructor= engine->newFunction(constructDAQ);
  21941. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  21942. value.setProperty("Fahrenheit",Units::Fahrenheit);
  21943. value.setProperty("Celsius",Units::Celsius);
  21944. value.setProperty("Kelvin",Units::Kelvin);
  21945. value.setProperty("Rankine",Units::Rankine);
  21946. engine->globalObject().setProperty("DAQ",value);
  21947. /*:331*//*340:*/
  21948. #line 7657 "./typica.w"
  21949. constructor= engine->newFunction(constructFakeDAQ);
  21950. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  21951. engine->globalObject().setProperty("FakeDAQ",value);
  21952. /*:340*//*351:*/
  21953. #line 7940 "./typica.w"
  21954. constructor= engine->newFunction(constructLinearCalibrator);
  21955. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  21956. constructor);
  21957. engine->globalObject().setProperty("LinearCalibrator",value);
  21958. /*:351*//*356:*/
  21959. #line 8079 "./typica.w"
  21960. constructor= engine->newFunction(constructLinearSplineInterpolator);
  21961. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  21962. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  21963. /*:356*//*366:*/
  21964. #line 8287 "./typica.w"
  21965. constructor= engine->newFunction(constructTemperatureDisplay);
  21966. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  21967. constructor);
  21968. engine->globalObject().setProperty("TemperatureDisplay",value);
  21969. /*:366*//*374:*/
  21970. #line 8445 "./typica.w"
  21971. constructor= engine->newFunction(constructMeasurementTimeOffset);
  21972. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  21973. constructor);
  21974. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  21975. /*:374*//*379:*/
  21976. #line 8566 "./typica.w"
  21977. constructor= engine->newFunction(constructThresholdDetector);
  21978. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  21979. engine->globalObject().setProperty("ThresholdDetector",value);
  21980. /*:379*//*384:*/
  21981. #line 8665 "./typica.w"
  21982. constructor= engine->newFunction(constructZeroEmitter);
  21983. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  21984. engine->globalObject().setProperty("ZeroEmitter",value);
  21985. /*:384*//*389:*/
  21986. #line 8744 "./typica.w"
  21987. constructor= engine->newFunction(constructMeasurementAdapter);
  21988. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  21989. constructor);
  21990. engine->globalObject().setProperty("MeasurementAdapter",value);
  21991. /*:389*//*406:*/
  21992. #line 9207 "./typica.w"
  21993. constructor= engine->newFunction(constructGraphView);
  21994. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  21995. engine->globalObject().setProperty("GraphView",value);
  21996. /*:406*//*429:*/
  21997. #line 9856 "./typica.w"
  21998. constructor= engine->newFunction(constructZoomLog);
  21999. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  22000. engine->globalObject().setProperty("ZoomLog",value);
  22001. /*:429*//*467:*/
  22002. #line 10804 "./typica.w"
  22003. constructor= engine->newFunction(constructAnnotationButton);
  22004. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  22005. constructor);
  22006. engine->globalObject().setProperty("AnnotationButton",value);
  22007. /*:467*//*475:*/
  22008. #line 10946 "./typica.w"
  22009. constructor= engine->newFunction(constructAnnotationSpinBox);
  22010. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  22011. constructor);
  22012. engine->globalObject().setProperty("AnnotationSpinBox",value);
  22013. /*:475*//*496:*/
  22014. #line 11371 "./typica.w"
  22015. constructor= engine->newFunction(constructTimerDisplay);
  22016. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  22017. engine->globalObject().setProperty("TimerDisplay",value);
  22018. /*:496*//*524:*/
  22019. #line 11895 "./typica.w"
  22020. constructor= engine->newFunction(constructWidgetDecorator);
  22021. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  22022. engine->globalObject().setProperty("WidgetDecorator",value);
  22023. /*:524*//*537:*/
  22024. #line 12177 "./typica.w"
  22025. constructor= engine->newFunction(constructLogEditWindow);
  22026. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  22027. engine->globalObject().setProperty("LogEditWindow",value);
  22028. /*:537*//*556:*/
  22029. #line 12704 "./typica.w"
  22030. constructor= engine->newFunction(constructXMLInput);
  22031. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  22032. engine->globalObject().setProperty("XMLInput",value);
  22033. /*:556*//*571:*/
  22034. #line 164 "./webview.w"
  22035. constructor= engine->newFunction(constructWebView);
  22036. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  22037. engine->globalObject().setProperty("WebView",value);
  22038. /*:571*//*579:*/
  22039. #line 256 "./webview.w"
  22040. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  22041. /*:579*//*582:*/
  22042. #line 298 "./webview.w"
  22043. constructor= engine->newFunction(constructWebElement);
  22044. engine->globalObject().setProperty("WebElement",constructor);
  22045. /*:582*//*594:*/
  22046. #line 76 "./printerselector.w"
  22047. constructor= engine->newFunction(constructPrinterSelector);
  22048. engine->globalObject().setProperty("PrinterSelector",constructor);
  22049. /*:594*//*602:*/
  22050. #line 12966 "./typica.w"
  22051. value= engine->newQObject(AppInstance);
  22052. value.setProperty("subscribe",engine->newFunction(Application_subscribe));
  22053. engine->globalObject().setProperty("Application",value);
  22054. /*:602*//*667:*/
  22055. #line 14207 "./typica.w"
  22056. constructor= engine->newFunction(constructSqlQueryView);
  22057. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  22058. engine->globalObject().setProperty("SqlQueryView",value);
  22059. /*:667*//*778:*/
  22060. #line 16113 "./typica.w"
  22061. constructor= engine->newFunction(constructDeviceTreeModel);
  22062. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  22063. constructor);
  22064. engine->globalObject().setProperty("DeviceTreeModel",value);
  22065. /*:778*//*784:*/
  22066. #line 16253 "./typica.w"
  22067. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  22068. /*:784*//*800:*/
  22069. #line 16545 "./typica.w"
  22070. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  22071. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  22072. constructor);
  22073. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  22074. /*:800*//*871:*/
  22075. #line 58 "./settings.w"
  22076. constructor= engine->newFunction(constructSettingsWindow);
  22077. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  22078. engine->globalObject().setProperty("SettingsWindow",value);
  22079. #line 1 "./graphsettings.w"
  22080. /*:871*//*898:*/
  22081. #line 19175 "./typica.w"
  22082. constructor= engine->newFunction(constructModbusRTUDevice);
  22083. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  22084. engine->globalObject().setProperty("ModbusRTUDevice",value);
  22085. /*:898*//*916:*/
  22086. #line 705 "./modbus.w"
  22087. constructor= engine->newFunction(constructModbusNG);
  22088. value= engine->newQMetaObject(&ModbusNG::staticMetaObject,constructor);
  22089. engine->globalObject().setProperty("ModbusNG",value);
  22090. /*:916*//*930:*/
  22091. #line 350 "./unsupportedserial.w"
  22092. engine->globalObject().setProperty("createDevice",
  22093. engine->newFunction(createDevice));
  22094. /*:930*//*942:*/
  22095. #line 622 "./unsupportedserial.w"
  22096. engine->globalObject().setProperty("getMeasurementTimestamp",
  22097. engine->newFunction(getMeasurementTimestamp));
  22098. /*:942*//*946:*/
  22099. #line 658 "./unsupportedserial.w"
  22100. constructor= engine->newFunction(constructSerialPort);
  22101. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  22102. engine->globalObject().setProperty("SerialPort",value);
  22103. /*:946*//*968:*/
  22104. #line 450 "./phidgets.w"
  22105. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  22106. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  22107. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  22108. /*:968*//*1000:*/
  22109. #line 798 "./phidget22.w"
  22110. constructor= engine->newFunction(constructPhidget22);
  22111. value= engine->newQMetaObject(&Phidget22::staticMetaObject,constructor);
  22112. engine->globalObject().setProperty("Phidget22",value);
  22113. /*:1000*//*1034:*/
  22114. #line 144 "./rate.w"
  22115. constructor= engine->newFunction(constructRateOfChange);
  22116. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  22117. engine->globalObject().setProperty("RateOfChange",value);
  22118. /*:1034*//*1048:*/
  22119. #line 137 "./mergeseries.w"
  22120. constructor= engine->newFunction(constructDifferenceSeries);
  22121. value= engine->newQMetaObject(&DifferenceSeries::staticMetaObject,
  22122. constructor);
  22123. engine->globalObject().setProperty("DifferenceSeries",value);
  22124. constructor= engine->newFunction(constructMeanSeries);
  22125. value= engine->newQMetaObject(&MeanSeries::staticMetaObject,constructor);
  22126. engine->globalObject().setProperty("MeanSeries",value);
  22127. /*:1048*//*1073:*/
  22128. #line 604 "./dataqsdk.w"
  22129. constructor= engine->newFunction(constructDataqSdkDevice);
  22130. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  22131. engine->globalObject().setProperty("DataqSdkDevice",value);
  22132. /*:1073*//*1100:*/
  22133. #line 73 "./scales.w"
  22134. constructor= engine->newFunction(constructDragLabel);
  22135. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  22136. engine->globalObject().setProperty("DragLabel",value);
  22137. /*:1100*//*1108:*/
  22138. #line 265 "./scales.w"
  22139. constructor= engine->newFunction(constructSerialScale);
  22140. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  22141. engine->globalObject().setProperty("SerialScale",value);
  22142. /*:1108*//*1112:*/
  22143. #line 351 "./scales.w"
  22144. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  22145. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  22146. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  22147. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  22148. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  22149. /*:1112*//*1136:*/
  22150. #line 271 "./valueannotation.w"
  22151. constructor= engine->newFunction(constructValueAnnotation);
  22152. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  22153. engine->globalObject().setProperty("ValueAnnotation",value);
  22154. /*:1136*//*1147:*/
  22155. #line 201 "./thresholdannotation.w"
  22156. constructor= engine->newFunction(constructAnnotator);
  22157. value= engine->newQMetaObject(&Annotator::staticMetaObject,constructor);
  22158. engine->globalObject().setProperty("Annotator",value);
  22159. /*:1147*//*1157:*/
  22160. #line 135 "./user.w"
  22161. constructor= engine->newFunction(constructLoginDialog);
  22162. value= engine->newQMetaObject(&LoginDialog::staticMetaObject,constructor);
  22163. engine->globalObject().setProperty("LoginDialog",value);
  22164. /*:1157*//*1167:*/
  22165. #line 323 "./user.w"
  22166. constructor= engine->newFunction(constructNewTypicaUser);
  22167. value= engine->newQMetaObject(&NewTypicaUser::staticMetaObject,constructor);
  22168. engine->globalObject().setProperty("NewTypicaUser",value);
  22169. /*:1167*/
  22170. #line 13808 "./typica.w"
  22171. app.engine= engine;
  22172. /*195:*/
  22173. #line 4556 "./typica.w"
  22174. QString styleText;
  22175. QString programText;
  22176. QDomElement currentElement;
  22177. for(int i= 0;i<children.size();i++)
  22178. {
  22179. QDomNode currentNode= children.at(i);
  22180. if(currentNode.nodeName()=="style")
  22181. {
  22182. currentElement= currentNode.toElement();
  22183. styleText.append(currentElement.text());
  22184. }
  22185. else if(currentNode.nodeName()=="program")
  22186. {
  22187. currentElement= currentNode.toElement();
  22188. programText.append(currentElement.text());
  22189. }
  22190. }
  22191. app.setStyleSheet(styleText);
  22192. QScriptValue result= engine->evaluate(programText);
  22193. /*196:*/
  22194. #line 4581 "./typica.w"
  22195. if(engine->hasUncaughtException())
  22196. {
  22197. int line= engine->uncaughtExceptionLineNumber();
  22198. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  22199. result.toString();
  22200. QString trace;
  22201. foreach(trace,engine->uncaughtExceptionBacktrace())
  22202. {
  22203. qDebug()<<trace;
  22204. }
  22205. }
  22206. /*:196*/
  22207. #line 4576 "./typica.w"
  22208. /*:195*/
  22209. #line 13810 "./typica.w"
  22210. int retval= app.exec();
  22211. delete engine;
  22212. return retval;
  22213. }
  22214. /*:644*/
  22215. #line 535 "./typica.w"
  22216. #include "moc_typica.cpp"
  22217. /*:3*/