Typica is a free program for professional coffee roasters. https://typica.us
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

typica.cpp 493KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 616 "./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. /*:5*//*6:*/
  16. #line 631 "./typica.w"
  17. #include "helpmenu.h"
  18. /*:6*//*276:*/
  19. #line 6353 "./typica.w"
  20. #include "units.h"
  21. #line 1 "./measurement.w"
  22. /*:276*//*545:*/
  23. #line 197 "./webview.w"
  24. #include "webview.h"
  25. /*:545*//*558:*/
  26. #line 375 "./webview.w"
  27. #include "webelement.h"
  28. #line 12282 "./typica.w"
  29. /*:558*//*669:*/
  30. #line 478 "./daterangeselector.w"
  31. #include "daterangeselector.h"
  32. #line 13998 "./typica.w"
  33. /*:669*//*777:*/
  34. #line 16499 "./typica.w"
  35. #include "qextserialport.h"
  36. #include "qextserialenumerator.h"
  37. /*:777*//*934:*/
  38. #line 124 "./dataqsdk.w"
  39. #ifdef Q_OS_WIN32
  40. #include <windef.h>
  41. #else
  42. #define PASCAL
  43. #endif
  44. /*:934*//*958:*/
  45. #line 862 "./dataqsdk.w"
  46. #include <limits>
  47. /*:958*//*973:*/
  48. #line 62 "./scales.w"
  49. #include "draglabel.h"
  50. /*:973*//*988:*/
  51. #line 335 "./scales.w"
  52. #include "scale.h"
  53. /*:988*/
  54. #line 525 "./typica.w"
  55. /*20:*/
  56. #line 946 "./typica.w"
  57. class ScriptQMainWindow:public QMainWindow
  58. {
  59. Q_OBJECT
  60. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  61. public:
  62. ScriptQMainWindow();
  63. QString closePrompt();
  64. public slots:
  65. void show();
  66. void saveSizeAndPosition(const QString&key);
  67. void restoreSizeAndPosition(const QString&key);
  68. void displayStatus(const QString&message= QString());
  69. void setClosePrompt(QString prompt);
  70. protected:
  71. void closeEvent(QCloseEvent*event);
  72. void showEvent(QShowEvent*event);
  73. signals:
  74. void aboutToClose(void);
  75. private:
  76. QString cprompt;
  77. };
  78. /*:20*//*160:*/
  79. #line 3783 "./typica.w"
  80. class SqlQueryConnection:public QSqlQuery
  81. {
  82. public:
  83. SqlQueryConnection(const QString&query= QString());
  84. ~SqlQueryConnection();
  85. QSqlQuery*operator->()const;
  86. private:
  87. QString connection;
  88. QSqlQuery*q;
  89. };
  90. /*:160*//*230:*/
  91. #line 5632 "./typica.w"
  92. class NumericDelegate:public QItemDelegate
  93. {
  94. Q_OBJECT
  95. public:
  96. NumericDelegate(QObject*parent= NULL);
  97. QWidget*createEditor(QWidget*parent,
  98. const QStyleOptionViewItem&option,
  99. const QModelIndex&index)const;
  100. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  101. void setModelData(QWidget*editor,QAbstractItemModel*model,
  102. const QModelIndex&index)const;
  103. void updateEditorGeometry(QWidget*editor,
  104. const QStyleOptionViewItem&option,
  105. const QModelIndex&index)const;
  106. };
  107. /*:230*//*272:*/
  108. #line 425 "./units.w"
  109. Q_DECLARE_METATYPE(Units::Unit)
  110. /*:272*//*277:*/
  111. #line 19 "./measurement.w"
  112. class Measurement:public QVariantMap
  113. {
  114. public:
  115. Measurement(double temperature= 0,QTime time= QTime(),
  116. Units::Unit sc= Units::Fahrenheit);
  117. Measurement(double temperature);
  118. double temperature()const;
  119. QTime time()const;
  120. void setTemperature(double temperature);
  121. void setTime(QTime time);
  122. void setUnit(Units::Unit scale);
  123. Units::Unit scale()const;
  124. Measurement toFahrenheit();
  125. Measurement toCelsius();
  126. Measurement toKelvin();
  127. Measurement toRankine();
  128. };
  129. /*:277*//*281:*/
  130. #line 128 "./measurement.w"
  131. Q_DECLARE_METATYPE(Measurement)
  132. /*:281*//*288:*/
  133. #line 6417 "./typica.w"
  134. class Channel;
  135. class DAQImplementation;
  136. class DAQ:public QObject
  137. {
  138. Q_OBJECT
  139. Q_ENUMS(ThermocoupleType)
  140. DAQImplementation*imp;
  141. private slots:
  142. void threadFinished();
  143. public:
  144. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  145. ~DAQ();
  146. Channel*newChannel(int units,int thermocouple);
  147. Q_INVOKABLE void setClockRate(double Hz);
  148. Q_INVOKABLE void start();
  149. Q_INVOKABLE void stop();
  150. enum ThermocoupleType
  151. {
  152. TypeJ= 10072,
  153. TypeK= 10073,
  154. TypeN= 10077,
  155. TypeR= 10082,
  156. TypeS= 10085,
  157. TypeT= 10086,
  158. TypeB= 10047,
  159. TypeE= 10055
  160. };
  161. };
  162. /*:288*//*289:*/
  163. #line 6455 "./typica.w"
  164. class DAQImplementation:public QThread
  165. {
  166. Q_OBJECT
  167. public:
  168. DAQImplementation(const QString&driverinfo);
  169. ~DAQImplementation();
  170. void run();
  171. void measure();
  172. /*290:*/
  173. #line 6475 "./typica.w"
  174. typedef int(*daqfp)(...);
  175. daqfp read;
  176. daqfp errorInfo;
  177. daqfp startTask;
  178. daqfp createTask;
  179. daqfp createChannel;
  180. daqfp setClock;
  181. daqfp stopTask;
  182. daqfp clearTask;
  183. daqfp resetDevice;
  184. daqfp waitForMeasurement;
  185. /*:290*/
  186. #line 6464 "./typica.w"
  187. /*291:*/
  188. #line 6491 "./typica.w"
  189. bool useBase;
  190. QString device;
  191. QVector<Channel*> channelMap;
  192. unsigned int handle;
  193. int error;
  194. int channels;
  195. bool ready;
  196. QLibrary driver;
  197. QVector<Units::Unit> unitMap;
  198. /*:291*/
  199. #line 6465 "./typica.w"
  200. };
  201. /*:289*//*307:*/
  202. #line 6995 "./typica.w"
  203. class FakeDAQImplementation:public QThread
  204. {
  205. Q_OBJECT
  206. public:
  207. FakeDAQImplementation();
  208. ~FakeDAQImplementation();
  209. void run();
  210. void measure();
  211. QVector<Channel*> channelMap;
  212. int channels;
  213. bool ready;
  214. double clockRate;
  215. };
  216. class FakeDAQ:public QObject
  217. {
  218. Q_OBJECT
  219. FakeDAQImplementation*imp;
  220. public:
  221. FakeDAQ(QString device);
  222. ~FakeDAQ();
  223. Channel*newChannel(int units,int thermocouple);
  224. Q_INVOKABLE void setClockRate(double Hz);
  225. Q_INVOKABLE void start();
  226. };
  227. /*:307*//*314:*/
  228. #line 7182 "./typica.w"
  229. class Channel:public QObject
  230. {
  231. Q_OBJECT
  232. public:
  233. Channel();
  234. ~Channel();
  235. public slots:
  236. void input(Measurement measurement);
  237. signals:
  238. void newData(Measurement);
  239. };
  240. /*:314*//*318:*/
  241. #line 7249 "./typica.w"
  242. class LinearCalibrator:public QObject
  243. {
  244. Q_OBJECT
  245. Q_PROPERTY(double measuredLower READ measuredLower
  246. WRITE setMeasuredLower)
  247. Q_PROPERTY(double measuredUpper READ measuredUpper
  248. WRITE setMeasuredUpper)
  249. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  250. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  251. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  252. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  253. public:
  254. LinearCalibrator(QObject*parent= NULL);
  255. double measuredLower();
  256. double measuredUpper();
  257. double mappedLower();
  258. double mappedUpper();
  259. bool isClosedRange();
  260. double sensitivity();
  261. public slots:
  262. void setMeasuredLower(double lower);
  263. void setMeasuredUpper(double upper);
  264. void setMappedLower(double lower);
  265. void setMappedUpper(double upper);
  266. void setClosedRange(bool closed);
  267. void setSensitivity(double sensitivity);
  268. Measurement newMeasurement(Measurement measure);
  269. signals:
  270. void measurement(Measurement measure);
  271. void newData(Measurement measure);
  272. private:
  273. double Lo1;
  274. double Lo2;
  275. double Up1;
  276. double Up2;
  277. double sensitivitySetting;
  278. bool clamp;
  279. };
  280. /*:318*//*325:*/
  281. #line 7445 "./typica.w"
  282. class LinearSplineInterpolator:public QObject
  283. {
  284. Q_OBJECT
  285. public:
  286. LinearSplineInterpolator(QObject*parent= NULL);
  287. Q_INVOKABLE void add_pair(double source,double destination);
  288. public slots:
  289. Measurement newMeasurement(Measurement measure);
  290. signals:
  291. void newData(Measurement measure);
  292. private:
  293. void make_interpolators();
  294. QMap<double,double> *pairs;
  295. QList<LinearCalibrator*> *interpolators;
  296. };
  297. /*:325*//*330:*/
  298. #line 7581 "./typica.w"
  299. class TemperatureDisplay:public QLCDNumber
  300. {
  301. Q_OBJECT
  302. int unit;
  303. bool r;
  304. public:
  305. TemperatureDisplay(QWidget*parent= NULL);
  306. ~TemperatureDisplay();
  307. public slots:
  308. void setValue(Measurement temperature);
  309. void invalidate();
  310. void setDisplayUnits(Units::Unit scale);
  311. void setRelativeMode(bool relative);
  312. };
  313. /*:330*//*341:*/
  314. #line 7797 "./typica.w"
  315. class MeasurementTimeOffset:public QObject
  316. {
  317. Q_OBJECT
  318. QTime epoch;
  319. QTime previous;
  320. bool hasPrevious;
  321. public:
  322. MeasurementTimeOffset(QTime zero);
  323. QTime zeroTime();
  324. public slots:
  325. void newMeasurement(Measurement measure);
  326. void setZeroTime(QTime zero);
  327. signals:
  328. void measurement(Measurement measure);
  329. };
  330. /*:341*//*348:*/
  331. #line 7949 "./typica.w"
  332. class ThresholdDetector:public QObject
  333. {
  334. Q_OBJECT
  335. Q_ENUMS(EdgeDirection)
  336. public:
  337. enum EdgeDirection{
  338. Ascending,Descending
  339. };
  340. ThresholdDetector(double value);
  341. public slots:
  342. void newMeasurement(Measurement measure);
  343. void setThreshold(double value);
  344. void setEdgeDirection(EdgeDirection direction);
  345. signals:
  346. void timeForValue(double);
  347. private:
  348. double previousValue;
  349. double threshold;
  350. EdgeDirection currentDirection;
  351. };
  352. /*:348*//*353:*/
  353. #line 8055 "./typica.w"
  354. class ZeroEmitter:public QObject
  355. {
  356. Q_OBJECT
  357. Q_PROPERTY(int column READ column WRITE setColumn)
  358. Measurement cache;
  359. int col;
  360. public:
  361. ZeroEmitter(int tempcolumn= 1);
  362. int column();
  363. double lastTemperature();
  364. public slots:
  365. void newMeasurement(Measurement measure);
  366. void setColumn(int column);
  367. void emitZero();
  368. signals:
  369. void measurement(Measurement measure,int tempcolumn);
  370. };
  371. /*:353*//*358:*/
  372. #line 8149 "./typica.w"
  373. class MeasurementAdapter:public QObject
  374. {
  375. Q_OBJECT
  376. int col;
  377. public:
  378. MeasurementAdapter(int tempcolumn);
  379. int column();
  380. public slots:
  381. void newMeasurement(Measurement measure);
  382. void setColumn(int column);
  383. signals:
  384. void measurement(Measurement measure,int tempcolumn);
  385. };
  386. /*:358*//*363:*/
  387. #line 8238 "./typica.w"
  388. class GraphView:public QGraphicsView
  389. {
  390. Q_OBJECT
  391. QGraphicsScene*theScene;
  392. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  393. QMap<int,QPointF> *prevPoints;
  394. QMap<int,double> *translations;
  395. QList<QGraphicsItem*> *gridLinesF;
  396. QList<QGraphicsItem*> *gridLinesC;
  397. QList<QGraphicsItem*> *relativeGridLines;
  398. bool relativeEnabled;
  399. bool timeIndicatorEnabled;
  400. QGraphicsLineItem*timeLine;
  401. LinearSplineInterpolator*relativeAdjuster;
  402. public:
  403. GraphView(QWidget*parent= NULL);
  404. void removeSeries(int column);
  405. protected:
  406. void resizeEvent(QResizeEvent*event);
  407. public slots:
  408. void newMeasurement(Measurement measure,int tempcolumn);
  409. void setSeriesTranslation(int column,double offset);
  410. void setTimeIndicatorEnabled(bool enabled);
  411. void clear();
  412. void showF();
  413. void showC();
  414. };
  415. /*:363*//*380:*/
  416. #line 8703 "./typica.w"
  417. class MeasurementModel;
  418. class ZoomLog:public QTableView
  419. {
  420. Q_OBJECT
  421. /*381:*/
  422. #line 8752 "./typica.w"
  423. MeasurementModel*model_ms;
  424. MeasurementModel*model_1s;
  425. MeasurementModel*model_5s;
  426. MeasurementModel*model_10s;
  427. MeasurementModel*model_15s;
  428. MeasurementModel*model_30s;
  429. MeasurementModel*model_1m;
  430. QList<MeasurementModel*> modelSet;
  431. QHash<int,Measurement> lastMeasurement;
  432. MeasurementModel*currentModel;
  433. QList<int> saveTempCols;
  434. QList<int> saveControlCols;
  435. QList<int> saveNoteCols;
  436. QList<int> currentColumnSet;
  437. /*:381*/
  438. #line 8708 "./typica.w"
  439. void switchLOD(MeasurementModel*m);
  440. private slots:
  441. void centerOn(int row);
  442. void persistColumnResize(int column,int oldsize,int newsize);
  443. void restoreColumnWidths();
  444. public:
  445. ZoomLog();
  446. QVariant data(int row,int column)const;
  447. int rowCount();
  448. bool saveXML(QIODevice*device);
  449. bool saveCSV(QIODevice*device);
  450. QString lastTime(int series);
  451. Q_INVOKABLE Units::Unit displayUnits();
  452. public slots:
  453. void setVisible(bool visibility);
  454. void setHeaderData(int section,QString text);
  455. void LOD_ms();
  456. void LOD_1s();
  457. void LOD_5s();
  458. void LOD_10s();
  459. void LOD_15s();
  460. void LOD_30s();
  461. void LOD_1m();
  462. void newMeasurement(Measurement measure,int tempcolumn);
  463. void newAnnotation(QString annotation,int tempcolumn,
  464. int annotationcolumn);
  465. void clear();
  466. void addOutputTemperatureColumn(int column);
  467. void addOutputControlColumn(int column);
  468. void addOutputAnnotationColumn(int column);
  469. void clearOutputColumns();
  470. void setDisplayUnits(Units::Unit scale);
  471. void addToCurrentColumnSet(int column);
  472. void clearCurrentColumnSet();
  473. protected:
  474. virtual void showEvent(QShowEvent*event);
  475. };
  476. /*:380*//*406:*/
  477. #line 9448 "./typica.w"
  478. class MeasurementList;
  479. class MeasurementModel:public QAbstractItemModel
  480. {
  481. Q_OBJECT
  482. Units::Unit unit;
  483. QList<MeasurementList*> *entries;
  484. QStringList*hData;
  485. int colcount;
  486. QHash<int,int> *lastTemperature;
  487. QList<MeasurementList*> ::iterator lastInsertion;
  488. QHash<int,bool> *controlColumns;
  489. public:
  490. MeasurementModel(QObject*parent= NULL);
  491. ~MeasurementModel();
  492. int rowCount(const QModelIndex&parent= QModelIndex())const;
  493. int columnCount(const QModelIndex&parent= QModelIndex())const;
  494. bool setHeaderData(int section,Qt::Orientation orientation,
  495. const QVariant&value,int role= Qt::DisplayRole);
  496. QVariant data(const QModelIndex&index,int role)const;
  497. bool setData(const QModelIndex&index,const QVariant&value,
  498. int role= Qt::EditRole);
  499. Qt::ItemFlags flags(const QModelIndex&index)const;
  500. QVariant headerData(int section,Qt::Orientation orientation,
  501. int role= Qt::DisplayRole)const;
  502. QModelIndex index(int row,int column,
  503. const QModelIndex&parent= QModelIndex())const;
  504. QModelIndex parent(const QModelIndex&index)const;
  505. Units::Unit displayUnits();
  506. public slots:
  507. void newMeasurement(Measurement measure,int tempcolumn);
  508. void newAnnotation(QString annotation,int tempcolumn,
  509. int annotationColumn);
  510. void clear();
  511. void setDisplayUnits(Units::Unit scale);
  512. signals:
  513. void rowChanged(int);
  514. };
  515. /*:406*//*407:*/
  516. #line 9492 "./typica.w"
  517. class MeasurementList:public QVariantList
  518. {
  519. public:
  520. bool operator<(const MeasurementList&other)const;
  521. bool operator==(const MeasurementList&other)const;
  522. };
  523. /*:407*//*433:*/
  524. #line 10150 "./typica.w"
  525. class AnnotationButton:public QPushButton
  526. {
  527. Q_OBJECT
  528. QString note;
  529. int tc;
  530. int ac;
  531. int count;
  532. public:
  533. AnnotationButton(const QString&text,QWidget*parent= NULL);
  534. public slots:
  535. void setAnnotation(const QString&annotation);
  536. void setTemperatureColumn(int tempcolumn);
  537. void setAnnotationColumn(int annotationcolumn);
  538. void annotate();
  539. void resetCount();
  540. signals:
  541. void annotation(QString annotation,int tempcolumn,
  542. int notecolumn);
  543. };
  544. /*:433*//*441:*/
  545. #line 10275 "./typica.w"
  546. class AnnotationSpinBox:public QDoubleSpinBox
  547. {
  548. Q_OBJECT
  549. QString pretext;
  550. QString posttext;
  551. int tc;
  552. int ac;
  553. bool change;
  554. public:
  555. AnnotationSpinBox(const QString&pret,const QString&postt,
  556. QWidget*parent= NULL);
  557. public slots:
  558. void setPretext(const QString&pret);
  559. void setPosttext(const QString&postt);
  560. void setTemperatureColumn(int tempcolumn);
  561. void setAnnotationColumn(int annotationcolumn);
  562. void annotate();
  563. void resetChange();
  564. signals:
  565. void annotation(QString annotation,int tempcolumn,
  566. int notecolumn);
  567. };
  568. /*:441*//*449:*/
  569. #line 10434 "./typica.w"
  570. class TimerDisplay:public QLCDNumber
  571. {
  572. Q_OBJECT
  573. /*450:*/
  574. #line 10484 "./typica.w"
  575. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  576. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  577. Q_PROPERTY(bool running READ isRunning)
  578. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  579. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  580. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  581. /*:450*/
  582. #line 10438 "./typica.w"
  583. private slots:
  584. void updateTime();
  585. void setCountUpMode();
  586. void setCountDownMode();
  587. void setClockMode();
  588. public:
  589. TimerDisplay(QWidget*parent= NULL);
  590. ~TimerDisplay();
  591. enum TimerMode
  592. {
  593. CountUp,
  594. CountDown,
  595. Clock
  596. };
  597. QString value();
  598. QTime seconds();
  599. TimerMode mode();
  600. bool isRunning();
  601. QTime resetValue();
  602. QString displayFormat();
  603. bool autoReset();
  604. public slots:
  605. void setTimer(QTime value= QTime(0,0,0));
  606. void setMode(TimerMode mode);
  607. void startTimer();
  608. void stopTimer();
  609. void copyTimer();
  610. void setResetValue(QTime value= QTime(0,0,0));
  611. void reset();
  612. void setDisplayFormat(QString format);
  613. void setAutoReset(bool reset);
  614. void updateDisplay();
  615. signals:
  616. void valueChanged(QTime);
  617. void runStateChanged(bool);
  618. private:
  619. /*451:*/
  620. #line 10494 "./typica.w"
  621. QTime s;
  622. QTime r;
  623. QTimer clock;
  624. TimerDisplay::TimerMode m;
  625. bool running;
  626. bool ar;
  627. QAction*startAction;
  628. QAction*stopAction;
  629. QAction*resetAction;
  630. QString f;
  631. QTime relative;
  632. QTime base;
  633. /*:451*/
  634. #line 10475 "./typica.w"
  635. };
  636. /*:449*//*471:*/
  637. #line 10853 "./typica.w"
  638. class PackLayout:public QLayout
  639. {
  640. int doLayout(const QRect&rect,bool testOnly)const;
  641. QList<QLayoutItem*> itemList;
  642. Qt::Orientations orientation;
  643. public:
  644. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  645. PackLayout(int spacing= -1);
  646. ~PackLayout();
  647. void addItem(QLayoutItem*item);
  648. Qt::Orientations expandingDirections()const;
  649. bool hasHeightForWidth()const;
  650. int heightForWidth(int width)const;
  651. int count()const;
  652. QLayoutItem*itemAt(int index)const;
  653. QSize minimumSize()const;
  654. void setGeometry(const QRect&rect);
  655. void setOrientation(Qt::Orientations direction);
  656. QSize sizeHint()const;
  657. QLayoutItem*takeAt(int index);
  658. };
  659. /*:471*//*484:*/
  660. #line 11131 "./typica.w"
  661. class SceneButton:public QGraphicsScene
  662. {
  663. Q_OBJECT
  664. public:
  665. SceneButton();
  666. ~SceneButton();
  667. protected:
  668. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  669. signals:
  670. void clicked(QPoint pos);
  671. };
  672. /*:484*//*486:*/
  673. #line 11173 "./typica.w"
  674. class WidgetDecorator:public QWidget
  675. {
  676. Q_OBJECT
  677. PackLayout*layout;
  678. QGraphicsView*label;
  679. QGraphicsTextItem*text;
  680. SceneButton*scene;
  681. public:
  682. WidgetDecorator(QWidget*widget,const QString&labeltext,
  683. Qt::Orientations orientation= Qt::Horizontal,
  684. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  685. ~WidgetDecorator();
  686. void setBackgroundBrush(QBrush background);
  687. void setTextColor(QColor color);
  688. };
  689. /*:486*//*497:*/
  690. #line 11348 "./typica.w"
  691. class LogEditWindow:public QMainWindow
  692. {
  693. Q_OBJECT
  694. QWidget*centralWidget;
  695. PackLayout*mainLayout;
  696. QHBoxLayout*addRowsLayout;
  697. QLabel*startTimeLabel;
  698. QTimeEdit*startTime;
  699. QLabel*endTimeLabel;
  700. QTimeEdit*endTime;
  701. QLabel*intervalLabel;
  702. QSpinBox*interval;
  703. QPushButton*addRows;
  704. QAction*saveXml;
  705. QAction*saveCsv;
  706. QAction*openXml;
  707. MeasurementModel*model;
  708. QTableView*log;
  709. private slots:
  710. void addTheRows();
  711. void saveXML();
  712. void saveCSV();
  713. void openXML();
  714. protected:
  715. void closeEvent(QCloseEvent*event);
  716. public:
  717. LogEditWindow();
  718. };
  719. /*:497*//*511:*/
  720. #line 11656 "./typica.w"
  721. class XMLOutput:public QObject
  722. {
  723. Q_OBJECT
  724. MeasurementModel*data;
  725. QIODevice*out;
  726. int time;
  727. QMap<int,QString> temperatureColumns;
  728. QMap<int,QString> controlColumns;
  729. QMap<int,QString> annotationColumns;
  730. public:
  731. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  732. void addTemperatureColumn(const QString&series,int column);
  733. void addControlColumn(const QString&series,int column);
  734. void addAnnotationColumn(const QString&series,int column);
  735. void setModel(MeasurementModel*model);
  736. void setTimeColumn(int column);
  737. void setDevice(QIODevice*device);
  738. bool output();
  739. };
  740. /*:511*//*518:*/
  741. #line 11892 "./typica.w"
  742. class XMLInput:public QObject
  743. {
  744. Q_OBJECT
  745. int firstc;
  746. QIODevice*in;
  747. public:
  748. XMLInput(QIODevice*input,int c);
  749. void setFirstColumn(int column);
  750. void setDevice(QIODevice*device);
  751. bool input();
  752. signals:
  753. void measure(Measurement,int);
  754. void annotation(QString,int,int);
  755. void newTemperatureColumn(int,QString);
  756. void newAnnotationColumn(int,QString);
  757. void lastColumn(int);
  758. };
  759. /*:518*//*529:*/
  760. #line 12147 "./typica.w"
  761. class CSVOutput
  762. {
  763. MeasurementModel*data;
  764. QIODevice*out;
  765. int time;
  766. QMap<int,QString> temperatureColumns;
  767. QMap<int,QString> controlColumns;
  768. QMap<int,QString> annotationColumns;
  769. public:
  770. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  771. void addTemperatureColumn(const QString&series,int column);
  772. void addControlColumn(const QString&series,int column);
  773. void addAnnotationColumn(const QString&series,int column);
  774. void setModel(MeasurementModel*model);
  775. void setTimeColumn(int column);
  776. void setDevice(QIODevice*device);
  777. bool output();
  778. };
  779. /*:529*//*559:*/
  780. #line 12290 "./typica.w"
  781. #define AppInstance (qobject_cast<Application *> (qApp))
  782. class NodeInserter;
  783. class DeviceTreeModel;
  784. class Application:public QApplication
  785. {
  786. Q_OBJECT
  787. public:
  788. Application(int&argc,char**argv);
  789. QDomDocument*configuration();
  790. /*701:*/
  791. #line 14844 "./typica.w"
  792. QDomDocument deviceConfiguration();
  793. /*:701*//*734:*/
  794. #line 15517 "./typica.w"
  795. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  796. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  797. const QModelIndex&index);
  798. /*:734*//*739:*/
  799. #line 15621 "./typica.w"
  800. QList<NodeInserter*> topLevelNodeInserters;
  801. /*:739*/
  802. #line 12301 "./typica.w"
  803. QSqlDatabase database();
  804. QScriptEngine*engine;
  805. public slots:
  806. /*702:*/
  807. #line 14851 "./typica.w"
  808. void saveDeviceConfiguration();
  809. /*:702*/
  810. #line 12305 "./typica.w"
  811. private:
  812. /*700:*/
  813. #line 14835 "./typica.w"
  814. QDomDocument deviceConfigurationDocument;
  815. /*:700*//*733:*/
  816. #line 15511 "./typica.w"
  817. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  818. /*:733*/
  819. #line 12307 "./typica.w"
  820. QDomDocument conf;
  821. };
  822. /*:559*//*567:*/
  823. #line 12432 "./typica.w"
  824. class SaltModel:public QAbstractItemModel
  825. {
  826. Q_OBJECT
  827. QList<QList<QMap<int,QVariant> > > modelData;
  828. QStringList hData;
  829. int colcount;
  830. public:
  831. SaltModel(int columns);
  832. ~SaltModel();
  833. int rowCount(const QModelIndex&parent= QModelIndex())const;
  834. int columnCount(const QModelIndex&parent= QModelIndex())const;
  835. bool setHeaderData(int section,Qt::Orientation orientation,
  836. const QVariant&value,int role= Qt::DisplayRole);
  837. QVariant data(const QModelIndex&index,int role)const;
  838. bool setData(const QModelIndex&index,const QVariant&value,
  839. int role= Qt::EditRole);
  840. Qt::ItemFlags flags(const QModelIndex&index)const;
  841. QVariant headerData(int section,Qt::Orientation orientation,
  842. int role= Qt::DisplayRole)const;
  843. QModelIndex index(int row,int column,
  844. const QModelIndex&parent= QModelIndex())const;
  845. QModelIndex parent(const QModelIndex&index)const;
  846. QString arrayLiteral(int column,int role)const;
  847. QString quotedArrayLiteral(int column,int role)const;
  848. void clear();
  849. bool removeRows(int row,int count,
  850. const QModelIndex&parent= QModelIndex());
  851. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  852. };
  853. /*:567*//*583:*/
  854. #line 12817 "./typica.w"
  855. class SqlComboBox:public QComboBox
  856. {
  857. Q_OBJECT
  858. int dataColumn;
  859. int displayColumn;
  860. bool dataColumnShown;
  861. QString specialNullText;
  862. QVariant specialNullData;
  863. public:
  864. SqlComboBox();
  865. ~SqlComboBox();
  866. SqlComboBox*clone(QWidget*parent);
  867. public slots:
  868. void addNullOption();
  869. void addSqlOptions(QString query);
  870. void setDataColumn(int column);
  871. void setDisplayColumn(int column);
  872. void showData(bool show);
  873. void setNullText(QString nullText);
  874. void setNullData(QVariant nullData);
  875. };
  876. /*:583*//*590:*/
  877. #line 12964 "./typica.w"
  878. class SqlComboBoxDelegate:public QItemDelegate
  879. {
  880. Q_OBJECT
  881. SqlComboBox*delegate;
  882. public:
  883. SqlComboBoxDelegate(QObject*parent= NULL);
  884. QWidget*createEditor(QWidget*parent,
  885. const QStyleOptionViewItem&option,
  886. const QModelIndex&index)const;
  887. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  888. void setModelData(QWidget*editor,QAbstractItemModel*model,
  889. const QModelIndex&index)const;
  890. void setWidget(SqlComboBox*widget);
  891. virtual QSize sizeHint()const;
  892. void updateEditorGeometry(QWidget*editor,
  893. const QStyleOptionViewItem&option,
  894. const QModelIndex&index)const;
  895. };
  896. /*:590*//*605:*/
  897. #line 13175 "./typica.w"
  898. class SqlConnectionSetup:public QDialog
  899. {
  900. Q_OBJECT
  901. public:
  902. SqlConnectionSetup();
  903. ~SqlConnectionSetup();
  904. public slots:
  905. void testConnection();
  906. private:
  907. QFormLayout*formLayout;
  908. QComboBox*driver;
  909. QLineEdit*hostname;
  910. QLineEdit*dbname;
  911. QLineEdit*user;
  912. QLineEdit*password;
  913. QVBoxLayout*layout;
  914. QHBoxLayout*buttons;
  915. QPushButton*cancelButton;
  916. QPushButton*connectButton;
  917. };
  918. /*:605*//*610:*/
  919. #line 13310 "./typica.w"
  920. class SqlQueryView:public QTableView
  921. {
  922. Q_OBJECT
  923. public:
  924. SqlQueryView(QWidget*parent= NULL);
  925. void setQuery(const QString&query);
  926. bool setHeaderData(int section,Qt::Orientation orientation,
  927. const QVariant&value,int role);
  928. Q_INVOKABLE QVariant data(int row,int column,
  929. int role= Qt::DisplayRole);
  930. signals:
  931. void openEntry(QString key);
  932. void openEntryRow(int row);
  933. protected:
  934. virtual void showEvent(QShowEvent*event);
  935. private slots:
  936. void openRow(const QModelIndex&index);
  937. void persistColumnResize(int column,int oldsize,int newsize);
  938. };
  939. /*:610*//*625:*/
  940. #line 13565 "./typica.w"
  941. class ReportAction:public QAction
  942. {
  943. Q_OBJECT
  944. public:
  945. ReportAction(const QString&fileName,const QString&reportName,
  946. QObject*parent= NULL);
  947. private slots:
  948. void createReport();
  949. private:
  950. QString reportFile;
  951. };
  952. /*:625*//*637:*/
  953. #line 13774 "./typica.w"
  954. class ReportTable:public QObject
  955. {
  956. Q_OBJECT
  957. QTextFrame*area;
  958. QDomElement configuration;
  959. QMap<QString,QVariant> bindings;
  960. public:
  961. ReportTable(QTextFrame*frame,QDomElement description);
  962. ~ReportTable();
  963. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  964. public slots:
  965. void refresh();
  966. };
  967. /*:637*//*670:*/
  968. #line 14013 "./typica.w"
  969. class FormArray:public QScrollArea
  970. {
  971. Q_OBJECT
  972. QDomElement configuration;
  973. QWidget itemContainer;
  974. QVBoxLayout itemLayout;
  975. int maxwidth;
  976. int maxheight;
  977. public:
  978. FormArray(QDomElement description);
  979. Q_INVOKABLE QWidget*elementAt(int index);
  980. Q_INVOKABLE int elements();
  981. public slots:
  982. void addElements(int copies= 1);
  983. void removeAllElements();
  984. void setMaximumElementWidth(int width);
  985. void setMaximumElementHeight(int height);
  986. };
  987. /*:670*//*680:*/
  988. #line 14229 "./typica.w"
  989. class ScaleControl:public QGraphicsView
  990. {
  991. Q_OBJECT
  992. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  993. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  994. /*681:*/
  995. #line 14255 "./typica.w"
  996. QGraphicsScene scene;
  997. QGraphicsPolygonItem initialDecrement;
  998. QGraphicsPolygonItem initialIncrement;
  999. QGraphicsPolygonItem finalDecrement;
  1000. QGraphicsPolygonItem finalIncrement;
  1001. QGraphicsPolygonItem initialIndicator;
  1002. QGraphicsPolygonItem finalIndicator;
  1003. QGraphicsPathItem scaleLine;
  1004. QPolygonF left;
  1005. QPolygonF right;
  1006. QPolygonF down;
  1007. QPolygonF up;
  1008. QPainterPath scalePath;
  1009. QBrush initialBrush;
  1010. QBrush finalBrush;
  1011. double nonScoredValue;
  1012. double scoredValue;
  1013. bool initialSet;
  1014. bool finalSet;
  1015. bool scaleDown;
  1016. /*:681*/
  1017. #line 14235 "./typica.w"
  1018. public:
  1019. ScaleControl();
  1020. double initialValue(void);
  1021. double finalValue(void);
  1022. virtual QSize sizeHint()const;
  1023. public slots:
  1024. void setInitialValue(double value);
  1025. void setFinalValue(double value);
  1026. signals:
  1027. void initialChanged(double);
  1028. void finalChanged(double);
  1029. protected:
  1030. virtual void mousePressEvent(QMouseEvent*event);
  1031. virtual void mouseReleaseEvent(QMouseEvent*event);
  1032. };
  1033. /*:680*//*692:*/
  1034. #line 14552 "./typica.w"
  1035. class IntensityControl:public QGraphicsView
  1036. {
  1037. Q_OBJECT
  1038. Q_PROPERTY(double value READ value WRITE setValue)
  1039. QGraphicsScene scene;
  1040. QGraphicsPolygonItem decrement;
  1041. QGraphicsPolygonItem increment;
  1042. QGraphicsPolygonItem indicator;
  1043. QGraphicsPathItem scaleLine;
  1044. QPolygonF left;
  1045. QPolygonF up;
  1046. QPolygonF down;
  1047. QPainterPath scalePath;
  1048. QBrush theBrush;
  1049. double theValue;
  1050. bool valueSet;
  1051. bool scaleDown;
  1052. public:
  1053. IntensityControl();
  1054. double value();
  1055. virtual QSize sizeHint()const;
  1056. public slots:
  1057. void setValue(double val);
  1058. signals:
  1059. void valueChanged(double);
  1060. protected:
  1061. virtual void mousePressEvent(QMouseEvent*event);
  1062. virtual void mouseReleaseEvent(QMouseEvent*event);
  1063. };
  1064. /*:692*//*708:*/
  1065. #line 14940 "./typica.w"
  1066. class DeviceTreeModelNode
  1067. {
  1068. public:
  1069. DeviceTreeModelNode(QDomNode&node,int row,
  1070. DeviceTreeModelNode*parent= NULL);
  1071. ~DeviceTreeModelNode();
  1072. DeviceTreeModelNode*child(int index);
  1073. DeviceTreeModelNode*parent();
  1074. QDomNode node()const;
  1075. int row();
  1076. private:
  1077. QDomNode domNode;
  1078. QHash<int,DeviceTreeModelNode*> children;
  1079. int rowNumber;
  1080. DeviceTreeModelNode*parentItem;
  1081. };
  1082. /*:708*//*710:*/
  1083. #line 15015 "./typica.w"
  1084. class DeviceTreeModel:public QAbstractItemModel
  1085. {
  1086. Q_OBJECT
  1087. public:
  1088. DeviceTreeModel(QObject*parent= NULL);
  1089. ~DeviceTreeModel();
  1090. QVariant data(const QModelIndex&index,int role)const;
  1091. Qt::ItemFlags flags(const QModelIndex&index)const;
  1092. QVariant headerData(int section,Qt::Orientation orientation,
  1093. int role= Qt::DisplayRole)const;
  1094. QModelIndex index(int row,int column,
  1095. const QModelIndex&parent= QModelIndex())const;
  1096. QModelIndex parent(const QModelIndex&child)const;
  1097. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1098. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1099. bool setData(const QModelIndex&index,const QVariant&value,
  1100. int role);
  1101. bool removeRows(int row,int count,const QModelIndex&parent);
  1102. QDomElement referenceElement(const QString&id);
  1103. public slots:
  1104. void newNode(const QString&name,const QString&driver,
  1105. const QModelIndex&parent);
  1106. private:
  1107. QDomDocument document;
  1108. DeviceTreeModelNode*root;
  1109. QDomNode referenceSection;
  1110. QDomNode treeRoot;
  1111. };
  1112. /*:710*//*729:*/
  1113. #line 15469 "./typica.w"
  1114. Q_DECLARE_METATYPE(QModelIndex)
  1115. /*:729*//*737:*/
  1116. #line 15576 "./typica.w"
  1117. class NodeInserter:public QAction
  1118. {
  1119. Q_OBJECT
  1120. public:
  1121. NodeInserter(const QString&title,const QString&name,
  1122. const QString&driver,QObject*parent= NULL);
  1123. signals:
  1124. void triggered(QString name,QString driver);
  1125. private slots:
  1126. void onTriggered();
  1127. private:
  1128. QString defaultNodeName;
  1129. QString driverString;
  1130. };
  1131. /*:737*//*740:*/
  1132. #line 15631 "./typica.w"
  1133. class DeviceConfigurationWindow:public QWidget
  1134. {
  1135. Q_OBJECT
  1136. public:
  1137. DeviceConfigurationWindow();
  1138. public slots:
  1139. void addDevice();
  1140. void removeNode();
  1141. void newSelection(const QModelIndex&index);
  1142. private slots:
  1143. void resizeColumn();
  1144. private:
  1145. QDomDocument document;
  1146. DeviceTreeModel*model;
  1147. QTreeView*view;
  1148. QScrollArea*configArea;
  1149. };
  1150. /*:740*//*749:*/
  1151. #line 15801 "./typica.w"
  1152. class BasicDeviceConfigurationWidget:public QWidget
  1153. {
  1154. Q_OBJECT
  1155. public:
  1156. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1157. const QModelIndex&index);
  1158. public slots:
  1159. void insertChildNode(const QString&name,const QString&driver);
  1160. void updateAttribute(const QString&name,const QString&value);
  1161. protected:
  1162. DeviceTreeModel*deviceModel;
  1163. QModelIndex currentNode;
  1164. };
  1165. /*:749*//*753:*/
  1166. #line 15886 "./typica.w"
  1167. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1168. {
  1169. Q_OBJECT
  1170. public:
  1171. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1172. const QModelIndex&index);
  1173. private slots:
  1174. void updateRoasterId(int id);
  1175. };
  1176. /*:753*//*758:*/
  1177. #line 16021 "./typica.w"
  1178. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1179. {
  1180. Q_OBJECT
  1181. public:
  1182. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1183. const QModelIndex&index);
  1184. };
  1185. /*:758*//*760:*/
  1186. #line 16067 "./typica.w"
  1187. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1188. {
  1189. Q_OBJECT
  1190. public:
  1191. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1192. const QModelIndex&index);
  1193. private slots:
  1194. void addChannel();
  1195. void updateDeviceId(const QString&newId);
  1196. };
  1197. /*:760*//*764:*/
  1198. #line 16153 "./typica.w"
  1199. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1200. {
  1201. Q_OBJECT
  1202. public:
  1203. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1204. const QModelIndex&index);
  1205. private slots:
  1206. void updateThermocoupleType(const QString&type);
  1207. void updateColumnName(const QString&name);
  1208. void updateHidden(bool hidden);
  1209. };
  1210. /*:764*//*769:*/
  1211. #line 16269 "./typica.w"
  1212. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1213. {
  1214. Q_OBJECT
  1215. public:
  1216. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1217. const QModelIndex&index);
  1218. };
  1219. /*:769*//*771:*/
  1220. #line 16310 "./typica.w"
  1221. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1222. {
  1223. Q_OBJECT
  1224. public:
  1225. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1226. const QModelIndex&index);
  1227. private slots:
  1228. void addChannel();
  1229. void updateDeviceId(const QString&newId);
  1230. };
  1231. /*:771*//*773:*/
  1232. #line 16379 "./typica.w"
  1233. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1234. {
  1235. Q_OBJECT
  1236. public:
  1237. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1238. const QModelIndex&index);
  1239. private slots:
  1240. void updateDeviceId(const QString&newId);
  1241. void updateThermocoupleType(const QString&type);
  1242. void updateColumnName(const QString&name);
  1243. void updateHidden(bool hidden);
  1244. };
  1245. /*:773*//*778:*/
  1246. #line 16510 "./typica.w"
  1247. class PortSelector:public QComboBox
  1248. {
  1249. Q_OBJECT
  1250. public:
  1251. PortSelector(QWidget*parent= NULL);
  1252. private slots:
  1253. void addDevice(QextPortInfo port);
  1254. private:
  1255. QextSerialEnumerator*lister;
  1256. };
  1257. /*:778*//*780:*/
  1258. #line 16558 "./typica.w"
  1259. class BaudSelector:public QComboBox
  1260. {
  1261. Q_OBJECT
  1262. Q_ENUMS(BaudRateType)
  1263. public:
  1264. BaudSelector(QWidget*parent= NULL);
  1265. enum BaudRateType
  1266. {
  1267. #if defined(Q_OS_UNIX) || defined(qdoc)
  1268. BAUD50= 50,
  1269. BAUD75= 75,
  1270. BAUD134= 134,
  1271. BAUD150= 150,
  1272. BAUD200= 200,
  1273. BAUD1800= 1800,
  1274. #if defined(B76800) || defined(qdoc)
  1275. BAUD76800= 76800,
  1276. #endif
  1277. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1278. BAUD230400= 230400,
  1279. BAUD460800= 460800,
  1280. BAUD500000= 500000,
  1281. BAUD576000= 576000,
  1282. BAUD921600= 921600,
  1283. BAUD1000000= 1000000,
  1284. BAUD1152000= 1152000,
  1285. BAUD1500000= 1500000,
  1286. BAUD2000000= 2000000,
  1287. BAUD2500000= 2500000,
  1288. BAUD3000000= 3000000,
  1289. BAUD3500000= 3500000,
  1290. BAUD4000000= 4000000,
  1291. #endif
  1292. #endif
  1293. #if defined(Q_OS_WIN) || defined(qdoc)
  1294. BAUD14400= 14400,
  1295. BAUD56000= 56000,
  1296. BAUD128000= 128000,
  1297. BAUD256000= 256000,
  1298. #endif
  1299. BAUD110= 110,
  1300. BAUD300= 300,
  1301. BAUD600= 600,
  1302. BAUD1200= 1200,
  1303. BAUD2400= 2400,
  1304. BAUD4800= 4800,
  1305. BAUD9600= 9600,
  1306. BAUD19200= 19200,
  1307. BAUD38400= 38400,
  1308. BAUD57600= 57600,
  1309. BAUD115200= 115200
  1310. };
  1311. };
  1312. /*:780*//*782:*/
  1313. #line 16629 "./typica.w"
  1314. class ParitySelector:public QComboBox
  1315. {
  1316. Q_OBJECT
  1317. Q_ENUMS(ParityType)
  1318. public:
  1319. ParitySelector(QWidget*parent= NULL);
  1320. enum ParityType
  1321. {
  1322. PAR_NONE,
  1323. PAR_ODD,
  1324. PAR_EVEN,
  1325. #if defined(Q_OS_WIN) || defined(qdoc)
  1326. PAR_MARK,
  1327. #endif
  1328. PAR_SPACE
  1329. };
  1330. };
  1331. /*:782*//*784:*/
  1332. #line 16667 "./typica.w"
  1333. class FlowSelector:public QComboBox
  1334. {
  1335. Q_OBJECT
  1336. Q_ENUMS(FlowType)
  1337. public:
  1338. FlowSelector(QWidget*parent= NULL);
  1339. enum FlowType
  1340. {
  1341. FLOW_OFF,
  1342. FLOW_HARDWARE,
  1343. FLOW_XONXOFF
  1344. };
  1345. };
  1346. /*:784*//*786:*/
  1347. #line 16700 "./typica.w"
  1348. class StopSelector:public QComboBox
  1349. {
  1350. Q_OBJECT
  1351. Q_ENUMS(StopBitsType)
  1352. public:
  1353. StopSelector(QWidget*parent= NULL);
  1354. enum StopBitsType
  1355. {
  1356. STOP_1,
  1357. #if defined(Q_OS_WIN) || defined(qdoc)
  1358. STOP_1_5,
  1359. #endif
  1360. STOP_2
  1361. };
  1362. };
  1363. /*:786*//*789:*/
  1364. #line 16753 "./typica.w"
  1365. class ShortHexSpinBox:public QSpinBox
  1366. {
  1367. Q_OBJECT
  1368. public:
  1369. ShortHexSpinBox(QWidget*parent= NULL);
  1370. virtual QValidator::State validate(QString&input,int&pos)const;
  1371. protected:
  1372. virtual int valueFromText(const QString&text)const;
  1373. virtual QString textFromValue(int value)const;
  1374. };
  1375. /*:789*//*791:*/
  1376. #line 16815 "./typica.w"
  1377. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1378. {
  1379. Q_OBJECT
  1380. public:
  1381. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1382. const QModelIndex&index);
  1383. private slots:
  1384. void updatePort(const QString&newPort);
  1385. void updateBaudRate(const QString&newRate);
  1386. void updateParity(const QString&newParity);
  1387. void updateFlowControl(const QString&newFlow);
  1388. void updateStopBits(const QString&newStopBits);
  1389. };
  1390. /*:791*//*793:*/
  1391. #line 16966 "./typica.w"
  1392. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1393. {
  1394. Q_OBJECT
  1395. public:
  1396. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1397. const QModelIndex&index);
  1398. private slots:
  1399. void updateStationNumber(int newStation);
  1400. void updateFixedUnit(bool newFixed);
  1401. void updateFixedDecimal(bool newFixed);
  1402. void updateUnit(const QString&newUnit);
  1403. void updateUnitAddress(int newAddress);
  1404. void updateValueF(int newValue);
  1405. void updateValueC(int newValue);
  1406. void updatePrecisionAddress(int newAddress);
  1407. void updatePrecisionValue(int newValue);
  1408. private:
  1409. QStackedLayout*unitSpecificationLayout;
  1410. QStackedLayout*decimalSpecificationLayout;
  1411. };
  1412. /*:793*//*795:*/
  1413. #line 17225 "./typica.w"
  1414. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1415. {
  1416. Q_OBJECT
  1417. public:
  1418. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1419. const QModelIndex&index);
  1420. private slots:
  1421. void updateAddress(int newAddress);
  1422. };
  1423. /*:795*//*797:*/
  1424. #line 17271 "./typica.w"
  1425. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1426. {
  1427. Q_OBJECT
  1428. public:
  1429. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1430. const QModelIndex&index);
  1431. private slots:
  1432. void updateReadAddress(int newAddress);
  1433. void updateWriteAddress(int newAddress);
  1434. void updateFixedRange(bool fixed);
  1435. void updateLower(const QString&lower);
  1436. void updateUpper(const QString&upper);
  1437. void updateLowerAddress(int newAddress);
  1438. void updateUpperAddress(int newAddress);
  1439. private:
  1440. QStackedLayout*boundsLayout;
  1441. };
  1442. /*:797*//*801:*/
  1443. #line 17465 "./typica.w"
  1444. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1445. {
  1446. Q_OBJECT
  1447. public:
  1448. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1449. private slots:
  1450. void updateButtonText(const QString&text);
  1451. void updateAnnotationText(const QString&text);
  1452. };
  1453. /*:801*//*805:*/
  1454. #line 17533 "./typica.w"
  1455. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1456. {
  1457. Q_OBJECT
  1458. public:
  1459. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1460. private slots:
  1461. void updateButtonText(const QString&text);
  1462. void updateAnnotationText(const QString&text);
  1463. };
  1464. /*:805*//*808:*/
  1465. #line 17607 "./typica.w"
  1466. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1467. {
  1468. Q_OBJECT
  1469. public:
  1470. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1471. private slots:
  1472. void updateLabel(const QString&text);
  1473. void updateMinimum(const QString&minimum);
  1474. void updateMaximum(const QString&maximum);
  1475. void updatePrecision(int precision);
  1476. void updatePretext(const QString&text);
  1477. void updatePosttext(const QString&text);
  1478. };
  1479. /*:808*//*811:*/
  1480. #line 12 "./freeannotation.w"
  1481. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1482. {
  1483. Q_OBJECT
  1484. public:
  1485. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1486. private slots:
  1487. void updateLabel(const QString&text);
  1488. };
  1489. /*:811*//*815:*/
  1490. #line 11 "./settings.w"
  1491. class SettingsWindow:public QMainWindow
  1492. {
  1493. Q_OBJECT
  1494. public:
  1495. SettingsWindow();
  1496. };
  1497. /*:815*//*820:*/
  1498. #line 8 "./graphsettings.w"
  1499. class GraphSettingsWidget:public QWidget
  1500. {
  1501. Q_OBJECT
  1502. public:
  1503. GraphSettingsWidget();
  1504. };
  1505. /*:820*//*822:*/
  1506. #line 46 "./graphsettings.w"
  1507. class GraphSettingsRelativeTab:public QWidget
  1508. {
  1509. Q_OBJECT
  1510. public:
  1511. GraphSettingsRelativeTab();
  1512. public slots:
  1513. void updateEnableSetting(bool enable);
  1514. void updateColorSetting(const QString&color);
  1515. void updateAxisSetting(const QString&gridList);
  1516. void updateUnit(int unit);
  1517. void showColorPicker();
  1518. private:
  1519. QLineEdit*colorEdit;
  1520. };
  1521. /*:822*//*826:*/
  1522. #line 7 "./advancedsettings.w"
  1523. class AdvancedSettingsWidget:public QWidget
  1524. {
  1525. Q_OBJECT
  1526. public:
  1527. AdvancedSettingsWidget();
  1528. public slots:
  1529. void enableDiagnosticLogging(bool enabled);
  1530. };
  1531. /*:826*//*830:*/
  1532. #line 17732 "./typica.w"
  1533. class ModbusRTUDevice:public QObject
  1534. {
  1535. Q_OBJECT
  1536. public:
  1537. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1538. ~ModbusRTUDevice();
  1539. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1540. Q_INVOKABLE double SVLower();
  1541. Q_INVOKABLE double SVUpper();
  1542. Q_INVOKABLE int decimals();
  1543. QList<Channel*> channels;
  1544. public slots:
  1545. void outputSV(double sv);
  1546. signals:
  1547. void SVLowerChanged(double);
  1548. void SVUpperChanged(double);
  1549. void SVDecimalChanged(int);
  1550. void queueEmpty();
  1551. private slots:
  1552. void dataAvailable();
  1553. void sendNextMessage();
  1554. void decimalResponse(QByteArray response);
  1555. void unitResponse(QByteArray response);
  1556. void svlResponse(QByteArray response);
  1557. void svuResponse(QByteArray response);
  1558. void requestMeasurement();
  1559. void mResponse(QByteArray response);
  1560. void ignore(QByteArray response);
  1561. void timeout();
  1562. private:
  1563. QextSerialPort*port;
  1564. QByteArray responseBuffer;
  1565. QList<QByteArray> messageQueue;
  1566. QList<QObject*> retObjQueue;
  1567. QList<char*> callbackQueue;
  1568. quint16 calculateCRC(QByteArray data);
  1569. QTimer*messageDelayTimer;
  1570. QTimer*commTimeout;
  1571. int delayTime;
  1572. char station;
  1573. int decimalPosition;
  1574. int valueF;
  1575. int valueC;
  1576. bool unitIsF;
  1577. double outputSVLower;
  1578. double outputSVUpper;
  1579. QByteArray outputSVStub;
  1580. QByteArray pvStub;
  1581. QByteArray svStub;
  1582. QByteArray mStub;
  1583. quint16 pvaddress;
  1584. quint16 svaddress;
  1585. bool svenabled;
  1586. bool readingsv;
  1587. double savedpv;
  1588. bool waiting;
  1589. };
  1590. /*:830*//*846:*/
  1591. #line 18435 "./typica.w"
  1592. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1593. {
  1594. Q_OBJECT
  1595. public:
  1596. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1597. private slots:
  1598. void updatePort(const QString&newPort);
  1599. void updateBaudRate(const QString&newRate);
  1600. void updateParity(const QString&newParity);
  1601. void updateFlowControl(const QString&newFlow);
  1602. void updateStopBits(const QString&newStopBits);
  1603. void updateStation(int station);
  1604. void updateFixedDecimal(bool fixed);
  1605. void updateDecimalAddress(int address);
  1606. void updateDecimalPosition(int position);
  1607. void updateFixedUnit(bool fixed);
  1608. void updateUnitAddress(int address);
  1609. void updateValueForF(int value);
  1610. void updateValueForC(int value);
  1611. void updateUnit(const QString&newUnit);
  1612. void updatePVAddress(int address);
  1613. void updateSVEnabled(bool enabled);
  1614. void updateSVReadAddress(int address);
  1615. void updateDeviceLimit(bool query);
  1616. void updateSVLowerAddress(int address);
  1617. void updateSVUpperAddress(int address);
  1618. void updateSVLower(double value);
  1619. void updateSVUpper(double value);
  1620. void updateSVWritable(bool canWriteSV);
  1621. void updateSVWriteAddress(int address);
  1622. void updatePVColumnName(const QString&name);
  1623. void updateSVColumnName(const QString&name);
  1624. void updatePVHidden(bool hidden);
  1625. void updateSVHidden(bool hidden);
  1626. private:
  1627. PortSelector*port;
  1628. BaudSelector*baud;
  1629. ParitySelector*parity;
  1630. FlowSelector*flow;
  1631. StopSelector*stop;
  1632. QSpinBox*station;
  1633. QCheckBox*decimalQuery;
  1634. ShortHexSpinBox*decimalAddress;
  1635. QSpinBox*decimalPosition;
  1636. QCheckBox*unitQuery;
  1637. ShortHexSpinBox*unitAddress;
  1638. QSpinBox*valueF;
  1639. QSpinBox*valueC;
  1640. QComboBox*fixedUnit;
  1641. ShortHexSpinBox*pVAddress;
  1642. QCheckBox*sVEnabled;
  1643. ShortHexSpinBox*sVReadAddress;
  1644. QCheckBox*deviceLimit;
  1645. ShortHexSpinBox*sVLowerAddr;
  1646. ShortHexSpinBox*sVUpperAddr;
  1647. QDoubleSpinBox*sVLower;
  1648. QDoubleSpinBox*sVUpper;
  1649. QCheckBox*sVWritable;
  1650. ShortHexSpinBox*sVOutputAddr;
  1651. QLineEdit*pVColumnName;
  1652. QLineEdit*sVColumnName;
  1653. };
  1654. /*:846*//*850:*/
  1655. #line 36 "./unsupportedserial.w"
  1656. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1657. {
  1658. Q_OBJECT
  1659. public:
  1660. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1661. const QModelIndex&index);
  1662. private slots:
  1663. void updateConfiguration();
  1664. void saveScript();
  1665. void addChannel();
  1666. private:
  1667. SaltModel*deviceSettingsModel;
  1668. QTextEdit*scriptEditor;
  1669. };
  1670. /*:850*//*855:*/
  1671. #line 166 "./unsupportedserial.w"
  1672. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1673. {
  1674. Q_OBJECT
  1675. public:
  1676. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1677. const QModelIndex&index);
  1678. private slots:
  1679. void updateColumnName(const QString&value);
  1680. void updateHidden(bool hidden);
  1681. void updateConfiguration();
  1682. private:
  1683. SaltModel*channelSettingsModel;
  1684. };
  1685. /*:855*//*860:*/
  1686. #line 298 "./unsupportedserial.w"
  1687. class JavaScriptDevice:public QObject
  1688. {
  1689. Q_OBJECT
  1690. public:
  1691. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1692. QScriptEngine*engine);
  1693. Q_INVOKABLE int channelCount();
  1694. Channel*getChannel(int channel);
  1695. Q_INVOKABLE bool isChannelHidden(int channel);
  1696. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1697. Q_INVOKABLE QString channelColumnName(int channel);
  1698. Q_INVOKABLE QString channelIndicatorText(int channel);
  1699. public slots:
  1700. void setTemperatureColumn(int tcol);
  1701. void setAnnotationColumn(int ncol);
  1702. void start();
  1703. void stop();
  1704. signals:
  1705. void annotation(QString note,int tcol,int ncol);
  1706. void triggerStartBatch();
  1707. void triggerStopBatch();
  1708. void deviceStopRequested();
  1709. private:
  1710. QVariantMap deviceSettings;
  1711. QString deviceScript;
  1712. QList<Channel*> channelList;
  1713. QList<bool> hiddenState;
  1714. QList<Units::Unit> channelUnits;
  1715. QList<QString> columnNames;
  1716. QList<QString> indicatorTexts;
  1717. QList<QVariantMap> channelSettings;
  1718. int annotationTemperatureColumn;
  1719. int annotationNoteColumn;
  1720. QScriptEngine*scriptengine;
  1721. };
  1722. /*:860*//*885:*/
  1723. #line 11 "./phidgets.w"
  1724. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1725. {
  1726. Q_OBJECT
  1727. public:
  1728. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1729. const QModelIndex&index);
  1730. private slots:
  1731. void addChannel();
  1732. void updateRate(int ms);
  1733. };
  1734. /*:885*//*889:*/
  1735. #line 82 "./phidgets.w"
  1736. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1737. {
  1738. Q_OBJECT
  1739. public:
  1740. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1741. const QModelIndex&index);
  1742. private slots:
  1743. void updateColumnName(const QString&value);
  1744. void updateHidden(bool hidden);
  1745. void updateTC(int index);
  1746. void updateChannel(int channel);
  1747. private:
  1748. QComboBox*tcType;
  1749. };
  1750. /*:889*//*894:*/
  1751. #line 213 "./phidgets.w"
  1752. class PhidgetsTemperatureSensor:public QObject
  1753. {
  1754. Q_OBJECT
  1755. public:
  1756. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1757. Q_INVOKABLE int channelCount();
  1758. Channel*getChannel(int channel);
  1759. Q_INVOKABLE bool isChannelHidden(int channel);
  1760. Q_INVOKABLE QString channelColumnName(int channel);
  1761. Q_INVOKABLE QString channelIndicatorText(int channel);
  1762. public slots:
  1763. void start();
  1764. void stop();
  1765. private slots:
  1766. void getMeasurements();
  1767. private:
  1768. QList<int> channelIndices;
  1769. QList<int> tctypes;
  1770. QList<Channel*> channelList;
  1771. QMap<int,Channel*> channelMap;
  1772. QList<bool> hiddenState;
  1773. QList<QString> columnNames;
  1774. QList<QString> indicatorTexts;
  1775. QLibrary driver;
  1776. QTimer sampleTimer;
  1777. void*device;
  1778. /*898:*/
  1779. #line 349 "./phidgets.w"
  1780. #ifdef _WIN32
  1781. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  1782. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  1783. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  1784. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1785. #else
  1786. typedef int(*PhidgetHandleOnly)(void*);
  1787. typedef int(*PhidgetHandleInt)(void*,int);
  1788. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1789. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1790. #endif
  1791. PhidgetHandleOnly createDevice;
  1792. PhidgetHandleInt openDevice;
  1793. PhidgetHandleInt waitForOpen;
  1794. PhidgetHandleIntInt setTCType;
  1795. PhidgetHandleIntDoubleOut getTemperature;
  1796. PhidgetHandleOnly closeDevice;
  1797. PhidgetHandleOnly deleteDevice;
  1798. /*:898*/
  1799. #line 240 "./phidgets.w"
  1800. };
  1801. /*:894*//*907:*/
  1802. #line 18973 "./typica.w"
  1803. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1804. {
  1805. Q_OBJECT
  1806. public:
  1807. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1808. const QModelIndex&index);
  1809. private slots:
  1810. void updateSourceColumn(const QString&source);
  1811. void updateDestinationColumn(const QString&dest);
  1812. void updateKnots();
  1813. private:
  1814. SaltModel*tablemodel;
  1815. };
  1816. /*:907*//*913:*/
  1817. #line 19097 "./typica.w"
  1818. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1819. {
  1820. Q_OBJECT
  1821. public:
  1822. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1823. private slots:
  1824. void updateMatchingColumn(const QString&column);
  1825. void updateTemperature();
  1826. private:
  1827. QDoubleSpinBox*temperatureValue;
  1828. QComboBox*unitSelector;
  1829. };
  1830. /*:913*//*917:*/
  1831. #line 16 "./rate.w"
  1832. class RateOfChange:public QObject
  1833. {
  1834. Q_OBJECT
  1835. public:
  1836. RateOfChange(int cachetime= 1,int scaletime= 1);
  1837. public slots:
  1838. void newMeasurement(Measurement measure);
  1839. void setCacheTime(int seconds);
  1840. void setScaleTime(int seconds);
  1841. signals:
  1842. void newData(Measurement measure);
  1843. private:
  1844. int ct;
  1845. int st;
  1846. QList<Measurement> cache;
  1847. };
  1848. /*:917*//*925:*/
  1849. #line 177 "./rate.w"
  1850. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  1851. {
  1852. Q_OBJECT
  1853. public:
  1854. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1855. private slots:
  1856. void updateColumn(const QString&column);
  1857. void updateCacheTime(const QString&seconds);
  1858. void updateScaleTime(const QString&seconds);
  1859. };
  1860. /*:925*//*931:*/
  1861. #line 19 "./dataqsdk.w"
  1862. class DataqSdkDeviceImplementation;
  1863. class DataqSdkDevice:public QObject
  1864. {
  1865. Q_OBJECT
  1866. DataqSdkDeviceImplementation*imp;
  1867. private slots:
  1868. void threadFinished();
  1869. public:
  1870. DataqSdkDevice(QString device);
  1871. ~DataqSdkDevice();
  1872. Channel*newChannel(Units::Unit scale);
  1873. Q_INVOKABLE void setClockRate(double Hz);
  1874. Q_INVOKABLE void start();
  1875. static QStringList detectPorts();
  1876. static QStringList detectHardware();
  1877. };
  1878. /*:931*//*932:*/
  1879. #line 49 "./dataqsdk.w"
  1880. class DataqSdkDeviceImplementation:public QThread
  1881. {
  1882. Q_OBJECT
  1883. public:
  1884. DataqSdkDeviceImplementation();
  1885. ~DataqSdkDeviceImplementation();
  1886. void run();
  1887. /*933:*/
  1888. #line 70 "./dataqsdk.w"
  1889. typedef struct di_inlist_struct{
  1890. unsigned short chan;
  1891. unsigned short diff;
  1892. unsigned short gain;
  1893. unsigned short unipolar;
  1894. unsigned short dig_out_enable;
  1895. unsigned short dig_out;
  1896. unsigned short ave;
  1897. unsigned short counter;
  1898. }DI_INLIST_STRUCT;
  1899. typedef int(PASCAL*FPDIOPEN)(unsigned);
  1900. typedef int(PASCAL*FPDICLOSE)(void);
  1901. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  1902. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  1903. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  1904. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  1905. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  1906. typedef int(PASCAL*FPDISTARTSCAN)(void);
  1907. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  1908. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  1909. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  1910. typedef int(PASCAL*FPDISTOPSCAN)(void);
  1911. FPDIOPEN di_open;
  1912. FPDICLOSE di_close;
  1913. FPDISAMPLERATE di_sample_rate;
  1914. FPDIMAXIMUMRATE di_maximum_rate;
  1915. FPDILISTLENGTH di_list_length;
  1916. FPDIINLIST di_inlist;
  1917. FPDIBUFFERALLOC di_buffer_alloc;
  1918. FPDISTARTSCAN di_start_scan;
  1919. FPDISTATUSREAD di_status_read;
  1920. FPDIBUFFERSTATUS di_buffer_status;
  1921. FPDIBURSTRATE di_burst_rate;
  1922. FPDISTOPSCAN di_stop_scan;
  1923. /*:933*/
  1924. #line 57 "./dataqsdk.w"
  1925. /*935:*/
  1926. #line 134 "./dataqsdk.w"
  1927. bool isOpen;
  1928. double sampleRate;
  1929. long oversample;
  1930. long burstDivisor;
  1931. QString device;
  1932. unsigned deviceNumber;
  1933. QVector<Channel*> channelMap;
  1934. int error;
  1935. int channels;
  1936. bool ready;
  1937. QLibrary*driver;
  1938. QVector<Units::Unit> unitMap;
  1939. int*input_buffer;
  1940. QTimer*eventClock;
  1941. QMultiMap<int,double> smoother;
  1942. /*:935*/
  1943. #line 58 "./dataqsdk.w"
  1944. public slots:
  1945. void measure();
  1946. private:
  1947. qint16*buffer;
  1948. };
  1949. /*:932*//*952:*/
  1950. #line 663 "./dataqsdk.w"
  1951. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  1952. {
  1953. Q_OBJECT
  1954. public:
  1955. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  1956. const QModelIndex&index);
  1957. private slots:
  1958. void updateAutoSelect(bool automatic);
  1959. void updateDeviceNumber(int deviceNumber);
  1960. void updatePort(QString portId);
  1961. void addChannel();
  1962. private:
  1963. QStackedWidget*deviceIdStack;
  1964. };
  1965. /*:952*//*957:*/
  1966. #line 808 "./dataqsdk.w"
  1967. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  1968. {
  1969. Q_OBJECT
  1970. public:
  1971. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  1972. const QModelIndex&index);
  1973. private slots:
  1974. void updateUnits(const QString&unit);
  1975. void updateColumnName(const QString&value);
  1976. void updateMeasuredLower(const QString&value);
  1977. void updateMeasuredUpper(const QString&value);
  1978. void updateMappedLower(const QString&value);
  1979. void updateMappedUpper(const QString&value);
  1980. void updateClosedInterval(bool closed);
  1981. void updateSmoothingEnabled(bool enabled);
  1982. void updateSensitivity(const QString&value);
  1983. void startCalibration();
  1984. void stopCalibration();
  1985. void resetCalibration();
  1986. void updateInput(Measurement measure);
  1987. void updateOutput(Measurement measure);
  1988. void updateHidden(bool hidden);
  1989. private:
  1990. QPushButton*startButton;
  1991. QPushButton*resetButton;
  1992. QPushButton*stopButton;
  1993. /*962:*/
  1994. #line 1098 "./dataqsdk.w"
  1995. bool autoSelect;
  1996. QString deviceID;
  1997. unsigned int channelOfInterest;
  1998. /*:962*/
  1999. #line 835 "./dataqsdk.w"
  2000. DataqSdkDevice*calibrationDevice;
  2001. LinearCalibrator*calibrator;
  2002. QLineEdit*currentMeasurement;
  2003. QLineEdit*minimumMeasurement;
  2004. QLineEdit*maximumMeasurement;
  2005. QLineEdit*averageMeasurement;
  2006. QLineEdit*currentMapped;
  2007. QLineEdit*minimumMapped;
  2008. QLineEdit*maximumMapped;
  2009. QLineEdit*averageMapped;
  2010. int rmCount;
  2011. int cmCount;
  2012. double rmin;
  2013. double rmax;
  2014. double rmean;
  2015. double cmin;
  2016. double cmax;
  2017. double cmean;
  2018. };
  2019. /*:957*//*984:*/
  2020. #line 247 "./scales.w"
  2021. Q_DECLARE_METATYPE(BaudRateType)
  2022. Q_DECLARE_METATYPE(DataBitsType)
  2023. Q_DECLARE_METATYPE(ParityType)
  2024. Q_DECLARE_METATYPE(StopBitsType)
  2025. Q_DECLARE_METATYPE(FlowType)
  2026. /*:984*//*991:*/
  2027. #line 370 "./scales.w"
  2028. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2029. {
  2030. Q_OBJECT
  2031. public:
  2032. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2033. const QModelIndex&index);
  2034. private slots:
  2035. void updatePort(const QString&newPort);
  2036. void updateBaudRate(const QString&rate);
  2037. void updateParity(int index);
  2038. void updateFlowControl(int index);
  2039. void updateStopBits(int index);
  2040. private:
  2041. PortSelector*port;
  2042. BaudSelector*baud;
  2043. ParitySelector*parity;
  2044. FlowSelector*flow;
  2045. StopSelector*stop;
  2046. };
  2047. /*:991*//*996:*/
  2048. #line 14 "./valueannotation.w"
  2049. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2050. {
  2051. Q_OBJECT
  2052. public:
  2053. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2054. const QModelIndex&index);
  2055. private slots:
  2056. void updateSourceColumn(const QString&source);
  2057. void updateAnnotations();
  2058. void updateStart(bool noteOnStart);
  2059. private:
  2060. SaltModel*tablemodel;
  2061. };
  2062. /*:996*//*1004:*/
  2063. #line 165 "./valueannotation.w"
  2064. class ValueAnnotation:public QObject
  2065. {
  2066. Q_OBJECT
  2067. public:
  2068. ValueAnnotation();
  2069. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2070. public slots:
  2071. void newMeasurement(Measurement measure);
  2072. void annotate();
  2073. void setAnnotationColumn(int column);
  2074. void setTemperatureColumn(int column);
  2075. void setTolerance(double epsilon);
  2076. signals:
  2077. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2078. private:
  2079. int lastIndex;
  2080. int annotationColumn;
  2081. int measurementColumn;
  2082. QList<double> values;
  2083. QStringList annotations;
  2084. double tolerance;
  2085. };
  2086. /*:1004*/
  2087. #line 526 "./typica.w"
  2088. /*12:*/
  2089. #line 807 "./typica.w"
  2090. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2091. /*:12*//*14:*/
  2092. #line 822 "./typica.w"
  2093. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2094. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2095. /*:14*//*16:*/
  2096. #line 847 "./typica.w"
  2097. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2098. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2099. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2100. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2101. QScriptEngine*engine);
  2102. /*:16*//*27:*/
  2103. #line 1091 "./typica.w"
  2104. QScriptValue constructQMainWindow(QScriptContext*context,
  2105. QScriptEngine*engine);
  2106. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2107. QScriptEngine*engine);
  2108. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2109. QScriptEngine*engine);
  2110. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2111. /*:27*//*32:*/
  2112. #line 1190 "./typica.w"
  2113. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2114. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2115. /*:32*//*35:*/
  2116. #line 1235 "./typica.w"
  2117. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2118. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2119. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2120. /*:35*//*38:*/
  2121. #line 1301 "./typica.w"
  2122. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2123. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2124. /*:38*//*41:*/
  2125. #line 1334 "./typica.w"
  2126. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2127. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2128. /*:41*//*44:*/
  2129. #line 1372 "./typica.w"
  2130. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2131. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2132. /*:44*//*48:*/
  2133. #line 1411 "./typica.w"
  2134. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2135. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2136. QScriptEngine*engine);
  2137. QScriptValue QSplitter_saveState(QScriptContext*context,
  2138. QScriptEngine*engine);
  2139. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2140. QScriptEngine*engine);
  2141. QScriptValue QSplitter_count(QScriptContext*context,
  2142. QScriptEngine*engine);
  2143. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2144. /*:48*//*54:*/
  2145. #line 1550 "./typica.w"
  2146. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2147. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2148. /*:54*//*56:*/
  2149. #line 1605 "./typica.w"
  2150. QScriptValue constructQBoxLayout(QScriptContext*context,
  2151. QScriptEngine*engine);
  2152. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2153. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2154. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2155. /*:56*//*60:*/
  2156. #line 1718 "./typica.w"
  2157. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2158. QScriptValue QAction_setShortcut(QScriptContext*context,
  2159. QScriptEngine*engine);
  2160. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2161. /*:60*//*63:*/
  2162. #line 1774 "./typica.w"
  2163. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2164. QScriptEngine*engine);
  2165. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2166. QScriptEngine*engine);
  2167. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2168. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2169. /*:63*//*68:*/
  2170. #line 1885 "./typica.w"
  2171. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2172. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2173. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2174. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2175. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2176. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2177. QScriptValue QIODevice_readToString(QScriptContext*context,
  2178. QScriptEngine*engine);
  2179. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2180. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2181. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2182. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2183. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2184. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2185. /*:68*//*79:*/
  2186. #line 2111 "./typica.w"
  2187. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2188. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2189. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2190. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2191. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2192. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2193. /*:79*//*87:*/
  2194. #line 2229 "./typica.w"
  2195. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2196. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2197. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2198. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2199. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2200. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2201. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2202. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2203. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2204. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2205. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2206. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2207. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2208. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2209. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2210. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2211. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2212. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2213. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2214. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2215. /*:87*//*100:*/
  2216. #line 2503 "./typica.w"
  2217. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2218. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2219. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2220. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2221. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2222. /*:100*//*103:*/
  2223. #line 2608 "./typica.w"
  2224. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2225. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2226. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2227. /*:103*//*106:*/
  2228. #line 2653 "./typica.w"
  2229. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2230. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2231. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2232. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2233. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2234. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2235. /*:106*//*112:*/
  2236. #line 2735 "./typica.w"
  2237. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2238. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2239. QScriptEngine*engine);
  2240. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2241. QScriptEngine*engine);
  2242. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2243. QScriptEngine*engine);
  2244. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2245. QScriptEngine*engine);
  2246. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2247. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2248. QScriptEngine*engine);
  2249. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2250. QScriptEngine*engine);
  2251. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2252. QScriptEngine*engine);
  2253. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2254. QScriptEngine*engine);
  2255. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2256. QScriptEngine*engine);
  2257. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2258. QScriptEngine*engine);
  2259. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2260. QScriptEngine*engine);
  2261. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2262. QScriptEngine*engine);
  2263. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2264. /*:112*//*121:*/
  2265. #line 2953 "./typica.w"
  2266. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2267. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2268. QScriptValue XmlReader_attribute(QScriptContext*context,
  2269. QScriptEngine*engine);
  2270. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2271. QScriptEngine*engine);
  2272. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2273. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2274. QScriptEngine*engine);
  2275. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2276. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2277. QScriptEngine*engine);
  2278. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2279. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2280. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2281. /*:121*//*128:*/
  2282. #line 3088 "./typica.w"
  2283. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2284. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2285. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2286. /*:128*//*132:*/
  2287. #line 3170 "./typica.w"
  2288. QScriptValue constructQLCDNumber(QScriptContext*context,
  2289. QScriptEngine*engine);
  2290. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2291. /*:132*//*135:*/
  2292. #line 3208 "./typica.w"
  2293. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2294. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2295. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2296. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2297. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2298. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2299. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2300. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2301. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2302. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2303. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2304. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2305. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2306. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2307. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2308. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2309. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2310. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2311. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2312. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2313. /*:135*//*151:*/
  2314. #line 3686 "./typica.w"
  2315. void setQAbstractScrollAreaProperties(QScriptValue value,
  2316. QScriptEngine*engine);
  2317. /*:151*//*153:*/
  2318. #line 3701 "./typica.w"
  2319. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2320. /*:153*//*155:*/
  2321. #line 3714 "./typica.w"
  2322. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2323. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2324. /*:155*//*157:*/
  2325. #line 3738 "./typica.w"
  2326. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2327. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2328. QScriptValue constructQPushButton(QScriptContext*context,
  2329. QScriptEngine*engine);
  2330. /*:157*//*164:*/
  2331. #line 3837 "./typica.w"
  2332. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2333. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2334. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2335. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2336. QScriptEngine*engine);
  2337. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2338. QScriptEngine*engine);
  2339. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2340. QScriptEngine*engine);
  2341. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2342. QScriptEngine*engine);
  2343. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2344. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2345. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2346. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2347. /*:164*//*171:*/
  2348. #line 4008 "./typica.w"
  2349. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2350. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2351. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2352. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2353. QScriptValue annotationFromRecord(QScriptContext*context,
  2354. QScriptEngine*engine);
  2355. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2356. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2357. /*:171*//*183:*/
  2358. #line 4320 "./typica.w"
  2359. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2360. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2361. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2362. QStack<QLayout*> *layoutStack);
  2363. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2364. QStack<QLayout*> *layoutStack);
  2365. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2366. QStack<QLayout*> *layoutStack);
  2367. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2368. QStack<QLayout*> *layoutStack);
  2369. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2370. QStack<QLayout*> *layoutStack);
  2371. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2372. QStack<QLayout*> *layoutStack);
  2373. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2374. QStack<QLayout*> *layoutStack);
  2375. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2376. QStack<QLayout*> *layoutStack);
  2377. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2378. QStack<QLayout*> *layoutStack);
  2379. void addTemperatureDisplayToSplitter(QDomElement element,
  2380. QStack<QWidget*> *widgetStack,
  2381. QStack<QLayout*> *layoutStack);
  2382. void addTemperatureDisplayToLayout(QDomElement element,
  2383. QStack<QWidget*> *widgetStack,
  2384. QStack<QLayout*> *layoutStack);
  2385. void addTimerDisplayToSplitter(QDomElement element,
  2386. QStack<QWidget*> *widgetStack,
  2387. QStack<QLayout*> *layoutStack);
  2388. void addTimerDisplayToLayout(QDomElement element,
  2389. QStack<QWidget*> *widgetStack,
  2390. QStack<QLayout*> *layoutStack);
  2391. void addDecorationToSplitter(QDomElement element,
  2392. QStack<QWidget*> *widgetStack,
  2393. QStack<QLayout*> *layoutStack);
  2394. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2395. QStack<QLayout*> *layoutStack);
  2396. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2397. QStack<QLayout*> *layoutStack);
  2398. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2399. QStack<QLayout*> *layoutStack);
  2400. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2401. QStack<QLayout*> *layoutStack);
  2402. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2403. QStack<QLayout*> *layoutStack);
  2404. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2405. QStack<QLayout*> *layoutStack);
  2406. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2407. QStack<QLayout*> *layoutStack);
  2408. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2409. QStack<QLayout*> *layoutStack);
  2410. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2411. QStack<QLayout*> *layoutStack);
  2412. void addSqlQueryViewToLayout(QDomElement element,
  2413. QStack<QWidget*> *widgetStack,
  2414. QStack<QLayout*> *layoutStack);
  2415. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2416. QStack<QLayout*> *layoutStack);
  2417. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2418. QStack<QLayout*> *layoutStack);
  2419. /*:183*//*242:*/
  2420. #line 5910 "./typica.w"
  2421. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2422. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2423. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2424. QScriptEngine*engine);
  2425. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2426. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2427. QScriptEngine*engine);
  2428. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2429. /*:242*//*243:*/
  2430. #line 5925 "./typica.w"
  2431. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2432. /*:243*//*247:*/
  2433. #line 6060 "./typica.w"
  2434. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2435. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2436. QScriptEngine*engine);
  2437. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2438. QScriptEngine*engine);
  2439. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2440. QScriptEngine*engine);
  2441. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2442. QScriptEngine*engine);
  2443. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2444. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2445. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2446. QScriptEngine*engine);
  2447. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2448. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2449. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2450. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2451. /*:247*//*257:*/
  2452. #line 6276 "./typica.w"
  2453. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2454. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2455. QScriptValue QComboBox_currentData(QScriptContext*context,
  2456. QScriptEngine*engine);
  2457. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2458. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2459. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2460. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2461. /*:257*//*269:*/
  2462. #line 366 "./units.w"
  2463. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2464. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2465. QScriptEngine*engine);
  2466. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2467. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2468. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2469. /*:269*//*273:*/
  2470. #line 430 "./units.w"
  2471. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2472. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2473. /*:273*//*282:*/
  2474. #line 133 "./measurement.w"
  2475. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2476. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2477. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2478. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2479. /*:282*//*302:*/
  2480. #line 6910 "./typica.w"
  2481. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2482. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2483. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2484. /*:302*//*311:*/
  2485. #line 7115 "./typica.w"
  2486. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2487. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2488. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2489. /*:311*//*316:*/
  2490. #line 7216 "./typica.w"
  2491. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2492. /*:316*//*322:*/
  2493. #line 7398 "./typica.w"
  2494. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2495. QScriptEngine*engine);
  2496. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2497. /*:322*//*327:*/
  2498. #line 7538 "./typica.w"
  2499. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2500. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2501. /*:327*//*337:*/
  2502. #line 7740 "./typica.w"
  2503. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2504. QScriptEngine*engine);
  2505. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2506. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2507. QScriptEngine*engine);
  2508. /*:337*//*345:*/
  2509. #line 7899 "./typica.w"
  2510. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2511. QScriptEngine*engine);
  2512. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2513. QScriptEngine*engine);
  2514. /*:345*//*350:*/
  2515. #line 8012 "./typica.w"
  2516. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2517. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2518. /*:350*//*355:*/
  2519. #line 8110 "./typica.w"
  2520. QScriptValue constructZeroEmitter(QScriptContext*context,
  2521. QScriptEngine*engine);
  2522. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2523. /*:355*//*360:*/
  2524. #line 8189 "./typica.w"
  2525. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2526. QScriptEngine*engine);
  2527. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2528. /*:360*//*377:*/
  2529. #line 8653 "./typica.w"
  2530. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2531. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2532. /*:377*//*400:*/
  2533. #line 9280 "./typica.w"
  2534. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2535. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2536. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2537. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2538. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2539. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2540. QScriptEngine*engine);
  2541. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2542. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2543. QScriptEngine*engnie);
  2544. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2545. QScriptEngine*engine);
  2546. /*:400*//*438:*/
  2547. #line 10237 "./typica.w"
  2548. QScriptValue constructAnnotationButton(QScriptContext*context,
  2549. QScriptEngine*engine);
  2550. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2551. /*:438*//*446:*/
  2552. #line 10377 "./typica.w"
  2553. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2554. QScriptEngine*engine);
  2555. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2556. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2557. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2558. /*:446*//*467:*/
  2559. #line 10800 "./typica.w"
  2560. QScriptValue constructTimerDisplay(QScriptContext*context,
  2561. QScriptEngine*engine);
  2562. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2563. /*:467*//*494:*/
  2564. #line 11294 "./typica.w"
  2565. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2566. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2567. QScriptEngine*engine);
  2568. /*:494*//*507:*/
  2569. #line 11577 "./typica.w"
  2570. QScriptValue constructLogEditWindow(QScriptContext*context,
  2571. QScriptEngine*engine);
  2572. /*:507*//*526:*/
  2573. #line 12105 "./typica.w"
  2574. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2575. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2576. /*:526*//*544:*/
  2577. #line 189 "./webview.w"
  2578. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2579. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2580. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2581. QStack<QLayout*> *layoutStack);
  2582. /*:544*//*547:*/
  2583. #line 219 "./webview.w"
  2584. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2585. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2586. /*:547*//*551:*/
  2587. #line 277 "./webview.w"
  2588. QScriptValue constructWebElement(QScriptContext*context,
  2589. QScriptEngine*engine);
  2590. /*:551*//*620:*/
  2591. #line 13444 "./typica.w"
  2592. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2593. QScriptValue constructSqlQueryView(QScriptContext*context,
  2594. QScriptEngine*engine);
  2595. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2596. QScriptEngine*engine);
  2597. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2598. QScriptEngine*engine);
  2599. /*:620*//*630:*/
  2600. #line 13681 "./typica.w"
  2601. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2602. QStack<QLayout*> *layoutStack);
  2603. /*:630*//*646:*/
  2604. #line 13966 "./typica.w"
  2605. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2606. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2607. /*:646*//*668:*/
  2608. #line 471 "./daterangeselector.w"
  2609. void addDateRangeToLayout(QDomElement element,
  2610. QStack<QWidget*> *widgetStack,
  2611. QStack<QLayout*> *layoutStack);
  2612. /*:668*//*677:*/
  2613. #line 14163 "./typica.w"
  2614. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2615. QStack<QLayout*> *layoutStack);
  2616. /*:677*//*698:*/
  2617. #line 14747 "./typica.w"
  2618. void addScaleControlToLayout(QDomElement element,
  2619. QStack<QWidget*> *widgetStack,
  2620. QStack<QLayout*> *layoutStack);
  2621. void addIntensityControlToLayout(QDomElement element,
  2622. QStack<QWidget*> *widgetStack,
  2623. QStack<QLayout*> *layoutStack);
  2624. /*:698*//*724:*/
  2625. #line 15333 "./typica.w"
  2626. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2627. QScriptEngine*engine);
  2628. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2629. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2630. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2631. QScriptEngine*engine);
  2632. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2633. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2634. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2635. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2636. /*:724*//*730:*/
  2637. #line 15475 "./typica.w"
  2638. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2639. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2640. /*:730*//*746:*/
  2641. #line 15773 "./typica.w"
  2642. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2643. QScriptEngine*engine);
  2644. /*:746*//*817:*/
  2645. #line 42 "./settings.w"
  2646. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2647. /*:817*//*841:*/
  2648. #line 18342 "./typica.w"
  2649. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2650. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2651. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2652. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2653. /*:841*//*861:*/
  2654. #line 345 "./unsupportedserial.w"
  2655. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  2656. /*:861*//*867:*/
  2657. #line 425 "./unsupportedserial.w"
  2658. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  2659. /*:867*//*873:*/
  2660. #line 617 "./unsupportedserial.w"
  2661. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  2662. /*:873*//*877:*/
  2663. #line 651 "./unsupportedserial.w"
  2664. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  2665. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  2666. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  2667. /*:877*//*904:*/
  2668. #line 457 "./phidgets.w"
  2669. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  2670. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  2671. /*:904*//*922:*/
  2672. #line 138 "./rate.w"
  2673. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2674. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2675. /*:922*//*947:*/
  2676. #line 597 "./dataqsdk.w"
  2677. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2678. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2679. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2680. /*:947*//*974:*/
  2681. #line 67 "./scales.w"
  2682. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2683. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2684. /*:974*//*982:*/
  2685. #line 233 "./scales.w"
  2686. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2687. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2688. /*:982*//*985:*/
  2689. #line 258 "./scales.w"
  2690. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2691. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2692. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2693. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2694. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2695. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2696. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2697. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2698. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2699. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2700. /*:985*//*1010:*/
  2701. #line 265 "./valueannotation.w"
  2702. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2703. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2704. /*:1010*/
  2705. #line 527 "./typica.w"
  2706. /*600:*/
  2707. #line 13101 "./typica.w"
  2708. void messageFileOutput(QtMsgType type,const char*msg);
  2709. /*:600*/
  2710. #line 528 "./typica.w"
  2711. /*4:*/
  2712. #line 537 "./typica.w"
  2713. /*738:*/
  2714. #line 15596 "./typica.w"
  2715. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2716. const QString&driver,QObject*parent):
  2717. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2718. {
  2719. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2720. }
  2721. void NodeInserter::onTriggered()
  2722. {
  2723. emit triggered(defaultNodeName,driverString);
  2724. }
  2725. /*:738*/
  2726. #line 538 "./typica.w"
  2727. /*278:*/
  2728. #line 40 "./measurement.w"
  2729. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2730. {
  2731. insert("measurement",temperature);
  2732. insert("time",time);
  2733. insert("unit",sc);
  2734. }
  2735. Measurement::Measurement(double temperature)
  2736. {
  2737. insert("measurement",temperature);
  2738. insert("time",QTime::currentTime());
  2739. insert("unit",Units::Fahrenheit);
  2740. }
  2741. void Measurement::setTemperature(double temperature)
  2742. {
  2743. insert("measurement",temperature);
  2744. }
  2745. void Measurement::setTime(QTime time)
  2746. {
  2747. insert("time",time);
  2748. }
  2749. void Measurement::setUnit(Units::Unit scale)
  2750. {
  2751. insert("unit",scale);
  2752. }
  2753. double Measurement::temperature()const
  2754. {
  2755. return value("measurement").toDouble();
  2756. }
  2757. QTime Measurement::time()const
  2758. {
  2759. return value("time").toTime();
  2760. }
  2761. Units::Unit Measurement::scale()const
  2762. {
  2763. return(Units::Unit)(value("unit").toInt());
  2764. }
  2765. /*:278*//*279:*/
  2766. #line 88 "./measurement.w"
  2767. Measurement Measurement::toFahrenheit()
  2768. {
  2769. return Measurement(Units::convertTemperature(this->temperature(),
  2770. this->scale(),Units::Fahrenheit),
  2771. this->time(),Units::Fahrenheit);
  2772. }
  2773. Measurement Measurement::toCelsius()
  2774. {
  2775. return Measurement(Units::convertTemperature(this->temperature(),
  2776. this->scale(),Units::Celsius),
  2777. this->time(),Units::Celsius);
  2778. }
  2779. Measurement Measurement::toKelvin()
  2780. {
  2781. return Measurement(Units::convertTemperature(this->temperature(),
  2782. this->scale(),Units::Kelvin),
  2783. this->time(),Units::Kelvin);
  2784. }
  2785. Measurement Measurement::toRankine()
  2786. {
  2787. return Measurement(Units::convertTemperature(this->temperature(),
  2788. this->scale(),Units::Rankine),
  2789. this->time(),Units::Rankine);
  2790. }
  2791. /*:279*/
  2792. #line 539 "./typica.w"
  2793. /*292:*/
  2794. #line 6516 "./typica.w"
  2795. void DAQImplementation::measure()
  2796. {
  2797. int samplesRead= 0;
  2798. double buffer[channels];
  2799. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  2800. (unsigned long)(0),buffer,(unsigned long)(channels),
  2801. &samplesRead,(signed long)(0));
  2802. if(error)
  2803. {
  2804. ready= false;
  2805. }
  2806. else
  2807. {
  2808. if(samplesRead)
  2809. {
  2810. QTime time= QTime::currentTime();
  2811. for(int i= 0;i<samplesRead;i++)
  2812. {
  2813. for(int j= 0;j<channels;j++)
  2814. {
  2815. Measurement measure(buffer[j+(i*channels)],time,
  2816. unitMap[j]);
  2817. channelMap[j]->input(measure);
  2818. }
  2819. }
  2820. }
  2821. }
  2822. }
  2823. /*:292*//*293:*/
  2824. #line 6558 "./typica.w"
  2825. void DAQImplementation::run()
  2826. {
  2827. setPriority(QThread::TimeCriticalPriority);
  2828. while(ready)
  2829. {
  2830. measure();
  2831. }
  2832. }
  2833. /*:293*//*294:*/
  2834. #line 6574 "./typica.w"
  2835. void DAQ::threadFinished()
  2836. {
  2837. if(imp->error)
  2838. {
  2839. /*295:*/
  2840. #line 6625 "./typica.w"
  2841. imp->ready= false;
  2842. QMessageBox warning;
  2843. warning.setStandardButtons(QMessageBox::Cancel);
  2844. warning.setIcon(QMessageBox::Warning);
  2845. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2846. unsigned long bytes= imp->errorInfo(NULL,0);
  2847. char string[bytes];
  2848. imp->errorInfo(string,bytes);
  2849. warning.setInformativeText(QString(string));
  2850. warning.setWindowTitle(QString(PROGRAM_NAME));
  2851. warning.exec();
  2852. /*:295*/
  2853. #line 6579 "./typica.w"
  2854. }
  2855. }
  2856. /*:294*//*296:*/
  2857. #line 6650 "./typica.w"
  2858. void DAQ::start()
  2859. {
  2860. if(imp->ready)
  2861. {
  2862. imp->error= imp->startTask(imp->handle);
  2863. if(imp->error)
  2864. {
  2865. /*295:*/
  2866. #line 6625 "./typica.w"
  2867. imp->ready= false;
  2868. QMessageBox warning;
  2869. warning.setStandardButtons(QMessageBox::Cancel);
  2870. warning.setIcon(QMessageBox::Warning);
  2871. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2872. unsigned long bytes= imp->errorInfo(NULL,0);
  2873. char string[bytes];
  2874. imp->errorInfo(string,bytes);
  2875. warning.setInformativeText(QString(string));
  2876. warning.setWindowTitle(QString(PROGRAM_NAME));
  2877. warning.exec();
  2878. /*:295*/
  2879. #line 6658 "./typica.w"
  2880. }
  2881. else
  2882. {
  2883. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  2884. imp->start();
  2885. }
  2886. }
  2887. }
  2888. void DAQ::stop()
  2889. {
  2890. if(imp->useBase)
  2891. {
  2892. imp->ready= false;
  2893. imp->wait(ULONG_MAX);
  2894. imp->stopTask(imp->handle);
  2895. }
  2896. else
  2897. {
  2898. imp->ready= false;
  2899. imp->error= imp->stopTask(imp->handle);
  2900. if(imp->error)
  2901. {
  2902. /*295:*/
  2903. #line 6625 "./typica.w"
  2904. imp->ready= false;
  2905. QMessageBox warning;
  2906. warning.setStandardButtons(QMessageBox::Cancel);
  2907. warning.setIcon(QMessageBox::Warning);
  2908. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2909. unsigned long bytes= imp->errorInfo(NULL,0);
  2910. char string[bytes];
  2911. imp->errorInfo(string,bytes);
  2912. warning.setInformativeText(QString(string));
  2913. warning.setWindowTitle(QString(PROGRAM_NAME));
  2914. warning.exec();
  2915. /*:295*/
  2916. #line 6682 "./typica.w"
  2917. }
  2918. imp->error= imp->clearTask(imp->handle);
  2919. if(imp->error)
  2920. {
  2921. /*295:*/
  2922. #line 6625 "./typica.w"
  2923. imp->ready= false;
  2924. QMessageBox warning;
  2925. warning.setStandardButtons(QMessageBox::Cancel);
  2926. warning.setIcon(QMessageBox::Warning);
  2927. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2928. unsigned long bytes= imp->errorInfo(NULL,0);
  2929. char string[bytes];
  2930. imp->errorInfo(string,bytes);
  2931. warning.setInformativeText(QString(string));
  2932. warning.setWindowTitle(QString(PROGRAM_NAME));
  2933. warning.exec();
  2934. /*:295*/
  2935. #line 6687 "./typica.w"
  2936. }
  2937. }
  2938. }
  2939. /*:296*//*297:*/
  2940. #line 6697 "./typica.w"
  2941. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  2942. {
  2943. imp->device= device;
  2944. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  2945. if(imp->error)
  2946. {
  2947. /*295:*/
  2948. #line 6625 "./typica.w"
  2949. imp->ready= false;
  2950. QMessageBox warning;
  2951. warning.setStandardButtons(QMessageBox::Cancel);
  2952. warning.setIcon(QMessageBox::Warning);
  2953. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2954. unsigned long bytes= imp->errorInfo(NULL,0);
  2955. char string[bytes];
  2956. imp->errorInfo(string,bytes);
  2957. warning.setInformativeText(QString(string));
  2958. warning.setWindowTitle(QString(PROGRAM_NAME));
  2959. warning.exec();
  2960. /*:295*/
  2961. #line 6704 "./typica.w"
  2962. }
  2963. else
  2964. {
  2965. imp->ready= true;
  2966. }
  2967. }
  2968. /*:297*//*298:*/
  2969. #line 6718 "./typica.w"
  2970. Channel*DAQ::newChannel(int units,int thermocouple)
  2971. {
  2972. Channel*retval= new Channel();
  2973. imp->channelMap[imp->channels]= retval;
  2974. imp->unitMap[imp->channels]= (Units::Unit)units;
  2975. imp->channels++;
  2976. if(imp->ready)
  2977. {
  2978. if(imp->useBase)
  2979. {
  2980. imp->error= imp->createChannel(imp->handle,
  2981. QString("%1/ai%2").arg(imp->device).
  2982. arg(imp->channels-1).
  2983. toAscii().data(),
  2984. "",(double)(-1.0),(double)(100.0),
  2985. (signed long)(units),
  2986. (signed long)(thermocouple),
  2987. (signed long)(10200),(double)(0),
  2988. "");
  2989. }
  2990. else
  2991. {
  2992. imp->error= imp->createChannel(imp->handle,
  2993. QString("%1/ai%2").arg(imp->device).
  2994. arg(imp->channels-1).
  2995. toAscii().data(),
  2996. "",(double)(50.0),(double)(500.0),
  2997. (signed long)(units),
  2998. (signed long)(thermocouple),
  2999. (signed long)(10200),(double)(0),
  3000. "");
  3001. }
  3002. if(imp->error)
  3003. {
  3004. /*295:*/
  3005. #line 6625 "./typica.w"
  3006. imp->ready= false;
  3007. QMessageBox warning;
  3008. warning.setStandardButtons(QMessageBox::Cancel);
  3009. warning.setIcon(QMessageBox::Warning);
  3010. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3011. unsigned long bytes= imp->errorInfo(NULL,0);
  3012. char string[bytes];
  3013. imp->errorInfo(string,bytes);
  3014. warning.setInformativeText(QString(string));
  3015. warning.setWindowTitle(QString(PROGRAM_NAME));
  3016. warning.exec();
  3017. /*:295*/
  3018. #line 6753 "./typica.w"
  3019. }
  3020. }
  3021. return retval;
  3022. }
  3023. /*:298*//*299:*/
  3024. #line 6767 "./typica.w"
  3025. void DAQ::setClockRate(double Hz)
  3026. {
  3027. if(imp->ready)
  3028. {
  3029. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3030. (signed long)(10280),(signed long)(10123),
  3031. (unsigned long long)(1));
  3032. if(imp->error)
  3033. {
  3034. /*295:*/
  3035. #line 6625 "./typica.w"
  3036. imp->ready= false;
  3037. QMessageBox warning;
  3038. warning.setStandardButtons(QMessageBox::Cancel);
  3039. warning.setIcon(QMessageBox::Warning);
  3040. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3041. unsigned long bytes= imp->errorInfo(NULL,0);
  3042. char string[bytes];
  3043. imp->errorInfo(string,bytes);
  3044. warning.setInformativeText(QString(string));
  3045. warning.setWindowTitle(QString(PROGRAM_NAME));
  3046. warning.exec();
  3047. /*:295*/
  3048. #line 6777 "./typica.w"
  3049. }
  3050. }
  3051. }
  3052. /*:299*//*300:*/
  3053. #line 6787 "./typica.w"
  3054. DAQ::~DAQ()
  3055. {
  3056. if(imp->useBase)
  3057. {
  3058. imp->resetDevice(imp->device.toAscii().data());
  3059. imp->clearTask(imp->handle);
  3060. }
  3061. else
  3062. {
  3063. if(imp->ready)
  3064. {
  3065. imp->ready= false;
  3066. imp->wait(ULONG_MAX);
  3067. imp->stopTask(imp->handle);
  3068. imp->resetDevice(imp->device.toAscii().data());
  3069. imp->clearTask(imp->handle);
  3070. }
  3071. }
  3072. delete imp;
  3073. }
  3074. /*:300*//*301:*/
  3075. #line 6818 "./typica.w"
  3076. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3077. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3078. unitMap(4)
  3079. {
  3080. if(driverinfo=="nidaqmxbase")
  3081. {
  3082. useBase= true;
  3083. }
  3084. else
  3085. {
  3086. useBase= false;
  3087. }
  3088. if(useBase)
  3089. {
  3090. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3091. if(!driver.load())
  3092. {
  3093. driver.setFileName("nidaqmxbase");
  3094. if(!driver.load())
  3095. {
  3096. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3097. tr("Failed to find nidaqmxbase. Please install it."));
  3098. QApplication::quit();
  3099. }
  3100. }
  3101. }
  3102. else
  3103. {
  3104. driver.setFileName("nicaiu");
  3105. if(!driver.load())
  3106. {
  3107. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3108. tr("Failed to find nidaqmx. Please install it."));
  3109. QApplication::quit();
  3110. }
  3111. }
  3112. if(useBase)
  3113. {
  3114. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3115. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3116. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3117. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3118. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3119. ==0||
  3120. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3121. 0||
  3122. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3123. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3124. 0||
  3125. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3126. {
  3127. waitForMeasurement= NULL;
  3128. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3129. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3130. QApplication::quit();
  3131. }
  3132. }
  3133. else
  3134. {
  3135. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3136. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3137. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3138. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3139. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3140. ==0||
  3141. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3142. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3143. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3144. 0||
  3145. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3146. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3147. {
  3148. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3149. tr("Failed to link a required symbol in NI-DAQmx."));
  3150. QApplication::quit();
  3151. }
  3152. }
  3153. }
  3154. DAQImplementation::~DAQImplementation()
  3155. {
  3156. driver.unload();
  3157. }
  3158. /*:301*/
  3159. #line 540 "./typica.w"
  3160. /*936:*/
  3161. #line 197 "./dataqsdk.w"
  3162. void DataqSdkDeviceImplementation::measure()
  3163. {
  3164. unsigned count= channels*40;
  3165. di_status_read(buffer,count);
  3166. QTime time= QTime::currentTime();
  3167. for(unsigned int i= 0;i<count;i++)
  3168. {
  3169. buffer[i]= buffer[i]&0xFFFC;
  3170. }
  3171. QList<int> countList;
  3172. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3173. {
  3174. QList<double> channelBuffer;
  3175. for(unsigned int j= 0;j<40;j++)
  3176. {
  3177. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3178. if(i==0)
  3179. {
  3180. countList<<buffer[i+(channels*j)];
  3181. }
  3182. }
  3183. double value= 0.0;
  3184. for(unsigned int j= 0;j<40;j++)
  3185. {
  3186. value+= channelBuffer[j];
  3187. }
  3188. value/= 40.0;
  3189. if(i==0)
  3190. {
  3191. QList<double> smoothingList;
  3192. smoothingList<<value;
  3193. QList<int> smoothingKeys= smoother.uniqueKeys();
  3194. for(int j= 0;j<smoothingKeys.size();j++)
  3195. {
  3196. if(countList.contains(smoothingKeys[j]))
  3197. {
  3198. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3199. for(int k= 0;k<keyValues.size();k++)
  3200. {
  3201. smoothingList<<keyValues[k];
  3202. }
  3203. }
  3204. else
  3205. {
  3206. smoother.remove(smoothingKeys[j]);
  3207. }
  3208. }
  3209. qSort(countList);
  3210. int lastCount= 0;
  3211. for(int j= 0;j<countList.size();j++)
  3212. {
  3213. if(j==0||countList[j]!=lastCount)
  3214. {
  3215. smoother.insert(countList[j],value);
  3216. lastCount= countList[j];
  3217. }
  3218. }
  3219. value= 0.0;
  3220. for(int j= 0;j<smoothingList.size();j++)
  3221. {
  3222. value+= smoothingList[j];
  3223. }
  3224. value/= smoothingList.size();
  3225. }
  3226. Measurement measure(value,time,unitMap[i]);
  3227. channelMap[i]->input(measure);
  3228. }
  3229. }
  3230. /*:936*//*937:*/
  3231. #line 290 "./dataqsdk.w"
  3232. void DataqSdkDeviceImplementation::run()
  3233. {
  3234. if(!ready)
  3235. {
  3236. error= 9;
  3237. return;
  3238. }
  3239. driver= new QLibrary(device);
  3240. if(!driver->load())
  3241. {
  3242. error= 1;
  3243. qDebug()<<"Failed to load driver: "<<device;
  3244. return;
  3245. }
  3246. di_open= (FPDIOPEN)driver->resolve("di_open");
  3247. di_close= (FPDICLOSE)driver->resolve("di_close");
  3248. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3249. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3250. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3251. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3252. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3253. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3254. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3255. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3256. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3257. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3258. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3259. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3260. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3261. (!di_burst_rate)||(!di_stop_scan))
  3262. {
  3263. error= 2;
  3264. return;
  3265. }
  3266. error= di_open(deviceNumber);
  3267. if(error)
  3268. {
  3269. di_close();
  3270. error= di_open(deviceNumber);
  3271. if(error)
  3272. {
  3273. error= 3;
  3274. di_close();
  3275. return;
  3276. }
  3277. }
  3278. isOpen= true;
  3279. di_maximum_rate(240.0);
  3280. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3281. &burstDivisor);
  3282. buffer= new qint16[(int)sampleRate];
  3283. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3284. for(unsigned short i= 0;i<channels;i++)
  3285. {
  3286. inlist[i].chan= i;
  3287. inlist[i].gain= 0;
  3288. inlist[i].ave= 1;
  3289. inlist[i].counter= (oversample-1);
  3290. }
  3291. error= di_list_length(channels,0);
  3292. if(error)
  3293. {
  3294. error= 4;
  3295. return;
  3296. }
  3297. error= di_inlist(inlist);
  3298. if(error)
  3299. {
  3300. error= 5;
  3301. return;
  3302. }
  3303. input_buffer= di_buffer_alloc(0,4096);
  3304. if(input_buffer==NULL)
  3305. {
  3306. error= 6;
  3307. return;
  3308. }
  3309. error= di_start_scan();
  3310. if(error)
  3311. {
  3312. error= 7;
  3313. return;
  3314. }
  3315. while(ready)
  3316. {
  3317. measure();
  3318. }
  3319. }
  3320. /*:937*//*938:*/
  3321. #line 386 "./dataqsdk.w"
  3322. void DataqSdkDevice::threadFinished()
  3323. {
  3324. if(imp->error)
  3325. {
  3326. /*939:*/
  3327. #line 400 "./dataqsdk.w"
  3328. imp->ready= false;
  3329. QMessageBox warning;
  3330. warning.setStandardButtons(QMessageBox::Cancel);
  3331. warning.setIcon(QMessageBox::Warning);
  3332. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3333. warning.setInformativeText(tr("An error occurred"));
  3334. warning.setWindowTitle(QString(PROGRAM_NAME));
  3335. warning.exec();
  3336. /*:939*/
  3337. #line 391 "./dataqsdk.w"
  3338. }
  3339. }
  3340. /*:938*//*940:*/
  3341. #line 417 "./dataqsdk.w"
  3342. void DataqSdkDevice::start()
  3343. {
  3344. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3345. imp->start();
  3346. }
  3347. /*:940*//*941:*/
  3348. #line 428 "./dataqsdk.w"
  3349. QStringList DataqSdkDevice::detectHardware()
  3350. {
  3351. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3352. QSettings::NativeFormat);
  3353. QStringList keys= deviceLookup.childKeys();
  3354. QStringList devices;
  3355. for(int i= 0;i<keys.size();i++)
  3356. {
  3357. QString value= deviceLookup.value(keys.at(i)).toString();
  3358. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3359. {
  3360. devices.append(value.split("\\").at(2));
  3361. }
  3362. }
  3363. QStringList portList;
  3364. foreach(QString device,devices)
  3365. {
  3366. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3367. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3368. portList.append(deviceEntry.value("FriendlyName").toString());
  3369. }
  3370. return portList;
  3371. }
  3372. QStringList DataqSdkDevice::detectPorts()
  3373. {
  3374. QStringList friendlyNames= detectHardware();
  3375. QStringList portList;
  3376. foreach(QString name,friendlyNames)
  3377. {
  3378. name.remove(0,name.indexOf("COM"));
  3379. name.chop(1);
  3380. portList.append(name);
  3381. }
  3382. return portList;
  3383. }
  3384. /*:941*//*942:*/
  3385. #line 473 "./dataqsdk.w"
  3386. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3387. {
  3388. bool usesAuto= false;
  3389. int autoIndex= device.toInt(&usesAuto);
  3390. QString finalizedPort;
  3391. if(usesAuto)
  3392. {
  3393. QStringList portList= detectPorts();
  3394. if(autoIndex> 0&&autoIndex<=portList.size())
  3395. {
  3396. finalizedPort= portList.at(autoIndex-1);
  3397. }
  3398. else
  3399. {
  3400. imp->error= 8;
  3401. qDebug()<<"Failed to detect port.";
  3402. }
  3403. }
  3404. else
  3405. {
  3406. finalizedPort= device;
  3407. }
  3408. int rstart= finalizedPort.indexOf("COM");
  3409. finalizedPort.remove(0,rstart+3);
  3410. bool chopFinished= false;
  3411. int finalizedPortNumber= 0;
  3412. while(finalizedPort.size()> 0&&!chopFinished)
  3413. {
  3414. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3415. if(!chopFinished)
  3416. {
  3417. finalizedPort.chop(1);
  3418. }
  3419. }
  3420. if(finalizedPortNumber<10)
  3421. {
  3422. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3423. }
  3424. else
  3425. {
  3426. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3427. }
  3428. imp->deviceNumber= 0x12C02D00;
  3429. imp->deviceNumber+= finalizedPortNumber;
  3430. imp->ready= true;
  3431. }
  3432. /*:942*//*943:*/
  3433. #line 523 "./dataqsdk.w"
  3434. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3435. {
  3436. Channel*retval= NULL;
  3437. if(imp->ready)
  3438. {
  3439. retval= new Channel();
  3440. imp->channelMap[imp->channels]= retval;
  3441. imp->unitMap[imp->channels]= scale;
  3442. imp->channels++;
  3443. }
  3444. return retval;
  3445. }
  3446. /*:943*//*944:*/
  3447. #line 547 "./dataqsdk.w"
  3448. void DataqSdkDevice::setClockRate(double Hz)
  3449. {
  3450. imp->sampleRate= Hz;
  3451. }
  3452. /*:944*//*945:*/
  3453. #line 557 "./dataqsdk.w"
  3454. DataqSdkDevice::~DataqSdkDevice()
  3455. {
  3456. if(imp->ready)
  3457. {
  3458. imp->ready= false;
  3459. }
  3460. imp->wait(ULONG_MAX);
  3461. delete imp;
  3462. }
  3463. /*:945*//*946:*/
  3464. #line 575 "./dataqsdk.w"
  3465. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3466. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3467. {
  3468. }
  3469. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3470. {
  3471. if(isOpen)
  3472. {
  3473. di_stop_scan();
  3474. di_close();
  3475. }
  3476. if(driver->isLoaded())
  3477. {
  3478. driver->unload();
  3479. }
  3480. }
  3481. /*:946*/
  3482. #line 541 "./typica.w"
  3483. /*308:*/
  3484. #line 7027 "./typica.w"
  3485. void FakeDAQImplementation::measure()
  3486. {
  3487. msleep((int)(1000/clockRate));
  3488. QTime time= QTime::currentTime();
  3489. for(int i= 0;i<channels;i++)
  3490. {
  3491. Measurement measure(qrand()%500,time);
  3492. channelMap[i]->input(measure);
  3493. }
  3494. }
  3495. /*:308*//*309:*/
  3496. #line 7041 "./typica.w"
  3497. void FakeDAQImplementation::run()
  3498. {
  3499. setPriority(QThread::TimeCriticalPriority);
  3500. while(ready)
  3501. {
  3502. measure();
  3503. }
  3504. }
  3505. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3506. channels(0),ready(false),clockRate(1)
  3507. {
  3508. }
  3509. FakeDAQImplementation::~FakeDAQImplementation()
  3510. {
  3511. }
  3512. /*:309*//*310:*/
  3513. #line 7066 "./typica.w"
  3514. void FakeDAQ::start()
  3515. {
  3516. if(imp->ready)
  3517. {
  3518. imp->start();
  3519. }
  3520. }
  3521. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3522. {
  3523. imp->ready= true;
  3524. }
  3525. Channel*FakeDAQ::newChannel(int,int)
  3526. {
  3527. Channel*retval;
  3528. if(imp->ready)
  3529. {
  3530. retval= new Channel();
  3531. imp->channelMap[imp->channels]= retval;
  3532. imp->channels++;
  3533. }
  3534. else
  3535. {
  3536. return NULL;
  3537. }
  3538. return retval;
  3539. }
  3540. void FakeDAQ::setClockRate(double Hz)
  3541. {
  3542. if(imp->ready)
  3543. {
  3544. imp->clockRate= Hz;
  3545. }
  3546. }
  3547. FakeDAQ::~FakeDAQ()
  3548. {
  3549. imp->ready= false;
  3550. imp->wait(ULONG_MAX);
  3551. delete imp;
  3552. }
  3553. /*:310*/
  3554. #line 542 "./typica.w"
  3555. /*315:*/
  3556. #line 7197 "./typica.w"
  3557. Channel::Channel():QObject(NULL)
  3558. {
  3559. }
  3560. Channel::~Channel()
  3561. {
  3562. }
  3563. void Channel::input(Measurement measurement)
  3564. {
  3565. emit newData(measurement);
  3566. }
  3567. /*:315*/
  3568. #line 543 "./typica.w"
  3569. /*331:*/
  3570. #line 7602 "./typica.w"
  3571. void TemperatureDisplay::setRelativeMode(bool relative)
  3572. {
  3573. r= relative;
  3574. }
  3575. /*:331*//*332:*/
  3576. #line 7619 "./typica.w"
  3577. void TemperatureDisplay::setValue(Measurement temperature)
  3578. {
  3579. QString number;
  3580. switch(unit)
  3581. {
  3582. case Units::Fahrenheit:
  3583. display(QString("%1'F").
  3584. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3585. 2)));
  3586. break;
  3587. case Units::Celsius:
  3588. if(!r){
  3589. display(QString("%1'C").
  3590. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3591. 2)));
  3592. }else{
  3593. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3594. display(QString("%1'C").arg(number));
  3595. }
  3596. break;
  3597. case Units::Kelvin:
  3598. if(!r){
  3599. display(QString("%1").
  3600. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3601. 2)));
  3602. }else{
  3603. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3604. display(QString("%1").arg(number));
  3605. }
  3606. break;
  3607. case Units::Rankine:
  3608. display(QString("%1'r").
  3609. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3610. 2)));
  3611. break;
  3612. case Units::Unitless:
  3613. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3614. break;
  3615. default:
  3616. switch(temperature.scale())
  3617. {
  3618. case Units::Fahrenheit:
  3619. display(QString("%1'F").
  3620. arg(number.setNum(temperature.temperature(),'f',2)));
  3621. break;
  3622. case Units::Celsius:
  3623. display(QString("%1'C").
  3624. arg(number.setNum(temperature.temperature(),'f',2)));
  3625. break;
  3626. case Units::Kelvin:
  3627. display(QString("%1").
  3628. arg(number.setNum(temperature.temperature(),'f',2)));
  3629. break;
  3630. case Units::Rankine:
  3631. display(QString("%1'r").
  3632. arg(number.setNum(temperature.temperature(),'f',2)));
  3633. break;
  3634. case Units::Unitless:
  3635. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3636. break;
  3637. }
  3638. break;
  3639. }
  3640. }
  3641. /*:332*//*333:*/
  3642. #line 7695 "./typica.w"
  3643. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3644. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3645. {
  3646. setSegmentStyle(Filled);
  3647. display("---.--'F");
  3648. }
  3649. /*:333*//*334:*/
  3650. #line 7711 "./typica.w"
  3651. void TemperatureDisplay::invalidate()
  3652. {
  3653. display("---.--'F");
  3654. }
  3655. /*:334*//*335:*/
  3656. #line 7723 "./typica.w"
  3657. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3658. {
  3659. unit= scale;
  3660. }
  3661. /*:335*//*336:*/
  3662. #line 7731 "./typica.w"
  3663. TemperatureDisplay::~TemperatureDisplay()
  3664. {
  3665. }
  3666. /*:336*/
  3667. #line 544 "./typica.w"
  3668. /*342:*/
  3669. #line 7831 "./typica.w"
  3670. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3671. {
  3672. if(measure.time()<epoch)
  3673. {
  3674. if(hasPrevious)
  3675. {
  3676. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3677. epoch.msec());
  3678. QTime jitComp(epoch.hour(),measure.time().minute(),
  3679. measure.time().second(),measure.time().msec());
  3680. int relTime= jitBase.msecsTo(jitComp);
  3681. /*343:*/
  3682. #line 7865 "./typica.w"
  3683. QTime newTime(0,0,0,0);
  3684. newTime= newTime.addMSecs(relTime);
  3685. if(newTime.hour()> 0)
  3686. {
  3687. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3688. }
  3689. Measurement rel= measure;
  3690. rel.setTime(newTime);
  3691. emit measurement(rel);
  3692. /*:343*/
  3693. #line 7843 "./typica.w"
  3694. }
  3695. else
  3696. {
  3697. Measurement rel= measure;
  3698. rel.setTime(QTime(0,0,0,0));
  3699. emit measurement(rel);
  3700. }
  3701. }
  3702. else
  3703. {
  3704. int relTime= epoch.msecsTo(measure.time());
  3705. /*343:*/
  3706. #line 7865 "./typica.w"
  3707. QTime newTime(0,0,0,0);
  3708. newTime= newTime.addMSecs(relTime);
  3709. if(newTime.hour()> 0)
  3710. {
  3711. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3712. }
  3713. Measurement rel= measure;
  3714. rel.setTime(newTime);
  3715. emit measurement(rel);
  3716. /*:343*/
  3717. #line 7855 "./typica.w"
  3718. }
  3719. hasPrevious= true;
  3720. previous= measure.time();
  3721. }
  3722. /*:342*//*344:*/
  3723. #line 7878 "./typica.w"
  3724. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3725. previous(0,0,0,0),hasPrevious(false)
  3726. {
  3727. }
  3728. QTime MeasurementTimeOffset::zeroTime()
  3729. {
  3730. return epoch;
  3731. }
  3732. void MeasurementTimeOffset::setZeroTime(QTime zero)
  3733. {
  3734. epoch= zero;
  3735. hasPrevious= false;
  3736. }
  3737. /*:344*/
  3738. #line 545 "./typica.w"
  3739. /*354:*/
  3740. #line 8076 "./typica.w"
  3741. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  3742. {
  3743. }
  3744. int ZeroEmitter::column()
  3745. {
  3746. return col;
  3747. }
  3748. double ZeroEmitter::lastTemperature()
  3749. {
  3750. return cache.temperature();
  3751. }
  3752. void ZeroEmitter::newMeasurement(Measurement measure)
  3753. {
  3754. cache= measure;
  3755. }
  3756. void ZeroEmitter::setColumn(int column)
  3757. {
  3758. col= column;
  3759. }
  3760. void ZeroEmitter::emitZero()
  3761. {
  3762. cache.setTime(QTime(0,0,0,0));
  3763. emit measurement(cache,col);
  3764. }
  3765. /*:354*/
  3766. #line 546 "./typica.w"
  3767. /*359:*/
  3768. #line 8166 "./typica.w"
  3769. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  3770. {
  3771. }
  3772. int MeasurementAdapter::column()
  3773. {
  3774. return col;
  3775. }
  3776. void MeasurementAdapter::newMeasurement(Measurement measure)
  3777. {
  3778. emit measurement(measure,col);
  3779. }
  3780. void MeasurementAdapter::setColumn(int column)
  3781. {
  3782. col= column;
  3783. }
  3784. /*:359*/
  3785. #line 547 "./typica.w"
  3786. /*364:*/
  3787. #line 8288 "./typica.w"
  3788. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  3789. theScene(new QGraphicsScene),
  3790. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  3791. prevPoints(new QMap<int,QPointF> ),
  3792. translations(new QMap<int,double> ),
  3793. gridLinesF(new QList<QGraphicsItem*> ),
  3794. gridLinesC(new QList<QGraphicsItem*> ),
  3795. relativeGridLines(new QList<QGraphicsItem*> ),
  3796. relativeEnabled(false),
  3797. timeIndicatorEnabled(false),
  3798. timeLine(new QGraphicsLineItem),
  3799. relativeAdjuster(new LinearSplineInterpolator)
  3800. {
  3801. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3802. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3803. setScene(theScene);
  3804. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  3805. QPen timePen;
  3806. timePen.setColor(QColor(160,160,164,127));
  3807. timeLine->setPen(timePen);
  3808. timeLine->setLine(0,0,0,-500);
  3809. timeLine->hide();
  3810. theScene->addItem(timeLine);
  3811. /*365:*/
  3812. #line 8328 "./typica.w"
  3813. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  3814. tempaxis->setLine(-10,-500,-10,0);
  3815. theScene->addItem(tempaxis);
  3816. QGraphicsLineItem*gridLine;
  3817. QGraphicsTextItem*label;
  3818. for(int y= -100;y> -600;y-= 100)
  3819. {
  3820. gridLine= new QGraphicsLineItem;
  3821. gridLine->setLine(0,y,1200,y);
  3822. theScene->addItem(gridLine);
  3823. label= new QGraphicsTextItem;
  3824. label->setHtml(QString("%1&deg;F").arg(-y));
  3825. label->setPos(-55,y-(label->boundingRect().height()/2));
  3826. theScene->addItem(label);
  3827. gridLinesF->append(gridLine);
  3828. gridLinesF->append(label);
  3829. }
  3830. for(int degC= 50;degC<=250;degC+= 50)
  3831. {
  3832. gridLine= new QGraphicsLineItem;
  3833. int y= -(degC*(9.0/5.0)+32);
  3834. gridLine->setLine(0,y,1200,y);
  3835. gridLine->hide();
  3836. theScene->addItem(gridLine);
  3837. gridLinesC->append(gridLine);
  3838. label= new QGraphicsTextItem;
  3839. label->setHtml(QString("%1&deg;C").arg(degC));
  3840. label->setPos(-55,y-(label->boundingRect().height()/2));
  3841. label->hide();
  3842. theScene->addItem(label);
  3843. gridLinesC->append(label);
  3844. }
  3845. /*:365*/
  3846. #line 8312 "./typica.w"
  3847. ;
  3848. /*366:*/
  3849. #line 8369 "./typica.w"
  3850. QSettings settings;
  3851. if(settings.contains("settings/graph/relative/enable"))
  3852. {
  3853. if(settings.value("settings/graph/relative/enable").toBool())
  3854. {
  3855. relativeEnabled= true;
  3856. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  3857. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  3858. QMap<double,QString> relativeAxisPairs;
  3859. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  3860. foreach(QString item,relativeAxisLabels)
  3861. {
  3862. relativeAxisPairs.insert(item.toDouble(),item);
  3863. }
  3864. if(relativeAxisPairs.size()> 1)
  3865. {
  3866. double skip= 500.0/(relativeAxisPairs.size()-1);
  3867. double y= 0;
  3868. foreach(double key,relativeAxisPairs.keys())
  3869. {
  3870. gridLine= new QGraphicsLineItem;
  3871. gridLine->setLine(0,y,1205,y);
  3872. gridLine->setPen(QPen(relativeColor));
  3873. theScene->addItem(gridLine);
  3874. relativeGridLines->append(gridLine);
  3875. label= new QGraphicsTextItem;
  3876. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  3877. label->setPos(1210,y-(label->boundingRect().height()/2));
  3878. theScene->addItem(label);
  3879. relativeGridLines->append(label);
  3880. if(unit=="F")
  3881. {
  3882. relativeAdjuster->add_pair(key,-y);
  3883. }
  3884. else
  3885. {
  3886. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  3887. }
  3888. y-= skip;
  3889. }
  3890. }
  3891. }
  3892. }
  3893. /*:366*/
  3894. #line 8313 "./typica.w"
  3895. /*368:*/
  3896. #line 8446 "./typica.w"
  3897. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  3898. timeaxis->setLine(0,10,1200,10);
  3899. theScene->addItem(timeaxis);
  3900. for(int x= 0;x<1201;x+= 120)
  3901. {
  3902. QGraphicsLineItem*tick= new QGraphicsLineItem;
  3903. tick->setLine(x,0,x,20);
  3904. theScene->addItem(tick);
  3905. QGraphicsTextItem*label= new QGraphicsTextItem;
  3906. label->setPlainText(QString("%1").arg(x/60));
  3907. label->setPos(x-(label->boundingRect().width()/2),20);
  3908. theScene->addItem(label);
  3909. }
  3910. /*:368*/
  3911. #line 8314 "./typica.w"
  3912. ;
  3913. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3914. }
  3915. /*:364*//*367:*/
  3916. #line 8416 "./typica.w"
  3917. void GraphView::showF()
  3918. {
  3919. for(int i= 0;i<gridLinesF->size();i++)
  3920. {
  3921. gridLinesF->at(i)->show();
  3922. }
  3923. for(int i= 0;i<gridLinesC->size();i++)
  3924. {
  3925. gridLinesC->at(i)->hide();
  3926. }
  3927. }
  3928. void GraphView::showC()
  3929. {
  3930. for(int i= 0;i<gridLinesF->size();i++)
  3931. {
  3932. gridLinesF->at(i)->hide();
  3933. }
  3934. for(int i= 0;i<gridLinesC->size();i++)
  3935. {
  3936. gridLinesC->at(i)->show();
  3937. }
  3938. }
  3939. /*:367*//*369:*/
  3940. #line 8465 "./typica.w"
  3941. void GraphView::resizeEvent(QResizeEvent*)
  3942. {
  3943. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3944. }
  3945. /*:369*//*370:*/
  3946. #line 8479 "./typica.w"
  3947. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  3948. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  3949. {
  3950. double offset= 0;
  3951. if(measure.contains("relative"))
  3952. {
  3953. if(measure.value("relative").toBool())
  3954. {
  3955. if(relativeEnabled)
  3956. {
  3957. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  3958. }
  3959. else
  3960. {
  3961. return;
  3962. }
  3963. }
  3964. }
  3965. if(translations->contains(tempcolumn))
  3966. {
  3967. offset= translations->value(tempcolumn);
  3968. }
  3969. if(prevPoints->contains(tempcolumn))
  3970. {
  3971. /*372:*/
  3972. #line 8556 "./typica.w"
  3973. QGraphicsLineItem*segment= new QGraphicsLineItem;
  3974. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  3975. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  3976. -(prevPoints->value(tempcolumn).y()),
  3977. nextPoint.x()+offset,-(nextPoint.y()));
  3978. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  3979. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  3980. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  3981. Qt::darkYellow};
  3982. segment->setPen(p[tempcolumn%12]);
  3983. theScene->addItem(segment);
  3984. prevPoints->insert(tempcolumn,nextPoint);
  3985. if(timeIndicatorEnabled)
  3986. {
  3987. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  3988. }
  3989. /*:372*/
  3990. #line 8505 "./typica.w"
  3991. if(graphLines->contains(tempcolumn))
  3992. {
  3993. graphLines->value(tempcolumn)->append(segment);
  3994. }
  3995. else
  3996. {
  3997. QList<QGraphicsLineItem*> *newLine=
  3998. new QList<QGraphicsLineItem*> ;
  3999. newLine->append(segment);
  4000. graphLines->insert(tempcolumn,newLine);
  4001. }
  4002. }
  4003. else
  4004. {
  4005. /*371:*/
  4006. #line 8541 "./typica.w"
  4007. int x= FULLTIMETOINT(measure.time())/1000;
  4008. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4009. if(timeIndicatorEnabled)
  4010. {
  4011. timeLine->setLine(x,0,x,-500);
  4012. }
  4013. /*:371*/
  4014. #line 8522 "./typica.w"
  4015. }
  4016. }
  4017. /*:370*//*373:*/
  4018. #line 8577 "./typica.w"
  4019. void GraphView::clear()
  4020. {
  4021. int i;
  4022. foreach(i,prevPoints->keys())
  4023. {
  4024. removeSeries(i);
  4025. }
  4026. translations->clear();
  4027. }
  4028. /*:373*//*374:*/
  4029. #line 8591 "./typica.w"
  4030. void GraphView::removeSeries(int column)
  4031. {
  4032. if(graphLines->contains(column))
  4033. {
  4034. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4035. QGraphicsLineItem*segment;
  4036. foreach(segment,*series)
  4037. {
  4038. theScene->removeItem(segment);
  4039. }
  4040. qDeleteAll(*series);
  4041. }
  4042. graphLines->remove(column);
  4043. prevPoints->remove(column);
  4044. }
  4045. /*:374*//*375:*/
  4046. #line 8610 "./typica.w"
  4047. void GraphView::setSeriesTranslation(int column,double offset)
  4048. {
  4049. if(graphLines->contains(column))
  4050. {
  4051. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4052. QGraphicsLineItem*segment;
  4053. foreach(segment,*series)
  4054. {
  4055. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4056. }
  4057. }
  4058. if(translations->contains(column))
  4059. {
  4060. translations->insert(column,offset+translations->value(column));
  4061. }
  4062. else
  4063. {
  4064. translations->insert(column,offset);
  4065. }
  4066. }
  4067. /*:375*//*376:*/
  4068. #line 8637 "./typica.w"
  4069. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4070. {
  4071. timeIndicatorEnabled= enabled;
  4072. if(enabled)
  4073. {
  4074. timeLine->show();
  4075. }
  4076. else
  4077. {
  4078. timeLine->hide();
  4079. }
  4080. }
  4081. /*:376*/
  4082. #line 548 "./typica.w"
  4083. /*382:*/
  4084. #line 8781 "./typica.w"
  4085. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4086. {
  4087. if(measure.time()!=QTime(0,0,0,0))
  4088. {
  4089. /*384:*/
  4090. #line 8855 "./typica.w"
  4091. if(lastMeasurement.contains(tempcolumn))
  4092. {
  4093. if(lastMeasurement[tempcolumn].time()<measure.time())
  4094. {
  4095. QList<QTime> timelist;
  4096. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4097. {
  4098. timelist.append(i);
  4099. }
  4100. for(int i= 0;i<timelist.size();i++)
  4101. {
  4102. Measurement synthesized= measure;
  4103. synthesized.setTime(timelist[i]);
  4104. newMeasurement(synthesized,tempcolumn);
  4105. }
  4106. }
  4107. }
  4108. /*:384*/
  4109. #line 8786 "./typica.w"
  4110. }
  4111. model_ms->newMeasurement(measure,tempcolumn);
  4112. if(lastMeasurement.contains(tempcolumn))
  4113. {
  4114. if(measure.time().second()!=
  4115. lastMeasurement.value(tempcolumn).time().second())
  4116. {
  4117. Measurement adjusted= measure;
  4118. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4119. adjusted.setTime(adjtime);
  4120. model_1s->newMeasurement(adjusted,tempcolumn);
  4121. if(adjusted.time().second()%5==0)
  4122. {
  4123. model_5s->newMeasurement(adjusted,tempcolumn);
  4124. if(adjusted.time().second()%10==0)
  4125. {
  4126. model_10s->newMeasurement(adjusted,tempcolumn);
  4127. }
  4128. if(adjusted.time().second()%15==0)
  4129. {
  4130. model_15s->newMeasurement(adjusted,tempcolumn);
  4131. if(adjusted.time().second()%30==0)
  4132. {
  4133. model_30s->newMeasurement(adjusted,tempcolumn);
  4134. if(adjusted.time().second()==0)
  4135. {
  4136. model_1m->newMeasurement(adjusted,tempcolumn);
  4137. }
  4138. }
  4139. }
  4140. }
  4141. }
  4142. /*386:*/
  4143. #line 8899 "./typica.w"
  4144. if(currentColumnSet.contains(tempcolumn))
  4145. {
  4146. int replicationcolumn;
  4147. foreach(replicationcolumn,currentColumnSet)
  4148. {
  4149. if(replicationcolumn!=tempcolumn)
  4150. {
  4151. if(lastMeasurement.contains(replicationcolumn))
  4152. {
  4153. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4154. {
  4155. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4156. synthetic.setTime(measure.time());
  4157. model_ms->newMeasurement(synthetic,replicationcolumn);
  4158. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4159. {
  4160. Measurement adjusted= synthetic;
  4161. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4162. model_1s->newMeasurement(adjusted,replicationcolumn);
  4163. if(adjusted.time().second()%5==0)
  4164. {
  4165. model_5s->newMeasurement(adjusted,replicationcolumn);
  4166. if(adjusted.time().second()%10==0)
  4167. {
  4168. model_10s->newMeasurement(adjusted,replicationcolumn);
  4169. }
  4170. if(adjusted.time().second()%15==0)
  4171. {
  4172. model_15s->newMeasurement(adjusted,replicationcolumn);
  4173. if(adjusted.time().second()%30==0)
  4174. {
  4175. model_30s->newMeasurement(adjusted,replicationcolumn);
  4176. if(adjusted.time().second()==0)
  4177. {
  4178. model_1m->newMeasurement(adjusted,replicationcolumn);
  4179. }
  4180. }
  4181. }
  4182. }
  4183. }
  4184. lastMeasurement[replicationcolumn]= synthetic;
  4185. }
  4186. }
  4187. }
  4188. }
  4189. }
  4190. /*:386*/
  4191. #line 8819 "./typica.w"
  4192. }
  4193. else
  4194. {
  4195. /*383:*/
  4196. #line 8831 "./typica.w"
  4197. MeasurementModel*m;
  4198. foreach(m,modelSet)
  4199. {
  4200. m->newMeasurement(measure,tempcolumn);
  4201. }
  4202. /*:383*/
  4203. #line 8823 "./typica.w"
  4204. }
  4205. lastMeasurement.insert(tempcolumn,measure);
  4206. }
  4207. /*:382*//*385:*/
  4208. #line 8885 "./typica.w"
  4209. void ZoomLog::addToCurrentColumnSet(int column)
  4210. {
  4211. currentColumnSet.append(column);
  4212. }
  4213. void ZoomLog::clearCurrentColumnSet()
  4214. {
  4215. currentColumnSet.clear();
  4216. }
  4217. /*:385*//*387:*/
  4218. #line 8969 "./typica.w"
  4219. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4220. int annotationcolumn)
  4221. {
  4222. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4223. MeasurementModel*m;
  4224. if(lastMeasurement.contains(tempcolumn))
  4225. {
  4226. foreach(m,modelSet)
  4227. {
  4228. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4229. }
  4230. }
  4231. foreach(m,modelSet)
  4232. {
  4233. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4234. }
  4235. }
  4236. /*:387*//*388:*/
  4237. #line 8993 "./typica.w"
  4238. void ZoomLog::centerOn(int row)
  4239. {
  4240. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4241. }
  4242. /*:388*//*389:*/
  4243. #line 9003 "./typica.w"
  4244. void ZoomLog::clear()
  4245. {
  4246. MeasurementModel*m;
  4247. foreach(m,modelSet)
  4248. {
  4249. m->clear();
  4250. }
  4251. lastMeasurement.clear();
  4252. saveTempCols.clear();
  4253. saveControlCols.clear();
  4254. saveNoteCols.clear();
  4255. }
  4256. /*:389*//*390:*/
  4257. #line 9021 "./typica.w"
  4258. QVariant ZoomLog::data(int row,int column)const
  4259. {
  4260. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4261. Qt::DisplayRole);
  4262. }
  4263. int ZoomLog::rowCount()
  4264. {
  4265. return model_ms->rowCount();
  4266. }
  4267. /*:390*//*391:*/
  4268. #line 9044 "./typica.w"
  4269. bool ZoomLog::saveXML(QIODevice*device)
  4270. {
  4271. Units::Unit prevUnits= model_ms->displayUnits();
  4272. if(prevUnits!=Units::Fahrenheit)
  4273. {
  4274. model_ms->setDisplayUnits(Units::Fahrenheit);
  4275. }
  4276. XMLOutput writer(model_ms,device,0);
  4277. int c;
  4278. foreach(c,saveTempCols)
  4279. {
  4280. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4281. toString(),c);
  4282. }
  4283. foreach(c,saveControlCols)
  4284. {
  4285. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4286. toString(),c);
  4287. }
  4288. foreach(c,saveNoteCols)
  4289. {
  4290. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4291. toString(),c);
  4292. }
  4293. bool retval= writer.output();
  4294. if(prevUnits!=Units::Fahrenheit)
  4295. {
  4296. model_ms->setDisplayUnits(prevUnits);
  4297. }
  4298. return retval;
  4299. }
  4300. /*:391*//*392:*/
  4301. #line 9080 "./typica.w"
  4302. bool ZoomLog::saveCSV(QIODevice*device)
  4303. {
  4304. CSVOutput writer(currentModel,device,0);
  4305. int c;
  4306. foreach(c,saveTempCols)
  4307. {
  4308. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4309. toString(),c);
  4310. }
  4311. foreach(c,saveControlCols)
  4312. {
  4313. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4314. toString(),c);
  4315. }
  4316. foreach(c,saveNoteCols)
  4317. {
  4318. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4319. toString(),c);
  4320. }
  4321. return writer.output();
  4322. }
  4323. /*:392*//*393:*/
  4324. #line 9109 "./typica.w"
  4325. void ZoomLog::switchLOD(MeasurementModel*m)
  4326. {
  4327. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4328. setModel(m);
  4329. currentModel= m;
  4330. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4331. }
  4332. void ZoomLog::LOD_ms()
  4333. {
  4334. switchLOD(model_ms);
  4335. }
  4336. void ZoomLog::LOD_1s()
  4337. {
  4338. switchLOD(model_1s);
  4339. }
  4340. void ZoomLog::LOD_5s()
  4341. {
  4342. switchLOD(model_5s);
  4343. }
  4344. void ZoomLog::LOD_10s()
  4345. {
  4346. switchLOD(model_10s);
  4347. }
  4348. void ZoomLog::LOD_15s()
  4349. {
  4350. switchLOD(model_15s);
  4351. }
  4352. void ZoomLog::LOD_30s()
  4353. {
  4354. switchLOD(model_30s);
  4355. }
  4356. void ZoomLog::LOD_1m()
  4357. {
  4358. switchLOD(model_1m);
  4359. }
  4360. /*:393*//*394:*/
  4361. #line 9157 "./typica.w"
  4362. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4363. {
  4364. model_ms->setDisplayUnits(scale);
  4365. model_1s->setDisplayUnits(scale);
  4366. model_5s->setDisplayUnits(scale);
  4367. model_10s->setDisplayUnits(scale);
  4368. model_15s->setDisplayUnits(scale);
  4369. model_30s->setDisplayUnits(scale);
  4370. model_1m->setDisplayUnits(scale);
  4371. }
  4372. Units::Unit ZoomLog::displayUnits()
  4373. {
  4374. return model_ms->displayUnits();
  4375. }
  4376. /*:394*//*395:*/
  4377. #line 9177 "./typica.w"
  4378. QString ZoomLog::lastTime(int series)
  4379. {
  4380. Measurement measure= lastMeasurement.value(series);
  4381. QTime time= measure.time();
  4382. return time.toString("h:mm:ss.zzz");
  4383. }
  4384. /*:395*//*396:*/
  4385. #line 9187 "./typica.w"
  4386. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4387. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4388. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4389. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4390. {
  4391. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4392. setSelectionMode(QAbstractItemView::NoSelection);
  4393. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4394. model_30s<<model_1m;
  4395. currentModel= model_30s;
  4396. setModel(currentModel);
  4397. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4398. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4399. this,SLOT(persistColumnResize(int,int,int)));
  4400. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4401. this,SLOT(restoreColumnWidths()));
  4402. }
  4403. /*:396*//*397:*/
  4404. #line 9210 "./typica.w"
  4405. void ZoomLog::setHeaderData(int section,QString text)
  4406. {
  4407. MeasurementModel*m;
  4408. foreach(m,modelSet)
  4409. {
  4410. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4411. }
  4412. }
  4413. /*:397*//*398:*/
  4414. #line 9228 "./typica.w"
  4415. void ZoomLog::addOutputTemperatureColumn(int column)
  4416. {
  4417. saveTempCols.append(column);
  4418. }
  4419. void ZoomLog::addOutputControlColumn(int column)
  4420. {
  4421. saveControlCols.append(column);
  4422. }
  4423. void ZoomLog::addOutputAnnotationColumn(int column)
  4424. {
  4425. saveNoteCols.append(column);
  4426. }
  4427. void ZoomLog::clearOutputColumns()
  4428. {
  4429. saveTempCols.clear();
  4430. saveControlCols.clear();
  4431. saveNoteCols.clear();
  4432. }
  4433. /*:398*//*399:*/
  4434. #line 9254 "./typica.w"
  4435. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4436. {
  4437. /*613:*/
  4438. #line 13359 "./typica.w"
  4439. QSettings settings;
  4440. /*614:*/
  4441. #line 13372 "./typica.w"
  4442. QWidget*topLevelWidget= this;
  4443. while(topLevelWidget->parentWidget())
  4444. {
  4445. topLevelWidget= topLevelWidget->parentWidget();
  4446. }
  4447. /*:614*/
  4448. #line 13361 "./typica.w"
  4449. settings.setValue(QString("columnWidths/%1/%2/%3").
  4450. arg(topLevelWidget->objectName()).
  4451. arg(objectName()).arg(column),
  4452. QVariant(newsize));
  4453. /*:613*/
  4454. #line 9257 "./typica.w"
  4455. }
  4456. void ZoomLog::restoreColumnWidths()
  4457. {
  4458. /*616:*/
  4459. #line 13392 "./typica.w"
  4460. QSettings settings;
  4461. /*614:*/
  4462. #line 13372 "./typica.w"
  4463. QWidget*topLevelWidget= this;
  4464. while(topLevelWidget->parentWidget())
  4465. {
  4466. topLevelWidget= topLevelWidget->parentWidget();
  4467. }
  4468. /*:614*/
  4469. #line 13394 "./typica.w"
  4470. QString baseKey=
  4471. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4472. arg(objectName());
  4473. for(int i= 0;i<model()->columnCount();i++)
  4474. {
  4475. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4476. if(settings.contains(key))
  4477. {
  4478. setColumnWidth(i,settings.value(key).toInt());
  4479. }
  4480. }
  4481. /*:616*/
  4482. #line 9262 "./typica.w"
  4483. }
  4484. void ZoomLog::setVisible(bool visibility)
  4485. {
  4486. QTableView::setVisible(visibility);
  4487. }
  4488. void ZoomLog::showEvent(QShowEvent*)
  4489. {
  4490. /*616:*/
  4491. #line 13392 "./typica.w"
  4492. QSettings settings;
  4493. /*614:*/
  4494. #line 13372 "./typica.w"
  4495. QWidget*topLevelWidget= this;
  4496. while(topLevelWidget->parentWidget())
  4497. {
  4498. topLevelWidget= topLevelWidget->parentWidget();
  4499. }
  4500. /*:614*/
  4501. #line 13394 "./typica.w"
  4502. QString baseKey=
  4503. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4504. arg(objectName());
  4505. for(int i= 0;i<model()->columnCount();i++)
  4506. {
  4507. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4508. if(settings.contains(key))
  4509. {
  4510. setColumnWidth(i,settings.value(key).toInt());
  4511. }
  4512. }
  4513. /*:616*/
  4514. #line 9272 "./typica.w"
  4515. }
  4516. /*:399*/
  4517. #line 549 "./typica.w"
  4518. /*408:*/
  4519. #line 9505 "./typica.w"
  4520. bool MeasurementList::operator<(const MeasurementList&other)const
  4521. {
  4522. return this->first().toTime()<other.first().toTime();
  4523. }
  4524. bool MeasurementList::operator==(const MeasurementList&other)const
  4525. {
  4526. return this->first().toTime()==other.first().toTime();
  4527. }
  4528. /*:408*//*409:*/
  4529. #line 9521 "./typica.w"
  4530. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4531. {
  4532. return QModelIndex();
  4533. }
  4534. /*:409*//*410:*/
  4535. #line 9531 "./typica.w"
  4536. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4537. {
  4538. if(measure.scale()==Units::Unitless)
  4539. {
  4540. controlColumns->insert(tempcolumn,true);
  4541. }
  4542. else
  4543. {
  4544. controlColumns->insert(tempcolumn,false);
  4545. }
  4546. MeasurementList*temp;
  4547. temp= new MeasurementList;
  4548. temp->append(QVariant(measure.time()));
  4549. /*411:*/
  4550. #line 9590 "./typica.w"
  4551. /*412:*/
  4552. #line 9635 "./typica.w"
  4553. QList<MeasurementList*> ::iterator i= lastInsertion;
  4554. bool quickscan= false;
  4555. if(entries->size()> 5)
  4556. {
  4557. if(**i<*temp)
  4558. {
  4559. i+= 1;
  4560. for(int j= 10;j> 0;j--)
  4561. {
  4562. if(i!=entries->end())
  4563. {
  4564. if(**i<*temp)
  4565. {
  4566. i+= 1;
  4567. }
  4568. else
  4569. {
  4570. quickscan= true;
  4571. break;
  4572. }
  4573. }
  4574. else
  4575. {
  4576. quickscan= true;
  4577. break;
  4578. }
  4579. }
  4580. }
  4581. else
  4582. {
  4583. if(**i==*temp)
  4584. {
  4585. quickscan= true;
  4586. }
  4587. }
  4588. }
  4589. /*:412*/
  4590. #line 9591 "./typica.w"
  4591. if(quickscan==false)
  4592. {
  4593. i= entries->begin();
  4594. QList<MeasurementList*> ::iterator u= entries->end();
  4595. QList<MeasurementList*> ::iterator midpoint;
  4596. int n= u-i;
  4597. int rA;
  4598. while(n> 0)
  4599. {
  4600. rA= n>>1;
  4601. midpoint= i+rA;
  4602. if(**midpoint<*temp)
  4603. {
  4604. i= midpoint+1;
  4605. n-= rA+1;
  4606. }
  4607. else
  4608. {
  4609. n= rA;
  4610. }
  4611. }
  4612. }
  4613. /*:411*/
  4614. #line 9545 "./typica.w"
  4615. MeasurementList*newEntry;
  4616. int insertion;
  4617. if(i!=entries->end())
  4618. {
  4619. insertion= entries->indexOf(*i);
  4620. if((*i)->first().toTime()==measure.time())
  4621. {
  4622. /*413:*/
  4623. #line 9677 "./typica.w"
  4624. if((*i)->size()<tempcolumn+1)
  4625. {
  4626. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4627. {
  4628. (*i)->append(QVariant());
  4629. }
  4630. }
  4631. (*i)->replace(tempcolumn,measure);
  4632. lastInsertion= i;
  4633. emit dataChanged(createIndex(insertion,tempcolumn),
  4634. createIndex(insertion,tempcolumn));
  4635. lastTemperature->insert(tempcolumn,insertion);
  4636. /*:413*/
  4637. #line 9553 "./typica.w"
  4638. }
  4639. else
  4640. {
  4641. /*414:*/
  4642. #line 9695 "./typica.w"
  4643. beginInsertRows(QModelIndex(),insertion,insertion);
  4644. newEntry= new MeasurementList;
  4645. newEntry->append(QVariant(measure.time()));
  4646. for(int j= 0;j<tempcolumn+1;j++)
  4647. {
  4648. newEntry->append(QVariant());
  4649. }
  4650. newEntry->replace(tempcolumn,measure);
  4651. lastInsertion= entries->insert(i,newEntry);
  4652. endInsertRows();
  4653. lastTemperature->insert(tempcolumn,insertion);
  4654. /*:414*/
  4655. #line 9557 "./typica.w"
  4656. }
  4657. }
  4658. else
  4659. {
  4660. /*415:*/
  4661. #line 9713 "./typica.w"
  4662. insertion= entries->size();
  4663. /*414:*/
  4664. #line 9695 "./typica.w"
  4665. beginInsertRows(QModelIndex(),insertion,insertion);
  4666. newEntry= new MeasurementList;
  4667. newEntry->append(QVariant(measure.time()));
  4668. for(int j= 0;j<tempcolumn+1;j++)
  4669. {
  4670. newEntry->append(QVariant());
  4671. }
  4672. newEntry->replace(tempcolumn,measure);
  4673. lastInsertion= entries->insert(i,newEntry);
  4674. endInsertRows();
  4675. lastTemperature->insert(tempcolumn,insertion);
  4676. /*:414*/
  4677. #line 9715 "./typica.w"
  4678. /*:415*/
  4679. #line 9562 "./typica.w"
  4680. }
  4681. if(tempcolumn>=colcount)
  4682. {
  4683. colcount= tempcolumn+1;
  4684. }
  4685. emit rowChanged(insertion);
  4686. delete temp;
  4687. }
  4688. /*:410*//*416:*/
  4689. #line 9725 "./typica.w"
  4690. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4691. int annotationColumn)
  4692. {
  4693. int r;
  4694. if(lastTemperature->contains(tempcolumn))
  4695. {
  4696. r= lastTemperature->value(tempcolumn);
  4697. }
  4698. else
  4699. {
  4700. r= 0;
  4701. }
  4702. if(r==0&&entries->size()==0)
  4703. {
  4704. /*417:*/
  4705. #line 9763 "./typica.w"
  4706. beginInsertRows(QModelIndex(),0,0);
  4707. MeasurementList*newEntry= new MeasurementList;
  4708. newEntry->append(QVariant(QTime(0,0,0,0)));
  4709. entries->append(newEntry);
  4710. endInsertRows();
  4711. /*:417*/
  4712. #line 9740 "./typica.w"
  4713. }
  4714. MeasurementList*row= entries->at(r);
  4715. if(row->size()<=annotationColumn)
  4716. {
  4717. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4718. {
  4719. row->append(QVariant());
  4720. }
  4721. }
  4722. row->replace(annotationColumn,annotation);
  4723. emit dataChanged(createIndex(r,annotationColumn),
  4724. createIndex(r,annotationColumn));
  4725. emit rowChanged(r);
  4726. if(annotationColumn> colcount-1)
  4727. {
  4728. colcount= annotationColumn+1;
  4729. }
  4730. }
  4731. /*:416*//*418:*/
  4732. #line 9774 "./typica.w"
  4733. void MeasurementModel::clear()
  4734. {
  4735. beginRemoveRows(QModelIndex(),0,entries->size());
  4736. while(entries->size()!=0)
  4737. {
  4738. MeasurementList*row= entries->takeFirst();
  4739. delete row;
  4740. }
  4741. endRemoveRows();
  4742. colcount= hData->size();
  4743. lastTemperature->clear();
  4744. reset();
  4745. }
  4746. /*:418*//*419:*/
  4747. #line 9807 "./typica.w"
  4748. bool MeasurementModel::setData(const QModelIndex&index,
  4749. const QVariant&value,int role)
  4750. {
  4751. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  4752. {
  4753. return false;
  4754. }
  4755. /*420:*/
  4756. #line 9839 "./typica.w"
  4757. bool valid= false;
  4758. if(index.isValid())
  4759. {
  4760. if(index.row()<entries->size())
  4761. {
  4762. if(index.column()<colcount)
  4763. {
  4764. valid= true;
  4765. }
  4766. }
  4767. }
  4768. /*:420*/
  4769. #line 9815 "./typica.w"
  4770. if(!valid)
  4771. {
  4772. return false;
  4773. }
  4774. MeasurementList*row= entries->at(index.row());
  4775. if(index.column()>=row->size())
  4776. {
  4777. /*421:*/
  4778. #line 9856 "./typica.w"
  4779. for(int i= row->size()-1;i<index.column();i++)
  4780. {
  4781. row->append(QVariant());
  4782. }
  4783. /*:421*/
  4784. #line 9823 "./typica.w"
  4785. }
  4786. if(index.column()==0)
  4787. {
  4788. /*422:*/
  4789. #line 9871 "./typica.w"
  4790. QTime time;
  4791. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  4792. {
  4793. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  4794. {
  4795. return false;
  4796. }
  4797. }
  4798. row= entries->takeAt(index.row());
  4799. row->replace(index.column(),QVariant(time));
  4800. MeasurementList*temp= row;
  4801. /*411:*/
  4802. #line 9590 "./typica.w"
  4803. /*412:*/
  4804. #line 9635 "./typica.w"
  4805. QList<MeasurementList*> ::iterator i= lastInsertion;
  4806. bool quickscan= false;
  4807. if(entries->size()> 5)
  4808. {
  4809. if(**i<*temp)
  4810. {
  4811. i+= 1;
  4812. for(int j= 10;j> 0;j--)
  4813. {
  4814. if(i!=entries->end())
  4815. {
  4816. if(**i<*temp)
  4817. {
  4818. i+= 1;
  4819. }
  4820. else
  4821. {
  4822. quickscan= true;
  4823. break;
  4824. }
  4825. }
  4826. else
  4827. {
  4828. quickscan= true;
  4829. break;
  4830. }
  4831. }
  4832. }
  4833. else
  4834. {
  4835. if(**i==*temp)
  4836. {
  4837. quickscan= true;
  4838. }
  4839. }
  4840. }
  4841. /*:412*/
  4842. #line 9591 "./typica.w"
  4843. if(quickscan==false)
  4844. {
  4845. i= entries->begin();
  4846. QList<MeasurementList*> ::iterator u= entries->end();
  4847. QList<MeasurementList*> ::iterator midpoint;
  4848. int n= u-i;
  4849. int rA;
  4850. while(n> 0)
  4851. {
  4852. rA= n>>1;
  4853. midpoint= i+rA;
  4854. if(**midpoint<*temp)
  4855. {
  4856. i= midpoint+1;
  4857. n-= rA+1;
  4858. }
  4859. else
  4860. {
  4861. n= rA;
  4862. }
  4863. }
  4864. }
  4865. /*:411*/
  4866. #line 9883 "./typica.w"
  4867. entries->insert(i,row);
  4868. int newRow= entries->indexOf(*i);
  4869. if(newRow<index.row())
  4870. {
  4871. emit dataChanged(createIndex(newRow,index.column()),index);
  4872. }
  4873. else
  4874. {
  4875. emit dataChanged(index,createIndex(newRow,index.column()));
  4876. }
  4877. /*:422*/
  4878. #line 9827 "./typica.w"
  4879. }
  4880. else
  4881. {
  4882. /*423:*/
  4883. #line 9897 "./typica.w"
  4884. row->replace(index.column(),value);
  4885. emit dataChanged(index,index);
  4886. /*:423*/
  4887. #line 9831 "./typica.w"
  4888. }
  4889. return true;
  4890. }
  4891. /*:419*//*424:*/
  4892. #line 9905 "./typica.w"
  4893. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  4894. unit(Units::Fahrenheit),hData(new QStringList),
  4895. lastTemperature(new QHash<int,int> ),
  4896. controlColumns(new QHash<int,bool> )
  4897. {
  4898. colcount= 1;
  4899. entries= new QList<MeasurementList*> ;
  4900. lastInsertion= entries->begin();
  4901. hData->append(tr("Time"));
  4902. }
  4903. /*:424*//*425:*/
  4904. #line 9919 "./typica.w"
  4905. MeasurementModel::~MeasurementModel()
  4906. {
  4907. clear();
  4908. delete entries;
  4909. delete hData;
  4910. }
  4911. /*:425*//*426:*/
  4912. #line 9931 "./typica.w"
  4913. int MeasurementModel::rowCount(const QModelIndex&parent)const
  4914. {
  4915. if(parent==QModelIndex())
  4916. {
  4917. return entries->size();
  4918. }
  4919. return 0;
  4920. }
  4921. int MeasurementModel::columnCount(const QModelIndex&parent)const
  4922. {
  4923. if(parent==QModelIndex())
  4924. {
  4925. return colcount;
  4926. }
  4927. return 0;
  4928. }
  4929. /*:426*//*427:*/
  4930. #line 9958 "./typica.w"
  4931. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  4932. const QVariant&value,int)
  4933. {
  4934. if(orientation==Qt::Horizontal)
  4935. {
  4936. if(hData->size()<section+1)
  4937. {
  4938. for(int i= hData->size();i<section+1;i++)
  4939. {
  4940. if(colcount<i)
  4941. {
  4942. beginInsertColumns(QModelIndex(),i,i);
  4943. }
  4944. hData->append(QString());
  4945. if(colcount<i)
  4946. {
  4947. endInsertColumns();
  4948. }
  4949. }
  4950. }
  4951. hData->replace(section,value.toString());
  4952. emit headerDataChanged(orientation,section,section);
  4953. if(colcount<section+1)
  4954. {
  4955. colcount= section+1;
  4956. }
  4957. return true;
  4958. }
  4959. return false;
  4960. }
  4961. /*:427*//*428:*/
  4962. #line 9998 "./typica.w"
  4963. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  4964. {
  4965. beginResetModel();
  4966. unit= scale;
  4967. endResetModel();
  4968. }
  4969. Units::Unit MeasurementModel::displayUnits()
  4970. {
  4971. return unit;
  4972. }
  4973. /*:428*//*429:*/
  4974. #line 10024 "./typica.w"
  4975. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  4976. {
  4977. /*420:*/
  4978. #line 9839 "./typica.w"
  4979. bool valid= false;
  4980. if(index.isValid())
  4981. {
  4982. if(index.row()<entries->size())
  4983. {
  4984. if(index.column()<colcount)
  4985. {
  4986. valid= true;
  4987. }
  4988. }
  4989. }
  4990. /*:420*/
  4991. #line 10027 "./typica.w"
  4992. if(!valid)
  4993. {
  4994. return QVariant();
  4995. }
  4996. MeasurementList*row= entries->at(index.row());
  4997. if(role==Qt::UserRole)
  4998. {
  4999. return QVariant(row->at(index.column()));
  5000. }
  5001. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5002. {
  5003. if(index.column()> row->size())
  5004. {
  5005. return QVariant();
  5006. }
  5007. else
  5008. {
  5009. if(index.column()==0)
  5010. {
  5011. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5012. }
  5013. else if(lastTemperature->contains(index.column()))
  5014. {
  5015. QVariantMap v= row->at(index.column()).toMap();
  5016. if(!v.contains("measurement"))
  5017. {
  5018. return QVariant();
  5019. }
  5020. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5021. {
  5022. return v.value("measurement");
  5023. }
  5024. else
  5025. {
  5026. if(v.contains("relative"))
  5027. {
  5028. if(v.value("relative").toBool())
  5029. {
  5030. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5031. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5032. }
  5033. }
  5034. return QVariant(QString("%1").
  5035. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5036. (Units::Unit)(v.value("unit").toInt()),unit)));
  5037. }
  5038. }
  5039. return QVariant(row->at(index.column()).toString());
  5040. }
  5041. }
  5042. return QVariant();
  5043. }
  5044. /*:429*//*430:*/
  5045. #line 10083 "./typica.w"
  5046. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5047. int role)const
  5048. {
  5049. if(orientation==Qt::Horizontal)
  5050. {
  5051. if(role==Qt::DisplayRole)
  5052. {
  5053. if(section<hData->size())
  5054. {
  5055. return QVariant(hData->at(section));
  5056. }
  5057. }
  5058. }
  5059. return QVariant();
  5060. }
  5061. /*:430*//*431:*/
  5062. #line 10110 "./typica.w"
  5063. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5064. {
  5065. /*420:*/
  5066. #line 9839 "./typica.w"
  5067. bool valid= false;
  5068. if(index.isValid())
  5069. {
  5070. if(index.row()<entries->size())
  5071. {
  5072. if(index.column()<colcount)
  5073. {
  5074. valid= true;
  5075. }
  5076. }
  5077. }
  5078. /*:420*/
  5079. #line 10113 "./typica.w"
  5080. if(valid)
  5081. {
  5082. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5083. }
  5084. return 0;
  5085. }
  5086. /*:431*//*432:*/
  5087. #line 10125 "./typica.w"
  5088. QModelIndex MeasurementModel::index(int row,int column,
  5089. const QModelIndex&parent)const
  5090. {
  5091. if(parent==QModelIndex())
  5092. {
  5093. if(row<entries->size()&&entries->isEmpty()==false)
  5094. {
  5095. if(column<entries->at(row)->size())
  5096. {
  5097. return createIndex(row,column);
  5098. }
  5099. }
  5100. }
  5101. return QModelIndex();
  5102. }
  5103. /*:432*/
  5104. #line 550 "./typica.w"
  5105. /*434:*/
  5106. #line 10176 "./typica.w"
  5107. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5108. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5109. {
  5110. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5111. }
  5112. /*:434*//*435:*/
  5113. #line 10191 "./typica.w"
  5114. void AnnotationButton::annotate()
  5115. {
  5116. if(note.contains("%1"))
  5117. {
  5118. count++;
  5119. emit annotation(note.arg(count),tc,ac);
  5120. }
  5121. else
  5122. {
  5123. emit annotation(note,tc,ac);
  5124. }
  5125. }
  5126. /*:435*//*436:*/
  5127. #line 10209 "./typica.w"
  5128. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5129. {
  5130. tc= tempcolumn;
  5131. }
  5132. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5133. {
  5134. ac= annotationcolumn;
  5135. }
  5136. void AnnotationButton::setAnnotation(const QString&annotation)
  5137. {
  5138. note= annotation;
  5139. }
  5140. /*:436*//*437:*/
  5141. #line 10228 "./typica.w"
  5142. void AnnotationButton::resetCount()
  5143. {
  5144. count= 0;
  5145. }
  5146. /*:437*/
  5147. #line 551 "./typica.w"
  5148. /*442:*/
  5149. #line 10311 "./typica.w"
  5150. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5151. const QString&postt,
  5152. QWidget*parent)
  5153. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5154. {
  5155. resetChange();
  5156. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5157. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5158. }
  5159. /*:442*//*443:*/
  5160. #line 10328 "./typica.w"
  5161. void AnnotationSpinBox::resetChange()
  5162. {
  5163. change= true;
  5164. }
  5165. /*:443*//*444:*/
  5166. #line 10339 "./typica.w"
  5167. void AnnotationSpinBox::annotate()
  5168. {
  5169. if(change)
  5170. {
  5171. change= false;
  5172. emit annotation(QString("%1%2%3").arg(pretext).
  5173. arg(value()).arg(posttext),tc,ac);
  5174. }
  5175. }
  5176. /*:444*//*445:*/
  5177. #line 10352 "./typica.w"
  5178. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5179. {
  5180. tc= tempcolumn;
  5181. }
  5182. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5183. {
  5184. ac= annotationcolumn;
  5185. }
  5186. void AnnotationSpinBox::setPretext(const QString&pret)
  5187. {
  5188. pretext= pret;
  5189. }
  5190. void AnnotationSpinBox::setPosttext(const QString&postt)
  5191. {
  5192. posttext= postt;
  5193. }
  5194. /*:445*/
  5195. #line 552 "./typica.w"
  5196. /*452:*/
  5197. #line 10520 "./typica.w"
  5198. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5199. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5200. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5201. stopAction(new QAction(tr("Stop"),NULL)),
  5202. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5203. relative(QTime::currentTime()),base(QTime(0,0,0))
  5204. {
  5205. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5206. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5207. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5208. clock.setInterval(500);
  5209. clock.setSingleShot(false);
  5210. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5211. setSegmentStyle(Filled);
  5212. updateDisplay();
  5213. }
  5214. /*:452*//*453:*/
  5215. #line 10541 "./typica.w"
  5216. void TimerDisplay::updateTime()
  5217. {
  5218. QTime time;
  5219. int cseconds= 0;
  5220. int oseconds= 0;
  5221. int r= 0;
  5222. QTime nt= QTime(0,0,0);
  5223. int n= 0;
  5224. int bseconds= 0;
  5225. switch(m)
  5226. {
  5227. case TimerDisplay::CountUp:
  5228. /*454:*/
  5229. #line 10573 "./typica.w"
  5230. /*455:*/
  5231. #line 10586 "./typica.w"
  5232. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5233. time= QTime::currentTime();
  5234. cseconds= TIMETOINT(time);
  5235. oseconds= TIMETOINT(relative);
  5236. r= cseconds-oseconds;
  5237. /*:455*/
  5238. #line 10574 "./typica.w"
  5239. nt= nt.addSecs(r);
  5240. if(nt!=s)
  5241. {
  5242. s= nt;
  5243. emit valueChanged(s);
  5244. }
  5245. /*:454*/
  5246. #line 10554 "./typica.w"
  5247. ;
  5248. break;
  5249. case TimerDisplay::CountDown:
  5250. /*456:*/
  5251. #line 10598 "./typica.w"
  5252. if(s> QTime(0,0,0))
  5253. {
  5254. /*455:*/
  5255. #line 10586 "./typica.w"
  5256. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5257. time= QTime::currentTime();
  5258. cseconds= TIMETOINT(time);
  5259. oseconds= TIMETOINT(relative);
  5260. r= cseconds-oseconds;
  5261. /*:455*/
  5262. #line 10601 "./typica.w"
  5263. bseconds= TIMETOINT(base);
  5264. n= bseconds-r;
  5265. nt= nt.addSecs(n);
  5266. if(nt!=s)
  5267. {
  5268. s= nt;
  5269. emit valueChanged(s);
  5270. }
  5271. }
  5272. /*:456*/
  5273. #line 10557 "./typica.w"
  5274. ;
  5275. break;
  5276. case TimerDisplay::Clock:
  5277. /*457:*/
  5278. #line 10615 "./typica.w"
  5279. time= QTime::currentTime();
  5280. if(time!=s)
  5281. {
  5282. s= time;
  5283. emit valueChanged(s);
  5284. }
  5285. /*:457*/
  5286. #line 10560 "./typica.w"
  5287. ;
  5288. break;
  5289. default:
  5290. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5291. break;
  5292. }
  5293. updateDisplay();
  5294. }
  5295. /*:453*//*458:*/
  5296. #line 10627 "./typica.w"
  5297. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5298. void TimerDisplay::startTimer()
  5299. {
  5300. if(!running)
  5301. {
  5302. relative= QTime::currentTime();
  5303. if(ar)
  5304. {
  5305. reset();
  5306. }
  5307. else
  5308. {
  5309. relative= TIMESUBTRACT(relative,s);
  5310. }
  5311. if(m==Clock)
  5312. {
  5313. updateTime();
  5314. }
  5315. base= s;
  5316. clock.start();
  5317. running= true;
  5318. emit runStateChanged(true);
  5319. }
  5320. }
  5321. /*:458*//*459:*/
  5322. #line 10657 "./typica.w"
  5323. void TimerDisplay::stopTimer()
  5324. {
  5325. if(running)
  5326. {
  5327. clock.stop();
  5328. running= false;
  5329. emit runStateChanged(false);
  5330. }
  5331. }
  5332. /*:459*//*460:*/
  5333. #line 10670 "./typica.w"
  5334. TimerDisplay::~TimerDisplay()
  5335. {
  5336. clock.stop();
  5337. }
  5338. /*:460*//*461:*/
  5339. #line 10679 "./typica.w"
  5340. void TimerDisplay::setCountUpMode()
  5341. {
  5342. m= TimerDisplay::CountUp;
  5343. }
  5344. void TimerDisplay::setCountDownMode()
  5345. {
  5346. m= TimerDisplay::CountDown;
  5347. }
  5348. void TimerDisplay::setClockMode()
  5349. {
  5350. m= TimerDisplay::Clock;
  5351. }
  5352. /*:461*//*462:*/
  5353. #line 10697 "./typica.w"
  5354. QString TimerDisplay::value()
  5355. {
  5356. return s.toString(f);
  5357. }
  5358. QTime TimerDisplay::seconds()
  5359. {
  5360. return s;
  5361. }
  5362. TimerDisplay::TimerMode TimerDisplay::mode()
  5363. {
  5364. return m;
  5365. }
  5366. bool TimerDisplay::isRunning()
  5367. {
  5368. return running;
  5369. }
  5370. QTime TimerDisplay::resetValue()
  5371. {
  5372. return r;
  5373. }
  5374. QString TimerDisplay::displayFormat()
  5375. {
  5376. return f;
  5377. }
  5378. bool TimerDisplay::autoReset()
  5379. {
  5380. return ar;
  5381. }
  5382. /*:462*//*463:*/
  5383. #line 10735 "./typica.w"
  5384. void TimerDisplay::setTimer(QTime value)
  5385. {
  5386. if(value.isValid())
  5387. {
  5388. s= value;
  5389. updateDisplay();
  5390. emit valueChanged(value);
  5391. }
  5392. }
  5393. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5394. {
  5395. m= mode;
  5396. }
  5397. void TimerDisplay::setResetValue(QTime value)
  5398. {
  5399. r= value;
  5400. }
  5401. void TimerDisplay::setDisplayFormat(QString format)
  5402. {
  5403. f= format;
  5404. setNumDigits(format.length());
  5405. }
  5406. void TimerDisplay::setAutoReset(bool reset)
  5407. {
  5408. ar= reset;
  5409. }
  5410. /*:463*//*464:*/
  5411. #line 10770 "./typica.w"
  5412. void TimerDisplay::copyTimer()
  5413. {
  5414. QApplication::clipboard()->setText(value());
  5415. }
  5416. /*:464*//*465:*/
  5417. #line 10779 "./typica.w"
  5418. void TimerDisplay::reset()
  5419. {
  5420. if(!running)
  5421. {
  5422. s= r;
  5423. updateDisplay();
  5424. }
  5425. }
  5426. /*:465*//*466:*/
  5427. #line 10792 "./typica.w"
  5428. void TimerDisplay::updateDisplay()
  5429. {
  5430. display(value());
  5431. }
  5432. /*:466*/
  5433. #line 553 "./typica.w"
  5434. /*472:*/
  5435. #line 10886 "./typica.w"
  5436. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5437. {
  5438. int x= rect.x();
  5439. int y= rect.y();
  5440. QLayoutItem*item;
  5441. if(orientation==Qt::Horizontal)
  5442. {
  5443. /*473:*/
  5444. #line 10910 "./typica.w"
  5445. foreach(item,itemList)
  5446. {
  5447. int nextX= x+item->sizeHint().width()+spacing();
  5448. int right= x+item->sizeHint().width();
  5449. if(item==itemList.last())
  5450. {
  5451. right= rect.right();
  5452. }
  5453. int bottom= rect.bottom();
  5454. if(!testOnly)
  5455. {
  5456. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5457. }
  5458. x= nextX;
  5459. }
  5460. /*:473*/
  5461. #line 10894 "./typica.w"
  5462. }
  5463. else
  5464. {
  5465. /*474:*/
  5466. #line 10929 "./typica.w"
  5467. foreach(item,itemList)
  5468. {
  5469. int nextY= y+item->sizeHint().height()+spacing();
  5470. int bottom= y+item->sizeHint().height();
  5471. if(item==itemList.last())
  5472. {
  5473. bottom= rect.bottom();
  5474. }
  5475. int right= rect.right();
  5476. if(!testOnly)
  5477. {
  5478. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5479. }
  5480. y= nextY;
  5481. }
  5482. /*:474*/
  5483. #line 10898 "./typica.w"
  5484. }
  5485. return y;
  5486. }
  5487. /*:472*//*475:*/
  5488. #line 10953 "./typica.w"
  5489. QSize PackLayout::minimumSize()const
  5490. {
  5491. QSize size;
  5492. QLayoutItem*item;
  5493. foreach(item,itemList)
  5494. {
  5495. if(orientation==Qt::Horizontal)
  5496. {
  5497. size+= QSize(item->minimumSize().width(),0);
  5498. if(size.height()<item->minimumSize().height())
  5499. {
  5500. size.setHeight(item->minimumSize().height());
  5501. }
  5502. }
  5503. else
  5504. {
  5505. size+= QSize(0,item->minimumSize().height());
  5506. if(size.width()<item->minimumSize().width())
  5507. {
  5508. size.setWidth(item->minimumSize().width());
  5509. }
  5510. }
  5511. }
  5512. size+= QSize(2*margin(),2*margin());
  5513. return size;
  5514. }
  5515. /*:475*//*476:*/
  5516. #line 10985 "./typica.w"
  5517. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5518. QLayout(parent)
  5519. {
  5520. setMargin(margin);
  5521. setSpacing(spacing);
  5522. setOrientation(Qt::Horizontal);
  5523. }
  5524. PackLayout::PackLayout(int spacing)
  5525. {
  5526. setSpacing(spacing);
  5527. setOrientation(Qt::Horizontal);
  5528. }
  5529. /*:476*//*477:*/
  5530. #line 11003 "./typica.w"
  5531. PackLayout::~PackLayout()
  5532. {
  5533. QLayoutItem*item;
  5534. while((item= takeAt(0)))
  5535. {
  5536. delete item;
  5537. }
  5538. }
  5539. /*:477*//*478:*/
  5540. #line 11017 "./typica.w"
  5541. QLayoutItem*PackLayout::takeAt(int index)
  5542. {
  5543. if(index>=0&&index<itemList.size())
  5544. {
  5545. return itemList.takeAt(index);
  5546. }
  5547. else
  5548. {
  5549. return NULL;
  5550. }
  5551. }
  5552. /*:478*//*479:*/
  5553. #line 11033 "./typica.w"
  5554. QLayoutItem*PackLayout::itemAt(int index)const
  5555. {
  5556. if(index>=0&&index<itemList.size())
  5557. {
  5558. return itemList.at(index);
  5559. }
  5560. else
  5561. {
  5562. return NULL;
  5563. }
  5564. }
  5565. /*:479*//*480:*/
  5566. #line 11056 "./typica.w"
  5567. void PackLayout::addItem(QLayoutItem*item)
  5568. {
  5569. itemList.append(item);
  5570. }
  5571. /*:480*//*481:*/
  5572. #line 11064 "./typica.w"
  5573. int PackLayout::count()const
  5574. {
  5575. return itemList.size();
  5576. }
  5577. /*:481*//*482:*/
  5578. #line 11076 "./typica.w"
  5579. Qt::Orientations PackLayout::expandingDirections()const
  5580. {
  5581. return Qt::Vertical|Qt::Horizontal;
  5582. }
  5583. bool PackLayout::hasHeightForWidth()const
  5584. {
  5585. return false;
  5586. }
  5587. int PackLayout::heightForWidth(int width)const
  5588. {
  5589. return doLayout(QRect(0,0,width,0),true);
  5590. }
  5591. void PackLayout::setGeometry(const QRect&rect)
  5592. {
  5593. QLayout::setGeometry(rect);
  5594. doLayout(rect,false);
  5595. }
  5596. QSize PackLayout::sizeHint()const
  5597. {
  5598. return minimumSize();
  5599. }
  5600. /*:482*//*483:*/
  5601. #line 11107 "./typica.w"
  5602. void PackLayout::setOrientation(Qt::Orientations direction)
  5603. {
  5604. orientation= direction;
  5605. doLayout(geometry(),false);
  5606. }
  5607. /*:483*/
  5608. #line 554 "./typica.w"
  5609. /*485:*/
  5610. #line 11146 "./typica.w"
  5611. SceneButton::SceneButton():QGraphicsScene()
  5612. {
  5613. }
  5614. SceneButton::~SceneButton()
  5615. {
  5616. }
  5617. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5618. {
  5619. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5620. }
  5621. /*:485*/
  5622. #line 555 "./typica.w"
  5623. /*487:*/
  5624. #line 11192 "./typica.w"
  5625. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5626. Qt::Orientations orientation,
  5627. QWidget*parent,Qt::WindowFlags f):
  5628. QWidget(parent,f),label(new QGraphicsView()),
  5629. scene(new SceneButton())
  5630. {
  5631. layout= new PackLayout(this);
  5632. layout->setOrientation(orientation);
  5633. /*488:*/
  5634. #line 11212 "./typica.w"
  5635. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5636. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5637. label->setFrameShape(QFrame::NoFrame);
  5638. label->setInteractive(true);
  5639. /*:488*/
  5640. #line 11201 "./typica.w"
  5641. /*489:*/
  5642. #line 11223 "./typica.w"
  5643. scene->setBackgroundBrush(Qt::cyan);
  5644. text= scene->addText(labeltext);
  5645. if(orientation==Qt::Horizontal)
  5646. {
  5647. text->rotate(270.0);
  5648. }
  5649. label->setScene(scene);
  5650. /*:489*/
  5651. #line 11202 "./typica.w"
  5652. /*490:*/
  5653. #line 11241 "./typica.w"
  5654. if(orientation==Qt::Horizontal)
  5655. {
  5656. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5657. }
  5658. else
  5659. {
  5660. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5661. }
  5662. label->centerOn(text);
  5663. /*:490*/
  5664. #line 11203 "./typica.w"
  5665. /*491:*/
  5666. #line 11256 "./typica.w"
  5667. layout->addWidget(label);
  5668. layout->addWidget(widget);
  5669. if(orientation==Qt::Horizontal)
  5670. {
  5671. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5672. widget->sizeHint().height());
  5673. }
  5674. else
  5675. {
  5676. setMinimumSize(widget->sizeHint().width(),
  5677. widget->sizeHint().height()+label->sizeHint().height());
  5678. }
  5679. /*:491*/
  5680. #line 11204 "./typica.w"
  5681. }
  5682. /*:487*//*492:*/
  5683. #line 11273 "./typica.w"
  5684. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5685. {
  5686. scene->setBackgroundBrush(background);
  5687. }
  5688. void WidgetDecorator::setTextColor(QColor color)
  5689. {
  5690. text->setDefaultTextColor(color);
  5691. }
  5692. /*:492*//*493:*/
  5693. #line 11286 "./typica.w"
  5694. WidgetDecorator::~WidgetDecorator()
  5695. {
  5696. }
  5697. /*:493*/
  5698. #line 556 "./typica.w"
  5699. /*498:*/
  5700. #line 11385 "./typica.w"
  5701. void LogEditWindow::addTheRows()
  5702. {
  5703. QTime s= startTime->time();
  5704. while(s<endTime->time())
  5705. {
  5706. model->newMeasurement(Measurement(0,s),1);
  5707. s= s.addSecs(interval->value());
  5708. }
  5709. model->newMeasurement(Measurement(0,endTime->time()),1);
  5710. }
  5711. /*:498*//*499:*/
  5712. #line 11399 "./typica.w"
  5713. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5714. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5715. addRowsLayout(new QHBoxLayout(NULL)),
  5716. startTimeLabel(new QLabel("Start Time")),
  5717. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5718. endTimeLabel(new QLabel("End Time")),
  5719. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5720. intervalLabel(new QLabel("Interval (seconds)")),
  5721. interval(new QSpinBox()),
  5722. addRows(new QPushButton("Add Rows")),
  5723. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5724. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5725. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5726. model(new MeasurementModel()),
  5727. log(new QTableView())
  5728. {
  5729. /*500:*/
  5730. #line 11436 "./typica.w"
  5731. QSettings settings;
  5732. resize(settings.value("logSize",QSize(620,400)).toSize());
  5733. move(settings.value("logPos",QPoint(200,60)).toPoint());
  5734. /*:500*/
  5735. #line 11416 "./typica.w"
  5736. /*501:*/
  5737. #line 11449 "./typica.w"
  5738. mainLayout->setOrientation(Qt::Vertical);
  5739. addRowsLayout->addSpacing(10);
  5740. addRowsLayout->addWidget(startTimeLabel);
  5741. addRowsLayout->addWidget(startTime);
  5742. addRowsLayout->addSpacing(10);
  5743. startTime->setDisplayFormat("mm:ss");
  5744. addRowsLayout->addWidget(endTimeLabel);
  5745. addRowsLayout->addWidget(endTime);
  5746. addRowsLayout->addSpacing(10);
  5747. endTime->setDisplayFormat("mm:ss");
  5748. addRowsLayout->addWidget(intervalLabel);
  5749. addRowsLayout->addWidget(interval);
  5750. addRowsLayout->addSpacing(10);
  5751. interval->setRange(0,60);
  5752. interval->setValue(30);
  5753. addRowsLayout->addWidget(addRows);
  5754. addRowsLayout->addSpacing(10);
  5755. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  5756. /*:501*/
  5757. #line 11417 "./typica.w"
  5758. /*502:*/
  5759. #line 11472 "./typica.w"
  5760. model->setHeaderData(0,Qt::Horizontal,"Time");
  5761. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  5762. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  5763. model->clear();
  5764. /*:502*/
  5765. #line 11418 "./typica.w"
  5766. /*503:*/
  5767. #line 11481 "./typica.w"
  5768. log->setModel(model);
  5769. log->setColumnWidth(0,100);
  5770. log->setColumnWidth(1,100);
  5771. log->setColumnWidth(2,100);
  5772. /*:503*/
  5773. #line 11419 "./typica.w"
  5774. mainLayout->addItem(addRowsLayout);
  5775. mainLayout->addWidget(log);
  5776. centralWidget->setLayout(mainLayout);
  5777. setCentralWidget(centralWidget);
  5778. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  5779. fileMenu->addAction(openXml);
  5780. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  5781. fileMenu->addAction(saveXml);
  5782. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  5783. fileMenu->addAction(saveCsv);
  5784. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  5785. }
  5786. /*:499*//*504:*/
  5787. #line 11492 "./typica.w"
  5788. void LogEditWindow::saveXML()
  5789. {
  5790. QSettings settings;
  5791. QString lastDir= settings.value("lastDirectory").toString();
  5792. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  5793. lastDir,"",0);
  5794. QFile file(filename);
  5795. XMLOutput writer(model,&file,0);
  5796. writer.addTemperatureColumn("Temperature",1);
  5797. writer.addAnnotationColumn("Annotation",2);
  5798. if(writer.output())
  5799. {
  5800. QFileInfo info(filename);
  5801. QDir directory= info.dir();
  5802. lastDir= directory.path();
  5803. settings.setValue("lastDirectory",lastDir);
  5804. }
  5805. }
  5806. void LogEditWindow::saveCSV()
  5807. {
  5808. QSettings settings;
  5809. QString lastDir= settings.value("lastDirectory").toString();
  5810. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  5811. lastDir,"",0);
  5812. QFile file(filename);
  5813. CSVOutput writer(model,&file,0);
  5814. writer.addTemperatureColumn("Temperature",1);
  5815. writer.addAnnotationColumn("Annotation",2);
  5816. if(writer.output())
  5817. {
  5818. QFileInfo info(filename);
  5819. QDir directory= info.dir();
  5820. lastDir= directory.path();
  5821. settings.setValue("lastDirectory",lastDir);
  5822. }
  5823. }
  5824. /*:504*//*505:*/
  5825. #line 11535 "./typica.w"
  5826. void LogEditWindow::openXML()
  5827. {
  5828. QSettings settings;
  5829. QString lastDir= settings.value("lastDirectory").toString();
  5830. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  5831. lastDir,"",0);
  5832. if(filename.isNull())
  5833. {
  5834. return;
  5835. }
  5836. QFile file(filename);
  5837. XMLInput reader(&file,1);
  5838. connect(&reader,SIGNAL(measure(Measurement,int)),
  5839. model,SLOT(newMeasurement(Measurement,int)));
  5840. connect(&reader,SIGNAL(annotation(QString,int,int)),
  5841. model,SLOT(newAnnotation(QString,int,int)));
  5842. if(reader.input())
  5843. {
  5844. QFileInfo info(filename);
  5845. setWindowTitle(QString(tr("%1 - %2")).
  5846. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  5847. QDir directory= info.dir();
  5848. lastDir= directory.path();
  5849. settings.setValue("lastDirectory",lastDir);
  5850. }
  5851. }
  5852. /*:505*//*506:*/
  5853. #line 11566 "./typica.w"
  5854. void LogEditWindow::closeEvent(QCloseEvent*event)
  5855. {
  5856. QSettings settings;
  5857. settings.setValue("logSize",size());
  5858. settings.setValue("logPos",pos());
  5859. event->accept();
  5860. }
  5861. /*:506*/
  5862. #line 557 "./typica.w"
  5863. /*512:*/
  5864. #line 11681 "./typica.w"
  5865. bool XMLOutput::output()
  5866. {
  5867. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  5868. {
  5869. return false;
  5870. }
  5871. QXmlStreamWriter xmlout(out);
  5872. xmlout.writeStartDocument("1.0");
  5873. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  5874. xmlout.writeStartElement("roastlog");
  5875. /*513:*/
  5876. #line 11714 "./typica.w"
  5877. foreach(int c,temperatureColumns.keys())
  5878. {
  5879. xmlout.writeStartElement("tempseries");
  5880. xmlout.writeAttribute("name",temperatureColumns.value(c));
  5881. xmlout.writeEndElement();
  5882. }
  5883. foreach(int c,controlColumns.keys())
  5884. {
  5885. xmlout.writeStartElement("controlseries");
  5886. xmlout.writeAttribute("name",controlColumns.value(c));
  5887. xmlout.writeEndElement();
  5888. }
  5889. foreach(int c,annotationColumns.keys())
  5890. {
  5891. xmlout.writeStartElement("noteseries");
  5892. xmlout.writeAttribute("name",annotationColumns.value(c));
  5893. xmlout.writeEndElement();
  5894. }
  5895. /*:513*/
  5896. #line 11692 "./typica.w"
  5897. xmlout.writeStartElement("roast");
  5898. bool oresult;
  5899. for(int i= 0;i<data->rowCount();i++)
  5900. {
  5901. /*514:*/
  5902. #line 11739 "./typica.w"
  5903. oresult= false;
  5904. foreach(int c,temperatureColumns.keys())
  5905. {
  5906. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5907. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5908. {
  5909. oresult= true;
  5910. break;
  5911. }
  5912. }
  5913. foreach(int c,controlColumns.keys())
  5914. {
  5915. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5916. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5917. {
  5918. oresult= true;
  5919. break;
  5920. }
  5921. }
  5922. if(oresult==false)
  5923. {
  5924. foreach(int c,annotationColumns.keys())
  5925. {
  5926. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5927. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  5928. isEmpty()))
  5929. {
  5930. oresult= true;
  5931. break;
  5932. }
  5933. }
  5934. }
  5935. /*:514*/
  5936. #line 11697 "./typica.w"
  5937. if(oresult)
  5938. {
  5939. /*515:*/
  5940. #line 11778 "./typica.w"
  5941. xmlout.writeStartElement("tuple");
  5942. xmlout.writeTextElement("time",data->data(data->index(i,time),
  5943. Qt::DisplayRole).toString());
  5944. foreach(int c,temperatureColumns.keys())
  5945. {
  5946. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5947. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5948. {
  5949. xmlout.writeStartElement("temperature");
  5950. xmlout.writeAttribute("series",temperatureColumns.value(c));
  5951. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  5952. {
  5953. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  5954. {
  5955. xmlout.writeAttribute("relative","true");
  5956. }
  5957. }
  5958. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  5959. toString());
  5960. xmlout.writeEndElement();
  5961. }
  5962. }
  5963. foreach(int c,controlColumns.keys())
  5964. {
  5965. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5966. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5967. {
  5968. xmlout.writeStartElement("control");
  5969. xmlout.writeAttribute("series",controlColumns.value(c));
  5970. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  5971. xmlout.writeEndElement();
  5972. }
  5973. }
  5974. foreach(int c,annotationColumns.keys())
  5975. {
  5976. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5977. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5978. {
  5979. xmlout.writeStartElement("annotation");
  5980. xmlout.writeAttribute("series",annotationColumns.value(c));
  5981. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  5982. toString());
  5983. xmlout.writeEndElement();
  5984. }
  5985. }
  5986. xmlout.writeEndElement();
  5987. /*:515*/
  5988. #line 11700 "./typica.w"
  5989. }
  5990. }
  5991. xmlout.writeEndElement();
  5992. xmlout.writeEndElement();
  5993. xmlout.writeEndDocument();
  5994. out->close();
  5995. return true;
  5996. }
  5997. /*:512*//*516:*/
  5998. #line 11828 "./typica.w"
  5999. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6000. :QObject(NULL),data(model),out(device),time(timec)
  6001. {
  6002. }
  6003. void XMLOutput::setModel(MeasurementModel*model)
  6004. {
  6005. data= model;
  6006. }
  6007. void XMLOutput::setTimeColumn(int column)
  6008. {
  6009. time= column;
  6010. }
  6011. void XMLOutput::setDevice(QIODevice*device)
  6012. {
  6013. out= device;
  6014. }
  6015. /*:516*//*517:*/
  6016. #line 11857 "./typica.w"
  6017. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6018. {
  6019. temperatureColumns.insert(column,series);
  6020. }
  6021. void XMLOutput::addControlColumn(const QString&series,int column)
  6022. {
  6023. controlColumns.insert(column,series);
  6024. }
  6025. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6026. {
  6027. annotationColumns.insert(column,series);
  6028. }
  6029. /*:517*/
  6030. #line 558 "./typica.w"
  6031. /*519:*/
  6032. #line 11914 "./typica.w"
  6033. bool XMLInput::input()
  6034. {
  6035. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6036. {
  6037. return false;
  6038. }
  6039. QXmlStreamReader xmlin(in);
  6040. QMap<QString,int> temperatureColumns;
  6041. QMap<QString,int> annotationColumns;
  6042. int nextColumn= firstc;
  6043. /*520:*/
  6044. #line 11945 "./typica.w"
  6045. while(!xmlin.isDTD())
  6046. {
  6047. xmlin.readNext();
  6048. }
  6049. if(xmlin.isDTD())
  6050. {
  6051. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6052. {
  6053. /*521:*/
  6054. #line 11967 "./typica.w"
  6055. emit newTemperatureColumn(firstc,"Bean");
  6056. emit newAnnotationColumn(firstc+1,"Note");
  6057. emit lastColumn(firstc+1);
  6058. /*:521*/
  6059. #line 11954 "./typica.w"
  6060. }
  6061. else
  6062. {
  6063. xmlin.readNext();
  6064. /*522:*/
  6065. #line 11976 "./typica.w"
  6066. while(xmlin.name()!="roast")
  6067. {
  6068. if(xmlin.isStartElement())
  6069. {
  6070. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6071. {
  6072. temperatureColumns.insert(xmlin.attributes().value("name").
  6073. toString(),
  6074. nextColumn);
  6075. emit newTemperatureColumn(nextColumn,
  6076. xmlin.attributes().value("name").
  6077. toString());
  6078. nextColumn++;
  6079. }
  6080. else if(xmlin.name()=="noteseries")
  6081. {
  6082. annotationColumns.insert(xmlin.attributes().value("name").
  6083. toString(),nextColumn);
  6084. emit newAnnotationColumn(nextColumn,
  6085. xmlin.attributes().value("name").
  6086. toString());
  6087. nextColumn++;
  6088. }
  6089. }
  6090. xmlin.readNext();
  6091. }
  6092. emit lastColumn(nextColumn-1);
  6093. /*:522*/
  6094. #line 11959 "./typica.w"
  6095. }
  6096. }
  6097. /*:520*/
  6098. #line 11925 "./typica.w"
  6099. QTime timeval= QTime();
  6100. double tempval= 0;
  6101. QString noteval= QString();
  6102. int column;
  6103. int counter= 0;
  6104. while(!xmlin.atEnd())
  6105. {
  6106. /*523:*/
  6107. #line 12017 "./typica.w"
  6108. xmlin.readNext();
  6109. if(xmlin.isStartElement())
  6110. {
  6111. /*524:*/
  6112. #line 12043 "./typica.w"
  6113. if(xmlin.name()=="time")
  6114. {
  6115. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6116. }
  6117. else if(xmlin.name()=="temperature")
  6118. {
  6119. column= xmlin.attributes().value("series").toString().isEmpty()?
  6120. firstc:temperatureColumns.value(xmlin.attributes().
  6121. value("series").toString());
  6122. bool relative= (xmlin.attributes().value("relative")=="true");
  6123. tempval= xmlin.readElementText().toDouble();
  6124. Measurement measurement(tempval,timeval);
  6125. if(relative)
  6126. {
  6127. measurement.insert("relative",true);
  6128. }
  6129. emit measure(measurement,column);
  6130. }
  6131. else if(xmlin.name()=="control")
  6132. {
  6133. column= xmlin.attributes().value("series").toString().isEmpty()?
  6134. firstc:temperatureColumns.value(xmlin.attributes().
  6135. value("series").toString());
  6136. tempval= xmlin.readElementText().toDouble();
  6137. Measurement measurement(tempval,timeval,Units::Unitless);
  6138. emit measure(measurement,column);
  6139. }
  6140. else if(xmlin.name()=="annotation")
  6141. {
  6142. column= xmlin.attributes().value("series").toString().isEmpty()?
  6143. firstc+1:annotationColumns.value(xmlin.attributes().
  6144. value("series").toString());
  6145. noteval= xmlin.readElementText();
  6146. if(!noteval.isEmpty())
  6147. {
  6148. emit annotation(noteval,firstc,column);
  6149. }
  6150. }
  6151. /*:524*/
  6152. #line 12021 "./typica.w"
  6153. }
  6154. counter++;
  6155. if(counter%100==0)
  6156. {
  6157. QCoreApplication::processEvents();
  6158. }
  6159. /*:523*/
  6160. #line 11933 "./typica.w"
  6161. }
  6162. return true;
  6163. }
  6164. /*:519*//*525:*/
  6165. #line 12085 "./typica.w"
  6166. XMLInput::XMLInput(QIODevice*input,int c):
  6167. firstc(c),in(input)
  6168. {
  6169. }
  6170. void XMLInput::setFirstColumn(int column)
  6171. {
  6172. firstc= column;
  6173. }
  6174. void XMLInput::setDevice(QIODevice*device)
  6175. {
  6176. in= device;
  6177. }
  6178. /*:525*/
  6179. #line 559 "./typica.w"
  6180. /*530:*/
  6181. #line 12176 "./typica.w"
  6182. bool CSVOutput::output()
  6183. {
  6184. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6185. {
  6186. return false;
  6187. }
  6188. QTextStream output(out);
  6189. /*531:*/
  6190. #line 12200 "./typica.w"
  6191. output<<"Time";
  6192. foreach(int c,temperatureColumns.keys())
  6193. {
  6194. output<<','<<temperatureColumns.value(c);
  6195. }
  6196. foreach(int c,controlColumns.keys())
  6197. {
  6198. output<<','<<controlColumns.value(c);
  6199. }
  6200. foreach(int c,annotationColumns.keys())
  6201. {
  6202. output<<','<<annotationColumns.value(c);
  6203. }
  6204. output<<'\n';
  6205. /*:531*/
  6206. #line 12184 "./typica.w"
  6207. bool oresult;
  6208. for(int i= 0;i<data->rowCount();i++)
  6209. {
  6210. /*514:*/
  6211. #line 11739 "./typica.w"
  6212. oresult= false;
  6213. foreach(int c,temperatureColumns.keys())
  6214. {
  6215. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6216. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6217. {
  6218. oresult= true;
  6219. break;
  6220. }
  6221. }
  6222. foreach(int c,controlColumns.keys())
  6223. {
  6224. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6225. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6226. {
  6227. oresult= true;
  6228. break;
  6229. }
  6230. }
  6231. if(oresult==false)
  6232. {
  6233. foreach(int c,annotationColumns.keys())
  6234. {
  6235. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6236. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6237. isEmpty()))
  6238. {
  6239. oresult= true;
  6240. break;
  6241. }
  6242. }
  6243. }
  6244. /*:514*/
  6245. #line 12188 "./typica.w"
  6246. if(oresult)
  6247. {
  6248. /*532:*/
  6249. #line 12225 "./typica.w"
  6250. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6251. foreach(int c,temperatureColumns.keys())
  6252. {
  6253. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6254. }
  6255. foreach(int c,controlColumns.keys())
  6256. {
  6257. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6258. }
  6259. foreach(int c,annotationColumns.keys())
  6260. {
  6261. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6262. }
  6263. output<<'\n';
  6264. /*:532*/
  6265. #line 12191 "./typica.w"
  6266. }
  6267. }
  6268. out->close();
  6269. return true;
  6270. }
  6271. /*:530*//*533:*/
  6272. #line 12244 "./typica.w"
  6273. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6274. data(model),out(device),time(timec)
  6275. {
  6276. }
  6277. void CSVOutput::setModel(MeasurementModel*model)
  6278. {
  6279. data= model;
  6280. }
  6281. void CSVOutput::setTimeColumn(int column)
  6282. {
  6283. time= column;
  6284. }
  6285. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6286. {
  6287. temperatureColumns.insert(column,series);
  6288. }
  6289. void CSVOutput::addControlColumn(const QString&series,int column)
  6290. {
  6291. controlColumns.insert(column,series);
  6292. }
  6293. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6294. {
  6295. annotationColumns.insert(column,series);
  6296. }
  6297. void CSVOutput::setDevice(QIODevice*device)
  6298. {
  6299. out= device;
  6300. }
  6301. #line 1 "./webview.w"
  6302. /*:533*/
  6303. #line 560 "./typica.w"
  6304. /*568:*/
  6305. #line 12505 "./typica.w"
  6306. QString SaltModel::arrayLiteral(int column,int role)const
  6307. {
  6308. QString literal= "'{";
  6309. for(int i= 0;i<rowCount();i++)
  6310. {
  6311. QString datum= data(index(i,column),role).toString();
  6312. if(!datum.isEmpty())
  6313. {
  6314. literal.append(datum);
  6315. literal.append(", ");
  6316. }
  6317. }
  6318. if(literal.size()> 2)
  6319. {
  6320. literal.chop(2);
  6321. }
  6322. literal.append("}'");
  6323. return literal;
  6324. }
  6325. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6326. {
  6327. QString literal= "'{";
  6328. for(int i= 0;i<rowCount();i++)
  6329. {
  6330. QString datum= data(index(i,column),role).toString();
  6331. if(!datum.isEmpty())
  6332. {
  6333. literal.append("\"");
  6334. literal.append(datum);
  6335. literal.append("\", ");
  6336. }
  6337. }
  6338. if(literal.size()> 2)
  6339. {
  6340. literal.chop(2);
  6341. }
  6342. literal.append("}'");
  6343. return literal;
  6344. }
  6345. /*:568*//*569:*/
  6346. #line 12549 "./typica.w"
  6347. QModelIndex SaltModel::parent(const QModelIndex&)const
  6348. {
  6349. return QModelIndex();
  6350. }
  6351. /*:569*//*570:*/
  6352. #line 12568 "./typica.w"
  6353. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6354. int role)
  6355. {
  6356. /*571:*/
  6357. #line 12599 "./typica.w"
  6358. bool valid= false;
  6359. if(index.isValid())
  6360. {
  6361. if(index.row()<modelData.size())
  6362. {
  6363. if(index.column()<colcount)
  6364. {
  6365. valid= true;
  6366. }
  6367. }
  6368. }
  6369. /*:571*/
  6370. #line 12572 "./typica.w"
  6371. if(!valid)
  6372. {
  6373. return false;
  6374. }
  6375. if(index.row()==modelData.size()-1)
  6376. {
  6377. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6378. /*572:*/
  6379. #line 12615 "./typica.w"
  6380. QList<QMap<int,QVariant> > newRow;
  6381. QMap<int,QVariant> defaults;
  6382. for(int i= 0;i<colcount;i++)
  6383. {
  6384. newRow.append(defaults);
  6385. }
  6386. modelData.append(newRow);
  6387. /*:572*/
  6388. #line 12580 "./typica.w"
  6389. endInsertRows();
  6390. }
  6391. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6392. QMap<int,QVariant> cell= row.at(index.column());
  6393. cell.insert(role,value);
  6394. if(role==Qt::EditRole)
  6395. {
  6396. cell.insert(Qt::DisplayRole,value);
  6397. }
  6398. row.replace(index.column(),cell);
  6399. modelData.replace(index.row(),row);
  6400. emit dataChanged(index,index);
  6401. return true;
  6402. }
  6403. /*:570*//*573:*/
  6404. #line 12626 "./typica.w"
  6405. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6406. {
  6407. for(int i= 0;i<columns;i++)
  6408. {
  6409. hData<<"";
  6410. }
  6411. /*572:*/
  6412. #line 12615 "./typica.w"
  6413. QList<QMap<int,QVariant> > newRow;
  6414. QMap<int,QVariant> defaults;
  6415. for(int i= 0;i<colcount;i++)
  6416. {
  6417. newRow.append(defaults);
  6418. }
  6419. modelData.append(newRow);
  6420. /*:572*/
  6421. #line 12633 "./typica.w"
  6422. }
  6423. /*:573*//*574:*/
  6424. #line 12638 "./typica.w"
  6425. SaltModel::~SaltModel()
  6426. {
  6427. }
  6428. /*:574*//*575:*/
  6429. #line 12648 "./typica.w"
  6430. int SaltModel::rowCount(const QModelIndex&parent)const
  6431. {
  6432. return(parent==QModelIndex()?modelData.size():0);
  6433. }
  6434. int SaltModel::columnCount(const QModelIndex&parent)const
  6435. {
  6436. return(parent==QModelIndex()?colcount:0);
  6437. }
  6438. /*:575*//*576:*/
  6439. #line 12661 "./typica.w"
  6440. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6441. const QVariant&value,int)
  6442. {
  6443. if(orientation==Qt::Horizontal&&section<colcount)
  6444. {
  6445. hData.replace(section,value.toString());
  6446. emit headerDataChanged(orientation,section,section);
  6447. return true;
  6448. }
  6449. return false;
  6450. }
  6451. /*:576*//*577:*/
  6452. #line 12676 "./typica.w"
  6453. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6454. {
  6455. /*571:*/
  6456. #line 12599 "./typica.w"
  6457. bool valid= false;
  6458. if(index.isValid())
  6459. {
  6460. if(index.row()<modelData.size())
  6461. {
  6462. if(index.column()<colcount)
  6463. {
  6464. valid= true;
  6465. }
  6466. }
  6467. }
  6468. /*:571*/
  6469. #line 12679 "./typica.w"
  6470. if(!valid)
  6471. {
  6472. return QVariant();
  6473. }
  6474. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6475. QMap<int,QVariant> cell= row.at(index.column());
  6476. return cell.value(role,QVariant());
  6477. }
  6478. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6479. int role)const
  6480. {
  6481. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6482. section<colcount)
  6483. {
  6484. return QVariant(hData.at(section));
  6485. }
  6486. return QVariant();
  6487. }
  6488. /*:577*//*578:*/
  6489. #line 12703 "./typica.w"
  6490. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6491. {
  6492. /*571:*/
  6493. #line 12599 "./typica.w"
  6494. bool valid= false;
  6495. if(index.isValid())
  6496. {
  6497. if(index.row()<modelData.size())
  6498. {
  6499. if(index.column()<colcount)
  6500. {
  6501. valid= true;
  6502. }
  6503. }
  6504. }
  6505. /*:571*/
  6506. #line 12706 "./typica.w"
  6507. if(valid)
  6508. {
  6509. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6510. }
  6511. return 0;
  6512. }
  6513. /*:578*//*579:*/
  6514. #line 12717 "./typica.w"
  6515. QModelIndex SaltModel::index(int row,int column,
  6516. const QModelIndex&parent)const
  6517. {
  6518. if(parent==QModelIndex())
  6519. {
  6520. if(row<modelData.size()&&column<colcount)
  6521. {
  6522. return createIndex(row,column);
  6523. }
  6524. }
  6525. return QModelIndex();
  6526. }
  6527. /*:579*//*580:*/
  6528. #line 12735 "./typica.w"
  6529. void SaltModel::clear()
  6530. {
  6531. beginResetModel();
  6532. modelData.clear();
  6533. /*572:*/
  6534. #line 12615 "./typica.w"
  6535. QList<QMap<int,QVariant> > newRow;
  6536. QMap<int,QVariant> defaults;
  6537. for(int i= 0;i<colcount;i++)
  6538. {
  6539. newRow.append(defaults);
  6540. }
  6541. modelData.append(newRow);
  6542. /*:572*/
  6543. #line 12740 "./typica.w"
  6544. endResetModel();
  6545. }
  6546. /*:580*//*581:*/
  6547. #line 12749 "./typica.w"
  6548. bool SaltModel::removeRows(int row,int count,
  6549. const QModelIndex&parent)
  6550. {
  6551. if(parent==QModelIndex())
  6552. {
  6553. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6554. {
  6555. beginRemoveRows(parent,row,row+count-1);
  6556. for(int i= 0;i<count;i++)
  6557. {
  6558. modelData.removeAt(row);
  6559. }
  6560. endRemoveRows();
  6561. if(modelData.size()==0)
  6562. {
  6563. beginInsertRows(parent,0,0);
  6564. /*572:*/
  6565. #line 12615 "./typica.w"
  6566. QList<QMap<int,QVariant> > newRow;
  6567. QMap<int,QVariant> defaults;
  6568. for(int i= 0;i<colcount;i++)
  6569. {
  6570. newRow.append(defaults);
  6571. }
  6572. modelData.append(newRow);
  6573. /*:572*/
  6574. #line 12766 "./typica.w"
  6575. endInsertRows();
  6576. }
  6577. return true;
  6578. }
  6579. }
  6580. return false;
  6581. }
  6582. /*:581*//*582:*/
  6583. #line 12780 "./typica.w"
  6584. int SaltModel::findData(const QVariant&value,int column,int role)
  6585. {
  6586. for(int i= 0;i<modelData.size();i++)
  6587. {
  6588. if(modelData.at(i).size()> column)
  6589. {
  6590. if(modelData.at(i).at(column).contains(role))
  6591. {
  6592. if(modelData.at(i).at(column).value(role)==value)
  6593. {
  6594. return i;
  6595. }
  6596. }
  6597. }
  6598. }
  6599. return-1;
  6600. }
  6601. /*:582*/
  6602. #line 561 "./typica.w"
  6603. /*584:*/
  6604. #line 12844 "./typica.w"
  6605. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6606. {
  6607. SqlComboBox*widget= new SqlComboBox();
  6608. widget->setParent(parent);
  6609. for(int i= 0;i<count();i++)
  6610. {
  6611. widget->addItem(itemText(i),itemData(i));
  6612. }
  6613. return widget;
  6614. }
  6615. /*:584*//*585:*/
  6616. #line 12861 "./typica.w"
  6617. void SqlComboBox::showData(bool show)
  6618. {
  6619. dataColumnShown= show;
  6620. }
  6621. /*:585*//*586:*/
  6622. #line 12875 "./typica.w"
  6623. void SqlComboBox::addNullOption()
  6624. {
  6625. addItem(specialNullText,specialNullData);
  6626. }
  6627. void SqlComboBox::setNullText(QString nullText)
  6628. {
  6629. specialNullText= nullText;
  6630. }
  6631. void SqlComboBox::setNullData(QVariant nullData)
  6632. {
  6633. specialNullData= nullData;
  6634. }
  6635. /*:586*//*587:*/
  6636. #line 12898 "./typica.w"
  6637. void SqlComboBox::setDataColumn(int column)
  6638. {
  6639. dataColumn= column;
  6640. }
  6641. void SqlComboBox::setDisplayColumn(int column)
  6642. {
  6643. displayColumn= column;
  6644. }
  6645. /*:587*//*588:*/
  6646. #line 12912 "./typica.w"
  6647. void SqlComboBox::addSqlOptions(QString query)
  6648. {
  6649. SqlQueryConnection h;
  6650. QSqlQuery*dbquery= h.operator->();
  6651. if(!dbquery->exec(query))
  6652. {
  6653. QSqlError error= dbquery->lastError();
  6654. qDebug()<<error.databaseText();
  6655. qDebug()<<error.driverText();
  6656. qDebug()<<error.text();
  6657. qDebug()<<dbquery->lastQuery();
  6658. }
  6659. while(dbquery->next())
  6660. {
  6661. QString displayValue(dbquery->value(displayColumn).toString());
  6662. QString dataValue(dbquery->value(dataColumn).toString());
  6663. if(dataColumnShown)
  6664. {
  6665. displayValue.append(QString(" (%1)").arg(dataValue));
  6666. }
  6667. addItem(displayValue,dataValue);
  6668. }
  6669. }
  6670. /*:588*//*589:*/
  6671. #line 12948 "./typica.w"
  6672. SqlComboBox::SqlComboBox():
  6673. dataColumn(0),displayColumn(0),dataColumnShown(false),
  6674. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  6675. {
  6676. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6677. }
  6678. SqlComboBox::~SqlComboBox()
  6679. {
  6680. }
  6681. /*:589*/
  6682. #line 562 "./typica.w"
  6683. /*591:*/
  6684. #line 12987 "./typica.w"
  6685. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6686. {
  6687. delegate= widget;
  6688. }
  6689. /*:591*//*592:*/
  6690. #line 12996 "./typica.w"
  6691. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6692. const QStyleOptionViewItem&,
  6693. const QModelIndex&)const
  6694. {
  6695. return delegate->clone(parent);
  6696. }
  6697. /*:592*//*593:*/
  6698. #line 13007 "./typica.w"
  6699. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6700. const QModelIndex&index)const
  6701. {
  6702. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6703. self->setCurrentIndex(self->findData(
  6704. index.model()->data(index,
  6705. Qt::UserRole).toString()));
  6706. }
  6707. /*:593*//*594:*/
  6708. #line 13020 "./typica.w"
  6709. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6710. QAbstractItemModel*model,
  6711. const QModelIndex&index)const
  6712. {
  6713. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6714. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6715. Qt::UserRole);
  6716. model->setData(index,self->currentText(),Qt::DisplayRole);
  6717. }
  6718. /*:594*//*595:*/
  6719. #line 13033 "./typica.w"
  6720. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6721. const QStyleOptionViewItem&option,
  6722. const QModelIndex&)const
  6723. {
  6724. editor->setGeometry(option.rect);
  6725. }
  6726. /*:595*//*596:*/
  6727. #line 13044 "./typica.w"
  6728. QSize SqlComboBoxDelegate::sizeHint()const
  6729. {
  6730. return delegate->sizeHint();
  6731. }
  6732. /*:596*//*597:*/
  6733. #line 13052 "./typica.w"
  6734. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  6735. :QItemDelegate(parent)
  6736. {
  6737. }
  6738. /*:597*/
  6739. #line 563 "./typica.w"
  6740. /*560:*/
  6741. #line 12314 "./typica.w"
  6742. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  6743. {
  6744. /*561:*/
  6745. #line 12329 "./typica.w"
  6746. setOrganizationName("Wilson's Coffee & Tea");
  6747. setOrganizationDomain("wilsonscoffee.com");
  6748. setApplicationName(PROGRAM_NAME);
  6749. /*:561*/
  6750. #line 12317 "./typica.w"
  6751. /*562:*/
  6752. #line 12338 "./typica.w"
  6753. QTranslator base;
  6754. if(base.load(QString("qt_%1").arg(QLocale::system().name())))
  6755. {
  6756. installTranslator(&base);
  6757. }
  6758. QTranslator app;
  6759. if(app.load(QString("%1_%2").arg("Typica").arg(QLocale::system().name())))
  6760. {
  6761. installTranslator(&app);
  6762. }
  6763. /*:562*/
  6764. #line 12318 "./typica.w"
  6765. /*280:*/
  6766. #line 123 "./measurement.w"
  6767. qRegisterMetaType<Measurement> ("Measurement");
  6768. /*:280*/
  6769. #line 12319 "./typica.w"
  6770. /*768:*/
  6771. #line 16253 "./typica.w"
  6772. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  6773. tr("NI DAQmx Base"),
  6774. "nidaqmxbase",NULL);
  6775. topLevelNodeInserters.append(inserter);
  6776. /*:768*//*776:*/
  6777. #line 16484 "./typica.w"
  6778. #ifdef Q_OS_WIN32
  6779. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  6780. topLevelNodeInserters.append(inserter);
  6781. #endif
  6782. /*:776*//*800:*/
  6783. #line 17447 "./typica.w"
  6784. #if 0
  6785. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  6786. topLevelNodeInserters.append(inserter);
  6787. #endif
  6788. /*:800*//*849:*/
  6789. #line 18960 "./typica.w"
  6790. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  6791. topLevelNodeInserters.append(inserter);
  6792. #line 1 "./unsupportedserial.w"
  6793. /*:849*//*859:*/
  6794. #line 272 "./unsupportedserial.w"
  6795. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  6796. "unsupporteddevice",NULL);
  6797. topLevelNodeInserters.append(inserter);
  6798. /*:859*//*893:*/
  6799. #line 190 "./phidgets.w"
  6800. QLibrary phidgetsCheck("phidget21");
  6801. if(phidgetsCheck.load())
  6802. {
  6803. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  6804. "phidgets1048",NULL);
  6805. topLevelNodeInserters.append(inserter);
  6806. phidgetsCheck.unload();
  6807. }
  6808. else
  6809. {
  6810. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  6811. if(phidgetsCheck.load())
  6812. {
  6813. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  6814. "phidgets1048",NULL);
  6815. topLevelNodeInserters.append(inserter);
  6816. phidgetsCheck.unload();
  6817. }
  6818. }
  6819. /*:893*//*970:*/
  6820. #line 1241 "./dataqsdk.w"
  6821. #ifdef Q_OS_WIN32
  6822. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  6823. "dataqsdk",NULL);
  6824. topLevelNodeInserters.append(inserter);
  6825. #endif
  6826. #line 19184 "./typica.w"
  6827. #line 1 "./scales.w"
  6828. /*:970*//*995:*/
  6829. #line 495 "./scales.w"
  6830. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  6831. topLevelNodeInserters.append(inserter);
  6832. #line 19186 "./typica.w"
  6833. #line 1 "./valueannotation.w"
  6834. /*:995*/
  6835. #line 12320 "./typica.w"
  6836. }
  6837. /*:560*//*564:*/
  6838. #line 12361 "./typica.w"
  6839. QDomDocument*Application::configuration()
  6840. {
  6841. return&conf;
  6842. }
  6843. /*:564*//*565:*/
  6844. #line 12370 "./typica.w"
  6845. QSqlDatabase Application::database()
  6846. {
  6847. QString connectionName;
  6848. QSqlDatabase connection=
  6849. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  6850. do
  6851. {
  6852. connectionName= QUuid::createUuid().toString();
  6853. }while(QSqlDatabase::connectionNames().contains(connectionName));
  6854. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  6855. }
  6856. /*:565*//*703:*/
  6857. #line 14856 "./typica.w"
  6858. void Application::saveDeviceConfiguration()
  6859. {
  6860. QSettings settings;
  6861. settings.setValue("DeviceConfiguration",
  6862. QVariant(deviceConfigurationDocument.toByteArray()));
  6863. }
  6864. /*:703*//*704:*/
  6865. #line 14868 "./typica.w"
  6866. QDomDocument Application::deviceConfiguration()
  6867. {
  6868. if(deviceConfigurationDocument.isNull())
  6869. {
  6870. /*705:*/
  6871. #line 14882 "./typica.w"
  6872. QSettings settings;
  6873. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  6874. QString etext;
  6875. int eline;
  6876. int ecol;
  6877. if(document.length()==0)
  6878. {
  6879. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  6880. /*706:*/
  6881. #line 14906 "./typica.w"
  6882. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6883. emptyDocument.open(QIODevice::ReadOnly);
  6884. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6885. &etext,&eline,&ecol))
  6886. {
  6887. /*707:*/
  6888. #line 14923 "./typica.w"
  6889. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6890. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6891. qDebug()<<etext;
  6892. /*:707*/
  6893. #line 14912 "./typica.w"
  6894. }
  6895. else
  6896. {
  6897. saveDeviceConfiguration();
  6898. }
  6899. /*:706*/
  6900. #line 14891 "./typica.w"
  6901. }
  6902. else
  6903. {
  6904. if(!deviceConfigurationDocument.setContent(document,false,
  6905. &etext,&eline,&ecol))
  6906. {
  6907. /*707:*/
  6908. #line 14923 "./typica.w"
  6909. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6910. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6911. qDebug()<<etext;
  6912. /*:707*/
  6913. #line 14898 "./typica.w"
  6914. /*706:*/
  6915. #line 14906 "./typica.w"
  6916. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6917. emptyDocument.open(QIODevice::ReadOnly);
  6918. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6919. &etext,&eline,&ecol))
  6920. {
  6921. /*707:*/
  6922. #line 14923 "./typica.w"
  6923. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6924. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6925. qDebug()<<etext;
  6926. /*:707*/
  6927. #line 14912 "./typica.w"
  6928. }
  6929. else
  6930. {
  6931. saveDeviceConfiguration();
  6932. }
  6933. /*:706*/
  6934. #line 14899 "./typica.w"
  6935. }
  6936. }
  6937. /*:705*/
  6938. #line 14873 "./typica.w"
  6939. }
  6940. return deviceConfigurationDocument;
  6941. }
  6942. /*:704*//*735:*/
  6943. #line 15524 "./typica.w"
  6944. void Application::registerDeviceConfigurationWidget(QString driver,
  6945. QMetaObject widget)
  6946. {
  6947. deviceConfigurationWidgets.insert(driver,widget);
  6948. }
  6949. /*:735*//*736:*/
  6950. #line 15540 "./typica.w"
  6951. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  6952. const QModelIndex&index)
  6953. {
  6954. QVariant nodeReference= index.data(Qt::UserRole);
  6955. QDomElement referenceElement= model->referenceElement(
  6956. model->data(index,Qt::UserRole).toString());
  6957. QMetaObject metaObject=
  6958. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  6959. QWidget::staticMetaObject);
  6960. QWidget*editor;
  6961. if(metaObject.className()==QWidget::staticMetaObject.className())
  6962. {
  6963. editor= NULL;
  6964. }
  6965. else
  6966. {
  6967. editor= qobject_cast<QWidget*> (
  6968. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  6969. Q_ARG(QModelIndex,index)));
  6970. }
  6971. return editor;
  6972. }
  6973. /*:736*/
  6974. #line 564 "./typica.w"
  6975. /*606:*/
  6976. #line 13199 "./typica.w"
  6977. SqlConnectionSetup::SqlConnectionSetup():
  6978. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  6979. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  6980. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  6981. cancelButton(new QPushButton(tr("Cancel"))),
  6982. connectButton(new QPushButton(tr("Connect")))
  6983. {
  6984. driver->addItem("PostgreSQL","QPSQL");
  6985. formLayout->addRow(tr("Database driver:"),driver);
  6986. formLayout->addRow(tr("Host name:"),hostname);
  6987. formLayout->addRow(tr("Database name:"),dbname);
  6988. formLayout->addRow(tr("User name:"),user);
  6989. password->setEchoMode(QLineEdit::Password);
  6990. formLayout->addRow(tr("Password:"),password);
  6991. layout->addLayout(formLayout);
  6992. buttons->addStretch(1);
  6993. buttons->addWidget(cancelButton);
  6994. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  6995. buttons->addWidget(connectButton);
  6996. layout->addLayout(buttons);
  6997. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  6998. setLayout(layout);
  6999. setModal(true);
  7000. }
  7001. SqlConnectionSetup::~SqlConnectionSetup()
  7002. {
  7003. }
  7004. /*:606*//*607:*/
  7005. #line 13233 "./typica.w"
  7006. void SqlConnectionSetup::testConnection()
  7007. {
  7008. QSqlDatabase database=
  7009. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7010. toString());
  7011. database.setConnectOptions("application_name=Typica");
  7012. database.setHostName(hostname->text());
  7013. database.setDatabaseName(dbname->text());
  7014. database.setUserName(user->text());
  7015. database.setPassword(password->text());
  7016. if(database.open())
  7017. {
  7018. QSettings settings;
  7019. settings.setValue("database/exists","true");
  7020. settings.setValue("database/driver",
  7021. driver->itemData(driver->currentIndex()).toString());
  7022. settings.setValue("database/hostname",hostname->text());
  7023. settings.setValue("database/dbname",dbname->text());
  7024. settings.setValue("database/user",user->text());
  7025. settings.setValue("database/password",password->text());
  7026. database.close();
  7027. accept();
  7028. }
  7029. else
  7030. {
  7031. QMessageBox::information(this,tr("Database connection failed"),
  7032. tr("Failed to connect to database."));
  7033. }
  7034. }
  7035. /*:607*/
  7036. #line 565 "./typica.w"
  7037. /*611:*/
  7038. #line 13335 "./typica.w"
  7039. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7040. {
  7041. setModel(new QSqlQueryModel);
  7042. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7043. this,SLOT(openRow(QModelIndex)));
  7044. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7045. this,SLOT(persistColumnResize(int,int,int)));
  7046. }
  7047. /*:611*//*612:*/
  7048. #line 13350 "./typica.w"
  7049. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7050. {
  7051. /*613:*/
  7052. #line 13359 "./typica.w"
  7053. QSettings settings;
  7054. /*614:*/
  7055. #line 13372 "./typica.w"
  7056. QWidget*topLevelWidget= this;
  7057. while(topLevelWidget->parentWidget())
  7058. {
  7059. topLevelWidget= topLevelWidget->parentWidget();
  7060. }
  7061. /*:614*/
  7062. #line 13361 "./typica.w"
  7063. settings.setValue(QString("columnWidths/%1/%2/%3").
  7064. arg(topLevelWidget->objectName()).
  7065. arg(objectName()).arg(column),
  7066. QVariant(newsize));
  7067. /*:613*/
  7068. #line 13353 "./typica.w"
  7069. }
  7070. /*:612*//*615:*/
  7071. #line 13382 "./typica.w"
  7072. void SqlQueryView::showEvent(QShowEvent*event)
  7073. {
  7074. /*616:*/
  7075. #line 13392 "./typica.w"
  7076. QSettings settings;
  7077. /*614:*/
  7078. #line 13372 "./typica.w"
  7079. QWidget*topLevelWidget= this;
  7080. while(topLevelWidget->parentWidget())
  7081. {
  7082. topLevelWidget= topLevelWidget->parentWidget();
  7083. }
  7084. /*:614*/
  7085. #line 13394 "./typica.w"
  7086. QString baseKey=
  7087. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7088. arg(objectName());
  7089. for(int i= 0;i<model()->columnCount();i++)
  7090. {
  7091. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7092. if(settings.contains(key))
  7093. {
  7094. setColumnWidth(i,settings.value(key).toInt());
  7095. }
  7096. }
  7097. /*:616*/
  7098. #line 13385 "./typica.w"
  7099. event->accept();
  7100. }
  7101. /*:615*//*617:*/
  7102. #line 13409 "./typica.w"
  7103. void SqlQueryView::openRow(const QModelIndex&index)
  7104. {
  7105. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7106. emit openEntryRow(index.row());
  7107. }
  7108. /*:617*//*618:*/
  7109. #line 13418 "./typica.w"
  7110. void SqlQueryView::setQuery(const QString&query)
  7111. {
  7112. QSqlDatabase database= AppInstance->database();
  7113. database.open();
  7114. QSqlQuery q(query,database);
  7115. ((QSqlQueryModel*)model())->setQuery(q);
  7116. database.close();
  7117. }
  7118. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7119. const QVariant&value,int role)
  7120. {
  7121. return model()->setHeaderData(section,orientation,value,role);
  7122. }
  7123. /*:618*//*619:*/
  7124. #line 13436 "./typica.w"
  7125. QVariant SqlQueryView::data(int row,int column,int role)
  7126. {
  7127. return model()->data(model()->index(row,column),role);
  7128. }
  7129. /*:619*/
  7130. #line 566 "./typica.w"
  7131. /*161:*/
  7132. #line 3801 "./typica.w"
  7133. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7134. {
  7135. QSqlDatabase database= AppInstance->database();
  7136. database.open();
  7137. q= new QSqlQuery(query,database);
  7138. connection= database.connectionName();
  7139. }
  7140. /*:161*//*162:*/
  7141. #line 3814 "./typica.w"
  7142. SqlQueryConnection::~SqlQueryConnection()
  7143. {
  7144. delete q;
  7145. {
  7146. QSqlDatabase database= QSqlDatabase::database(connection);
  7147. database.close();
  7148. }
  7149. QSqlDatabase::removeDatabase(connection);
  7150. }
  7151. /*:162*//*163:*/
  7152. #line 3828 "./typica.w"
  7153. QSqlQuery*SqlQueryConnection::operator->()const
  7154. {
  7155. return q;
  7156. }
  7157. /*:163*/
  7158. #line 567 "./typica.w"
  7159. /*638:*/
  7160. #line 13793 "./typica.w"
  7161. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7162. area(frame),configuration(description)
  7163. {
  7164. refresh();
  7165. }
  7166. ReportTable::~ReportTable()
  7167. {
  7168. }
  7169. /*:638*//*639:*/
  7170. #line 13809 "./typica.w"
  7171. void ReportTable::bind(QString placeholder,QVariant value)
  7172. {
  7173. bindings.insert(placeholder,value);
  7174. }
  7175. /*:639*//*640:*/
  7176. #line 13819 "./typica.w"
  7177. void ReportTable::refresh()
  7178. {
  7179. /*641:*/
  7180. #line 13840 "./typica.w"
  7181. QTextCursor cursor= area->firstCursorPosition();
  7182. while(cursor<area->lastCursorPosition())
  7183. {
  7184. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7185. }
  7186. cursor.removeSelectedText();
  7187. /*:641*/
  7188. #line 13822 "./typica.w"
  7189. int rows= 1;
  7190. int columns= 1;
  7191. int currentRow= 0;
  7192. QTextTable*table= cursor.insertTable(rows,columns);
  7193. /*642:*/
  7194. #line 13853 "./typica.w"
  7195. QTextTableFormat format= table->format();
  7196. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7197. if(configuration.hasAttribute("align"))
  7198. {
  7199. if(configuration.attribute("align")=="center")
  7200. {
  7201. format.setAlignment(Qt::AlignHCenter);
  7202. }
  7203. }
  7204. table->setFormat(format);
  7205. /*:642*/
  7206. #line 13827 "./typica.w"
  7207. /*643:*/
  7208. #line 13867 "./typica.w"
  7209. QDomNodeList children= configuration.childNodes();
  7210. for(int i= 0;i<children.count();i++)
  7211. {
  7212. QDomNode current;
  7213. QDomElement currentElement;
  7214. current= children.at(i);
  7215. if(current.isElement())
  7216. {
  7217. currentElement= current.toElement();
  7218. if(currentElement.tagName()=="query")
  7219. {
  7220. /*644:*/
  7221. #line 13894 "./typica.w"
  7222. SqlQueryConnection h;
  7223. QSqlQuery*query= h.operator->();
  7224. query->prepare(currentElement.text());
  7225. foreach(QString key,bindings.uniqueKeys())
  7226. {
  7227. if(currentElement.text().contains(key))
  7228. {
  7229. query->bindValue(key,bindings.value(key));
  7230. }
  7231. }
  7232. query->exec();
  7233. if(!query->next())
  7234. {
  7235. continue;
  7236. }
  7237. if(query->record().count()> columns)
  7238. {
  7239. table->appendColumns(query->record().count()-columns);
  7240. }
  7241. do
  7242. {
  7243. table->appendRows(1);
  7244. rows++;
  7245. currentRow++;
  7246. for(int j= 0;j<query->record().count();j++)
  7247. {
  7248. QTextTableCell cell= table->cellAt(currentRow,j);
  7249. cursor= cell.firstCursorPosition();
  7250. cursor.insertText(query->value(j).toString());
  7251. }
  7252. }while(query->next());
  7253. /*:644*/
  7254. #line 13879 "./typica.w"
  7255. }
  7256. else if(currentElement.tagName()=="row")
  7257. {
  7258. /*645:*/
  7259. #line 13934 "./typica.w"
  7260. table->appendRows(1);
  7261. currentRow++;
  7262. rows++;
  7263. QDomNodeList rowChildren= currentElement.childNodes();
  7264. int currentColumn= 0;
  7265. for(int j= 0;j<rowChildren.count();j++)
  7266. {
  7267. QDomNode node;
  7268. QDomElement nodeElement;
  7269. node= rowChildren.at(j);
  7270. if(node.isElement())
  7271. {
  7272. nodeElement= node.toElement();
  7273. if(nodeElement.tagName()=="cell")
  7274. {
  7275. if(currentColumn==columns)
  7276. {
  7277. table->appendColumns(1);
  7278. columns++;
  7279. }
  7280. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7281. cursor= cell.firstCursorPosition();
  7282. cursor.insertText(nodeElement.text());
  7283. currentColumn++;
  7284. }
  7285. }
  7286. }
  7287. /*:645*/
  7288. #line 13883 "./typica.w"
  7289. }
  7290. }
  7291. }
  7292. /*:643*/
  7293. #line 13828 "./typica.w"
  7294. if(rows> 1)
  7295. {
  7296. table->removeRows(0,1);
  7297. }
  7298. }
  7299. /*:640*/
  7300. #line 568 "./typica.w"
  7301. /*671:*/
  7302. #line 14038 "./typica.w"
  7303. FormArray::FormArray(QDomElement description):configuration(description),
  7304. maxwidth(-1),maxheight(-1)
  7305. {
  7306. setWidget(&itemContainer);
  7307. itemContainer.setLayout(&itemLayout);
  7308. }
  7309. /*:671*//*672:*/
  7310. #line 14055 "./typica.w"
  7311. void FormArray::addElements(int copies)
  7312. {
  7313. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7314. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7315. QWidget*widget;
  7316. for(int i= 0;i<copies;i++)
  7317. {
  7318. widget= new QWidget;
  7319. if(maxwidth> -1)
  7320. {
  7321. widget->setMaximumWidth(maxwidth);
  7322. }
  7323. if(maxheight> -1)
  7324. {
  7325. widget->setMaximumHeight(maxheight);
  7326. }
  7327. if(configuration.hasChildNodes())
  7328. {
  7329. widgetStack->push(widget);
  7330. populateWidget(configuration,widgetStack,layoutStack);
  7331. widgetStack->pop();
  7332. widget->setMinimumHeight(widget->sizeHint().height());
  7333. itemLayout.addWidget(widget);
  7334. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7335. {
  7336. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7337. }
  7338. else
  7339. {
  7340. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7341. +widget->sizeHint().height());
  7342. }
  7343. if(maxwidth> -1)
  7344. {
  7345. itemContainer.setMinimumWidth(maxwidth+50);
  7346. }
  7347. else
  7348. {
  7349. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7350. }
  7351. }
  7352. }
  7353. }
  7354. /*:672*//*673:*/
  7355. #line 14105 "./typica.w"
  7356. QWidget*FormArray::elementAt(int index)
  7357. {
  7358. if(index<itemLayout.count())
  7359. {
  7360. QLayoutItem*item= itemLayout.itemAt(index);
  7361. return item->widget();
  7362. }
  7363. else
  7364. {
  7365. return NULL;
  7366. }
  7367. }
  7368. /*:673*//*674:*/
  7369. #line 14122 "./typica.w"
  7370. void FormArray::removeAllElements()
  7371. {
  7372. while(itemLayout.count()> 0)
  7373. {
  7374. QLayoutItem*item;
  7375. item= itemLayout.itemAt(0);
  7376. item->widget()->hide();
  7377. itemLayout.removeWidget(item->widget());
  7378. }
  7379. itemContainer.setMinimumHeight(0);
  7380. }
  7381. /*:674*//*675:*/
  7382. #line 14138 "./typica.w"
  7383. int FormArray::elements()
  7384. {
  7385. return itemLayout.count();
  7386. }
  7387. /*:675*//*676:*/
  7388. #line 14149 "./typica.w"
  7389. void FormArray::setMaximumElementWidth(int width)
  7390. {
  7391. maxwidth= width;
  7392. }
  7393. void FormArray::setMaximumElementHeight(int height)
  7394. {
  7395. maxheight= height;
  7396. }
  7397. /*:676*/
  7398. #line 569 "./typica.w"
  7399. /*682:*/
  7400. #line 14280 "./typica.w"
  7401. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7402. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7403. {
  7404. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7405. QPointF(0,5);
  7406. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7407. QPointF(10,5);
  7408. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7409. QPointF(0,0);
  7410. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7411. initialBrush.setColor(QColor(170,170,255));
  7412. initialBrush.setStyle(Qt::SolidPattern);
  7413. finalBrush.setColor(Qt::blue);
  7414. finalBrush.setStyle(Qt::SolidPattern);
  7415. initialDecrement.setPolygon(left);
  7416. initialDecrement.setBrush(initialBrush);
  7417. initialDecrement.setPos(0,0);
  7418. scene.addItem(&initialDecrement);
  7419. initialIncrement.setPolygon(right);
  7420. initialIncrement.setBrush(initialBrush);
  7421. initialIncrement.setPos(122,0);
  7422. scene.addItem(&initialIncrement);
  7423. finalDecrement.setPolygon(left);
  7424. finalDecrement.setBrush(finalBrush);
  7425. finalDecrement.setPos(0,12);
  7426. scene.addItem(&finalDecrement);
  7427. finalIncrement.setPolygon(right);
  7428. finalIncrement.setBrush(finalBrush);
  7429. finalIncrement.setPos(122,12);
  7430. scene.addItem(&finalIncrement);
  7431. scalePath.moveTo(0,10);
  7432. scalePath.lineTo(100,10);
  7433. scalePath.moveTo(0,0);
  7434. scalePath.lineTo(0,20);
  7435. scalePath.moveTo(10,5);
  7436. scalePath.lineTo(10,15);
  7437. scalePath.moveTo(20,5);
  7438. scalePath.lineTo(20,15);
  7439. scalePath.moveTo(30,5);
  7440. scalePath.lineTo(30,15);
  7441. scalePath.moveTo(40,5);
  7442. scalePath.lineTo(40,15);
  7443. scalePath.moveTo(50,0);
  7444. scalePath.lineTo(50,20);
  7445. scalePath.moveTo(60,5);
  7446. scalePath.lineTo(60,15);
  7447. scalePath.moveTo(70,5);
  7448. scalePath.lineTo(70,15);
  7449. scalePath.moveTo(80,5);
  7450. scalePath.lineTo(80,15);
  7451. scalePath.moveTo(90,5);
  7452. scalePath.lineTo(90,15);
  7453. scalePath.moveTo(100,0);
  7454. scalePath.lineTo(100,20);
  7455. scaleLine.setPath(scalePath);
  7456. scaleLine.setPos(16,1);
  7457. scene.addItem(&scaleLine);
  7458. setScene(&scene);
  7459. initialIndicator.setPolygon(down);
  7460. initialIndicator.setBrush(initialBrush);
  7461. finalIndicator.setPolygon(up);
  7462. finalIndicator.setBrush(finalBrush);
  7463. setMinimumSize(sizeHint());
  7464. setMaximumSize(sizeHint());
  7465. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7466. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7467. setMinimumSize(sizeHint());
  7468. }
  7469. /*:682*//*683:*/
  7470. #line 14353 "./typica.w"
  7471. QSize ScaleControl::sizeHint()const
  7472. {
  7473. return QSize(140,30);
  7474. }
  7475. /*:683*//*684:*/
  7476. #line 14362 "./typica.w"
  7477. void ScaleControl::setInitialValue(double value)
  7478. {
  7479. if(value>=0&&value<=10)
  7480. {
  7481. nonScoredValue= value;
  7482. if(!initialSet)
  7483. {
  7484. scene.addItem(&initialIndicator);
  7485. }
  7486. initialSet= true;
  7487. initialIndicator.setPos(value*10+16,10);
  7488. emit initialChanged(value);
  7489. if(!finalSet)
  7490. {
  7491. setFinalValue(value);
  7492. }
  7493. }
  7494. }
  7495. void ScaleControl::setFinalValue(double value)
  7496. {
  7497. if(value>=0&&value<=10)
  7498. {
  7499. scoredValue= value;
  7500. if(!finalSet)
  7501. {
  7502. scene.addItem(&finalIndicator);
  7503. }
  7504. finalSet= true;
  7505. finalIndicator.setPos(value*10+16,11);
  7506. emit finalChanged(value);
  7507. }
  7508. }
  7509. /*:684*//*685:*/
  7510. #line 14399 "./typica.w"
  7511. double ScaleControl::initialValue(void)
  7512. {
  7513. return nonScoredValue;
  7514. }
  7515. double ScaleControl::finalValue(void)
  7516. {
  7517. return scoredValue;
  7518. }
  7519. /*:685*//*686:*/
  7520. #line 14420 "./typica.w"
  7521. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7522. {
  7523. /*687:*/
  7524. #line 14432 "./typica.w"
  7525. if(event->button()!=Qt::LeftButton)
  7526. {
  7527. event->ignore();
  7528. return;
  7529. }
  7530. /*:687*/
  7531. #line 14423 "./typica.w"
  7532. scaleDown= true;
  7533. event->accept();
  7534. }
  7535. /*:686*//*688:*/
  7536. #line 14443 "./typica.w"
  7537. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7538. {
  7539. /*687:*/
  7540. #line 14432 "./typica.w"
  7541. if(event->button()!=Qt::LeftButton)
  7542. {
  7543. event->ignore();
  7544. return;
  7545. }
  7546. /*:687*/
  7547. #line 14446 "./typica.w"
  7548. if(!scaleDown)
  7549. {
  7550. event->ignore();
  7551. return;
  7552. }
  7553. scaleDown= false;
  7554. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7555. /*689:*/
  7556. #line 14468 "./typica.w"
  7557. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7558. {
  7559. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7560. {
  7561. if(initialSet)
  7562. {
  7563. setInitialValue(nonScoredValue-0.05);
  7564. }
  7565. event->accept();
  7566. return;
  7567. }
  7568. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7569. {
  7570. if(finalSet)
  7571. {
  7572. setFinalValue(scoredValue-0.05);
  7573. event->accept();
  7574. return;
  7575. }
  7576. }
  7577. }
  7578. /*:689*/
  7579. #line 14454 "./typica.w"
  7580. /*690:*/
  7581. #line 14494 "./typica.w"
  7582. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7583. {
  7584. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7585. {
  7586. if(initialSet)
  7587. {
  7588. setInitialValue(nonScoredValue+0.05);
  7589. event->accept();
  7590. return;
  7591. }
  7592. }
  7593. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7594. {
  7595. if(finalSet)
  7596. {
  7597. setFinalValue(scoredValue+0.05);
  7598. event->accept();
  7599. return;
  7600. }
  7601. }
  7602. }
  7603. /*:690*/
  7604. #line 14455 "./typica.w"
  7605. /*691:*/
  7606. #line 14520 "./typica.w"
  7607. double relativeX= sceneCoordinate.x()-16;
  7608. if(initialSet)
  7609. {
  7610. if(relativeX>=0&&relativeX<=100)
  7611. {
  7612. setFinalValue(relativeX/10.0);
  7613. event->accept();
  7614. return;
  7615. }
  7616. }
  7617. else
  7618. {
  7619. if(relativeX>=0&&relativeX<=100)
  7620. {
  7621. setInitialValue(relativeX/10.0);
  7622. event->accept();
  7623. return;
  7624. }
  7625. }
  7626. /*:691*/
  7627. #line 14456 "./typica.w"
  7628. event->ignore();
  7629. return;
  7630. }
  7631. /*:688*/
  7632. #line 570 "./typica.w"
  7633. /*693:*/
  7634. #line 14586 "./typica.w"
  7635. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7636. valueSet(false),scaleDown(false)
  7637. {
  7638. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7639. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7640. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7641. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7642. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7643. theBrush.setColor(Qt::blue);
  7644. theBrush.setStyle(Qt::SolidPattern);
  7645. increment.setPolygon(up);
  7646. increment.setBrush(theBrush);
  7647. increment.setPos(0,0);
  7648. scene.addItem(&increment);
  7649. decrement.setPolygon(down);
  7650. decrement.setBrush(theBrush);
  7651. decrement.setPos(0,122);
  7652. scene.addItem(&decrement);
  7653. scalePath.moveTo(5,0);
  7654. scalePath.lineTo(5,100);
  7655. scalePath.moveTo(0,0);
  7656. scalePath.lineTo(10,0);
  7657. scalePath.moveTo(0,10);
  7658. scalePath.lineTo(10,10);
  7659. scalePath.moveTo(0,20);
  7660. scalePath.lineTo(10,20);
  7661. scalePath.moveTo(0,30);
  7662. scalePath.lineTo(10,30);
  7663. scalePath.moveTo(0,40);
  7664. scalePath.lineTo(10,40);
  7665. scalePath.moveTo(0,50);
  7666. scalePath.lineTo(10,50);
  7667. scalePath.moveTo(0,60);
  7668. scalePath.lineTo(10,60);
  7669. scalePath.moveTo(0,70);
  7670. scalePath.lineTo(10,70);
  7671. scalePath.moveTo(0,80);
  7672. scalePath.lineTo(10,80);
  7673. scalePath.moveTo(0,90);
  7674. scalePath.lineTo(10,90);
  7675. scalePath.moveTo(0,100);
  7676. scalePath.lineTo(10,100);
  7677. scaleLine.setPath(scalePath);
  7678. scaleLine.setPos(0,16);
  7679. scene.addItem(&scaleLine);
  7680. setScene(&scene);
  7681. indicator.setPolygon(left);
  7682. indicator.setBrush(theBrush);
  7683. setMinimumSize(sizeHint());
  7684. setMaximumSize(sizeHint());
  7685. }
  7686. /*:693*//*694:*/
  7687. #line 14641 "./typica.w"
  7688. QSize IntensityControl::sizeHint()const
  7689. {
  7690. return QSize(25,160);
  7691. }
  7692. /*:694*//*695:*/
  7693. #line 14656 "./typica.w"
  7694. void IntensityControl::setValue(double val)
  7695. {
  7696. if(val>=0&&val<=10)
  7697. {
  7698. theValue= val;
  7699. if(!valueSet)
  7700. {
  7701. scene.addItem(&indicator);
  7702. }
  7703. valueSet= true;
  7704. indicator.setPos(6,(100-(val*10))+16);
  7705. emit(valueChanged(val));
  7706. }
  7707. else if(val<1)
  7708. {
  7709. setValue(0);
  7710. }
  7711. else
  7712. {
  7713. setValue(10);
  7714. }
  7715. }
  7716. double IntensityControl::value()
  7717. {
  7718. return theValue;
  7719. }
  7720. /*:695*//*696:*/
  7721. #line 14688 "./typica.w"
  7722. void IntensityControl::mousePressEvent(QMouseEvent*event)
  7723. {
  7724. /*687:*/
  7725. #line 14432 "./typica.w"
  7726. if(event->button()!=Qt::LeftButton)
  7727. {
  7728. event->ignore();
  7729. return;
  7730. }
  7731. /*:687*/
  7732. #line 14691 "./typica.w"
  7733. scaleDown= true;
  7734. event->accept();
  7735. }
  7736. /*:696*//*697:*/
  7737. #line 14702 "./typica.w"
  7738. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  7739. {
  7740. /*687:*/
  7741. #line 14432 "./typica.w"
  7742. if(event->button()!=Qt::LeftButton)
  7743. {
  7744. event->ignore();
  7745. return;
  7746. }
  7747. /*:687*/
  7748. #line 14705 "./typica.w"
  7749. if(!scaleDown)
  7750. {
  7751. event->ignore();
  7752. return;
  7753. }
  7754. scaleDown= false;
  7755. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7756. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  7757. {
  7758. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7759. {
  7760. if(valueSet)
  7761. {
  7762. setValue(theValue+0.05);
  7763. }
  7764. event->accept();
  7765. return;
  7766. }
  7767. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  7768. {
  7769. if(valueSet)
  7770. {
  7771. setValue(theValue-0.05);
  7772. }
  7773. event->accept();
  7774. return;
  7775. }
  7776. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  7777. {
  7778. setValue(10-((sceneCoordinate.y()-16)/10.0));
  7779. event->accept();
  7780. return;
  7781. }
  7782. }
  7783. }
  7784. /*:697*/
  7785. #line 571 "./typica.w"
  7786. /*349:*/
  7787. #line 7974 "./typica.w"
  7788. void ThresholdDetector::newMeasurement(Measurement measure)
  7789. {
  7790. if((currentDirection==Ascending&&previousValue<threshold&&
  7791. previousValue>=0)||(currentDirection==Descending&&
  7792. previousValue> threshold&&previousValue>=0))
  7793. {
  7794. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  7795. (currentDirection==Descending&&measure.temperature()<=threshold))
  7796. {
  7797. double offset= measure.time().hour()*60*60;
  7798. offset+= measure.time().minute()*60;
  7799. offset+= measure.time().second();
  7800. offset+= measure.time().msec()/1000;
  7801. emit timeForValue(offset);
  7802. }
  7803. }
  7804. previousValue= measure.temperature();
  7805. }
  7806. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  7807. previousValue(-1),threshold(value),currentDirection(Ascending)
  7808. {
  7809. }
  7810. void ThresholdDetector::setThreshold(double value)
  7811. {
  7812. threshold= value;
  7813. }
  7814. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  7815. {
  7816. currentDirection= direction;
  7817. }
  7818. /*:349*/
  7819. #line 572 "./typica.w"
  7820. /*779:*/
  7821. #line 16524 "./typica.w"
  7822. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  7823. lister(new QextSerialEnumerator)
  7824. {
  7825. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  7826. QextPortInfo port;
  7827. foreach(port,ports)
  7828. {
  7829. #ifdef Q_OS_WIN32
  7830. addItem(port.portName);
  7831. #else
  7832. addItem(port.physName);
  7833. #endif
  7834. }
  7835. lister->setUpNotifications();
  7836. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  7837. this,SLOT(addDevice(QextPortInfo)));
  7838. setEditable(true);
  7839. }
  7840. void PortSelector::addDevice(QextPortInfo port)
  7841. {
  7842. addItem(port.portName);
  7843. }
  7844. /*:779*/
  7845. #line 573 "./typica.w"
  7846. /*781:*/
  7847. #line 16616 "./typica.w"
  7848. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  7849. {
  7850. QMetaObject meta= BaudSelector::staticMetaObject;
  7851. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  7852. for(int i= 0;i<type.keyCount();i++)
  7853. {
  7854. addItem(QString("%1").arg(type.value(i)));
  7855. }
  7856. }
  7857. /*:781*/
  7858. #line 574 "./typica.w"
  7859. /*783:*/
  7860. #line 16654 "./typica.w"
  7861. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  7862. {
  7863. QMetaObject meta= ParitySelector::staticMetaObject;
  7864. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  7865. for(int i= 0;i<type.keyCount();i++)
  7866. {
  7867. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7868. }
  7869. }
  7870. /*:783*/
  7871. #line 575 "./typica.w"
  7872. /*785:*/
  7873. #line 16684 "./typica.w"
  7874. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  7875. {
  7876. QMetaObject meta= FlowSelector::staticMetaObject;
  7877. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  7878. for(int i= 0;i<type.keyCount();i++)
  7879. {
  7880. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7881. }
  7882. }
  7883. /*:785*/
  7884. #line 576 "./typica.w"
  7885. /*787:*/
  7886. #line 16719 "./typica.w"
  7887. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  7888. {
  7889. QMetaObject meta= StopSelector::staticMetaObject;
  7890. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  7891. for(int i= 0;i<type.keyCount();i++)
  7892. {
  7893. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7894. }
  7895. }
  7896. /*:787*/
  7897. #line 577 "./typica.w"
  7898. /*847:*/
  7899. #line 18501 "./typica.w"
  7900. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  7901. :BasicDeviceConfigurationWidget(model,index),
  7902. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  7903. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  7904. decimalQuery(new QCheckBox(tr("Enable"))),
  7905. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  7906. unitQuery(new QCheckBox(tr("Enable"))),
  7907. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  7908. valueC(new QSpinBox),fixedUnit(new QComboBox),
  7909. pVAddress(new ShortHexSpinBox),
  7910. sVEnabled(new QCheckBox(tr("Enable"))),
  7911. sVReadAddress(new ShortHexSpinBox),
  7912. deviceLimit(new QCheckBox(tr("Enable"))),
  7913. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  7914. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  7915. sVWritable(new QCheckBox(tr("Enable"))),
  7916. sVOutputAddr(new ShortHexSpinBox),
  7917. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  7918. {
  7919. QHBoxLayout*layout= new QHBoxLayout;
  7920. QWidget*form= new QWidget;
  7921. QHBoxLayout*masterLayout= new QHBoxLayout;
  7922. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  7923. QVBoxLayout*seriesLayout= new QVBoxLayout;
  7924. QFormLayout*serialSection= new QFormLayout;
  7925. serialSection->addRow(QString(tr("Port:")),port);
  7926. serialSection->addRow(QString(tr("Baud rate:")),baud);
  7927. serialSection->addRow(QString(tr("Parity:")),parity);
  7928. serialSection->addRow(QString(tr("Flow control:")),flow);
  7929. serialSection->addRow(QString(tr("Stop bits:")),stop);
  7930. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  7931. serialSectionBox->setLayout(serialSection);
  7932. portAndDeviceLayout->addWidget(serialSectionBox);
  7933. QFormLayout*deviceSection= new QFormLayout;
  7934. station->setMinimum(1);
  7935. station->setMaximum(255);
  7936. decimalPosition->setMinimum(0);
  7937. decimalPosition->setMaximum(9);
  7938. valueF->setMinimum(0);
  7939. valueF->setMaximum(0xFFFF);
  7940. valueC->setMinimum(0);
  7941. valueC->setMaximum(0xFFFF);
  7942. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  7943. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  7944. deviceSection->addRow(tr("Station:"),station);
  7945. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  7946. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  7947. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  7948. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  7949. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  7950. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  7951. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  7952. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  7953. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  7954. deviceSectionBox->setLayout(deviceSection);
  7955. portAndDeviceLayout->addWidget(deviceSectionBox);
  7956. QFormLayout*pVSection= new QFormLayout;
  7957. pVSection->addRow(tr("Value relative address:"),pVAddress);
  7958. pVSection->addRow(tr("PV column name:"),pVColumnName);
  7959. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  7960. pVSection->addRow(pVHideBox);
  7961. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  7962. processValueBox->setLayout(pVSection);
  7963. seriesLayout->addWidget(processValueBox);
  7964. QFormLayout*sVSection= new QFormLayout;
  7965. sVLower->setDecimals(1);
  7966. sVLower->setMinimum(0.0);
  7967. sVLower->setMaximum(999.9);
  7968. sVUpper->setDecimals(1);
  7969. sVUpper->setMinimum(0.0);
  7970. sVUpper->setMaximum(999.9);
  7971. sVSection->addRow(tr("Set value:"),sVEnabled);
  7972. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  7973. sVSection->addRow(tr("SV column name:"),sVColumnName);
  7974. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  7975. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  7976. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  7977. sVSection->addRow(tr("Lower limit:"),sVLower);
  7978. sVSection->addRow(tr("Upper limit:"),sVUpper);
  7979. sVSection->addRow(tr("Output set value:"),sVWritable);
  7980. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  7981. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  7982. sVSection->addRow(sVHideBox);
  7983. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  7984. setValueBox->setLayout(sVSection);
  7985. seriesLayout->addWidget(setValueBox);
  7986. masterLayout->addLayout(portAndDeviceLayout);
  7987. masterLayout->addLayout(seriesLayout);
  7988. form->setLayout(masterLayout);
  7989. /*755:*/
  7990. #line 15980 "./typica.w"
  7991. QDomElement referenceElement=
  7992. model->referenceElement(model->data(index,Qt::UserRole).toString());
  7993. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  7994. QDomElement node;
  7995. /*:755*/
  7996. #line 18591 "./typica.w"
  7997. for(int i= 0;i<configData.size();i++)
  7998. {
  7999. node= configData.at(i).toElement();
  8000. if(node.attribute("name")=="port")
  8001. {
  8002. QString portname= node.attribute("value");
  8003. int idx= port->findText(portname);
  8004. if(idx>=0)
  8005. {
  8006. port->setCurrentIndex(idx);
  8007. }
  8008. else
  8009. {
  8010. port->addItem(portname);
  8011. }
  8012. }
  8013. else if(node.attribute("name")=="baud")
  8014. {
  8015. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8016. }
  8017. else if(node.attribute("name")=="parity")
  8018. {
  8019. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8020. }
  8021. else if(node.attribute("name")=="flow")
  8022. {
  8023. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8024. }
  8025. else if(node.attribute("name")=="stop")
  8026. {
  8027. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8028. }
  8029. else if(node.attribute("name")=="station")
  8030. {
  8031. station->setValue(node.attribute("value").toInt());
  8032. }
  8033. else if(node.attribute("name")=="decimalQuery")
  8034. {
  8035. if(node.attribute("value")=="true")
  8036. {
  8037. decimalQuery->setChecked(true);
  8038. }
  8039. else
  8040. {
  8041. decimalQuery->setChecked(false);
  8042. }
  8043. }
  8044. else if(node.attribute("name")=="decimalAddress")
  8045. {
  8046. decimalAddress->setValue(node.attribute("value").toInt());
  8047. }
  8048. else if(node.attribute("name")=="decimalPosition")
  8049. {
  8050. decimalPosition->setValue(node.attribute("value").toInt());
  8051. }
  8052. else if(node.attribute("name")=="unitQuery")
  8053. {
  8054. if(node.attribute("value")=="true")
  8055. {
  8056. unitQuery->setChecked(true);
  8057. }
  8058. else
  8059. {
  8060. unitQuery->setChecked(false);
  8061. }
  8062. }
  8063. else if(node.attribute("name")=="unitAddress")
  8064. {
  8065. unitAddress->setValue(node.attribute("value").toInt());
  8066. }
  8067. else if(node.attribute("name")=="valueF")
  8068. {
  8069. valueF->setValue(node.attribute("value").toInt());
  8070. }
  8071. else if(node.attribute("name")=="valueC")
  8072. {
  8073. valueC->setValue(node.attribute("value").toInt());
  8074. }
  8075. else if(node.attribute("name")=="fixedUnit")
  8076. {
  8077. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8078. }
  8079. else if(node.attribute("name")=="pVAddress")
  8080. {
  8081. pVAddress->setValue(node.attribute("value").toInt());
  8082. }
  8083. else if(node.attribute("name")=="sVEnabled")
  8084. {
  8085. if(node.attribute("value")=="true")
  8086. {
  8087. sVEnabled->setChecked(true);
  8088. }
  8089. else
  8090. {
  8091. sVEnabled->setChecked(false);
  8092. }
  8093. }
  8094. else if(node.attribute("name")=="sVReadAddress")
  8095. {
  8096. sVReadAddress->setValue(node.attribute("value").toInt());
  8097. }
  8098. else if(node.attribute("name")=="deviceLimit")
  8099. {
  8100. if(node.attribute("value")=="true")
  8101. {
  8102. deviceLimit->setChecked(true);
  8103. }
  8104. else
  8105. {
  8106. deviceLimit->setChecked(false);
  8107. }
  8108. }
  8109. else if(node.attribute("name")=="sVLowerAddr")
  8110. {
  8111. sVLowerAddr->setValue(node.attribute("value").toInt());
  8112. }
  8113. else if(node.attribute("name")=="sVUpperAddr")
  8114. {
  8115. sVUpperAddr->setValue(node.attribute("value").toInt());
  8116. }
  8117. else if(node.attribute("name")=="sVLower")
  8118. {
  8119. sVLower->setValue(node.attribute("value").toDouble());
  8120. }
  8121. else if(node.attribute("name")=="sVUpper")
  8122. {
  8123. sVUpper->setValue(node.attribute("value").toDouble());
  8124. }
  8125. else if(node.attribute("name")=="sVWritable")
  8126. {
  8127. if(node.attribute("value")=="true")
  8128. {
  8129. sVWritable->setChecked(true);
  8130. }
  8131. else
  8132. {
  8133. sVWritable->setChecked(false);
  8134. }
  8135. }
  8136. else if(node.attribute("name")=="sVOutputAddr")
  8137. {
  8138. sVOutputAddr->setValue(node.attribute("value").toInt());
  8139. }
  8140. else if(node.attribute("name")=="pvcolname")
  8141. {
  8142. pVColumnName->setText(node.attribute("value"));
  8143. }
  8144. else if(node.attribute("name")=="svcolname")
  8145. {
  8146. sVColumnName->setText(node.attribute("value"));
  8147. }
  8148. else if(node.attribute("name")=="pvhidden")
  8149. {
  8150. pVHideBox->setChecked(node.attribute("value")=="true");
  8151. }
  8152. else if(node.attribute("name")=="svhidden")
  8153. {
  8154. sVHideBox->setChecked(node.attribute("value")=="true");
  8155. }
  8156. }
  8157. updatePort(port->currentText());
  8158. updateBaudRate(baud->currentText());
  8159. updateParity(parity->itemData(parity->currentIndex()).toString());
  8160. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8161. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8162. updateStation(station->value());
  8163. updateFixedDecimal(decimalQuery->isChecked());
  8164. updateDecimalAddress(decimalAddress->value());
  8165. updateDecimalPosition(decimalPosition->value());
  8166. updateFixedUnit(unitQuery->isChecked());
  8167. updateUnitAddress(unitAddress->value());
  8168. updateValueForF(valueF->value());
  8169. updateValueForC(valueC->value());
  8170. updateUnit(fixedUnit->currentText());
  8171. updatePVAddress(pVAddress->value());
  8172. updateSVEnabled(sVEnabled->isChecked());
  8173. updateSVReadAddress(sVReadAddress->value());
  8174. updateDeviceLimit(deviceLimit->isChecked());
  8175. updateSVLowerAddress(sVLowerAddr->value());
  8176. updateSVUpperAddress(sVUpperAddr->value());
  8177. updateSVLower(sVLower->value());
  8178. updateSVUpper(sVUpper->value());
  8179. updateSVWritable(sVWritable->isChecked());
  8180. updateSVWriteAddress(sVOutputAddr->value());
  8181. updatePVColumnName(pVColumnName->text());
  8182. updateSVColumnName(sVColumnName->text());
  8183. updatePVHidden(pVHideBox->isChecked());
  8184. updateSVHidden(sVHideBox->isChecked());
  8185. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8186. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8187. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8188. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8189. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8190. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8191. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8192. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8193. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8194. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8195. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8196. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8197. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8198. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8199. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8200. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8201. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8202. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8203. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8204. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8205. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8206. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8207. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8208. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8209. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8210. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8211. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8212. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8213. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8214. layout->addWidget(form);
  8215. setLayout(layout);
  8216. }
  8217. void ModbusConfigurator::updatePort(const QString&newPort)
  8218. {
  8219. updateAttribute("port",newPort);
  8220. }
  8221. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8222. {
  8223. updateAttribute("baud",newRate);
  8224. }
  8225. void ModbusConfigurator::updateParity(const QString&)
  8226. {
  8227. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8228. }
  8229. void ModbusConfigurator::updateFlowControl(const QString&)
  8230. {
  8231. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8232. }
  8233. void ModbusConfigurator::updateStopBits(const QString&)
  8234. {
  8235. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8236. }
  8237. void ModbusConfigurator::updateStation(int station)
  8238. {
  8239. updateAttribute("station",QString("%1").arg(station));
  8240. }
  8241. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8242. {
  8243. updateAttribute("decimalQuery",fixed?"true":"false");
  8244. }
  8245. void ModbusConfigurator::updateDecimalAddress(int address)
  8246. {
  8247. updateAttribute("decimalAddress",QString("%1").arg(address));
  8248. }
  8249. void ModbusConfigurator::updateDecimalPosition(int position)
  8250. {
  8251. updateAttribute("decimalPosition",QString("%1").arg(position));
  8252. }
  8253. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8254. {
  8255. updateAttribute("unitQuery",fixed?"true":"false");
  8256. }
  8257. void ModbusConfigurator::updateUnitAddress(int address)
  8258. {
  8259. updateAttribute("unitAddress",QString("%1").arg(address));
  8260. }
  8261. void ModbusConfigurator::updateValueForF(int value)
  8262. {
  8263. updateAttribute("valueF",QString("%1").arg(value));
  8264. }
  8265. void ModbusConfigurator::updateValueForC(int value)
  8266. {
  8267. updateAttribute("valueC",QString("%1").arg(value));
  8268. }
  8269. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8270. {
  8271. updateAttribute("fixedUnit",newUnit);
  8272. }
  8273. void ModbusConfigurator::updatePVAddress(int address)
  8274. {
  8275. updateAttribute("pVAddress",QString("%1").arg(address));
  8276. }
  8277. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8278. {
  8279. updateAttribute("sVEnabled",enabled?"true":"false");
  8280. }
  8281. void ModbusConfigurator::updateSVReadAddress(int address)
  8282. {
  8283. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8284. }
  8285. void ModbusConfigurator::updateDeviceLimit(bool query)
  8286. {
  8287. updateAttribute("deviceLimit",query?"true":"false");
  8288. }
  8289. void ModbusConfigurator::updateSVLowerAddress(int address)
  8290. {
  8291. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8292. }
  8293. void ModbusConfigurator::updateSVUpperAddress(int address)
  8294. {
  8295. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8296. }
  8297. void ModbusConfigurator::updateSVLower(double value)
  8298. {
  8299. updateAttribute("sVLower",QString("%1").arg(value));
  8300. }
  8301. void ModbusConfigurator::updateSVUpper(double value)
  8302. {
  8303. updateAttribute("sVUpper",QString("%1").arg(value));
  8304. }
  8305. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8306. {
  8307. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8308. }
  8309. void ModbusConfigurator::updateSVWriteAddress(int address)
  8310. {
  8311. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8312. }
  8313. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8314. {
  8315. updateAttribute("pvcolname",name);
  8316. }
  8317. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8318. {
  8319. updateAttribute("svcolname",name);
  8320. }
  8321. void ModbusConfigurator::updatePVHidden(bool hidden)
  8322. {
  8323. updateAttribute("pvhidden",hidden?"true":"false");
  8324. }
  8325. void ModbusConfigurator::updateSVHidden(bool hidden)
  8326. {
  8327. updateAttribute("svhidden",hidden?"true":"false");
  8328. }
  8329. /*:847*/
  8330. #line 578 "./typica.w"
  8331. /*790:*/
  8332. #line 16768 "./typica.w"
  8333. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8334. {
  8335. setMinimum(0);
  8336. setMaximum(0xFFFF);
  8337. setPrefix("0x");
  8338. setMinimumWidth(65);
  8339. }
  8340. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8341. {
  8342. if(input.size()==2)
  8343. {
  8344. return QValidator::Intermediate;
  8345. }
  8346. bool okay;
  8347. input.toInt(&okay,16);
  8348. if(okay)
  8349. {
  8350. return QValidator::Acceptable;
  8351. }
  8352. return QValidator::Invalid;
  8353. }
  8354. int ShortHexSpinBox::valueFromText(const QString&text)const
  8355. {
  8356. return text.toInt(NULL,16);
  8357. }
  8358. QString ShortHexSpinBox::textFromValue(int value)const
  8359. {
  8360. QString retval;
  8361. retval.setNum(value,16);
  8362. while(retval.size()<4)
  8363. {
  8364. retval.prepend("0");
  8365. }
  8366. return retval.toUpper();
  8367. }
  8368. /*:790*/
  8369. #line 579 "./typica.w"
  8370. /*831:*/
  8371. #line 17800 "./typica.w"
  8372. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8373. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  8374. waiting(false)
  8375. {
  8376. qDebug()<<"Initializing Modbus RTU Device";
  8377. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8378. Qt::UserRole).toString());
  8379. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8380. QDomElement node;
  8381. QVariantMap attributes;
  8382. for(int i= 0;i<portConfigData.size();i++)
  8383. {
  8384. node= portConfigData.at(i).toElement();
  8385. attributes.insert(node.attribute("name"),node.attribute("value"));
  8386. }
  8387. port= new QextSerialPort(attributes.value("port").toString(),
  8388. QextSerialPort::EventDriven);
  8389. int baudRate= attributes.value("baud").toInt();
  8390. port->setBaudRate((BaudRateType)baudRate);
  8391. double temp= ((double)(1)/(double)(baudRate))*48;
  8392. delayTime= (int)(temp*3000);
  8393. messageDelayTimer->setSingleShot(true);
  8394. commTimeout->setSingleShot(true);
  8395. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8396. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  8397. port->setDataBits(DATA_8);
  8398. port->setParity((ParityType)attributes.value("parity").toInt());
  8399. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8400. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8401. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8402. port->open(QIODevice::ReadWrite);
  8403. station= (char)attributes.value("station").toInt();
  8404. if(attributes.value("decimalQuery")=="true")
  8405. {
  8406. decimalPosition= 0;
  8407. QByteArray message;
  8408. message.append(station);
  8409. message.append((char)0x03);
  8410. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8411. char*addressBytes= (char*)&address;
  8412. message.append(addressBytes[1]);
  8413. message.append(addressBytes[0]);
  8414. message.append((char)0x00);
  8415. message.append((char)0x01);
  8416. queueMessage(message,this,"decimalResponse(QByteArray)");
  8417. }
  8418. else
  8419. {
  8420. decimalPosition= attributes.value("decimalPosition").toInt();
  8421. }
  8422. valueF= attributes.value("valueF").toInt();
  8423. valueC= attributes.value("valueC").toInt();
  8424. if(attributes.value("unitQuery")=="true")
  8425. {
  8426. QByteArray message;
  8427. message.append(station);
  8428. message.append((char)0x03);
  8429. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8430. char*addressBytes= (char*)&address;
  8431. message.append(addressBytes[1]);
  8432. message.append(addressBytes[0]);
  8433. message.append((char)0x00);
  8434. message.append((char)0x01);
  8435. queueMessage(message,this,"unitResponse(QByteArray)");
  8436. }
  8437. else
  8438. {
  8439. if(attributes.value("fixedUnit")=="Celsius")
  8440. {
  8441. unitIsF= false;
  8442. }
  8443. }
  8444. if(attributes.value("sVWritable")=="true")
  8445. {
  8446. if(attributes.value("deviceLimit")=="true")
  8447. {
  8448. QByteArray lmessage;
  8449. lmessage.append(station);
  8450. lmessage.append((char)0x03);
  8451. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8452. char*addressBytes= (char*)&laddress;
  8453. lmessage.append(addressBytes[1]);
  8454. lmessage.append(addressBytes[0]);
  8455. lmessage.append((char)0x00);
  8456. lmessage.append((char)0x01);
  8457. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8458. QByteArray umessage;
  8459. umessage.append(station);
  8460. umessage.append((char)0x03);
  8461. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8462. addressBytes= (char*)&uaddress;
  8463. umessage.append(addressBytes[1]);
  8464. umessage.append(addressBytes[0]);
  8465. umessage.append((char)0x00);
  8466. umessage.append((char)0x01);
  8467. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8468. }
  8469. else
  8470. {
  8471. outputSVLower= attributes.value("sVLower").toDouble();
  8472. outputSVUpper= attributes.value("sVUpper").toDouble();
  8473. }
  8474. outputSVStub.append(station);
  8475. outputSVStub.append((char)0x06);
  8476. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8477. char*addressBytes= (char*)&address;
  8478. outputSVStub.append(addressBytes[1]);
  8479. outputSVStub.append(addressBytes[0]);
  8480. }
  8481. Channel*pv= new Channel;
  8482. channels.append(pv);
  8483. pvStub.append(station);
  8484. pvStub.append((char)0x04);
  8485. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8486. char*pvac= (char*)&pvaddress;
  8487. pvStub.append(pvac[1]);
  8488. pvStub.append(pvac[0]);
  8489. pvStub.append((char)0x00);
  8490. pvStub.append((char)0x01);
  8491. svenabled= attributes.value("sVEnabled").toBool();
  8492. if(svenabled)
  8493. {
  8494. Channel*sv= new Channel;
  8495. channels.append(sv);
  8496. svStub.append(station);
  8497. svStub.append((char)0x04);
  8498. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8499. char*svac= (char*)&svaddress;
  8500. svStub.append(svac[1]);
  8501. svStub.append(svac[0]);
  8502. svStub.append((char)0x00);
  8503. svStub.append((char)0x01);
  8504. if(svaddress-pvaddress==1)
  8505. {
  8506. mStub.append(station);
  8507. mStub.append((char)0x04);
  8508. mStub.append(pvac[1]);
  8509. mStub.append(pvac[0]);
  8510. mStub.append((char)0x00);
  8511. mStub.append((char)0x02);
  8512. }
  8513. }
  8514. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8515. requestMeasurement();
  8516. }
  8517. double ModbusRTUDevice::SVLower()
  8518. {
  8519. return outputSVLower;
  8520. }
  8521. double ModbusRTUDevice::SVUpper()
  8522. {
  8523. return outputSVUpper;
  8524. }
  8525. int ModbusRTUDevice::decimals()
  8526. {
  8527. return decimalPosition;
  8528. }
  8529. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8530. {
  8531. quint16 temp;
  8532. char*tchar= (char*)&temp;
  8533. tchar[1]= response.at(3);
  8534. tchar[0]= response.at(4);
  8535. decimalPosition= temp;
  8536. emit SVDecimalChanged(decimalPosition);
  8537. qDebug()<<"Received decimal response";
  8538. }
  8539. void ModbusRTUDevice::unitResponse(QByteArray response)
  8540. {
  8541. quint16 temp;
  8542. char*tchar= (char*)&temp;
  8543. tchar[1]= response.at(3);
  8544. tchar[0]= response.at(4);
  8545. int value= temp;
  8546. if(value==valueF)
  8547. {
  8548. unitIsF= true;
  8549. }
  8550. else
  8551. {
  8552. unitIsF= false;
  8553. }
  8554. qDebug()<<"Received unit response";
  8555. }
  8556. void ModbusRTUDevice::svlResponse(QByteArray response)
  8557. {
  8558. quint16 temp;
  8559. char*tchar= (char*)&temp;
  8560. tchar[1]= response.at(3);
  8561. tchar[0]= response.at(4);
  8562. outputSVLower= (double)temp;
  8563. for(int i= 0;i<decimalPosition;i++)
  8564. {
  8565. outputSVLower/= 10;
  8566. }
  8567. emit SVLowerChanged(outputSVLower);
  8568. qDebug()<<"Received set value lower bound response";
  8569. }
  8570. void ModbusRTUDevice::svuResponse(QByteArray response)
  8571. {
  8572. quint16 temp;
  8573. char*tchar= (char*)&temp;
  8574. tchar[1]= response.at(3);
  8575. tchar[0]= response.at(4);
  8576. outputSVUpper= (double)temp;
  8577. for(int i= 0;i<decimalPosition;i++)
  8578. {
  8579. outputSVUpper/= 10;
  8580. }
  8581. emit SVUpperChanged(outputSVUpper);
  8582. qDebug()<<"Received set value upper bound response";
  8583. }
  8584. void ModbusRTUDevice::requestMeasurement()
  8585. {
  8586. if(mStub.length()> 0)
  8587. {
  8588. queueMessage(mStub,this,"mResponse(QByteArray)");
  8589. }
  8590. else
  8591. {
  8592. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8593. if(svenabled)
  8594. {
  8595. queueMessage(svStub,this,"mResponse(QByteArray)");
  8596. }
  8597. }
  8598. }
  8599. void ModbusRTUDevice::mResponse(QByteArray response)
  8600. {
  8601. QTime time= QTime::currentTime();
  8602. if(response.at(2)==0x04)
  8603. {
  8604. /*832:*/
  8605. #line 18055 "./typica.w"
  8606. quint16 pv;
  8607. quint16 sv;
  8608. char*pvBytes= (char*)&pv;
  8609. char*svBytes= (char*)&sv;
  8610. pvBytes[1]= response.at(3);
  8611. pvBytes[0]= response.at(4);
  8612. svBytes[1]= response.at(5);
  8613. svBytes[0]= response.at(6);
  8614. double pvOut= (double)pv;
  8615. double svOut= (double)sv;
  8616. for(int i= 0;i<decimalPosition;i++)
  8617. {
  8618. pvOut/= 10;
  8619. svOut/= 10;
  8620. }
  8621. if(!unitIsF)
  8622. {
  8623. pvOut= pvOut*9/5+32;
  8624. svOut= svOut*9/5+32;
  8625. }
  8626. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8627. Measurement svm(svOut,time,Units::Fahrenheit);
  8628. channels.at(0)->input(pvm);
  8629. channels.at(1)->input(svm);
  8630. /*:832*/
  8631. #line 18042 "./typica.w"
  8632. }
  8633. else
  8634. {
  8635. /*833:*/
  8636. #line 18085 "./typica.w"
  8637. quint16 value;
  8638. char*valueBytes= (char*)&value;
  8639. valueBytes[1]= response.at(3);
  8640. valueBytes[0]= response.at(4);
  8641. double valueOut= (double)value;
  8642. for(int i= 0;i<decimalPosition;i++)
  8643. {
  8644. valueOut/= 10;
  8645. }
  8646. if(!unitIsF)
  8647. {
  8648. valueOut= valueOut*9/5+32;
  8649. }
  8650. if(!svenabled)
  8651. {
  8652. Measurement vm(valueOut,time,Units::Fahrenheit);
  8653. channels.at(0)->input(vm);
  8654. }
  8655. else
  8656. {
  8657. if(readingsv)
  8658. {
  8659. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8660. Measurement svm(valueOut,time,Units::Fahrenheit);
  8661. channels.at(0)->input(pvm);
  8662. channels.at(1)->input(svm);
  8663. readingsv= false;
  8664. }
  8665. else
  8666. {
  8667. savedpv= valueOut;
  8668. readingsv= true;
  8669. }
  8670. }
  8671. /*:833*/
  8672. #line 18046 "./typica.w"
  8673. }
  8674. }
  8675. /*:831*//*834:*/
  8676. #line 18123 "./typica.w"
  8677. ModbusRTUDevice::~ModbusRTUDevice()
  8678. {
  8679. commTimeout->stop();
  8680. messageDelayTimer->stop();
  8681. port->close();
  8682. }
  8683. /*:834*//*835:*/
  8684. #line 18150 "./typica.w"
  8685. void ModbusRTUDevice::dataAvailable()
  8686. {
  8687. if(messageDelayTimer->isActive())
  8688. {
  8689. messageDelayTimer->stop();
  8690. }
  8691. responseBuffer.append(port->readAll());
  8692. /*836:*/
  8693. #line 18196 "./typica.w"
  8694. if(responseBuffer.size()<5)
  8695. {
  8696. return;
  8697. }
  8698. switch(responseBuffer.at(1))
  8699. {
  8700. case 0x01:
  8701. case 0x02:
  8702. if(responseBuffer.size()<6)
  8703. {
  8704. return;
  8705. }
  8706. responseBuffer= responseBuffer.left(6);
  8707. break;
  8708. case 0x03:
  8709. case 0x04:
  8710. if(responseBuffer.size()<5+responseBuffer.at(2))
  8711. {
  8712. return;
  8713. }
  8714. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8715. break;
  8716. case 0x05:
  8717. case 0x06:
  8718. case 0x10:
  8719. if(responseBuffer.size()<8)
  8720. {
  8721. return;
  8722. }
  8723. responseBuffer= responseBuffer.left(8);
  8724. break;
  8725. }
  8726. /*:836*/
  8727. #line 18158 "./typica.w"
  8728. commTimeout->stop();
  8729. if(calculateCRC(responseBuffer)==0)
  8730. {
  8731. QObject*object= retObjQueue.at(0);
  8732. char*method= callbackQueue.at(0);
  8733. QMetaMethod metamethod= object->metaObject()->
  8734. method(object->metaObject()->
  8735. indexOfMethod(QMetaObject::normalizedSignature(method)));
  8736. metamethod.invoke(object,Qt::QueuedConnection,
  8737. Q_ARG(QByteArray,responseBuffer));
  8738. messageQueue.removeAt(0);
  8739. retObjQueue.removeAt(0);
  8740. callbackQueue.removeAt(0);
  8741. }
  8742. else
  8743. {
  8744. qDebug()<<"CRC failed";
  8745. }
  8746. messageDelayTimer->start(delayTime);
  8747. waiting= false;
  8748. responseBuffer.clear();
  8749. }
  8750. /*:835*//*837:*/
  8751. #line 18238 "./typica.w"
  8752. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  8753. {
  8754. quint16 retval= 0xFFFF;
  8755. int i= 0;
  8756. while(i<data.size())
  8757. {
  8758. retval^= 0x00FF&(quint16)data.at(i);
  8759. for(int j= 0;j<8;j++)
  8760. {
  8761. if(retval&1)
  8762. {
  8763. retval= (retval>>1)^0xA001;
  8764. }
  8765. else
  8766. {
  8767. retval>>= 1;
  8768. }
  8769. }
  8770. i++;
  8771. }
  8772. return retval;
  8773. }
  8774. /*:837*//*838:*/
  8775. #line 18269 "./typica.w"
  8776. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  8777. const char*callback)
  8778. {
  8779. messageQueue.append(request);
  8780. retObjQueue.append(object);
  8781. callbackQueue.append(const_cast<char*> (callback));
  8782. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  8783. {
  8784. sendNextMessage();
  8785. }
  8786. }
  8787. void ModbusRTUDevice::sendNextMessage()
  8788. {
  8789. if(messageQueue.size()> 0&&!waiting)
  8790. {
  8791. QByteArray message= messageQueue.at(0);
  8792. quint16 crc= calculateCRC(message);
  8793. char*check= (char*)&crc;
  8794. message.append(check[0]);
  8795. message.append(check[1]);
  8796. port->write(message);
  8797. commTimeout->start(2000);
  8798. messageDelayTimer->start(delayTime);
  8799. waiting= true;
  8800. }
  8801. else
  8802. {
  8803. emit queueEmpty();
  8804. }
  8805. }
  8806. void ModbusRTUDevice::outputSV(double value)
  8807. {
  8808. for(int i= 0;i<decimalPosition;i++)
  8809. {
  8810. value*= 10;
  8811. }
  8812. quint16 outval= (quint16)value;
  8813. QByteArray message(outputSVStub);
  8814. char*valBytes= (char*)&outval;
  8815. message.append(valBytes[1]);
  8816. message.append(valBytes[0]);
  8817. queueMessage(message,this,"ignore(QByteArray)");
  8818. }
  8819. /*:838*//*839:*/
  8820. #line 18318 "./typica.w"
  8821. void ModbusRTUDevice::ignore(QByteArray)
  8822. {
  8823. return;
  8824. }
  8825. /*:839*//*840:*/
  8826. #line 18331 "./typica.w"
  8827. void ModbusRTUDevice::timeout()
  8828. {
  8829. qDebug()<<"Communications timeout.";
  8830. responseBuffer.clear();
  8831. waiting= false;
  8832. messageDelayTimer->start();
  8833. }
  8834. /*:840*/
  8835. #line 580 "./typica.w"
  8836. /*709:*/
  8837. #line 14960 "./typica.w"
  8838. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  8839. DeviceTreeModelNode*parent)
  8840. :domNode(node),rowNumber(row),parentItem(parent)
  8841. {
  8842. }
  8843. DeviceTreeModelNode::~DeviceTreeModelNode()
  8844. {
  8845. QHash<int,DeviceTreeModelNode*> ::iterator i;
  8846. for(i= children.begin();i!=children.end();i++)
  8847. {
  8848. delete i.value();
  8849. }
  8850. }
  8851. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  8852. {
  8853. return parentItem;
  8854. }
  8855. int DeviceTreeModelNode::row()
  8856. {
  8857. return rowNumber;
  8858. }
  8859. QDomNode DeviceTreeModelNode::node()const
  8860. {
  8861. return domNode;
  8862. }
  8863. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  8864. {
  8865. if(children.contains(index))
  8866. {
  8867. return children[index];
  8868. }
  8869. if(index>=0&&index<domNode.childNodes().count())
  8870. {
  8871. QDomNode childNode= domNode.childNodes().item(index);
  8872. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  8873. index,this);
  8874. children[index]= childItem;
  8875. return childItem;
  8876. }
  8877. return NULL;
  8878. }
  8879. /*:709*/
  8880. #line 581 "./typica.w"
  8881. /*711:*/
  8882. #line 15049 "./typica.w"
  8883. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  8884. :QAbstractItemModel(parent)
  8885. {
  8886. document= AppInstance->deviceConfiguration();
  8887. QDomNodeList elements= document.elementsByTagName("devices");
  8888. if(elements.size()!=1)
  8889. {
  8890. qDebug()<<"Unexpected result when loading device map.";
  8891. }
  8892. treeRoot= elements.at(0);
  8893. root= new DeviceTreeModelNode(treeRoot,0);
  8894. elements= document.elementsByTagName("references");
  8895. if(elements.size()!=1)
  8896. {
  8897. qDebug()<<"No references section. Creating.";
  8898. referenceSection= document.createElement("references");
  8899. document.appendChild(referenceSection);
  8900. }
  8901. else
  8902. {
  8903. referenceSection= elements.at(0);
  8904. }
  8905. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  8906. AppInstance,SLOT(saveDeviceConfiguration()));
  8907. connect(this,SIGNAL(modelReset()),
  8908. AppInstance,SLOT(saveDeviceConfiguration()));
  8909. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  8910. AppInstance,SLOT(saveDeviceConfiguration()));
  8911. }
  8912. /*:711*//*712:*/
  8913. #line 15084 "./typica.w"
  8914. int DeviceTreeModel::columnCount(const QModelIndex&)const
  8915. {
  8916. return 1;
  8917. }
  8918. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  8919. {
  8920. if(parent.column()> 0)
  8921. {
  8922. return 0;
  8923. }
  8924. /*713:*/
  8925. #line 15103 "./typica.w"
  8926. DeviceTreeModelNode*parentItem;
  8927. if(!parent.isValid())
  8928. {
  8929. parentItem= root;
  8930. }
  8931. else
  8932. {
  8933. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8934. }
  8935. /*:713*/
  8936. #line 15096 "./typica.w"
  8937. return parentItem->node().childNodes().count();
  8938. }
  8939. /*:712*//*714:*/
  8940. #line 15117 "./typica.w"
  8941. QModelIndex DeviceTreeModel::index(int row,int column,
  8942. const QModelIndex&parent)const
  8943. {
  8944. if(!hasIndex(row,column,parent))
  8945. {
  8946. return QModelIndex();
  8947. }
  8948. /*713:*/
  8949. #line 15103 "./typica.w"
  8950. DeviceTreeModelNode*parentItem;
  8951. if(!parent.isValid())
  8952. {
  8953. parentItem= root;
  8954. }
  8955. else
  8956. {
  8957. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8958. }
  8959. /*:713*/
  8960. #line 15125 "./typica.w"
  8961. DeviceTreeModelNode*childItem= parentItem->child(row);
  8962. if(childItem)
  8963. {
  8964. return createIndex(row,column,childItem);
  8965. }
  8966. return QModelIndex();
  8967. }
  8968. /*:714*//*715:*/
  8969. #line 15136 "./typica.w"
  8970. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  8971. {
  8972. if(!child.isValid())
  8973. {
  8974. return QModelIndex();
  8975. }
  8976. DeviceTreeModelNode*childItem=
  8977. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  8978. DeviceTreeModelNode*parentItem= childItem->parent();
  8979. if(!parentItem||parentItem==root)
  8980. {
  8981. return QModelIndex();
  8982. }
  8983. return createIndex(parentItem->row(),0,parentItem);
  8984. }
  8985. /*:715*//*716:*/
  8986. #line 15155 "./typica.w"
  8987. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  8988. {
  8989. if(!index.isValid())
  8990. {
  8991. return 0;
  8992. }
  8993. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  8994. }
  8995. /*:716*//*717:*/
  8996. #line 15170 "./typica.w"
  8997. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  8998. {
  8999. if(!index.isValid())
  9000. {
  9001. return QVariant();
  9002. }
  9003. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9004. {
  9005. return QVariant();
  9006. }
  9007. DeviceTreeModelNode*item=
  9008. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9009. QDomNode node= item->node();
  9010. QDomElement element= node.toElement();
  9011. switch(role)
  9012. {
  9013. case Qt::DisplayRole:
  9014. case Qt::EditRole:
  9015. return QVariant(element.attribute("name"));
  9016. case Qt::UserRole:
  9017. return QVariant(element.attribute("reference"));
  9018. default:
  9019. return QVariant();
  9020. }
  9021. return QVariant();
  9022. }
  9023. /*:717*//*718:*/
  9024. #line 15202 "./typica.w"
  9025. bool DeviceTreeModel::setData(const QModelIndex&index,
  9026. const QVariant&value,int)
  9027. {
  9028. if(!index.isValid())
  9029. {
  9030. return false;
  9031. }
  9032. DeviceTreeModelNode*item=
  9033. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9034. QDomNode node= item->node();
  9035. QDomElement element= node.toElement();
  9036. element.setAttribute("name",value.toString());
  9037. emit dataChanged(index,index);
  9038. return true;
  9039. }
  9040. /*:718*//*719:*/
  9041. #line 15225 "./typica.w"
  9042. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9043. const QModelIndex&parent)
  9044. {
  9045. QString referenceID= QUuid::createUuid().toString();
  9046. /*713:*/
  9047. #line 15103 "./typica.w"
  9048. DeviceTreeModelNode*parentItem;
  9049. if(!parent.isValid())
  9050. {
  9051. parentItem= root;
  9052. }
  9053. else
  9054. {
  9055. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9056. }
  9057. /*:713*/
  9058. #line 15230 "./typica.w"
  9059. QDomNode parentNode= parentItem->node();
  9060. int newRowNumber= rowCount(parent);
  9061. beginInsertRows(parent,newRowNumber,newRowNumber);
  9062. QDomElement deviceElement= document.createElement("node");
  9063. deviceElement.setAttribute("name",name);
  9064. deviceElement.setAttribute("reference",referenceID);
  9065. parentNode.appendChild(deviceElement);
  9066. QDomElement referenceElement= document.createElement("reference");
  9067. referenceElement.setAttribute("id",referenceID);
  9068. referenceElement.setAttribute("driver",driver);
  9069. referenceSection.appendChild(referenceElement);
  9070. endInsertRows();
  9071. }
  9072. /*:719*//*720:*/
  9073. #line 15248 "./typica.w"
  9074. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9075. {
  9076. /*713:*/
  9077. #line 15103 "./typica.w"
  9078. DeviceTreeModelNode*parentItem;
  9079. if(!parent.isValid())
  9080. {
  9081. parentItem= root;
  9082. }
  9083. else
  9084. {
  9085. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9086. }
  9087. /*:713*/
  9088. #line 15251 "./typica.w"
  9089. QDomNode parentNode= parentItem->node();
  9090. QDomNodeList childNodes= parentNode.childNodes();
  9091. if(childNodes.size()<row+count)
  9092. {
  9093. return false;
  9094. }
  9095. beginRemoveRows(parent,row,row+count-1);
  9096. QList<QDomElement> removalList;
  9097. for(int i= row;i<row+count;i++)
  9098. {
  9099. removalList.append(childNodes.at(i).toElement());
  9100. }
  9101. QDomElement element;
  9102. QDomElement reference;
  9103. for(int i= 0;i<count;i++)
  9104. {
  9105. element= removalList.at(i);
  9106. if(element.hasAttribute("reference"))
  9107. {
  9108. reference= referenceElement(element.attribute("reference"));
  9109. if(!reference.isNull())
  9110. {
  9111. referenceSection.removeChild(reference);
  9112. }
  9113. }
  9114. parentNode.removeChild(element);
  9115. }
  9116. endRemoveRows();
  9117. beginResetModel();
  9118. delete root;
  9119. root= new DeviceTreeModelNode(treeRoot,0);
  9120. endResetModel();
  9121. return true;
  9122. }
  9123. /*:720*//*721:*/
  9124. #line 15290 "./typica.w"
  9125. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9126. {
  9127. QDomNodeList childNodes= referenceSection.childNodes();
  9128. QDomElement element;
  9129. for(int i= 0;i<childNodes.size();i++)
  9130. {
  9131. element= childNodes.at(i).toElement();
  9132. if(element.hasAttribute("id"))
  9133. {
  9134. if(element.attribute("id")==id)
  9135. {
  9136. return element;
  9137. }
  9138. }
  9139. }
  9140. return QDomElement();
  9141. }
  9142. /*:721*//*722:*/
  9143. #line 15311 "./typica.w"
  9144. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9145. {
  9146. return QVariant();
  9147. }
  9148. /*:722*//*723:*/
  9149. #line 15320 "./typica.w"
  9150. DeviceTreeModel::~DeviceTreeModel()
  9151. {
  9152. delete root;
  9153. }
  9154. /*:723*/
  9155. #line 582 "./typica.w"
  9156. /*750:*/
  9157. #line 15820 "./typica.w"
  9158. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9159. DeviceTreeModel*model,const QModelIndex&index)
  9160. :QWidget(NULL),deviceModel(model),currentNode(index)
  9161. {
  9162. }
  9163. /*:750*//*751:*/
  9164. #line 15832 "./typica.w"
  9165. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9166. const QString&value)
  9167. {
  9168. QDomElement referenceElement= deviceModel->referenceElement(
  9169. deviceModel->data(currentNode,Qt::UserRole).toString());
  9170. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9171. QDomElement node;
  9172. bool found= false;
  9173. for(int i= 0;i<configData.size();i++)
  9174. {
  9175. node= configData.at(i).toElement();
  9176. if(node.attribute("name")==name)
  9177. {
  9178. node.setAttribute("value",value);
  9179. found= true;
  9180. break;
  9181. }
  9182. }
  9183. if(!found)
  9184. {
  9185. node= AppInstance->deviceConfiguration().createElement("attribute");
  9186. node.setAttribute("name",name);
  9187. node.setAttribute("value",value);
  9188. referenceElement.appendChild(node);
  9189. }
  9190. AppInstance->saveDeviceConfiguration();
  9191. }
  9192. /*:751*//*752:*/
  9193. #line 15866 "./typica.w"
  9194. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9195. const QString&driver)
  9196. {
  9197. deviceModel->newNode(name,driver,currentNode);
  9198. }
  9199. /*:752*/
  9200. #line 583 "./typica.w"
  9201. /*741:*/
  9202. #line 15664 "./typica.w"
  9203. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9204. view(new QTreeView),configArea(new QScrollArea)
  9205. {
  9206. QSplitter*splitter= new QSplitter;
  9207. QWidget*leftWidget= new QWidget;
  9208. leftWidget->setMinimumWidth(200);
  9209. QVBoxLayout*left= new QVBoxLayout;
  9210. view->setAnimated(true);
  9211. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9212. document= AppInstance->deviceConfiguration();
  9213. model= new DeviceTreeModel;
  9214. view->setModel(model);
  9215. view->setTextElideMode(Qt::ElideNone);
  9216. view->expandAll();
  9217. view->resizeColumnToContents(0);
  9218. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9219. QHBoxLayout*treeButtons= new QHBoxLayout;
  9220. QToolButton*addDeviceButton= new QToolButton;
  9221. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9222. addDeviceButton->setToolTip(tr("New Roaster"));
  9223. connect(addDeviceButton,SIGNAL(clicked()),
  9224. this,SLOT(addDevice()));
  9225. QToolButton*removeNodeButton= new QToolButton;
  9226. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9227. removeNodeButton->setToolTip(tr("Delete Selection"));
  9228. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9229. treeButtons->addWidget(addDeviceButton);
  9230. treeButtons->addWidget(removeNodeButton);
  9231. left->addWidget(view);
  9232. left->addLayout(treeButtons);
  9233. leftWidget->setLayout(left);
  9234. splitter->addWidget(leftWidget);
  9235. configArea->setMinimumWidth(580);
  9236. configArea->setMinimumHeight(460);
  9237. configArea->setWidgetResizable(true);
  9238. splitter->addWidget(configArea);
  9239. QVBoxLayout*centralLayout= new QVBoxLayout;
  9240. centralLayout->addWidget(splitter);
  9241. setLayout(centralLayout);
  9242. connect(view,SIGNAL(activated(QModelIndex)),
  9243. this,SLOT(newSelection(QModelIndex)));
  9244. connect(view,SIGNAL(clicked(QModelIndex)),
  9245. this,SLOT(newSelection(QModelIndex)));
  9246. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9247. view,SLOT(expand(QModelIndex)));
  9248. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9249. this,SLOT(resizeColumn()));
  9250. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9251. this,SLOT(resizeColumn()));
  9252. }
  9253. /*:741*//*742:*/
  9254. #line 15719 "./typica.w"
  9255. void DeviceConfigurationWindow::addDevice()
  9256. {
  9257. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9258. }
  9259. /*:742*//*743:*/
  9260. #line 15727 "./typica.w"
  9261. void DeviceConfigurationWindow::removeNode()
  9262. {
  9263. QModelIndex index= view->currentIndex();
  9264. if(index.isValid())
  9265. {
  9266. int row= index.row();
  9267. QModelIndex parent= index.parent();
  9268. model->removeRow(row,parent);
  9269. }
  9270. }
  9271. /*:743*//*744:*/
  9272. #line 15743 "./typica.w"
  9273. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9274. {
  9275. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9276. if(editor)
  9277. {
  9278. configArea->setWidget(editor);
  9279. editor->show();
  9280. }
  9281. }
  9282. /*:744*//*745:*/
  9283. #line 15760 "./typica.w"
  9284. void DeviceConfigurationWindow::resizeColumn()
  9285. {
  9286. view->resizeColumnToContents(0);
  9287. }
  9288. /*:745*/
  9289. #line 584 "./typica.w"
  9290. /*765:*/
  9291. #line 16171 "./typica.w"
  9292. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9293. const QModelIndex&index):
  9294. BasicDeviceConfigurationWidget(model,index)
  9295. {
  9296. QFormLayout*layout= new QFormLayout;
  9297. QLineEdit*columnName= new QLineEdit;
  9298. layout->addRow(tr("Column Name:"),columnName);
  9299. QComboBox*typeSelector= new QComboBox;
  9300. typeSelector->addItem("J");
  9301. typeSelector->addItem("K");
  9302. typeSelector->addItem("T");
  9303. typeSelector->addItem("B");
  9304. typeSelector->addItem("E");
  9305. typeSelector->addItem("N");
  9306. typeSelector->addItem("R");
  9307. typeSelector->addItem("S");
  9308. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9309. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9310. layout->addRow(hideSeries);
  9311. setLayout(layout);
  9312. /*755:*/
  9313. #line 15980 "./typica.w"
  9314. QDomElement referenceElement=
  9315. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9316. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9317. QDomElement node;
  9318. /*:755*/
  9319. #line 16192 "./typica.w"
  9320. for(int i= 0;i<configData.size();i++)
  9321. {
  9322. node= configData.at(i).toElement();
  9323. if(node.attribute("name")=="type")
  9324. {
  9325. typeSelector->setCurrentIndex(
  9326. typeSelector->findText(node.attribute("value")));
  9327. }
  9328. else if(node.attribute("name")=="columnname")
  9329. {
  9330. columnName->setText(node.attribute("value"));
  9331. }
  9332. else if(node.attribute("name")=="hidden")
  9333. {
  9334. hideSeries->setChecked(node.attribute("value")=="true");
  9335. }
  9336. }
  9337. updateThermocoupleType(typeSelector->currentText());
  9338. updateColumnName(columnName->text());
  9339. updateHidden(hideSeries->isChecked());
  9340. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9341. this,SLOT(updateThermocoupleType(QString)));
  9342. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9343. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9344. }
  9345. /*:765*//*766:*/
  9346. #line 16222 "./typica.w"
  9347. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9348. {
  9349. updateAttribute("type",type);
  9350. }
  9351. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9352. {
  9353. updateAttribute("columnname",name);
  9354. }
  9355. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9356. {
  9357. updateAttribute("hidden",hidden?"true":"false");
  9358. }
  9359. /*:766*/
  9360. #line 585 "./typica.w"
  9361. /*761:*/
  9362. #line 16085 "./typica.w"
  9363. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9364. const QModelIndex&index)
  9365. :BasicDeviceConfigurationWidget(model,index)
  9366. {
  9367. QVBoxLayout*layout= new QVBoxLayout;
  9368. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9369. QLabel*label= new QLabel(tr("Device ID:"));
  9370. QLineEdit*deviceId= new QLineEdit;
  9371. deviceIdLayout->addWidget(label);
  9372. deviceIdLayout->addWidget(deviceId);
  9373. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9374. layout->addLayout(deviceIdLayout);
  9375. layout->addWidget(addChannelButton);
  9376. /*755:*/
  9377. #line 15980 "./typica.w"
  9378. QDomElement referenceElement=
  9379. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9380. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9381. QDomElement node;
  9382. /*:755*/
  9383. #line 16099 "./typica.w"
  9384. for(int i= 0;i<configData.size();i++)
  9385. {
  9386. node= configData.at(i).toElement();
  9387. if(node.attribute("name")=="deviceID")
  9388. {
  9389. deviceId->setText(node.attribute("value","Dev1"));
  9390. break;
  9391. }
  9392. }
  9393. updateDeviceId(deviceId->text());
  9394. connect(addChannelButton,SIGNAL(clicked()),
  9395. this,SLOT(addChannel()));
  9396. connect(deviceId,SIGNAL(textEdited(QString)),
  9397. this,SLOT(updateDeviceId(QString)));
  9398. setLayout(layout);
  9399. }
  9400. /*:761*//*762:*/
  9401. #line 16121 "./typica.w"
  9402. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9403. {
  9404. updateAttribute("deviceID",newId);
  9405. }
  9406. /*:762*//*763:*/
  9407. #line 16129 "./typica.w"
  9408. void NiDaqMxBase9211ConfWidget::addChannel()
  9409. {
  9410. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9411. }
  9412. /*:763*/
  9413. #line 586 "./typica.w"
  9414. /*759:*/
  9415. #line 16036 "./typica.w"
  9416. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9417. DeviceTreeModel*model,const QModelIndex&index):
  9418. BasicDeviceConfigurationWidget(model,index)
  9419. {
  9420. QHBoxLayout*layout= new QHBoxLayout;
  9421. QToolButton*addDeviceButton= new QToolButton;
  9422. addDeviceButton->setText(tr("Add Device"));
  9423. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9424. "nidaqmxbase9211series");
  9425. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9426. "nidaqmxbase9211series");
  9427. connect(add9211,SIGNAL(triggered(QString,QString)),
  9428. this,SLOT(insertChildNode(QString,QString)));
  9429. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9430. this,SLOT(insertChildNode(QString,QString)));
  9431. QMenu*deviceMenu= new QMenu;
  9432. deviceMenu->addAction(add9211);
  9433. deviceMenu->addAction(add9211a);
  9434. addDeviceButton->setMenu(deviceMenu);
  9435. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9436. layout->addWidget(addDeviceButton);
  9437. setLayout(layout);
  9438. }
  9439. /*:759*/
  9440. #line 587 "./typica.w"
  9441. /*626:*/
  9442. #line 13582 "./typica.w"
  9443. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9444. QObject*parent):
  9445. QAction(reportName,parent),reportFile(fileName)
  9446. {
  9447. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9448. }
  9449. /*:626*//*627:*/
  9450. #line 13598 "./typica.w"
  9451. void ReportAction::createReport()
  9452. {
  9453. QFile file(reportFile);
  9454. QDomDocument document;
  9455. if(file.open(QIODevice::ReadOnly))
  9456. {
  9457. document.setContent(&file,true);
  9458. QDomElement element= document.documentElement();
  9459. QScriptEngine*engine= AppInstance->engine;
  9460. QScriptContext*context= engine->pushContext();
  9461. QScriptValue object;
  9462. QString targetID= reportFile;
  9463. /*188:*/
  9464. #line 4474 "./typica.w"
  9465. ScriptQMainWindow*window= new ScriptQMainWindow;
  9466. window->setObjectName(targetID);
  9467. object= engine->newQObject(window);
  9468. setQMainWindowProperties(object,engine);
  9469. QWidget*central= new(QWidget);
  9470. central->setParent(window);
  9471. central->setObjectName("centralWidget");
  9472. window->setCentralWidget(central);
  9473. if(element.hasChildNodes())
  9474. {
  9475. /*189:*/
  9476. #line 4509 "./typica.w"
  9477. QStack<QWidget*> widgetStack;
  9478. QStack<QLayout*> layoutStack;
  9479. QString windowScript;
  9480. widgetStack.push(central);
  9481. QDomNodeList windowChildren= element.childNodes();
  9482. int i= 0;
  9483. while(i<windowChildren.count())
  9484. {
  9485. QDomNode current;
  9486. QDomElement element;
  9487. current= windowChildren.at(i);
  9488. if(current.isElement())
  9489. {
  9490. element= current.toElement();
  9491. if(element.tagName()=="program")
  9492. {
  9493. windowScript.append(element.text());
  9494. }
  9495. else if(element.tagName()=="layout")
  9496. {
  9497. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9498. }
  9499. else if(element.tagName()=="menu")
  9500. {
  9501. /*190:*/
  9502. #line 4556 "./typica.w"
  9503. QMenuBar*bar= window->menuBar();
  9504. bar->setParent(window);
  9505. bar->setObjectName("menuBar");
  9506. if(element.hasAttribute("name"))
  9507. {
  9508. QMenu*menu= bar->addMenu(element.attribute("name"));
  9509. menu->setParent(bar);
  9510. if(element.hasAttribute("type"))
  9511. {
  9512. if(element.attribute("type")=="reports")
  9513. {
  9514. if(element.hasAttribute("src"))
  9515. {
  9516. /*624:*/
  9517. #line 13542 "./typica.w"
  9518. QSettings settings;
  9519. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9520. toString()).
  9521. arg(element.attribute("src"));
  9522. QDir::addSearchPath("reports",reportDirectory);
  9523. QDir directory(reportDirectory);
  9524. directory.setFilter(QDir::Files);
  9525. directory.setSorting(QDir::Name);
  9526. QStringList nameFilter;
  9527. nameFilter<<"*.xml";
  9528. directory.setNameFilters(nameFilter);
  9529. QFileInfoList reportFiles= directory.entryInfoList();
  9530. for(int i= 0;i<reportFiles.size();i++)
  9531. {
  9532. QFileInfo reportFile= reportFiles.at(i);
  9533. /*628:*/
  9534. #line 13622 "./typica.w"
  9535. QString path= reportFile.absoluteFilePath();
  9536. QFile file(path);
  9537. if(file.open(QIODevice::ReadOnly))
  9538. {
  9539. QDomDocument document;
  9540. document.setContent(&file,true);
  9541. QDomElement root= document.documentElement();
  9542. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9543. if(!titleNode.isNull())
  9544. {
  9545. QDomElement titleElement= titleNode.toElement();
  9546. QString title= titleElement.text();
  9547. if(!title.isEmpty())
  9548. {
  9549. QStringList hierarchy= title.split(":->");
  9550. QMenu*insertionPoint= menu;
  9551. /*629:*/
  9552. #line 13649 "./typica.w"
  9553. for(int j= 0;j<hierarchy.size()-1;j++)
  9554. {
  9555. QObjectList menuList= insertionPoint->children();
  9556. bool menuFound= false;
  9557. for(int k= 0;k<menuList.size();k++)
  9558. {
  9559. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9560. if(currentItem)
  9561. {
  9562. if(currentItem->title()==hierarchy.at(j))
  9563. {
  9564. menuFound= true;
  9565. insertionPoint= currentItem;
  9566. break;
  9567. }
  9568. }
  9569. }
  9570. if(!menuFound)
  9571. {
  9572. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9573. }
  9574. }
  9575. /*:629*/
  9576. #line 13639 "./typica.w"
  9577. ReportAction*action= new ReportAction(path,hierarchy.last());
  9578. insertionPoint->addAction(action);
  9579. }
  9580. }
  9581. }
  9582. /*:628*/
  9583. #line 13558 "./typica.w"
  9584. }
  9585. /*:624*/
  9586. #line 4570 "./typica.w"
  9587. }
  9588. }
  9589. }
  9590. if(element.hasChildNodes())
  9591. {
  9592. /*191:*/
  9593. #line 4583 "./typica.w"
  9594. QDomNodeList menuItems= element.childNodes();
  9595. int j= 0;
  9596. while(j<menuItems.count())
  9597. {
  9598. QDomNode item= menuItems.at(j);
  9599. if(item.isElement())
  9600. {
  9601. QDomElement itemElement= item.toElement();
  9602. if(itemElement.tagName()=="item")
  9603. {
  9604. QAction*itemAction= new QAction(itemElement.text(),menu);
  9605. if(itemElement.hasAttribute("id"))
  9606. {
  9607. itemAction->setObjectName(itemElement.attribute("id"));
  9608. }
  9609. if(itemElement.hasAttribute("shortcut"))
  9610. {
  9611. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9612. }
  9613. menu->addAction(itemAction);
  9614. }
  9615. else if(itemElement.tagName()=="separator")
  9616. {
  9617. menu->addSeparator();
  9618. }
  9619. }
  9620. j++;
  9621. }
  9622. #line 1 "./helpmenu.w"
  9623. /*:191*/
  9624. #line 4576 "./typica.w"
  9625. }
  9626. }
  9627. /*:190*/
  9628. #line 4534 "./typica.w"
  9629. }
  9630. }
  9631. i++;
  9632. }
  9633. QScriptValue oldThis= context->thisObject();
  9634. context->setThisObject(object);
  9635. QScriptValue result= engine->evaluate(windowScript);
  9636. /*182:*/
  9637. #line 4291 "./typica.w"
  9638. if(engine->hasUncaughtException())
  9639. {
  9640. int line= engine->uncaughtExceptionLineNumber();
  9641. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9642. result.toString();
  9643. QString trace;
  9644. foreach(trace,engine->uncaughtExceptionBacktrace())
  9645. {
  9646. qDebug()<<trace;
  9647. }
  9648. }
  9649. /*:182*/
  9650. #line 4542 "./typica.w"
  9651. context->setThisObject(oldThis);
  9652. /*:189*/
  9653. #line 4485 "./typica.w"
  9654. }
  9655. /*192:*/
  9656. #line 9 "./helpmenu.w"
  9657. HelpMenu*helpMenu= new HelpMenu();
  9658. window->menuBar()->addMenu(helpMenu);
  9659. /*:192*/
  9660. #line 4487 "./typica.w"
  9661. window->show();
  9662. /*:188*/
  9663. #line 13611 "./typica.w"
  9664. file.close();
  9665. engine->popContext();
  9666. }
  9667. }
  9668. /*:627*/
  9669. #line 588 "./typica.w"
  9670. /*231:*/
  9671. #line 5651 "./typica.w"
  9672. NumericDelegate::NumericDelegate(QObject*parent):
  9673. QItemDelegate(parent)
  9674. {
  9675. }
  9676. /*:231*//*232:*/
  9677. #line 5663 "./typica.w"
  9678. void NumericDelegate::setEditorData(QWidget*editor,
  9679. const QModelIndex&index)const
  9680. {
  9681. QString value= index.model()->data(index,Qt::EditRole).toString();
  9682. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9683. line->setText(value);
  9684. }
  9685. /*:232*//*233:*/
  9686. #line 5678 "./typica.w"
  9687. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  9688. const QModelIndex&index)const
  9689. {
  9690. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9691. model->setData(index,line->text(),Qt::EditRole);
  9692. QScriptEngine*engine= AppInstance->engine;
  9693. engine->pushContext();
  9694. QString script= QString("Number(%1)").arg(line->text());
  9695. QScriptValue result= engine->evaluate(line->text());
  9696. if(result.isNumber())
  9697. {
  9698. model->setData(index,result.toVariant(),Qt::DisplayRole);
  9699. }
  9700. else
  9701. {
  9702. model->setData(index,QVariant(),Qt::DisplayRole);
  9703. }
  9704. engine->popContext();
  9705. }
  9706. /*:233*//*234:*/
  9707. #line 5701 "./typica.w"
  9708. QWidget*NumericDelegate::createEditor(QWidget*parent,
  9709. const QStyleOptionViewItem&,
  9710. const QModelIndex&)const
  9711. {
  9712. return(new QLineEdit(parent));
  9713. }
  9714. /*:234*//*235:*/
  9715. #line 5712 "./typica.w"
  9716. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  9717. const QStyleOptionViewItem&option,
  9718. const QModelIndex&)const
  9719. {
  9720. editor->setGeometry(option.rect);
  9721. }
  9722. /*:235*/
  9723. #line 589 "./typica.w"
  9724. /*770:*/
  9725. #line 16281 "./typica.w"
  9726. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  9727. const QModelIndex&index)
  9728. :BasicDeviceConfigurationWidget(model,index)
  9729. {
  9730. QHBoxLayout*layout= new QHBoxLayout;
  9731. QToolButton*addDeviceButton= new QToolButton;
  9732. addDeviceButton->setText(tr("Add Device"));
  9733. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9734. "nidaqmx9211series");
  9735. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  9736. "nidaqmxtc01");
  9737. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9738. this,SLOT(insertChildNode(QString,QString)));
  9739. connect(addtc01,SIGNAL(triggered(QString,QString)),
  9740. this,SLOT(insertChildNode(QString,QString)));
  9741. QMenu*deviceMenu= new QMenu;
  9742. deviceMenu->addAction(add9211a);
  9743. deviceMenu->addAction(addtc01);
  9744. addDeviceButton->setMenu(deviceMenu);
  9745. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9746. layout->addWidget(addDeviceButton);
  9747. setLayout(layout);
  9748. }
  9749. /*:770*/
  9750. #line 590 "./typica.w"
  9751. /*772:*/
  9752. #line 16330 "./typica.w"
  9753. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  9754. const QModelIndex&index)
  9755. :BasicDeviceConfigurationWidget(model,index)
  9756. {
  9757. QVBoxLayout*layout= new QVBoxLayout;
  9758. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9759. QLabel*label= new QLabel(tr("Device ID:"));
  9760. QLineEdit*deviceId= new QLineEdit;
  9761. deviceIdLayout->addWidget(label);
  9762. deviceIdLayout->addWidget(deviceId);
  9763. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9764. layout->addLayout(deviceIdLayout);
  9765. layout->addWidget(addChannelButton);
  9766. /*755:*/
  9767. #line 15980 "./typica.w"
  9768. QDomElement referenceElement=
  9769. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9770. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9771. QDomElement node;
  9772. /*:755*/
  9773. #line 16344 "./typica.w"
  9774. for(int i= 0;i<configData.size();i++)
  9775. {
  9776. node= configData.at(i).toElement();
  9777. if(node.attribute("name")=="deviceID")
  9778. {
  9779. deviceId->setText(node.attribute("value","Dev1"));
  9780. break;
  9781. }
  9782. }
  9783. updateDeviceId(deviceId->text());
  9784. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  9785. connect(deviceId,SIGNAL(textEdited(QString)),
  9786. this,SLOT(updateDeviceId(QString)));
  9787. setLayout(layout);
  9788. }
  9789. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  9790. {
  9791. updateAttribute("deviceID",newId);
  9792. }
  9793. void NiDaqMx9211ConfWidget::addChannel()
  9794. {
  9795. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9796. }
  9797. /*:772*/
  9798. #line 591 "./typica.w"
  9799. /*774:*/
  9800. #line 16395 "./typica.w"
  9801. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  9802. const QModelIndex&index)
  9803. :BasicDeviceConfigurationWidget(model,index)
  9804. {
  9805. QFormLayout*layout= new QFormLayout;
  9806. QLineEdit*deviceId= new QLineEdit;
  9807. layout->addRow(tr("Device ID:"),deviceId);
  9808. QLineEdit*columnName= new QLineEdit;
  9809. layout->addRow(tr("Column Name:"),columnName);
  9810. QComboBox*typeSelector= new QComboBox;
  9811. typeSelector->addItem("J");
  9812. typeSelector->addItem("K");
  9813. typeSelector->addItem("T");
  9814. typeSelector->addItem("B");
  9815. typeSelector->addItem("E");
  9816. typeSelector->addItem("N");
  9817. typeSelector->addItem("R");
  9818. typeSelector->addItem("S");
  9819. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9820. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  9821. layout->addRow(hideSeries);
  9822. /*755:*/
  9823. #line 15980 "./typica.w"
  9824. QDomElement referenceElement=
  9825. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9826. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9827. QDomElement node;
  9828. /*:755*/
  9829. #line 16417 "./typica.w"
  9830. for(int i= 0;i<configData.size();i++)
  9831. {
  9832. node= configData.at(i).toElement();
  9833. if(node.attribute("name")=="deviceID")
  9834. {
  9835. deviceId->setText(node.attribute("value"));
  9836. }
  9837. else if(node.attribute("name")=="type")
  9838. {
  9839. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  9840. }
  9841. else if(node.attribute("name")=="columnname")
  9842. {
  9843. columnName->setText(node.attribute("value"));
  9844. }
  9845. else if(node.attribute("name")=="hidden")
  9846. {
  9847. hideSeries->setChecked(node.attribute("value")=="true");
  9848. }
  9849. }
  9850. updateDeviceId(deviceId->text());
  9851. updateThermocoupleType(typeSelector->currentText());
  9852. updateColumnName(columnName->text());
  9853. updateHidden(hideSeries->isChecked());
  9854. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  9855. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  9856. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9857. setLayout(layout);
  9858. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9859. }
  9860. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  9861. {
  9862. updateAttribute("deviceID",newId);
  9863. }
  9864. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  9865. {
  9866. updateAttribute("type",type);
  9867. }
  9868. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  9869. {
  9870. updateAttribute("columnname",name);
  9871. }
  9872. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  9873. {
  9874. updateAttribute("hidden",hidden?"true":"false");
  9875. }
  9876. /*:774*/
  9877. #line 592 "./typica.w"
  9878. /*792:*/
  9879. #line 16833 "./typica.w"
  9880. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  9881. const QModelIndex&index)
  9882. :BasicDeviceConfigurationWidget(model,index)
  9883. {
  9884. QFormLayout*layout= new QFormLayout;
  9885. QToolButton*addDeviceButton= new QToolButton;
  9886. addDeviceButton->setText(tr("Add Device"));
  9887. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  9888. "Modbus RTU Device",
  9889. "modbusrtudevice");
  9890. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  9891. this,SLOT(insertChildNode(QString,QString)));
  9892. QMenu*deviceMenu= new QMenu;
  9893. deviceMenu->addAction(addModbusRtuDevice);
  9894. addDeviceButton->setMenu(deviceMenu);
  9895. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9896. layout->addRow(QString(),addDeviceButton);
  9897. PortSelector*port= new PortSelector;
  9898. layout->addRow(tr("Port:"),port);
  9899. connect(port,SIGNAL(currentIndexChanged(QString)),
  9900. this,SLOT(updatePort(QString)));
  9901. connect(port,SIGNAL(editTextChanged(QString)),
  9902. this,SLOT(updatePort(QString)));
  9903. BaudSelector*rate= new BaudSelector;
  9904. layout->addRow(tr("Baud:"),rate);
  9905. connect(rate,SIGNAL(currentIndexChanged(QString)),
  9906. this,SLOT(updateBaudRate(QString)));
  9907. ParitySelector*parity= new ParitySelector;
  9908. layout->addRow(tr("Parity:"),parity);
  9909. connect(parity,SIGNAL(currentIndexChanged(QString)),
  9910. this,SLOT(updateParity(QString)));
  9911. FlowSelector*flow= new FlowSelector;
  9912. layout->addRow(tr("Flow Control:"),flow);
  9913. connect(flow,SIGNAL(currentIndexChanged(QString)),
  9914. this,SLOT(updateFlowControl(QString)));
  9915. StopSelector*stop= new StopSelector;
  9916. layout->addRow(tr("Stop Bits:"),stop);
  9917. connect(stop,SIGNAL(currentIndexChanged(QString)),
  9918. this,SLOT(updateStopBits(QString)));
  9919. /*755:*/
  9920. #line 15980 "./typica.w"
  9921. QDomElement referenceElement=
  9922. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9923. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9924. QDomElement node;
  9925. /*:755*/
  9926. #line 16873 "./typica.w"
  9927. for(int i= 0;i<configData.size();i++)
  9928. {
  9929. node= configData.at(i).toElement();
  9930. if(node.attribute("name")=="port")
  9931. {
  9932. int j= port->findText(node.attribute("value"));
  9933. if(j>=0)
  9934. {
  9935. port->setCurrentIndex(j);
  9936. }
  9937. else
  9938. {
  9939. port->insertItem(0,node.attribute("value"));
  9940. port->setCurrentIndex(0);
  9941. }
  9942. }
  9943. else if(node.attribute("name")=="baudrate")
  9944. {
  9945. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  9946. }
  9947. else if(node.attribute("name")=="parity")
  9948. {
  9949. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  9950. }
  9951. else if(node.attribute("name")=="flowcontrol")
  9952. {
  9953. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  9954. }
  9955. else if(node.attribute("name")=="stopbits")
  9956. {
  9957. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  9958. }
  9959. }
  9960. updatePort(port->currentText());
  9961. updateBaudRate(rate->currentText());
  9962. updateParity(parity->currentText());
  9963. updateFlowControl(flow->currentText());
  9964. updateStopBits(stop->currentText());
  9965. setLayout(layout);
  9966. }
  9967. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  9968. {
  9969. updateAttribute("port",newPort);
  9970. }
  9971. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  9972. {
  9973. updateAttribute("baudrate",newRate);
  9974. }
  9975. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  9976. {
  9977. updateAttribute("parity",newParity);
  9978. }
  9979. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  9980. {
  9981. updateAttribute("flowcontrol",newFlow);
  9982. }
  9983. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  9984. {
  9985. updateAttribute("stopbits",newStopBits);
  9986. }
  9987. /*:792*/
  9988. #line 593 "./typica.w"
  9989. /*794:*/
  9990. #line 16996 "./typica.w"
  9991. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  9992. const QModelIndex&index)
  9993. :BasicDeviceConfigurationWidget(model,index),
  9994. unitSpecificationLayout(new QStackedLayout),
  9995. decimalSpecificationLayout(new QStackedLayout)
  9996. {
  9997. QVBoxLayout*layout= new QVBoxLayout;
  9998. QToolButton*addChannelButton= new QToolButton;
  9999. addChannelButton->setText(tr("Add Channel"));
  10000. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10001. "Temperature Process Value",
  10002. "modbustemperaturepv");
  10003. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10004. "Temperature Set Value",
  10005. "modbustemperaturesv");
  10006. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10007. this,SLOT(insertChildNode(QString,QString)));
  10008. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10009. this,SLOT(insertChildNode(QString,QString)));
  10010. QMenu*channelMenu= new QMenu;
  10011. channelMenu->addAction(addTemperaturePV);
  10012. channelMenu->addAction(addTemperatureSV);
  10013. addChannelButton->setMenu(channelMenu);
  10014. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10015. layout->addWidget(addChannelButton);
  10016. QHBoxLayout*stationLayout= new QHBoxLayout;
  10017. QLabel*stationLabel= new QLabel(tr("Station:"));
  10018. QSpinBox*stationNumber= new QSpinBox;
  10019. stationNumber->setMinimum(0);
  10020. stationNumber->setMaximum(255);
  10021. stationLayout->addWidget(stationLabel);
  10022. stationLayout->addWidget(stationNumber);
  10023. layout->addLayout(stationLayout);
  10024. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10025. layout->addWidget(fixedUnit);
  10026. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10027. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10028. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10029. QComboBox*fixedUnitSelector= new QComboBox;
  10030. fixedUnitSelector->addItem("Fahrenheit");
  10031. fixedUnitSelector->addItem("Celsius");
  10032. fixedUnitLayout->addWidget(fixedUnitLabel);
  10033. fixedUnitLayout->addWidget(fixedUnitSelector);
  10034. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10035. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10036. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10037. QFormLayout*queriedUnitLayout= new QFormLayout;
  10038. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10039. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10040. QSpinBox*valueF= new QSpinBox;
  10041. valueF->setMinimum(0);
  10042. valueF->setMaximum(65535);
  10043. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10044. QSpinBox*valueC= new QSpinBox;
  10045. valueC->setMinimum(0);
  10046. valueC->setMaximum(65535);
  10047. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10048. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10049. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10050. layout->addLayout(unitSpecificationLayout);
  10051. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10052. layout->addWidget(fixedPrecision);
  10053. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10054. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10055. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10056. fixedPrecisionValue->setMinimum(0);
  10057. fixedPrecisionValue->setMaximum(9);
  10058. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10059. fixedPrecisionValue);
  10060. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10061. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10062. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10063. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10064. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10065. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10066. precisionAddress);
  10067. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10068. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10069. layout->addLayout(decimalSpecificationLayout);
  10070. /*755:*/
  10071. #line 15980 "./typica.w"
  10072. QDomElement referenceElement=
  10073. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10074. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10075. QDomElement node;
  10076. /*:755*/
  10077. #line 17076 "./typica.w"
  10078. for(int i= 0;i<configData.size();i++)
  10079. {
  10080. node= configData.at(i).toElement();
  10081. if(node.attribute("name")=="station")
  10082. {
  10083. stationNumber->setValue(node.attribute("value").toInt());
  10084. }
  10085. else if(node.attribute("name")=="fixedunit")
  10086. {
  10087. if(node.attribute("value")=="true")
  10088. {
  10089. fixedUnit->setCheckState(Qt::Checked);
  10090. }
  10091. else if(node.attribute("value")=="false")
  10092. {
  10093. fixedUnit->setCheckState(Qt::Unchecked);
  10094. }
  10095. }
  10096. else if(node.attribute("name")=="fixedprecision")
  10097. {
  10098. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10099. }
  10100. else if(node.attribute("name")=="unit")
  10101. {
  10102. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10103. }
  10104. else if(node.attribute("name")=="unitaddress")
  10105. {
  10106. unitAddress->setValue(node.attribute("value").toInt());
  10107. }
  10108. else if(node.attribute("name")=="fvalue")
  10109. {
  10110. valueF->setValue(node.attribute("value").toInt());
  10111. }
  10112. else if(node.attribute("name")=="cvalue")
  10113. {
  10114. valueC->setValue(node.attribute("value").toInt());
  10115. }
  10116. else if(node.attribute("name")=="precisionaddress")
  10117. {
  10118. precisionAddress->setValue(node.attribute("value").toInt());
  10119. }
  10120. else if(node.attribute("name")=="precision")
  10121. {
  10122. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10123. }
  10124. }
  10125. updateStationNumber(stationNumber->value());
  10126. updateFixedUnit(fixedUnit->isChecked());
  10127. updateFixedDecimal(fixedPrecision->isChecked());
  10128. updateUnit(fixedUnitSelector->currentText());
  10129. updateUnitAddress(unitAddress->value());
  10130. updateValueF(valueF->value());
  10131. updateValueC(valueC->value());
  10132. updatePrecisionAddress(precisionAddress->value());
  10133. updatePrecisionValue(fixedPrecisionValue->value());
  10134. connect(stationNumber,SIGNAL(valueChanged(int)),
  10135. this,SLOT(updateStationNumber(int)));
  10136. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10137. this,SLOT(updateUnit(QString)));
  10138. connect(unitAddress,SIGNAL(valueChanged(int)),
  10139. this,SLOT(updateUnitAddress(int)));
  10140. connect(valueF,SIGNAL(valueChanged(int)),
  10141. this,SLOT(updateValueF(int)));
  10142. connect(valueC,SIGNAL(valueChanged(int)),
  10143. this,SLOT(updateValueC(int)));
  10144. connect(fixedUnit,SIGNAL(toggled(bool)),
  10145. this,SLOT(updateFixedUnit(bool)));
  10146. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10147. this,SLOT(updateFixedDecimal(bool)));
  10148. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10149. this,SLOT(updatePrecisionValue(int)));
  10150. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10151. this,SLOT(updatePrecisionAddress(int)));
  10152. setLayout(layout);
  10153. }
  10154. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10155. {
  10156. updateAttribute("station",QString("%1").arg(newStation));
  10157. }
  10158. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10159. {
  10160. if(newFixed)
  10161. {
  10162. unitSpecificationLayout->setCurrentIndex(0);
  10163. updateAttribute("fixedunit","true");
  10164. }
  10165. else
  10166. {
  10167. unitSpecificationLayout->setCurrentIndex(1);
  10168. updateAttribute("fixedunit","false");
  10169. }
  10170. }
  10171. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10172. {
  10173. if(newFixed)
  10174. {
  10175. decimalSpecificationLayout->setCurrentIndex(0);
  10176. updateAttribute("fixedprecision","true");
  10177. }
  10178. else
  10179. {
  10180. decimalSpecificationLayout->setCurrentIndex(1);
  10181. updateAttribute("fixedprecision","false");
  10182. }
  10183. }
  10184. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10185. {
  10186. updateAttribute("unit",newUnit);
  10187. }
  10188. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10189. {
  10190. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10191. }
  10192. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10193. {
  10194. updateAttribute("fvalue",QString("%1").arg(newValue));
  10195. }
  10196. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10197. {
  10198. updateAttribute("cvalue",QString("%1").arg(newValue));
  10199. }
  10200. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10201. {
  10202. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10203. }
  10204. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10205. {
  10206. updateAttribute("precision",QString("%1").arg(newValue));
  10207. }
  10208. /*:794*/
  10209. #line 594 "./typica.w"
  10210. /*796:*/
  10211. #line 17239 "./typica.w"
  10212. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10213. const QModelIndex&index)
  10214. :BasicDeviceConfigurationWidget(model,index)
  10215. {
  10216. QFormLayout*layout= new QFormLayout;
  10217. ShortHexSpinBox*address= new ShortHexSpinBox;
  10218. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10219. /*755:*/
  10220. #line 15980 "./typica.w"
  10221. QDomElement referenceElement=
  10222. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10223. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10224. QDomElement node;
  10225. /*:755*/
  10226. #line 17247 "./typica.w"
  10227. for(int i= 0;i<configData.size();i++)
  10228. {
  10229. node= configData.at(i).toElement();
  10230. if(node.attribute("name")=="address")
  10231. {
  10232. address->setValue(node.attribute("value").toInt());
  10233. break;
  10234. }
  10235. }
  10236. updateAddress(address->value());
  10237. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10238. setLayout(layout);
  10239. }
  10240. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10241. {
  10242. updateAttribute("address",QString("%1").arg(newAddress));
  10243. }
  10244. /*:796*/
  10245. #line 595 "./typica.w"
  10246. /*798:*/
  10247. #line 17295 "./typica.w"
  10248. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10249. const QModelIndex&index)
  10250. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10251. {
  10252. QVBoxLayout*layout= new QVBoxLayout;
  10253. QFormLayout*addressLayout= new QFormLayout;
  10254. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10255. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10256. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10257. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10258. layout->addLayout(addressLayout);
  10259. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10260. layout->addWidget(fixedRange);
  10261. QWidget*queriedRangePlaceholder= new QWidget(this);
  10262. QFormLayout*queriedRangeLayout= new QFormLayout;
  10263. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10264. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10265. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10266. lowerAddress);
  10267. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10268. upperAddress);
  10269. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10270. boundsLayout->addWidget(queriedRangePlaceholder);
  10271. QWidget*fixedRangePlaceholder= new QWidget(this);
  10272. QFormLayout*fixedRangeLayout= new QFormLayout;
  10273. QLineEdit*fixedLower= new QLineEdit;
  10274. QLineEdit*fixedUpper= new QLineEdit;
  10275. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10276. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10277. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10278. boundsLayout->addWidget(fixedRangePlaceholder);
  10279. layout->addLayout(boundsLayout);
  10280. /*755:*/
  10281. #line 15980 "./typica.w"
  10282. QDomElement referenceElement=
  10283. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10284. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10285. QDomElement node;
  10286. /*:755*/
  10287. #line 17328 "./typica.w"
  10288. for(int i= 0;i<configData.size();i++)
  10289. {
  10290. node= configData.at(i).toElement();
  10291. if(node.attribute("name")=="readaddress")
  10292. {
  10293. readAddress->setValue(node.attribute("value").toInt());
  10294. }
  10295. else if(node.attribute("name")=="writeaddress")
  10296. {
  10297. writeAddress->setValue(node.attribute("value").toInt());
  10298. }
  10299. else if(node.attribute("name")=="fixedrange")
  10300. {
  10301. if(node.attribute("value")=="true")
  10302. {
  10303. fixedRange->setCheckState(Qt::Checked);
  10304. }
  10305. else if(node.attribute("value")=="false")
  10306. {
  10307. fixedRange->setCheckState(Qt::Unchecked);
  10308. }
  10309. }
  10310. else if(node.attribute("name")=="fixedlower")
  10311. {
  10312. fixedLower->setText(node.attribute("value"));
  10313. }
  10314. else if(node.attribute("name")=="fixedupper")
  10315. {
  10316. fixedUpper->setText(node.attribute("value"));
  10317. }
  10318. else if(node.attribute("name")=="loweraddress")
  10319. {
  10320. lowerAddress->setValue(node.attribute("value").toInt());
  10321. }
  10322. else if(node.attribute("name")=="upperaddress")
  10323. {
  10324. upperAddress->setValue(node.attribute("value").toInt());
  10325. }
  10326. }
  10327. updateReadAddress(readAddress->value());
  10328. updateWriteAddress(writeAddress->value());
  10329. updateFixedRange(fixedRange->isChecked());
  10330. updateLower(fixedLower->text());
  10331. updateUpper(fixedUpper->text());
  10332. updateLowerAddress(lowerAddress->value());
  10333. updateUpperAddress(upperAddress->value());
  10334. connect(readAddress,SIGNAL(valueChanged(int)),
  10335. this,SLOT(updateReadAddress(int)));
  10336. connect(writeAddress,SIGNAL(valueChanged(int)),
  10337. this,SLOT(updateWriteAddress(int)));
  10338. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10339. connect(fixedLower,SIGNAL(textChanged(QString)),
  10340. this,SLOT(updateLower(QString)));
  10341. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10342. this,SLOT(updateUpper(QString)));
  10343. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10344. this,SLOT(updateLowerAddress(int)));
  10345. connect(upperAddress,SIGNAL(valueChanged(int)),
  10346. this,SLOT(updateUpperAddress(int)));
  10347. setLayout(layout);
  10348. }
  10349. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10350. {
  10351. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10352. }
  10353. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10354. {
  10355. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10356. }
  10357. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10358. {
  10359. if(fixed)
  10360. {
  10361. updateAttribute("fixedrange","true");
  10362. boundsLayout->setCurrentIndex(1);
  10363. }
  10364. else
  10365. {
  10366. updateAttribute("fixedrange","false");
  10367. boundsLayout->setCurrentIndex(0);
  10368. }
  10369. }
  10370. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10371. {
  10372. updateAttribute("fixedlower",lower);
  10373. }
  10374. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10375. {
  10376. updateAttribute("fixedupper",upper);
  10377. }
  10378. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10379. {
  10380. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10381. }
  10382. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10383. {
  10384. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10385. }
  10386. /*:798*/
  10387. #line 596 "./typica.w"
  10388. /*754:*/
  10389. #line 15902 "./typica.w"
  10390. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10391. :BasicDeviceConfigurationWidget(model,index)
  10392. {
  10393. QVBoxLayout*layout= new QVBoxLayout;
  10394. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10395. QMenu*deviceMenu= new QMenu;
  10396. NodeInserter*insertAction;
  10397. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10398. {
  10399. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10400. this,SLOT(insertChildNode(QString,QString)));
  10401. deviceMenu->addAction(insertAction);
  10402. }
  10403. addDeviceButton->setMenu(deviceMenu);
  10404. layout->addWidget(addDeviceButton);
  10405. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10406. QMenu*annotationMenu= new QMenu;
  10407. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10408. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10409. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10410. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10411. tr("Free Text"),
  10412. "freeannotation");
  10413. annotationMenu->addAction(basicButtonInserter);
  10414. annotationMenu->addAction(countingButtonInserter);
  10415. annotationMenu->addAction(spinBoxInserter);
  10416. annotationMenu->addAction(freeAnnotationInserter);
  10417. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10418. this,SLOT(insertChildNode(QString,QString)));
  10419. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10420. this,SLOT(insertChildNode(QString,QString)));
  10421. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10422. this,SLOT(insertChildNode(QString,QString)));
  10423. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10424. this,SLOT(insertChildNode(QString,QString)));
  10425. /*1003:*/
  10426. #line 144 "./valueannotation.w"
  10427. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10428. tr("Value Annotation"),
  10429. "valueannotation");
  10430. annotationMenu->addAction(valueAnnotationInserter);
  10431. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10432. this,SLOT(insertChildNode(QString,QString)));
  10433. /*:1003*/
  10434. #line 15938 "./typica.w"
  10435. addAnnotationControlButton->setMenu(annotationMenu);
  10436. layout->addWidget(addAnnotationControlButton);
  10437. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10438. QMenu*advancedMenu= new QMenu;
  10439. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10440. advancedMenu->addAction(linearsplineinserter);
  10441. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10442. advancedMenu->addAction(translationinserter);
  10443. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10444. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10445. /*929:*/
  10446. #line 258 "./rate.w"
  10447. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10448. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10449. advancedMenu->addAction(rateOfChangeInserter);
  10450. /*:929*/
  10451. #line 15949 "./typica.w"
  10452. advancedButton->setMenu(advancedMenu);
  10453. layout->addWidget(advancedButton);
  10454. QHBoxLayout*idLayout= new QHBoxLayout;
  10455. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10456. idLayout->addWidget(idLabel);
  10457. QSpinBox*id= new QSpinBox;
  10458. idLayout->addWidget(id);
  10459. layout->addLayout(idLayout);
  10460. /*755:*/
  10461. #line 15980 "./typica.w"
  10462. QDomElement referenceElement=
  10463. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10464. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10465. QDomElement node;
  10466. /*:755*/
  10467. #line 15958 "./typica.w"
  10468. for(int i= 0;i<configData.size();i++)
  10469. {
  10470. node= configData.at(i).toElement();
  10471. if(node.attribute("name")=="databaseid")
  10472. {
  10473. id->setValue(node.attribute("value").toInt());
  10474. break;
  10475. }
  10476. }
  10477. updateRoasterId(id->value());
  10478. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10479. setLayout(layout);
  10480. }
  10481. /*:754*//*756:*/
  10482. #line 15990 "./typica.w"
  10483. void RoasterConfWidget::updateRoasterId(int id)
  10484. {
  10485. updateAttribute("databaseid",QString("%1").arg(id));
  10486. }
  10487. /*:756*/
  10488. #line 597 "./typica.w"
  10489. /*802:*/
  10490. #line 17478 "./typica.w"
  10491. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10492. :BasicDeviceConfigurationWidget(model,index)
  10493. {
  10494. QFormLayout*layout= new QFormLayout;
  10495. QLineEdit*buttonTextEdit= new QLineEdit;
  10496. QLineEdit*annotationTextEdit= new QLineEdit;
  10497. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10498. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10499. /*755:*/
  10500. #line 15980 "./typica.w"
  10501. QDomElement referenceElement=
  10502. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10503. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10504. QDomElement node;
  10505. /*:755*/
  10506. #line 17487 "./typica.w"
  10507. for(int i= 0;i<configData.size();i++)
  10508. {
  10509. node= configData.at(i).toElement();
  10510. if(node.attribute("name")=="buttontext")
  10511. {
  10512. buttonTextEdit->setText(node.attribute("value"));
  10513. }
  10514. else if(node.attribute("name")=="annotationtext")
  10515. {
  10516. annotationTextEdit->setText(node.attribute("value"));
  10517. }
  10518. }
  10519. updateButtonText(buttonTextEdit->text());
  10520. updateAnnotationText(annotationTextEdit->text());
  10521. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10522. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10523. setLayout(layout);
  10524. }
  10525. /*:802*//*803:*/
  10526. #line 17509 "./typica.w"
  10527. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10528. {
  10529. updateAttribute("buttontext",text);
  10530. }
  10531. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10532. {
  10533. updateAttribute("annotationtext",text);
  10534. }
  10535. /*:803*//*806:*/
  10536. #line 17547 "./typica.w"
  10537. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10538. :BasicDeviceConfigurationWidget(model,index)
  10539. {
  10540. QFormLayout*layout= new QFormLayout;
  10541. QLineEdit*buttonTextEdit= new QLineEdit;
  10542. QLineEdit*annotationTextEdit= new QLineEdit;
  10543. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10544. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10545. /*755:*/
  10546. #line 15980 "./typica.w"
  10547. QDomElement referenceElement=
  10548. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10549. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10550. QDomElement node;
  10551. /*:755*/
  10552. #line 17556 "./typica.w"
  10553. for(int i= 0;i<configData.size();i++)
  10554. {
  10555. node= configData.at(i).toElement();
  10556. if(node.attribute("name")=="buttontext")
  10557. {
  10558. buttonTextEdit->setText(node.attribute("value"));
  10559. }
  10560. else if(node.attribute("name")=="annotationtext")
  10561. {
  10562. annotationTextEdit->setText(node.attribute("value"));
  10563. }
  10564. }
  10565. updateButtonText(buttonTextEdit->text());
  10566. updateAnnotationText(annotationTextEdit->text());
  10567. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10568. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10569. QTextEdit*documentation= new QTextEdit;
  10570. 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."));
  10571. documentation->setReadOnly(true);
  10572. layout->addRow("",documentation);
  10573. setLayout(layout);
  10574. }
  10575. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10576. {
  10577. updateAttribute("buttontext",text);
  10578. }
  10579. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10580. {
  10581. updateAttribute("annotationtext",text);
  10582. }
  10583. /*:806*/
  10584. #line 598 "./typica.w"
  10585. /*809:*/
  10586. #line 17624 "./typica.w"
  10587. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10588. :BasicDeviceConfigurationWidget(model,index)
  10589. {
  10590. QFormLayout*layout= new QFormLayout;
  10591. QLineEdit*labelEdit= new QLineEdit;
  10592. layout->addRow(tr("Control Label: "),labelEdit);
  10593. QLineEdit*minimumEdit= new QLineEdit;
  10594. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10595. QLineEdit*maximumEdit= new QLineEdit;
  10596. layout->addRow(tr("Maximum Value: "),maximumEdit);
  10597. QSpinBox*precisionEdit= new QSpinBox;
  10598. precisionEdit->setMinimum(0);
  10599. precisionEdit->setMaximum(9);
  10600. layout->addRow(tr("Precision"),precisionEdit);
  10601. QLineEdit*pretext= new QLineEdit;
  10602. layout->addRow(tr("Prefix text"),pretext);
  10603. QLineEdit*posttext= new QLineEdit;
  10604. layout->addRow(tr("Suffix text"),posttext);
  10605. /*755:*/
  10606. #line 15980 "./typica.w"
  10607. QDomElement referenceElement=
  10608. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10609. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10610. QDomElement node;
  10611. /*:755*/
  10612. #line 17643 "./typica.w"
  10613. for(int i= 0;i<configData.size();i++)
  10614. {
  10615. node= configData.at(i).toElement();
  10616. if(node.attribute("name")=="label")
  10617. {
  10618. labelEdit->setText(node.attribute("value"));
  10619. }
  10620. else if(node.attribute("name")=="minimum")
  10621. {
  10622. minimumEdit->setText(node.attribute("value"));
  10623. }
  10624. else if(node.attribute("name")=="maximum")
  10625. {
  10626. maximumEdit->setText(node.attribute("value"));
  10627. }
  10628. else if(node.attribute("name")=="precision")
  10629. {
  10630. precisionEdit->setValue(node.attribute("value").toInt());
  10631. }
  10632. else if(node.attribute("name")=="pretext")
  10633. {
  10634. pretext->setText(node.attribute("value"));
  10635. }
  10636. else if(node.attribute("name")=="posttext")
  10637. {
  10638. posttext->setText(node.attribute("value"));
  10639. }
  10640. }
  10641. updateLabel(labelEdit->text());
  10642. updateMinimum(minimumEdit->text());
  10643. updateMaximum(maximumEdit->text());
  10644. updatePrecision(precisionEdit->value());
  10645. updatePretext(pretext->text());
  10646. updatePosttext(posttext->text());
  10647. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  10648. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  10649. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  10650. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  10651. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  10652. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  10653. setLayout(layout);
  10654. }
  10655. void NoteSpinConfWidget::updateLabel(const QString&text)
  10656. {
  10657. updateAttribute("label",text);
  10658. }
  10659. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  10660. {
  10661. updateAttribute("minimum",minimum);
  10662. }
  10663. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  10664. {
  10665. updateAttribute("maximum",maximum);
  10666. }
  10667. void NoteSpinConfWidget::updatePrecision(int precision)
  10668. {
  10669. updateAttribute("precision",QString("%1").arg(precision));
  10670. }
  10671. void NoteSpinConfWidget::updatePretext(const QString&text)
  10672. {
  10673. updateAttribute("pretext",text);
  10674. }
  10675. void NoteSpinConfWidget::updatePosttext(const QString&text)
  10676. {
  10677. updateAttribute("posttext",text);
  10678. }
  10679. /*:809*/
  10680. #line 599 "./typica.w"
  10681. /*319:*/
  10682. #line 7293 "./typica.w"
  10683. LinearCalibrator::LinearCalibrator(QObject*parent):
  10684. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  10685. {
  10686. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10687. }
  10688. /*:319*//*320:*/
  10689. #line 7307 "./typica.w"
  10690. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  10691. {
  10692. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  10693. if(clamp)
  10694. {
  10695. if(outval<Lo1)
  10696. {
  10697. outval= Lo1;
  10698. }
  10699. else if(outval> Up1)
  10700. {
  10701. outval= Up1;
  10702. }
  10703. }
  10704. if(sensitivitySetting>=0.05)
  10705. {
  10706. int temp= qRound(outval/sensitivitySetting);
  10707. outval= temp*sensitivitySetting;
  10708. }
  10709. Measurement adjusted(outval,measure.time(),measure.scale());
  10710. emit measurement(adjusted);
  10711. return adjusted;
  10712. }
  10713. /*:320*//*321:*/
  10714. #line 7334 "./typica.w"
  10715. double LinearCalibrator::measuredLower()
  10716. {
  10717. return Lo2;
  10718. }
  10719. double LinearCalibrator::measuredUpper()
  10720. {
  10721. return Up2;
  10722. }
  10723. double LinearCalibrator::mappedLower()
  10724. {
  10725. return Lo1;
  10726. }
  10727. double LinearCalibrator::mappedUpper()
  10728. {
  10729. return Up1;
  10730. }
  10731. bool LinearCalibrator::isClosedRange()
  10732. {
  10733. return clamp;
  10734. }
  10735. void LinearCalibrator::setMeasuredLower(double lower)
  10736. {
  10737. Lo2= lower;
  10738. }
  10739. void LinearCalibrator::setMeasuredUpper(double upper)
  10740. {
  10741. Up2= upper;
  10742. }
  10743. void LinearCalibrator::setMappedLower(double lower)
  10744. {
  10745. Lo1= lower;
  10746. }
  10747. void LinearCalibrator::setMappedUpper(double upper)
  10748. {
  10749. Up1= upper;
  10750. }
  10751. void LinearCalibrator::setClosedRange(bool closed)
  10752. {
  10753. clamp= closed;
  10754. }
  10755. void LinearCalibrator::setSensitivity(double sensitivity)
  10756. {
  10757. sensitivitySetting= sensitivity;
  10758. }
  10759. double LinearCalibrator::sensitivity()
  10760. {
  10761. return sensitivitySetting;
  10762. }
  10763. /*:321*/
  10764. #line 600 "./typica.w"
  10765. /*326:*/
  10766. #line 7467 "./typica.w"
  10767. void LinearSplineInterpolator::add_pair(double source,double destination)
  10768. {
  10769. pairs->insert(source,destination);
  10770. make_interpolators();
  10771. }
  10772. void LinearSplineInterpolator::make_interpolators()
  10773. {
  10774. if(pairs->size()> 1)
  10775. {
  10776. while(interpolators->size()> 0)
  10777. {
  10778. LinearCalibrator*removed= interpolators->takeFirst();
  10779. removed->deleteLater();
  10780. }
  10781. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10782. QMap<double,double> ::const_iterator j= i+1;
  10783. while(j!=pairs->constEnd())
  10784. {
  10785. LinearCalibrator*segment= new LinearCalibrator();
  10786. segment->setMeasuredLower(i.key());
  10787. segment->setMappedLower(i.value());
  10788. segment->setMeasuredUpper(j.key());
  10789. segment->setMappedUpper(j.value());
  10790. segment->setClosedRange(false);
  10791. interpolators->append(segment);
  10792. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10793. i++;
  10794. j++;
  10795. }
  10796. }
  10797. }
  10798. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  10799. QObject(parent),pairs(new QMap<double,double> ),
  10800. interpolators(new QList<LinearCalibrator*> )
  10801. {
  10802. }
  10803. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  10804. {
  10805. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10806. int index= -1;
  10807. while(i!=pairs->constEnd())
  10808. {
  10809. if(measure.temperature()<=i.key())
  10810. {
  10811. break;
  10812. }
  10813. i++;
  10814. index++;
  10815. }
  10816. if(index<0)
  10817. {
  10818. index= 0;
  10819. }
  10820. if(index>=interpolators->size())
  10821. {
  10822. index= interpolators->size()-1;
  10823. }
  10824. if(interpolators->at(index)!=NULL)
  10825. {
  10826. return interpolators->at(index)->newMeasurement(measure);
  10827. }
  10828. return Measurement();
  10829. }
  10830. /*:326*/
  10831. #line 601 "./typica.w"
  10832. /*908:*/
  10833. #line 18992 "./typica.w"
  10834. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10835. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  10836. {
  10837. QFormLayout*layout= new QFormLayout;
  10838. QLineEdit*source= new QLineEdit;
  10839. layout->addRow(tr("Source column name:"),source);
  10840. QLineEdit*destination= new QLineEdit;
  10841. layout->addRow(tr("Destination column name:"),destination);
  10842. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  10843. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  10844. QTableView*mappingTable= new QTableView;
  10845. mappingTable->setModel(tablemodel);
  10846. NumericDelegate*delegate= new NumericDelegate;
  10847. mappingTable->setItemDelegate(delegate);
  10848. layout->addRow(tr("Mapping data:"),mappingTable);
  10849. /*755:*/
  10850. #line 15980 "./typica.w"
  10851. QDomElement referenceElement=
  10852. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10853. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10854. QDomElement node;
  10855. /*:755*/
  10856. #line 19008 "./typica.w"
  10857. for(int i= 0;i<configData.size();i++)
  10858. {
  10859. node= configData.at(i).toElement();
  10860. if(node.attribute("name")=="source")
  10861. {
  10862. source->setText(node.attribute("value"));
  10863. }
  10864. else if(node.attribute("name")=="destination")
  10865. {
  10866. destination->setText(node.attribute("value"));
  10867. }
  10868. else if(node.attribute("name")=="sourcevalues")
  10869. {
  10870. /*909:*/
  10871. #line 19047 "./typica.w"
  10872. QString data= node.attribute("value");
  10873. if(data.length()> 3)
  10874. {
  10875. data.chop(2);
  10876. data= data.remove(0,2);
  10877. }
  10878. QStringList itemList= data.split(",");
  10879. /*:909*/
  10880. #line 19022 "./typica.w"
  10881. int column= 0;
  10882. /*910:*/
  10883. #line 19059 "./typica.w"
  10884. for(int i= 0;i<itemList.size();i++)
  10885. {
  10886. tablemodel->setData(tablemodel->index(i,column),
  10887. QVariant(itemList.at(i).toDouble()),
  10888. Qt::DisplayRole);
  10889. }
  10890. /*:910*/
  10891. #line 19024 "./typica.w"
  10892. }
  10893. else if(node.attribute("name")=="destinationvalues")
  10894. {
  10895. /*909:*/
  10896. #line 19047 "./typica.w"
  10897. QString data= node.attribute("value");
  10898. if(data.length()> 3)
  10899. {
  10900. data.chop(2);
  10901. data= data.remove(0,2);
  10902. }
  10903. QStringList itemList= data.split(",");
  10904. /*:909*/
  10905. #line 19029 "./typica.w"
  10906. int column= 1;
  10907. /*910:*/
  10908. #line 19059 "./typica.w"
  10909. for(int i= 0;i<itemList.size();i++)
  10910. {
  10911. tablemodel->setData(tablemodel->index(i,column),
  10912. QVariant(itemList.at(i).toDouble()),
  10913. Qt::DisplayRole);
  10914. }
  10915. /*:910*/
  10916. #line 19031 "./typica.w"
  10917. }
  10918. }
  10919. updateSourceColumn(source->text());
  10920. updateDestinationColumn(destination->text());
  10921. updateKnots();
  10922. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  10923. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  10924. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  10925. setLayout(layout);
  10926. }
  10927. /*:908*//*911:*/
  10928. #line 19070 "./typica.w"
  10929. void LinearSplineInterpolationConfWidget::updateKnots()
  10930. {
  10931. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  10932. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  10933. }
  10934. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  10935. {
  10936. updateAttribute("source",source);
  10937. }
  10938. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  10939. {
  10940. updateAttribute("destination",dest);
  10941. }
  10942. /*:911*/
  10943. #line 602 "./typica.w"
  10944. /*914:*/
  10945. #line 19113 "./typica.w"
  10946. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10947. :BasicDeviceConfigurationWidget(model,index),
  10948. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  10949. {
  10950. unitSelector->addItem("Fahrenheit");
  10951. unitSelector->addItem("Celsius");
  10952. temperatureValue->setMinimum(0);
  10953. temperatureValue->setMaximum(1000);
  10954. QFormLayout*layout= new QFormLayout;
  10955. QLineEdit*column= new QLineEdit;
  10956. layout->addRow(tr("Column to match:"),column);
  10957. layout->addRow(tr("Unit:"),unitSelector);
  10958. layout->addRow(tr("Value:"),temperatureValue);
  10959. /*755:*/
  10960. #line 15980 "./typica.w"
  10961. QDomElement referenceElement=
  10962. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10963. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10964. QDomElement node;
  10965. /*:755*/
  10966. #line 19127 "./typica.w"
  10967. for(int i= 0;i<configData.size();i++)
  10968. {
  10969. node= configData.at(i).toElement();
  10970. if(node.attribute("name")=="column")
  10971. {
  10972. column->setText(node.attribute("value"));
  10973. }
  10974. else if(node.attribute("name")=="unit")
  10975. {
  10976. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  10977. }
  10978. else if(node.attribute("name")=="value")
  10979. {
  10980. temperatureValue->setValue(node.attribute("value").toDouble());
  10981. }
  10982. }
  10983. updateMatchingColumn(column->text());
  10984. updateTemperature();
  10985. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  10986. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  10987. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  10988. setLayout(layout);
  10989. }
  10990. /*:914*//*915:*/
  10991. #line 19156 "./typica.w"
  10992. void TranslationConfWidget::updateTemperature()
  10993. {
  10994. updateAttribute("unit",unitSelector->currentText());
  10995. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  10996. if(unitSelector->currentText()=="Fahrenheit")
  10997. {
  10998. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  10999. }
  11000. else
  11001. {
  11002. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11003. }
  11004. }
  11005. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11006. {
  11007. updateAttribute("column",column);
  11008. }
  11009. /*:915*/
  11010. #line 603 "./typica.w"
  11011. /*812:*/
  11012. #line 24 "./freeannotation.w"
  11013. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11014. const QModelIndex&index)
  11015. :BasicDeviceConfigurationWidget(model,index)
  11016. {
  11017. QFormLayout*layout= new QFormLayout;
  11018. QLineEdit*labelEdit= new QLineEdit;
  11019. layout->addRow(tr("Label Text:"),labelEdit);
  11020. /*755:*/
  11021. #line 15980 "./typica.w"
  11022. QDomElement referenceElement=
  11023. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11024. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11025. QDomElement node;
  11026. /*:755*/
  11027. #line 32 "./freeannotation.w"
  11028. for(int i= 0;i<configData.size();i++)
  11029. {
  11030. node= configData.at(i).toElement();
  11031. if(node.attribute("name")=="labeltext")
  11032. {
  11033. labelEdit->setText(node.attribute("value"));
  11034. }
  11035. }
  11036. updateLabel(labelEdit->text());
  11037. connect(labelEdit,SIGNAL(textEdited(QString)),
  11038. this,SLOT(updateLabel(QString)));
  11039. setLayout(layout);
  11040. }
  11041. /*:812*//*813:*/
  11042. #line 49 "./freeannotation.w"
  11043. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11044. {
  11045. updateAttribute("labeltext",text);
  11046. }
  11047. /*:813*/
  11048. #line 604 "./typica.w"
  11049. /*918:*/
  11050. #line 39 "./rate.w"
  11051. void RateOfChange::newMeasurement(Measurement measure)
  11052. {
  11053. cache.append(measure);
  11054. /*919:*/
  11055. #line 64 "./rate.w"
  11056. if(cache.size()> 2)
  11057. {
  11058. bool done= false;
  11059. while(!done)
  11060. {
  11061. if(cache.front().time().secsTo(cache.back().time())> ct)
  11062. {
  11063. cache.removeFirst();
  11064. }
  11065. else if(cache.back().time()<cache.front().time())
  11066. {
  11067. cache.removeFirst();
  11068. done= true;
  11069. }
  11070. else
  11071. {
  11072. done= true;
  11073. }
  11074. if(cache.size()<3)
  11075. {
  11076. done= true;
  11077. }
  11078. }
  11079. }
  11080. /*:919*/
  11081. #line 43 "./rate.w"
  11082. if(cache.size()>=2)
  11083. {
  11084. /*920:*/
  11085. #line 96 "./rate.w"
  11086. int N= cache.size();
  11087. double SXY= 0;
  11088. double SX= 0;
  11089. double SXX= 0;
  11090. double SY= 0;
  11091. double y;
  11092. double x;
  11093. for(int i= 0;i<N;i++)
  11094. {
  11095. y= cache.at(i).temperature();
  11096. SY+= y;
  11097. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11098. SX+= x;
  11099. SXX+= (x*x);
  11100. SXY+= (x*y);
  11101. }
  11102. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11103. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11104. value.insert("relative",true);
  11105. emit newData(value);
  11106. /*:920*/
  11107. #line 46 "./rate.w"
  11108. }
  11109. }
  11110. /*:918*//*921:*/
  11111. #line 120 "./rate.w"
  11112. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11113. {
  11114. setScaleTime(scaletime);
  11115. }
  11116. void RateOfChange::setCacheTime(int seconds)
  11117. {
  11118. ct= seconds;
  11119. }
  11120. void RateOfChange::setScaleTime(int seconds)
  11121. {
  11122. st= (seconds> 0?seconds:1);
  11123. }
  11124. /*:921*/
  11125. #line 605 "./typica.w"
  11126. /*816:*/
  11127. #line 26 "./settings.w"
  11128. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11129. {
  11130. QTabWidget*settingsTab= new QTabWidget;
  11131. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11132. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11133. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11134. settingsTab->addTab(graphSettings,tr("Graph"));
  11135. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11136. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11137. setCentralWidget(settingsTab);
  11138. }
  11139. /*:816*/
  11140. #line 606 "./typica.w"
  11141. /*821:*/
  11142. #line 27 "./graphsettings.w"
  11143. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11144. {
  11145. QTabWidget*graphCategories= new QTabWidget;
  11146. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11147. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11148. QVBoxLayout*layout= new QVBoxLayout;
  11149. layout->addWidget(graphCategories);
  11150. setLayout(layout);
  11151. }
  11152. /*:821*//*823:*/
  11153. #line 65 "./graphsettings.w"
  11154. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11155. colorEdit(new QLineEdit)
  11156. {
  11157. QSettings settings;
  11158. QVBoxLayout*layout= new QVBoxLayout;
  11159. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11160. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11161. updateEnableSetting(enable->isChecked());
  11162. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11163. layout->addWidget(enable);
  11164. QHBoxLayout*colorLayout= new QHBoxLayout;
  11165. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11166. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11167. updateColorSetting(colorEdit->text());
  11168. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11169. QToolButton*colorPickerButton= new QToolButton();
  11170. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11171. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11172. colorLayout->addWidget(colorLabel);
  11173. colorLayout->addWidget(colorEdit);
  11174. colorLayout->addWidget(colorPickerButton);
  11175. colorLayout->addStretch();
  11176. layout->addLayout(colorLayout);
  11177. QHBoxLayout*unitLayout= new QHBoxLayout;
  11178. QLabel*unitLabel= new QLabel(tr("Unit"));
  11179. QComboBox*unitSelector= new QComboBox;
  11180. unitSelector->addItem(tr("Fahrenheit"));
  11181. unitSelector->addItem(tr("Celsius"));
  11182. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11183. updateUnit(unitSelector->currentIndex());
  11184. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11185. unitLayout->addWidget(unitLabel);
  11186. unitLayout->addWidget(unitSelector);
  11187. unitLayout->addStretch();
  11188. layout->addLayout(unitLayout);
  11189. QHBoxLayout*axisLayout= new QHBoxLayout;
  11190. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11191. QLineEdit*axisEdit= new QLineEdit;
  11192. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  11193. updateAxisSetting(axisEdit->text());
  11194. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11195. axisLayout->addWidget(axisLabel);
  11196. axisLayout->addWidget(axisEdit);
  11197. layout->addLayout(axisLayout);
  11198. layout->addStretch();
  11199. setLayout(layout);
  11200. }
  11201. /*:823*//*824:*/
  11202. #line 116 "./graphsettings.w"
  11203. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11204. {
  11205. QSettings settings;
  11206. settings.setValue("settings/graph/relative/enable",enabled);
  11207. }
  11208. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11209. {
  11210. QSettings settings;
  11211. settings.setValue("settings/graph/relative/color",color);
  11212. }
  11213. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11214. {
  11215. QSettings settings;
  11216. QString settingValue;
  11217. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11218. QStringList numbers;
  11219. foreach(QString text,points)
  11220. {
  11221. bool okay= false;
  11222. text.toDouble(&okay);
  11223. if(okay)
  11224. {
  11225. numbers.append(text);
  11226. }
  11227. }
  11228. numbers.removeDuplicates();
  11229. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11230. }
  11231. void GraphSettingsRelativeTab::updateUnit(int unit)
  11232. {
  11233. QSettings settings;
  11234. settings.setValue("settings/graph/relative/unit",unit);
  11235. }
  11236. /*:824*//*825:*/
  11237. #line 159 "./graphsettings.w"
  11238. void GraphSettingsRelativeTab::showColorPicker()
  11239. {
  11240. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11241. colorEdit->setText(color.name());
  11242. }
  11243. #line 62 "./settings.w"
  11244. #line 1 "./advancedsettings.w"
  11245. /*:825*/
  11246. #line 607 "./typica.w"
  11247. /*953:*/
  11248. #line 682 "./dataqsdk.w"
  11249. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11250. const QModelIndex&index)
  11251. :BasicDeviceConfigurationWidget(model,index),
  11252. deviceIdStack(new QStackedWidget)
  11253. {
  11254. QVBoxLayout*layout= new QVBoxLayout;
  11255. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11256. layout->addWidget(autoDetect);
  11257. QWidget*autoLayerWidget= new QWidget;
  11258. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11259. QLabel*autoLabel= new QLabel(tr("Device number"));
  11260. QSpinBox*autoNumber= new QSpinBox;
  11261. autoNumber->setMinimum(1);
  11262. autoNumber->setMaximum(99);
  11263. autoLayerLayout->addWidget(autoLabel);
  11264. autoLayerLayout->addWidget(autoNumber);
  11265. autoLayerWidget->setLayout(autoLayerLayout);
  11266. QWidget*fixedLayerWidget= new QWidget;
  11267. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11268. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11269. QComboBox*portSelection= new QComboBox;
  11270. portSelection->setEditable(true);
  11271. portSelection->addItems(DataqSdkDevice::detectHardware());
  11272. fixedLayerLayout->addWidget(fixedLabel);
  11273. fixedLayerLayout->addWidget(portSelection);
  11274. fixedLayerWidget->setLayout(fixedLayerLayout);
  11275. deviceIdStack->addWidget(autoLayerWidget);
  11276. deviceIdStack->addWidget(fixedLayerWidget);
  11277. layout->addWidget(deviceIdStack);
  11278. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11279. layout->addWidget(addChannelButton);
  11280. /*755:*/
  11281. #line 15980 "./typica.w"
  11282. QDomElement referenceElement=
  11283. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11284. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11285. QDomElement node;
  11286. /*:755*/
  11287. #line 714 "./dataqsdk.w"
  11288. for(int i= 0;i<configData.size();i++)
  11289. {
  11290. node= configData.at(i).toElement();
  11291. if(node.attribute("name")=="autoSelect")
  11292. {
  11293. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11294. }
  11295. else if(node.attribute("name")=="deviceNumber")
  11296. {
  11297. autoNumber->setValue(node.attribute("value").toInt());
  11298. }
  11299. else if(node.attribute("name")=="port")
  11300. {
  11301. int index= portSelection->findText(node.attribute("value"));
  11302. if(index> -1)
  11303. {
  11304. portSelection->setCurrentIndex(index);
  11305. }
  11306. else
  11307. {
  11308. portSelection->setEditText(node.attribute("value"));
  11309. }
  11310. }
  11311. }
  11312. updateAutoSelect(autoDetect->isChecked());
  11313. updateDeviceNumber(autoNumber->value());
  11314. updatePort(portSelection->currentText());
  11315. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11316. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11317. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11318. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11319. setLayout(layout);
  11320. }
  11321. /*:953*//*954:*/
  11322. #line 758 "./dataqsdk.w"
  11323. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11324. {
  11325. if(automatic)
  11326. {
  11327. updateAttribute("autoSelect","true");
  11328. deviceIdStack->setCurrentIndex(0);
  11329. }
  11330. else
  11331. {
  11332. updateAttribute("autoSelect","false");
  11333. deviceIdStack->setCurrentIndex(1);
  11334. }
  11335. }
  11336. /*:954*//*955:*/
  11337. #line 775 "./dataqsdk.w"
  11338. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11339. {
  11340. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11341. }
  11342. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11343. {
  11344. updateAttribute("port",portId);
  11345. }
  11346. /*:955*//*956:*/
  11347. #line 788 "./dataqsdk.w"
  11348. void DataqSdkDeviceConfWidget::addChannel()
  11349. {
  11350. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11351. }
  11352. /*:956*//*959:*/
  11353. #line 868 "./dataqsdk.w"
  11354. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11355. const QModelIndex&index)
  11356. :BasicDeviceConfigurationWidget(model,index),
  11357. startButton(new QPushButton(tr("Start"))),
  11358. resetButton(new QPushButton(tr("Reset"))),
  11359. stopButton(new QPushButton(tr("Stop"))),
  11360. calibrator(new LinearCalibrator),
  11361. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11362. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11363. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11364. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11365. rmCount(0),cmCount(0),
  11366. rmin(std::numeric_limits<double> ::max()),
  11367. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11368. cmin(std::numeric_limits<double> ::max()),
  11369. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11370. {
  11371. /*963:*/
  11372. #line 1107 "./dataqsdk.w"
  11373. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11374. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11375. QDomElement deviceNode;
  11376. QString configPort;
  11377. QString configAuto;
  11378. for(int i= 0;i<deviceConfigData.size();i++)
  11379. {
  11380. deviceNode= deviceConfigData.at(i).toElement();
  11381. if(deviceNode.attribute("name")=="autoSelect")
  11382. {
  11383. autoSelect= (deviceNode.attribute("value")=="true");
  11384. }
  11385. else if(deviceNode.attribute("name")=="deviceNumber")
  11386. {
  11387. configAuto= deviceNode.attribute("value");
  11388. }
  11389. else if(deviceNode.attribute("name")=="port")
  11390. {
  11391. configPort= deviceNode.attribute("value");
  11392. }
  11393. }
  11394. deviceID= autoSelect?configAuto:configPort;
  11395. channelOfInterest= index.row();
  11396. /*:963*/
  11397. #line 886 "./dataqsdk.w"
  11398. resetButton->setEnabled(false);
  11399. stopButton->setEnabled(false);
  11400. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11401. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11402. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11403. QVBoxLayout*layout= new QVBoxLayout;
  11404. QFormLayout*topLayout= new QFormLayout;
  11405. QLineEdit*columnEdit= new QLineEdit;
  11406. topLayout->addRow(tr("Column name"),columnEdit);
  11407. QComboBox*unitSelector= new QComboBox;
  11408. unitSelector->addItem(tr("Temperature"));
  11409. unitSelector->addItem(tr("Control"));
  11410. topLayout->addRow(tr("Measurement type"),unitSelector);
  11411. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11412. topLayout->addRow(smoothingBox);
  11413. layout->addLayout(topLayout);
  11414. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11415. topLayout->addRow(hideSeries);
  11416. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11417. layout->addWidget(calibrationLabel);
  11418. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11419. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11420. QLineEdit*measuredLowerEdit= new QLineEdit;
  11421. measuredLowerEdit->setText("0");
  11422. QLineEdit*measuredUpperEdit= new QLineEdit;
  11423. measuredUpperEdit->setText("10");
  11424. QLineEdit*mappedLowerEdit= new QLineEdit;
  11425. mappedLowerEdit->setText("0");
  11426. QLineEdit*mappedUpperEdit= new QLineEdit;
  11427. mappedUpperEdit->setText("10");
  11428. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11429. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11430. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11431. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11432. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11433. calibrationControlsLayout->addRow(closedBox);
  11434. QLineEdit*sensitivityEdit= new QLineEdit;
  11435. sensitivityEdit->setText("0");
  11436. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11437. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11438. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11439. deviceControlLayout->addWidget(startButton);
  11440. deviceControlLayout->addWidget(resetButton);
  11441. deviceControlLayout->addWidget(stopButton);
  11442. QFormLayout*indicatorLayout= new QFormLayout;
  11443. currentMeasurement->setReadOnly(true);
  11444. minimumMeasurement->setReadOnly(true);
  11445. maximumMeasurement->setReadOnly(true);
  11446. averageMeasurement->setReadOnly(true);
  11447. currentMapped->setReadOnly(true);
  11448. minimumMapped->setReadOnly(true);
  11449. maximumMapped->setReadOnly(true);
  11450. averageMapped->setReadOnly(true);
  11451. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11452. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11453. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11454. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11455. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11456. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11457. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11458. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11459. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11460. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11461. calibrationTestLayout->addLayout(deviceControlLayout);
  11462. calibrationTestLayout->addLayout(indicatorLayout);
  11463. calibrationLayout->addLayout(calibrationControlsLayout);
  11464. calibrationLayout->addLayout(calibrationTestLayout);
  11465. layout->addLayout(calibrationLayout);
  11466. /*755:*/
  11467. #line 15980 "./typica.w"
  11468. QDomElement referenceElement=
  11469. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11470. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11471. QDomElement node;
  11472. /*:755*/
  11473. #line 955 "./dataqsdk.w"
  11474. for(int i= 0;i<configData.size();i++)
  11475. {
  11476. node= configData.at(i).toElement();
  11477. if(node.attribute("name")=="column")
  11478. {
  11479. columnEdit->setText(node.attribute("value"));
  11480. }
  11481. else if(node.attribute("name")=="type")
  11482. {
  11483. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11484. }
  11485. else if(node.attribute("name")=="smoothing")
  11486. {
  11487. smoothingBox->setChecked(node.attribute("value")=="true");
  11488. }
  11489. else if(node.attribute("name")=="calibrationMeasuredLower")
  11490. {
  11491. measuredLowerEdit->setText(node.attribute("value"));
  11492. }
  11493. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11494. {
  11495. measuredUpperEdit->setText(node.attribute("value"));
  11496. }
  11497. else if(node.attribute("name")=="calibrationMappedLower")
  11498. {
  11499. mappedLowerEdit->setText(node.attribute("value"));
  11500. }
  11501. else if(node.attribute("name")=="calibrationMappedUpper")
  11502. {
  11503. mappedUpperEdit->setText(node.attribute("value"));
  11504. }
  11505. else if(node.attribute("name")=="calibrationClosedInterval")
  11506. {
  11507. closedBox->setChecked(node.attribute("value")=="true");
  11508. }
  11509. else if(node.attribute("name")=="calibrationSensitivity")
  11510. {
  11511. sensitivityEdit->setText(node.attribute("value"));
  11512. }
  11513. else if(node.attribute("name")=="hidden")
  11514. {
  11515. hideSeries->setChecked(node.attribute("value")=="true");
  11516. }
  11517. }
  11518. updateColumnName(columnEdit->text());
  11519. updateUnits(unitSelector->currentText());
  11520. updateSmoothingEnabled(smoothingBox->isChecked());
  11521. updateMeasuredLower(measuredLowerEdit->text());
  11522. updateMeasuredUpper(measuredUpperEdit->text());
  11523. updateMappedLower(mappedLowerEdit->text());
  11524. updateMappedUpper(mappedUpperEdit->text());
  11525. updateClosedInterval(closedBox->isChecked());
  11526. updateSensitivity(sensitivityEdit->text());
  11527. updateHidden(hideSeries->isChecked());
  11528. connect(columnEdit,SIGNAL(textChanged(QString)),
  11529. this,SLOT(updateColumnName(QString)));
  11530. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11531. this,SLOT(updateUnits(QString)));
  11532. connect(smoothingBox,SIGNAL(toggled(bool)),
  11533. this,SLOT(updateSmoothingEnabled(bool)));
  11534. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11535. this,SLOT(updateMeasuredLower(QString)));
  11536. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11537. this,SLOT(updateMappedLower(QString)));
  11538. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11539. this,SLOT(updateMeasuredUpper(QString)));
  11540. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11541. this,SLOT(updateMappedUpper(QString)));
  11542. connect(closedBox,SIGNAL(toggled(bool)),
  11543. this,SLOT(updateClosedInterval(bool)));
  11544. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11545. this,SLOT(updateSensitivity(QString)));
  11546. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11547. setLayout(layout);
  11548. }
  11549. /*:959*//*960:*/
  11550. #line 1038 "./dataqsdk.w"
  11551. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11552. {
  11553. updateAttribute("type",unit);
  11554. }
  11555. /*:960*//*961:*/
  11556. #line 1047 "./dataqsdk.w"
  11557. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11558. {
  11559. updateAttribute("calibrationMeasuredLower",value);
  11560. calibrator->setMeasuredLower(value.toDouble());
  11561. }
  11562. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11563. {
  11564. updateAttribute("calibrationMeasuredUpper",value);
  11565. calibrator->setMeasuredUpper(value.toDouble());
  11566. }
  11567. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11568. {
  11569. updateAttribute("calibrationMappedLower",value);
  11570. calibrator->setMappedLower(value.toDouble());
  11571. }
  11572. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11573. {
  11574. updateAttribute("calibrationMappedUpper",value);
  11575. calibrator->setMappedUpper(value.toDouble());
  11576. }
  11577. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11578. {
  11579. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11580. calibrator->setClosedRange(closed);
  11581. }
  11582. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11583. {
  11584. updateAttribute("smoothing",enabled?"true":"false");
  11585. }
  11586. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  11587. {
  11588. updateAttribute("calibrationSensitivity",value);
  11589. calibrator->setSensitivity(value.toDouble());
  11590. }
  11591. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  11592. {
  11593. updateAttribute("hidden",hidden?"true":"false");
  11594. }
  11595. /*:961*//*964:*/
  11596. #line 1136 "./dataqsdk.w"
  11597. void DataqSdkChannelConfWidget::startCalibration()
  11598. {
  11599. startButton->setEnabled(false);
  11600. stopButton->setEnabled(true);
  11601. resetButton->setEnabled(true);
  11602. calibrationDevice= new DataqSdkDevice(deviceID);
  11603. Channel*channel;
  11604. for(unsigned int i= 0;i<=channelOfInterest;i++)
  11605. {
  11606. channel= calibrationDevice->newChannel(Units::Unitless);
  11607. }
  11608. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  11609. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  11610. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  11611. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  11612. calibrationDevice->start();
  11613. }
  11614. void DataqSdkChannelConfWidget::stopCalibration()
  11615. {
  11616. startButton->setEnabled(true);
  11617. stopButton->setEnabled(false);
  11618. resetButton->setEnabled(false);
  11619. calibrationDevice->deleteLater();
  11620. /*966:*/
  11621. #line 1181 "./dataqsdk.w"
  11622. rmCount= 0;
  11623. cmCount= 0;
  11624. rmin= std::numeric_limits<double> ::max();
  11625. rmax= std::numeric_limits<double> ::min();
  11626. rmean= 0;
  11627. cmin= std::numeric_limits<double> ::max();
  11628. cmax= std::numeric_limits<double> ::min();
  11629. cmean= 0;
  11630. /*:966*/
  11631. #line 1161 "./dataqsdk.w"
  11632. }
  11633. /*:964*//*965:*/
  11634. #line 1172 "./dataqsdk.w"
  11635. void DataqSdkChannelConfWidget::resetCalibration()
  11636. {
  11637. /*966:*/
  11638. #line 1181 "./dataqsdk.w"
  11639. rmCount= 0;
  11640. cmCount= 0;
  11641. rmin= std::numeric_limits<double> ::max();
  11642. rmax= std::numeric_limits<double> ::min();
  11643. rmean= 0;
  11644. cmin= std::numeric_limits<double> ::max();
  11645. cmax= std::numeric_limits<double> ::min();
  11646. cmean= 0;
  11647. /*:966*/
  11648. #line 1175 "./dataqsdk.w"
  11649. }
  11650. /*:965*//*967:*/
  11651. #line 1195 "./dataqsdk.w"
  11652. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  11653. {
  11654. double nv= measure.temperature();
  11655. currentMeasurement->setText(QString("%1").arg(nv));
  11656. rmin= qMin(nv,rmin);
  11657. minimumMeasurement->setText(QString("%1").arg(rmin));
  11658. rmax= qMax(nv,rmax);
  11659. maximumMeasurement->setText(QString("%1").arg(rmax));
  11660. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  11661. rmCount++;
  11662. averageMeasurement->setText(QString("%1").arg(rmean));
  11663. }
  11664. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  11665. {
  11666. double nv= measure.temperature();
  11667. currentMapped->setText(QString("%1").arg(nv));
  11668. cmin= qMin(nv,cmin);
  11669. minimumMapped->setText(QString("%1").arg(cmin));
  11670. cmax= qMax(nv,cmax);
  11671. maximumMapped->setText(QString("%1").arg(cmax));
  11672. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  11673. cmCount++;
  11674. averageMapped->setText(QString("%1").arg(cmean));
  11675. }
  11676. /*:967*//*968:*/
  11677. #line 1224 "./dataqsdk.w"
  11678. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  11679. {
  11680. updateAttribute("column",value);
  11681. }
  11682. /*:968*/
  11683. #line 608 "./typica.w"
  11684. /*992:*/
  11685. #line 393 "./scales.w"
  11686. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  11687. const QModelIndex&index)
  11688. :BasicDeviceConfigurationWidget(model,index),
  11689. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  11690. flow(new FlowSelector),stop(new StopSelector)
  11691. {
  11692. QFormLayout*layout= new QFormLayout;
  11693. layout->addRow(tr("Port:"),port);
  11694. connect(port,SIGNAL(currentIndexChanged(QString)),
  11695. this,SLOT(updatePort(QString)));
  11696. connect(port,SIGNAL(editTextChanged(QString)),
  11697. this,SLOT(updatePort(QString)));
  11698. layout->addRow(tr("Baud:"),baud);
  11699. connect(baud,SIGNAL(currentIndexChanged(QString)),
  11700. this,SLOT(updateBaudRate(QString)));
  11701. layout->addRow(tr("Parity:"),parity);
  11702. connect(parity,SIGNAL(currentIndexChanged(int)),
  11703. this,SLOT(updateParity(int)));
  11704. layout->addRow(tr("Flow Control:"),flow);
  11705. connect(flow,SIGNAL(currentIndexChanged(int)),
  11706. this,SLOT(updateFlowControl(int)));
  11707. layout->addRow(tr("Stop Bits:"),stop);
  11708. connect(stop,SIGNAL(currentIndexChanged(int)),
  11709. this,SLOT(updateStopBits(int)));
  11710. /*755:*/
  11711. #line 15980 "./typica.w"
  11712. QDomElement referenceElement=
  11713. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11714. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11715. QDomElement node;
  11716. /*:755*/
  11717. #line 418 "./scales.w"
  11718. for(int i= 0;i<configData.size();i++)
  11719. {
  11720. node= configData.at(i).toElement();
  11721. if(node.attribute("name")=="port")
  11722. {
  11723. int j= port->findText(node.attribute("value"));
  11724. if(j>=0)
  11725. {
  11726. port->setCurrentIndex(j);
  11727. }
  11728. else
  11729. {
  11730. port->insertItem(0,node.attribute("value"));
  11731. port->setCurrentIndex(0);
  11732. }
  11733. }
  11734. else if(node.attribute("name")=="baudrate")
  11735. {
  11736. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  11737. }
  11738. else if(node.attribute("name")=="parity")
  11739. {
  11740. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  11741. }
  11742. else if(node.attribute("name")=="flowcontrol")
  11743. {
  11744. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  11745. }
  11746. else if(node.attribute("name")=="stopbits")
  11747. {
  11748. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  11749. }
  11750. }
  11751. updatePort(port->currentText());
  11752. updateBaudRate(baud->currentText());
  11753. updateParity(parity->currentIndex());
  11754. updateFlowControl(flow->currentIndex());
  11755. updateStopBits(stop->currentIndex());
  11756. setLayout(layout);
  11757. }
  11758. /*:992*//*993:*/
  11759. #line 462 "./scales.w"
  11760. void SerialScaleConfWidget::updatePort(const QString&newPort)
  11761. {
  11762. updateAttribute("port",newPort);
  11763. }
  11764. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  11765. {
  11766. updateAttribute("baudrate",rate);
  11767. }
  11768. void SerialScaleConfWidget::updateParity(int index)
  11769. {
  11770. updateAttribute("parity",parity->itemData(index).toString());
  11771. }
  11772. void SerialScaleConfWidget::updateFlowControl(int index)
  11773. {
  11774. updateAttribute("flowcontrol",flow->itemData(index).toString());
  11775. }
  11776. void SerialScaleConfWidget::updateStopBits(int index)
  11777. {
  11778. updateAttribute("stopbits",stop->itemData(index).toString());
  11779. }
  11780. /*:993*/
  11781. #line 609 "./typica.w"
  11782. /*1005:*/
  11783. #line 195 "./valueannotation.w"
  11784. void ValueAnnotation::newMeasurement(Measurement measure)
  11785. {
  11786. for(int i= 0;i<values.size();i++)
  11787. {
  11788. if(measure.temperature()> values.at(i)-tolerance&&
  11789. measure.temperature()<values.at(i)+tolerance)
  11790. {
  11791. if(i!=lastIndex)
  11792. {
  11793. lastIndex= i;
  11794. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  11795. }
  11796. }
  11797. }
  11798. }
  11799. /*:1005*//*1006:*/
  11800. #line 216 "./valueannotation.w"
  11801. void ValueAnnotation::annotate()
  11802. {
  11803. if(lastIndex> -1)
  11804. {
  11805. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  11806. }
  11807. }
  11808. /*:1006*//*1007:*/
  11809. #line 228 "./valueannotation.w"
  11810. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  11811. {
  11812. values.append(value);
  11813. annotations.append(annotation);
  11814. }
  11815. /*:1007*//*1008:*/
  11816. #line 237 "./valueannotation.w"
  11817. void ValueAnnotation::setAnnotationColumn(int column)
  11818. {
  11819. annotationColumn= column;
  11820. }
  11821. void ValueAnnotation::setTemperatureColumn(int column)
  11822. {
  11823. measurementColumn= column;
  11824. }
  11825. void ValueAnnotation::setTolerance(double epsilon)
  11826. {
  11827. tolerance= epsilon;
  11828. }
  11829. /*:1008*//*1009:*/
  11830. #line 255 "./valueannotation.w"
  11831. ValueAnnotation::ValueAnnotation():QObject(),
  11832. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  11833. {
  11834. }
  11835. /*:1009*/
  11836. #line 610 "./typica.w"
  11837. /*997:*/
  11838. #line 33 "./valueannotation.w"
  11839. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  11840. const QModelIndex&index)
  11841. :BasicDeviceConfigurationWidget(model,index),
  11842. tablemodel(new SaltModel(2))
  11843. {
  11844. QFormLayout*layout= new QFormLayout;
  11845. QLineEdit*source= new QLineEdit;
  11846. layout->addRow(tr("Source column name:"),source);
  11847. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  11848. noteOnStart->setChecked(true);
  11849. layout->addRow(noteOnStart);
  11850. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  11851. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  11852. QTableView*annotationTable= new QTableView;
  11853. annotationTable->setModel(tablemodel);
  11854. NumericDelegate*delegate= new NumericDelegate;
  11855. annotationTable->setItemDelegateForColumn(0,delegate);
  11856. layout->addRow(tr("Annotations for values:"),annotationTable);
  11857. /*755:*/
  11858. #line 15980 "./typica.w"
  11859. QDomElement referenceElement=
  11860. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11861. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11862. QDomElement node;
  11863. /*:755*/
  11864. #line 52 "./valueannotation.w"
  11865. for(int i= 0;i<configData.size();i++)
  11866. {
  11867. node= configData.at(i).toElement();
  11868. if(node.attribute("name")=="source")
  11869. {
  11870. source->setText(node.attribute("value"));
  11871. }
  11872. else if(node.attribute("name")=="emitOnStart")
  11873. {
  11874. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  11875. }
  11876. else if(node.attribute("name")=="measuredValues")
  11877. {
  11878. /*909:*/
  11879. #line 19047 "./typica.w"
  11880. QString data= node.attribute("value");
  11881. if(data.length()> 3)
  11882. {
  11883. data.chop(2);
  11884. data= data.remove(0,2);
  11885. }
  11886. QStringList itemList= data.split(",");
  11887. /*:909*/
  11888. #line 66 "./valueannotation.w"
  11889. int column= 0;
  11890. /*910:*/
  11891. #line 19059 "./typica.w"
  11892. for(int i= 0;i<itemList.size();i++)
  11893. {
  11894. tablemodel->setData(tablemodel->index(i,column),
  11895. QVariant(itemList.at(i).toDouble()),
  11896. Qt::DisplayRole);
  11897. }
  11898. /*:910*/
  11899. #line 68 "./valueannotation.w"
  11900. }
  11901. else if(node.attribute("name")=="annotations")
  11902. {
  11903. /*998:*/
  11904. #line 89 "./valueannotation.w"
  11905. QString data= node.attribute("value");
  11906. if(data.length()> 3)
  11907. {
  11908. data.chop(2);
  11909. data= data.remove(0,2);
  11910. }
  11911. QStringList itemList= data.split(",");
  11912. for(int i= 0;i<itemList.size();i++)
  11913. {
  11914. itemList[i]= itemList[i].simplified();
  11915. }
  11916. /*:998*/
  11917. #line 72 "./valueannotation.w"
  11918. int column= 1;
  11919. /*999:*/
  11920. #line 104 "./valueannotation.w"
  11921. for(int i= 0;i<itemList.size();i++)
  11922. {
  11923. tablemodel->setData(tablemodel->index(i,column),
  11924. QVariant(itemList.at(i)),
  11925. Qt::DisplayRole);
  11926. }
  11927. /*:999*/
  11928. #line 74 "./valueannotation.w"
  11929. }
  11930. }
  11931. updateSourceColumn(source->text());
  11932. updateStart(noteOnStart->isChecked());
  11933. updateAnnotations();
  11934. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11935. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  11936. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  11937. setLayout(layout);
  11938. }
  11939. /*:997*//*1000:*/
  11940. #line 115 "./valueannotation.w"
  11941. void ValueAnnotationConfWidget::updateAnnotations()
  11942. {
  11943. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11944. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11945. }
  11946. /*:1000*//*1001:*/
  11947. #line 125 "./valueannotation.w"
  11948. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  11949. {
  11950. updateAttribute("source",source);
  11951. }
  11952. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  11953. {
  11954. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  11955. }
  11956. /*:1001*/
  11957. #line 611 "./typica.w"
  11958. /*:4*//*829:*/
  11959. #line 60 "./advancedsettings.w"
  11960. /*827:*/
  11961. #line 26 "./advancedsettings.w"
  11962. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  11963. {
  11964. QSettings settings;
  11965. QFormLayout*layout= new QFormLayout;
  11966. QCheckBox*logDiagnostics= new QCheckBox;
  11967. logDiagnostics->setCheckState(
  11968. settings.value("settings/advanced/logging",false).toBool()?
  11969. Qt::Checked:Qt::Unchecked);
  11970. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  11971. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  11972. setLayout(layout);
  11973. }
  11974. /*:827*//*828:*/
  11975. #line 43 "./advancedsettings.w"
  11976. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  11977. {
  11978. QSettings settings;
  11979. settings.setValue("settings/advanced/logging",enabled);
  11980. if(enabled)
  11981. {
  11982. qInstallMsgHandler(messageFileOutput);
  11983. }
  11984. else
  11985. {
  11986. qInstallMsgHandler(0);
  11987. }
  11988. }
  11989. /*:828*/
  11990. #line 61 "./advancedsettings.w"
  11991. #line 17725 "./typica.w"
  11992. /*:829*//*876:*/
  11993. #line 639 "./unsupportedserial.w"
  11994. /*851:*/
  11995. #line 58 "./unsupportedserial.w"
  11996. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  11997. const QModelIndex&index)
  11998. :BasicDeviceConfigurationWidget(model,index),
  11999. deviceSettingsModel(new SaltModel(2)),
  12000. scriptEditor(new QTextEdit)
  12001. {
  12002. scriptEditor->setTabStopWidth(20);
  12003. QVBoxLayout*dummyLayout= new QVBoxLayout;
  12004. QTabWidget*central= new QTabWidget;
  12005. QWidget*deviceConfigurationWidget= new QWidget;
  12006. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  12007. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12008. deviceConfigurationLayout->addWidget(addChannelButton);
  12009. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12010. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  12011. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  12012. QTableView*deviceSettingsView= new QTableView;
  12013. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  12014. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  12015. deviceSettingsView->setModel(deviceSettingsModel);
  12016. deviceConfigurationLayout->addWidget(deviceSettingsView);
  12017. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  12018. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  12019. central->addTab(scriptEditor,tr("Script"));
  12020. dummyLayout->addWidget(central);
  12021. /*755:*/
  12022. #line 15980 "./typica.w"
  12023. QDomElement referenceElement=
  12024. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12025. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12026. QDomElement node;
  12027. /*:755*/
  12028. #line 86 "./unsupportedserial.w"
  12029. for(int i= 0;i<configData.size();i++)
  12030. {
  12031. node= configData.at(i).toElement();
  12032. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12033. {
  12034. int column= 0;
  12035. if(node.attribute("name")=="values")
  12036. {
  12037. column= 1;
  12038. }
  12039. QString data= node.attribute("value");
  12040. if(data.length()> 3)
  12041. {
  12042. data.chop(2);
  12043. data= data.remove(0,2);
  12044. }
  12045. QStringList keyList= data.split(", ");
  12046. for(int j= 0;j<keyList.size();j++)
  12047. {
  12048. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  12049. QVariant(keyList.at(j)),
  12050. Qt::EditRole);
  12051. }
  12052. }
  12053. else if(node.attribute("name")=="script")
  12054. {
  12055. scriptEditor->setPlainText(node.attribute("value"));
  12056. }
  12057. }
  12058. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  12059. this,SLOT(updateConfiguration()));
  12060. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  12061. setLayout(dummyLayout);
  12062. }
  12063. /*:851*//*852:*/
  12064. #line 131 "./unsupportedserial.w"
  12065. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  12066. {
  12067. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  12068. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  12069. }
  12070. /*:852*//*853:*/
  12071. #line 144 "./unsupportedserial.w"
  12072. void UnsupportedSerialDeviceConfWidget::saveScript()
  12073. {
  12074. updateAttribute("script",scriptEditor->toPlainText());
  12075. }
  12076. /*:853*//*854:*/
  12077. #line 155 "./unsupportedserial.w"
  12078. void UnsupportedSerialDeviceConfWidget::addChannel()
  12079. {
  12080. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  12081. }
  12082. /*:854*//*856:*/
  12083. #line 183 "./unsupportedserial.w"
  12084. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  12085. const QModelIndex&index)
  12086. :BasicDeviceConfigurationWidget(model,index),
  12087. channelSettingsModel(new SaltModel(2))
  12088. {
  12089. QFormLayout*layout= new QFormLayout;
  12090. QLineEdit*columnName= new QLineEdit;
  12091. layout->addRow(tr("Column Name:"),columnName);
  12092. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  12093. layout->addRow(hideSeries);
  12094. QTableView*channelSettings= new QTableView;
  12095. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  12096. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  12097. channelSettings->setModel(channelSettingsModel);
  12098. layout->addRow(channelSettings);
  12099. setLayout(layout);
  12100. /*755:*/
  12101. #line 15980 "./typica.w"
  12102. QDomElement referenceElement=
  12103. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12104. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12105. QDomElement node;
  12106. /*:755*/
  12107. #line 200 "./unsupportedserial.w"
  12108. for(int i= 0;i<configData.size();i++)
  12109. {
  12110. node= configData.at(i).toElement();
  12111. if(node.attribute("name")=="columnname")
  12112. {
  12113. columnName->setText(node.attribute("value"));
  12114. }
  12115. else if(node.attribute("name")=="hidden")
  12116. {
  12117. hideSeries->setChecked(node.attribute("value")=="true");
  12118. }
  12119. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12120. {
  12121. int column= 0;
  12122. if(node.attribute("name")=="values")
  12123. {
  12124. column= 1;
  12125. }
  12126. QString data= node.attribute("value");
  12127. if(data.length()> 3)
  12128. {
  12129. data.chop(2);
  12130. data= data.remove(0,2);
  12131. }
  12132. QStringList keyList= data.split(", ");
  12133. for(int j= 0;j<keyList.size();j++)
  12134. {
  12135. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  12136. QVariant(keyList.at(j)),
  12137. Qt::EditRole);
  12138. }
  12139. }
  12140. }
  12141. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12142. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12143. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  12144. this,SLOT(updateConfiguration()));
  12145. }
  12146. /*:856*//*857:*/
  12147. #line 244 "./unsupportedserial.w"
  12148. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  12149. {
  12150. updateAttribute("columnname",value);
  12151. }
  12152. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  12153. {
  12154. updateAttribute("hidden",hidden?"true":"false");
  12155. }
  12156. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  12157. {
  12158. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  12159. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  12160. }
  12161. /*:857*/
  12162. #line 640 "./unsupportedserial.w"
  12163. /*864:*/
  12164. #line 371 "./unsupportedserial.w"
  12165. void JavaScriptDevice::start()
  12166. {
  12167. QScriptValue object= scriptengine->newQObject(this);
  12168. /*865:*/
  12169. #line 390 "./unsupportedserial.w"
  12170. QScriptValue settingsObject= scriptengine->newObject();
  12171. QVariantMap::const_iterator i= deviceSettings.constBegin();
  12172. while(i!=deviceSettings.constEnd())
  12173. {
  12174. settingsObject.setProperty(i.key(),i.value().toString());
  12175. i++;
  12176. }
  12177. object.setProperty("settings",settingsObject);
  12178. /*:865*/
  12179. #line 375 "./unsupportedserial.w"
  12180. /*866:*/
  12181. #line 405 "./unsupportedserial.w"
  12182. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  12183. for(int i= 0;i<channelCount();i++)
  12184. {
  12185. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  12186. QScriptValue channelSettingsObject= scriptengine->newObject();
  12187. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  12188. while(j!=channelSettings.at(i).constEnd())
  12189. {
  12190. channelSettingsObject.setProperty(j.key(),j.value().toString());
  12191. j++;
  12192. }
  12193. channelObject.setProperty("settings",channelSettingsObject);
  12194. channelsArray.setProperty(i,channelObject);
  12195. }
  12196. object.setProperty("channels",channelsArray);
  12197. /*:866*/
  12198. #line 376 "./unsupportedserial.w"
  12199. QScriptContext*context= scriptengine->currentContext();
  12200. QScriptValue oldThis= context->thisObject();
  12201. context->setThisObject(object);
  12202. QScriptValue result= scriptengine->evaluate(deviceScript);
  12203. QScriptEngine*engine= scriptengine;
  12204. /*182:*/
  12205. #line 4291 "./typica.w"
  12206. if(engine->hasUncaughtException())
  12207. {
  12208. int line= engine->uncaughtExceptionLineNumber();
  12209. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  12210. result.toString();
  12211. QString trace;
  12212. foreach(trace,engine->uncaughtExceptionBacktrace())
  12213. {
  12214. qDebug()<<trace;
  12215. }
  12216. }
  12217. /*:182*/
  12218. #line 382 "./unsupportedserial.w"
  12219. context->setThisObject(oldThis);
  12220. }
  12221. /*:864*//*869:*/
  12222. #line 446 "./unsupportedserial.w"
  12223. void JavaScriptDevice::stop()
  12224. {
  12225. emit deviceStopRequested();
  12226. }
  12227. /*:869*//*870:*/
  12228. #line 459 "./unsupportedserial.w"
  12229. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  12230. QScriptEngine*engine):
  12231. QObject(NULL),scriptengine(engine)
  12232. {
  12233. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  12234. QDomElement deviceReferenceElement=
  12235. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12236. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  12237. QDomElement node;
  12238. QStringList deviceKeys;
  12239. QStringList deviceValues;
  12240. for(int i= 0;i<deviceConfigData.size();i++)
  12241. {
  12242. node= deviceConfigData.at(i).toElement();
  12243. if(node.attribute("name")=="keys")
  12244. {
  12245. QString data= node.attribute("value");
  12246. if(data.length()> 3)
  12247. {
  12248. data.chop(2);
  12249. data= data.remove(0,2);
  12250. }
  12251. deviceKeys= data.split(", ");
  12252. }
  12253. else if(node.attribute("name")=="values")
  12254. {
  12255. QString data= node.attribute("value");
  12256. if(data.length()> 3)
  12257. {
  12258. data.chop(2);
  12259. data= data.remove(0,2);
  12260. }
  12261. deviceValues= data.split(", ");
  12262. }
  12263. else if(node.attribute("name")=="script")
  12264. {
  12265. deviceScript= node.attribute("value");
  12266. }
  12267. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  12268. }
  12269. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  12270. {
  12271. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  12272. }
  12273. if(model->hasChildren(index))
  12274. {
  12275. for(int i= 0;i<model->rowCount(index);i++)
  12276. {
  12277. QModelIndex channelIndex= model->index(i,0,index);
  12278. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  12279. channelList.append(new Channel);
  12280. QDomElement channelReferenceElement=
  12281. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12282. QDomNodeList channelConfigData=
  12283. channelReferenceElement.elementsByTagName("attribute");
  12284. QStringList channelKeys;
  12285. QStringList channelValues;
  12286. for(int j= 0;j<channelConfigData.size();j++)
  12287. {
  12288. node= channelConfigData.at(j).toElement();
  12289. if(node.attribute("name")=="keys")
  12290. {
  12291. QString data= node.attribute("value");
  12292. if(data.length()> 3)
  12293. {
  12294. data.chop(2);
  12295. data= data.remove(0,2);
  12296. }
  12297. channelKeys= data.split(", ");
  12298. }
  12299. else if(node.attribute("name")=="values")
  12300. {
  12301. QString data= node.attribute("value");
  12302. if(data.length()> 3)
  12303. {
  12304. data.chop(2);
  12305. data= data.remove(0,2);
  12306. }
  12307. channelValues= data.split(", ");
  12308. }
  12309. else if(node.attribute("name")=="hidden")
  12310. {
  12311. hiddenState.append(node.attribute("value")=="true");
  12312. }
  12313. else if(node.attribute("name")=="columnname")
  12314. {
  12315. columnNames.append(node.attribute("value"));
  12316. }
  12317. }
  12318. QVariantMap cs;
  12319. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  12320. {
  12321. cs.insert(channelKeys[j],channelValues[j]);
  12322. }
  12323. channelSettings.append(cs);
  12324. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  12325. channelUnits.append(Units::Fahrenheit);
  12326. }
  12327. }
  12328. }
  12329. /*:870*//*871:*/
  12330. #line 564 "./unsupportedserial.w"
  12331. int JavaScriptDevice::channelCount()
  12332. {
  12333. return channelList.length();
  12334. }
  12335. Channel*JavaScriptDevice::getChannel(int channel)
  12336. {
  12337. return channelList.at(channel);
  12338. }
  12339. bool JavaScriptDevice::isChannelHidden(int channel)
  12340. {
  12341. return hiddenState.at(channel);
  12342. }
  12343. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  12344. {
  12345. return channelUnits.at(channel);
  12346. }
  12347. QString JavaScriptDevice::channelColumnName(int channel)
  12348. {
  12349. if(channel>=0&&channel<columnNames.length())
  12350. {
  12351. return columnNames.at(channel);
  12352. }
  12353. return QString();
  12354. }
  12355. QString JavaScriptDevice::channelIndicatorText(int channel)
  12356. {
  12357. return indicatorTexts.at(channel);
  12358. }
  12359. /*:871*//*872:*/
  12360. #line 601 "./unsupportedserial.w"
  12361. void JavaScriptDevice::setTemperatureColumn(int tcol)
  12362. {
  12363. annotationTemperatureColumn= tcol;
  12364. }
  12365. void JavaScriptDevice::setAnnotationColumn(int ncol)
  12366. {
  12367. annotationNoteColumn= ncol;
  12368. }
  12369. /*:872*/
  12370. #line 641 "./unsupportedserial.w"
  12371. /*:876*//*902:*/
  12372. #line 444 "./phidgets.w"
  12373. /*886:*/
  12374. #line 31 "./phidgets.w"
  12375. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  12376. const QModelIndex&index)
  12377. :BasicDeviceConfigurationWidget(model,index)
  12378. {
  12379. QFormLayout*layout= new QFormLayout;
  12380. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12381. QSpinBox*sampleRate= new QSpinBox;
  12382. sampleRate->setMinimum(40);
  12383. sampleRate->setMaximum(600);
  12384. sampleRate->setSingleStep(40);
  12385. sampleRate->setValue(360);
  12386. /*755:*/
  12387. #line 15980 "./typica.w"
  12388. QDomElement referenceElement=
  12389. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12390. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12391. QDomElement node;
  12392. /*:755*/
  12393. #line 44 "./phidgets.w"
  12394. for(int i= 0;i<configData.size();i++)
  12395. {
  12396. node= configData.at(i).toElement();
  12397. if(node.attribute("name")=="sampleRate")
  12398. {
  12399. sampleRate->setValue(node.attribute("value").toInt());
  12400. }
  12401. }
  12402. updateRate(sampleRate->value());
  12403. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  12404. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12405. layout->addRow(addChannelButton);
  12406. layout->addRow(tr("Sample rate:"),sampleRate);
  12407. setLayout(layout);
  12408. }
  12409. /*:886*//*887:*/
  12410. #line 66 "./phidgets.w"
  12411. void PhidgetsTemperatureSensorConfWidget::addChannel()
  12412. {
  12413. insertChildNode(tr("Channel"),"phidgets1048channel");
  12414. }
  12415. /*:887*//*888:*/
  12416. #line 74 "./phidgets.w"
  12417. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  12418. {
  12419. updateAttribute("sampleRate",QString("%1").arg(ms));
  12420. }
  12421. /*:888*//*890:*/
  12422. #line 103 "./phidgets.w"
  12423. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  12424. DeviceTreeModel*model,const QModelIndex&index)
  12425. :BasicDeviceConfigurationWidget(model,index),
  12426. tcType(new QComboBox)
  12427. {
  12428. QFormLayout*layout= new QFormLayout;
  12429. QLineEdit*columnName= new QLineEdit;
  12430. layout->addRow(tr("Column Name:"),columnName);
  12431. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  12432. layout->addRow(hideSeries);
  12433. layout->addRow(tr("Thermocouple Type:"),tcType);
  12434. tcType->addItem("Type K","1");
  12435. tcType->addItem("Type J","2");
  12436. tcType->addItem("Type E","3");
  12437. tcType->addItem("Type T","4");
  12438. QSpinBox*channel= new QSpinBox;
  12439. layout->addRow(tr("Channel:"),channel);
  12440. channel->setMinimum(0);
  12441. channel->setMaximum(3);
  12442. setLayout(layout);
  12443. /*755:*/
  12444. #line 15980 "./typica.w"
  12445. QDomElement referenceElement=
  12446. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12447. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12448. QDomElement node;
  12449. /*:755*/
  12450. #line 124 "./phidgets.w"
  12451. for(int i= 0;i<configData.size();i++)
  12452. {
  12453. node= configData.at(i).toElement();
  12454. if(node.attribute("name")=="columnname")
  12455. {
  12456. columnName->setText(node.attribute("value"));
  12457. }
  12458. else if(node.attribute("name")=="hidden")
  12459. {
  12460. hideSeries->setChecked(node.attribute("value")=="true");
  12461. }
  12462. else if(node.attribute("name")=="tctype")
  12463. {
  12464. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  12465. }
  12466. else if(node.attribute("name")=="channel")
  12467. {
  12468. channel->setValue(node.attribute("value").toInt());
  12469. }
  12470. }
  12471. updateColumnName(columnName->text());
  12472. updateHidden(hideSeries->isChecked());
  12473. updateTC(tcType->currentIndex());
  12474. updateChannel(channel->value());
  12475. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12476. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12477. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  12478. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  12479. }
  12480. /*:890*//*891:*/
  12481. #line 157 "./phidgets.w"
  12482. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  12483. {
  12484. updateAttribute("columnname",value);
  12485. }
  12486. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  12487. {
  12488. updateAttribute("hidden",hidden?"true":"false");
  12489. }
  12490. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  12491. {
  12492. updateAttribute("tctype",tcType->itemData(index).toString());
  12493. }
  12494. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  12495. {
  12496. updateAttribute("channel",QString("%1").arg(channel));
  12497. }
  12498. /*:891*//*895:*/
  12499. #line 246 "./phidgets.w"
  12500. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  12501. :QObject(NULL),driver("phidget21"),device(NULL)
  12502. {
  12503. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  12504. QDomElement deviceReferenceElement=
  12505. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12506. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  12507. QDomElement node;
  12508. for(int i= 0;i<deviceConfigData.size();i++)
  12509. {
  12510. node= deviceConfigData.at(i).toElement();
  12511. if(node.attribute("name")=="sampleRate")
  12512. {
  12513. sampleTimer.setInterval(node.attribute("value").toInt());
  12514. }
  12515. }
  12516. if(model->hasChildren(index))
  12517. {
  12518. for(int i= 0;i<model->rowCount(index);i++)
  12519. {
  12520. QModelIndex channelIndex= model->index(i,0,index);
  12521. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  12522. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12523. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  12524. for(int j= 0;j<channelConfigData.size();j++)
  12525. {
  12526. node= channelConfigData.at(j).toElement();
  12527. if(node.attribute("name")=="channel")
  12528. {
  12529. int channelID= node.attribute("value").toInt();
  12530. channelIndices.append(channelID);
  12531. Channel*channel= new Channel;
  12532. channelList.append(channel);
  12533. channelMap.insert(channelID,channel);
  12534. }
  12535. else if(node.attribute("name")=="hidden")
  12536. {
  12537. hiddenState.append(node.attribute("value")=="true");
  12538. }
  12539. else if(node.attribute("name")=="columnname")
  12540. {
  12541. columnNames.append(node.attribute("value"));
  12542. }
  12543. else if(node.attribute("name")=="tctype")
  12544. {
  12545. tctypes.append(node.attribute("value").toInt());
  12546. }
  12547. }
  12548. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  12549. }
  12550. }
  12551. }
  12552. /*:895*//*896:*/
  12553. #line 306 "./phidgets.w"
  12554. int PhidgetsTemperatureSensor::channelCount()
  12555. {
  12556. return channelList.length();
  12557. }
  12558. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  12559. {
  12560. return channelList.at(channel);
  12561. }
  12562. /*:896*//*897:*/
  12563. #line 319 "./phidgets.w"
  12564. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  12565. {
  12566. return hiddenState.at(channel);
  12567. }
  12568. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  12569. {
  12570. if(channel>=0&&channel<columnNames.length())
  12571. {
  12572. return columnNames.at(channel);
  12573. }
  12574. return QString();
  12575. }
  12576. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  12577. {
  12578. if(channel>=0&&channel<indicatorTexts.length())
  12579. {
  12580. return indicatorTexts.at(channel);
  12581. }
  12582. return QString();
  12583. }
  12584. /*:897*//*899:*/
  12585. #line 371 "./phidgets.w"
  12586. void PhidgetsTemperatureSensor::start()
  12587. {
  12588. if(!driver.load())
  12589. {
  12590. driver.setFileName("Phidget21.framework/Phidget21");
  12591. if(!driver.load())
  12592. {
  12593. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  12594. tr("Failed to find phidget21. Please install it."));
  12595. return;
  12596. }
  12597. }
  12598. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  12599. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  12600. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  12601. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  12602. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  12603. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  12604. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  12605. {
  12606. QMessageBox::critical(NULL,tr("Typica: Link error"),
  12607. tr("Failed to link a required symbol in phidget21."));
  12608. return;
  12609. }
  12610. createDevice(&device);
  12611. openDevice(device,-1);
  12612. int error;
  12613. if(error= waitForOpen(device,10000))
  12614. {
  12615. closeDevice(device);
  12616. deleteDevice(device);
  12617. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  12618. tr("CPhidget_waitForAttachment returns error %n",0,error));
  12619. return;
  12620. }
  12621. for(int i= 0;i<channelIndices.length();i++)
  12622. {
  12623. setTCType(device,channelIndices.at(i),tctypes.at(i));
  12624. }
  12625. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  12626. sampleTimer.start();
  12627. }
  12628. /*:899*//*900:*/
  12629. #line 418 "./phidgets.w"
  12630. void PhidgetsTemperatureSensor::getMeasurements()
  12631. {
  12632. double value= 0.0;
  12633. QTime time= QTime::currentTime();
  12634. foreach(int i,channelIndices)
  12635. {
  12636. getTemperature(device,i,&value);
  12637. Measurement measure(value*9.0/5.0+32.0,time);
  12638. channelMap[i]->input(measure);
  12639. }
  12640. }
  12641. /*:900*//*901:*/
  12642. #line 433 "./phidgets.w"
  12643. void PhidgetsTemperatureSensor::stop()
  12644. {
  12645. sampleTimer.stop();
  12646. closeDevice(device);
  12647. deleteDevice(device);
  12648. driver.unload();
  12649. }
  12650. /*:901*/
  12651. #line 445 "./phidgets.w"
  12652. /*:902*//*930:*/
  12653. #line 265 "./rate.w"
  12654. /*926:*/
  12655. #line 191 "./rate.w"
  12656. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  12657. :BasicDeviceConfigurationWidget(model,index)
  12658. {
  12659. QFormLayout*layout= new QFormLayout;
  12660. QLineEdit*column= new QLineEdit;
  12661. layout->addRow(tr("Primary series column name:"),column);
  12662. QSpinBox*cacheTime= new QSpinBox;
  12663. cacheTime->setMinimum(0);
  12664. cacheTime->setMaximum(300);
  12665. layout->addRow(tr("Cache time:"),cacheTime);
  12666. QSpinBox*scaleTime= new QSpinBox;
  12667. scaleTime->setMinimum(1);
  12668. scaleTime->setMaximum(300);
  12669. layout->addRow(tr("Scale time:"),scaleTime);
  12670. /*755:*/
  12671. #line 15980 "./typica.w"
  12672. QDomElement referenceElement=
  12673. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12674. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12675. QDomElement node;
  12676. /*:755*/
  12677. #line 206 "./rate.w"
  12678. for(int i= 0;i<configData.size();i++)
  12679. {
  12680. node= configData.at(i).toElement();
  12681. if(node.attribute("name")=="column")
  12682. {
  12683. column->setText(node.attribute("value"));
  12684. }
  12685. else if(node.attribute("name")=="cache")
  12686. {
  12687. cacheTime->setValue(node.attribute("value").toInt());
  12688. }
  12689. else if(node.attribute("name")=="scale")
  12690. {
  12691. scaleTime->setValue(node.attribute("value").toInt());
  12692. }
  12693. }
  12694. updateColumn(column->text());
  12695. updateCacheTime(cacheTime->text());
  12696. updateScaleTime(scaleTime->text());
  12697. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  12698. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  12699. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  12700. setLayout(layout);
  12701. }
  12702. /*:926*//*927:*/
  12703. #line 235 "./rate.w"
  12704. void RateOfChangeConfWidget::updateColumn(const QString&column)
  12705. {
  12706. updateAttribute("column",column);
  12707. }
  12708. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  12709. {
  12710. updateAttribute("cache",seconds);
  12711. }
  12712. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  12713. {
  12714. updateAttribute("scale",seconds);
  12715. }
  12716. /*:927*/
  12717. #line 266 "./rate.w"
  12718. #line 19182 "./typica.w"
  12719. #line 1 "./dataqsdk.w"
  12720. /*:930*/
  12721. #line 529 "./typica.w"
  12722. /*8:*/
  12723. #line 671 "./typica.w"
  12724. template<class TYPE> TYPE getself(QScriptContext*context)
  12725. {
  12726. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  12727. return self;
  12728. }
  12729. template<> QTime getself(QScriptContext*context)
  12730. {
  12731. QTime self= context->thisObject().toVariant().toTime();
  12732. return self;
  12733. }
  12734. template<> QByteArray getself(QScriptContext*context)
  12735. {
  12736. QByteArray self= context->thisObject().toVariant().toByteArray();
  12737. return self;
  12738. }
  12739. template<> SqlQueryConnection*getself(QScriptContext*context)
  12740. {
  12741. SqlQueryConnection*self=
  12742. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  12743. return self;
  12744. }
  12745. template<> QXmlQuery*getself(QScriptContext*context)
  12746. {
  12747. QXmlQuery*self=
  12748. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  12749. return self;
  12750. }
  12751. template<> QXmlStreamWriter*getself(QScriptContext*context)
  12752. {
  12753. QXmlStreamWriter*self=
  12754. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  12755. return self;
  12756. }
  12757. template<> QXmlStreamReader*getself(QScriptContext*context)
  12758. {
  12759. QXmlStreamReader*self=
  12760. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  12761. return self;
  12762. }
  12763. /*:8*//*9:*/
  12764. #line 722 "./typica.w"
  12765. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  12766. {
  12767. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  12768. return argument;
  12769. }
  12770. template<> QString argument(int arg,QScriptContext*context)
  12771. {
  12772. return context->argument(arg).toString();
  12773. }
  12774. template<> QVariant argument(int arg,QScriptContext*context)
  12775. {
  12776. return context->argument(arg).toVariant();
  12777. }
  12778. template<> int argument(int arg,QScriptContext*context)
  12779. {
  12780. return context->argument(arg).toInt32();
  12781. }
  12782. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  12783. {
  12784. return(SqlQueryConnection*)
  12785. qscriptvalue_cast<void*> (context->argument(arg));
  12786. }
  12787. template<> QModelIndex argument(int arg,QScriptContext*context)
  12788. {
  12789. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  12790. }
  12791. template<> double argument(int arg,QScriptContext*context)
  12792. {
  12793. return(double)(context->argument(arg).toNumber());
  12794. }
  12795. template<> Units::Unit argument(int arg,QScriptContext*context)
  12796. {
  12797. return(Units::Unit)(context->argument(arg).toInt32());
  12798. }
  12799. template<> QByteArray argument(int arg,QScriptContext*context)
  12800. {
  12801. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  12802. }
  12803. /*:9*//*13:*/
  12804. #line 814 "./typica.w"
  12805. void setQObjectProperties(QScriptValue,QScriptEngine*)
  12806. {
  12807. }
  12808. /*:13*//*15:*/
  12809. #line 828 "./typica.w"
  12810. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  12811. {
  12812. }
  12813. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  12814. {
  12815. }
  12816. /*:15*//*18:*/
  12817. #line 867 "./typica.w"
  12818. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  12819. {
  12820. QScriptValue object= engine->newQObject(new QWidget);
  12821. setQWidgetProperties(object,engine);
  12822. return object;
  12823. }
  12824. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  12825. {
  12826. setQObjectProperties(value,engine);
  12827. setQPaintDeviceProperties(value,engine);
  12828. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  12829. value.setProperty("activateWindow",
  12830. engine->newFunction(QWidget_activateWindow));
  12831. }
  12832. /*:18*//*19:*/
  12833. #line 889 "./typica.w"
  12834. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  12835. {
  12836. if(context->argumentCount()==1)
  12837. {
  12838. QWidget*self= getself<QWidget*> (context);
  12839. QLayout*layout= argument<QLayout*> (0,context);
  12840. if(layout)
  12841. {
  12842. self->setLayout(layout);
  12843. }
  12844. else
  12845. {
  12846. context->throwError("Incorrect argument type passed to "
  12847. "QWidget::setLayout(). This method requires "
  12848. "a QLayout.");
  12849. }
  12850. }
  12851. else
  12852. {
  12853. context->throwError("Incorrect number of arguments passed to "
  12854. "QWidget::setLayout(). This method takes one "
  12855. "QLayout as an argument.");
  12856. }
  12857. return QScriptValue();
  12858. }
  12859. QScriptValue QWidget_activateWindow(QScriptContext*context,
  12860. QScriptEngine*)
  12861. {
  12862. QWidget*self= getself<QWidget*> (context);
  12863. self->activateWindow();
  12864. return QScriptValue();
  12865. }
  12866. /*:19*//*21:*/
  12867. #line 971 "./typica.w"
  12868. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  12869. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  12870. {
  12871. }
  12872. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  12873. {
  12874. QSettings settings;
  12875. settings.beginGroup(key);
  12876. settings.setValue("pos",pos());
  12877. settings.setValue("size",size());
  12878. settings.endGroup();
  12879. }
  12880. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  12881. {
  12882. QSettings settings;
  12883. settings.beginGroup(key);
  12884. if(settings.contains("size"))
  12885. {
  12886. resize(settings.value("size").toSize());
  12887. }
  12888. if(settings.contains("pos"))
  12889. {
  12890. move(settings.value("pos").toPoint());
  12891. }
  12892. settings.endGroup();
  12893. }
  12894. void ScriptQMainWindow::displayStatus(const QString&message)
  12895. {
  12896. statusBar()->showMessage(message);
  12897. }
  12898. void ScriptQMainWindow::showEvent(QShowEvent*event)
  12899. {
  12900. if(!event->spontaneous())
  12901. {
  12902. /*26:*/
  12903. #line 1083 "./typica.w"
  12904. QSettings settings;
  12905. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  12906. toByteArray());
  12907. /*:26*/
  12908. #line 1011 "./typica.w"
  12909. event->accept();
  12910. }
  12911. else
  12912. {
  12913. event->ignore();
  12914. }
  12915. }
  12916. void ScriptQMainWindow::show()
  12917. {
  12918. QMainWindow::show();
  12919. }
  12920. /*:21*//*22:*/
  12921. #line 1032 "./typica.w"
  12922. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  12923. {
  12924. if(isWindowModified()){
  12925. /*23:*/
  12926. #line 1046 "./typica.w"
  12927. QMessageBox::StandardButton result;
  12928. result= QMessageBox::warning(this,"Typica",closePrompt(),
  12929. QMessageBox::Ok|QMessageBox::Cancel);
  12930. if(result==QMessageBox::Cancel)
  12931. {
  12932. event->ignore();
  12933. return;
  12934. }
  12935. /*:23*/
  12936. #line 1036 "./typica.w"
  12937. }
  12938. emit aboutToClose();
  12939. /*25:*/
  12940. #line 1077 "./typica.w"
  12941. QSettings settings;
  12942. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  12943. /*:25*/
  12944. #line 1039 "./typica.w"
  12945. event->accept();
  12946. }
  12947. /*:22*//*24:*/
  12948. #line 1058 "./typica.w"
  12949. QString ScriptQMainWindow::closePrompt()
  12950. {
  12951. return cprompt;
  12952. }
  12953. void ScriptQMainWindow::setClosePrompt(QString prompt)
  12954. {
  12955. cprompt= prompt;
  12956. }
  12957. /*:24*//*29:*/
  12958. #line 1111 "./typica.w"
  12959. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  12960. {
  12961. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  12962. setQMainWindowProperties(object,engine);
  12963. return object;
  12964. }
  12965. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  12966. {
  12967. setQWidgetProperties(value,engine);
  12968. value.setProperty("setCentralWidget",
  12969. engine->newFunction(QMainWindow_setCentralWidget));
  12970. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  12971. }
  12972. /*:29*//*30:*/
  12973. #line 1133 "./typica.w"
  12974. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  12975. QScriptEngine*)
  12976. {
  12977. if(context->argumentCount()==1)
  12978. {
  12979. QMainWindow*self= getself<QMainWindow*> (context);
  12980. QWidget*widget= argument<QWidget*> (0,context);
  12981. if(widget)
  12982. {
  12983. self->setCentralWidget(widget);
  12984. }
  12985. else
  12986. {
  12987. context->throwError("Incorrect argument type passed to "
  12988. "QMainWindow::setCentralWidget(). This "
  12989. "method requires a QWidget.");
  12990. }
  12991. }
  12992. else
  12993. {
  12994. context->throwError("Incorrect number of arguments passed to "
  12995. "QMainWindow::setCentralWidget(). This method "
  12996. "takes one QWidget as an argument.");
  12997. }
  12998. return QScriptValue();
  12999. }
  13000. /*:30*//*31:*/
  13001. #line 1167 "./typica.w"
  13002. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  13003. {
  13004. QScriptValue object;
  13005. if(context->argumentCount()==0)
  13006. {
  13007. QMainWindow*self= getself<QMainWindow*> (context);
  13008. QMenuBar*bar= self->menuBar();
  13009. object= engine->newQObject(bar);
  13010. setQMenuBarProperties(object,engine);
  13011. }
  13012. else
  13013. {
  13014. context->throwError("Incorrect number of arguments passed to "
  13015. "QMainWindow::menuBar(). This method takes no "
  13016. "arguments.");
  13017. }
  13018. return object;
  13019. }
  13020. /*:31*//*33:*/
  13021. #line 1197 "./typica.w"
  13022. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  13023. {
  13024. setQWidgetProperties(value,engine);
  13025. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  13026. }
  13027. /*:33*//*34:*/
  13028. #line 1212 "./typica.w"
  13029. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  13030. {
  13031. QScriptValue object;
  13032. if(context->argumentCount()==1)
  13033. {
  13034. QMenuBar*self= getself<QMenuBar*> (context);
  13035. QString title= argument<QString> (0,context);
  13036. object= engine->newQObject(self->addMenu(title));
  13037. setQMenuProperties(object,engine);
  13038. }
  13039. else
  13040. {
  13041. context->throwError("Incorrect number of arguments passed to "
  13042. "QMenuBar::addMenu(). This method takes one "
  13043. "string as an argument.");
  13044. }
  13045. return object;
  13046. }
  13047. /*:34*//*36:*/
  13048. #line 1242 "./typica.w"
  13049. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  13050. {
  13051. setQWidgetProperties(value,engine);
  13052. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  13053. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  13054. }
  13055. /*:36*//*37:*/
  13056. #line 1252 "./typica.w"
  13057. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  13058. {
  13059. if(context->argumentCount()==1)
  13060. {
  13061. QMenu*self= getself<QMenu*> (context);
  13062. QAction*action= argument<QAction*> (0,context);
  13063. if(action)
  13064. {
  13065. self->addAction(action);
  13066. }
  13067. else
  13068. {
  13069. context->throwError("Incorrect argument type passed to "
  13070. "QMenu::addAction(). This method requires a "
  13071. "QAction.");
  13072. }
  13073. }
  13074. else
  13075. {
  13076. context->throwError("Incorrect number of arguments passed to "
  13077. "QMenu::addAction(). This method takes one "
  13078. "QAction as an argument.");
  13079. }
  13080. return QScriptValue();
  13081. }
  13082. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  13083. {
  13084. if(context->argumentCount()==0)
  13085. {
  13086. QMenu*self= getself<QMenu*> (context);
  13087. self->addSeparator();
  13088. }
  13089. else
  13090. {
  13091. context->throwError("Incorrect number of arguments passed to "
  13092. "QMenu::addSeparator(). This method takes no "
  13093. "arguments.");
  13094. }
  13095. return QScriptValue();
  13096. }
  13097. /*:37*//*40:*/
  13098. #line 1314 "./typica.w"
  13099. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  13100. {
  13101. QScriptValue object= engine->newQObject(new QFrame);
  13102. setQFrameProperties(object,engine);
  13103. return object;
  13104. }
  13105. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  13106. {
  13107. setQWidgetProperties(value,engine);
  13108. }
  13109. /*:40*//*43:*/
  13110. #line 1348 "./typica.w"
  13111. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  13112. {
  13113. QString text;
  13114. if(context->argumentCount()==1)
  13115. {
  13116. text= argument<QString> (0,context);
  13117. }
  13118. QScriptValue object= engine->newQObject(new QLabel(text));
  13119. setQLabelProperties(object,engine);
  13120. return object;
  13121. }
  13122. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  13123. {
  13124. setQFrameProperties(value,engine);
  13125. }
  13126. /*:43*//*46:*/
  13127. #line 1385 "./typica.w"
  13128. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  13129. {
  13130. QScriptValue object= engine->newQObject(new QLineEdit());
  13131. setQLineEditProperties(object,engine);
  13132. return object;
  13133. }
  13134. /*:46*//*47:*/
  13135. #line 1396 "./typica.w"
  13136. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  13137. {
  13138. setQWidgetProperties(value,engine);
  13139. }
  13140. /*:47*//*50:*/
  13141. #line 1432 "./typica.w"
  13142. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  13143. {
  13144. QScriptValue object= engine->newQObject(new QSplitter);
  13145. setQSplitterProperties(object,engine);
  13146. return object;
  13147. }
  13148. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  13149. {
  13150. setQFrameProperties(value,engine);
  13151. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  13152. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  13153. value.setProperty("restoreState",
  13154. engine->newFunction(QSplitter_restoreState));
  13155. value.setProperty("count",engine->newFunction(QSplitter_count));
  13156. }
  13157. /*:50*//*51:*/
  13158. #line 1453 "./typica.w"
  13159. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  13160. {
  13161. if(context->argumentCount()==1)
  13162. {
  13163. QSplitter*self= getself<QSplitter*> (context);
  13164. QWidget*widget= argument<QWidget*> (0,context);
  13165. if(widget)
  13166. {
  13167. self->addWidget(widget);
  13168. }
  13169. else
  13170. {
  13171. context->throwError("Incorrect argument type passed to "
  13172. "QSplitter::addWidget(). This method "
  13173. "requires a QWidget.");
  13174. }
  13175. }
  13176. else
  13177. {
  13178. context->throwError("Incorrect number of arguments passed to "
  13179. "QSplitter::addWidget(). This method takes one "
  13180. "QWidget as an argument.");
  13181. }
  13182. return QScriptValue();
  13183. }
  13184. /*:51*//*52:*/
  13185. #line 1490 "./typica.w"
  13186. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  13187. {
  13188. QSplitter*self= getself<QSplitter*> (context);
  13189. return QScriptValue(self->count());
  13190. }
  13191. /*:52*//*53:*/
  13192. #line 1503 "./typica.w"
  13193. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  13194. {
  13195. if(context->argumentCount()==1)
  13196. {
  13197. QSplitter*self= getself<QSplitter*> (context);
  13198. QString key= argument<QString> (0,context);
  13199. QSettings settings;
  13200. settings.setValue(key,self->saveState());
  13201. }
  13202. else
  13203. {
  13204. context->throwError("Incorrect number of arguments passed to "
  13205. "QSplitter::saveState(). This method takes one "
  13206. "string as an argument.");
  13207. }
  13208. return QScriptValue();
  13209. }
  13210. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  13211. {
  13212. if(context->argumentCount()==1)
  13213. {
  13214. QSplitter*self= getself<QSplitter*> (context);
  13215. QString key= argument<QString> (0,context);
  13216. QSettings settings;
  13217. self->restoreState(settings.value(key).toByteArray());
  13218. }
  13219. else
  13220. {
  13221. context->throwError("Incorrect number of arguments passed to "
  13222. "QSplitter::restoreState(). This method takes "
  13223. "one string as an argument.");
  13224. }
  13225. return QScriptValue();
  13226. }
  13227. /*:53*//*55:*/
  13228. #line 1556 "./typica.w"
  13229. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  13230. {
  13231. setQLayoutItemProperties(value,engine);
  13232. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  13233. }
  13234. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  13235. {
  13236. if(context->argumentCount()==1)
  13237. {
  13238. QLayout*self= getself<QLayout*> (context);
  13239. QWidget*widget= argument<QWidget*> (0,context);
  13240. if(widget)
  13241. {
  13242. self->addWidget(widget);
  13243. }
  13244. else
  13245. {
  13246. context->throwError("Incorrect argument type passed to "
  13247. "QLayout::addWidget(). This method requires "
  13248. "a QWidget.");
  13249. }
  13250. }
  13251. else
  13252. {
  13253. context->throwError("Incorrect number of arguments passed to "
  13254. "QLayout::addWidget(). This method takes one "
  13255. "QWidget as an argument.");
  13256. }
  13257. return QScriptValue();
  13258. }
  13259. /*:55*//*58:*/
  13260. #line 1623 "./typica.w"
  13261. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  13262. {
  13263. QScriptValue object=
  13264. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  13265. setQBoxLayoutProperties(object,engine);
  13266. return object;
  13267. }
  13268. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  13269. {
  13270. setQLayoutProperties(value,engine);
  13271. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  13272. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  13273. }
  13274. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  13275. {
  13276. if(context->argumentCount()> 0&&context->argumentCount()<3)
  13277. {
  13278. QBoxLayout*self= getself<QBoxLayout*> (context);
  13279. QLayout*layout= argument<QLayout*> (0,context);
  13280. int stretch= 0;
  13281. if(context->argumentCount()==2)
  13282. {
  13283. stretch= argument<int> (1,context);
  13284. }
  13285. if(layout)
  13286. {
  13287. self->addLayout(layout,stretch);
  13288. }
  13289. else
  13290. {
  13291. context->throwError("Incorrect argument type passed to "
  13292. "QLayout::addLayout(). This method requires "
  13293. "a QLayout.");
  13294. }
  13295. }
  13296. else
  13297. {
  13298. context->throwError("Incorrect number of arguments passed to "
  13299. "QLayout::addLayout(). This method takes one "
  13300. "QLayout as an argument and optionally one integer.");
  13301. }
  13302. return QScriptValue();
  13303. }
  13304. /*:58*//*59:*/
  13305. #line 1674 "./typica.w"
  13306. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  13307. {
  13308. if(context->argumentCount()> 0&&context->argumentCount()<4)
  13309. {
  13310. QBoxLayout*self= getself<QBoxLayout*> (context);
  13311. QWidget*widget= argument<QWidget*> (0,context);
  13312. int stretch= 0;
  13313. Qt::Alignment alignment= 0;
  13314. if(context->argumentCount()> 1)
  13315. {
  13316. stretch= argument<int> (1,context);
  13317. }
  13318. if(context->argumentCount()> 2)
  13319. {
  13320. alignment= (Qt::Alignment)(argument<int> (2,context));
  13321. }
  13322. if(widget)
  13323. {
  13324. self->addWidget(widget,stretch,alignment);
  13325. }
  13326. else
  13327. {
  13328. context->throwError("Incorrect argument type passed to "
  13329. "QBoxLayout::addWidget(). This method requires "
  13330. "a QWidget.");
  13331. }
  13332. }
  13333. else
  13334. {
  13335. context->throwError("Incorrect number of arguments passed to "
  13336. "QBoxLayout::addWidget(). This method takes one "
  13337. "QWidget and optionally up to two integers as "
  13338. "arguments.");
  13339. }
  13340. return QScriptValue();
  13341. }
  13342. /*:59*//*62:*/
  13343. #line 1738 "./typica.w"
  13344. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  13345. {
  13346. QScriptValue object= engine->newQObject(new QAction(NULL));
  13347. setQActionProperties(object,engine);
  13348. return object;
  13349. }
  13350. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  13351. {
  13352. setQObjectProperties(value,engine);
  13353. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  13354. }
  13355. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  13356. {
  13357. if(context->argumentCount()==1)
  13358. {
  13359. QAction*self= getself<QAction*> (context);
  13360. self->setShortcut(argument<QString> (0,context));
  13361. }
  13362. else
  13363. {
  13364. context->throwError("Incorrect number of arguments passed to "
  13365. "QAction::setShortcut(). This method takes one "
  13366. "string as an argument.");
  13367. }
  13368. return QScriptValue();
  13369. }
  13370. /*:62*//*65:*/
  13371. #line 1796 "./typica.w"
  13372. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  13373. QScriptEngine*engine)
  13374. {
  13375. QScriptValue retval;
  13376. if(context->argumentCount()==3)
  13377. {
  13378. QWidget*widget= argument<QWidget*> (0,context);
  13379. if(widget)
  13380. {
  13381. QString caption= argument<QString> (1,context);
  13382. QString dir= argument<QString> (2,context);
  13383. retval= QScriptValue(engine,
  13384. QFileDialog::getOpenFileName(widget,caption,
  13385. dir,"",0,0));
  13386. setQFileDialogProperties(retval,engine);
  13387. }
  13388. else
  13389. {
  13390. context->throwError("Incorrect argument type passed to "
  13391. "QFileDialog::getOpenFileName(). The first "
  13392. "argument to this method must be a QWidget.");
  13393. }
  13394. }
  13395. else
  13396. {
  13397. context->throwError("Incorrect number of arguments passed to "
  13398. "QFileDialog::getOpenFileName(). This method "
  13399. "takes one QWidget followed by two strings for a "
  13400. "total of three arguments.");
  13401. }
  13402. return retval;
  13403. }
  13404. /*:65*//*66:*/
  13405. #line 1832 "./typica.w"
  13406. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  13407. QScriptEngine*engine)
  13408. {
  13409. QScriptValue retval;
  13410. if(context->argumentCount()==3)
  13411. {
  13412. QWidget*widget= argument<QWidget*> (0,context);
  13413. if(widget)
  13414. {
  13415. QString caption= argument<QString> (1,context);
  13416. QString dir= argument<QString> (2,context);
  13417. retval= QScriptValue(engine,
  13418. QFileDialog::getSaveFileName(widget,caption,
  13419. dir,"",0,0));
  13420. setQFileDialogProperties(retval,engine);
  13421. }
  13422. else
  13423. {
  13424. context->throwError("Incorrect argument type passed to "
  13425. "QFileDialog::getSaveFileName(). The first "
  13426. "argument to this method must be a QWidget.");
  13427. }
  13428. }
  13429. else
  13430. {
  13431. context->throwError("Incorrect number of arguments passed to "
  13432. "QFileDialog::getSaveFileName(). This method "
  13433. "takes one QWidget followed by two strings for a "
  13434. "total of three arguments.");
  13435. }
  13436. return retval;
  13437. }
  13438. /*:66*//*67:*/
  13439. #line 1869 "./typica.w"
  13440. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  13441. {
  13442. setQDialogProperties(value,engine);
  13443. }
  13444. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  13445. {
  13446. setQWidgetProperties(value,engine);
  13447. }
  13448. /*:67*//*70:*/
  13449. #line 1910 "./typica.w"
  13450. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  13451. {
  13452. QScriptValue object=
  13453. engine->newQObject(new QFile(argument<QString> (0,context)));
  13454. setQFileProperties(object,engine);
  13455. return object;
  13456. }
  13457. /*:70*//*71:*/
  13458. #line 1921 "./typica.w"
  13459. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  13460. {
  13461. setQIODeviceProperties(value,engine);
  13462. value.setProperty("remove",engine->newFunction(QFile_remove));
  13463. }
  13464. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  13465. {
  13466. QFile*self= getself<QFile*> (context);
  13467. bool retval= self->remove();
  13468. return QScriptValue(engine,retval);
  13469. }
  13470. /*:71*//*72:*/
  13471. #line 1943 "./typica.w"
  13472. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  13473. {
  13474. setQObjectProperties(value,engine);
  13475. value.setProperty("open",engine->newFunction(QIODevice_open));
  13476. value.setProperty("close",engine->newFunction(QIODevice_close));
  13477. value.setProperty("readToString",
  13478. engine->newFunction(QIODevice_readToString));
  13479. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  13480. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  13481. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  13482. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  13483. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  13484. value.setProperty("read",engine->newFunction(QIODevice_read));
  13485. }
  13486. /*:72*//*73:*/
  13487. #line 1964 "./typica.w"
  13488. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  13489. {
  13490. QIODevice*self= getself<QIODevice*> (context);
  13491. bool retval= false;
  13492. if(context->argumentCount()==1)
  13493. {
  13494. switch(argument<int> (0,context))
  13495. {
  13496. case 1:
  13497. retval= self->open(QIODevice::ReadOnly);
  13498. break;
  13499. case 2:
  13500. retval= self->open(QIODevice::WriteOnly);
  13501. break;
  13502. case 3:
  13503. retval= self->open(QIODevice::ReadWrite);
  13504. break;
  13505. default:
  13506. break;
  13507. }
  13508. }
  13509. else
  13510. {
  13511. retval= self->open(QIODevice::ReadWrite);
  13512. }
  13513. return QScriptValue(retval);
  13514. }
  13515. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  13516. {
  13517. QIODevice*self= getself<QIODevice*> (context);
  13518. self->close();
  13519. return QScriptValue();
  13520. }
  13521. /*:73*//*74:*/
  13522. #line 2004 "./typica.w"
  13523. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  13524. {
  13525. QIODevice*self= getself<QIODevice*> (context);
  13526. self->reset();
  13527. return QScriptValue(QString(self->readAll()));
  13528. }
  13529. /*:74*//*75:*/
  13530. #line 2020 "./typica.w"
  13531. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  13532. {
  13533. QIODevice*self= getself<QIODevice*> (context);
  13534. if(context->argumentCount()==1)
  13535. {
  13536. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  13537. }
  13538. context->throwError("Incorrect number of arguments passed to "
  13539. "QIODevice::putChar()");
  13540. return QScriptValue();
  13541. }
  13542. /*:75*//*76:*/
  13543. #line 2038 "./typica.w"
  13544. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  13545. {
  13546. QIODevice*self= getself<QIODevice*> (context);
  13547. if(context->argumentCount()==1)
  13548. {
  13549. self->write(argument<QString> (0,context).toUtf8());
  13550. }
  13551. else
  13552. {
  13553. context->throwError("Incorrect number of arguments passed to "
  13554. "QIODevice::writeString()");
  13555. }
  13556. return QScriptValue();
  13557. }
  13558. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  13559. {
  13560. QIODevice*self= getself<QIODevice*> (context);
  13561. if(context->argumentCount()==1)
  13562. {
  13563. self->write(argument<QByteArray> (0,context));
  13564. }
  13565. else
  13566. {
  13567. context->throwError("Incorrect number of arguments passed to "
  13568. "QIODevice::writeBytes()");
  13569. }
  13570. return QScriptValue();
  13571. }
  13572. /*:76*//*77:*/
  13573. #line 2072 "./typica.w"
  13574. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  13575. {
  13576. QIODevice*self= getself<QIODevice*> (context);
  13577. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  13578. setQByteArrayProperties(value,engine);
  13579. return value;
  13580. }
  13581. /*:77*//*78:*/
  13582. #line 2083 "./typica.w"
  13583. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  13584. {
  13585. QIODevice*self= getself<QIODevice*> (context);
  13586. QScriptValue value= engine->toScriptValue<QByteArray> (
  13587. self->peek(argument<int> (0,context)));
  13588. setQByteArrayProperties(value,engine);
  13589. return value;
  13590. }
  13591. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  13592. {
  13593. QIODevice*self= getself<QIODevice*> (context);
  13594. QScriptValue value= engine->toScriptValue<QByteArray> (
  13595. self->read(argument<int> (0,context)));
  13596. setQByteArrayProperties(value,engine);
  13597. return value;
  13598. }
  13599. /*:78*//*81:*/
  13600. #line 2128 "./typica.w"
  13601. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  13602. {
  13603. QScriptValue object= engine->newQObject(new QProcess);
  13604. setQProcessProperties(object,engine);
  13605. return object;
  13606. }
  13607. /*:81*//*82:*/
  13608. #line 2139 "./typica.w"
  13609. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  13610. {
  13611. setQIODeviceProperties(value,engine);
  13612. value.setProperty("execute",engine->newFunction(QProcess_execute));
  13613. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  13614. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  13615. value.setProperty("start",engine->newFunction(QProcess_start));
  13616. }
  13617. /*:82*//*83:*/
  13618. #line 2153 "./typica.w"
  13619. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  13620. {
  13621. QProcess*self= getself<QProcess*> (context);
  13622. QString program= argument<QString> (0,context);
  13623. QStringList arguments= QStringList();
  13624. if(context->argumentCount()> 1){
  13625. arguments= argument<QVariant> (1,context).toStringList();
  13626. }
  13627. int retval= self->execute(program,arguments);
  13628. return QScriptValue(retval);
  13629. }
  13630. /*:83*//*84:*/
  13631. #line 2168 "./typica.w"
  13632. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  13633. {
  13634. QProcess*self= getself<QProcess*> (context);
  13635. QString program= argument<QString> (0,context);
  13636. QStringList arguments= QStringList();
  13637. if(context->argumentCount()> 1){
  13638. arguments= argument<QVariant> (1,context).toStringList();
  13639. }
  13640. QString workingDirectory= "";
  13641. if(context->argumentCount()> 2){
  13642. workingDirectory= argument<QString> (2,context);
  13643. }
  13644. bool retval;
  13645. switch(context->argumentCount())
  13646. {
  13647. case 1:
  13648. retval= self->startDetached(program);
  13649. break;
  13650. case 2:
  13651. retval= self->startDetached(program,arguments);
  13652. break;
  13653. case 3:
  13654. retval= self->startDetached(program,arguments,workingDirectory);
  13655. break;
  13656. default:
  13657. retval= false;
  13658. }
  13659. return QScriptValue(retval);
  13660. }
  13661. /*:84*//*85:*/
  13662. #line 2201 "./typica.w"
  13663. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  13664. {
  13665. QProcess*self= getself<QProcess*> (context);
  13666. QString directory= argument<QString> (0,context);
  13667. self->setWorkingDirectory(directory);
  13668. return QScriptValue();
  13669. }
  13670. /*:85*//*86:*/
  13671. #line 2213 "./typica.w"
  13672. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  13673. {
  13674. QProcess*self= getself<QProcess*> (context);
  13675. QString program= argument<QString> (0,context);
  13676. QStringList arguments= QStringList();
  13677. if(context->argumentCount()> 1){
  13678. arguments= argument<QVariant> (1,context).toStringList();
  13679. }
  13680. self->start(program,arguments);
  13681. return QScriptValue();
  13682. }
  13683. /*:86*//*88:*/
  13684. #line 2254 "./typica.w"
  13685. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  13686. {
  13687. QScriptValue object= engine->newVariant(QVariant(bytes));
  13688. setQByteArrayProperties(object,engine);
  13689. return object;
  13690. }
  13691. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  13692. {
  13693. bytes= value.toVariant().toByteArray();
  13694. }
  13695. /*:88*//*90:*/
  13696. #line 2277 "./typica.w"
  13697. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  13698. {
  13699. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  13700. setQByteArrayProperties(object,engine);
  13701. return object;
  13702. }
  13703. /*:90*//*91:*/
  13704. #line 2288 "./typica.w"
  13705. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  13706. {
  13707. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  13708. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  13709. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  13710. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  13711. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  13712. value.setProperty("size",engine->newFunction(QByteArray_size));
  13713. value.setProperty("left",engine->newFunction(QByteArray_left));
  13714. value.setProperty("right",engine->newFunction(QByteArray_right));
  13715. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  13716. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  13717. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  13718. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  13719. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  13720. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  13721. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  13722. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  13723. }
  13724. /*:91*//*92:*/
  13725. #line 2312 "./typica.w"
  13726. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  13727. {
  13728. QByteArray self= getself<QByteArray> (context);
  13729. QByteArray retval;
  13730. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  13731. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  13732. setQByteArrayProperties(value,engine);
  13733. return value;
  13734. }
  13735. /*:92*//*93:*/
  13736. #line 2326 "./typica.w"
  13737. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  13738. {
  13739. QByteArray self= getself<QByteArray> (context);
  13740. return QScriptValue((int)(self.at(argument<int> (0,context))));
  13741. }
  13742. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  13743. {
  13744. QByteArray self= getself<QByteArray> (context);
  13745. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  13746. return QScriptValue();
  13747. }
  13748. /*:93*//*94:*/
  13749. #line 2344 "./typica.w"
  13750. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  13751. {
  13752. QByteArray self= getself<QByteArray> (context);
  13753. QScriptValue value=
  13754. engine->toScriptValue<QByteArray> (
  13755. self.append(argument<QByteArray> (0,context)));
  13756. setQByteArrayProperties(value,engine);
  13757. return value;
  13758. }
  13759. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  13760. {
  13761. QByteArray self= getself<QByteArray> (context);
  13762. QScriptValue value= engine->toScriptValue<QByteArray> (
  13763. self.append(argument<QString> (0,context)));
  13764. setQByteArrayProperties(value,engine);
  13765. return value;
  13766. }
  13767. /*:94*//*95:*/
  13768. #line 2366 "./typica.w"
  13769. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  13770. {
  13771. QByteArray self= getself<QByteArray> (context);
  13772. return QScriptValue(self.size());
  13773. }
  13774. /*:95*//*96:*/
  13775. #line 2376 "./typica.w"
  13776. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  13777. {
  13778. QByteArray self= getself<QByteArray> (context);
  13779. QScriptValue value= engine->toScriptValue<QByteArray> (
  13780. self.left(argument<int> (0,context)));
  13781. setQByteArrayProperties(value,engine);
  13782. return value;
  13783. }
  13784. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  13785. {
  13786. QByteArray self= getself<QByteArray> (context);
  13787. QScriptValue value= engine->toScriptValue<QByteArray> (
  13788. self.right(argument<int> (0,context)));
  13789. setQByteArrayProperties(value,engine);
  13790. return value;
  13791. }
  13792. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  13793. {
  13794. QByteArray self= getself<QByteArray> (context);
  13795. int length= -1;
  13796. if(context->argumentCount()> 1)
  13797. {
  13798. length= argument<int> (1,context);
  13799. }
  13800. QScriptValue value= engine->toScriptValue<QByteArray> (
  13801. self.mid(argument<int> (0,context),length));
  13802. setQByteArrayProperties(value,engine);
  13803. return value;
  13804. }
  13805. /*:96*//*97:*/
  13806. #line 2411 "./typica.w"
  13807. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  13808. {
  13809. QByteArray self= getself<QByteArray> (context);
  13810. self.chop(argument<int> (0,context));
  13811. return QScriptValue();
  13812. }
  13813. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  13814. {
  13815. QByteArray self= getself<QByteArray> (context);
  13816. QScriptValue value= engine->toScriptValue<QByteArray> (
  13817. self.remove(argument<int> (0,context),argument<int> (1,context)));
  13818. setQByteArrayProperties(value,engine);
  13819. return value;
  13820. }
  13821. /*:97*//*98:*/
  13822. #line 2434 "./typica.w"
  13823. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  13824. {
  13825. QByteArray self= getself<QByteArray> (context);
  13826. int value= 0;
  13827. char*bytes= (char*)&value;
  13828. bytes[0]= self[0];
  13829. return QScriptValue(value);
  13830. }
  13831. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  13832. {
  13833. QByteArray self= getself<QByteArray> (context);
  13834. int value= 0;
  13835. char*bytes= (char*)&value;
  13836. bytes[0]= self[0];
  13837. bytes[1]= self[1];
  13838. return QScriptValue(value);
  13839. }
  13840. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  13841. {
  13842. QByteArray self= getself<QByteArray> (context);
  13843. int value= 0;
  13844. char*bytes= (char*)&value;
  13845. bytes[0]= self[0];
  13846. bytes[1]= self[1];
  13847. bytes[2]= self[2];
  13848. bytes[3]= self[3];
  13849. return QScriptValue(value);
  13850. }
  13851. /*:98*//*99:*/
  13852. #line 2470 "./typica.w"
  13853. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  13854. {
  13855. QByteArray self= getself<QByteArray> (context);
  13856. float value= 0.0;
  13857. char*bytes= (char*)&value;
  13858. bytes[0]= self[0];
  13859. bytes[1]= self[1];
  13860. bytes[2]= self[2];
  13861. bytes[3]= self[3];
  13862. return QScriptValue(value);
  13863. }
  13864. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  13865. {
  13866. QByteArray self= getself<QByteArray> (context);
  13867. double value= 0.0;
  13868. char*bytes= (char*)&value;
  13869. bytes[0]= self[0];
  13870. bytes[1]= self[1];
  13871. bytes[2]= self[2];
  13872. bytes[3]= self[3];
  13873. bytes[4]= self[4];
  13874. bytes[5]= self[5];
  13875. bytes[6]= self[6];
  13876. bytes[7]= self[7];
  13877. return QScriptValue(value);
  13878. }
  13879. /*:99*//*102:*/
  13880. #line 2525 "./typica.w"
  13881. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  13882. {
  13883. qint8 value= (qint8)(argument<int> (0,context));
  13884. char*bytes= (char*)&value;
  13885. QByteArray retval;
  13886. retval.resize(1);
  13887. retval[0]= bytes[0];
  13888. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  13889. setQByteArrayProperties(v,engine);
  13890. return v;
  13891. }
  13892. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  13893. {
  13894. qint16 value= (qint16)(argument<int> (0,context));
  13895. char*bytes= (char*)&value;
  13896. QByteArray retval;
  13897. retval.resize(2);
  13898. retval[0]= bytes[0];
  13899. retval[1]= bytes[1];
  13900. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  13901. setQByteArrayProperties(v,engine);
  13902. return v;
  13903. }
  13904. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  13905. {
  13906. qint32 value= (qint32)(argument<int> (0,context));
  13907. char*bytes= (char*)&value;
  13908. QByteArray retval;
  13909. retval.resize(4);
  13910. retval[0]= bytes[0];
  13911. retval[1]= bytes[1];
  13912. retval[2]= bytes[2];
  13913. retval[3]= bytes[3];
  13914. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  13915. setQByteArrayProperties(v,engine);
  13916. return v;
  13917. }
  13918. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  13919. {
  13920. float value= (float)(argument<double> (0,context));
  13921. char*bytes= (char*)&value;
  13922. QByteArray retval;
  13923. retval.resize(4);
  13924. retval[0]= bytes[0];
  13925. retval[1]= bytes[1];
  13926. retval[2]= bytes[2];
  13927. retval[3]= bytes[3];
  13928. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  13929. setQByteArrayProperties(v,engine);
  13930. return v;
  13931. }
  13932. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  13933. {
  13934. double value= (double)(argument<double> (0,context));
  13935. char*bytes= (char*)&value;
  13936. QByteArray retval;
  13937. retval.resize(8);
  13938. retval[0]= bytes[0];
  13939. retval[1]= bytes[1];
  13940. retval[2]= bytes[2];
  13941. retval[3]= bytes[3];
  13942. retval[4]= bytes[4];
  13943. retval[5]= bytes[5];
  13944. retval[6]= bytes[6];
  13945. retval[7]= bytes[7];
  13946. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  13947. setQByteArrayProperties(v,engine);
  13948. return v;
  13949. }
  13950. /*:102*//*105:*/
  13951. #line 2622 "./typica.w"
  13952. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  13953. {
  13954. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  13955. QScriptValue object= engine->newQObject(new QBuffer(array));
  13956. setQBufferProperties(object,engine);
  13957. return object;
  13958. }
  13959. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  13960. {
  13961. setQIODeviceProperties(value,engine);
  13962. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  13963. }
  13964. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  13965. {
  13966. QBuffer*self= getself<QBuffer*> (context);
  13967. self->setData(argument<QString> (0,context).toAscii());
  13968. return QScriptValue();
  13969. }
  13970. /*:105*//*108:*/
  13971. #line 2671 "./typica.w"
  13972. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  13973. {
  13974. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  13975. setXQueryProperties(object,engine);
  13976. return object;
  13977. }
  13978. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  13979. {
  13980. QXmlQuery*self= getself<QXmlQuery*> (context);
  13981. delete self;
  13982. return QScriptValue();
  13983. }
  13984. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  13985. {
  13986. value.setProperty("bind",engine->newFunction(XQuery_bind));
  13987. value.setProperty("exec",engine->newFunction(XQuery_exec));
  13988. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  13989. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  13990. }
  13991. /*:108*//*109:*/
  13992. #line 2697 "./typica.w"
  13993. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  13994. {
  13995. QXmlQuery*self= getself<QXmlQuery*> (context);
  13996. QIODevice*buffer= argument<QIODevice*> (1,context);
  13997. self->bindVariable(argument<QString> (0,context),buffer);
  13998. return QScriptValue();
  13999. }
  14000. /*:109*//*110:*/
  14001. #line 2708 "./typica.w"
  14002. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  14003. {
  14004. QXmlQuery*self= getself<QXmlQuery*> (context);
  14005. self->setQuery(argument<QString> (0,context));
  14006. return QScriptValue();
  14007. }
  14008. /*:110*//*111:*/
  14009. #line 2718 "./typica.w"
  14010. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  14011. {
  14012. QXmlQuery*self= getself<QXmlQuery*> (context);
  14013. QString result;
  14014. self->evaluateTo(&result);
  14015. return QScriptValue(result);
  14016. }
  14017. /*:111*//*114:*/
  14018. #line 2773 "./typica.w"
  14019. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  14020. {
  14021. QXmlStreamWriter*retval;
  14022. if(context->argumentCount()==1)
  14023. {
  14024. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  14025. }
  14026. else
  14027. {
  14028. retval= new QXmlStreamWriter;
  14029. }
  14030. QScriptValue object= engine->toScriptValue<void*> (retval);
  14031. setXmlWriterProperties(object,engine);
  14032. return object;
  14033. }
  14034. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  14035. {
  14036. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  14037. value.setProperty("writeAttribute",
  14038. engine->newFunction(XmlWriter_writeAttribute));
  14039. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  14040. value.setProperty("writeCharacters",
  14041. engine->newFunction(XmlWriter_writeCharacters));
  14042. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  14043. value.setProperty("writeEmptyElement",
  14044. engine->newFunction(XmlWriter_writeEmptyElement));
  14045. value.setProperty("writeEndDocument",
  14046. engine->newFunction(XmlWriter_writeEndDocument));
  14047. value.setProperty("writeEndElement",
  14048. engine->newFunction(XmlWriter_writeEndElement));
  14049. value.setProperty("writeEntityReference",
  14050. engine->newFunction(XmlWriter_writeEntityReference));
  14051. value.setProperty("writeProcessingInstruction",
  14052. engine->newFunction(XmlWriter_writeProcessingInstruction));
  14053. value.setProperty("writeStartDocument",
  14054. engine->newFunction(XmlWriter_writeStartDocument));
  14055. value.setProperty("writeStartElement",
  14056. engine->newFunction(XmlWriter_writeStartElement));
  14057. value.setProperty("writeTextElement",
  14058. engine->newFunction(XmlWriter_writeTextElement));
  14059. }
  14060. /*:114*//*115:*/
  14061. #line 2820 "./typica.w"
  14062. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  14063. {
  14064. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14065. QIODevice*device= argument<QIODevice*> (0,context);
  14066. self->setDevice(device);
  14067. return QScriptValue();
  14068. }
  14069. /*:115*//*116:*/
  14070. #line 2834 "./typica.w"
  14071. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  14072. QScriptEngine*)
  14073. {
  14074. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14075. self->writeStartDocument(argument<QString> (0,context));
  14076. return QScriptValue();
  14077. }
  14078. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  14079. QScriptEngine*)
  14080. {
  14081. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14082. self->writeEndDocument();
  14083. return QScriptValue();
  14084. }
  14085. /*:116*//*117:*/
  14086. #line 2853 "./typica.w"
  14087. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  14088. {
  14089. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14090. self->writeDTD(argument<QString> (0,context));
  14091. return QScriptValue();
  14092. }
  14093. /*:117*//*118:*/
  14094. #line 2864 "./typica.w"
  14095. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  14096. QScriptEngine*)
  14097. {
  14098. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14099. self->writeStartElement(argument<QString> (0,context));
  14100. return QScriptValue();
  14101. }
  14102. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  14103. {
  14104. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14105. self->writeAttribute(argument<QString> (0,context),
  14106. argument<QString> (1,context));
  14107. return QScriptValue();
  14108. }
  14109. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  14110. {
  14111. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14112. self->writeCharacters(argument<QString> (0,context));
  14113. return QScriptValue();
  14114. }
  14115. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  14116. {
  14117. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14118. self->writeEndElement();
  14119. return QScriptValue();
  14120. }
  14121. /*:118*//*119:*/
  14122. #line 2900 "./typica.w"
  14123. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  14124. QScriptEngine*)
  14125. {
  14126. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14127. self->writeEmptyElement(argument<QString> (0,context));
  14128. return QScriptValue();
  14129. }
  14130. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  14131. QScriptEngine*)
  14132. {
  14133. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14134. self->writeTextElement(argument<QString> (0,context),
  14135. argument<QString> (1,context));
  14136. return QScriptValue();
  14137. }
  14138. /*:119*//*120:*/
  14139. #line 2921 "./typica.w"
  14140. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  14141. {
  14142. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14143. self->writeCDATA(argument<QString> (0,context));
  14144. return QScriptValue();
  14145. }
  14146. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  14147. QScriptEngine*)
  14148. {
  14149. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14150. self->writeEntityReference(argument<QString> (0,context));
  14151. return QScriptValue();
  14152. }
  14153. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  14154. QScriptEngine*)
  14155. {
  14156. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14157. self->writeProcessingInstruction(argument<QString> (0,context),
  14158. argument<QString> (1,context));
  14159. return QScriptValue();
  14160. }
  14161. /*:120*//*123:*/
  14162. #line 2980 "./typica.w"
  14163. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  14164. {
  14165. QXmlStreamReader*retval=
  14166. new QXmlStreamReader(argument<QIODevice*> (0,context));
  14167. QScriptValue object= engine->toScriptValue<void*> (retval);
  14168. setXmlReaderProperties(object,engine);
  14169. return object;
  14170. }
  14171. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  14172. {
  14173. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  14174. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  14175. value.setProperty("hasAttribute",
  14176. engine->newFunction(XmlReader_hasAttribute));
  14177. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  14178. value.setProperty("isStartElement",
  14179. engine->newFunction(XmlReader_isStartElement));
  14180. value.setProperty("name",engine->newFunction(XmlReader_name));
  14181. value.setProperty("readElementText",
  14182. engine->newFunction(XmlReader_readElementText));
  14183. value.setProperty("readNext",
  14184. engine->newFunction(XmlReader_readNext));
  14185. value.setProperty("text",engine->newFunction(XmlReader_text));
  14186. }
  14187. /*:123*//*124:*/
  14188. #line 3010 "./typica.w"
  14189. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  14190. {
  14191. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14192. QString retval=
  14193. self->attributes().value(argument<QString> (0,context)).toString();
  14194. return QScriptValue(retval);
  14195. }
  14196. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  14197. {
  14198. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14199. bool retval=
  14200. self->attributes().hasAttribute(argument<QString> (0,context));
  14201. return QScriptValue(retval);
  14202. }
  14203. /*:124*//*125:*/
  14204. #line 3030 "./typica.w"
  14205. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  14206. {
  14207. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14208. return QScriptValue(self->atEnd());
  14209. }
  14210. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  14211. {
  14212. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14213. return QScriptValue(self->isDTD());
  14214. }
  14215. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  14216. {
  14217. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14218. return QScriptValue(self->isStartElement());
  14219. }
  14220. /*:125*//*126:*/
  14221. #line 3051 "./typica.w"
  14222. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  14223. {
  14224. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14225. self->readNext();
  14226. return QScriptValue();
  14227. }
  14228. /*:126*//*127:*/
  14229. #line 3061 "./typica.w"
  14230. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  14231. {
  14232. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14233. return QScriptValue(self->name().toString());
  14234. }
  14235. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  14236. {
  14237. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14238. return QScriptValue(self->readElementText());
  14239. }
  14240. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  14241. {
  14242. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14243. return QScriptValue(self->text().toString());
  14244. }
  14245. /*:127*//*130:*/
  14246. #line 3103 "./typica.w"
  14247. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  14248. {
  14249. setQObjectProperties(value,engine);
  14250. value.setProperty("value",engine->newFunction(QSettings_value));
  14251. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  14252. }
  14253. /*:130*//*131:*/
  14254. #line 3115 "./typica.w"
  14255. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  14256. {
  14257. QScriptValue object;
  14258. if(context->argumentCount()==1||context->argumentCount()==2)
  14259. {
  14260. QSettings settings;
  14261. QString key= argument<QString> (0,context);
  14262. QVariant value;
  14263. QVariant retval;
  14264. if(context->argumentCount()> 1)
  14265. {
  14266. value= argument<QVariant> (1,context);
  14267. retval= settings.value(key,value);
  14268. }
  14269. else
  14270. {
  14271. retval= settings.value(key);
  14272. }
  14273. object= engine->newVariant(retval);
  14274. }
  14275. else
  14276. {
  14277. context->throwError("Incorrect number of arguments passed to "
  14278. "QSettings::value(). This method takes one "
  14279. "string and one optional variant type.");
  14280. }
  14281. return object;
  14282. }
  14283. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  14284. {
  14285. if(context->argumentCount()==2)
  14286. {
  14287. QSettings settings;
  14288. QString key= argument<QString> (0,context);
  14289. QVariant value= argument<QVariant> (1,context);
  14290. settings.setValue(key,value);
  14291. }
  14292. else
  14293. {
  14294. context->throwError("Incorrect number of arguments passed to "
  14295. "QSettings::setValue(). This method takes one "
  14296. "string and one variant type for a total of two "
  14297. "arguments.");
  14298. }
  14299. return QScriptValue();
  14300. }
  14301. /*:131*//*134:*/
  14302. #line 3184 "./typica.w"
  14303. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  14304. {
  14305. QScriptValue object= engine->newQObject(new QLCDNumber());
  14306. setQLCDNumberProperties(object,engine);
  14307. return object;
  14308. }
  14309. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  14310. {
  14311. setQFrameProperties(value,engine);
  14312. }
  14313. /*:134*//*137:*/
  14314. #line 3242 "./typica.w"
  14315. QScriptValue constructQTime(QScriptContext*context,
  14316. QScriptEngine*engine)
  14317. {
  14318. QScriptValue object;
  14319. if(context->argumentCount()==0||
  14320. (context->argumentCount()>=2&&context->argumentCount()<=4))
  14321. {
  14322. int arg1= 0;
  14323. int arg2= 0;
  14324. int arg3= 0;
  14325. int arg4= 0;
  14326. switch(context->argumentCount())
  14327. {
  14328. case 4:
  14329. arg4= argument<int> (3,context);
  14330. case 3:
  14331. arg3= argument<int> (2,context);
  14332. case 2:
  14333. arg2= argument<int> (1,context);
  14334. arg1= argument<int> (0,context);
  14335. default:
  14336. break;
  14337. }
  14338. if(context->argumentCount())
  14339. {
  14340. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  14341. arg4));
  14342. }
  14343. else
  14344. {
  14345. object= engine->toScriptValue<QTime> (QTime());
  14346. }
  14347. setQTimeProperties(object,engine);
  14348. }
  14349. else
  14350. {
  14351. context->throwError("Incorrect number of arguments passed to "
  14352. "QTime::QTime(). This method takes zero, two, "
  14353. "three, or four integer arguments.");
  14354. }
  14355. return object;
  14356. }
  14357. /*:137*//*138:*/
  14358. #line 3290 "./typica.w"
  14359. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  14360. {
  14361. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  14362. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  14363. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  14364. value.setProperty("hour",engine->newFunction(QTime_hour));
  14365. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  14366. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  14367. value.setProperty("minute",engine->newFunction(QTime_minute));
  14368. value.setProperty("msec",engine->newFunction(QTime_msec));
  14369. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  14370. value.setProperty("restart",engine->newFunction(QTime_restart));
  14371. value.setProperty("second",engine->newFunction(QTime_second));
  14372. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  14373. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  14374. value.setProperty("start",engine->newFunction(QTime_start));
  14375. value.setProperty("toString",engine->newFunction(QTime_toString));
  14376. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  14377. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  14378. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  14379. }
  14380. /*:138*//*139:*/
  14381. #line 3319 "./typica.w"
  14382. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  14383. {
  14384. QTime self= getself<QTime> (context);
  14385. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  14386. (self.second()*1000)+self.msec();
  14387. return QScriptValue(retval);
  14388. }
  14389. /*:139*//*140:*/
  14390. #line 3333 "./typica.w"
  14391. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  14392. {
  14393. QTime time;
  14394. QScriptValue retval;
  14395. if(context->argumentCount()==1)
  14396. {
  14397. QTime self= getself<QTime> (context);
  14398. time= self.addMSecs(argument<int> (0,context));
  14399. retval= engine->toScriptValue<QTime> (time);
  14400. setQTimeProperties(retval,engine);
  14401. }
  14402. else
  14403. {
  14404. context->throwError("Incorrect number of arguments passed to "
  14405. "QTime::addMSecs(). This method takes one "
  14406. "integer as an argument.");
  14407. }
  14408. return retval;
  14409. }
  14410. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  14411. {
  14412. QTime time;
  14413. QScriptValue retval;
  14414. if(context->argumentCount()==1)
  14415. {
  14416. QTime self= getself<QTime> (context);
  14417. time= self.addSecs(argument<int> (0,context));
  14418. retval= engine->toScriptValue<QTime> (time);
  14419. setQTimeProperties(retval,engine);
  14420. }
  14421. else
  14422. {
  14423. context->throwError("Incorrect number of arguments passed to "
  14424. "QTime::addSecs(). This method takes one "
  14425. "integer as an argument.");
  14426. }
  14427. return retval;
  14428. }
  14429. /*:140*//*141:*/
  14430. #line 3376 "./typica.w"
  14431. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  14432. {
  14433. QScriptValue retval;
  14434. if(context->argumentCount()==0)
  14435. {
  14436. QTime self= getself<QTime> (context);
  14437. retval= QScriptValue(engine,self.elapsed());
  14438. }
  14439. else
  14440. {
  14441. context->throwError("Incorrect number of arguments passed to "
  14442. "QTime::elapsed(). This method takes no "
  14443. "arguments.");
  14444. }
  14445. return retval;
  14446. }
  14447. /*:141*//*142:*/
  14448. #line 3397 "./typica.w"
  14449. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  14450. {
  14451. QScriptValue retval;
  14452. if(context->argumentCount()==0)
  14453. {
  14454. QTime self= getself<QTime> (context);
  14455. retval= QScriptValue(engine,self.hour());
  14456. }
  14457. else
  14458. {
  14459. context->throwError("Incorrect number of arguments passed to "
  14460. "QTime::hour(). This method takes no "
  14461. "arguments.");
  14462. }
  14463. return retval;
  14464. }
  14465. /*:142*//*143:*/
  14466. #line 3417 "./typica.w"
  14467. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  14468. {
  14469. QScriptValue retval;
  14470. if(context->argumentCount()==0)
  14471. {
  14472. QTime self= getself<QTime> (context);
  14473. retval= QScriptValue(engine,self.minute());
  14474. }
  14475. else
  14476. {
  14477. context->throwError("Incorrect number of arguments passed to "
  14478. "QTime::minute(). This method takes no "
  14479. "arguments.");
  14480. }
  14481. return retval;
  14482. }
  14483. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  14484. {
  14485. QScriptValue retval;
  14486. if(context->argumentCount()==0)
  14487. {
  14488. QTime self= getself<QTime> (context);
  14489. retval= QScriptValue(engine,self.second());
  14490. }
  14491. else
  14492. {
  14493. context->throwError("Incorrect number of arguments passed to "
  14494. "QTime::second(). This method takes no "
  14495. "arguments.");
  14496. }
  14497. return retval;
  14498. }
  14499. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  14500. {
  14501. QScriptValue retval;
  14502. if(context->argumentCount()==0)
  14503. {
  14504. QTime self= getself<QTime> (context);
  14505. retval= QScriptValue(engine,self.msec());
  14506. }
  14507. else
  14508. {
  14509. context->throwError("Incorrect number of arguments passed to "
  14510. "QTime::msec(). This method takes no "
  14511. "arguments.");
  14512. }
  14513. return retval;
  14514. }
  14515. /*:143*//*144:*/
  14516. #line 3473 "./typica.w"
  14517. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  14518. {
  14519. QScriptValue retval;
  14520. if(context->argumentCount()==0)
  14521. {
  14522. QTime self= getself<QTime> (context);
  14523. retval= QScriptValue(engine,self.isNull());
  14524. }
  14525. else
  14526. {
  14527. context->throwError("Incorrect number of arguments passed to "
  14528. "QTime::isNull(). This method takes no "
  14529. "arguments.");
  14530. }
  14531. return retval;
  14532. }
  14533. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  14534. {
  14535. QScriptValue retval;
  14536. if(context->argumentCount()==0)
  14537. {
  14538. QTime self= getself<QTime> (context);
  14539. retval= QScriptValue(engine,self.isValid());
  14540. }
  14541. else
  14542. {
  14543. context->throwError("Incorrect number of arguments passed to "
  14544. "QTime::isValid(). This method takes no "
  14545. "arguments.");
  14546. }
  14547. return retval;
  14548. }
  14549. /*:144*//*145:*/
  14550. #line 3511 "./typica.w"
  14551. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  14552. {
  14553. QScriptValue retval;
  14554. if(context->argumentCount()==1)
  14555. {
  14556. QTime self= getself<QTime> (context);
  14557. QTime arg= argument<QVariant> (0,context).toTime();
  14558. retval= QScriptValue(engine,self.msecsTo(arg));
  14559. }
  14560. else
  14561. {
  14562. context->throwError("Incorrect number of arguments passed to "
  14563. "QTime::msecsTo(). This method takes one QTime.");
  14564. }
  14565. return retval;
  14566. }
  14567. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  14568. {
  14569. QScriptValue retval;
  14570. if(context->argumentCount()==1)
  14571. {
  14572. QTime self= getself<QTime> (context);
  14573. QTime arg= argument<QVariant> (0,context).toTime();
  14574. retval= QScriptValue(engine,self.secsTo(arg));
  14575. }
  14576. else
  14577. {
  14578. context->throwError("Incorrect number of arguments passed to "
  14579. "QTime::secsTo(). This method takes one QTime.");
  14580. }
  14581. return retval;
  14582. }
  14583. /*:145*//*146:*/
  14584. #line 3550 "./typica.w"
  14585. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  14586. {
  14587. QScriptValue retval;
  14588. if(context->argumentCount()==0)
  14589. {
  14590. QTime self= getself<QTime> (context);
  14591. retval= QScriptValue(engine,self.restart());
  14592. }
  14593. else
  14594. {
  14595. context->throwError("Incorrect number of arguments passed to "
  14596. "QTime::restart(). This method takes no "
  14597. "arguments.");
  14598. }
  14599. return retval;
  14600. }
  14601. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  14602. {
  14603. if(context->argumentCount()==0)
  14604. {
  14605. QTime self= getself<QTime> (context);
  14606. self.start();
  14607. }
  14608. else
  14609. {
  14610. context->throwError("Incorrect number of arguments passed to "
  14611. "QTime::start(). This method takes no arguments.");
  14612. }
  14613. return QScriptValue();
  14614. }
  14615. /*:146*//*147:*/
  14616. #line 3586 "./typica.w"
  14617. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  14618. {
  14619. QScriptValue retval;
  14620. if(context->argumentCount()==3||context->argumentCount()==4)
  14621. {
  14622. QTime self= getself<QTime> (context);
  14623. int arg1= 0;
  14624. int arg2= 0;
  14625. int arg3= 0;
  14626. int arg4= 0;
  14627. switch(context->argumentCount())
  14628. {
  14629. case 4:
  14630. arg4= argument<int> (3,context);
  14631. case 3:
  14632. arg3= argument<int> (2,context);
  14633. arg2= argument<int> (1,context);
  14634. arg1= argument<int> (0,context);
  14635. default:
  14636. break;
  14637. }
  14638. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  14639. }
  14640. else
  14641. {
  14642. context->throwError("Incorrect number of arguments passed to "
  14643. "QTime::setHMS(). This method takes three or "
  14644. "four integer arguments.");
  14645. }
  14646. return retval;
  14647. }
  14648. /*:147*//*148:*/
  14649. #line 3622 "./typica.w"
  14650. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  14651. {
  14652. QScriptValue retval;
  14653. if(context->argumentCount()==1)
  14654. {
  14655. QTime self= getself<QTime> (context);
  14656. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  14657. }
  14658. else
  14659. {
  14660. context->throwError("Incorrect number of arguments passed to "
  14661. "QTime::toString(). This method takes one QString "
  14662. "as an argument.");
  14663. }
  14664. return retval;
  14665. }
  14666. /*:148*//*149:*/
  14667. #line 3643 "./typica.w"
  14668. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  14669. {
  14670. QScriptValue object;
  14671. object= engine->toScriptValue<QTime> (QTime::currentTime());
  14672. setQTimeProperties(object,engine);
  14673. return object;
  14674. }
  14675. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  14676. {
  14677. QScriptValue object;
  14678. if(context->argumentCount()==2)
  14679. {
  14680. QString time= argument<QString> (0,context);
  14681. QString format= argument<QString> (1,context);
  14682. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  14683. setQTimeProperties(object,engine);
  14684. }
  14685. else
  14686. {
  14687. context->throwError("Incorrect number of arguments passed to "
  14688. "QTime::fromString(). This method takes two "
  14689. "string arguments.");
  14690. }
  14691. return object;
  14692. }
  14693. /*:149*//*150:*/
  14694. #line 3674 "./typica.w"
  14695. template<> QTime argument(int arg,QScriptContext*context)
  14696. {
  14697. return qscriptvalue_cast<QTime> (context->argument(arg));
  14698. }
  14699. /*:150*//*152:*/
  14700. #line 3692 "./typica.w"
  14701. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  14702. {
  14703. setQFrameProperties(value,engine);
  14704. }
  14705. /*:152*//*154:*/
  14706. #line 3706 "./typica.w"
  14707. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  14708. {
  14709. setQAbstractScrollAreaProperties(value,engine);
  14710. }
  14711. /*:154*//*156:*/
  14712. #line 3720 "./typica.w"
  14713. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  14714. {
  14715. setQAbstractScrollAreaProperties(value,engine);
  14716. }
  14717. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  14718. {
  14719. setQAbstractItemViewProperties(value,engine);
  14720. }
  14721. /*:156*//*159:*/
  14722. #line 3753 "./typica.w"
  14723. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  14724. {
  14725. QScriptValue object= engine->newQObject(new QPushButton());
  14726. setQPushButtonProperties(object,engine);
  14727. return object;
  14728. }
  14729. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  14730. {
  14731. setQAbstractButtonProperties(value,engine);
  14732. }
  14733. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  14734. {
  14735. setQWidgetProperties(value,engine);
  14736. }
  14737. /*:159*//*166:*/
  14738. #line 3865 "./typica.w"
  14739. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  14740. {
  14741. SqlQueryConnection*obj= new SqlQueryConnection();
  14742. QScriptValue object=
  14743. engine->toScriptValue<void*> (obj);
  14744. setQSqlQueryProperties(object,engine);
  14745. return object;
  14746. }
  14747. /*:166*//*167:*/
  14748. #line 3878 "./typica.w"
  14749. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  14750. {
  14751. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  14752. value.setProperty("bindFileData",
  14753. engine->newFunction(QSqlQuery_bindFileData));
  14754. value.setProperty("bindDeviceData",
  14755. engine->newFunction(QSqlQuery_bindDeviceData));
  14756. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  14757. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  14758. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  14759. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  14760. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  14761. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  14762. }
  14763. /*:167*//*168:*/
  14764. #line 3896 "./typica.w"
  14765. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  14766. {
  14767. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  14768. QScriptValue retval;
  14769. if(context->argumentCount()==1)
  14770. {
  14771. retval= QScriptValue(engine,
  14772. q->exec(argument<QString> (0,context)));
  14773. }
  14774. else
  14775. {
  14776. retval= QScriptValue(engine,q->exec());
  14777. }
  14778. if(q->lastError().isValid())
  14779. {
  14780. qDebug()<<q->lastQuery();
  14781. qDebug()<<q->lastError().text();
  14782. }
  14783. return retval;
  14784. }
  14785. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  14786. {
  14787. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14788. return QScriptValue(query->lastQuery());
  14789. }
  14790. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  14791. {
  14792. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14793. return QScriptValue(engine,query->next());
  14794. }
  14795. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  14796. {
  14797. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14798. return QScriptValue(engine,
  14799. query->value(argument<int> (0,context)).toString());
  14800. }
  14801. /*:168*//*169:*/
  14802. #line 3940 "./typica.w"
  14803. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  14804. {
  14805. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14806. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  14807. }
  14808. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  14809. {
  14810. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14811. query->bindValue(argument<QString> (0,context),
  14812. argument<QVariant> (1,context));
  14813. return QScriptValue();
  14814. }
  14815. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  14816. QScriptEngine*)
  14817. {
  14818. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14819. QString placeholder= argument<QString> (0,context);
  14820. QString filename= argument<QString> (1,context);
  14821. QFile file(filename);
  14822. QByteArray data;
  14823. if(file.open(QIODevice::ReadOnly))
  14824. {
  14825. data= file.readAll();
  14826. file.close();
  14827. }
  14828. query->bindValue(placeholder,data);
  14829. return QScriptValue();
  14830. }
  14831. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  14832. QScriptEngine*)
  14833. {
  14834. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14835. QString placeholder= argument<QString> (0,context);
  14836. QIODevice*device= argument<QIODevice*> (1,context);
  14837. device->reset();
  14838. QByteArray data;
  14839. data= device->readAll();
  14840. query->bindValue(placeholder,data);
  14841. return QScriptValue();
  14842. }
  14843. /*:169*//*170:*/
  14844. #line 3992 "./typica.w"
  14845. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  14846. {
  14847. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  14848. delete query;
  14849. return QScriptValue::UndefinedValue;
  14850. }
  14851. /*:170*//*173:*/
  14852. #line 4037 "./typica.w"
  14853. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  14854. {
  14855. QFileInfo info(argument<QString> (0,context));
  14856. QScriptValue retval(engine,info.baseName());
  14857. return retval;
  14858. }
  14859. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  14860. {
  14861. QFileInfo info(argument<QString> (0,context));
  14862. QDir dir= info.dir();
  14863. QScriptValue retval(engine,dir.path());
  14864. return retval;
  14865. }
  14866. /*:173*//*174:*/
  14867. #line 4056 "./typica.w"
  14868. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  14869. {
  14870. SqlQueryConnection h;
  14871. QSqlQuery*query= h.operator->();
  14872. QString q= "SELECT file FROM files WHERE id = :file";
  14873. query->prepare(q);
  14874. query->bindValue(":file",argument<int> (0,context));
  14875. query->exec();
  14876. query->next();
  14877. QByteArray array= query->value(0).toByteArray();
  14878. QFile file(argument<QString> (1,context));
  14879. file.open(QIODevice::WriteOnly);
  14880. file.write(array);
  14881. file.close();
  14882. return QScriptValue();
  14883. }
  14884. /*:174*//*175:*/
  14885. #line 4077 "./typica.w"
  14886. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  14887. {
  14888. QString source= argument<QString> (0,context);
  14889. source.remove(0,1);
  14890. source.chop(1);
  14891. QStringList elements= source.split(",");
  14892. QString element;
  14893. QScriptValue dest= engine->newArray(elements.size());
  14894. int i= 0;
  14895. foreach(element,elements)
  14896. {
  14897. if(element.startsWith("\"")&&element.endsWith("\""))
  14898. {
  14899. element.chop(1);
  14900. element= element.remove(0,1);
  14901. }
  14902. dest.setProperty(i,QScriptValue(engine,element));
  14903. i++;
  14904. }
  14905. return dest;
  14906. }
  14907. /*:175*//*176:*/
  14908. #line 4103 "./typica.w"
  14909. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  14910. {
  14911. QString font= argument<QString> (0,context);
  14912. QString classname;
  14913. if(context->argumentCount()> 1)
  14914. {
  14915. classname= argument<QString> (1,context);
  14916. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  14917. }
  14918. else
  14919. {
  14920. QApplication::setFont(QFont(font));
  14921. }
  14922. return QScriptValue();
  14923. }
  14924. /*:176*//*177:*/
  14925. #line 4123 "./typica.w"
  14926. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  14927. {
  14928. SqlQueryConnection h;
  14929. QSqlQuery*query= h.operator->();
  14930. QString q= "SELECT file FROM files WHERE id = :file";
  14931. query->prepare(q);
  14932. query->bindValue(":file",argument<int> (0,context));
  14933. query->exec();
  14934. query->next();
  14935. QByteArray array= query->value(0).toByteArray();
  14936. QBuffer buffer(&array);
  14937. buffer.open(QIODevice::ReadOnly);
  14938. QXmlQuery xquery;
  14939. xquery.bindVariable("profile",&buffer);
  14940. QString xq;
  14941. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  14942. xquery.setQuery(xq);
  14943. QString result;
  14944. xquery.evaluateTo(&result);
  14945. return QScriptValue(result);
  14946. }
  14947. /*:177*//*178:*/
  14948. #line 4150 "./typica.w"
  14949. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  14950. {
  14951. QWidget::setTabOrder(argument<QWidget*> (0,context),
  14952. argument<QWidget*> (1,context));
  14953. return QScriptValue();
  14954. }
  14955. /*:178*//*185:*/
  14956. #line 4395 "./typica.w"
  14957. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  14958. {
  14959. QString targetID= argument<QString> (0,context);
  14960. QDomNode element;
  14961. QScriptValue object;
  14962. /*187:*/
  14963. #line 4442 "./typica.w"
  14964. QDomNodeList windows=
  14965. AppInstance->configuration()->documentElement().elementsByTagName("window");
  14966. QDomNode nullNode;
  14967. int i= 0;
  14968. element= nullNode;
  14969. while(i<windows.count())
  14970. {
  14971. element= windows.at(i);
  14972. QDomNamedNodeMap attributes= element.attributes();
  14973. if(attributes.contains("id"))
  14974. {
  14975. if(attributes.namedItem("id").toAttr().value()==targetID)
  14976. {
  14977. break;
  14978. }
  14979. }
  14980. element= nullNode;
  14981. i++;
  14982. }
  14983. /*:187*/
  14984. #line 4401 "./typica.w"
  14985. if(!element.isNull())
  14986. {
  14987. /*188:*/
  14988. #line 4474 "./typica.w"
  14989. ScriptQMainWindow*window= new ScriptQMainWindow;
  14990. window->setObjectName(targetID);
  14991. object= engine->newQObject(window);
  14992. setQMainWindowProperties(object,engine);
  14993. QWidget*central= new(QWidget);
  14994. central->setParent(window);
  14995. central->setObjectName("centralWidget");
  14996. window->setCentralWidget(central);
  14997. if(element.hasChildNodes())
  14998. {
  14999. /*189:*/
  15000. #line 4509 "./typica.w"
  15001. QStack<QWidget*> widgetStack;
  15002. QStack<QLayout*> layoutStack;
  15003. QString windowScript;
  15004. widgetStack.push(central);
  15005. QDomNodeList windowChildren= element.childNodes();
  15006. int i= 0;
  15007. while(i<windowChildren.count())
  15008. {
  15009. QDomNode current;
  15010. QDomElement element;
  15011. current= windowChildren.at(i);
  15012. if(current.isElement())
  15013. {
  15014. element= current.toElement();
  15015. if(element.tagName()=="program")
  15016. {
  15017. windowScript.append(element.text());
  15018. }
  15019. else if(element.tagName()=="layout")
  15020. {
  15021. addLayoutToWidget(element,&widgetStack,&layoutStack);
  15022. }
  15023. else if(element.tagName()=="menu")
  15024. {
  15025. /*190:*/
  15026. #line 4556 "./typica.w"
  15027. QMenuBar*bar= window->menuBar();
  15028. bar->setParent(window);
  15029. bar->setObjectName("menuBar");
  15030. if(element.hasAttribute("name"))
  15031. {
  15032. QMenu*menu= bar->addMenu(element.attribute("name"));
  15033. menu->setParent(bar);
  15034. if(element.hasAttribute("type"))
  15035. {
  15036. if(element.attribute("type")=="reports")
  15037. {
  15038. if(element.hasAttribute("src"))
  15039. {
  15040. /*624:*/
  15041. #line 13542 "./typica.w"
  15042. QSettings settings;
  15043. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  15044. toString()).
  15045. arg(element.attribute("src"));
  15046. QDir::addSearchPath("reports",reportDirectory);
  15047. QDir directory(reportDirectory);
  15048. directory.setFilter(QDir::Files);
  15049. directory.setSorting(QDir::Name);
  15050. QStringList nameFilter;
  15051. nameFilter<<"*.xml";
  15052. directory.setNameFilters(nameFilter);
  15053. QFileInfoList reportFiles= directory.entryInfoList();
  15054. for(int i= 0;i<reportFiles.size();i++)
  15055. {
  15056. QFileInfo reportFile= reportFiles.at(i);
  15057. /*628:*/
  15058. #line 13622 "./typica.w"
  15059. QString path= reportFile.absoluteFilePath();
  15060. QFile file(path);
  15061. if(file.open(QIODevice::ReadOnly))
  15062. {
  15063. QDomDocument document;
  15064. document.setContent(&file,true);
  15065. QDomElement root= document.documentElement();
  15066. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  15067. if(!titleNode.isNull())
  15068. {
  15069. QDomElement titleElement= titleNode.toElement();
  15070. QString title= titleElement.text();
  15071. if(!title.isEmpty())
  15072. {
  15073. QStringList hierarchy= title.split(":->");
  15074. QMenu*insertionPoint= menu;
  15075. /*629:*/
  15076. #line 13649 "./typica.w"
  15077. for(int j= 0;j<hierarchy.size()-1;j++)
  15078. {
  15079. QObjectList menuList= insertionPoint->children();
  15080. bool menuFound= false;
  15081. for(int k= 0;k<menuList.size();k++)
  15082. {
  15083. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  15084. if(currentItem)
  15085. {
  15086. if(currentItem->title()==hierarchy.at(j))
  15087. {
  15088. menuFound= true;
  15089. insertionPoint= currentItem;
  15090. break;
  15091. }
  15092. }
  15093. }
  15094. if(!menuFound)
  15095. {
  15096. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  15097. }
  15098. }
  15099. /*:629*/
  15100. #line 13639 "./typica.w"
  15101. ReportAction*action= new ReportAction(path,hierarchy.last());
  15102. insertionPoint->addAction(action);
  15103. }
  15104. }
  15105. }
  15106. /*:628*/
  15107. #line 13558 "./typica.w"
  15108. }
  15109. /*:624*/
  15110. #line 4570 "./typica.w"
  15111. }
  15112. }
  15113. }
  15114. if(element.hasChildNodes())
  15115. {
  15116. /*191:*/
  15117. #line 4583 "./typica.w"
  15118. QDomNodeList menuItems= element.childNodes();
  15119. int j= 0;
  15120. while(j<menuItems.count())
  15121. {
  15122. QDomNode item= menuItems.at(j);
  15123. if(item.isElement())
  15124. {
  15125. QDomElement itemElement= item.toElement();
  15126. if(itemElement.tagName()=="item")
  15127. {
  15128. QAction*itemAction= new QAction(itemElement.text(),menu);
  15129. if(itemElement.hasAttribute("id"))
  15130. {
  15131. itemAction->setObjectName(itemElement.attribute("id"));
  15132. }
  15133. if(itemElement.hasAttribute("shortcut"))
  15134. {
  15135. itemAction->setShortcut(itemElement.attribute("shortcut"));
  15136. }
  15137. menu->addAction(itemAction);
  15138. }
  15139. else if(itemElement.tagName()=="separator")
  15140. {
  15141. menu->addSeparator();
  15142. }
  15143. }
  15144. j++;
  15145. }
  15146. #line 1 "./helpmenu.w"
  15147. /*:191*/
  15148. #line 4576 "./typica.w"
  15149. }
  15150. }
  15151. /*:190*/
  15152. #line 4534 "./typica.w"
  15153. }
  15154. }
  15155. i++;
  15156. }
  15157. QScriptValue oldThis= context->thisObject();
  15158. context->setThisObject(object);
  15159. QScriptValue result= engine->evaluate(windowScript);
  15160. /*182:*/
  15161. #line 4291 "./typica.w"
  15162. if(engine->hasUncaughtException())
  15163. {
  15164. int line= engine->uncaughtExceptionLineNumber();
  15165. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  15166. result.toString();
  15167. QString trace;
  15168. foreach(trace,engine->uncaughtExceptionBacktrace())
  15169. {
  15170. qDebug()<<trace;
  15171. }
  15172. }
  15173. /*:182*/
  15174. #line 4542 "./typica.w"
  15175. context->setThisObject(oldThis);
  15176. /*:189*/
  15177. #line 4485 "./typica.w"
  15178. }
  15179. /*192:*/
  15180. #line 9 "./helpmenu.w"
  15181. HelpMenu*helpMenu= new HelpMenu();
  15182. window->menuBar()->addMenu(helpMenu);
  15183. /*:192*/
  15184. #line 4487 "./typica.w"
  15185. window->show();
  15186. /*:188*/
  15187. #line 4404 "./typica.w"
  15188. }
  15189. return object;
  15190. }
  15191. /*:185*//*186:*/
  15192. #line 4415 "./typica.w"
  15193. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  15194. {
  15195. QString targetID= argument<QString> (0,context);
  15196. QFile file(QString("reports:%1").arg(targetID));
  15197. QScriptValue object;
  15198. if(file.open(QIODevice::ReadOnly))
  15199. {
  15200. QDomDocument document;
  15201. document.setContent(&file,true);
  15202. QDomElement element= document.documentElement();
  15203. if(!element.isNull())
  15204. {
  15205. /*188:*/
  15206. #line 4474 "./typica.w"
  15207. ScriptQMainWindow*window= new ScriptQMainWindow;
  15208. window->setObjectName(targetID);
  15209. object= engine->newQObject(window);
  15210. setQMainWindowProperties(object,engine);
  15211. QWidget*central= new(QWidget);
  15212. central->setParent(window);
  15213. central->setObjectName("centralWidget");
  15214. window->setCentralWidget(central);
  15215. if(element.hasChildNodes())
  15216. {
  15217. /*189:*/
  15218. #line 4509 "./typica.w"
  15219. QStack<QWidget*> widgetStack;
  15220. QStack<QLayout*> layoutStack;
  15221. QString windowScript;
  15222. widgetStack.push(central);
  15223. QDomNodeList windowChildren= element.childNodes();
  15224. int i= 0;
  15225. while(i<windowChildren.count())
  15226. {
  15227. QDomNode current;
  15228. QDomElement element;
  15229. current= windowChildren.at(i);
  15230. if(current.isElement())
  15231. {
  15232. element= current.toElement();
  15233. if(element.tagName()=="program")
  15234. {
  15235. windowScript.append(element.text());
  15236. }
  15237. else if(element.tagName()=="layout")
  15238. {
  15239. addLayoutToWidget(element,&widgetStack,&layoutStack);
  15240. }
  15241. else if(element.tagName()=="menu")
  15242. {
  15243. /*190:*/
  15244. #line 4556 "./typica.w"
  15245. QMenuBar*bar= window->menuBar();
  15246. bar->setParent(window);
  15247. bar->setObjectName("menuBar");
  15248. if(element.hasAttribute("name"))
  15249. {
  15250. QMenu*menu= bar->addMenu(element.attribute("name"));
  15251. menu->setParent(bar);
  15252. if(element.hasAttribute("type"))
  15253. {
  15254. if(element.attribute("type")=="reports")
  15255. {
  15256. if(element.hasAttribute("src"))
  15257. {
  15258. /*624:*/
  15259. #line 13542 "./typica.w"
  15260. QSettings settings;
  15261. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  15262. toString()).
  15263. arg(element.attribute("src"));
  15264. QDir::addSearchPath("reports",reportDirectory);
  15265. QDir directory(reportDirectory);
  15266. directory.setFilter(QDir::Files);
  15267. directory.setSorting(QDir::Name);
  15268. QStringList nameFilter;
  15269. nameFilter<<"*.xml";
  15270. directory.setNameFilters(nameFilter);
  15271. QFileInfoList reportFiles= directory.entryInfoList();
  15272. for(int i= 0;i<reportFiles.size();i++)
  15273. {
  15274. QFileInfo reportFile= reportFiles.at(i);
  15275. /*628:*/
  15276. #line 13622 "./typica.w"
  15277. QString path= reportFile.absoluteFilePath();
  15278. QFile file(path);
  15279. if(file.open(QIODevice::ReadOnly))
  15280. {
  15281. QDomDocument document;
  15282. document.setContent(&file,true);
  15283. QDomElement root= document.documentElement();
  15284. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  15285. if(!titleNode.isNull())
  15286. {
  15287. QDomElement titleElement= titleNode.toElement();
  15288. QString title= titleElement.text();
  15289. if(!title.isEmpty())
  15290. {
  15291. QStringList hierarchy= title.split(":->");
  15292. QMenu*insertionPoint= menu;
  15293. /*629:*/
  15294. #line 13649 "./typica.w"
  15295. for(int j= 0;j<hierarchy.size()-1;j++)
  15296. {
  15297. QObjectList menuList= insertionPoint->children();
  15298. bool menuFound= false;
  15299. for(int k= 0;k<menuList.size();k++)
  15300. {
  15301. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  15302. if(currentItem)
  15303. {
  15304. if(currentItem->title()==hierarchy.at(j))
  15305. {
  15306. menuFound= true;
  15307. insertionPoint= currentItem;
  15308. break;
  15309. }
  15310. }
  15311. }
  15312. if(!menuFound)
  15313. {
  15314. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  15315. }
  15316. }
  15317. /*:629*/
  15318. #line 13639 "./typica.w"
  15319. ReportAction*action= new ReportAction(path,hierarchy.last());
  15320. insertionPoint->addAction(action);
  15321. }
  15322. }
  15323. }
  15324. /*:628*/
  15325. #line 13558 "./typica.w"
  15326. }
  15327. /*:624*/
  15328. #line 4570 "./typica.w"
  15329. }
  15330. }
  15331. }
  15332. if(element.hasChildNodes())
  15333. {
  15334. /*191:*/
  15335. #line 4583 "./typica.w"
  15336. QDomNodeList menuItems= element.childNodes();
  15337. int j= 0;
  15338. while(j<menuItems.count())
  15339. {
  15340. QDomNode item= menuItems.at(j);
  15341. if(item.isElement())
  15342. {
  15343. QDomElement itemElement= item.toElement();
  15344. if(itemElement.tagName()=="item")
  15345. {
  15346. QAction*itemAction= new QAction(itemElement.text(),menu);
  15347. if(itemElement.hasAttribute("id"))
  15348. {
  15349. itemAction->setObjectName(itemElement.attribute("id"));
  15350. }
  15351. if(itemElement.hasAttribute("shortcut"))
  15352. {
  15353. itemAction->setShortcut(itemElement.attribute("shortcut"));
  15354. }
  15355. menu->addAction(itemAction);
  15356. }
  15357. else if(itemElement.tagName()=="separator")
  15358. {
  15359. menu->addSeparator();
  15360. }
  15361. }
  15362. j++;
  15363. }
  15364. #line 1 "./helpmenu.w"
  15365. /*:191*/
  15366. #line 4576 "./typica.w"
  15367. }
  15368. }
  15369. /*:190*/
  15370. #line 4534 "./typica.w"
  15371. }
  15372. }
  15373. i++;
  15374. }
  15375. QScriptValue oldThis= context->thisObject();
  15376. context->setThisObject(object);
  15377. QScriptValue result= engine->evaluate(windowScript);
  15378. /*182:*/
  15379. #line 4291 "./typica.w"
  15380. if(engine->hasUncaughtException())
  15381. {
  15382. int line= engine->uncaughtExceptionLineNumber();
  15383. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  15384. result.toString();
  15385. QString trace;
  15386. foreach(trace,engine->uncaughtExceptionBacktrace())
  15387. {
  15388. qDebug()<<trace;
  15389. }
  15390. }
  15391. /*:182*/
  15392. #line 4542 "./typica.w"
  15393. context->setThisObject(oldThis);
  15394. /*:189*/
  15395. #line 4485 "./typica.w"
  15396. }
  15397. /*192:*/
  15398. #line 9 "./helpmenu.w"
  15399. HelpMenu*helpMenu= new HelpMenu();
  15400. window->menuBar()->addMenu(helpMenu);
  15401. /*:192*/
  15402. #line 4487 "./typica.w"
  15403. window->show();
  15404. /*:188*/
  15405. #line 4428 "./typica.w"
  15406. }
  15407. file.close();
  15408. }
  15409. return object;
  15410. }
  15411. /*:186*//*204:*/
  15412. #line 4627 "./typica.w"
  15413. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  15414. QStack<QLayout*> *layoutStack)
  15415. {
  15416. if(element.hasAttribute("type"))
  15417. {
  15418. /*205:*/
  15419. #line 4648 "./typica.w"
  15420. QLayout*layout;
  15421. QString layoutType= element.attribute("type");
  15422. if(layoutType=="horizontal")
  15423. {
  15424. layout= new QHBoxLayout;
  15425. layoutStack->push(layout);
  15426. populateBoxLayout(element,widgetStack,layoutStack);
  15427. }
  15428. else if(layoutType=="vertical")
  15429. {
  15430. layout= new QVBoxLayout;
  15431. layoutStack->push(layout);
  15432. populateBoxLayout(element,widgetStack,layoutStack);
  15433. }
  15434. else if(layoutType=="grid")
  15435. {
  15436. layout= new QGridLayout;
  15437. layoutStack->push(layout);
  15438. populateGridLayout(element,widgetStack,layoutStack);
  15439. }
  15440. else if(layoutType=="stack")
  15441. {
  15442. layout= new QStackedLayout;
  15443. layoutStack->push(layout);
  15444. populateStackedLayout(element,widgetStack,layoutStack);
  15445. }
  15446. if(element.hasAttribute("id"))
  15447. {
  15448. layout->setObjectName(element.attribute("id"));
  15449. }
  15450. if(element.hasAttribute("spacing"))
  15451. {
  15452. layout->setSpacing(element.attribute("spacing").toInt());
  15453. }
  15454. if(element.hasAttribute("margin"))
  15455. {
  15456. int m= element.attribute("margin").toInt();
  15457. layout->setContentsMargins(m,m,m,m);
  15458. }
  15459. /*:205*/
  15460. #line 4633 "./typica.w"
  15461. QWidget*widget= widgetStack->top();
  15462. if(layout)
  15463. {
  15464. widget->setLayout(layout);
  15465. }
  15466. layoutStack->pop();
  15467. }
  15468. }
  15469. /*:204*//*206:*/
  15470. #line 4695 "./typica.w"
  15471. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15472. QStack<QLayout*> *layoutStack)
  15473. {
  15474. QDomNodeList children= element.childNodes();
  15475. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  15476. for(int i= 0;i<children.count();i++)
  15477. {
  15478. QDomNode current;
  15479. QDomElement currentElement;
  15480. current= children.at(i);
  15481. if(current.isElement())
  15482. {
  15483. currentElement= current.toElement();
  15484. if(currentElement.tagName()=="page")
  15485. {
  15486. QWidget*widget= new QWidget;
  15487. layout->addWidget(widget);
  15488. widgetStack->push(widget);
  15489. populateWidget(currentElement,widgetStack,layoutStack);
  15490. widgetStack->pop();
  15491. }
  15492. }
  15493. }
  15494. }
  15495. /*:206*//*207:*/
  15496. #line 4727 "./typica.w"
  15497. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15498. QStack<QLayout*> *layoutStack)
  15499. {
  15500. QDomNodeList children= element.childNodes();
  15501. int row= -1;
  15502. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  15503. for(int i= 0;i<children.count();i++)
  15504. {
  15505. QDomNode current;
  15506. QDomElement currentElement;
  15507. current= children.at(i);
  15508. if(current.isElement())
  15509. {
  15510. currentElement= current.toElement();
  15511. if(currentElement.tagName()=="row")
  15512. {
  15513. row++;
  15514. if(currentElement.hasAttribute("height"))
  15515. {
  15516. layout->setRowMinimumHeight(row,
  15517. currentElement.attribute("height").toInt());
  15518. }
  15519. if(currentElement.hasAttribute("stretch"))
  15520. {
  15521. layout->setRowStretch(row,
  15522. currentElement.attribute("stretch").toInt());
  15523. }
  15524. /*208:*/
  15525. #line 4783 "./typica.w"
  15526. int column= -1;
  15527. QDomNodeList rowChildren= currentElement.childNodes();
  15528. for(int j= 0;j<rowChildren.count();j++)
  15529. {
  15530. QDomNode columnNode;
  15531. QDomElement columnElement;
  15532. columnNode= rowChildren.at(j);
  15533. if(columnNode.isElement())
  15534. {
  15535. columnElement= columnNode.toElement();
  15536. if(columnElement.tagName()=="column")
  15537. {
  15538. column++;
  15539. if(columnElement.hasAttribute("column"))
  15540. {
  15541. column= columnElement.attribute("column").toInt();
  15542. }
  15543. if(columnElement.hasAttribute("width"))
  15544. {
  15545. layout->setColumnMinimumWidth(column,
  15546. columnElement.attribute("width").toInt());
  15547. }
  15548. if(columnElement.hasAttribute("stretch"))
  15549. {
  15550. layout->setColumnStretch(column,
  15551. columnElement.attribute("stretch").toInt());
  15552. }
  15553. int hspan= 1;
  15554. int vspan= 1;
  15555. if(columnElement.hasAttribute("rowspan"))
  15556. {
  15557. vspan= columnElement.attribute("rowspan").toInt();
  15558. }
  15559. if(columnElement.hasAttribute("colspan"))
  15560. {
  15561. hspan= columnElement.attribute("colspan").toInt();
  15562. }
  15563. QHBoxLayout*cell= new QHBoxLayout;
  15564. layout->addLayout(cell,row,column,vspan,hspan);
  15565. layoutStack->push(cell);
  15566. populateBoxLayout(columnElement,widgetStack,layoutStack);
  15567. layoutStack->pop();
  15568. }
  15569. }
  15570. }
  15571. /*:208*/
  15572. #line 4755 "./typica.w"
  15573. }
  15574. }
  15575. }
  15576. }
  15577. /*:207*//*209:*/
  15578. #line 4833 "./typica.w"
  15579. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15580. QStack<QLayout*> *layoutStack)
  15581. {
  15582. QDomNodeList children= element.childNodes();
  15583. for(int i= 0;i<children.count();i++)
  15584. {
  15585. QDomNode current;
  15586. QDomElement currentElement;
  15587. current= children.at(i);
  15588. if(current.isElement())
  15589. {
  15590. currentElement= current.toElement();
  15591. if(currentElement.tagName()=="button")
  15592. {
  15593. addButtonToLayout(currentElement,widgetStack,layoutStack);
  15594. }
  15595. else if(currentElement.tagName()=="calendar")
  15596. {
  15597. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  15598. }
  15599. else if(currentElement.tagName()=="decoration")
  15600. {
  15601. addDecorationToLayout(currentElement,widgetStack,
  15602. layoutStack);
  15603. }
  15604. else if(currentElement.tagName()=="layout")
  15605. {
  15606. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  15607. }
  15608. else if(currentElement.tagName()=="splitter")
  15609. {
  15610. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  15611. }
  15612. else if(currentElement.tagName()=="label")
  15613. {
  15614. QBoxLayout*layout=
  15615. qobject_cast<QBoxLayout*> (layoutStack->top());
  15616. QLabel*label= new QLabel(currentElement.text());
  15617. layout->addWidget(label);
  15618. }
  15619. else if(currentElement.tagName()=="lcdtemperature")
  15620. {
  15621. addTemperatureDisplayToLayout(currentElement,widgetStack,
  15622. layoutStack);
  15623. }
  15624. else if(currentElement.tagName()=="lcdtimer")
  15625. {
  15626. addTimerDisplayToLayout(currentElement,widgetStack,
  15627. layoutStack);
  15628. }
  15629. else if(currentElement.tagName()=="line")
  15630. {
  15631. addLineToLayout(currentElement,widgetStack,layoutStack);
  15632. }
  15633. else if(currentElement.tagName()=="report")
  15634. {
  15635. addReportToLayout(currentElement,widgetStack,layoutStack);
  15636. }
  15637. else if(currentElement.tagName()=="sqldrop")
  15638. {
  15639. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  15640. }
  15641. else if(currentElement.tagName()=="sqltablearray")
  15642. {
  15643. addSaltToLayout(currentElement,widgetStack,layoutStack);
  15644. }
  15645. else if(currentElement.tagName()=="sqlview")
  15646. {
  15647. addSqlQueryViewToLayout(currentElement,widgetStack,
  15648. layoutStack);
  15649. }
  15650. else if(currentElement.tagName()=="textarea")
  15651. {
  15652. addTextToLayout(currentElement,widgetStack,layoutStack);
  15653. }
  15654. else if(currentElement.tagName()=="spinbox")
  15655. {
  15656. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  15657. }
  15658. else if(currentElement.tagName()=="formarray")
  15659. {
  15660. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  15661. }
  15662. else if(currentElement.tagName()=="hscale")
  15663. {
  15664. addScaleControlToLayout(currentElement,widgetStack,
  15665. layoutStack);
  15666. }
  15667. else if(currentElement.tagName()=="vscale")
  15668. {
  15669. addIntensityControlToLayout(currentElement,widgetStack,
  15670. layoutStack);
  15671. }
  15672. else if(currentElement.tagName()=="webview")
  15673. {
  15674. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  15675. }
  15676. else if(currentElement.tagName()=="stretch")
  15677. {
  15678. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15679. layout->addStretch();
  15680. }
  15681. /*666:*/
  15682. #line 442 "./daterangeselector.w"
  15683. else if(currentElement.tagName()=="daterange")
  15684. {
  15685. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  15686. }
  15687. /*:666*/
  15688. #line 4936 "./typica.w"
  15689. }
  15690. }
  15691. }
  15692. /*:209*//*210:*/
  15693. #line 4944 "./typica.w"
  15694. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15695. QStack<QLayout*> *layoutStack)
  15696. {
  15697. QLayout*targetLayout= layoutStack->pop();
  15698. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  15699. if(element.hasAttribute("type"))
  15700. {
  15701. /*205:*/
  15702. #line 4648 "./typica.w"
  15703. QLayout*layout;
  15704. QString layoutType= element.attribute("type");
  15705. if(layoutType=="horizontal")
  15706. {
  15707. layout= new QHBoxLayout;
  15708. layoutStack->push(layout);
  15709. populateBoxLayout(element,widgetStack,layoutStack);
  15710. }
  15711. else if(layoutType=="vertical")
  15712. {
  15713. layout= new QVBoxLayout;
  15714. layoutStack->push(layout);
  15715. populateBoxLayout(element,widgetStack,layoutStack);
  15716. }
  15717. else if(layoutType=="grid")
  15718. {
  15719. layout= new QGridLayout;
  15720. layoutStack->push(layout);
  15721. populateGridLayout(element,widgetStack,layoutStack);
  15722. }
  15723. else if(layoutType=="stack")
  15724. {
  15725. layout= new QStackedLayout;
  15726. layoutStack->push(layout);
  15727. populateStackedLayout(element,widgetStack,layoutStack);
  15728. }
  15729. if(element.hasAttribute("id"))
  15730. {
  15731. layout->setObjectName(element.attribute("id"));
  15732. }
  15733. if(element.hasAttribute("spacing"))
  15734. {
  15735. layout->setSpacing(element.attribute("spacing").toInt());
  15736. }
  15737. if(element.hasAttribute("margin"))
  15738. {
  15739. int m= element.attribute("margin").toInt();
  15740. layout->setContentsMargins(m,m,m,m);
  15741. }
  15742. /*:205*/
  15743. #line 4952 "./typica.w"
  15744. boxLayout->addLayout(layout);
  15745. layoutStack->pop();
  15746. }
  15747. layoutStack->push(targetLayout);
  15748. }
  15749. /*:210*//*211:*/
  15750. #line 4963 "./typica.w"
  15751. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15752. QStack<QLayout*> *layoutStack)
  15753. {
  15754. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15755. QSplitter*splitter= new(QSplitter);
  15756. layout->addWidget(splitter);
  15757. /*212:*/
  15758. #line 4976 "./typica.w"
  15759. QString orientation= element.attribute("type");
  15760. if(orientation=="horizontal")
  15761. {
  15762. splitter->setOrientation(Qt::Horizontal);
  15763. }
  15764. else if(orientation=="vertical")
  15765. {
  15766. splitter->setOrientation(Qt::Vertical);
  15767. }
  15768. QString id= element.attribute("id");
  15769. if(!id.isEmpty())
  15770. {
  15771. splitter->setObjectName(id);
  15772. }
  15773. if(element.hasChildNodes())
  15774. {
  15775. widgetStack->push(splitter);
  15776. populateSplitter(element,widgetStack,layoutStack);
  15777. widgetStack->pop();
  15778. }
  15779. /*:212*/
  15780. #line 4970 "./typica.w"
  15781. }
  15782. /*:211*//*213:*/
  15783. #line 5002 "./typica.w"
  15784. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15785. QStack<QLayout*> *layoutStack)
  15786. {
  15787. QDomNodeList children= element.childNodes();
  15788. for(int i= 0;i<children.count();i++)
  15789. {
  15790. QDomNode current;
  15791. QDomElement currentElement;
  15792. current= children.at(i);
  15793. if(current.isElement())
  15794. {
  15795. currentElement= current.toElement();
  15796. if(currentElement.tagName()=="decoration")
  15797. {
  15798. addDecorationToSplitter(currentElement,widgetStack,
  15799. layoutStack);
  15800. }
  15801. else if(currentElement.tagName()=="graph")
  15802. {
  15803. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  15804. }
  15805. else if(currentElement.tagName()=="splitter")
  15806. {
  15807. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  15808. }
  15809. else if(currentElement.tagName()=="lcdtemperature")
  15810. {
  15811. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  15812. layoutStack);
  15813. }
  15814. else if(currentElement.tagName()=="lcdtimer")
  15815. {
  15816. addTimerDisplayToSplitter(currentElement,widgetStack,
  15817. layoutStack);
  15818. }
  15819. else if(currentElement.tagName()=="measurementtable")
  15820. {
  15821. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  15822. }
  15823. else if(currentElement.tagName()=="widget")
  15824. {
  15825. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  15826. }
  15827. }
  15828. }
  15829. }
  15830. /*:213*//*214:*/
  15831. #line 5052 "./typica.w"
  15832. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15833. QStack<QLayout*> *layoutStack)
  15834. {
  15835. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  15836. QSplitter*splitter= new(QSplitter);
  15837. splitter->setParent(parent);
  15838. parent->addWidget(splitter);
  15839. /*212:*/
  15840. #line 4976 "./typica.w"
  15841. QString orientation= element.attribute("type");
  15842. if(orientation=="horizontal")
  15843. {
  15844. splitter->setOrientation(Qt::Horizontal);
  15845. }
  15846. else if(orientation=="vertical")
  15847. {
  15848. splitter->setOrientation(Qt::Vertical);
  15849. }
  15850. QString id= element.attribute("id");
  15851. if(!id.isEmpty())
  15852. {
  15853. splitter->setObjectName(id);
  15854. }
  15855. if(element.hasChildNodes())
  15856. {
  15857. widgetStack->push(splitter);
  15858. populateSplitter(element,widgetStack,layoutStack);
  15859. widgetStack->pop();
  15860. }
  15861. /*:212*/
  15862. #line 5060 "./typica.w"
  15863. }
  15864. /*:214*//*215:*/
  15865. #line 5069 "./typica.w"
  15866. void addTemperatureDisplayToSplitter(QDomElement element,
  15867. QStack<QWidget*> *widgetStack,
  15868. QStack<QLayout*> *)
  15869. {
  15870. TemperatureDisplay*display= new(TemperatureDisplay);
  15871. if(element.hasAttribute("id"))
  15872. {
  15873. display->setObjectName(element.attribute("id"));
  15874. }
  15875. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15876. splitter->addWidget(display);
  15877. }
  15878. void addTemperatureDisplayToLayout(QDomElement element,
  15879. QStack<QWidget*> *,
  15880. QStack<QLayout*> *layoutStack)
  15881. {
  15882. TemperatureDisplay*display= new(TemperatureDisplay);
  15883. if(element.hasAttribute("id"))
  15884. {
  15885. display->setObjectName(element.attribute("id"));
  15886. }
  15887. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15888. layout->addWidget(display);
  15889. }
  15890. /*:215*//*216:*/
  15891. #line 5100 "./typica.w"
  15892. void addTimerDisplayToSplitter(QDomElement element,
  15893. QStack<QWidget*> *widgetStack,
  15894. QStack<QLayout*> *)
  15895. {
  15896. TimerDisplay*display= new(TimerDisplay);
  15897. if(element.hasAttribute("id"))
  15898. {
  15899. display->setObjectName(element.attribute("id"));
  15900. }
  15901. if(element.hasAttribute("format"))
  15902. {
  15903. display->setDisplayFormat(element.attribute("format"));
  15904. }
  15905. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15906. splitter->addWidget(display);
  15907. }
  15908. void addTimerDisplayToLayout(QDomElement element,
  15909. QStack<QWidget*> *,
  15910. QStack<QLayout*> *layoutStack)
  15911. {
  15912. TimerDisplay*display= new(TimerDisplay);
  15913. if(element.hasAttribute("id"))
  15914. {
  15915. display->setObjectName(element.attribute("id"));
  15916. }
  15917. if(element.hasAttribute("format"))
  15918. {
  15919. display->setDisplayFormat(element.attribute("format"));
  15920. }
  15921. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15922. layout->addWidget(display);
  15923. }
  15924. /*:216*//*217:*/
  15925. #line 5138 "./typica.w"
  15926. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  15927. QStack<QLayout*> *layoutStack)
  15928. {
  15929. /*218:*/
  15930. #line 5159 "./typica.w"
  15931. QString labelText= element.attribute("name");
  15932. Qt::Orientations orientation= Qt::Horizontal;
  15933. if(element.hasAttribute("type"))
  15934. {
  15935. if(element.attribute("type")=="horizontal")
  15936. {
  15937. orientation= Qt::Horizontal;
  15938. }
  15939. else if(element.attribute("type")=="vertical")
  15940. {
  15941. orientation= Qt::Vertical;
  15942. }
  15943. }
  15944. /*219:*/
  15945. #line 5184 "./typica.w"
  15946. QWidget*theWidget= NULL;
  15947. QDomNodeList children= element.childNodes();
  15948. for(int i= 0;i<children.count();i++)
  15949. {
  15950. QDomNode item= children.at(i);
  15951. if(item.isElement())
  15952. {
  15953. QDomElement itemElement= item.toElement();
  15954. if(itemElement.tagName()=="lcdtemperature")
  15955. {
  15956. TemperatureDisplay*display= new TemperatureDisplay;
  15957. if(itemElement.hasAttribute("id"))
  15958. {
  15959. display->setObjectName(itemElement.attribute("id"));
  15960. }
  15961. theWidget= display;
  15962. }
  15963. else if(itemElement.tagName()=="lcdtimer")
  15964. {
  15965. TimerDisplay*display= new TimerDisplay;
  15966. if(itemElement.hasAttribute("id"))
  15967. {
  15968. display->setObjectName(itemElement.attribute("id"));
  15969. }
  15970. if(itemElement.hasAttribute("format"))
  15971. {
  15972. display->setDisplayFormat(itemElement.attribute("format"));
  15973. }
  15974. theWidget= display;
  15975. }
  15976. }
  15977. }
  15978. /*:219*/
  15979. #line 5173 "./typica.w"
  15980. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  15981. orientation);
  15982. if(element.hasAttribute("id"))
  15983. {
  15984. decoration->setObjectName(element.attribute("id"));
  15985. }
  15986. /*:218*/
  15987. #line 5142 "./typica.w"
  15988. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15989. layout->addWidget(decoration);
  15990. }
  15991. void addDecorationToSplitter(QDomElement element,
  15992. QStack<QWidget*> *widgetStack,
  15993. QStack<QLayout*> *)
  15994. {
  15995. /*218:*/
  15996. #line 5159 "./typica.w"
  15997. QString labelText= element.attribute("name");
  15998. Qt::Orientations orientation= Qt::Horizontal;
  15999. if(element.hasAttribute("type"))
  16000. {
  16001. if(element.attribute("type")=="horizontal")
  16002. {
  16003. orientation= Qt::Horizontal;
  16004. }
  16005. else if(element.attribute("type")=="vertical")
  16006. {
  16007. orientation= Qt::Vertical;
  16008. }
  16009. }
  16010. /*219:*/
  16011. #line 5184 "./typica.w"
  16012. QWidget*theWidget= NULL;
  16013. QDomNodeList children= element.childNodes();
  16014. for(int i= 0;i<children.count();i++)
  16015. {
  16016. QDomNode item= children.at(i);
  16017. if(item.isElement())
  16018. {
  16019. QDomElement itemElement= item.toElement();
  16020. if(itemElement.tagName()=="lcdtemperature")
  16021. {
  16022. TemperatureDisplay*display= new TemperatureDisplay;
  16023. if(itemElement.hasAttribute("id"))
  16024. {
  16025. display->setObjectName(itemElement.attribute("id"));
  16026. }
  16027. theWidget= display;
  16028. }
  16029. else if(itemElement.tagName()=="lcdtimer")
  16030. {
  16031. TimerDisplay*display= new TimerDisplay;
  16032. if(itemElement.hasAttribute("id"))
  16033. {
  16034. display->setObjectName(itemElement.attribute("id"));
  16035. }
  16036. if(itemElement.hasAttribute("format"))
  16037. {
  16038. display->setDisplayFormat(itemElement.attribute("format"));
  16039. }
  16040. theWidget= display;
  16041. }
  16042. }
  16043. }
  16044. /*:219*/
  16045. #line 5173 "./typica.w"
  16046. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  16047. orientation);
  16048. if(element.hasAttribute("id"))
  16049. {
  16050. decoration->setObjectName(element.attribute("id"));
  16051. }
  16052. /*:218*/
  16053. #line 5151 "./typica.w"
  16054. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16055. splitter->addWidget(decoration);
  16056. }
  16057. /*:217*//*220:*/
  16058. #line 5223 "./typica.w"
  16059. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  16060. QStack<QLayout*> *layoutStack)
  16061. {
  16062. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16063. QWidget*widget= new QWidget;
  16064. if(element.hasAttribute("id"))
  16065. {
  16066. widget->setObjectName(element.attribute("id"));
  16067. }
  16068. splitter->addWidget(widget);
  16069. if(element.hasChildNodes())
  16070. {
  16071. widgetStack->push(widget);
  16072. populateWidget(element,widgetStack,layoutStack);
  16073. widgetStack->pop();
  16074. }
  16075. }
  16076. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  16077. QStack<QLayout*> *layoutStack)
  16078. {
  16079. QDomNodeList children= element.childNodes();
  16080. for(int i= 0;i<children.count();i++)
  16081. {
  16082. QDomNode current;
  16083. QDomElement currentElement;
  16084. current= children.at(i);
  16085. if(current.isElement())
  16086. {
  16087. currentElement= current.toElement();
  16088. if(currentElement.tagName()=="layout")
  16089. {
  16090. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  16091. }
  16092. }
  16093. }
  16094. }
  16095. /*:220*//*221:*/
  16096. #line 5266 "./typica.w"
  16097. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  16098. QStack<QLayout*> *layoutStack)
  16099. {
  16100. QAbstractButton*button= NULL;
  16101. QString text= element.attribute("name");
  16102. if(element.hasAttribute("type"))
  16103. {
  16104. QString type= element.attribute("type");
  16105. if(type=="annotation")
  16106. {
  16107. AnnotationButton*abutton= new AnnotationButton(text);
  16108. if(element.hasAttribute("annotation"))
  16109. {
  16110. abutton->setAnnotation(element.attribute("annotation"));
  16111. }
  16112. if(element.hasAttribute("series"))
  16113. {
  16114. abutton->setTemperatureColumn(element.attribute("series").
  16115. toInt());
  16116. }
  16117. if(element.hasAttribute("column"))
  16118. {
  16119. abutton->setAnnotationColumn(element.attribute("column").
  16120. toInt());
  16121. }
  16122. button= abutton;
  16123. }
  16124. else if(type=="check")
  16125. {
  16126. button= new QCheckBox(text);
  16127. }
  16128. else if(type=="push")
  16129. {
  16130. button= new QPushButton(text);
  16131. }
  16132. }
  16133. if(element.hasAttribute("id"))
  16134. {
  16135. button->setObjectName(element.attribute("id"));
  16136. }
  16137. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16138. layout->addWidget(button);
  16139. }
  16140. /*:221*//*222:*/
  16141. #line 5318 "./typica.w"
  16142. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  16143. QStack<QLayout*> *layoutStack)
  16144. {
  16145. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  16146. if(element.hasAttribute("pretext"))
  16147. {
  16148. box->setPretext(element.attribute("pretext"));
  16149. }
  16150. if(element.hasAttribute("posttext"))
  16151. {
  16152. box->setPosttext(element.attribute("posttext"));
  16153. }
  16154. if(element.hasAttribute("series"))
  16155. {
  16156. box->setTemperatureColumn(element.attribute("series").toInt());
  16157. }
  16158. if(element.hasAttribute("column"))
  16159. {
  16160. box->setAnnotationColumn(element.attribute("column").toInt());
  16161. }
  16162. if(element.hasAttribute("min"))
  16163. {
  16164. box->setMinimum(element.attribute("min").toDouble());
  16165. }
  16166. if(element.hasAttribute("max"))
  16167. {
  16168. box->setMaximum(element.attribute("max").toDouble());
  16169. }
  16170. if(element.hasAttribute("decimals"))
  16171. {
  16172. box->setDecimals(element.attribute("decimals").toInt());
  16173. }
  16174. if(element.hasAttribute("step"))
  16175. {
  16176. box->setSingleStep(element.attribute("step").toDouble());
  16177. }
  16178. if(element.hasAttribute("id"))
  16179. {
  16180. box->setObjectName(element.attribute("id"));
  16181. }
  16182. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16183. layout->addWidget(box);
  16184. }
  16185. /*:222*//*223:*/
  16186. #line 5374 "./typica.w"
  16187. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  16188. QStack<QLayout*> *)
  16189. {
  16190. ZoomLog*widget= new ZoomLog;
  16191. if(!widget)
  16192. {
  16193. qDebug()<<"Error constructing widget!";
  16194. }
  16195. if(element.hasAttribute("id"))
  16196. {
  16197. widget->setObjectName(element.attribute("id"));
  16198. }
  16199. if(element.hasChildNodes())
  16200. {
  16201. QDomNodeList children= element.childNodes();
  16202. int column= 0;
  16203. for(int i= 0;i<children.count();i++)
  16204. {
  16205. QDomNode current;
  16206. QDomElement currentElement;
  16207. current= children.at(i);
  16208. if(current.isElement())
  16209. {
  16210. currentElement= current.toElement();
  16211. if(currentElement.tagName()=="column")
  16212. {
  16213. QString text= currentElement.text();
  16214. widget->setHeaderData(column,text);
  16215. column++;
  16216. }
  16217. }
  16218. }
  16219. }
  16220. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16221. if(splitter)
  16222. {
  16223. splitter->addWidget(widget);
  16224. }
  16225. else
  16226. {
  16227. qDebug()<<"Splitter not found at top of widget stack!";
  16228. }
  16229. }
  16230. /*:223*//*224:*/
  16231. #line 5422 "./typica.w"
  16232. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  16233. QStack<QLayout*> *)
  16234. {
  16235. GraphView*view= new GraphView;
  16236. if(element.hasAttribute("id"))
  16237. {
  16238. view->setObjectName(element.attribute("id"));
  16239. }
  16240. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16241. splitter->addWidget(view);
  16242. }
  16243. /*:224*//*225:*/
  16244. #line 5439 "./typica.w"
  16245. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  16246. QStack<QLayout*> *layoutStack)
  16247. {
  16248. SqlComboBox*box= new SqlComboBox();
  16249. if(element.hasAttribute("data"))
  16250. {
  16251. box->setDataColumn(element.attribute("data").toInt());
  16252. }
  16253. if(element.hasAttribute("display"))
  16254. {
  16255. box->setDisplayColumn(element.attribute("display").toInt());
  16256. }
  16257. if(element.hasAttribute("showdata"))
  16258. {
  16259. if(element.attribute("showdata")=="true")
  16260. {
  16261. box->showData(true);
  16262. }
  16263. }
  16264. if(element.hasAttribute("editable"))
  16265. {
  16266. if(element.attribute("editable")=="true")
  16267. {
  16268. box->setEditable(true);
  16269. }
  16270. }
  16271. if(element.hasChildNodes())
  16272. {
  16273. QDomNodeList children= element.childNodes();
  16274. for(int i= 0;i<children.count();i++)
  16275. {
  16276. QDomNode current;
  16277. QDomElement currentElement;
  16278. current= children.at(i);
  16279. if(current.isElement())
  16280. {
  16281. currentElement= current.toElement();
  16282. if(currentElement.tagName()=="null")
  16283. {
  16284. box->addNullOption();
  16285. }
  16286. else if(currentElement.tagName()=="query")
  16287. {
  16288. box->addSqlOptions(currentElement.text());
  16289. }
  16290. }
  16291. }
  16292. }
  16293. if(element.hasAttribute("id"))
  16294. {
  16295. box->setObjectName(element.attribute("id"));
  16296. }
  16297. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16298. layout->addWidget(box);
  16299. }
  16300. /*:225*//*226:*/
  16301. #line 5518 "./typica.w"
  16302. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  16303. QStack<QLayout*> *layoutStack)
  16304. {
  16305. QTableView*view= new QTableView;
  16306. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  16307. SaltModel*model= new SaltModel(element.childNodes().count());
  16308. if(element.hasAttribute("id"))
  16309. {
  16310. view->setObjectName(element.attribute("id"));
  16311. }
  16312. if(element.hasChildNodes())
  16313. {
  16314. QDomNodeList children= element.childNodes();
  16315. int currentColumn= 0;
  16316. for(int i= 0;i<children.count();i++)
  16317. {
  16318. QDomNode current;
  16319. QDomElement currentElement;
  16320. current= children.at(i);
  16321. if(current.isElement())
  16322. {
  16323. currentElement= current.toElement();
  16324. if(currentElement.tagName()=="column")
  16325. {
  16326. if(currentElement.hasAttribute("name"))
  16327. {
  16328. model->setHeaderData(currentColumn,Qt::Horizontal,
  16329. currentElement.attribute("name"));
  16330. }
  16331. if(currentElement.hasAttribute("delegate"))
  16332. {
  16333. /*227:*/
  16334. #line 5566 "./typica.w"
  16335. if(currentElement.attribute("delegate")=="sql")
  16336. {
  16337. /*228:*/
  16338. #line 5582 "./typica.w"
  16339. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  16340. SqlComboBox*widget= new SqlComboBox();
  16341. if(currentElement.hasAttribute("nulltext"))
  16342. {
  16343. widget->setNullText(currentElement.attribute("nulltext"));
  16344. }
  16345. if(currentElement.hasAttribute("nulldata"))
  16346. {
  16347. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  16348. }
  16349. if(currentElement.hasAttribute("null"))
  16350. {
  16351. if(currentElement.attribute("null")=="true")
  16352. {
  16353. widget->addNullOption();
  16354. }
  16355. }
  16356. if(currentElement.hasAttribute("showdata"))
  16357. {
  16358. if(currentElement.attribute("showdata")=="true")
  16359. {
  16360. widget->showData(true);
  16361. }
  16362. }
  16363. if(currentElement.hasAttribute("data"))
  16364. {
  16365. widget->setDataColumn(currentElement.attribute("data").toInt());
  16366. }
  16367. if(currentElement.hasAttribute("display"))
  16368. {
  16369. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  16370. }
  16371. widget->addSqlOptions(currentElement.text());
  16372. delegate->setWidget(widget);
  16373. view->setItemDelegateForColumn(currentColumn,delegate);
  16374. /*:228*/
  16375. #line 5569 "./typica.w"
  16376. }
  16377. else if(currentElement.attribute("delegate")=="numeric")
  16378. {
  16379. /*229:*/
  16380. #line 5623 "./typica.w"
  16381. NumericDelegate*delegate= new NumericDelegate;
  16382. view->setItemDelegateForColumn(currentColumn,delegate);
  16383. /*:229*/
  16384. #line 5573 "./typica.w"
  16385. }
  16386. /*:227*/
  16387. #line 5550 "./typica.w"
  16388. }
  16389. currentColumn++;
  16390. }
  16391. }
  16392. }
  16393. }
  16394. view->setModel(model);
  16395. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16396. layout->addWidget(view);
  16397. }
  16398. /*:226*//*236:*/
  16399. #line 5733 "./typica.w"
  16400. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  16401. QStack<QLayout*> *layoutStack)
  16402. {
  16403. QLineEdit*widget= new QLineEdit(element.text());
  16404. if(element.hasAttribute("id"))
  16405. {
  16406. widget->setObjectName(element.attribute("id"));
  16407. }
  16408. if(element.hasAttribute("writable"))
  16409. {
  16410. if(element.attribute("writable")=="false")
  16411. {
  16412. widget->setReadOnly(true);
  16413. }
  16414. }
  16415. if(element.hasAttribute("validator"))
  16416. {
  16417. if(element.attribute("validator")=="numeric")
  16418. {
  16419. widget->setValidator(new QDoubleValidator(NULL));
  16420. }
  16421. else if(element.attribute("validator")=="integer")
  16422. {
  16423. widget->setValidator(new QIntValidator(NULL));
  16424. }
  16425. else if(element.attribute("validator")=="expression"&&
  16426. element.hasAttribute("expression"))
  16427. {
  16428. widget->setValidator(new QRegExpValidator(
  16429. QRegExp(element.attribute("expression")),
  16430. NULL));
  16431. }
  16432. }
  16433. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16434. layout->addWidget(widget);
  16435. }
  16436. /*:236*//*237:*/
  16437. #line 5774 "./typica.w"
  16438. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  16439. QStack<QLayout*> *layoutStack)
  16440. {
  16441. QTextEdit*widget= new QTextEdit;
  16442. if(element.hasAttribute("id"))
  16443. {
  16444. widget->setObjectName(element.attribute("id"));
  16445. }
  16446. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16447. layout->addWidget(widget);
  16448. }
  16449. /*:237*//*238:*/
  16450. #line 5791 "./typica.w"
  16451. void addSqlQueryViewToLayout(QDomElement element,
  16452. QStack<QWidget*> *,
  16453. QStack<QLayout*> *layoutStack)
  16454. {
  16455. SqlQueryView*view= new SqlQueryView;
  16456. if(element.hasAttribute("id"))
  16457. {
  16458. view->setObjectName(element.attribute("id"));
  16459. }
  16460. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16461. layout->addWidget(view);
  16462. }
  16463. /*:238*//*239:*/
  16464. #line 5808 "./typica.w"
  16465. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  16466. QStack<QLayout*> *layoutStack)
  16467. {
  16468. QWidget*widget;
  16469. if(element.hasAttribute("time"))
  16470. {
  16471. if(element.attribute("time")=="true")
  16472. {
  16473. QDateTimeEdit*edit= new QDateTimeEdit;
  16474. edit->setDateTime(QDateTime::currentDateTime());
  16475. edit->setCalendarPopup(true);
  16476. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  16477. widget= qobject_cast<QWidget*> (edit);
  16478. }
  16479. else
  16480. {
  16481. QDateEdit*edit= new QDateEdit;
  16482. edit->setDate(QDate::currentDate());
  16483. edit->setCalendarPopup(true);
  16484. edit->setDisplayFormat("yyyy-MM-dd");
  16485. widget= qobject_cast<QWidget*> (edit);
  16486. }
  16487. }
  16488. else
  16489. {
  16490. QDateEdit*edit= new QDateEdit;
  16491. edit->setDate(QDate::currentDate());
  16492. edit->setCalendarPopup(true);
  16493. edit->setDisplayFormat("yyyy-MM-dd");
  16494. widget= qobject_cast<QWidget*> (edit);
  16495. }
  16496. if(element.hasAttribute("id"))
  16497. {
  16498. widget->setObjectName(element.attribute("id"));
  16499. }
  16500. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16501. layout->addWidget(widget);
  16502. }
  16503. /*:239*//*240:*/
  16504. #line 5851 "./typica.w"
  16505. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  16506. {
  16507. setQDateTimeEditProperties(value,engine);
  16508. }
  16509. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  16510. {
  16511. setQAbstractSpinBoxProperties(value,engine);
  16512. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  16513. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  16514. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  16515. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  16516. }
  16517. /*:240*//*241:*/
  16518. #line 5871 "./typica.w"
  16519. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  16520. {
  16521. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  16522. if(context->argumentCount()==3)
  16523. {
  16524. self->setDate(QDate(argument<int> (0,context),
  16525. argument<int> (1,context),
  16526. argument<int> (2,context)));
  16527. }
  16528. else
  16529. {
  16530. context->throwError("Incorrect number of arguments passed to "
  16531. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  16532. "specifying the year, month, and day.");
  16533. }
  16534. return QScriptValue();
  16535. }
  16536. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  16537. {
  16538. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  16539. return QScriptValue(self->date().day());
  16540. }
  16541. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  16542. {
  16543. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  16544. return QScriptValue(self->date().month());
  16545. }
  16546. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  16547. {
  16548. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  16549. return QScriptValue(self->date().year());
  16550. }
  16551. /*:241*//*245:*/
  16552. #line 5938 "./typica.w"
  16553. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  16554. {
  16555. QObject*parent= argument<QObject*> (0,context);
  16556. QString name= argument<QString> (1,context);
  16557. QObject*object= parent->findChild<QObject*> (name);
  16558. QScriptValue value;
  16559. if(object)
  16560. {
  16561. value= engine->newQObject(object);
  16562. QString className= object->metaObject()->className();
  16563. /*246:*/
  16564. #line 5956 "./typica.w"
  16565. if(className=="TemperatureDisplay")
  16566. {
  16567. setTemperatureDisplayProperties(value,engine);
  16568. }
  16569. else if(className=="TimerDisplay")
  16570. {
  16571. setTimerDisplayProperties(value,engine);
  16572. }
  16573. else if(className=="QAction")
  16574. {
  16575. setQActionProperties(value,engine);
  16576. }
  16577. else if(className=="QBoxLayout")
  16578. {
  16579. setQBoxLayoutProperties(value,engine);
  16580. }
  16581. else if(className=="QDateEdit")
  16582. {
  16583. setQDateEditProperties(value,engine);
  16584. }
  16585. else if(className=="QDateTimeEdit")
  16586. {
  16587. setQDateTimeEditProperties(value,engine);
  16588. }
  16589. else if(className=="QFrame")
  16590. {
  16591. setQFrameProperties(value,engine);
  16592. }
  16593. else if(className=="QHBoxLayout")
  16594. {
  16595. setQBoxLayoutProperties(value,engine);
  16596. }
  16597. else if(className=="QLCDNumber")
  16598. {
  16599. setQLCDNumberProperties(value,engine);
  16600. }
  16601. else if(className=="QMenu")
  16602. {
  16603. setQMenuProperties(value,engine);
  16604. }
  16605. else if(className=="QMenuBar")
  16606. {
  16607. setQMenuBarProperties(value,engine);
  16608. }
  16609. else if(className=="QPushButton")
  16610. {
  16611. setQPushButtonProperties(value,engine);
  16612. }
  16613. else if(className=="QSplitter")
  16614. {
  16615. setQSplitterProperties(value,engine);
  16616. }
  16617. else if(className=="QTableView")
  16618. {
  16619. if(object->property("tabletype").isValid())
  16620. {
  16621. if(object->property("tabletype").toString()=="SaltTable")
  16622. {
  16623. setSaltTableProperties(value,engine);
  16624. }
  16625. }
  16626. }
  16627. else if(className=="QVBoxLayout")
  16628. {
  16629. setQBoxLayoutProperties(value,engine);
  16630. }
  16631. else if(className=="QWidget")
  16632. {
  16633. setQWidgetProperties(value,engine);
  16634. }
  16635. else if(className=="ScriptQMainWindow")
  16636. {
  16637. setQMainWindowProperties(value,engine);
  16638. }
  16639. else if(className=="SqlComboBox")
  16640. {
  16641. setSqlComboBoxProperties(value,engine);
  16642. }
  16643. else if(className=="SqlQueryView")
  16644. {
  16645. setSqlQueryViewProperties(value,engine);
  16646. }
  16647. else if(className=="ZoomLog")
  16648. {
  16649. setZoomLogProperties(value,engine);
  16650. }
  16651. else if(className=="QTextEdit")
  16652. {
  16653. setQTextEditProperties(value,engine);
  16654. }
  16655. else if(className=="QWebView")
  16656. {
  16657. setQWebViewProperties(value,engine);
  16658. }
  16659. else if(className=="QLineEdit")
  16660. {
  16661. setQLineEditProperties(value,engine);
  16662. }
  16663. /*:246*/
  16664. #line 5949 "./typica.w"
  16665. }
  16666. return value;
  16667. }
  16668. /*:245*//*248:*/
  16669. #line 6085 "./typica.w"
  16670. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  16671. {
  16672. QTableView*self= getself<QTableView*> (context);
  16673. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16674. QString datum;
  16675. double total= 0.0;
  16676. int column= argument<int> (0,context);
  16677. int role= argument<int> (1,context);
  16678. for(int i= 0;i<model->rowCount();i++)
  16679. {
  16680. datum= model->data(model->index(i,column),role).toString();
  16681. if(!datum.isEmpty())
  16682. {
  16683. total+= datum.toDouble();
  16684. }
  16685. }
  16686. return QScriptValue(engine,total);
  16687. }
  16688. /*:248*//*249:*/
  16689. #line 6109 "./typica.w"
  16690. QScriptValue SaltTable_columnArray(QScriptContext*context,
  16691. QScriptEngine*engine)
  16692. {
  16693. QTableView*self= getself<QTableView*> (context);
  16694. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16695. int column= argument<int> (0,context);
  16696. int role= argument<int> (1,context);
  16697. QString literal= model->arrayLiteral(column,role);
  16698. return QScriptValue(engine,literal);
  16699. }
  16700. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  16701. QScriptEngine*engine)
  16702. {
  16703. QTableView*self= getself<QTableView*> (context);
  16704. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16705. int column= argument<int> (0,context);
  16706. int role= argument<int> (1,context);
  16707. QString literal= model->quotedArrayLiteral(column,role);
  16708. return QScriptValue(engine,literal);
  16709. }
  16710. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  16711. QScriptEngine*engine)
  16712. {
  16713. QTableView*self= getself<QTableView*> (context);
  16714. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16715. int column= argument<int> (0,context);
  16716. int role= argument<int> (1,context);
  16717. QString literal= model->arrayLiteral(column,role);
  16718. literal.chop(1);
  16719. literal= literal.remove(0,1);
  16720. return QScriptValue(engine,literal);
  16721. }
  16722. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  16723. QScriptEngine*engine)
  16724. {
  16725. QTableView*self= getself<QTableView*> (context);
  16726. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16727. int column= argument<int> (0,context);
  16728. int role= argument<int> (1,context);
  16729. QString literal= model->quotedArrayLiteral(column,role);
  16730. literal.chop(1);
  16731. literal= literal.remove(0,1);
  16732. return QScriptValue(engine,literal);
  16733. }
  16734. /*:249*//*250:*/
  16735. #line 6161 "./typica.w"
  16736. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  16737. {
  16738. QTableView*self= getself<QTableView*> (context);
  16739. QScriptValue value= engine->newQObject(self->model());
  16740. return value;
  16741. }
  16742. /*:250*//*251:*/
  16743. #line 6175 "./typica.w"
  16744. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  16745. {
  16746. QTableView*self= getself<QTableView*> (context);
  16747. int row= argument<int> (0,context);
  16748. int column= argument<int> (1,context);
  16749. QVariant value= argument<QVariant> (2,context);
  16750. int role= argument<int> (3,context);
  16751. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16752. QModelIndex cell= model->index(row,column);
  16753. model->setData(cell,value,role);
  16754. self->update(cell);
  16755. return QScriptValue();
  16756. }
  16757. /*:251*//*252:*/
  16758. #line 6193 "./typica.w"
  16759. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  16760. {
  16761. QTableView*self= getself<QTableView*> (context);
  16762. int row= argument<int> (0,context);
  16763. int column= argument<int> (1,context);
  16764. int role= argument<int> (2,context);
  16765. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16766. QModelIndex cell= model->index(row,column);
  16767. QVariant value= model->data(cell,role);
  16768. QScriptValue retval= engine->newVariant(value);
  16769. retval.setProperty("value",QScriptValue(value.toString()));
  16770. return retval;
  16771. }
  16772. /*:252*//*253:*/
  16773. #line 6213 "./typica.w"
  16774. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  16775. {
  16776. QTableView*self= getself<QTableView*> (context);
  16777. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16778. model->clear();
  16779. return QScriptValue();
  16780. }
  16781. /*:253*//*254:*/
  16782. #line 6225 "./typica.w"
  16783. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  16784. {
  16785. QTableView*self= getself<QTableView*> (context);
  16786. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16787. int row= argument<int> (0,context);
  16788. return engine->newVariant(model->removeRow(row));
  16789. }
  16790. /*:254*//*255:*/
  16791. #line 6238 "./typica.w"
  16792. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  16793. {
  16794. QTableView*self= getself<QTableView*> (context);
  16795. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16796. QVariant value= argument<QVariant> (0,context);
  16797. int column= argument<int> (1,context);
  16798. return engine->newVariant(model->findData(value,column));
  16799. }
  16800. /*:255*//*256:*/
  16801. #line 6251 "./typica.w"
  16802. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  16803. {
  16804. setQWidgetProperties(value,engine);
  16805. value.setProperty("columnArray",
  16806. engine->newFunction(SaltTable_columnArray));
  16807. value.setProperty("quotedColumnArray",
  16808. engine->newFunction(SaltTable_quotedColumnArray));
  16809. value.setProperty("bindableColumnArray",
  16810. engine->newFunction(SaltTable_bindableColumnArray));
  16811. value.setProperty("bindableQuotedColumnArray",
  16812. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  16813. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  16814. value.setProperty("data",engine->newFunction(SaltTable_data));
  16815. value.setProperty("model",engine->newFunction(SaltTable_model));
  16816. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  16817. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  16818. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  16819. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  16820. }
  16821. /*:256*//*258:*/
  16822. #line 6288 "./typica.w"
  16823. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  16824. {
  16825. setQComboBoxProperties(value,engine);
  16826. }
  16827. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  16828. {
  16829. setQWidgetProperties(value,engine);
  16830. value.setProperty("currentData",
  16831. engine->newFunction(QComboBox_currentData));
  16832. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  16833. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  16834. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  16835. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  16836. }
  16837. QScriptValue QComboBox_currentData(QScriptContext*context,
  16838. QScriptEngine*engine)
  16839. {
  16840. QComboBox*self= getself<QComboBox*> (context);
  16841. return QScriptValue(engine,
  16842. self->itemData(self->currentIndex()).toString());
  16843. }
  16844. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  16845. {
  16846. QComboBox*self= getself<QComboBox*> (context);
  16847. self->addItem(argument<QString> (0,context));
  16848. return QScriptValue();
  16849. }
  16850. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  16851. {
  16852. QComboBox*self= getself<QComboBox*> (context);
  16853. self->setModel(argument<QAbstractItemModel*> (0,context));
  16854. return QScriptValue();
  16855. }
  16856. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  16857. {
  16858. QComboBox*self= getself<QComboBox*> (context);
  16859. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  16860. }
  16861. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  16862. {
  16863. QComboBox*self= getself<QComboBox*> (context);
  16864. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  16865. }
  16866. #line 1 "./abouttypica.w"
  16867. /*:258*//*271:*/
  16868. #line 388 "./units.w"
  16869. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  16870. {
  16871. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  16872. argument<Units::Unit> (1,context),
  16873. argument<Units::Unit> (2,context)));
  16874. }
  16875. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  16876. QScriptEngine*)
  16877. {
  16878. return QScriptValue(Units::convertRelativeTemperature(
  16879. argument<double> (0,context),
  16880. argument<Units::Unit> (1,context),
  16881. argument<Units::Unit> (2,context)));
  16882. }
  16883. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  16884. {
  16885. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  16886. }
  16887. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  16888. {
  16889. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  16890. argument<Units::Unit> (1,context),
  16891. argument<Units::Unit> (2,context)));
  16892. }
  16893. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  16894. {
  16895. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  16896. }
  16897. /*:271*//*274:*/
  16898. #line 436 "./units.w"
  16899. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  16900. {
  16901. return engine->newVariant(QVariant(value));
  16902. }
  16903. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  16904. {
  16905. value= sv.toVariant().value<Units::Unit> ();
  16906. }
  16907. /*:274*//*284:*/
  16908. #line 149 "./measurement.w"
  16909. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  16910. {
  16911. QScriptValue object;
  16912. if(context->argumentCount()==2||context->argumentCount()==3)
  16913. {
  16914. double measurement= argument<double> (0,context);
  16915. QTime timestamp= argument<QTime> (1,context);
  16916. Units::Unit unit= Units::Fahrenheit;
  16917. if(context->argumentCount()==3)
  16918. {
  16919. unit= argument<Units::Unit> (2,context);
  16920. }
  16921. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  16922. setMeasurementProperties(object,engine);
  16923. }
  16924. else
  16925. {
  16926. context->throwError("Incorrect number of arguments passed to "
  16927. "Measurement::Measurement(). This method takes two "
  16928. "or three arguments.");
  16929. }
  16930. return object;
  16931. }
  16932. /*:284*//*285:*/
  16933. #line 176 "./measurement.w"
  16934. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  16935. {
  16936. }
  16937. /*:285*//*286:*/
  16938. #line 184 "./measurement.w"
  16939. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  16940. {
  16941. QVariant var;
  16942. var.setValue(measurement);
  16943. return engine->newVariant(var);
  16944. }
  16945. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  16946. {
  16947. measurement= value.toVariant().value<Measurement> ();
  16948. }
  16949. #line 6357 "./typica.w"
  16950. /*:286*//*304:*/
  16951. #line 6934 "./typica.w"
  16952. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  16953. {
  16954. QScriptValue object;
  16955. if(context->argumentCount()==1)
  16956. {
  16957. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  16958. QScriptEngine::ScriptOwnership);
  16959. setDAQProperties(object,engine);
  16960. }
  16961. else if(context->argumentCount()==2)
  16962. {
  16963. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  16964. argument<QString> (1,context)),
  16965. QScriptEngine::ScriptOwnership);
  16966. setDAQProperties(object,engine);
  16967. }
  16968. else
  16969. {
  16970. context->throwError("Incorrect number of arguments passed to DAQ"
  16971. "constructor. The DAQ constructor takes one"
  16972. "string as an argument specifying a device name."
  16973. "Example: Dev1");
  16974. }
  16975. return object;
  16976. }
  16977. /*:304*//*305:*/
  16978. #line 6964 "./typica.w"
  16979. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  16980. {
  16981. setQObjectProperties(value,engine);
  16982. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  16983. }
  16984. /*:305*//*306:*/
  16985. #line 6974 "./typica.w"
  16986. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  16987. {
  16988. DAQ*self= getself<DAQ*> (context);
  16989. QScriptValue object;
  16990. if(self)
  16991. {
  16992. object=
  16993. engine->newQObject(self->newChannel(argument<int> (0,context),
  16994. argument<int> (1,context)));
  16995. setChannelProperties(object,engine);
  16996. }
  16997. return object;
  16998. }
  16999. /*:306*//*313:*/
  17000. #line 7130 "./typica.w"
  17001. QScriptValue constructFakeDAQ(QScriptContext*context,
  17002. QScriptEngine*engine)
  17003. {
  17004. QScriptValue object;
  17005. if(context->argumentCount()==1)
  17006. {
  17007. object=
  17008. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  17009. QScriptEngine::ScriptOwnership);
  17010. setFakeDAQProperties(object,engine);
  17011. }
  17012. else
  17013. {
  17014. context->throwError("Incorrect number of arguments passed to DAQ"
  17015. "constructor. The DAQ constructor takes one"
  17016. "string as an argument specifying a device name."
  17017. "Example: Dev1");
  17018. }
  17019. return object;
  17020. }
  17021. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  17022. {
  17023. setQObjectProperties(value,engine);
  17024. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  17025. }
  17026. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  17027. {
  17028. FakeDAQ*self= getself<FakeDAQ*> (context);
  17029. QScriptValue object;
  17030. if(self)
  17031. {
  17032. object=
  17033. engine->newQObject(self->newChannel(argument<int> (0,context),
  17034. argument<int> (1,context)));
  17035. setChannelProperties(object,engine);
  17036. }
  17037. return object;
  17038. }
  17039. /*:313*//*317:*/
  17040. #line 7221 "./typica.w"
  17041. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  17042. {
  17043. setQObjectProperties(value,engine);
  17044. }
  17045. /*:317*//*324:*/
  17046. #line 7413 "./typica.w"
  17047. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  17048. {
  17049. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  17050. setLinearCalibratorProperties(object,engine);
  17051. return object;
  17052. }
  17053. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  17054. {
  17055. setQObjectProperties(value,engine);
  17056. }
  17057. /*:324*//*329:*/
  17058. #line 7551 "./typica.w"
  17059. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  17060. {
  17061. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  17062. setLinearSplineInterpolatorProperties(object,engine);
  17063. return object;
  17064. }
  17065. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  17066. {
  17067. setQObjectProperties(value,engine);
  17068. }
  17069. /*:329*//*339:*/
  17070. #line 7757 "./typica.w"
  17071. QScriptValue constructTemperatureDisplay(QScriptContext*,
  17072. QScriptEngine*engine)
  17073. {
  17074. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  17075. setTemperatureDisplayProperties(object,engine);
  17076. return object;
  17077. }
  17078. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  17079. {
  17080. setQLCDNumberProperties(value,engine);
  17081. value.setProperty("setDisplayUnits",
  17082. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  17083. }
  17084. /*:339*//*340:*/
  17085. #line 7781 "./typica.w"
  17086. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  17087. {
  17088. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  17089. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  17090. return QScriptValue();
  17091. }
  17092. /*:340*//*347:*/
  17093. #line 7918 "./typica.w"
  17094. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  17095. QScriptEngine*engine)
  17096. {
  17097. QScriptValue object=
  17098. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  17099. setMeasurementTimeOffsetProperties(object,engine);
  17100. return object;
  17101. }
  17102. void setMeasurementTimeOffsetProperties(QScriptValue value,
  17103. QScriptEngine*engine)
  17104. {
  17105. setQObjectProperties(value,engine);
  17106. }
  17107. /*:347*//*352:*/
  17108. #line 8027 "./typica.w"
  17109. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  17110. {
  17111. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  17112. return object;
  17113. }
  17114. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  17115. {
  17116. setQObjectProperties(value,engine);
  17117. }
  17118. /*:352*//*357:*/
  17119. #line 8124 "./typica.w"
  17120. QScriptValue constructZeroEmitter(QScriptContext*context,
  17121. QScriptEngine*engine)
  17122. {
  17123. QScriptValue object=
  17124. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  17125. setZeroEmitterProperties(object,engine);
  17126. return object;
  17127. }
  17128. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  17129. {
  17130. setQObjectProperties(value,engine);
  17131. }
  17132. /*:357*//*362:*/
  17133. #line 8204 "./typica.w"
  17134. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  17135. QScriptEngine*engine)
  17136. {
  17137. QScriptValue object=
  17138. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  17139. setMeasurementAdapterProperties(object,engine);
  17140. return object;
  17141. }
  17142. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  17143. {
  17144. setQObjectProperties(value,engine);
  17145. }
  17146. /*:362*//*379:*/
  17147. #line 8666 "./typica.w"
  17148. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  17149. {
  17150. QScriptValue object= engine->newQObject(new GraphView);
  17151. setGraphViewProperties(object,engine);
  17152. return object;
  17153. }
  17154. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  17155. {
  17156. setQGraphicsViewProperties(value,engine);
  17157. }
  17158. /*:379*//*402:*/
  17159. #line 9304 "./typica.w"
  17160. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  17161. {
  17162. QScriptValue object= engine->newQObject(new ZoomLog);
  17163. setZoomLogProperties(object,engine);
  17164. return object;
  17165. }
  17166. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  17167. {
  17168. setQTableViewProperties(value,engine);
  17169. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  17170. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  17171. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  17172. value.setProperty("restoreState",
  17173. engine->newFunction(ZoomLog_restoreState));
  17174. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  17175. value.setProperty("saveTemporary",
  17176. engine->newFunction(ZoomLog_saveTemporary));
  17177. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  17178. }
  17179. /*:402*//*403:*/
  17180. #line 9331 "./typica.w"
  17181. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  17182. {
  17183. ZoomLog*self= getself<ZoomLog*> (context);
  17184. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  17185. return QScriptValue(engine,retval);
  17186. }
  17187. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  17188. {
  17189. ZoomLog*self= getself<ZoomLog*> (context);
  17190. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  17191. return QScriptValue(engine,retval);
  17192. }
  17193. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  17194. QScriptEngine*engine)
  17195. {
  17196. ZoomLog*self= getself<ZoomLog*> (context);
  17197. QString filename= QDir::tempPath();
  17198. filename.append("/");
  17199. filename.append(QUuid::createUuid().toString());
  17200. filename.append(".xml");
  17201. QFile*file= new QFile(filename);
  17202. self->saveXML(file);
  17203. file->close();
  17204. delete file;
  17205. return QScriptValue(engine,filename);
  17206. }
  17207. /*:403*//*404:*/
  17208. #line 9379 "./typica.w"
  17209. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  17210. {
  17211. ZoomLog*self= getself<ZoomLog*> (context);
  17212. QString key= argument<QString> (0,context);
  17213. int columns= argument<int> (1,context);
  17214. QSettings settings;
  17215. for(int i= 0;i<columns;i++)
  17216. {
  17217. if(self->columnWidth(i))
  17218. {
  17219. settings.beginGroup(key);
  17220. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  17221. settings.endGroup();
  17222. }
  17223. }
  17224. return QScriptValue();
  17225. }
  17226. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  17227. {
  17228. ZoomLog*self= getself<ZoomLog*> (context);
  17229. QString key= argument<QString> (0,context);
  17230. int columns= argument<int> (1,context);
  17231. QSettings settings;
  17232. for(int i= 0;i<columns;i++)
  17233. {
  17234. settings.beginGroup(key);
  17235. self->setColumnWidth(i,
  17236. settings.value(QString("%1").arg(i),80).toInt());
  17237. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  17238. {
  17239. self->setColumnWidth(i,80);
  17240. }
  17241. settings.endGroup();
  17242. }
  17243. return QScriptValue();
  17244. }
  17245. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  17246. {
  17247. ZoomLog*self= getself<ZoomLog*> (context);
  17248. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  17249. }
  17250. /*:404*//*405:*/
  17251. #line 9432 "./typica.w"
  17252. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  17253. {
  17254. ZoomLog*self= getself<ZoomLog*> (context);
  17255. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  17256. return QScriptValue();
  17257. }
  17258. /*:405*//*440:*/
  17259. #line 10252 "./typica.w"
  17260. QScriptValue constructAnnotationButton(QScriptContext*context,
  17261. QScriptEngine*engine)
  17262. {
  17263. QScriptValue object=
  17264. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  17265. setAnnotationButtonProperties(object,engine);
  17266. return object;
  17267. }
  17268. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  17269. {
  17270. setQPushButtonProperties(value,engine);
  17271. }
  17272. /*:440*//*448:*/
  17273. #line 10395 "./typica.w"
  17274. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  17275. QScriptEngine*engine)
  17276. {
  17277. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  17278. argument<QString> (0,context),argument<QString> (1,context)));
  17279. setAnnotationSpinBoxProperties(object,engine);
  17280. return object;
  17281. }
  17282. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  17283. {
  17284. setQDoubleSpinBoxProperties(value,engine);
  17285. }
  17286. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  17287. {
  17288. setQAbstractSpinBoxProperties(value,engine);
  17289. }
  17290. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  17291. {
  17292. setQWidgetProperties(value,engine);
  17293. }
  17294. /*:448*//*469:*/
  17295. #line 10814 "./typica.w"
  17296. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  17297. {
  17298. QScriptValue object= engine->newQObject(new TimerDisplay);
  17299. setTimerDisplayProperties(object,engine);
  17300. return object;
  17301. }
  17302. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  17303. {
  17304. setQLCDNumberProperties(value,engine);
  17305. }
  17306. /*:469*//*496:*/
  17307. #line 11309 "./typica.w"
  17308. QScriptValue constructWidgetDecorator(QScriptContext*context,
  17309. QScriptEngine*engine)
  17310. {
  17311. QWidget*widget= argument<QWidget*> (0,context);
  17312. QString text= argument<QString> (1,context);
  17313. Qt::Orientations orientation;
  17314. switch(argument<int> (2,context))
  17315. {
  17316. case 2:
  17317. orientation= Qt::Vertical;
  17318. break;
  17319. default:
  17320. orientation= Qt::Horizontal;
  17321. break;
  17322. }
  17323. QScriptValue object=
  17324. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  17325. setWidgetDecoratorProperties(object,engine);
  17326. return object;
  17327. }
  17328. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  17329. {
  17330. setQWidgetProperties(value,engine);
  17331. }
  17332. /*:496*//*509:*/
  17333. #line 11590 "./typica.w"
  17334. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  17335. {
  17336. QScriptValue object= engine->newQObject(new LogEditWindow);
  17337. return object;
  17338. }
  17339. /*:509*//*528:*/
  17340. #line 12118 "./typica.w"
  17341. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  17342. {
  17343. QIODevice*device= argument<QIODevice*> (0,context);
  17344. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  17345. argument<int> (1,context)));
  17346. object.setProperty("input",engine->newFunction(XMLInput_input));
  17347. return object;
  17348. }
  17349. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  17350. {
  17351. XMLInput*self= getself<XMLInput*> (context);
  17352. self->input();
  17353. return QScriptValue();
  17354. }
  17355. /*:528*//*542:*/
  17356. #line 157 "./webview.w"
  17357. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  17358. {
  17359. QScriptValue object= engine->newQObject(new TypicaWebView);
  17360. setQWebViewProperties(object,engine);
  17361. return object;
  17362. }
  17363. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  17364. {
  17365. setQWidgetProperties(value,engine);
  17366. }
  17367. /*:542*//*543:*/
  17368. #line 174 "./webview.w"
  17369. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  17370. QStack<QLayout*> *layoutStack)
  17371. {
  17372. TypicaWebView*view= new TypicaWebView;
  17373. if(element.hasAttribute("id"))
  17374. {
  17375. view->setObjectName(element.attribute("id"));
  17376. }
  17377. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17378. layout->addWidget(view);
  17379. }
  17380. /*:543*//*548:*/
  17381. #line 225 "./webview.w"
  17382. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  17383. {
  17384. QVariant var;
  17385. var.setValue(element);
  17386. QScriptValue object= engine->newVariant(var);
  17387. return object;
  17388. }
  17389. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  17390. {
  17391. element= value.toVariant().value<QWebElement> ();
  17392. }
  17393. /*:548*//*553:*/
  17394. #line 290 "./webview.w"
  17395. template<> QWebElement argument(int arg,QScriptContext*context)
  17396. {
  17397. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  17398. }
  17399. /*:553*//*554:*/
  17400. #line 299 "./webview.w"
  17401. QScriptValue constructWebElement(QScriptContext*context,
  17402. QScriptEngine*engine)
  17403. {
  17404. QWebElement element= argument<QWebElement> (0,context);
  17405. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  17406. return object;
  17407. }
  17408. /*:554*//*622:*/
  17409. #line 13463 "./typica.w"
  17410. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  17411. {
  17412. QScriptValue object= engine->newQObject(new SqlQueryView);
  17413. setSqlQueryViewProperties(object,engine);
  17414. return object;
  17415. }
  17416. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  17417. {
  17418. setQTableViewProperties(value,engine);
  17419. value.setProperty("setHeaderData",
  17420. engine->newFunction(SqlQueryView_setHeaderData));
  17421. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  17422. }
  17423. /*:622*//*623:*/
  17424. #line 13481 "./typica.w"
  17425. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  17426. {
  17427. SqlQueryView*self= getself<SqlQueryView*> (context);
  17428. QString query= argument<QString> (0,context);
  17429. self->setQuery(query);
  17430. self->reset();
  17431. return QScriptValue();
  17432. }
  17433. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  17434. QScriptEngine*)
  17435. {
  17436. SqlQueryView*self= getself<SqlQueryView*> (context);
  17437. int section= argument<int> (0,context);
  17438. QString data= argument<QString> (1,context);
  17439. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  17440. return QScriptValue();
  17441. }
  17442. /*:623*//*631:*/
  17443. #line 13688 "./typica.w"
  17444. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  17445. QStack<QLayout*> *layoutStack)
  17446. {
  17447. QTextEdit*widget= new QTextEdit;
  17448. if(element.hasAttribute("id"))
  17449. {
  17450. widget->setObjectName(element.attribute("id"));
  17451. }
  17452. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17453. layout->addWidget(widget);
  17454. QTextDocument*document= new QTextDocument;
  17455. QFont defaultFont;
  17456. defaultFont.setPointSize(11);
  17457. document->setDefaultFont(defaultFont);
  17458. QTextCursor cursor(document);
  17459. /*632:*/
  17460. #line 13711 "./typica.w"
  17461. QDomNodeList children= element.childNodes();
  17462. for(int i= 0;i<children.count();i++)
  17463. {
  17464. QDomNode current;
  17465. QDomElement currentElement;
  17466. current= children.at(i);
  17467. if(current.isElement())
  17468. {
  17469. currentElement= current.toElement();
  17470. /*633:*/
  17471. #line 13728 "./typica.w"
  17472. if(currentElement.tagName()=="style")
  17473. {
  17474. document->setDefaultStyleSheet(currentElement.text());
  17475. }
  17476. /*:633*//*634:*/
  17477. #line 13739 "./typica.w"
  17478. if(currentElement.tagName()=="html")
  17479. {
  17480. cursor.insertHtml(currentElement.text());
  17481. }
  17482. /*:634*//*635:*/
  17483. #line 13749 "./typica.w"
  17484. if(currentElement.tagName()=="text")
  17485. {
  17486. cursor.insertText(currentElement.text());
  17487. }
  17488. /*:635*//*636:*/
  17489. #line 13759 "./typica.w"
  17490. if(currentElement.tagName()=="table")
  17491. {
  17492. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  17493. ReportTable*table= new ReportTable(frame,currentElement);
  17494. table->setParent(widget);
  17495. if(currentElement.hasAttribute("id"))
  17496. {
  17497. table->setObjectName(currentElement.attribute("id"));
  17498. }
  17499. }
  17500. /*:636*/
  17501. #line 13721 "./typica.w"
  17502. }
  17503. }
  17504. /*:632*/
  17505. #line 13704 "./typica.w"
  17506. widget->setDocument(document);
  17507. }
  17508. /*:631*//*647:*/
  17509. #line 13972 "./typica.w"
  17510. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  17511. {
  17512. QTextEdit*self= getself<QTextEdit*> (context);
  17513. QTextDocument*document= self->document();
  17514. QPrinter printer;
  17515. QPrintDialog printwindow(&printer,self);
  17516. if(printwindow.exec()!=QDialog::Accepted)
  17517. {
  17518. return QScriptValue();
  17519. }
  17520. document->print(&printer);
  17521. return QScriptValue();
  17522. }
  17523. /*:647*//*648:*/
  17524. #line 13990 "./typica.w"
  17525. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  17526. {
  17527. setQAbstractScrollAreaProperties(value,engine);
  17528. value.setProperty("print",engine->newFunction(QTextEdit_print));
  17529. }
  17530. #line 1 "./daterangeselector.w"
  17531. /*:648*//*667:*/
  17532. #line 452 "./daterangeselector.w"
  17533. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  17534. QStack<QLayout*> *layoutStack)
  17535. {
  17536. DateRangeSelector*widget= new DateRangeSelector;
  17537. if(element.hasAttribute("id"))
  17538. {
  17539. widget->setObjectName(element.attribute("id"));
  17540. }
  17541. if(element.hasAttribute("initial"))
  17542. {
  17543. widget->setCurrentIndex(element.attribute("initial").toInt());
  17544. }
  17545. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17546. layout->addWidget(widget);
  17547. }
  17548. /*:667*//*678:*/
  17549. #line 14170 "./typica.w"
  17550. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  17551. QStack<QLayout*> *layoutStack)
  17552. {
  17553. FormArray*widget= new FormArray(element);
  17554. if(element.hasAttribute("id"))
  17555. {
  17556. widget->setObjectName(element.attribute("id"));
  17557. }
  17558. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17559. layout->addWidget(widget);
  17560. }
  17561. /*:678*//*699:*/
  17562. #line 14757 "./typica.w"
  17563. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  17564. QStack<QLayout*> *layoutStack)
  17565. {
  17566. ScaleControl*scale= new ScaleControl;
  17567. if(element.hasAttribute("id"))
  17568. {
  17569. scale->setObjectName(element.attribute("id"));
  17570. }
  17571. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17572. layout->addWidget(scale);
  17573. }
  17574. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  17575. QStack<QLayout*> *layoutStack)
  17576. {
  17577. IntensityControl*scale= new IntensityControl;
  17578. if(element.hasAttribute("id"))
  17579. {
  17580. scale->setObjectName(element.attribute("id"));
  17581. }
  17582. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17583. layout->addWidget(scale);
  17584. }
  17585. /*:699*//*725:*/
  17586. #line 15347 "./typica.w"
  17587. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  17588. {
  17589. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  17590. setDeviceTreeModelProperties(object,engine);
  17591. return object;
  17592. }
  17593. /*:725*//*727:*/
  17594. #line 15370 "./typica.w"
  17595. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  17596. {
  17597. setQAbstractItemModelProperties(value,engine);
  17598. value.setProperty("referenceElement",
  17599. engine->newFunction(DeviceTreeModel_referenceElement));
  17600. }
  17601. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  17602. {
  17603. setQObjectProperties(value,engine);
  17604. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  17605. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  17606. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  17607. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  17608. }
  17609. /*:727*//*728:*/
  17610. #line 15397 "./typica.w"
  17611. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  17612. QScriptEngine*engine)
  17613. {
  17614. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  17615. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  17616. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  17617. QDomElement node;
  17618. QVariantMap retval;
  17619. retval.insert("driver",referenceElement.attribute("driver"));
  17620. for(int i= 0;i<configData.size();i++)
  17621. {
  17622. node= configData.at(i).toElement();
  17623. retval.insert(node.attribute("name"),node.attribute("value"));
  17624. }
  17625. return engine->toScriptValue(retval);
  17626. }
  17627. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  17628. {
  17629. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  17630. QModelIndex index= argument<QModelIndex> (0,context);
  17631. int role= argument<int> (1,context);
  17632. return engine->toScriptValue(model->data(index,role));
  17633. }
  17634. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  17635. {
  17636. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  17637. int row= 0;
  17638. int column= 0;
  17639. QModelIndex index;
  17640. if(context->argumentCount()> 1)
  17641. {
  17642. row= argument<int> (0,context);
  17643. column= argument<int> (1,context);
  17644. }
  17645. if(context->argumentCount()> 2)
  17646. {
  17647. index= argument<QModelIndex> (2,context);
  17648. }
  17649. QModelIndex retval= model->index(row,column,index);
  17650. return engine->toScriptValue(retval);
  17651. }
  17652. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  17653. QScriptEngine*)
  17654. {
  17655. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  17656. QModelIndex index;
  17657. if(context->argumentCount()==1)
  17658. {
  17659. index= argument<QModelIndex> (0,context);
  17660. }
  17661. return QScriptValue(model->rowCount(index));
  17662. }
  17663. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  17664. QScriptEngine*engine)
  17665. {
  17666. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  17667. QModelIndex index;
  17668. if(context->argumentCount()==1)
  17669. {
  17670. index= argument<QModelIndex> (0,context);
  17671. }
  17672. return QScriptValue(engine,model->hasChildren(index));
  17673. }
  17674. /*:728*//*731:*/
  17675. #line 15481 "./typica.w"
  17676. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  17677. {
  17678. QVariant var;
  17679. var.setValue(index);
  17680. QScriptValue object= engine->newVariant(var);
  17681. return object;
  17682. }
  17683. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  17684. {
  17685. index= value.toVariant().value<QModelIndex> ();
  17686. }
  17687. /*:731*//*747:*/
  17688. #line 15779 "./typica.w"
  17689. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  17690. QScriptEngine*engine)
  17691. {
  17692. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  17693. return object;
  17694. }
  17695. /*:747*//*818:*/
  17696. #line 47 "./settings.w"
  17697. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  17698. {
  17699. QScriptValue object= engine->newQObject(new SettingsWindow);
  17700. return object;
  17701. }
  17702. /*:818*//*843:*/
  17703. #line 18359 "./typica.w"
  17704. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  17705. {
  17706. QScriptValue object;
  17707. if(context->argumentCount()==2)
  17708. {
  17709. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  17710. argument<QModelIndex> (1,context)),
  17711. QScriptEngine::ScriptOwnership);
  17712. setModbusRTUDeviceProperties(object,engine);
  17713. }
  17714. else
  17715. {
  17716. context->throwError("Incorrect number of arguments passed to "
  17717. "ModbusRTUDevice constructor. This takes the configuration model "
  17718. "and an index.");
  17719. }
  17720. return object;
  17721. }
  17722. /*:843*//*844:*/
  17723. #line 18381 "./typica.w"
  17724. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  17725. {
  17726. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  17727. QScriptValue object;
  17728. if(self)
  17729. {
  17730. if(self->channels.size()> 0)
  17731. {
  17732. object= engine->newQObject(self->channels.at(0));
  17733. setChannelProperties(object,engine);
  17734. }
  17735. }
  17736. return object;
  17737. }
  17738. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  17739. {
  17740. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  17741. QScriptValue object;
  17742. if(self)
  17743. {
  17744. if(self->channels.size()> 1)
  17745. {
  17746. object= engine->newQObject(self->channels.at(1));
  17747. setChannelProperties(object,engine);
  17748. }
  17749. }
  17750. return object;
  17751. }
  17752. /*:844*//*845:*/
  17753. #line 18414 "./typica.w"
  17754. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  17755. {
  17756. setQObjectProperties(value,engine);
  17757. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  17758. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  17759. }
  17760. /*:845*//*863:*/
  17761. #line 357 "./unsupportedserial.w"
  17762. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  17763. {
  17764. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  17765. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  17766. QScriptValue object= engine->newQObject(device);
  17767. setQObjectProperties(object,engine);
  17768. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  17769. return object;
  17770. }
  17771. /*:863*//*868:*/
  17772. #line 430 "./unsupportedserial.w"
  17773. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  17774. {
  17775. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  17776. QScriptValue object;
  17777. if(self)
  17778. {
  17779. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  17780. setChannelProperties(object,engine);
  17781. }
  17782. return object;
  17783. }
  17784. /*:868*//*875:*/
  17785. #line 630 "./unsupportedserial.w"
  17786. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  17787. {
  17788. return engine->toScriptValue<QTime> (QTime::currentTime());
  17789. }
  17790. /*:875*//*879:*/
  17791. #line 667 "./unsupportedserial.w"
  17792. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  17793. {
  17794. QScriptValue object= engine->newQObject(new QextSerialPort());
  17795. setSerialPortProperties(object,engine);
  17796. return object;
  17797. }
  17798. /*:879*//*880:*/
  17799. #line 678 "./unsupportedserial.w"
  17800. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  17801. {
  17802. setQIODeviceProperties(value,engine);
  17803. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  17804. }
  17805. /*:880*//*881:*/
  17806. #line 687 "./unsupportedserial.w"
  17807. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  17808. {
  17809. QextSerialPort*self= getself<QextSerialPort*> (context);
  17810. self->flush();
  17811. return QScriptValue();
  17812. }
  17813. /*:881*//*884:*/
  17814. #line 721 "./unsupportedserial.w"
  17815. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  17816. {
  17817. setQObjectProperties(value,engine);
  17818. }
  17819. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  17820. {
  17821. QScriptValue object= engine->newQObject(new QTimer);
  17822. setQTimerProperties(object,engine);
  17823. return object;
  17824. }
  17825. #line 18965 "./typica.w"
  17826. #line 1 "./phidgets.w"
  17827. /*:884*//*905:*/
  17828. #line 463 "./phidgets.w"
  17829. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  17830. {
  17831. if(context->argumentCount()!=1)
  17832. {
  17833. context->throwError("Incorrect number of arguments passed to "
  17834. "PhidgetsTemperatureSensor constructor. This takes "
  17835. "a QModelIndex.");
  17836. }
  17837. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  17838. setQObjectProperties(object,engine);
  17839. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  17840. return object;
  17841. }
  17842. /*:905*//*906:*/
  17843. #line 480 "./phidgets.w"
  17844. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  17845. {
  17846. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  17847. QScriptValue object;
  17848. if(self)
  17849. {
  17850. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  17851. setChannelProperties(object,engine);
  17852. }
  17853. return object;
  17854. }
  17855. #line 18967 "./typica.w"
  17856. /*:906*//*924:*/
  17857. #line 151 "./rate.w"
  17858. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  17859. {
  17860. int cachetime= 1;
  17861. int scaletime= 1;
  17862. if(context->argumentCount()> 0)
  17863. {
  17864. cachetime= argument<int> (0,context);
  17865. if(context->argumentCount()> 1)
  17866. {
  17867. scaletime= argument<int> (1,context);
  17868. }
  17869. }
  17870. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  17871. setRateOfChangeProperties(object,engine);
  17872. return object;
  17873. }
  17874. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  17875. {
  17876. setQObjectProperties(value,engine);
  17877. }
  17878. /*:924*//*949:*/
  17879. #line 614 "./dataqsdk.w"
  17880. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  17881. {
  17882. QScriptValue object;
  17883. if(context->argumentCount()==1)
  17884. {
  17885. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  17886. QScriptEngine::ScriptOwnership);
  17887. setDataqSdkDeviceProperties(object,engine);
  17888. }
  17889. else
  17890. {
  17891. context->throwError("Incorrect number of arguments passed to "
  17892. "DataqSdkDevice. The constructor takes one string "
  17893. "as an argument specifying a device name. "
  17894. "Example: Dev1");
  17895. }
  17896. return object;
  17897. }
  17898. /*:949*//*950:*/
  17899. #line 637 "./dataqsdk.w"
  17900. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  17901. {
  17902. setQObjectProperties(value,engine);
  17903. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  17904. }
  17905. /*:950*//*951:*/
  17906. #line 647 "./dataqsdk.w"
  17907. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  17908. {
  17909. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  17910. QScriptValue object;
  17911. if(self)
  17912. {
  17913. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  17914. setChannelProperties(object,engine);
  17915. }
  17916. return object;
  17917. }
  17918. /*:951*//*976:*/
  17919. #line 80 "./scales.w"
  17920. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  17921. {
  17922. QScriptValue object;
  17923. QString labelText= "";
  17924. if(context->argumentCount()==1)
  17925. {
  17926. labelText= argument<QString> (0,context);
  17927. }
  17928. object= engine->newQObject(new DragLabel(labelText));
  17929. setDragLabelProperties(object,engine);
  17930. return object;
  17931. }
  17932. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  17933. {
  17934. setQLabelProperties(value,engine);
  17935. }
  17936. /*:976*//*986:*/
  17937. #line 272 "./scales.w"
  17938. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  17939. {
  17940. return engine->newVariant(QVariant((int)(value)));
  17941. }
  17942. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  17943. {
  17944. value= (BaudRateType)(sv.toVariant().toInt());
  17945. }
  17946. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  17947. {
  17948. return engine->newVariant(QVariant((int)(value)));
  17949. }
  17950. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  17951. {
  17952. value= (DataBitsType)(sv.toVariant().toInt());
  17953. }
  17954. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  17955. {
  17956. return engine->newVariant(QVariant((int)(value)));
  17957. }
  17958. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  17959. {
  17960. value= (ParityType)(sv.toVariant().toInt());
  17961. }
  17962. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  17963. {
  17964. return engine->newVariant(QVariant((int)(value)));
  17965. }
  17966. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  17967. {
  17968. value= (StopBitsType)(sv.toVariant().toInt());
  17969. }
  17970. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  17971. {
  17972. return engine->newVariant(QVariant((int)(value)));
  17973. }
  17974. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  17975. {
  17976. value= (FlowType)(sv.toVariant().toInt());
  17977. }
  17978. /*:986*//*989:*/
  17979. #line 341 "./scales.w"
  17980. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  17981. {
  17982. setQIODeviceProperties(value,engine);
  17983. }
  17984. /*:989*//*990:*/
  17985. #line 349 "./scales.w"
  17986. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  17987. {
  17988. QScriptValue object;
  17989. if(context->argumentCount()==1)
  17990. {
  17991. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  17992. setSerialScaleProperties(object,engine);
  17993. }
  17994. else
  17995. {
  17996. context->throwError("Incorrect number of arguments passed to "
  17997. "SerialScale. The constructor takes one string "
  17998. "as an argument specifying a port name.");
  17999. }
  18000. return object;
  18001. }
  18002. /*:990*//*1012:*/
  18003. #line 278 "./valueannotation.w"
  18004. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  18005. {
  18006. QScriptValue object= engine->newQObject(new ValueAnnotation);
  18007. setValueAnnotationProperties(object,engine);
  18008. return object;
  18009. }
  18010. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  18011. {
  18012. setQObjectProperties(value,engine);
  18013. }
  18014. #line 19188 "./typica.w"
  18015. /*:1012*/
  18016. #line 530 "./typica.w"
  18017. /*601:*/
  18018. #line 13106 "./typica.w"
  18019. void messageFileOutput(QtMsgType type,const char*msg)
  18020. {
  18021. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  18022. output.open(QIODevice::WriteOnly|QIODevice::Append);
  18023. QTextStream outstream(&output);
  18024. outstream<<msg<<"\r\n";
  18025. }
  18026. /*:601*/
  18027. #line 531 "./typica.w"
  18028. /*598:*/
  18029. #line 13067 "./typica.w"
  18030. int main(int argc,char**argv)
  18031. {
  18032. int*c= &argc;
  18033. Application app(*c,argv);
  18034. QSettings settings;
  18035. /*599:*/
  18036. #line 13093 "./typica.w"
  18037. if(settings.value("settings/advanced/logging",false).toBool())
  18038. {
  18039. qInstallMsgHandler(messageFileOutput);
  18040. }
  18041. /*:599*/
  18042. #line 13073 "./typica.w"
  18043. /*602:*/
  18044. #line 13119 "./typica.w"
  18045. QStringList themeSearchPath= QIcon::themeSearchPaths();
  18046. themeSearchPath.append(":/resources/icons/tango");
  18047. QIcon::setThemeSearchPaths(themeSearchPath);
  18048. QIcon::setThemeName(":/resources/icons/tango");
  18049. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  18050. /*:602*/
  18051. #line 13074 "./typica.w"
  18052. /*603:*/
  18053. #line 13139 "./typica.w"
  18054. QFile entypo(":/resources/fonts/entypo.ttf");
  18055. entypo.open(QIODevice::ReadOnly);
  18056. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  18057. entypo.close();
  18058. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  18059. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  18060. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  18061. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  18062. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  18063. /*:603*/
  18064. #line 13075 "./typica.w"
  18065. /*757:*/
  18066. #line 15999 "./typica.w"
  18067. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  18068. /*:757*//*767:*/
  18069. #line 16241 "./typica.w"
  18070. app.registerDeviceConfigurationWidget("nidaqmxbase",
  18071. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  18072. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  18073. NiDaqMxBase9211ConfWidget::staticMetaObject);
  18074. app.registerDeviceConfigurationWidget("ni9211seriestc",
  18075. Ni9211TcConfWidget::staticMetaObject);
  18076. /*:767*//*775:*/
  18077. #line 16472 "./typica.w"
  18078. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  18079. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  18080. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  18081. /*:775*//*799:*/
  18082. #line 17437 "./typica.w"
  18083. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  18084. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  18085. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  18086. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  18087. /*:799*//*804:*/
  18088. #line 17522 "./typica.w"
  18089. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  18090. /*:804*//*807:*/
  18091. #line 17592 "./typica.w"
  18092. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  18093. /*:807*//*810:*/
  18094. #line 17719 "./typica.w"
  18095. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  18096. #line 1 "./freeannotation.w"
  18097. /*:810*//*814:*/
  18098. #line 57 "./freeannotation.w"
  18099. app.registerDeviceConfigurationWidget("freeannotation",
  18100. FreeAnnotationConfWidget::staticMetaObject);
  18101. #line 17723 "./typica.w"
  18102. #line 1 "./settings.w"
  18103. /*:814*//*848:*/
  18104. #line 18955 "./typica.w"
  18105. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  18106. /*:848*//*858:*/
  18107. #line 264 "./unsupportedserial.w"
  18108. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  18109. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  18110. app.registerDeviceConfigurationWidget("unsupporteddevice",
  18111. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  18112. /*:858*//*892:*/
  18113. #line 181 "./phidgets.w"
  18114. app.registerDeviceConfigurationWidget("phidgets1048",
  18115. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  18116. app.registerDeviceConfigurationWidget("phidgets1048channel",
  18117. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  18118. /*:892*//*912:*/
  18119. #line 19089 "./typica.w"
  18120. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  18121. /*:912*//*916:*/
  18122. #line 19178 "./typica.w"
  18123. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  18124. #line 1 "./rate.w"
  18125. /*:916*//*928:*/
  18126. #line 253 "./rate.w"
  18127. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  18128. /*:928*//*969:*/
  18129. #line 1233 "./dataqsdk.w"
  18130. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  18131. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  18132. DataqSdkChannelConfWidget::staticMetaObject);
  18133. /*:969*//*994:*/
  18134. #line 490 "./scales.w"
  18135. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  18136. /*:994*//*1002:*/
  18137. #line 138 "./valueannotation.w"
  18138. app.registerDeviceConfigurationWidget("valueannotation",
  18139. ValueAnnotationConfWidget::staticMetaObject);
  18140. /*:1002*/
  18141. #line 13077 "./typica.w"
  18142. /*604:*/
  18143. #line 13156 "./typica.w"
  18144. if(settings.value("database/exists","false").toString()=="true")
  18145. {
  18146. /*609:*/
  18147. #line 13278 "./typica.w"
  18148. QSqlDatabase database=
  18149. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  18150. database.setConnectOptions("application_name=Typica");
  18151. database.setHostName(settings.value("database/hostname").toString());
  18152. database.setDatabaseName(settings.value("database/dbname").toString());
  18153. database.setUserName(settings.value("database/user").toString());
  18154. database.setPassword(settings.value("database/password").toString());
  18155. if(!database.open())
  18156. {
  18157. settings.setValue("database/exists","false");
  18158. }
  18159. else
  18160. {
  18161. database.close();
  18162. }
  18163. /*:609*/
  18164. #line 13159 "./typica.w"
  18165. }
  18166. if(settings.value("database/exists","false").toString()=="false")
  18167. {
  18168. /*608:*/
  18169. #line 13269 "./typica.w"
  18170. SqlConnectionSetup dialog;
  18171. dialog.exec();
  18172. /*:608*/
  18173. #line 13163 "./typica.w"
  18174. }
  18175. /*:604*/
  18176. #line 13078 "./typica.w"
  18177. /*179:*/
  18178. #line 4184 "./typica.w"
  18179. QStringList arguments= QCoreApplication::arguments();
  18180. int position= arguments.indexOf("-c");
  18181. QString filename= QString();
  18182. if(position!=-1)
  18183. {
  18184. if(arguments.size()>=position+1)
  18185. {
  18186. filename= arguments.at(position+1);
  18187. }
  18188. }
  18189. if(filename.isEmpty())
  18190. {
  18191. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  18192. settings.value("config","").toString());
  18193. }
  18194. QDir directory;
  18195. if(!filename.isEmpty())
  18196. {
  18197. QFile file(filename);
  18198. QFileInfo info(filename);
  18199. directory= info.dir();
  18200. settings.setValue("config",directory.path());
  18201. if(file.open(QIODevice::ReadOnly))
  18202. {
  18203. app.configuration()->setContent(&file,true);
  18204. }
  18205. }
  18206. /*180:*/
  18207. #line 4218 "./typica.w"
  18208. QDomElement root= app.configuration()->documentElement();
  18209. QDomNodeList children= root.childNodes();
  18210. QString replacementDoc;
  18211. QDomDocument includedDoc;
  18212. QDomDocumentFragment fragment;
  18213. for(int i= 0;i<children.size();i++)
  18214. {
  18215. QDomNode currentNode= children.at(i);
  18216. QDomElement currentElement;
  18217. if(currentNode.nodeName()=="include")
  18218. {
  18219. currentElement= currentNode.toElement();
  18220. if(currentElement.hasAttribute("src"))
  18221. {
  18222. replacementDoc= directory.path();
  18223. replacementDoc.append('/');
  18224. replacementDoc.append(currentElement.attribute("src"));
  18225. QFile doc(replacementDoc);
  18226. if(doc.open(QIODevice::ReadOnly))
  18227. {
  18228. includedDoc.setContent(&doc,true);
  18229. fragment= includedDoc.createDocumentFragment();
  18230. fragment.appendChild(includedDoc.documentElement());
  18231. root.replaceChild(fragment,currentNode);
  18232. doc.close();
  18233. }
  18234. }
  18235. }
  18236. }
  18237. /*:180*/
  18238. #line 4212 "./typica.w"
  18239. /*:179*/
  18240. #line 13079 "./typica.w"
  18241. /*7:*/
  18242. #line 659 "./typica.w"
  18243. QScriptEngine*engine= new QScriptEngine;
  18244. QScriptValue constructor;
  18245. QScriptValue value;
  18246. /*:7*//*17:*/
  18247. #line 856 "./typica.w"
  18248. constructor= engine->newFunction(constructQWidget);
  18249. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  18250. engine->globalObject().setProperty("QWidget",value);
  18251. /*:17*//*28:*/
  18252. #line 1102 "./typica.w"
  18253. constructor= engine->newFunction(constructQMainWindow);
  18254. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  18255. constructor);
  18256. engine->globalObject().setProperty("QMainWindow",value);
  18257. /*:28*//*39:*/
  18258. #line 1307 "./typica.w"
  18259. constructor= engine->newFunction(constructQFrame);
  18260. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  18261. engine->globalObject().setProperty("QFrame",value);
  18262. /*:39*//*42:*/
  18263. #line 1340 "./typica.w"
  18264. constructor= engine->newFunction(constructQLabel);
  18265. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  18266. engine->globalObject().setProperty("QLabel",value);
  18267. /*:42*//*45:*/
  18268. #line 1378 "./typica.w"
  18269. constructor= engine->newFunction(constructQLineEdit);
  18270. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  18271. engine->globalObject().setProperty("QLineEdit",value);
  18272. /*:45*//*49:*/
  18273. #line 1425 "./typica.w"
  18274. constructor= engine->newFunction(constructQSplitter);
  18275. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  18276. engine->globalObject().setProperty("QSplitter",value);
  18277. /*:49*//*57:*/
  18278. #line 1614 "./typica.w"
  18279. constructor= engine->newFunction(constructQBoxLayout);
  18280. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  18281. engine->globalObject().setProperty("QBoxLayout",value);
  18282. /*:57*//*61:*/
  18283. #line 1726 "./typica.w"
  18284. constructor= engine->newFunction(constructQAction);
  18285. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  18286. engine->globalObject().setProperty("QAction",value);
  18287. /*:61*//*64:*/
  18288. #line 1785 "./typica.w"
  18289. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  18290. value.setProperty("getOpenFileName",
  18291. engine->newFunction(QFileDialog_getOpenFileName));
  18292. value.setProperty("getSaveFileName",
  18293. engine->newFunction(QFileDialog_getSaveFileName));
  18294. engine->globalObject().setProperty("QFileDialog",value);
  18295. /*:64*//*69:*/
  18296. #line 1903 "./typica.w"
  18297. constructor= engine->newFunction(constructQFile);
  18298. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  18299. engine->globalObject().setProperty("QFile",value);
  18300. /*:69*//*80:*/
  18301. #line 2121 "./typica.w"
  18302. constructor= engine->newFunction(constructQProcess);
  18303. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  18304. engine->globalObject().setProperty("QProcess",value);
  18305. /*:80*//*89:*/
  18306. #line 2270 "./typica.w"
  18307. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  18308. constructor= engine->newFunction(constructQByteArray);
  18309. engine->globalObject().setProperty("QByteArray",constructor);
  18310. /*:89*//*101:*/
  18311. #line 2512 "./typica.w"
  18312. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  18313. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  18314. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  18315. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  18316. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  18317. /*:101*//*104:*/
  18318. #line 2615 "./typica.w"
  18319. constructor= engine->newFunction(constructQBuffer);
  18320. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  18321. engine->globalObject().setProperty("QBuffer",value);
  18322. /*:104*//*107:*/
  18323. #line 2664 "./typica.w"
  18324. constructor= engine->newFunction(constructXQuery);
  18325. engine->globalObject().setProperty("XQuery",constructor);
  18326. /*:107*//*113:*/
  18327. #line 2766 "./typica.w"
  18328. constructor= engine->newFunction(constructXmlWriter);
  18329. engine->globalObject().setProperty("XmlWriter",constructor);
  18330. /*:113*//*122:*/
  18331. #line 2972 "./typica.w"
  18332. constructor= engine->newFunction(constructXmlReader);
  18333. engine->globalObject().setProperty("XmlReader",constructor);
  18334. /*:122*//*129:*/
  18335. #line 3096 "./typica.w"
  18336. value= engine->newQObject(&settings);
  18337. setQSettingsProperties(value,engine);
  18338. engine->globalObject().setProperty("QSettings",value);
  18339. /*:129*//*133:*/
  18340. #line 3177 "./typica.w"
  18341. constructor= engine->newFunction(constructQLCDNumber);
  18342. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  18343. engine->globalObject().setProperty("QLCDNumber",value);
  18344. /*:133*//*136:*/
  18345. #line 3233 "./typica.w"
  18346. constructor= engine->newFunction(constructQTime);
  18347. engine->globalObject().setProperty("QTime",constructor);
  18348. /*:136*//*158:*/
  18349. #line 3746 "./typica.w"
  18350. constructor= engine->newFunction(constructQPushButton);
  18351. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  18352. engine->globalObject().setProperty("QPushButton",value);
  18353. /*:158*//*165:*/
  18354. #line 3857 "./typica.w"
  18355. constructor= engine->newFunction(constructQSqlQuery);
  18356. engine->globalObject().setProperty("QSqlQuery",constructor);
  18357. /*:165*//*172:*/
  18358. #line 4020 "./typica.w"
  18359. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  18360. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  18361. engine->globalObject().setProperty("sqlToArray",
  18362. engine->newFunction(sqlToArray));
  18363. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  18364. engine->globalObject().setProperty("annotationFromRecord",
  18365. engine->newFunction(annotationFromRecord));
  18366. engine->globalObject().setProperty("setTabOrder",
  18367. engine->newFunction(setTabOrder));
  18368. engine->globalObject().setProperty("saveFileFromDatabase",
  18369. engine->newFunction(saveFileFromDatabase));
  18370. /*:172*//*184:*/
  18371. #line 4385 "./typica.w"
  18372. engine->globalObject().setProperty("createWindow",
  18373. engine->newFunction(createWindow));
  18374. engine->globalObject().setProperty("createReport",
  18375. engine->newFunction(createReport));
  18376. /*:184*//*244:*/
  18377. #line 5930 "./typica.w"
  18378. engine->globalObject().setProperty("findChildObject",
  18379. engine->newFunction(findChildObject));
  18380. /*:244*//*270:*/
  18381. #line 376 "./units.w"
  18382. value= engine->newQMetaObject(&Units::staticMetaObject);
  18383. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  18384. value.setProperty("convertRelativeTemperature",
  18385. engine->newFunction(Units_convertRelativeTemperature));
  18386. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  18387. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  18388. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  18389. engine->globalObject().setProperty("Units",value);
  18390. /*:270*//*275:*/
  18391. #line 449 "./units.w"
  18392. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  18393. #line 6350 "./typica.w"
  18394. /*:275*//*283:*/
  18395. #line 141 "./measurement.w"
  18396. constructor= engine->newFunction(constructMeasurement);
  18397. engine->globalObject().setProperty("Measurement",constructor);
  18398. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  18399. /*:283*//*303:*/
  18400. #line 6920 "./typica.w"
  18401. constructor= engine->newFunction(constructDAQ);
  18402. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  18403. value.setProperty("Fahrenheit",Units::Fahrenheit);
  18404. value.setProperty("Celsius",Units::Celsius);
  18405. value.setProperty("Kelvin",Units::Kelvin);
  18406. value.setProperty("Rankine",Units::Rankine);
  18407. engine->globalObject().setProperty("DAQ",value);
  18408. /*:303*//*312:*/
  18409. #line 7122 "./typica.w"
  18410. constructor= engine->newFunction(constructFakeDAQ);
  18411. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  18412. engine->globalObject().setProperty("FakeDAQ",value);
  18413. /*:312*//*323:*/
  18414. #line 7405 "./typica.w"
  18415. constructor= engine->newFunction(constructLinearCalibrator);
  18416. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  18417. constructor);
  18418. engine->globalObject().setProperty("LinearCalibrator",value);
  18419. /*:323*//*328:*/
  18420. #line 7544 "./typica.w"
  18421. constructor= engine->newFunction(constructLinearSplineInterpolator);
  18422. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  18423. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  18424. /*:328*//*338:*/
  18425. #line 7749 "./typica.w"
  18426. constructor= engine->newFunction(constructTemperatureDisplay);
  18427. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  18428. constructor);
  18429. engine->globalObject().setProperty("TemperatureDisplay",value);
  18430. /*:338*//*346:*/
  18431. #line 7907 "./typica.w"
  18432. constructor= engine->newFunction(constructMeasurementTimeOffset);
  18433. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  18434. constructor);
  18435. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  18436. /*:346*//*351:*/
  18437. #line 8018 "./typica.w"
  18438. constructor= engine->newFunction(constructThresholdDetector);
  18439. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  18440. engine->globalObject().setProperty("ThresholdDetector",value);
  18441. /*:351*//*356:*/
  18442. #line 8117 "./typica.w"
  18443. constructor= engine->newFunction(constructZeroEmitter);
  18444. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  18445. engine->globalObject().setProperty("ZeroEmitter",value);
  18446. /*:356*//*361:*/
  18447. #line 8196 "./typica.w"
  18448. constructor= engine->newFunction(constructMeasurementAdapter);
  18449. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  18450. constructor);
  18451. engine->globalObject().setProperty("MeasurementAdapter",value);
  18452. /*:361*//*378:*/
  18453. #line 8659 "./typica.w"
  18454. constructor= engine->newFunction(constructGraphView);
  18455. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  18456. engine->globalObject().setProperty("GraphView",value);
  18457. /*:378*//*401:*/
  18458. #line 9296 "./typica.w"
  18459. constructor= engine->newFunction(constructZoomLog);
  18460. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  18461. engine->globalObject().setProperty("ZoomLog",value);
  18462. /*:401*//*439:*/
  18463. #line 10244 "./typica.w"
  18464. constructor= engine->newFunction(constructAnnotationButton);
  18465. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  18466. constructor);
  18467. engine->globalObject().setProperty("AnnotationButton",value);
  18468. /*:439*//*447:*/
  18469. #line 10386 "./typica.w"
  18470. constructor= engine->newFunction(constructAnnotationSpinBox);
  18471. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  18472. constructor);
  18473. engine->globalObject().setProperty("AnnotationSpinBox",value);
  18474. /*:447*//*468:*/
  18475. #line 10807 "./typica.w"
  18476. constructor= engine->newFunction(constructTimerDisplay);
  18477. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  18478. engine->globalObject().setProperty("TimerDisplay",value);
  18479. /*:468*//*495:*/
  18480. #line 11301 "./typica.w"
  18481. constructor= engine->newFunction(constructWidgetDecorator);
  18482. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  18483. engine->globalObject().setProperty("WidgetDecorator",value);
  18484. /*:495*//*508:*/
  18485. #line 11583 "./typica.w"
  18486. constructor= engine->newFunction(constructLogEditWindow);
  18487. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  18488. engine->globalObject().setProperty("LogEditWindow",value);
  18489. /*:508*//*527:*/
  18490. #line 12111 "./typica.w"
  18491. constructor= engine->newFunction(constructXMLInput);
  18492. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  18493. engine->globalObject().setProperty("XMLInput",value);
  18494. /*:527*//*541:*/
  18495. #line 149 "./webview.w"
  18496. constructor= engine->newFunction(constructWebView);
  18497. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  18498. engine->globalObject().setProperty("WebView",value);
  18499. /*:541*//*549:*/
  18500. #line 241 "./webview.w"
  18501. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  18502. /*:549*//*552:*/
  18503. #line 283 "./webview.w"
  18504. constructor= engine->newFunction(constructWebElement);
  18505. engine->globalObject().setProperty("WebElement",constructor);
  18506. /*:552*//*563:*/
  18507. #line 12354 "./typica.w"
  18508. value= engine->newQObject(AppInstance);
  18509. engine->globalObject().setProperty("Application",value);
  18510. /*:563*//*621:*/
  18511. #line 13455 "./typica.w"
  18512. constructor= engine->newFunction(constructSqlQueryView);
  18513. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  18514. engine->globalObject().setProperty("SqlQueryView",value);
  18515. /*:621*//*726:*/
  18516. #line 15357 "./typica.w"
  18517. constructor= engine->newFunction(constructDeviceTreeModel);
  18518. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  18519. constructor);
  18520. engine->globalObject().setProperty("DeviceTreeModel",value);
  18521. /*:726*//*732:*/
  18522. #line 15497 "./typica.w"
  18523. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  18524. /*:732*//*748:*/
  18525. #line 15789 "./typica.w"
  18526. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  18527. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  18528. constructor);
  18529. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  18530. /*:748*//*819:*/
  18531. #line 56 "./settings.w"
  18532. constructor= engine->newFunction(constructSettingsWindow);
  18533. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  18534. engine->globalObject().setProperty("SettingsWindow",value);
  18535. #line 1 "./graphsettings.w"
  18536. /*:819*//*842:*/
  18537. #line 18350 "./typica.w"
  18538. constructor= engine->newFunction(constructModbusRTUDevice);
  18539. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  18540. engine->globalObject().setProperty("ModbusRTUDevice",value);
  18541. /*:842*//*862:*/
  18542. #line 350 "./unsupportedserial.w"
  18543. engine->globalObject().setProperty("createDevice",
  18544. engine->newFunction(createDevice));
  18545. /*:862*//*874:*/
  18546. #line 622 "./unsupportedserial.w"
  18547. engine->globalObject().setProperty("getMeasurementTimestamp",
  18548. engine->newFunction(getMeasurementTimestamp));
  18549. /*:874*//*878:*/
  18550. #line 658 "./unsupportedserial.w"
  18551. constructor= engine->newFunction(constructSerialPort);
  18552. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  18553. engine->globalObject().setProperty("SerialPort",value);
  18554. /*:878*//*883:*/
  18555. #line 713 "./unsupportedserial.w"
  18556. constructor= engine->newFunction(constructQTimer);
  18557. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  18558. engine->globalObject().setProperty("Timer",value);
  18559. /*:883*//*903:*/
  18560. #line 450 "./phidgets.w"
  18561. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  18562. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  18563. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  18564. /*:903*//*923:*/
  18565. #line 144 "./rate.w"
  18566. constructor= engine->newFunction(constructRateOfChange);
  18567. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  18568. engine->globalObject().setProperty("RateOfChange",value);
  18569. /*:923*//*948:*/
  18570. #line 604 "./dataqsdk.w"
  18571. constructor= engine->newFunction(constructDataqSdkDevice);
  18572. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  18573. engine->globalObject().setProperty("DataqSdkDevice",value);
  18574. /*:948*//*975:*/
  18575. #line 73 "./scales.w"
  18576. constructor= engine->newFunction(constructDragLabel);
  18577. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  18578. engine->globalObject().setProperty("DragLabel",value);
  18579. /*:975*//*983:*/
  18580. #line 239 "./scales.w"
  18581. constructor= engine->newFunction(constructSerialScale);
  18582. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  18583. engine->globalObject().setProperty("SerialScale",value);
  18584. /*:983*//*987:*/
  18585. #line 325 "./scales.w"
  18586. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  18587. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  18588. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  18589. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  18590. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  18591. /*:987*//*1011:*/
  18592. #line 271 "./valueannotation.w"
  18593. constructor= engine->newFunction(constructValueAnnotation);
  18594. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  18595. engine->globalObject().setProperty("ValueAnnotation",value);
  18596. /*:1011*/
  18597. #line 13080 "./typica.w"
  18598. app.engine= engine;
  18599. /*181:*/
  18600. #line 4266 "./typica.w"
  18601. QString styleText;
  18602. QString programText;
  18603. QDomElement currentElement;
  18604. for(int i= 0;i<children.size();i++)
  18605. {
  18606. QDomNode currentNode= children.at(i);
  18607. if(currentNode.nodeName()=="style")
  18608. {
  18609. currentElement= currentNode.toElement();
  18610. styleText.append(currentElement.text());
  18611. }
  18612. else if(currentNode.nodeName()=="program")
  18613. {
  18614. currentElement= currentNode.toElement();
  18615. programText.append(currentElement.text());
  18616. }
  18617. }
  18618. app.setStyleSheet(styleText);
  18619. QScriptValue result= engine->evaluate(programText);
  18620. /*182:*/
  18621. #line 4291 "./typica.w"
  18622. if(engine->hasUncaughtException())
  18623. {
  18624. int line= engine->uncaughtExceptionLineNumber();
  18625. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  18626. result.toString();
  18627. QString trace;
  18628. foreach(trace,engine->uncaughtExceptionBacktrace())
  18629. {
  18630. qDebug()<<trace;
  18631. }
  18632. }
  18633. /*:182*/
  18634. #line 4286 "./typica.w"
  18635. /*:181*/
  18636. #line 13082 "./typica.w"
  18637. int retval= app.exec();
  18638. delete engine;
  18639. return retval;
  18640. }
  18641. /*:598*/
  18642. #line 532 "./typica.w"
  18643. #include "moc_typica.cpp"
  18644. /*:3*/