RecipeDataBase.cs 242 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751
  1. using Aitex.Core.RT.Log;
  2. using Caliburn.Micro.Core;
  3. using MECF.Framework.Common.CommonData;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.Common.RecipeCenter;
  6. using MECF.Framework.Common.Utilities;
  7. using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
  8. using RecipeEditorLib.DGExtension.CustomColumn;
  9. using RecipeEditorLib.RecipeModel.Params;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Collections.ObjectModel;
  13. using System.Linq;
  14. using System.Reflection;
  15. using System.Text;
  16. using System.Windows;
  17. using System.Xml;
  18. using System.ComponentModel;
  19. using OpenSEMI.ClientBase;
  20. using MECF.Framework.UI.Client.ClientBase;
  21. using System.Collections;
  22. namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
  23. {
  24. public class RecipeTable : PropertyChangedBase
  25. {
  26. private int _Index;
  27. public int Index
  28. {
  29. get { return _Index; }
  30. set { _Index = value; this.NotifyOfPropertyChange(nameof(Index)); }
  31. }
  32. private string _Name;
  33. public string Name
  34. {
  35. get { return _Name; }
  36. set { _Name = value; this.NotifyOfPropertyChange(nameof(Name)); }
  37. }
  38. private string _EndStatus;
  39. public string EndStatus
  40. {
  41. get { return _EndStatus; }
  42. set { _EndStatus = value; this.NotifyOfPropertyChange(nameof(EndStatus)); }
  43. }
  44. private RecipeDataBase _TableData;
  45. public RecipeDataBase TableData
  46. {
  47. get { return _TableData; }
  48. set { _TableData = value; this.NotifyOfPropertyChange(nameof(TableData)); }
  49. }
  50. }
  51. public class RecipeDataBase : PropertyChangedBase
  52. {
  53. public static string[] SaveTableRecipeTypes = new string[] { "sub", "alarm", "abort" };
  54. public static string ProcessType = "Process";
  55. public bool GetIsTableType
  56. {
  57. get
  58. {
  59. if (string.IsNullOrEmpty(RecipeChamberType))
  60. return false;
  61. else if (SaveTableRecipeTypes.Contains(RecipeChamberType))
  62. {
  63. return true;
  64. }
  65. else
  66. {
  67. return false;
  68. }
  69. }
  70. }
  71. public bool IsChanged
  72. {
  73. get
  74. {
  75. bool changed = !IsSavedDesc;
  76. if (!changed)
  77. {
  78. //changed = ChkChanged(Steps) || ChkChanged(PopSettingSteps) || ChkChanged(StepTolerances);
  79. }
  80. if (!changed)
  81. {
  82. foreach (Param config in this.ConfigItems)
  83. {
  84. if (!config.IsSaved)
  85. {
  86. changed = true;
  87. break;
  88. }
  89. }
  90. }
  91. return changed;
  92. }
  93. }
  94. private bool _isSavedDesc;
  95. public bool IsSavedDesc
  96. {
  97. get { return _isSavedDesc; }
  98. set
  99. {
  100. this._isSavedDesc = value;
  101. this.NotifyOfPropertyChange("IsSavedDesc");
  102. }
  103. }
  104. private string name;
  105. public string Name
  106. {
  107. get { return this.name; }
  108. set
  109. {
  110. this.name = value;
  111. this.NotifyOfPropertyChange("Name");
  112. }
  113. }
  114. private string _chamberType;
  115. public string RecipeChamberType
  116. {
  117. get { return this._chamberType; }
  118. set
  119. {
  120. this._chamberType = value;
  121. CreateTable(value);
  122. this.NotifyOfPropertyChange("RecipeChamberType");
  123. }
  124. }
  125. public void CreateTable(string type)
  126. {
  127. if (SaveTableRecipeTypes.Contains(type))
  128. {
  129. int maxCount = 20;
  130. if (type.ToLower() == "abort")
  131. {
  132. maxCount = 10;
  133. }
  134. for (int i = 0; i < maxCount; i++)
  135. {
  136. Tables.Add(new RecipeTable()
  137. { Index = i + 1, Name = "", EndStatus = "", TableData = new RecipeDataBase() });
  138. }
  139. }
  140. }
  141. private string _recipeVersion;
  142. public string RecipeVersion
  143. {
  144. get { return this._recipeVersion; }
  145. set
  146. {
  147. this._recipeVersion = value;
  148. this.NotifyOfPropertyChange("RecipeVersion");
  149. }
  150. }
  151. private string _recipePermission;
  152. public string RecipePermission
  153. {
  154. get { return this._recipePermission; }
  155. set
  156. {
  157. this._recipePermission = value;
  158. this.NotifyOfPropertyChange("RecipePermisson");
  159. }
  160. }
  161. private string _recipeLevel;
  162. public string RecipeLevel
  163. {
  164. get { return this._recipeLevel; }
  165. set
  166. {
  167. this._recipeLevel = value;
  168. this.NotifyOfPropertyChange("RecipeLevel");
  169. }
  170. }
  171. private string _prefixPath;
  172. public string PrefixPath
  173. {
  174. get { return _prefixPath; }
  175. set
  176. {
  177. _prefixPath = value;
  178. this.NotifyOfPropertyChange("PrefixPath");
  179. }
  180. }
  181. private string creator;
  182. public string Creator
  183. {
  184. get { return this.creator; }
  185. set
  186. {
  187. this.creator = value;
  188. this.NotifyOfPropertyChange("Creator");
  189. }
  190. }
  191. private DateTime createTime;
  192. public DateTime CreateTime
  193. {
  194. get { return this.createTime; }
  195. set
  196. {
  197. this.createTime = value;
  198. this.NotifyOfPropertyChange("CreateTime");
  199. }
  200. }
  201. private string description;
  202. public string Description
  203. {
  204. get { return this.description; }
  205. set
  206. {
  207. this.description = value;
  208. this.NotifyOfPropertyChange("Description");
  209. }
  210. }
  211. private string devisor;
  212. public string Revisor
  213. {
  214. get { return this.devisor; }
  215. set
  216. {
  217. this.devisor = value;
  218. this.NotifyOfPropertyChange("Revisor");
  219. }
  220. }
  221. private int _TableIndex = 1;
  222. public int TableIndex
  223. {
  224. get { return this._TableIndex; }
  225. set
  226. {
  227. this._TableIndex = value;
  228. this.NotifyOfPropertyChange("TableIndex");
  229. }
  230. }
  231. public string Time
  232. {
  233. get => GetTime();
  234. }
  235. private string GetTime()
  236. {
  237. var parm = this.ConfigItems.FirstOrDefault(x => x.Name == "RecipeTime") as StringParam;
  238. if (parm != null)
  239. {
  240. return ConvertSecondsToHMSFormat(parm.Value);
  241. }
  242. return "00:00:00.0";
  243. }
  244. public static string ConvertSecondsToHMSFormat(string strTotalSeconds)
  245. {
  246. double totalSeconds = 0;
  247. double.TryParse(strTotalSeconds, out totalSeconds);
  248. int intTotalSeconds = (int)totalSeconds;
  249. int hours = intTotalSeconds / 3600;
  250. int minutes = (intTotalSeconds % 3600) / 60;
  251. double seconds = intTotalSeconds % 60 + (totalSeconds - intTotalSeconds);
  252. return string.Format("{0:00}:{1:00}:{2:00.0}", hours, minutes, seconds);
  253. }
  254. public string TableName => Tables.Count > 0 ? Tables.FirstOrDefault(x => x.Index == TableIndex).Name : "";
  255. private DateTime deviseTime;
  256. public DateTime ReviseTime
  257. {
  258. get { return this.deviseTime; }
  259. set
  260. {
  261. this.deviseTime = value;
  262. this.NotifyOfPropertyChange("ReviseTime");
  263. }
  264. }
  265. public ObservableCollection<Step> Steps { get; set; }
  266. public Dictionary<string, ObservableCollection<ObservableCollection<Param>>> PopSettingSteps { get; private set; }
  267. public ObservableCollection<ObservableCollection<Param>> StepTolerances { get; private set; }
  268. public ObservableCollection<Param> ConfigItems { get; private set; }
  269. public List<int> StepNos { get; set; } = new List<int>();
  270. private XmlDocument _doc;
  271. private string _module = "PM1";
  272. public bool ToleranceEnable { get; set; }
  273. public Dictionary<string, bool> PopEnable { get; set; }
  274. public bool IsCompatibleWithCurrentFormat { get; set; }
  275. private RecipeProvider _recipeProvider = new RecipeProvider();
  276. private Dictionary<string, ObservableCollection<RecipeTemplateColumnBase>> RecipeTemplate;
  277. public ObservableCollection<RecipeTable> Tables { get; set; } = new ObservableCollection<RecipeTable>();
  278. public void ShallowCopyStep(ref Step destinationStep, Step originalStep)
  279. {
  280. int stepNo = destinationStep.StepNo;
  281. Type type = originalStep.GetType();
  282. PropertyInfo[] properties = type.GetProperties();
  283. TraverseAndAssign(destinationStep, originalStep);
  284. // 遍历属性并赋值
  285. //foreach (PropertyInfo property in properties)
  286. //{
  287. // // 判断属性是否可写
  288. // if (property.CanWrite)
  289. // {
  290. // // 设置属性的值
  291. // property.SetValue(destinationStep, property.GetValue(originalStep));
  292. // }
  293. //}
  294. destinationStep.StepNo = stepNo;
  295. }
  296. static void TraverseAndAssign(object source, object target)
  297. {
  298. if (source == null || target == null) return;
  299. Type sourceType = source.GetType();
  300. Type targetType = target.GetType();
  301. if (sourceType != targetType) return;
  302. PropertyInfo[] properties = sourceType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
  303. foreach (PropertyInfo property in properties)
  304. {
  305. if (property.CanRead && property.CanWrite)
  306. {
  307. Type propertyType = property.PropertyType;
  308. object sourceValue = property.GetValue(source);
  309. object targetValue = property.GetValue(target);
  310. if (IsPrimitiveType(propertyType))
  311. {
  312. // 基础类型赋值
  313. property.SetValue(source, targetValue);
  314. }
  315. else if (typeof(IEnumerable).IsAssignableFrom(propertyType) &&
  316. !typeof(string).IsAssignableFrom(propertyType))
  317. {
  318. // 处理集合类型,如 ObservableCollection<T>
  319. IEnumerable sourceCollection = sourceValue as IEnumerable;
  320. IEnumerable targetCollection = targetValue as IEnumerable;
  321. if (sourceCollection != null && targetCollection != null)
  322. {
  323. IEnumerator sourceEnumerator = sourceCollection.GetEnumerator();
  324. IEnumerator targetEnumerator = targetCollection.GetEnumerator();
  325. while (sourceEnumerator.MoveNext() && targetEnumerator.MoveNext())
  326. {
  327. TraverseAndAssign(sourceEnumerator.Current, targetEnumerator.Current);
  328. }
  329. }
  330. }
  331. else
  332. {
  333. // 处理对象类型
  334. if (sourceValue != null && targetValue != null)
  335. {
  336. TraverseAndAssign(sourceValue, targetValue);
  337. }
  338. }
  339. }
  340. }
  341. }
  342. static bool IsPrimitiveType(Type type)
  343. {
  344. return type == typeof(string) || type == typeof(bool) || type == typeof(double) ||
  345. type == typeof(int) || type == typeof(float) || type == typeof(decimal) ||
  346. type == typeof(DateTime) || type.IsPrimitive;
  347. }
  348. public void CloneStep(ref Step destinationStep, Step originalStep)
  349. {
  350. int stepNo = destinationStep.StepNo;
  351. destinationStep = (Step)CloneUtil.CloneObjectSetFlag(originalStep, "IsSaved", true);
  352. destinationStep.StepNo = stepNo;
  353. SetDelegateEvent(destinationStep);
  354. ////destinationStep.StepNo = originalStep.StepNo;
  355. //destinationStep.Name = originalStep.Name;
  356. //destinationStep.Time = originalStep.Time;
  357. //destinationStep.SkipWait = originalStep.SkipWait;
  358. //destinationStep.EndBy = originalStep.EndBy;
  359. //destinationStep.MFCSets = originalStep.MFCSets;
  360. //destinationStep.MFMSets = originalStep.MFMSets;
  361. //destinationStep.ValveSets = originalStep.ValveSets;
  362. ////destinationStep.AlarmActionSets = originalStep.AlarmActionSets;
  363. //foreach (var temkey in originalStep.AlarmActionSets.Keys)
  364. //{
  365. // if (!destinationStep.AlarmActionSets.ContainsKey(temkey))
  366. // {
  367. // destinationStep.AlarmActionSets.Add(temkey, originalStep.AlarmActionSets[temkey]);
  368. // }
  369. // else
  370. // {
  371. // destinationStep.AlarmActionSets[temkey] = originalStep.AlarmActionSets[temkey];
  372. // }
  373. //}
  374. //destinationStep.AlarmConditionTable = originalStep.AlarmConditionTable;
  375. ////destinationStep.TemperatureSets = originalStep.TemperatureSets;
  376. //foreach (var temkey in originalStep.TemperatureSets.Keys)
  377. //{
  378. // if (!destinationStep.TemperatureSets.ContainsKey(temkey))
  379. // {
  380. // destinationStep.TemperatureSets.Add(temkey, originalStep.TemperatureSets[temkey]);
  381. // }
  382. // else
  383. // {
  384. // destinationStep.TemperatureSets[temkey] = originalStep.TemperatureSets[temkey];
  385. // }
  386. //}
  387. //destinationStep.TemperatureControlMode = originalStep.TemperatureControlMode;
  388. //destinationStep.TemperatureCorrect = originalStep.TemperatureCorrect;
  389. //destinationStep.TemperaturePID = originalStep.TemperaturePID;
  390. //destinationStep.LoaderCommand = originalStep.LoaderCommand;
  391. //destinationStep.LoaderValue = originalStep.LoaderValue;
  392. //destinationStep.PressCommand = originalStep.PressCommand;
  393. //destinationStep.PressValue = originalStep.PressValue;
  394. //destinationStep.TemperatureProfile = originalStep.TemperatureProfile;
  395. //destinationStep.TemperatureAlarm = originalStep.TemperatureAlarm;
  396. //destinationStep.CAPTemperatureAlarm = originalStep.CAPTemperatureAlarm;
  397. //destinationStep.CAPSetValue = originalStep.CAPSetValue;
  398. //destinationStep.CAPRampingValue = originalStep.CAPRampingValue;
  399. //destinationStep.TemperatureStabilize = originalStep.TemperatureStabilize;
  400. //destinationStep.TemperatureReadyCond = originalStep.TemperatureReadyCond;
  401. //destinationStep.RFSwitch = originalStep.RFSwitch;
  402. //destinationStep.RFSetpoint = originalStep.RFSetpoint;
  403. //destinationStep.RFPowerSetpoint = originalStep.RFPowerSetpoint;
  404. //destinationStep.C1Setpoint = originalStep.C1Setpoint;
  405. //destinationStep.C2Setpoint = originalStep.C2Setpoint;
  406. //destinationStep.ForwardPowerAlarmWatchTable = originalStep.ForwardPowerAlarmWatchTable;
  407. //destinationStep.PrAlarmWatchTable = originalStep.PrAlarmWatchTable;
  408. //destinationStep.PIAlarmWatchTable = originalStep.PIAlarmWatchTable;
  409. //destinationStep.C1AlarmWatchTable = originalStep.C1AlarmWatchTable;
  410. //destinationStep.C2AlarmWatchTable = originalStep.C2AlarmWatchTable;
  411. //destinationStep.VppAlarmWatchTable = originalStep.VppAlarmWatchTable;
  412. //destinationStep.VdcAlarmWatchTable = originalStep.VdcAlarmWatchTable;
  413. ////destinationStep.Command = originalStep.Command;
  414. ////destinationStep.APC_SetPressure = originalStep.APC_SetPressure;
  415. ////destinationStep.EXOUSets = originalStep.EXOUSets;
  416. ////destinationStep.ExternalSensor = originalStep.ExternalSensor;
  417. ////destinationStep.GasLineN2_Flow = originalStep.GasLineN2_Flow;
  418. ////destinationStep.GasLineN3_Flow = originalStep.GasLineN3_Flow;
  419. ////destinationStep.IsnoneConditionCheck = originalStep.IsnoneConditionCheck;
  420. ////destinationStep.ZAxisPosition = originalStep.ZAxisPosition;
  421. ////destinationStep.ZAxisSpeed = originalStep.ZAxisSpeed;
  422. ////destinationStep.RotatePosition = originalStep.RotatePosition;
  423. ////destinationStep.RotateSpeed = originalStep.RotateSpeed;
  424. ////destinationStep.RotateInterval = originalStep.RotateInterval;
  425. ////destinationStep.ReachPressureValue = originalStep.ReachPressureValue;
  426. ////destinationStep.PressureStabilizeSelected = originalStep.PressureStabilizeSelected;
  427. ////destinationStep.PressureSonserValue = originalStep.PressureSonserValue;
  428. ////destinationStep.PressureValveAngle = originalStep.PressureValveAngle;
  429. ////destinationStep.PressureSettingVG = originalStep.PressureSettingVG;
  430. ////destinationStep.PressureAlarmTableNo = originalStep.PressureAlarmTableNo;
  431. ////destinationStep.EventSetting = originalStep.EventSetting;
  432. ////destinationStep.FinishAutoProfile = originalStep.FinishAutoProfile;
  433. ////destinationStep.ReachTemp = originalStep.ReachTemp;
  434. ////destinationStep.ReachPressure = originalStep.ReachPressure;
  435. ////destinationStep.ReachPressureVG = originalStep.ReachPressureVG;
  436. ////destinationStep.PressureStabilizeVG = originalStep.PressureStabilizeVG;
  437. ////destinationStep.ReachTempValue = originalStep.ReachTempValue;
  438. ////destinationStep.TempStabilizeSelected = originalStep.TempStabilizeSelected;
  439. }
  440. public void CloneStep(Step destinationStep, Step originalStep)
  441. {
  442. //destinationStep.StepNo = originalStep.StepNo;
  443. //destinationStep.Name = originalStep.Name;
  444. //destinationStep.EndBy = originalStep.EndBy;
  445. //destinationStep.Time = originalStep.Time;
  446. //destinationStep.SkipWait = originalStep.SkipWait;
  447. //destinationStep.Command = originalStep.Command;
  448. //destinationStep.APC_SetPressure = originalStep.APC_SetPressure;
  449. //destinationStep.EXOUSets = originalStep.EXOUSets;
  450. //destinationStep.ExternalSensor = originalStep.ExternalSensor;
  451. //destinationStep.GasLineN2_Flow = originalStep.GasLineN2_Flow;
  452. //destinationStep.GasLineN3_Flow = originalStep.GasLineN3_Flow;
  453. //destinationStep.IsnoneConditionCheck = originalStep.IsnoneConditionCheck;
  454. //destinationStep.ZAxisPosition = originalStep.ZAxisPosition;
  455. //destinationStep.ZAxisSpeed = originalStep.ZAxisSpeed;
  456. //destinationStep.RotatePosition = originalStep.RotatePosition;
  457. //destinationStep.RotateSpeed = originalStep.RotateSpeed;
  458. //destinationStep.RotateInterval = originalStep.RotateInterval;
  459. //destinationStep.MFCSets = originalStep.MFCSets;
  460. //destinationStep.MFMSets = originalStep.MFMSets;
  461. //destinationStep.ValveSets = originalStep.ValveSets;
  462. //destinationStep.ReachPressureValue = originalStep.ReachPressureValue;
  463. //destinationStep.PressureStabilizeSelected = originalStep.PressureStabilizeSelected;
  464. //destinationStep.PressureSonserValue = originalStep.PressureSonserValue;
  465. //destinationStep.PressureValveAngle = originalStep.PressureValveAngle;
  466. //destinationStep.PressureSettingVG = originalStep.PressureSettingVG;
  467. //destinationStep.SlowVacuumValue = originalStep.SlowVacuumValue;
  468. //destinationStep.PressureAlarmTableNo = originalStep.PressureAlarmTableNo;
  469. //destinationStep.TemperatureCorrect = originalStep.TemperatureCorrect;
  470. //destinationStep.TemperaturePID = originalStep.TemperaturePID;
  471. //destinationStep.LoaderCommand = originalStep.LoaderCommand;
  472. //destinationStep.LoaderValue = originalStep.LoaderValue;
  473. //destinationStep.PressCommand = originalStep.PressCommand;
  474. //destinationStep.PressValue = originalStep.PressValue;
  475. //destinationStep.TemperatureSets = originalStep.TemperatureSets;
  476. //destinationStep.EventSetting = originalStep.EventSetting;
  477. //destinationStep.FinishAutoProfile = originalStep.FinishAutoProfile;
  478. //destinationStep.ReachTemp = originalStep.ReachTemp;
  479. //destinationStep.O2Density = originalStep.O2Density;
  480. //destinationStep.ReachPressure = originalStep.ReachPressure;
  481. //destinationStep.ReachPressureVG = originalStep.ReachPressureVG;
  482. //destinationStep.PressureStabilizeVG = originalStep.PressureStabilizeVG;
  483. //destinationStep.ReachTempValue = originalStep.ReachTempValue;
  484. //destinationStep.O2DensityValue = originalStep.O2DensityValue;
  485. //destinationStep.RotateDirection = originalStep.RotateDirection;
  486. //destinationStep.TempStabilizeSelected = originalStep.TempStabilizeSelected;
  487. destinationStep = (Step)CloneUtil.CloneObject(originalStep);
  488. SetDelegateEvent(destinationStep);
  489. }
  490. public RecipeDataBase()
  491. {
  492. this.Steps = new ObservableCollection<Step>();
  493. StepTolerances = new ObservableCollection<ObservableCollection<Param>>();
  494. this.PopSettingSteps = new Dictionary<string, ObservableCollection<ObservableCollection<Param>>>();
  495. this.PopEnable = new Dictionary<string, bool>();
  496. ConfigItems = new ObservableCollection<Param>()
  497. {
  498. new StringParam { Name="Combination.SubRecipe"},
  499. new StringParam { Name="Combination.AlarmRecipe"},
  500. new StringParam { Name="Combination.AlarmCondition"},
  501. new StringParam { Name="Combination.LeakCheck"},
  502. new StringParam { Name="Combination.AbortRecipe"},
  503. new StringParam { Name="Combination.PressAPCPID"},
  504. new StringParam { Name="Combination.TempCorrection"},
  505. new StringParam { Name="Combination.TempPID"},
  506. new StringParam { Name="Combination.ProfileCondition"},
  507. new StringParam { Name="RecipeTime"},
  508. new StringParam { Name="N2PurgeMode",Value = "None"},
  509. };
  510. IsSavedDesc = true;
  511. _doc = new XmlDocument();
  512. XmlElement node = _doc.CreateElement("Aitex");
  513. _doc.AppendChild(node);
  514. node.AppendChild(_doc.CreateElement("TableRecipeData"));
  515. string vars = _recipeProvider.GetRecipeFormatXml(MECF.Framework.Common.Equipment.ModuleName.PM1);
  516. RecipeTemplate = _recipeProvider.GetGroupRecipeTemplate();
  517. StepCollectionChanged();
  518. }
  519. private void StepCollectionChanged()
  520. {
  521. foreach (var item in Steps)
  522. {
  523. item.TempValueChangedEvent += Item_TempValueChangedEvent;
  524. item.MFCValueChangedEvent += Item_MFCValueChangedEvent;
  525. item.ValveValueChangedEvent += Item_ValveValueChangedEvent;
  526. item.AUXValueChangedEvent += Item_AUXValueChangedEvent;
  527. item.OhterTempValueChangedEvent += Item_OhterTempValueChangedEvent;
  528. item.PressureValueChangedEvent += Item_PressureValueChangedEvent;
  529. item.LoaderValueChangedEvent += Item_LoaderValueChangedEvent;
  530. item.AlarmValueChangedEvent += Item_AlarmValueChangedEvent;
  531. }
  532. Steps.CollectionChanged += (s, e) =>
  533. {
  534. if (e.OldItems != null)
  535. {
  536. foreach (Step item in e.OldItems)
  537. {
  538. item.TempValueChangedEvent -= Item_TempValueChangedEvent;
  539. item.MFCValueChangedEvent -= Item_MFCValueChangedEvent;
  540. item.ValveValueChangedEvent -= Item_ValveValueChangedEvent;
  541. item.AUXValueChangedEvent -= Item_AUXValueChangedEvent;
  542. item.OhterTempValueChangedEvent -= Item_OhterTempValueChangedEvent;
  543. item.PressureValueChangedEvent -= Item_PressureValueChangedEvent;
  544. item.LoaderValueChangedEvent -= Item_LoaderValueChangedEvent;
  545. item.AlarmValueChangedEvent -= Item_AlarmValueChangedEvent;
  546. }
  547. }
  548. if (e.NewItems != null)
  549. {
  550. foreach (Step item in e.NewItems)
  551. {
  552. item.TempValueChangedEvent += Item_TempValueChangedEvent;
  553. item.MFCValueChangedEvent += Item_MFCValueChangedEvent;
  554. item.ValveValueChangedEvent += Item_ValveValueChangedEvent;
  555. item.AUXValueChangedEvent += Item_AUXValueChangedEvent;
  556. item.OhterTempValueChangedEvent += Item_OhterTempValueChangedEvent;
  557. item.PressureValueChangedEvent += Item_PressureValueChangedEvent;
  558. item.LoaderValueChangedEvent += Item_LoaderValueChangedEvent;
  559. item.AlarmValueChangedEvent += Item_AlarmValueChangedEvent;
  560. }
  561. }
  562. };
  563. }
  564. private void Item_LoaderValueChangedEvent(object sender, SetValueEventArgs e)
  565. {
  566. //throw new NotImplementedException();
  567. }
  568. private void Item_AlarmValueChangedEvent(object sender, SetValueEventArgs e)
  569. {
  570. if (sender != null && sender is Step)
  571. {
  572. var step = sender as Step;
  573. int stepIndex = Steps.IndexOf(step);
  574. if (stepIndex < Steps.Count - 1)
  575. {
  576. for (int i = stepIndex + 1; i < Steps.Count; i++)
  577. {
  578. if (Steps[i].AlarmIsSaved)
  579. {
  580. string tempName = e.ValueName;
  581. string proName = e.PropertyName;
  582. string proValue = e.PropertyValue;
  583. Type type = Steps[i].GetType();
  584. PropertyInfo[] properties = type.GetProperties();
  585. var property = properties.FirstOrDefault(x => x.Name == proName);
  586. if (property != null)
  587. {
  588. var proParam = property.GetValue(Steps[i]);
  589. if (proParam is StringParam)
  590. {
  591. ((StringParam)proParam).Value = proValue;
  592. //property.SetValue(Steps[i], proParam);
  593. }
  594. }
  595. }
  596. else
  597. { break; }
  598. }
  599. }
  600. }
  601. }
  602. private void Item_PressureValueChangedEvent(object sender, SetValueEventArgs e)
  603. {
  604. if (sender != null && sender is Step)
  605. {
  606. var step = sender as Step;
  607. int stepIndex = Steps.IndexOf(step);
  608. if (stepIndex < Steps.Count - 1)
  609. {
  610. for (int i = stepIndex + 1; i < Steps.Count; i++)
  611. {
  612. if (Steps[i].PressIsSaved)
  613. {
  614. string tempName = e.ValueName;
  615. string proName = e.PropertyName;
  616. string proValue = e.PropertyValue;
  617. Type type = Steps[i].GetType();
  618. PropertyInfo[] properties = type.GetProperties();
  619. var property = properties.FirstOrDefault(x => x.Name == proName);
  620. if (property != null)
  621. {
  622. var proParam = property.GetValue(Steps[i]);
  623. if (proParam is DoubleParam)
  624. {
  625. ((DoubleParam)proParam).Value = proValue;
  626. property.SetValue(Steps[i], proParam);
  627. }
  628. else if (proParam is StringParam)
  629. {
  630. ((StringParam)proParam).Value = proValue;
  631. property.SetValue(Steps[i], proParam);
  632. }
  633. }
  634. }
  635. else
  636. { break; }
  637. }
  638. }
  639. }
  640. }
  641. private void Item_OhterTempValueChangedEvent(object sender, SetValueEventArgs e)
  642. {
  643. if (sender != null && sender is Step)
  644. {
  645. var step = sender as Step;
  646. int stepIndex = Steps.IndexOf(step);
  647. if (stepIndex < Steps.Count - 1)
  648. {
  649. for (int i = stepIndex + 1; i < Steps.Count; i++)
  650. {
  651. if (Steps[i].TemperatureIsSaved)
  652. {
  653. string tempName = e.ValueName;
  654. string proName = e.PropertyName;
  655. string proValue = e.PropertyValue;
  656. Type type = Steps[i].GetType();
  657. PropertyInfo[] properties = type.GetProperties();
  658. var property = properties.FirstOrDefault(x => x.Name == proName);
  659. if (property != null)
  660. {
  661. var proParam = property.GetValue(Steps[i]);
  662. if (proParam is DoubleParam)
  663. {
  664. ((DoubleParam)proParam).Value = proValue;
  665. property.SetValue(Steps[i], proParam);
  666. }
  667. else if (proParam is StringParam)
  668. {
  669. ((StringParam)proParam).Value = proValue;
  670. ((StringParam)proParam).IsSaved = true;
  671. property.SetValue(Steps[i], proParam);
  672. }
  673. else if (proParam is BoolParam)
  674. {
  675. bool tryValue = true;
  676. bool.TryParse(proValue, out tryValue);
  677. ((BoolParam)proParam).Value = tryValue;
  678. property.SetValue(Steps[i], proParam);
  679. }
  680. }
  681. }
  682. else
  683. { break; }
  684. }
  685. }
  686. }
  687. }
  688. private void Item_MFCValueChangedEvent(object sender, SetValueEventArgs e)
  689. {
  690. if (sender != null && sender is Step)
  691. {
  692. var step = sender as Step;
  693. int stepIndex = Steps.IndexOf(step);
  694. if (stepIndex < Steps.Count - 1)
  695. {
  696. for (int i = stepIndex + 1; i < Steps.Count; i++)
  697. {
  698. if (Steps[i].MFCIsSaved)
  699. {
  700. var tempData = (MFCData)e.Sender;
  701. string tempName = e.ValueName;
  702. string proName = e.PropertyName;
  703. string proValue = e.PropertyValue;
  704. var temp = Steps[i].MFCSets.FirstOrDefault(x => x.ControlName == tempName);
  705. Type type = temp.GetType();
  706. PropertyInfo[] properties = type.GetProperties();
  707. var property = properties.FirstOrDefault(x => x.Name == proName);
  708. if (property != null)
  709. {
  710. var proParam = property.GetValue(temp);
  711. if (proParam is DoubleParam)
  712. {
  713. ((DoubleParam)proParam).Value = proValue;
  714. property.SetValue(temp, proParam);
  715. }
  716. else if (proParam is IntParam)
  717. {
  718. int.TryParse(proValue, out int outValue);
  719. ((IntParam)proParam).Value = outValue;
  720. property.SetValue(temp, proParam);
  721. }
  722. else if (proParam is StringParam)
  723. {
  724. ((StringParam)proParam).Value = proValue;
  725. property.SetValue(temp, proParam);
  726. }
  727. else if (proParam is BoolParam)
  728. {
  729. bool tryValue = true;
  730. bool.TryParse(proValue, out tryValue);
  731. ((BoolParam)proParam).Value = tryValue;
  732. property.SetValue(temp, proParam);
  733. }
  734. }
  735. }
  736. else
  737. { break; }
  738. }
  739. }
  740. }
  741. }
  742. private void Item_TempValueChangedEvent(object sender, SetValueEventArgs e)
  743. {
  744. if (sender != null && sender is Step)
  745. {
  746. var step = sender as Step;
  747. int stepIndex = Steps.IndexOf(step);
  748. if (stepIndex < Steps.Count - 1)
  749. {
  750. for (int i = stepIndex + 1; i < Steps.Count; i++)
  751. {
  752. if (Steps[i].TemperatureIsSaved)
  753. {
  754. var tempData = (TempSetData)e.Sender;
  755. string tempName = e.ValueName;
  756. string proName = e.PropertyName;
  757. string proValue = e.PropertyValue;
  758. var temp = Steps[i].TemperatureSets.FirstOrDefault(x => x.Name == tempName);
  759. Type type = temp.GetType();
  760. PropertyInfo[] properties = type.GetProperties();
  761. var property = properties.FirstOrDefault(x => x.Name == proName);
  762. if (property != null)
  763. {
  764. var proParam = property.GetValue(temp);
  765. if (proParam is DoubleParam)
  766. {
  767. ((DoubleParam)proParam).Value = proValue;
  768. property.SetValue(temp, proParam);
  769. }
  770. else if (proParam is StringParam)
  771. {
  772. ((StringParam)proParam).Value = proValue;
  773. property.SetValue(temp, proParam);
  774. }
  775. }
  776. }
  777. else
  778. { break; }
  779. }
  780. }
  781. }
  782. }
  783. private void Item_TempOtherValueChangedEvent(object sender, SetValueEventArgs e)
  784. {
  785. if (sender != null && sender is Step)
  786. {
  787. var step = sender as Step;
  788. int stepIndex = Steps.IndexOf(step);
  789. if (stepIndex < Steps.Count - 1)
  790. {
  791. for (int i = stepIndex + 1; i < Steps.Count; i++)
  792. {
  793. if (Steps[i].TemperatureIsSaved)
  794. {
  795. string proName = e.PropertyName;
  796. string proValue = e.PropertyValue;
  797. Type type = step.GetType();
  798. PropertyInfo[] properties = type.GetProperties();
  799. var property = properties.FirstOrDefault(x => x.Name == proName);
  800. if (property != null)
  801. {
  802. var proParam = property.GetValue(Steps[i]);
  803. if (proParam is StringParam)
  804. {
  805. ((StringParam)proParam).Value = proValue;
  806. property.SetValue(Steps[i], proParam);
  807. }
  808. }
  809. }
  810. else
  811. { break; }
  812. }
  813. }
  814. }
  815. }
  816. private void Item_AUXValueChangedEvent(object sender, SetValueEventArgs e)
  817. {
  818. if (sender != null && sender is Step)
  819. {
  820. var step = sender as Step;
  821. int stepIndex = Steps.IndexOf(step);
  822. if (stepIndex < Steps.Count - 1)
  823. {
  824. for (int i = stepIndex + 1; i < Steps.Count; i++)
  825. {
  826. if (Steps[i].AUXIsSaved)
  827. {
  828. var tempData = (AUXData)e.Sender;
  829. string tempName = e.ValueName;
  830. string proName = e.PropertyName;
  831. string proValue = e.PropertyValue;
  832. var temp = Steps[i].AUXSets.FirstOrDefault(x => x.ControlName == tempName);
  833. Type type = temp.GetType();
  834. PropertyInfo[] properties = type.GetProperties();
  835. var property = properties.FirstOrDefault(x => x.Name == proName);
  836. if (property != null)
  837. {
  838. var proParam = property.GetValue(temp);
  839. if (proParam is DoubleParam)
  840. {
  841. ((DoubleParam)proParam).Value = proValue;
  842. property.SetValue(temp, proParam);
  843. }
  844. else if (proParam is StringParam)
  845. {
  846. ((StringParam)proParam).Value = proValue;
  847. property.SetValue(temp, proParam);
  848. }
  849. else if (proParam is BoolParam)
  850. {
  851. bool tryValue = true;
  852. bool.TryParse(proValue, out tryValue);
  853. ((BoolParam)proParam).Value = tryValue;
  854. property.SetValue(temp, proParam);
  855. }
  856. }
  857. }
  858. else
  859. { break; }
  860. }
  861. }
  862. }
  863. }
  864. private void Item_ValveValueChangedEvent(object sender, SetValueEventArgs e)
  865. {
  866. if (sender != null && sender is Step)
  867. {
  868. var step = sender as Step;
  869. int stepIndex = Steps.IndexOf(step);
  870. if (stepIndex < Steps.Count - 1)
  871. {
  872. for (int i = stepIndex + 1; i < Steps.Count; i++)
  873. {
  874. if (Steps[i].ValveIsSaved)
  875. {
  876. var tempData = (BoolParam)e.Sender;
  877. string tempName = e.ValueName;
  878. string proName = e.PropertyName;
  879. string proValue = e.PropertyValue;
  880. var temp = Steps[i].ValveSets.FirstOrDefault(x => x.Name == tempData.Name);
  881. bool tempValue = false;
  882. bool.TryParse(proValue, out tempValue);
  883. temp.Value = tempValue;
  884. }
  885. else
  886. { break; }
  887. }
  888. }
  889. }
  890. }
  891. public void Clear()
  892. {
  893. Steps.Clear();
  894. PopSettingSteps.Clear();
  895. StepTolerances.Clear();
  896. RecipeChamberType = "";
  897. RecipeVersion = "";
  898. IsSavedDesc = true;
  899. _module = "PM1";
  900. }
  901. public void StepCloneChangedIndex()
  902. {
  903. int index = 1;
  904. foreach (var item in Steps)
  905. {
  906. item.StepNo = index;
  907. index += 1;
  908. }
  909. }
  910. public void InitData(string prefixPath, string recipeName, string recipeContent, string module, int tableNo = 1)
  911. {
  912. IsCompatibleWithCurrentFormat = false;
  913. _module = module;
  914. Name = recipeName;
  915. PrefixPath = prefixPath;
  916. try
  917. {
  918. _doc = new XmlDocument();
  919. _doc.LoadXml(recipeContent);
  920. if (!LoadHeader(_doc.SelectSingleNode("Aitex/TableRecipeData")))
  921. return;
  922. //Load Tables
  923. XmlNode nodeTable = _doc.SelectSingleNode($"Aitex/TableRecipeData/Tables");
  924. if (nodeTable != null)
  925. LoadTables(nodeTable);
  926. if (!SaveTableRecipeTypes.Contains(RecipeChamberType))
  927. {
  928. XmlNodeList nodeSteps = _doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{module}']/Step");
  929. if (nodeSteps == null)
  930. nodeSteps = _doc.SelectNodes($"Aitex/TableRecipeData/Step");
  931. FastLoadSteps(nodeSteps);
  932. // LoadSteps(nodeSteps);
  933. XmlNode nodeConfig = _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{module}']/Config");
  934. if (nodeConfig == null)
  935. nodeConfig = _doc.SelectSingleNode($"Aitex/TableRecipeData/Config");
  936. LoadConfigs(nodeConfig);
  937. }
  938. else
  939. {
  940. Steps.Clear();
  941. StepNos.Clear();
  942. TableIndex = 1;
  943. Tables[0].TableData.Steps.ToList().ForEach(
  944. x =>
  945. {
  946. var tempStep = x;// (Step)CloneUtil.CloneObject(x);
  947. tempStep.StepNo = x.StepNo;
  948. Steps.Add(tempStep);
  949. StepNos.Add(x.StepNo);
  950. });
  951. }
  952. //var index = 1;
  953. //foreach (Step parameters in Steps)
  954. //{
  955. // parameters.Value = index.ToString();
  956. // index++;
  957. //}
  958. IsCompatibleWithCurrentFormat = true;
  959. }
  960. catch (Exception ex)
  961. {
  962. LOG.Write(ex);
  963. }
  964. }
  965. public void SaveTo(string[] moduleList)
  966. {
  967. GetXmlString();
  968. XmlNode nodeModule = _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{_module}']");
  969. if (nodeModule == null)
  970. {
  971. LOG.Write("recipe not find modules," + Name);
  972. return;
  973. }
  974. XmlNode nodeData = nodeModule.ParentNode;
  975. foreach (var module in moduleList)
  976. {
  977. if (module == _module)
  978. {
  979. continue;
  980. }
  981. var child = _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{module}']");
  982. if (child != null)
  983. nodeData.RemoveChild(child);
  984. XmlElement node = nodeModule.Clone() as XmlElement;
  985. node.SetAttribute("Name", module);
  986. nodeData.AppendChild(node);
  987. }
  988. }
  989. int StepNo = 1;
  990. public string DictionaryStepTime(Dictionary<string, string> steptimes)
  991. {
  992. if (steptimes == null && steptimes.Count == 0) return null;
  993. StringBuilder rtn = new StringBuilder();
  994. foreach (var item in steptimes.Keys)
  995. {
  996. if (steptimes[item] == "00:00:00") continue;
  997. rtn.Append($"{item},{steptimes[item]};");
  998. }
  999. if (rtn.Length > 0) rtn.Remove(rtn.Length - 1, 1);
  1000. return rtn.ToString();
  1001. }
  1002. public Dictionary<string, string> StepTimeToDictionary(string stepTime)
  1003. {
  1004. Dictionary<string, string> steptimes = new Dictionary<string, string>();
  1005. string[] tempTimes = stepTime.Split(';');
  1006. foreach (var item in tempTimes)
  1007. {
  1008. string[] subTimes = item.Split(',');
  1009. steptimes.Add(subTimes[0], subTimes[1]);
  1010. }
  1011. return steptimes;
  1012. }
  1013. private List<string> valveDefaultOpen = new List<string>() { "AGV", "MBP", "DP", "HTR1", "HTR2", "HTR3" };
  1014. private MFCData GetNewMFCData(string controlName)
  1015. {
  1016. return new MFCData()
  1017. {
  1018. Name = controlName,
  1019. ControlName = controlName.Replace(".Flow", ""),
  1020. SetValue = new StringParam() { Name = "SetValue", Value = "0" },
  1021. SetUnit = new StringParam() { Name = "SetUnit", Value = "SLM" },
  1022. Rampng = new DoubleParam() { Name = "Rampng", Value = "0" },
  1023. RampngUnit = new StringParam() { Name = "RampngUnit", Value = "SLM" },
  1024. AlarmValue = "None",
  1025. IsCheck = new BoolParam() { Name = "IsCheck", Value = false },
  1026. MaxValue = new DoubleParam() { Name = "MaxValue", Value = "0" },
  1027. MinValue = new DoubleParam { Name = "MaxValue", Value = "0" }
  1028. };
  1029. }
  1030. public Step CreateStep(Step oldStep, XmlNode stepNode = null)
  1031. {
  1032. if (oldStep == null)
  1033. {
  1034. return CreateStep(stepNode);
  1035. }
  1036. else
  1037. {
  1038. Step step = (Step)CloneUtil.CloneObject(oldStep);
  1039. if (stepNode != null)
  1040. {
  1041. if (stepNode.Attributes["StepNo"] != null)
  1042. step.StepNo = int.Parse(stepNode.Attributes["StepNo"].Value);
  1043. if (stepNode.Attributes["Name"] != null)
  1044. step.Name = stepNode.Attributes["Name"].Value;
  1045. if (stepNode.Attributes["EndBy"] != null)
  1046. step.EndBy = stepNode.Attributes["EndBy"].Value;
  1047. if (stepNode.Attributes["Time"] != null)
  1048. {
  1049. var timeValue = stepNode.Attributes["Time"].Value;
  1050. if (!string.IsNullOrEmpty(timeValue) && !timeValue.Contains('.'))
  1051. {
  1052. timeValue = $"{timeValue}.0";
  1053. }
  1054. step.Time = timeValue;
  1055. }
  1056. if (stepNode.Attributes["SkipWait"] != null)
  1057. step.SkipWait = stepNode.Attributes["SkipWait"].Value;
  1058. else
  1059. step.SkipWait = "";
  1060. if (stepNode.Attributes["Command"] != null)
  1061. step.Command = stepNode.Attributes["Command"].Value;
  1062. AnalysisIsSaved(stepNode, step);
  1063. ReadConditionCheck(stepNode, step);
  1064. if (stepNode.Attributes["AlarmConditionTable"] != null)
  1065. step.AlarmConditionTable = new StringParam() { Name = "AlarmConditionTable", Value = stepNode.Attributes["AlarmConditionTable"].Value };
  1066. if (stepNode.Attributes["AbortRecipeTableIndex"] != null)
  1067. step.AbortRecipeTableIndex = stepNode.Attributes["AbortRecipeTableIndex"].Value;
  1068. if (stepNode.Attributes["FilmThickFormula"] != null)
  1069. step.FilmThickFormula = stepNode.Attributes["FilmThickFormula"].Value;
  1070. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Valve"))
  1071. {
  1072. foreach (var item in RecipeTemplate["Valve"])
  1073. {
  1074. var _tempValve = step.ValveSets.FirstOrDefault(x => x.Name == item.ControlName);
  1075. if (stepNode.Attributes[item.ControlName] != null && _tempValve != null)
  1076. {
  1077. var tempstr = stepNode.Attributes[item.ControlName].Value;
  1078. //if (valveDefaultOpen.Contains(item.ControlName))
  1079. //{
  1080. // _tempValve.Value = true;
  1081. //}
  1082. //else
  1083. //{
  1084. var boolVal = stepNode.Attributes[item.ControlName].Value == "Open" ? true : false;
  1085. _tempValve.Value = boolVal;
  1086. //}
  1087. }
  1088. else
  1089. {
  1090. if (valveDefaultOpen.Contains(item.ControlName))
  1091. {
  1092. var findVal = step.ValveSets.FirstOrDefault(x => x.Name == item.ControlName);
  1093. if (findVal != null)
  1094. {
  1095. findVal.Value = true;
  1096. }
  1097. else
  1098. {
  1099. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = true });
  1100. }
  1101. }
  1102. else
  1103. {
  1104. var findVal = step.ValveSets.FirstOrDefault(x => x.Name == item.ControlName);
  1105. if (findVal != null)
  1106. {
  1107. findVal.Value = false;
  1108. }
  1109. else
  1110. {
  1111. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = false });
  1112. }
  1113. }
  1114. }
  1115. }
  1116. }
  1117. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Temperature"))
  1118. {
  1119. foreach (var item in RecipeTemplate["Temperature"])
  1120. {
  1121. FromXmlNodeGetTemperatureSets(stepNode, step, item);
  1122. }
  1123. }
  1124. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFC"))
  1125. {
  1126. foreach (var item in RecipeTemplate["MFC"])
  1127. {
  1128. var mFCData = step.MFCSets.FirstOrDefault(x => x.ControlName == item.ControlName.Replace(".Flow", ""));
  1129. if (mFCData == null)
  1130. {
  1131. step.MFCSets.Add(GetNewMFCData(item.ControlName));
  1132. }
  1133. if (step.MFCSets != null && step.MFCSets.Count > 0)
  1134. {
  1135. for (int i = 0; i < step.MFCSets.Count; i++)
  1136. {
  1137. step.MFCSets[i].No = i + 1;
  1138. }
  1139. }
  1140. if (stepNode.Attributes[$"{item.ControlName}.IsSaved"] != null)
  1141. {
  1142. bool.TryParse(stepNode.Attributes[$"{item.ControlName}.IsSaved"].Value, out bool isSaved);
  1143. mFCData.FlagIsSaved = isSaved;
  1144. }
  1145. else
  1146. {
  1147. mFCData.FlagIsSaved = true;
  1148. }
  1149. var setValue = stepNode.Attributes[$"{item.ControlName}.Set"] != null ? stepNode.Attributes[$"{item.ControlName}.Set"].Value : "0";
  1150. mFCData.SetValue = new StringParam() { Name = "SetValue", Value = setValue };
  1151. var strSetUnit = stepNode.Attributes[$"{item.ControlName}.SetUnit"] != null ? stepNode.Attributes[$"{item.ControlName}.SetUnit"].Value : "SLM";
  1152. mFCData.SetUnit = new StringParam() { Name = "SetUnit", Value = strSetUnit };
  1153. var rampngValue = stepNode.Attributes[$"{item.ControlName}.Ramprate"] != null ? stepNode.Attributes[$"{item.ControlName}.Ramprate"].Value : "0";
  1154. mFCData.Rampng = new DoubleParam() { Name = "Rampng", Value = rampngValue };
  1155. var strRampngUnit = stepNode.Attributes[$"{item.ControlName}.RamprateUnit"] != null ? stepNode.Attributes[$"{item.ControlName}.RamprateUnit"].Value : "SLM";
  1156. mFCData.RampngUnit = new StringParam() { Name = "RampngUnit", Value = strRampngUnit };
  1157. var boolIsCheck = stepNode.Attributes[$"{item.ControlName}.Check"] != null ? bool.Parse(stepNode.Attributes[$"{item.ControlName}.Check"].Value) : false;
  1158. mFCData.IsCheck = new BoolParam() { Name = "IsCheck", Value = boolIsCheck };
  1159. double max = 0;
  1160. if (stepNode.Attributes[$"{item.ControlName}.High"] != null && !string.IsNullOrEmpty(stepNode.Attributes[$"{item.ControlName}.High"].Value))
  1161. {
  1162. double.TryParse(stepNode.Attributes[$"{item.ControlName}.High"].Value, out max);
  1163. }
  1164. mFCData.MaxValue = new DoubleParam() { Name = "MaxValue", Value = max.ToString() };
  1165. double min = 0;
  1166. if (stepNode.Attributes[$"{item.ControlName}.Low"] != null && !string.IsNullOrEmpty(stepNode.Attributes[$"{item.ControlName}.Low"].Value))
  1167. {
  1168. double.TryParse(stepNode.Attributes[$"{item.ControlName}.Low"].Value, out min);
  1169. }
  1170. mFCData.MinValue = new DoubleParam() { Name = "MinValue", Value = min.ToString() };
  1171. mFCData.Unit = stepNode.Attributes[$"{item.ControlName}.Unit"] != null ? stepNode.Attributes[$"{item.ControlName}.Unit"].Value : "SLM";
  1172. }
  1173. }
  1174. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFM"))
  1175. {
  1176. step.MFMSets.Clear();
  1177. foreach (var item in RecipeTemplate["MFM"])
  1178. {
  1179. if (stepNode.Attributes[item.ControlName] != null)
  1180. {
  1181. var MFMListValues = stepNode.Attributes[item.ControlName].Value.Split(';');
  1182. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = MFMListValues[0] });
  1183. if (MFMListValues.Length > 1 && RecipeTemplate != null && RecipeTemplate.ContainsKey("MFMAlarm"))
  1184. {
  1185. step.MFMSets[item.ControlName].AlarmValue = MFMListValues[1];
  1186. }
  1187. else
  1188. {
  1189. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = "0", AlarmValue = "None" });
  1190. }
  1191. }
  1192. else
  1193. {
  1194. if (!step.MFMSets.ContainsKey(item.ControlName))
  1195. {
  1196. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = "0", AlarmValue = "None" });
  1197. }
  1198. }
  1199. }
  1200. }
  1201. for (int i = 1; i < 7; i++)
  1202. {
  1203. if (stepNode.Attributes[$"External.Out{i}"] != null && stepNode.Attributes[$"External.Out{i}"].Value != "")
  1204. {
  1205. if (step.EXOUSets.ContainsKey($"External.Out{i}"))
  1206. {
  1207. step.EXOUSets[$"External.Out{i}"] = bool.Parse(stepNode.Attributes[$"External.Out{i}"].Value);
  1208. }
  1209. else
  1210. {
  1211. step.EXOUSets.Add($"External.Out{i}", bool.Parse(stepNode.Attributes[$"External.Out{i}"].Value));
  1212. }
  1213. }
  1214. else
  1215. {
  1216. if (!step.EXOUSets.ContainsKey($"External.Out{i}"))
  1217. {
  1218. step.EXOUSets.Add($"External.Out{i}", false);
  1219. }
  1220. }
  1221. }
  1222. if (stepNode.Attributes["Temperature.ControlMode"] != null)
  1223. step.TemperatureControlMode = new StringParam() { Name = "TemperatureControlMode", Value = stepNode.Attributes["Temperature.ControlMode"].Value };
  1224. else
  1225. step.TemperatureControlMode = new StringParam() { Name = "TemperatureControlMode", Value = "Heater" };
  1226. if (stepNode.Attributes["Temperature.Correct"] != null)
  1227. step.TemperatureCorrect = new StringParam() { Name = "TemperatureCorrect", Value = stepNode.Attributes["Temperature.Correct"].Value };
  1228. else
  1229. step.TemperatureCorrect = new StringParam() { Name = "TemperatureCorrect", Value = "1" };
  1230. if (stepNode.Attributes["Temperature.PID"] != null)
  1231. step.TemperaturePID = new StringParam() { Name = "TemperaturePID", Value = stepNode.Attributes["Temperature.PID"].Value };
  1232. else
  1233. step.TemperaturePID = new StringParam() { Name = "TemperaturePID", Value = "1" };
  1234. if (stepNode.Attributes["Loader.Command"] != null)
  1235. step.LoaderCommand = new StringParam() { Name = "LoaderCommand", Value = stepNode.Attributes["Loader.Command"].Value };
  1236. else
  1237. step.LoaderCommand = new StringParam() { Name = "LoaderCommand", Value = "None" };
  1238. if (stepNode.Attributes["Loader.Speed1"] != null)
  1239. {
  1240. step.LoaderSpeed1 = new DoubleParam() { Name = "LoaderSpeed1", Value = stepNode.Attributes["Loader.Speed1"].Value };
  1241. }
  1242. if (stepNode.Attributes["Loader.Speed2"] != null)
  1243. {
  1244. step.LoaderSpeed2 = new DoubleParam() { Name = "LoaderSpeed2", Value = stepNode.Attributes["Loader.Speed2"].Value };
  1245. }
  1246. if (stepNode.Attributes["Loader.Speed3"] != null)
  1247. {
  1248. step.LoaderSpeed3 = new DoubleParam() { Name = "LoaderSpeed3", Value = stepNode.Attributes["Loader.Speed3"].Value };
  1249. }
  1250. if (stepNode.Attributes["Loader.RPM"] != null)
  1251. {
  1252. step.LoaderRPM = new DoubleParam() { Name = "LoaderRPM", Value = stepNode.Attributes["Loader.RPM"].Value };
  1253. }
  1254. if (stepNode.Attributes["Press.Command"] != null)
  1255. step.PressCommand = new StringParam() { Name = "PressCommand", Value = stepNode.Attributes["Press.Command"].Value };
  1256. else
  1257. step.PressCommand = new StringParam() { Name = "PressCommand", Value = "None" };
  1258. if (stepNode.Attributes["Press.PID"] != null)
  1259. step.PressPID = new StringParam() { Name = "PressPID", Value = stepNode.Attributes["Press.PID"].Value };
  1260. if (stepNode.Attributes["Press.Set"] != null)
  1261. {
  1262. step.PressSet = new DoubleParam() { Name = "PressSet", Value = stepNode.Attributes["Press.Set"].Value };
  1263. }
  1264. if (stepNode.Attributes["Press.SlowVacSet"] != null)
  1265. {
  1266. step.PressSlowVacSet = new DoubleParam() { Name = "PressSlowVacSet", Value = stepNode.Attributes["Press.SlowVacSet"].Value };
  1267. }
  1268. if (stepNode.Attributes["Press.ValveAngleSet"] != null)
  1269. step.PressValveAngleSet = new StringParam() { Name = "PressValveAngleSet", Value = stepNode.Attributes["Press.ValveAngleSet"].Value };
  1270. if (stepNode.Attributes["Press.IsWait"] != null)
  1271. {
  1272. bool.TryParse(stepNode.Attributes["Press.IsWait"].Value, out bool isWait);
  1273. step.PressIsWait = new BoolParam() { Name = "PressIsWait", Value = isWait };
  1274. }
  1275. if (stepNode.Attributes["Press.LowWait"] != null)
  1276. step.PressLowWait = new StringParam() { Name = "PressLowWait", Value = !string.IsNullOrEmpty(stepNode.Attributes["Press.LowWait"].Value) ? stepNode.Attributes["Press.LowWait"].Value : "0" };
  1277. if (stepNode.Attributes["Press.HighWait"] != null)
  1278. step.PressHighWait = new StringParam() { Name = "PressHighWait", Value = !string.IsNullOrEmpty(stepNode.Attributes["Press.HighWait"].Value) ? stepNode.Attributes["Press.HighWait"].Value : "0" };
  1279. if (stepNode.Attributes["Press.WaitUnit"] != null)
  1280. {
  1281. step.PressWaitUnit = new StringParam() { Name = "PressWaitUnit", Value = stepNode.Attributes["Press.WaitUnit"].Value };
  1282. }
  1283. if (stepNode.Attributes["Press.LowPressWait"] != null)
  1284. step.PressLowPressWait = new StringParam() { Name = "PressLowPressWait", Value = !string.IsNullOrEmpty(stepNode.Attributes["Press.LowPressWait"].Value) ? stepNode.Attributes["Press.LowPressWait"].Value : "None" };
  1285. if (stepNode.Attributes["Press.WaitPress"] != null)
  1286. step.WaitPress = new StringParam() { Name = "PressLowPressWait", Value = !string.IsNullOrEmpty(stepNode.Attributes["Press.WaitPress"].Value) ? stepNode.Attributes["Press.WaitPress"].Value : "0" };
  1287. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("AUX"))
  1288. {
  1289. List<string> queryList = new List<string>();
  1290. foreach (var item in RecipeTemplate["AUX"])
  1291. {
  1292. queryList.Add($"PM1.RecipeEditParameter.AUX.{item.ControlName}.Display");
  1293. queryList.Add($"PM1.RecipeEditParameter.AUX.{item.ControlName}.Unit");
  1294. }
  1295. var dictValues = QueryDataClient.Instance.Service.PollConfig(queryList);
  1296. foreach (var item in RecipeTemplate["AUX"])
  1297. {
  1298. if (stepNode.Attributes[$"AUX.{item.ControlName}.Set"] != null)
  1299. {
  1300. AUXData aUXData = step.AUXSets.FirstOrDefault(x => x.ControlName == item.ControlName);
  1301. if (aUXData == null)
  1302. {
  1303. aUXData = new AUXData();
  1304. var displayName = (string)dictValues[$"PM1.RecipeEditParameter.AUX.{item.ControlName}.Display"];
  1305. var auxUnit = (string)dictValues[$"PM1.RecipeEditParameter.AUX.{item.ControlName}.Unit"];
  1306. aUXData.ControlName = item.ControlName;
  1307. aUXData.DisplayName = displayName;
  1308. aUXData.Unit = auxUnit;
  1309. }
  1310. float setValue = 0;
  1311. if (stepNode.Attributes[$"AUX.{item.ControlName}.Set"] != null)
  1312. {
  1313. float.TryParse(stepNode.Attributes[$"AUX.{item.ControlName}.Set"].Value, out setValue);
  1314. }
  1315. aUXData.SetValue = new DoubleParam() { Name = "SetValue", Value = setValue.ToString() };
  1316. var _ischeck = stepNode.Attributes[$"AUX.{item.ControlName}.Check"] != null ? bool.Parse(stepNode.Attributes[$"AUX.{item.ControlName}.Check"].Value) : false;
  1317. aUXData.IsCheck = new BoolParam() { Name = "IsCheck", Value = _ischeck };
  1318. float maxValue = 0;
  1319. if (stepNode.Attributes[$"AUX.{item.ControlName}.High"] != null)
  1320. {
  1321. float.TryParse(stepNode.Attributes[$"AUX.{item.ControlName}.High"].Value, out maxValue);
  1322. }
  1323. aUXData.MaxValue = new DoubleParam() { Name = "MaxValue", Value = maxValue.ToString() };
  1324. float minValue = 0;
  1325. if (stepNode.Attributes[$"AUX.{item.ControlName}.Low"] != null)
  1326. {
  1327. float.TryParse(stepNode.Attributes[$"AUX.{item.ControlName}.Low"].Value, out minValue);
  1328. }
  1329. aUXData.MinValue = new DoubleParam() { Name = "MinValue", Value = minValue.ToString() };
  1330. var _setunit = stepNode.Attributes[$"AUX.{item.ControlName}.CheckUnit"] != null ? stepNode.Attributes[$"AUX.{item.ControlName}.CheckUnit"].Value : "℃";
  1331. aUXData.SetUnit = new StringParam() { Name = "SetUnit", Value = _setunit };
  1332. if (step.AUXSets.Where(x => x.Name == item.ControlName).Any())
  1333. {
  1334. step.AUXSets.Add(aUXData);
  1335. }
  1336. }
  1337. else
  1338. {
  1339. var displayName = (string)dictValues[$"PM1.RecipeEditParameter.AUX.{item.ControlName}.Display"];
  1340. var auxUnit = (string)dictValues[$"PM1.RecipeEditParameter.AUX.{item.ControlName}.Unit"];
  1341. if (step.AUXSets.Where(x => x.Name == item.ControlName).Any())
  1342. {
  1343. AddNewAUX(step, item, displayName, auxUnit);
  1344. }
  1345. }
  1346. }
  1347. }
  1348. }
  1349. SetDelegateEvent(step);
  1350. return step;
  1351. }
  1352. }
  1353. public void SetDelegateEvent(Step step)
  1354. {
  1355. MFCSetsCollectionChanged(step);
  1356. TemperatureSetsCollectionChanged(step);
  1357. ValveSetsCollectionChanged(step);
  1358. AUXSetsCollectionChanged(step);
  1359. }
  1360. private void MFCSetsCollectionChanged(Step step)
  1361. {
  1362. foreach (var item in step.MFCSets)
  1363. {
  1364. item.PropertyChanged += step.MFCIsSaved_PropertyChanged;
  1365. item.ValueChangedEvent += step.Item_MFCValueChangedEvent;
  1366. }
  1367. }
  1368. private void TemperatureSetsCollectionChanged(Step step)
  1369. {
  1370. foreach (var item in step.TemperatureSets)
  1371. {
  1372. item.PropertyChanged += step.TemperatureIsSaved_PropertyChanged;
  1373. item.ValueChangedEvent += step.Item_TempValueChangedEvent;
  1374. }
  1375. }
  1376. private void ValveSetsCollectionChanged(Step step)
  1377. {
  1378. foreach (var item in step.ValveSets)
  1379. {
  1380. item.PropertyChanged += step.ValveIsSaved_PropertyChanged;
  1381. item.ValueChangedEvent += step.Item_ValveValueChangedEvent;
  1382. }
  1383. //step.ValveSets.CollectionChanged += (s, e) =>
  1384. //{
  1385. // if (e.OldItems != null)
  1386. // {
  1387. // foreach (BoolParam item in e.OldItems)
  1388. // {
  1389. // item.PropertyChanged -= step.ValveIsSaved_PropertyChanged;
  1390. // item.ValueChangedEvent -= step.Item_ValveValueChangedEvent;
  1391. // }
  1392. // }
  1393. // if (e.NewItems != null)
  1394. // {
  1395. // foreach (BoolParam item in e.NewItems)
  1396. // {
  1397. // item.PropertyChanged += step.ValveIsSaved_PropertyChanged;
  1398. // item.ValueChangedEvent += step.Item_ValveValueChangedEvent;
  1399. // }
  1400. // }
  1401. //};
  1402. }
  1403. private void AUXSetsCollectionChanged(Step step)
  1404. {
  1405. foreach (var item in step.AUXSets)
  1406. {
  1407. item.PropertyChanged += step.AUXIsSaved_PropertyChanged;
  1408. item.ValueChangedEvent += step.Item_AUXValueChangedEvent;
  1409. }
  1410. //step.AUXSets.CollectionChanged += (s, e) =>
  1411. //{
  1412. // if (e.OldItems != null)
  1413. // {
  1414. // foreach (AUXData item in e.OldItems)
  1415. // {
  1416. // item.PropertyChanged -= step.AUXIsSaved_PropertyChanged;
  1417. // item.ValueChangedEvent -= step.Item_AUXValueChangedEvent;
  1418. // }
  1419. // }
  1420. // if (e.NewItems != null)
  1421. // {
  1422. // foreach (AUXData item in e.NewItems)
  1423. // {
  1424. // item.PropertyChanged += step.AUXIsSaved_PropertyChanged;
  1425. // item.ValueChangedEvent += step.Item_AUXValueChangedEvent;
  1426. // }
  1427. // }
  1428. //};
  1429. }
  1430. private static void AddNewAUX(Step step, RecipeTemplateColumnBase item, string displayName, string auxUnit)
  1431. {
  1432. var tempAUX = new AUXData()
  1433. {
  1434. ControlName = item.ControlName,
  1435. DisplayName = displayName,
  1436. SetValue = new DoubleParam() { Name = "SetValue", Value = "0" },
  1437. SetUnit = new StringParam() { Name = "SetUnit", Value = auxUnit },
  1438. Rampng = new DoubleParam() { Name = "Rampng", Value = "0" },
  1439. RampngUnit = new StringParam() { Name = "RampngUnit", Value = "SLM" },
  1440. AlarmValue = "None",
  1441. IsCheck = new BoolParam() { Name = "IsCheck", Value = false },
  1442. MaxValue = new DoubleParam() { Name = "MaxValue", Value = "0" },
  1443. MinValue = new DoubleParam() { Name = "MinValue", Value = "0" },
  1444. Unit = auxUnit
  1445. };
  1446. step.AUXSets.Add(tempAUX);
  1447. }
  1448. public Step CreateStep(XmlNode stepNode = null)
  1449. {
  1450. Step step = new Step();
  1451. if (stepNode != null)
  1452. {
  1453. if (stepNode.Attributes["StepNo"] != null)
  1454. step.StepNo = int.Parse(stepNode.Attributes["StepNo"].Value);
  1455. if (stepNode.Attributes["Name"] != null)
  1456. step.Name = stepNode.Attributes["Name"].Value;
  1457. if (stepNode.Attributes["EndBy"] != null)
  1458. step.EndBy = stepNode.Attributes["EndBy"].Value;
  1459. if (stepNode.Attributes["Time"] != null)
  1460. {
  1461. if (stepNode.Attributes["Time"] != null)
  1462. {
  1463. var timeValue = stepNode.Attributes["Time"].Value;
  1464. if (!string.IsNullOrEmpty(timeValue) && !timeValue.Contains('.'))
  1465. {
  1466. timeValue = $"{timeValue}.0";
  1467. }
  1468. step.Time = timeValue;
  1469. }
  1470. }
  1471. if (stepNode.Attributes["SkipWait"] != null)
  1472. step.SkipWait = stepNode.Attributes["SkipWait"].Value;
  1473. else
  1474. step.SkipWait = "";
  1475. if (stepNode.Attributes["Command"] != null)
  1476. step.Command = stepNode.Attributes["Command"].Value;
  1477. AnalysisIsSaved(stepNode, step);
  1478. ReadConditionCheck(stepNode, step);
  1479. if (stepNode.Attributes["AbortRecipeTableIndex"] != null)
  1480. step.AbortRecipeTableIndex = stepNode.Attributes["AbortRecipeTableIndex"].Value;
  1481. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Valve"))
  1482. {
  1483. step.ValveSets.Clear();
  1484. foreach (var item in RecipeTemplate["Valve"])
  1485. {
  1486. if (stepNode.Attributes[item.ControlName] != null)
  1487. {
  1488. var valValue = stepNode.Attributes[item.ControlName].Value == "Open" ? true : false;
  1489. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = valValue });
  1490. }
  1491. else
  1492. {
  1493. if (valveDefaultOpen.Contains(item.ControlName))
  1494. {
  1495. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = true });
  1496. }
  1497. else
  1498. {
  1499. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = false });
  1500. }
  1501. }
  1502. }
  1503. }
  1504. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Temperature"))
  1505. {
  1506. step.TemperatureSets.Clear();
  1507. foreach (var item in RecipeTemplate["Temperature"])
  1508. {
  1509. FromXmlNodeGetTemperatureSets(stepNode, step, item);
  1510. }
  1511. }
  1512. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFC"))
  1513. {
  1514. step.MFCSets.Clear();
  1515. foreach (var item in RecipeTemplate["MFC"])
  1516. {
  1517. if (stepNode.Attributes[$"{item.ControlName}.Set"] != null)
  1518. {
  1519. step.MFCSets.Add(StepNodeToMFCData(stepNode, item));
  1520. }
  1521. else
  1522. {
  1523. step.MFCSets.Add(GetNewMFCData(item.ControlName));
  1524. }
  1525. }
  1526. if (step.MFCSets != null && step.MFCSets.Count > 0)
  1527. {
  1528. for (int i = 0; i < step.MFCSets.Count; i++)
  1529. {
  1530. step.MFCSets[i].No = i + 1;
  1531. }
  1532. }
  1533. }
  1534. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFM"))
  1535. {
  1536. step.MFMSets.Clear();
  1537. foreach (var item in RecipeTemplate["MFM"])
  1538. {
  1539. if (stepNode.Attributes[item.ControlName] != null)
  1540. {
  1541. var MFMListValues = stepNode.Attributes[item.ControlName].Value.Split(';');
  1542. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = MFMListValues[0] });
  1543. if (MFMListValues.Length > 1 && RecipeTemplate != null && RecipeTemplate.ContainsKey("MFMAlarm"))
  1544. {
  1545. step.MFMSets[item.ControlName].AlarmValue = MFMListValues[1];
  1546. }
  1547. }
  1548. else
  1549. {
  1550. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = "0", AlarmValue = "None" });
  1551. }
  1552. }
  1553. }
  1554. for (int i = 1; i < 7; i++)
  1555. {
  1556. if (stepNode.Attributes[$"External.Out{i}"] != null && stepNode.Attributes[$"External.Out{i}"].Value != "")
  1557. {
  1558. step.EXOUSets.Add($"External.Out{i}", bool.Parse(stepNode.Attributes[$"External.Out{i}"].Value));
  1559. }
  1560. else
  1561. {
  1562. step.EXOUSets.Add($"External.Out{i}", false);
  1563. }
  1564. }
  1565. if (stepNode.Attributes["AlarmConditionTable"] != null)
  1566. step.AlarmConditionTable = new StringParam() { Name = "AlarmConditionTable", Value = stepNode.Attributes["AlarmConditionTable"].Value };
  1567. if (stepNode.Attributes["Temperature.ControlMode"] != null)
  1568. step.TemperatureControlMode = new StringParam() { Name = "TemperatureControlMode", Value = stepNode.Attributes["Temperature.ControlMode"].Value };
  1569. else
  1570. step.TemperatureControlMode = new StringParam() { Name = "TemperatureControlMode", Value = "Heater" };
  1571. if (stepNode.Attributes["Temperature.Correct"] != null)
  1572. step.TemperatureCorrect = new StringParam() { Name = "TemperatureCorrect", Value = stepNode.Attributes["Temperature.Correct"].Value };
  1573. else
  1574. step.TemperatureCorrect = new StringParam() { Name = "TemperatureCorrect", Value = "1" };
  1575. if (stepNode.Attributes["Temperature.PID"] != null)
  1576. step.TemperaturePID = new StringParam() { Name = "TemperaturePID", Value = stepNode.Attributes["Temperature.PID"].Value };
  1577. else
  1578. step.TemperaturePID = new StringParam() { Name = "TemperaturePID", Value = "1" };
  1579. if (stepNode.Attributes["Loader.Command"] != null)
  1580. step.LoaderCommand = new StringParam() { Name = "LoaderCommand", Value = stepNode.Attributes["Loader.Command"].Value };
  1581. else
  1582. step.LoaderCommand = new StringParam() { Name = "LoaderCommand", Value = "None" };
  1583. if (stepNode.Attributes["Loader.Speed1"] != null)
  1584. {
  1585. step.LoaderSpeed1 = new DoubleParam() { Name = "LoaderSpeed1", Value = stepNode.Attributes["Loader.Speed1"].Value };
  1586. }
  1587. if (stepNode.Attributes["Loader.Speed2"] != null)
  1588. {
  1589. step.LoaderSpeed2 = new DoubleParam() { Name = "LoaderSpeed2", Value = stepNode.Attributes["Loader.Speed2"].Value };
  1590. }
  1591. if (stepNode.Attributes["Loader.Speed3"] != null)
  1592. {
  1593. step.LoaderSpeed3 = new DoubleParam() { Name = "LoaderSpeed3", Value = stepNode.Attributes["Loader.Speed3"].Value };
  1594. }
  1595. if (stepNode.Attributes["Loader.RPM"] != null)
  1596. {
  1597. step.LoaderRPM = new DoubleParam() { Name = "LoaderRPM", Value = stepNode.Attributes["Loader.RPM"].Value };
  1598. }
  1599. if (stepNode.Attributes["Press.Command"] != null)
  1600. step.PressCommand = new StringParam() { Name = "PressCommand", Value = stepNode.Attributes["Press.Command"].Value };
  1601. else
  1602. step.PressCommand = new StringParam() { Name = "PressCommand", Value = "None" };
  1603. if (stepNode.Attributes["Press.PID"] != null)
  1604. step.PressPID = new StringParam() { Name = "PressPID", Value = stepNode.Attributes["Press.PID"].Value };
  1605. if (stepNode.Attributes["Press.Set"] != null)
  1606. {
  1607. step.PressSet = new DoubleParam() { Name = "PressSet", Value = stepNode.Attributes["Press.Set"].Value };
  1608. }
  1609. if (stepNode.Attributes["Press.SlowVacSet"] != null)
  1610. {
  1611. step.PressSlowVacSet = new DoubleParam() { Name = "PressSet", Value = stepNode.Attributes["Press.SlowVacSet"].Value };
  1612. }
  1613. if (stepNode.Attributes["Press.ValveAngleSet"] != null)
  1614. step.PressValveAngleSet = new StringParam() { Name = "PressValveAngleSet", Value = stepNode.Attributes["Press.ValveAngleSet"].Value };
  1615. if (stepNode.Attributes["Press.IsWait"] != null)
  1616. {
  1617. bool.TryParse(stepNode.Attributes["Press.IsWait"].Value, out bool isWait);
  1618. step.PressIsWait = new BoolParam() { Name = "PressIsWait", Value = isWait };
  1619. }
  1620. if (stepNode.Attributes["Press.LowWait"] != null)
  1621. step.PressLowWait = new StringParam() { Name = "PressLowWait", Value = !string.IsNullOrEmpty(stepNode.Attributes["Press.LowWait"].Value) ? stepNode.Attributes["Press.LowWait"].Value : "0" };
  1622. if (stepNode.Attributes["Press.HighWait"] != null)
  1623. step.PressHighWait = new StringParam() { Name = "PressHighWait", Value = !string.IsNullOrEmpty(stepNode.Attributes["Press.HighWait"].Value) ? stepNode.Attributes["Press.HighWait"].Value : "0" };
  1624. if (stepNode.Attributes["Press.WaitUnit"] != null)
  1625. {
  1626. step.PressWaitUnit = new StringParam() { Name = "PressWaitUnit", Value = stepNode.Attributes["Press.WaitUnit"].Value };
  1627. }
  1628. if (stepNode.Attributes["Press.LowPressWait"] != null)
  1629. step.PressLowPressWait = new StringParam() { Name = "PressLowPressWait", Value = !string.IsNullOrEmpty(stepNode.Attributes["Press.LowPressWait"].Value) ? stepNode.Attributes["Press.LowPressWait"].Value : "None" };
  1630. if (stepNode.Attributes["Press.WaitPress"] != null)
  1631. step.WaitPress = new StringParam() { Name = "WaitPress", Value = !string.IsNullOrEmpty(stepNode.Attributes["Press.WaitPress"].Value) ? stepNode.Attributes["Press.WaitPress"].Value : "0" };
  1632. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("AUX"))
  1633. {
  1634. step.AUXSets.Clear();
  1635. foreach (var item in RecipeTemplate["AUX"])
  1636. {
  1637. var displayName = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.RecipeEditParameter.AUX.{item.ControlName}.Display");
  1638. var auxUnit = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.RecipeEditParameter.AUX.{item.ControlName}.Unit");
  1639. if (stepNode.Attributes[$"AUX.{item.ControlName}.Set"] != null)
  1640. {
  1641. AUXData aUXData = new AUXData();
  1642. aUXData.ControlName = item.ControlName;
  1643. aUXData.DisplayName = displayName;
  1644. aUXData.Unit = auxUnit;
  1645. float setValue = 0;
  1646. if (stepNode.Attributes[$"AUX.{item.ControlName}.Set"] != null)
  1647. {
  1648. float.TryParse(stepNode.Attributes[$"AUX.{item.ControlName}.Set"].Value, out setValue);
  1649. }
  1650. aUXData.SetValue = new DoubleParam() { Name = "SetValue", Value = setValue.ToString() };
  1651. aUXData.IsCheck = new BoolParam() { Name = "IsCheck", Value = stepNode.Attributes[$"AUX.{item.ControlName}.Check"] != null ? bool.Parse(stepNode.Attributes[$"AUX.{item.ControlName}.Check"].Value) : false };
  1652. float maxValue = 0;
  1653. if (stepNode.Attributes[$"AUX.{item.ControlName}.High"] != null)
  1654. {
  1655. float.TryParse(stepNode.Attributes[$"AUX.{item.ControlName}.High"].Value, out maxValue);
  1656. }
  1657. aUXData.MaxValue = new DoubleParam() { Name = "MaxValue", Value = maxValue.ToString() };
  1658. float minValue = 0;
  1659. if (stepNode.Attributes[$"AUX.{item.ControlName}.Low"] != null)
  1660. {
  1661. float.TryParse(stepNode.Attributes[$"AUX.{item.ControlName}.Low"].Value, out minValue);
  1662. }
  1663. aUXData.MinValue = new DoubleParam() { Name = "MinValue", Value = minValue.ToString() };
  1664. aUXData.SetUnit = new StringParam() { Name = "SetUnit", Value = stepNode.Attributes[$"AUX.{item.ControlName}.CheckUnit"] != null ? stepNode.Attributes[$"AUX.{item.ControlName}.CheckUnit"].Value : "℃" };
  1665. step.AUXSets.Add(aUXData);
  1666. }
  1667. else
  1668. {
  1669. AddNewAUX(step, item, displayName, auxUnit);
  1670. }
  1671. }
  1672. }
  1673. if (stepNode.Attributes["AbortRecipeTableIndex"] != null)
  1674. step.AbortRecipeTableIndex = stepNode.Attributes["AbortRecipeTableIndex"].Value;
  1675. else
  1676. step.AbortRecipeTableIndex = "None";
  1677. for (int i = 1; i < 11; i++)
  1678. {
  1679. string tempType = "";
  1680. string tempDetails = "";
  1681. if (stepNode.Attributes[$"AlarmAction.{i}"] != null && stepNode.Attributes[$"AlarmAction.{i}"].Value != "")
  1682. {
  1683. tempType = stepNode.Attributes[$"AlarmAction.{i}"].Value;
  1684. }
  1685. else
  1686. {
  1687. tempType = "Ignore Alarm";
  1688. }
  1689. if (stepNode.Attributes[$"AlarmDetails.{i}"] != null)
  1690. tempDetails = stepNode.Attributes[$"AlarmDetails.{i}"].Value;
  1691. step.AlarmActionSets.Add(i, new AlarmAction()
  1692. {
  1693. PtocessingType = tempType,
  1694. PtocessingDetails = tempDetails
  1695. });
  1696. }
  1697. if (stepNode.Attributes["FilmThickFormula"] != null)
  1698. step.FilmThickFormula = stepNode.Attributes["FilmThickFormula"].Value;
  1699. }
  1700. else
  1701. {
  1702. step.StepNo = StepNo;
  1703. step.Name = "Name" + StepNo.ToString();
  1704. step.EndBy = "EndByStepTime";
  1705. step.Time = null;
  1706. step.SkipWait = "";
  1707. step.Command = "NoControl";
  1708. step.IsnoneConditionCheck = true;
  1709. step.AlarmConditionTable = new StringParam() { Name = "AlarmConditionTable", Value = "1:" };
  1710. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Valve"))
  1711. {
  1712. step.ValveSets.Clear();
  1713. foreach (var item in RecipeTemplate["Valve"])
  1714. {
  1715. if (valveDefaultOpen.Contains(item.ControlName))
  1716. {
  1717. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = true });
  1718. }
  1719. else
  1720. {
  1721. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = false });
  1722. }
  1723. }
  1724. }
  1725. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Temperature"))
  1726. {
  1727. step.TemperatureSets.Clear();
  1728. foreach (var item in RecipeTemplate["Temperature"])
  1729. {
  1730. var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.{item.ControlName}.DisplayName");
  1731. var tempSetData = new TempSetData(configHeater);
  1732. tempSetData.Name = item.ControlName;
  1733. tempSetData.DisplayName = configHeater;
  1734. step.TemperatureSets.Add(tempSetData);
  1735. }
  1736. }
  1737. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFC"))
  1738. {
  1739. step.MFCSets.Clear();
  1740. foreach (var item in RecipeTemplate["MFC"])
  1741. {
  1742. step.MFCSets.Add(GetNewMFCData(item.ControlName)); ;
  1743. }
  1744. if (step.MFCSets != null && step.MFCSets.Count > 0)
  1745. {
  1746. for (int i = 0; i < step.MFCSets.Count; i++)
  1747. {
  1748. step.MFCSets[i].No = i + 1;
  1749. }
  1750. }
  1751. }
  1752. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFM"))
  1753. {
  1754. step.MFMSets.Clear();
  1755. foreach (var item in RecipeTemplate["MFM"])
  1756. {
  1757. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = "0", AlarmValue = "None" }); ;
  1758. }
  1759. }
  1760. step.TemperatureControlMode = new StringParam() { Name = "TemperatureControlMode", Value = "Heater" };
  1761. step.TemperatureCorrect = new StringParam() { Name = "TemperatureCorrect", Value = "" };
  1762. step.TemperaturePID = new StringParam() { Name = "TemperaturePID", Value = "" };
  1763. step.LoaderCommand = new StringParam() { Name = "Loader", Value = "None" };
  1764. step.PressCommand = new StringParam() { Name = "PressCommand", Value = "None" };
  1765. step.FilmThickFormula = "";
  1766. step.AbortRecipeTableIndex = "None";
  1767. step.FinishAutoProfile = "None";
  1768. step.ReachPressure = "None";
  1769. step.ReachTemp = "None";
  1770. step.O2Density = "None";
  1771. step.TempStabilizeSelected = "None";
  1772. step.PressureStabilizeSelected = "None";
  1773. step.ProcessTimeToEnd = "None";
  1774. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("AUX"))
  1775. {
  1776. step.AUXSets.Clear();
  1777. foreach (var item in RecipeTemplate["AUX"])
  1778. {
  1779. var displayName = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.RecipeEditParameter.AUX.{item.ControlName}.Display");
  1780. var auxUnit = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.RecipeEditParameter.AUX.{item.ControlName}.Unit");
  1781. AddNewAUX(step, item, displayName, auxUnit);
  1782. // step.AUXSets.Add(item.ControlName, new AUXData() { ControlName = item.ControlName, DisplayName = displayName, SetValue = 0, SetUnit = auxUnit, Rampng = 0, RampngUnit = "SLM", AlarmValue = "None", IsCheck = false, MaxValue = 0, MinValue = 0, Unit = auxUnit });
  1783. }
  1784. }
  1785. StepNo++;
  1786. }
  1787. return step;
  1788. }
  1789. private static void AnalysisIsSaved(XmlNode stepNode, Step step)
  1790. {
  1791. if (stepNode.Attributes["AlarmIsSaved"] != null)
  1792. {
  1793. bool isSaved = true;
  1794. bool.TryParse(stepNode.Attributes["AlarmIsSaved"].Value, out isSaved);
  1795. step.AlarmIsSaved = isSaved;
  1796. }
  1797. else
  1798. {
  1799. step.AlarmIsSaved = true;
  1800. }
  1801. if (stepNode.Attributes["MFCIsSaved"] != null)
  1802. {
  1803. bool isSaved = true;
  1804. bool.TryParse(stepNode.Attributes["MFCIsSaved"].Value, out isSaved);
  1805. step.MFCIsSaved = isSaved;
  1806. }
  1807. else
  1808. {
  1809. step.MFCIsSaved = true;
  1810. }
  1811. if (stepNode.Attributes["ValveIsSaved"] != null)
  1812. {
  1813. bool isSaved = true;
  1814. bool.TryParse(stepNode.Attributes["ValveIsSaved"].Value, out isSaved);
  1815. step.ValveIsSaved = isSaved;
  1816. }
  1817. else
  1818. {
  1819. step.ValveIsSaved = true;
  1820. }
  1821. if (stepNode.Attributes["PressIsSaved"] != null)
  1822. {
  1823. bool isSaved = true;
  1824. bool.TryParse(stepNode.Attributes["PressIsSaved"].Value, out isSaved);
  1825. step.PressIsSaved = isSaved;
  1826. }
  1827. else
  1828. {
  1829. step.PressIsSaved = true;
  1830. }
  1831. if (stepNode.Attributes["AUXIsSaved"] != null)
  1832. {
  1833. bool isSaved = true;
  1834. bool.TryParse(stepNode.Attributes["AUXIsSaved"].Value, out isSaved);
  1835. step.AUXIsSaved = isSaved;
  1836. }
  1837. else
  1838. {
  1839. step.AUXIsSaved = true;
  1840. }
  1841. if (stepNode.Attributes["TemperatureIsSaved"] != null)
  1842. {
  1843. bool isSaved = true;
  1844. bool.TryParse(stepNode.Attributes["TemperatureIsSaved"].Value, out isSaved);
  1845. step.TemperatureIsSaved = isSaved;
  1846. }
  1847. else
  1848. {
  1849. step.TemperatureIsSaved = true;
  1850. }
  1851. }
  1852. private static void FromXmlNodeGetTemperatureSets(XmlNode stepNode, Step step, RecipeTemplateColumnBase item)
  1853. {
  1854. var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.{item.ControlName}.DisplayName");
  1855. TempSetData tempSetData = new TempSetData();
  1856. tempSetData.Name = item.ControlName;
  1857. tempSetData.DisplayName = configHeater != null ? configHeater : item.ControlName;
  1858. tempSetData.SetValue = new StringParam() { Name = "SetValue", Value = stepNode.Attributes[$"{item.ControlName}.Set"] != null ? stepNode.Attributes[$"{item.ControlName}.Set"].Value : "0" };
  1859. tempSetData.SetUnit = new StringParam() { Name = "SetUnit", Value = stepNode.Attributes[$"{item.ControlName}.SetUnit"] != null ? stepNode.Attributes[$"{item.ControlName}.SetUnit"].Value : "℃" };
  1860. tempSetData.RampngValue = new DoubleParam() { Name = "RampngValue", Value = stepNode.Attributes[$"{item.ControlName}.Ramprate"] != null ? stepNode.Attributes[$"{item.ControlName}.Ramprate"].Value : "0" };
  1861. tempSetData.RampngUnit = new StringParam() { Name = "RampngUnit", Value = stepNode.Attributes[$"{item.ControlName}.RamprateUnit"] != null ? stepNode.Attributes[$"{item.ControlName}.RamprateUnit"].Value : "℃/min" };
  1862. bool tempCheck = false;
  1863. if (stepNode.Attributes[$"{item.ControlName}.Check"] != null) bool.TryParse(stepNode.Attributes[$"{item.ControlName}.Check"].Value, out tempCheck);
  1864. tempSetData.IsCheck = new BoolParam() { Name = "IsCheck", Value = tempCheck };
  1865. double tempHigh = 0;
  1866. if (stepNode.Attributes[$"{item.ControlName}.High"] != null) double.TryParse(stepNode.Attributes[$"{item.ControlName}.High"].Value, out tempHigh);
  1867. tempSetData.HighValue = new DoubleParam() { Name = "HighValue", Value = tempHigh.ToString() };
  1868. double tempLow = 0;
  1869. if (stepNode.Attributes[$"{item.ControlName}.Low"] != null) double.TryParse(stepNode.Attributes[$"{item.ControlName}.Low"].Value, out tempLow);
  1870. tempSetData.LowValue = new DoubleParam() { Name = "LowValue", Value = tempLow.ToString() };
  1871. tempSetData.Unit = stepNode.Attributes[$"{item.ControlName}.Unit"] != null ? stepNode.Attributes[$"{item.ControlName}.Unit"].Value : "0";
  1872. if (!step.TemperatureSets.Where(x => x.Name == item.ControlName).Any())
  1873. {
  1874. step.TemperatureSets.Add(tempSetData);
  1875. }
  1876. else
  1877. {
  1878. var tempTemperatureSets = step.TemperatureSets.FirstOrDefault(x => x.Name == item.ControlName);
  1879. int getIndex = step.TemperatureSets.IndexOf(tempTemperatureSets);
  1880. step.TemperatureSets.Remove(tempTemperatureSets);
  1881. step.TemperatureSets.Insert(getIndex, tempSetData);
  1882. }
  1883. }
  1884. private static MFCData StepNodeToMFCData(XmlNode stepNode, RecipeTemplateColumnBase item)
  1885. {
  1886. MFCData mFCValue = new MFCData();
  1887. mFCValue.ControlName = item.ControlName.Replace(".Flow", "");
  1888. if (stepNode.Attributes[$"{item.ControlName}.IsSaved"] != null)
  1889. {
  1890. bool isSaved = true;
  1891. bool.TryParse(stepNode.Attributes[$"{item.ControlName}.IsSaved"].Value, out isSaved);
  1892. mFCValue.FlagIsSaved = isSaved;
  1893. }
  1894. else
  1895. {
  1896. mFCValue.FlagIsSaved = true;
  1897. }
  1898. var setValue = stepNode.Attributes[$"{item.ControlName}.Set"] != null ? stepNode.Attributes[$"{item.ControlName}.Set"].Value : "0";
  1899. mFCValue.SetValue = new StringParam() { Name = "SetValue", Value = setValue };
  1900. var strSetUnit = stepNode.Attributes[$"{item.ControlName}.SetUnit"] != null ? stepNode.Attributes[$"{item.ControlName}.SetUnit"].Value : "SLM";
  1901. mFCValue.SetUnit = new StringParam() { Name = "SetUnit", Value = strSetUnit };
  1902. var rampngValue = stepNode.Attributes[$"{item.ControlName}.Ramprate"] != null ? stepNode.Attributes[$"{item.ControlName}.Ramprate"].Value : "0";
  1903. mFCValue.Rampng = new DoubleParam() { Name = "Rampng", Value = rampngValue };
  1904. var strRampngUnit = stepNode.Attributes[$"{item.ControlName}.RamprateUnit"] != null ? stepNode.Attributes[$"{item.ControlName}.RamprateUnit"].Value : "SLM";
  1905. mFCValue.RampngUnit = new StringParam() { Name = "RampngUnit", Value = strRampngUnit };
  1906. var boolIsCheck = stepNode.Attributes[$"{item.ControlName}.Check"] != null ? bool.Parse(stepNode.Attributes[$"{item.ControlName}.Check"].Value) : false;
  1907. mFCValue.IsCheck = new BoolParam() { Name = "IsCheck", Value = boolIsCheck };
  1908. double maxValue = 0;
  1909. if (stepNode.Attributes[$"{item.ControlName}.High"] != null && !string.IsNullOrEmpty(stepNode.Attributes[$"{item.ControlName}.High"].Value))
  1910. double.TryParse(stepNode.Attributes[$"{item.ControlName}.High"].Value, out maxValue);
  1911. mFCValue.MaxValue = new DoubleParam() { Name = "MaxValue", Value = maxValue.ToString("F3") };
  1912. double minValue = 0;
  1913. if (stepNode.Attributes[$"{item.ControlName}.Low"] != null && !string.IsNullOrEmpty(stepNode.Attributes[$"{item.ControlName}.Low"].Value))
  1914. double.TryParse(stepNode.Attributes[$"{item.ControlName}.High"].Value, out minValue);
  1915. mFCValue.MinValue = new DoubleParam() { Name = "MinValue", Value = minValue.ToString("F3") };
  1916. mFCValue.Unit = stepNode.Attributes[$"{item.ControlName}.Unit"] != null ? stepNode.Attributes[$"{item.ControlName}.Unit"].Value : "SLM";
  1917. mFCValue.ScaleValue = SystemConfigProvider.Instance.GetValueByName($"PM1.MFC.{item.ModuleName}.N2Scale");
  1918. return mFCValue;
  1919. }
  1920. public Step CreateStandbyStep()
  1921. {
  1922. Step step = new Step();
  1923. step.StepNo = 0;
  1924. step.Name = "Standby";
  1925. step.EndBy = "EndByStepTime";
  1926. step.Time = null;
  1927. step.SkipWait = "";
  1928. step.Command = "NoControl";
  1929. //step.ZAxisPosition = "None";
  1930. step.AbortRecipeTableIndex = "None";
  1931. //step.ZAxisSpeed = "0";
  1932. //step.RotatePosition = "None";
  1933. //step.RotateDirection = "CW";
  1934. //step.RotateSpeed = "0";
  1935. //step.RotateInterval = "0";
  1936. //step.APC_SetPressure = "0";
  1937. step.IsnoneConditionCheck = true;
  1938. step.AlarmConditionTable = new StringParam() { Name = "AlarmConditionTable", Value = "1:" };
  1939. //step.MfmD1Flow = new MFMValue() { Value = "0", AlarmValue = "None" };
  1940. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Valve"))
  1941. {
  1942. step.ValveSets.Clear();
  1943. foreach (var item in RecipeTemplate["Valve"])
  1944. {
  1945. if (valveDefaultOpen.Contains(item.ControlName))
  1946. {
  1947. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = true });
  1948. }
  1949. else
  1950. {
  1951. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = false });
  1952. }
  1953. }
  1954. }
  1955. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Temperature"))
  1956. {
  1957. step.TemperatureSets.Clear();
  1958. foreach (var item in RecipeTemplate["Temperature"])
  1959. {
  1960. var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.{item.ControlName}.DisplayName");
  1961. var tempSet = new TempSetData(configHeater);
  1962. tempSet.Name = item.ControlName;
  1963. step.TemperatureSets.Add(tempSet);
  1964. }
  1965. }
  1966. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFC"))
  1967. {
  1968. step.MFCSets.Clear();
  1969. foreach (var item in RecipeTemplate["MFC"])
  1970. {
  1971. step.MFCSets.Add(GetNewMFCData(item.ControlName)); ;
  1972. }
  1973. if (step.MFCSets != null && step.MFCSets.Count > 0)
  1974. {
  1975. for (int i = 0; i < step.MFCSets.Count; i++)
  1976. {
  1977. step.MFCSets[i].No = i + 1;
  1978. }
  1979. }
  1980. }
  1981. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFM"))
  1982. {
  1983. step.MFMSets.Clear();
  1984. foreach (var item in RecipeTemplate["MFM"])
  1985. {
  1986. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = "0", AlarmValue = "0" }); ;
  1987. }
  1988. }
  1989. step.TemperatureControlMode = new StringParam() { Name = "TemperatureControlMode", Value = "Heater" };
  1990. step.TemperatureCorrect = new StringParam() { Name = "TemperatureCorrect", Value = "" };
  1991. step.TemperaturePID = new StringParam() { Name = "TemperaturePID", Value = "" };
  1992. step.LoaderCommand = new StringParam() { Name = "LoaderCommand", Value = "None" };
  1993. step.PressCommand = new StringParam() { Name = "PressCommand", Value = "None" };
  1994. //step.TemperatureProfile = "None";
  1995. //step.TemperatureAlarm = "None";
  1996. //step.CAPTemperatureAlarm = "None";
  1997. //step.TemperatureStabilize = "None";
  1998. step.FilmThickFormula = "None";
  1999. //隐藏StandBy行
  2000. //step.IsVisibility = Visibility.Collapsed;
  2001. return step;
  2002. }
  2003. public Step CreateFirstStep()
  2004. {
  2005. Step step = new Step();
  2006. step.StepNo = 1;
  2007. step.Name = "Name";
  2008. step.EndBy = "EndByStepTime";
  2009. step.Time = null;
  2010. step.SkipWait = "";
  2011. step.Command = "NoControl";
  2012. //step.ZAxisPosition = "None";
  2013. step.AbortRecipeTableIndex = "None";
  2014. //step.ZAxisSpeed = "0";
  2015. //step.RotatePosition = "None";
  2016. //step.RotateDirection = "CW";
  2017. //step.RotateSpeed = "0";
  2018. //step.RotateInterval = "0";
  2019. //step.APC_SetPressure = "0";
  2020. step.IsnoneConditionCheck = true;
  2021. step.AlarmConditionTable = new StringParam() { Name = "AlarmConditionTable", Value = "1:" };
  2022. //step.MfmD1Flow = new MFMValue() { Value = "0", AlarmValue = "None" };
  2023. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Valve"))
  2024. {
  2025. step.ValveSets.Clear();
  2026. foreach (var item in RecipeTemplate["Valve"])
  2027. {
  2028. if (valveDefaultOpen.Contains(item.ControlName))
  2029. {
  2030. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = true });
  2031. }
  2032. else
  2033. {
  2034. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = false });
  2035. }
  2036. }
  2037. }
  2038. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Temperature"))
  2039. {
  2040. step.TemperatureSets.Clear();
  2041. foreach (var item in RecipeTemplate["Temperature"])
  2042. {
  2043. var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.{item.ControlName}.DisplayName");
  2044. var tempSet = new TempSetData(configHeater);
  2045. tempSet.Name = item.ControlName;
  2046. step.TemperatureSets.Add(tempSet);
  2047. }
  2048. }
  2049. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFC"))
  2050. {
  2051. step.MFCSets.Clear();
  2052. foreach (var item in RecipeTemplate["MFC"])
  2053. {
  2054. step.MFCSets.Add(GetNewMFCData(item.ControlName));
  2055. }
  2056. if (step.MFCSets != null && step.MFCSets.Count > 0)
  2057. {
  2058. for (int i = 0; i < step.MFCSets.Count; i++)
  2059. {
  2060. step.MFCSets[i].No = i + 1;
  2061. }
  2062. }
  2063. }
  2064. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFM"))
  2065. {
  2066. step.MFMSets.Clear();
  2067. foreach (var item in RecipeTemplate["MFM"])
  2068. {
  2069. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = "0", AlarmValue = "0" }); ;
  2070. }
  2071. }
  2072. step.TemperatureControlMode = new StringParam() { Name = "TemperatureControlMode", Value = "Heater" };
  2073. step.TemperatureCorrect = new StringParam() { Name = "TemperatureCorrect", Value = "" };
  2074. step.TemperaturePID = new StringParam() { Name = "TemperaturePID", Value = "" };
  2075. step.LoaderCommand = new StringParam() { Name = "LoaderCommand", Value = "None" };
  2076. step.PressCommand = new StringParam() { Name = "PressCommand", Value = "None" };
  2077. //step.TemperatureProfile = "None";
  2078. //step.TemperatureAlarm = "None";
  2079. //step.CAPTemperatureAlarm = "None";
  2080. //step.TemperatureStabilize = "None";
  2081. step.FilmThickFormula = "None";
  2082. //隐藏StandBy行
  2083. //step.IsVisibility = Visibility.Collapsed;
  2084. return step;
  2085. }
  2086. public Step CreateEndStep()
  2087. {
  2088. Step step = new Step();
  2089. step.StepNo = 2;
  2090. step.Name = "End";
  2091. step.EndBy = "EndByStepTime";
  2092. step.Time = null;
  2093. step.SkipWait = "";
  2094. step.Command = "NoControl";
  2095. //step.ZAxisPosition = "None";
  2096. step.AbortRecipeTableIndex = "None";
  2097. //step.ZAxisSpeed = "0";
  2098. //step.RotatePosition = "None";
  2099. //step.RotateDirection = "CW";
  2100. //step.RotateSpeed = "0";
  2101. //step.RotateInterval = "0";
  2102. //step.APC_SetPressure = "0";
  2103. step.IsnoneConditionCheck = true;
  2104. step.AlarmConditionTable = new StringParam() { Name = "AlarmConditionTable", Value = "1:" };
  2105. //step.MfmD1Flow = new MFMValue() { Value = "0", AlarmValue = "None" };
  2106. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Valve"))
  2107. {
  2108. step.ValveSets.Clear();
  2109. foreach (var item in RecipeTemplate["Valve"])
  2110. {
  2111. if (valveDefaultOpen.Contains(item.ControlName))
  2112. {
  2113. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = true });
  2114. }
  2115. else
  2116. {
  2117. step.ValveSets.Add(new BoolParam() { Name = item.ControlName, Value = false });
  2118. }
  2119. }
  2120. }
  2121. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("Temperature"))
  2122. {
  2123. step.TemperatureSets.Clear();
  2124. foreach (var item in RecipeTemplate["Temperature"])
  2125. {
  2126. var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.{item.ControlName}.DisplayName");
  2127. var tempSet = new TempSetData(configHeater);
  2128. tempSet.Name = item.ControlName;
  2129. step.TemperatureSets.Add(tempSet);
  2130. }
  2131. }
  2132. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFC"))
  2133. {
  2134. step.MFCSets.Clear();
  2135. foreach (var item in RecipeTemplate["MFC"])
  2136. {
  2137. step.MFCSets.Add(GetNewMFCData(item.ControlName)); ;
  2138. }
  2139. if (step.MFCSets != null && step.MFCSets.Count > 0)
  2140. {
  2141. for (int i = 0; i < step.MFCSets.Count; i++)
  2142. {
  2143. step.MFCSets[i].No = i + 1;
  2144. }
  2145. }
  2146. }
  2147. if (RecipeTemplate != null && RecipeTemplate.ContainsKey("MFM"))
  2148. {
  2149. step.MFMSets.Clear();
  2150. foreach (var item in RecipeTemplate["MFM"])
  2151. {
  2152. step.MFMSets.Add(item.ControlName, new MFMValue() { Value = "0", AlarmValue = "0" }); ;
  2153. }
  2154. }
  2155. step.TemperatureControlMode = new StringParam() { Name = "TemperatureControlMode", Value = "Heater" };
  2156. step.TemperatureCorrect = new StringParam() { Name = "TemperatureCorrect", Value = "" };
  2157. step.TemperaturePID = new StringParam() { Name = "TemperaturePID", Value = "" };
  2158. step.LoaderCommand = new StringParam() { Name = "LoaderCommand", Value = "None" };
  2159. step.PressCommand = new StringParam() { Name = "PressCommand", Value = "None" };
  2160. //step.TemperatureProfile = "None";
  2161. //step.TemperatureAlarm = "None";
  2162. //step.CAPTemperatureAlarm = "None";
  2163. //step.TemperatureStabilize = "None";
  2164. step.FilmThickFormula = "None";
  2165. //隐藏StandBy行
  2166. //step.IsVisibility = Visibility.Collapsed;
  2167. return step;
  2168. }
  2169. private static void ReadConditionCheck(XmlNode stepNode, Step step)
  2170. {
  2171. if (stepNode.Attributes["ConditionCheck"] != null)
  2172. {
  2173. var conditionCheckValue = stepNode.Attributes["ConditionCheck"].Value;
  2174. if (conditionCheckValue != "none")
  2175. {
  2176. var subValues = conditionCheckValue.Split(';');
  2177. if (subValues.Count() == 0) return;
  2178. foreach (var item in subValues)
  2179. {
  2180. var itemValues = item.Split(':');
  2181. switch (itemValues[0])
  2182. {
  2183. case "ExternalSensor":
  2184. //step.ExternalSensor = itemValues[1].Split(',').ToArray();
  2185. var externalSensor = itemValues[1].Split(',').ToArray();
  2186. for (int i = 0; i < externalSensor.Count(); i++)
  2187. {
  2188. step.ExternalSensorName[i] = externalSensor[i].Split('.')[0];
  2189. step.ExternalSensor[i] = externalSensor[i].Split('.')[1];
  2190. }
  2191. break;
  2192. case "TempStabilize":
  2193. step.TempStabilizeSelected = itemValues[1];
  2194. break;
  2195. case "FinishAutoProfile":
  2196. step.FinishAutoProfile = itemValues[1];
  2197. break;
  2198. //case "TempUpper":
  2199. // step.TempUpper = int.Parse(itemValues[1]);
  2200. // break;
  2201. //case "TempLower":
  2202. // step.TempLower = int.Parse(itemValues[1]);
  2203. // break;
  2204. case "ReachTemp":
  2205. var reachTemp = itemValues[1];
  2206. if (reachTemp == "None")
  2207. {
  2208. step.ReachTemp = reachTemp;
  2209. step.ReachTempValue = 0;
  2210. }
  2211. else
  2212. {
  2213. step.ReachTemp = itemValues[1].Split(',')[0];
  2214. step.ReachTempValue = double.Parse(itemValues[1].Split(',')[1]);
  2215. }
  2216. break;
  2217. case "O2Density":
  2218. var o2Density = itemValues[1];
  2219. if (o2Density == "None")
  2220. {
  2221. step.O2Density = o2Density;
  2222. step.O2DensityValue = 0;
  2223. }
  2224. else
  2225. {
  2226. step.O2Density = itemValues[1].Split(',')[0];
  2227. step.O2DensityValue = int.Parse(itemValues[1].Split(',')[1]);
  2228. }
  2229. break;
  2230. //case "PressureUpper":
  2231. // step.PressureUpper = double.Parse(itemValues[1]);
  2232. // break;
  2233. //case "PressureLower":
  2234. // step.PressureLower = double.Parse(itemValues[1]);
  2235. // break;
  2236. case "ReachPressure":
  2237. var reachPressure = itemValues[1];
  2238. if (reachPressure == "None")
  2239. {
  2240. step.ReachPressure = reachPressure;
  2241. step.ReachPressureVG = reachPressure;
  2242. step.ReachPressureValue = 0;
  2243. }
  2244. else
  2245. {
  2246. step.ReachPressure = itemValues[1].Split(',')[0];
  2247. if (itemValues[1].Split(',').Length > 2)
  2248. {
  2249. step.ReachPressureVG = itemValues[1].Split(',')[1];
  2250. step.ReachPressureValue = double.Parse(itemValues[1].Split(',')[2]);
  2251. }
  2252. else
  2253. step.ReachPressureValue = double.Parse(itemValues[1].Split(',')[1]);
  2254. }
  2255. break;
  2256. case "PressureStabilize":
  2257. if (itemValues[1].Split(',').Length > 1)
  2258. {
  2259. step.PressureStabilizeSelected = itemValues[1].Split(',')[0];
  2260. step.PressureStabilizeVG = itemValues[1].Split(',')[1];
  2261. }
  2262. else
  2263. step.PressureStabilizeSelected = itemValues[1].Split(',')[0];
  2264. break;
  2265. case "ProcessTimeToEnd":
  2266. step.ProcessTimeToEnd = itemValues[1];
  2267. break;
  2268. default:
  2269. break;
  2270. }
  2271. }
  2272. }
  2273. else
  2274. {
  2275. step.IsnoneConditionCheck = true;
  2276. }
  2277. if (step.ExternalSensor == null || step.ExternalSensor.Count() == 0)
  2278. {
  2279. step.ExternalSensor = new string[] { "None", "None", "None", "None", "None", "None", "None" };
  2280. }
  2281. if (step.TempStabilizeSelected == null)
  2282. step.TempStabilizeSelected = "None";
  2283. if (step.FinishAutoProfile == null)
  2284. step.FinishAutoProfile = "None";
  2285. if (step.ReachTemp == null)
  2286. step.ReachTemp = "None";
  2287. if (step.O2Density == null)
  2288. step.O2Density = "None";
  2289. if (step.ReachPressure == null)
  2290. step.ReachPressure = "None";
  2291. if (step.PressureStabilizeSelected == null)
  2292. step.PressureStabilizeSelected = "None";
  2293. if (step.ProcessTimeToEnd == null)
  2294. step.ProcessTimeToEnd = "None";
  2295. }
  2296. }
  2297. public bool CreateStepTolerance(XmlNode stepNode, out ObservableCollection<Param> step, out ObservableCollection<Param> warning, out ObservableCollection<Param> alarm,
  2298. out Dictionary<string, ObservableCollection<Param>> popSettingStep)
  2299. {
  2300. step = new ObservableCollection<Param>();
  2301. warning = new ObservableCollection<Param>();
  2302. alarm = new ObservableCollection<Param>();
  2303. popSettingStep = new Dictionary<string, ObservableCollection<Param>>();
  2304. return true;
  2305. }
  2306. private bool LoadHeader(XmlNode nodeHeader)
  2307. {
  2308. if (nodeHeader == null)
  2309. return false;
  2310. if (nodeHeader.Attributes["CreatedBy"] != null)
  2311. this.Creator = nodeHeader.Attributes["CreatedBy"].Value;
  2312. if (nodeHeader.Attributes["CreationTime"] != null)
  2313. this.CreateTime = DateTime.Parse(nodeHeader.Attributes["CreationTime"].Value);
  2314. if (nodeHeader.Attributes["LastRevisedBy"] != null)
  2315. this.Revisor = nodeHeader.Attributes["LastRevisedBy"].Value;
  2316. if (nodeHeader.Attributes["LastRevisionTime"] != null)
  2317. this.ReviseTime = DateTime.Parse(nodeHeader.Attributes["LastRevisionTime"].Value);
  2318. if (nodeHeader.Attributes["Description"] != null)
  2319. this.Description = nodeHeader.Attributes["Description"].Value;
  2320. if (nodeHeader.Attributes["TableIndex"] != null)
  2321. this.TableIndex = int.Parse(nodeHeader.Attributes["TableIndex"].Value);
  2322. string chamberType = string.Empty;
  2323. if (nodeHeader.Attributes["RecipeChamberType"] != null)
  2324. this.RecipeChamberType = nodeHeader.Attributes["RecipeChamberType"].Value;
  2325. //if (!string.IsNullOrEmpty(chamberType) && chamberType != RecipeChamberType)
  2326. //{
  2327. // LOG.Write($"{chamberType} is not accordance with {RecipeChamberType}");
  2328. // return false;
  2329. //}
  2330. string version = string.Empty;
  2331. if (nodeHeader.Attributes["RecipeVersion"] != null)
  2332. version = nodeHeader.Attributes["RecipeVersion"].Value;
  2333. //if (!string.IsNullOrEmpty(version) && version != RecipeVersion)
  2334. //{
  2335. // LOG.Write($"{version} is not accordance with {RecipeVersion}");
  2336. // return false;
  2337. //}
  2338. return true;
  2339. }
  2340. private void LoadTables(XmlNode nodeRoot)
  2341. {
  2342. Tables.Clear();
  2343. foreach (XmlNode nodeTable in nodeRoot.ChildNodes)
  2344. {
  2345. XmlNodeList nodeSteps = nodeTable.SelectNodes($"Step");
  2346. RecipeTable recipeDataBase = new RecipeTable();
  2347. recipeDataBase.Index = int.Parse(nodeTable.Attributes["Index"].Value);
  2348. recipeDataBase.Name = nodeTable.Attributes["Name"].Value;
  2349. recipeDataBase.EndStatus = nodeTable.Attributes["EndStatus"].Value;
  2350. RecipeDataBase tableData = new RecipeDataBase();
  2351. tableData.FastLoadSteps(nodeSteps);
  2352. recipeDataBase.TableData = tableData;
  2353. Tables.Add(recipeDataBase);
  2354. }
  2355. }
  2356. private void LoadSteps(XmlNodeList steps)
  2357. {
  2358. Steps.Clear();
  2359. PopSettingSteps.Clear();
  2360. StepTolerances.Clear();
  2361. StepNos.Clear();
  2362. int index = 1;
  2363. foreach (XmlNode nodeStep in steps)
  2364. {
  2365. Step step = this.CreateStep(nodeStep);
  2366. StepNos.Add(step.StepNo);
  2367. Steps.Add(step);
  2368. index++;
  2369. }
  2370. if (StepNos == null || StepNos.Count == 0)
  2371. {
  2372. StepNo = 1;
  2373. }
  2374. else
  2375. {
  2376. StepNo = StepNos.Max() + 1;
  2377. }
  2378. }
  2379. private void FastLoadSteps(XmlNodeList steps)
  2380. {
  2381. Steps.Clear();
  2382. PopSettingSteps.Clear();
  2383. StepTolerances.Clear();
  2384. StepNos.Clear();
  2385. if (steps.Count != 0)
  2386. {
  2387. Step step = this.CreateStep(steps[0]);
  2388. var query1 = (from XmlNode n in steps select n).ToList();
  2389. query1.RemoveAt(0);
  2390. var allSteps = query1.AsParallel().AsOrdered()
  2391. .Select(x => this.CreateStep(Steps[0], x));
  2392. StepNos.Add(step.StepNo);
  2393. Steps.Add(step);
  2394. foreach (var item in allSteps)
  2395. {
  2396. StepNos.Add(item.StepNo);
  2397. Steps.Add(item);
  2398. }
  2399. }
  2400. }
  2401. private void LoadConfigs(XmlNode configNode)
  2402. {
  2403. if (configNode == null)
  2404. return;
  2405. foreach (Param configItem in ConfigItems)
  2406. {
  2407. if (configNode.Attributes[configItem.Name] != null)
  2408. {
  2409. if (configItem is StringParam)
  2410. (configItem as StringParam).Value = configNode.Attributes[configItem.Name]?.Value;
  2411. else if (configItem is DoubleParam)
  2412. (configItem as DoubleParam).Value = configNode.Attributes[configItem.Name]?.Value;
  2413. }
  2414. }
  2415. }
  2416. private string GetConditionCheckXmlString(Step parameters)
  2417. {
  2418. StringBuilder conditionCheckStr = new StringBuilder();
  2419. string externalSensor = "";
  2420. string[] tempStr = new string[] { "", "", "", "", "", "", "" };
  2421. for (int i = 0; i < tempStr.Count(); i++)
  2422. {
  2423. tempStr[i] = $"{parameters.ExternalSensorName[i]}.{parameters.ExternalSensor[i]}";
  2424. }
  2425. externalSensor = $"ExternalSensor:{string.Join(",", tempStr.Select(x => x.ToString()))}";
  2426. conditionCheckStr.Append($"{externalSensor};");
  2427. conditionCheckStr.Append($"TempStabilize:{parameters.TempStabilizeSelected};");
  2428. conditionCheckStr.Append($"FinishAutoProfile:{parameters.FinishAutoProfile};");
  2429. //conditionCheckStr.Append($"TempUpper:{parameters.TempUpper.ToString()};");
  2430. //conditionCheckStr.Append($"TempLower:{parameters.TempLower.ToString()};");
  2431. if (parameters.ReachTemp == "None")
  2432. {
  2433. conditionCheckStr.Append($"ReachTemp:{parameters.ReachTemp};");
  2434. }
  2435. else
  2436. {
  2437. conditionCheckStr.Append($"ReachTemp:{parameters.ReachTemp},{parameters.ReachTempValue.ToString()};");
  2438. }
  2439. if (parameters.O2Density == "None")
  2440. {
  2441. conditionCheckStr.Append($"O2Density:{parameters.O2Density};");
  2442. }
  2443. else
  2444. {
  2445. conditionCheckStr.Append($"O2Density:{parameters.O2Density},{parameters.O2DensityValue.ToString()};");
  2446. }
  2447. //conditionCheckStr.Append($"PressureUpper:{parameters.PressureUpper.ToString()};");
  2448. //conditionCheckStr.Append($"PressureLower:{parameters.PressureLower.ToString()};");
  2449. if (parameters.ReachPressure == "None")
  2450. {
  2451. conditionCheckStr.Append($"ReachPressureWait:{parameters.ReachPressure};");
  2452. }
  2453. else
  2454. {
  2455. conditionCheckStr.Append($"ReachPressure:{parameters.ReachPressure},{parameters.ReachPressureVG},{parameters.ReachPressureValue.ToString()};");
  2456. }
  2457. conditionCheckStr.Append($"PressureStabilize:{parameters.PressureStabilizeSelected},{parameters.PressureStabilizeVG}");
  2458. conditionCheckStr.Append($"ProcessTimeToEnd:{parameters.ProcessTimeToEnd}");
  2459. return conditionCheckStr.ToString();
  2460. }
  2461. private void CreateTablesXml(XmlElement nodeData)
  2462. {
  2463. XmlNode nodeTables = _doc.SelectSingleNode($"Aitex/TableRecipeData/Tables");
  2464. if (nodeTables == null) //创建Recipe文件
  2465. {
  2466. nodeTables = _doc.CreateElement("Tables");
  2467. nodeData.AppendChild(nodeTables);
  2468. nodeTables.RemoveAll();
  2469. int tableCount = 20;
  2470. if (_chamberType.ToLower() == "abort")
  2471. {
  2472. tableCount = 10;
  2473. }
  2474. for (int i = 1; i <= tableCount; i++)
  2475. {
  2476. XmlElement nodeTable = _doc.CreateElement("Table");
  2477. nodeTable.SetAttribute("Index", i.ToString());
  2478. nodeTable.SetAttribute("EndStatus", "");
  2479. nodeTable.SetAttribute("Name", "");
  2480. nodeTables.AppendChild(nodeTable);
  2481. }
  2482. }
  2483. }
  2484. private void SaveTables(XmlElement nodeData, List<XmlElement> steps, int tableIndex = 1)
  2485. {
  2486. //XmlNode nodeTables = nodeData.SelectSingleNode($"Aitex/TableRecipeData/Tables");
  2487. XmlElement selectednodeTable = (XmlElement)nodeData.ChildNodes[0].SelectSingleNode($"Table[@Index='{tableIndex}']");
  2488. var table = this.Tables.FirstOrDefault(x => x.Index == tableIndex);
  2489. if (selectednodeTable == null || table == null)
  2490. return;
  2491. selectednodeTable.SetAttribute("EndStatus", table.EndStatus);
  2492. selectednodeTable.SetAttribute("Name", table.Name);
  2493. while (selectednodeTable.FirstChild != null)
  2494. {
  2495. selectednodeTable.RemoveChild(selectednodeTable.FirstChild);
  2496. }
  2497. steps.ForEach(x => selectednodeTable.AppendChild(x));
  2498. }
  2499. public string GetXmlString()
  2500. {
  2501. XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableRecipeData") as XmlElement;
  2502. nodeData.SetAttribute("CreatedBy", Creator);
  2503. nodeData.SetAttribute("CreationTime", CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  2504. nodeData.SetAttribute("LastRevisedBy", Revisor);
  2505. nodeData.SetAttribute("LastRevisionTime", ReviseTime.ToString("yyyy-MM-dd HH:mm:ss"));
  2506. nodeData.SetAttribute("Description", Description);
  2507. nodeData.SetAttribute("RecipeChamberType", RecipeChamberType);
  2508. nodeData.SetAttribute("RecipeVersion", RecipeVersion);
  2509. nodeData.SetAttribute("RecipePermission", RecipePermission);
  2510. nodeData.SetAttribute("RecipeLevel", RecipeLevel);
  2511. nodeData.SetAttribute("TableIndex", TableIndex.ToString());
  2512. if (!SaveTableRecipeTypes.Contains(RecipeChamberType))
  2513. {
  2514. XmlNode nodeModule = _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{_module}']");
  2515. if (nodeModule == null)
  2516. {
  2517. nodeModule = _doc.CreateElement("Module");
  2518. nodeData.AppendChild(nodeModule);
  2519. }
  2520. nodeModule.RemoveAll();
  2521. (nodeModule as XmlElement).SetAttribute("Name", _module);
  2522. int i = 0;
  2523. foreach (Step parameters in Steps)
  2524. {
  2525. XmlElement nodeWarning = _doc.CreateElement("Warning");
  2526. XmlElement nodeAlarm = _doc.CreateElement("Alarm");
  2527. Dictionary<string, XmlElement> nodePop = new Dictionary<string, XmlElement>();
  2528. foreach (string key in PopEnable.Keys)
  2529. {
  2530. nodePop.Add(key, _doc.CreateElement(key));
  2531. }
  2532. XmlElement nodeStep = _doc.CreateElement("Step");
  2533. if (ToleranceEnable)
  2534. {
  2535. nodeStep.AppendChild(nodeWarning);
  2536. nodeStep.AppendChild(nodeAlarm);
  2537. }
  2538. nodeStep.SetAttribute("StepNo", parameters.StepNo.ToString());
  2539. nodeStep.SetAttribute("Name", parameters.Name);
  2540. nodeStep.SetAttribute("EndBy", parameters.EndBy);
  2541. nodeStep.SetAttribute("Time", parameters.Time);
  2542. nodeStep.SetAttribute("SkipWait", parameters.SkipWait);
  2543. nodeStep.SetAttribute("Command", parameters.Command);
  2544. nodeStep.SetAttribute("AlarmIsSaved", parameters.AlarmIsSaved.ToString());
  2545. nodeStep.SetAttribute("MFCIsSaved", parameters.MFCIsSaved.ToString());
  2546. nodeStep.SetAttribute("ValveIsSaved", parameters.ValveIsSaved.ToString());
  2547. nodeStep.SetAttribute("PressIsSaved", parameters.PressIsSaved.ToString());
  2548. nodeStep.SetAttribute("AUXIsSaved", parameters.AUXIsSaved.ToString());
  2549. nodeStep.SetAttribute("TemperatureIsSaved", parameters.TemperatureIsSaved.ToString());
  2550. if (parameters.IsnoneConditionCheck)
  2551. {
  2552. nodeStep.SetAttribute("ConditionCheck", "none");
  2553. }
  2554. else
  2555. {
  2556. nodeStep.SetAttribute("ConditionCheck", GetConditionCheckXmlString(parameters));
  2557. }
  2558. //nodeStep.SetAttribute("PressureSonserValue", parameters.PressureSonserValue);
  2559. //nodeStep.SetAttribute("PressureSonserValue", parameters.PressureSonserValue);
  2560. //nodeStep.SetAttribute("PressureValveAngle", parameters.PressureValveAngle);
  2561. //nodeStep.SetAttribute("PressureSettingVG", parameters.PressureSettingVG);
  2562. //nodeStep.SetAttribute("SlowVacuumValue", parameters.SlowVacuumValue);
  2563. //nodeStep.SetAttribute("PressureAlarmTableNo", parameters.PressureAlarmTableNo);
  2564. //nodeStep.SetAttribute("ZAxisPosition", parameters.ZAxisPosition);
  2565. //nodeStep.SetAttribute("ZAxisSpeed", parameters.ZAxisSpeed);
  2566. //nodeStep.SetAttribute("RotateDirection", parameters.RotateDirection);
  2567. //nodeStep.SetAttribute("RotatePosition", parameters.RotatePosition);
  2568. //nodeStep.SetAttribute("RotateSpeed", parameters.RotateSpeed);
  2569. //nodeStep.SetAttribute("RotateInterval", parameters.RotateInterval);
  2570. //nodeStep.SetAttribute("APC.SetPressure", parameters.APC_SetPressure);
  2571. //nodeStep.SetAttribute("MfmD1Flow", parameters.MfmD1Flow.ToString());
  2572. //nodeStep.SetAttribute("RFSwitch", parameters.RFSwitch);
  2573. //nodeStep.SetAttribute("RFSetpoint", parameters.RFSetpoint);
  2574. //nodeStep.SetAttribute("RFPowerSetpoint", parameters.RFPowerSetpoint);
  2575. //nodeStep.SetAttribute("CAPSetValue", parameters.CAPSetValue);
  2576. //nodeStep.SetAttribute("CAPRampingValue", parameters.CAPRampingValue);
  2577. //nodeStep.SetAttribute("C1Setpoint", parameters.C1Setpoint);
  2578. //nodeStep.SetAttribute("C2Setpoint", parameters.C2Setpoint);
  2579. //nodeStep.SetAttribute("ForwardPowerAlarmWatchTable", parameters.ForwardPowerAlarmWatchTable);
  2580. //nodeStep.SetAttribute("C1AlarmWatchTable", parameters.C1AlarmWatchTable);
  2581. //nodeStep.SetAttribute("C2AlarmWatchTable", parameters.C2AlarmWatchTable);
  2582. //nodeStep.SetAttribute("PrAlarmWatchTable", parameters.PrAlarmWatchTable);
  2583. //nodeStep.SetAttribute("PIAlarmWatchTable", parameters.PIAlarmWatchTable);
  2584. //nodeStep.SetAttribute("VppAlarmWatchTable", parameters.VppAlarmWatchTable);
  2585. //nodeStep.SetAttribute("VdcAlarmWatchTable", parameters.VdcAlarmWatchTable);
  2586. nodeStep.SetAttribute("AlarmConditionTable", parameters.AlarmConditionTable.Value);
  2587. nodeStep.SetAttribute("AbortRecipeTableIndex", parameters.AbortRecipeTableIndex);
  2588. //nodeStep.SetAttribute("EventSetting", parameters.EventSetting);
  2589. var dpParam = parameters.ValveSets.FirstOrDefault(x => x.Name == "DP");
  2590. foreach (var item in parameters.ValveSets)
  2591. {
  2592. if (item.Name == "MBP")
  2593. {
  2594. if (dpParam != null)
  2595. {
  2596. nodeStep.SetAttribute(item.Name, dpParam.Value ? "Open" : "Close");
  2597. }
  2598. else
  2599. {
  2600. nodeStep.SetAttribute(item.Name, item.Value ? "Open" : "Close");
  2601. }
  2602. }
  2603. else
  2604. {
  2605. nodeStep.SetAttribute(item.Name, item.Value ? "Open" : "Close");
  2606. }
  2607. }
  2608. foreach (var item in parameters.MFCSets)
  2609. {
  2610. nodeStep.SetAttribute($"{item.ControlName}.Flow.IsSaved", item.IsSaved.ToString());
  2611. nodeStep.SetAttribute($"{item.ControlName}.Flow.Set", item.SetValue.Value);
  2612. nodeStep.SetAttribute($"{item.ControlName}.Flow.SetUnit", item.SetUnit.Value);
  2613. nodeStep.SetAttribute($"{item.ControlName}.Flow.Ramprate", item.Rampng.Value);
  2614. nodeStep.SetAttribute($"{item.ControlName}.Flow.RamprateUnit", item.RampngUnit.Value);
  2615. nodeStep.SetAttribute($"{item.ControlName}.Flow.Check", item.IsCheck.Value.ToString());
  2616. nodeStep.SetAttribute($"{item.ControlName}.Flow.High", item.MaxValue.Value.ToString());
  2617. nodeStep.SetAttribute($"{item.ControlName}.Flow.Low", item.MinValue.Value.ToString());
  2618. nodeStep.SetAttribute($"{item.ControlName}.Flow.Unit", item.Unit);
  2619. }
  2620. foreach (var item in parameters.MFMSets)
  2621. {
  2622. nodeStep.SetAttribute(item.Key, parameters.MFMSets[item.Key].ToString());
  2623. }
  2624. foreach (var item in parameters.EXOUSets.Keys)
  2625. {
  2626. nodeStep.SetAttribute(item, parameters.EXOUSets[item].ToString());
  2627. }
  2628. foreach (var item in parameters.TemperatureSets)
  2629. {
  2630. nodeStep.SetAttribute($"{item.Name}.ZoneName", item.Name);
  2631. nodeStep.SetAttribute($"{item.Name}.Set", item.SetValue.Value);
  2632. nodeStep.SetAttribute($"{item.Name}.SetUnit", item.SetUnit.Value);
  2633. nodeStep.SetAttribute($"{item.Name}.Ramprate", item.RampngValue.Value);
  2634. nodeStep.SetAttribute($"{item.Name}.RamprateUnit", item.RampngUnit.Value);
  2635. nodeStep.SetAttribute($"{item.Name}.Check", item.IsCheck.Value.ToString());
  2636. nodeStep.SetAttribute($"{item.Name}.High", item.HighValue.Value.ToString());
  2637. nodeStep.SetAttribute($"{item.Name}.Low", item.LowValue.Value.ToString());
  2638. nodeStep.SetAttribute($"{item.Name}.Unit", item.Unit.ToString());
  2639. }
  2640. nodeStep.SetAttribute("Temperature.ControlMode", parameters.TemperatureControlMode.Value);
  2641. nodeStep.SetAttribute("Temperature.Correct", parameters.TemperatureCorrect.Value);
  2642. nodeStep.SetAttribute("Temperature.PID", parameters.TemperaturePID.Value);
  2643. nodeStep.SetAttribute("Loader.Command", parameters.LoaderCommand.Value);
  2644. nodeStep.SetAttribute("Loader.Speed1", parameters.LoaderSpeed1.Value);
  2645. nodeStep.SetAttribute("Loader.Speed2", parameters.LoaderSpeed2.Value);
  2646. nodeStep.SetAttribute("Loader.Speed3", parameters.LoaderSpeed3.Value);
  2647. nodeStep.SetAttribute("Loader.RPM", parameters.LoaderRPM.Value.ToString());
  2648. nodeStep.SetAttribute("Press.Command", parameters.PressCommand.Value);
  2649. nodeStep.SetAttribute("Press.PID", parameters.PressPID.Value);
  2650. // nodeStep.SetAttribute("Press.Set", parameters.PressSet.Value);
  2651. nodeStep.SetAttribute("Press.Set", GetPressSetValue(parameters));
  2652. // nodeStep.SetAttribute("Press.SlowVacSet", parameters.PressSlowVacSet.Value);
  2653. nodeStep.SetAttribute("Press.SlowVacSet", GetPressSlowVacSet(parameters));
  2654. // nodeStep.SetAttribute("Press.ValveAngleSet", parameters.PressValveAngleSet.Value);
  2655. nodeStep.SetAttribute("Press.ValveAngleSet", RecipeDataBase.GetValveAngleSet(parameters));
  2656. nodeStep.SetAttribute("Press.IsWait", parameters.PressIsWait.Value.ToString());
  2657. nodeStep.SetAttribute("Press.LowWait", parameters.PressLowWait.Value);
  2658. nodeStep.SetAttribute("Press.HighWait", parameters.PressHighWait.Value);
  2659. nodeStep.SetAttribute("Press.WaitUnit", parameters.PressWaitUnit.Value);
  2660. nodeStep.SetAttribute("Press.LowPressWait", parameters.PressLowPressWait.Value);
  2661. // nodeStep.SetAttribute("Press.WaitPress", parameters.WaitPress.Value);
  2662. nodeStep.SetAttribute("Press.WaitPress", RecipeDataBase.GetWaitPress(parameters));
  2663. nodeStep.SetAttribute("FilmThickFormula", parameters.FilmThickFormula);
  2664. foreach (var item in parameters.AUXSets)
  2665. {
  2666. nodeStep.SetAttribute($"AUX.{item.ControlName}.Set", item.SetValue.Value);
  2667. nodeStep.SetAttribute($"AUX.{item.ControlName}.Check", item.IsCheck.Value.ToString());
  2668. nodeStep.SetAttribute($"AUX.{item.ControlName}.High", item.MaxValue.Value);
  2669. nodeStep.SetAttribute($"AUX.{item.ControlName}.Low", item.MinValue.Value);
  2670. nodeStep.SetAttribute($"AUX.{item.ControlName}.CheckUnit", item.SetUnit.Value);
  2671. }
  2672. nodeModule.AppendChild(nodeStep);
  2673. i++;
  2674. }
  2675. XmlElement nodeConfig = _doc.CreateElement("Config");
  2676. foreach (Param parameter in ConfigItems)
  2677. {
  2678. if (parameter.Visible == System.Windows.Visibility.Visible)
  2679. {
  2680. if (parameter is IntParam)
  2681. nodeConfig.SetAttribute(parameter.Name, ((IntParam)parameter).Value.ToString());
  2682. else if (parameter is DoubleParam)
  2683. {
  2684. string strValue = ((DoubleParam)parameter).Value;
  2685. bool succed = double.TryParse(strValue, out double dValue);
  2686. if (!succed)
  2687. {
  2688. MessageBox.Show($"The set value of {parameter.DisplayName} is {strValue}, not a valid value");
  2689. return null;
  2690. }
  2691. var config = ConfigItems.Where(m => m.Name == parameter.Name).FirstOrDefault();
  2692. if (config is DoubleParam param1)
  2693. {
  2694. if (param1.Minimun == 0 && param1.Maximun == 0)
  2695. {
  2696. //没有设定范围
  2697. }
  2698. else if (dValue > param1.Maximun || dValue < param1.Minimun)
  2699. {
  2700. MessageBox.Show($"The set value of {parameter.DisplayName} is {dValue}, out of the range {param1.Minimun}~{param1.Maximun}");
  2701. return null;
  2702. }
  2703. }
  2704. nodeConfig.SetAttribute(parameter.Name, ((DoubleParam)parameter).Value.ToString());
  2705. }
  2706. else if (parameter is StringParam)
  2707. nodeConfig.SetAttribute(parameter.Name, ((StringParam)parameter).Value?.ToString());
  2708. else if (parameter is ComboxParam)
  2709. nodeConfig.SetAttribute(parameter.Name, ((ComboxParam)parameter).Value.ToString());
  2710. else if (parameter is LoopComboxParam)
  2711. nodeConfig.SetAttribute(parameter.Name, ((LoopComboxParam)parameter).Value.ToString());
  2712. else if (parameter is PositionParam)
  2713. nodeConfig.SetAttribute(parameter.Name, ((PositionParam)parameter).Value.ToString());
  2714. else if (parameter is BoolParam)
  2715. nodeConfig.SetAttribute(parameter.Name, ((BoolParam)parameter).Value.ToString());
  2716. else if (parameter is StepParam)
  2717. nodeConfig.SetAttribute(parameter.Name, ((StepParam)parameter).Value.ToString());
  2718. else if (parameter is MultipleSelectParam)
  2719. {
  2720. List<string> selected = new List<string>();
  2721. ((MultipleSelectParam)parameter).Options.Apply(
  2722. opt =>
  2723. {
  2724. if (opt.IsChecked)
  2725. selected.Add(opt.ControlName);
  2726. }
  2727. );
  2728. nodeConfig.SetAttribute(parameter.Name, string.Join(",", selected));
  2729. }
  2730. }
  2731. }
  2732. nodeModule.AppendChild(nodeConfig);
  2733. }
  2734. else
  2735. {
  2736. var CurrentTableSteps = Tables.FirstOrDefault(x => x.Index == TableIndex).TableData.Steps;
  2737. CurrentTableSteps.Clear();
  2738. Steps.ToList().ForEach(x => CurrentTableSteps.Add(x));
  2739. CreateTablesXml(nodeData);
  2740. foreach (var item in Tables)
  2741. {
  2742. List<XmlElement> StepsXmlElement = new List<XmlElement>();
  2743. foreach (Step parameters in item.TableData.Steps)
  2744. {
  2745. StepsXmlElement.Add(StepToXmlElement(parameters));
  2746. }
  2747. SaveTables(nodeData, StepsXmlElement, item.Index);
  2748. }
  2749. }
  2750. return _doc.OuterXml;
  2751. }
  2752. public static string GetPressPidValue(Step parameters)
  2753. {
  2754. string cmd = parameters.PressCommand.Value;
  2755. if (cmd == "Slow Vac" || cmd == "Valve Angle" || cmd == "Full Open" || cmd == "Full Close" || cmd == "Hold" ||
  2756. cmd == "WaitPressUp1" || cmd == "WaitPressDown1" || cmd == "WaitPressUp2" || cmd == "WaitPressDown2" || cmd == "Zero Set" || cmd == "Cancel Zero")
  2757. {
  2758. return "";
  2759. }
  2760. return parameters.PressPID.Value.Replace(",", ":");
  2761. }
  2762. public static string GetPressSetValue(Step parameters)
  2763. {
  2764. string rtn = "0";
  2765. string cmd = parameters.PressCommand.Value;
  2766. if (cmd == "Press" || cmd == "Press2")
  2767. {
  2768. rtn = parameters.PressSet.Value;
  2769. }
  2770. return rtn;
  2771. }
  2772. public static string GetPressSlowVacSet(Step parameters)
  2773. {
  2774. string rtn = "0";
  2775. string cmd = parameters.PressCommand.Value;
  2776. if (cmd == "Slow Vac")
  2777. {
  2778. rtn = parameters.PressSlowVacSet.Value;
  2779. }
  2780. return rtn;
  2781. }
  2782. public static string GetValveAngleSet(Step parameters)
  2783. {
  2784. string rtn = "0";
  2785. string cmd = parameters.PressCommand.Value;
  2786. if (cmd == "Valve Angle")
  2787. {
  2788. rtn = parameters.PressValveAngleSet.Value;
  2789. }
  2790. return rtn;
  2791. }
  2792. public static string GetWaitPress(Step parameters)
  2793. {
  2794. string rtn = "0";
  2795. string cmd = parameters.PressCommand.Value;
  2796. if (cmd == "WaitPressUp1" || cmd == "WaitPressDown1" || cmd == "WaitPressUp2" || cmd == "WaitPressDown2")
  2797. {
  2798. rtn = parameters.WaitPress.Value;
  2799. }
  2800. return rtn;
  2801. }
  2802. private XmlElement StepToXmlElement(Step parameters)
  2803. {
  2804. XmlElement nodeStep = _doc.CreateElement("Step");
  2805. if (ToleranceEnable)
  2806. {
  2807. //nodeStep.AppendChild(nodeWarning);
  2808. //nodeStep.AppendChild(nodeAlarm);
  2809. }
  2810. nodeStep.SetAttribute("StepNo", parameters.StepNo.ToString());
  2811. nodeStep.SetAttribute("Name", parameters.Name);
  2812. nodeStep.SetAttribute("EndBy", parameters.EndBy);
  2813. nodeStep.SetAttribute("Time", parameters.Time);
  2814. nodeStep.SetAttribute("SkipWait", parameters.SkipWait);
  2815. nodeStep.SetAttribute("Command", parameters.Command);
  2816. nodeStep.SetAttribute("AlarmIsSaved", parameters.AlarmIsSaved.ToString());
  2817. nodeStep.SetAttribute("MFCIsSaved", parameters.MFCIsSaved.ToString());
  2818. nodeStep.SetAttribute("ValveIsSaved", parameters.ValveIsSaved.ToString());
  2819. nodeStep.SetAttribute("PressIsSaved", parameters.PressIsSaved.ToString());
  2820. nodeStep.SetAttribute("AUXIsSaved", parameters.AUXIsSaved.ToString());
  2821. nodeStep.SetAttribute("TemperatureIsSaved", parameters.TemperatureIsSaved.ToString());
  2822. if (parameters.IsnoneConditionCheck)
  2823. {
  2824. nodeStep.SetAttribute("ConditionCheck", "none");
  2825. }
  2826. else
  2827. {
  2828. nodeStep.SetAttribute("ConditionCheck", GetConditionCheckXmlString(parameters));
  2829. }
  2830. nodeStep.SetAttribute("AlarmConditionTable", parameters.AlarmConditionTable.Value);
  2831. nodeStep.SetAttribute("AbortRecipeTableIndex", parameters.AbortRecipeTableIndex);
  2832. foreach (var item in parameters.ValveSets)
  2833. {
  2834. nodeStep.SetAttribute(item.Name, item.Value ? "Open" : "Close");
  2835. }
  2836. foreach (var item in parameters.MFCSets)
  2837. {
  2838. nodeStep.SetAttribute($"{item.ControlName}.Flow.IsSaved", item.IsSaved.ToString());
  2839. nodeStep.SetAttribute($"{item.ControlName}.Flow.Set", item.SetValue.Value);
  2840. nodeStep.SetAttribute($"{item.ControlName}.Flow.SetUnit", item.SetUnit.Value);
  2841. nodeStep.SetAttribute($"{item.ControlName}.Flow.Ramprate", item.Rampng.Value);
  2842. nodeStep.SetAttribute($"{item.ControlName}.Flow.RamprateUnit", item.RampngUnit.Value);
  2843. nodeStep.SetAttribute($"{item.ControlName}.Flow.Check", item.IsCheck.Value.ToString());
  2844. nodeStep.SetAttribute($"{item.ControlName}.Flow.High", item.MaxValue.Value.ToString());
  2845. nodeStep.SetAttribute($"{item.ControlName}.Flow.Low", item.MinValue.Value.ToString());
  2846. nodeStep.SetAttribute($"{item.ControlName}.Flow.Unit", item.Unit);
  2847. }
  2848. foreach (var item in parameters.MFMSets)
  2849. {
  2850. nodeStep.SetAttribute(item.Key, parameters.MFMSets[item.Key].ToString());
  2851. }
  2852. foreach (var item in parameters.EXOUSets.Keys)
  2853. {
  2854. nodeStep.SetAttribute(item, parameters.EXOUSets[item].ToString());
  2855. }
  2856. foreach (var item in parameters.TemperatureSets)
  2857. {
  2858. nodeStep.SetAttribute($"{item.Name}.ZoneName", item.Name);
  2859. nodeStep.SetAttribute($"{item.Name}.Set", item.SetValue.Value);
  2860. nodeStep.SetAttribute($"{item.Name}.SetUnit", item.SetUnit.Value);
  2861. nodeStep.SetAttribute($"{item.Name}.Ramprate", item.RampngValue.Value);
  2862. nodeStep.SetAttribute($"{item.Name}.RamprateUnit", item.RampngUnit.Value);
  2863. nodeStep.SetAttribute($"{item.Name}.Check", item.IsCheck.Value.ToString());
  2864. nodeStep.SetAttribute($"{item.Name}.High", item.HighValue.Value.ToString());
  2865. nodeStep.SetAttribute($"{item.Name}.Low", item.LowValue.Value.ToString());
  2866. nodeStep.SetAttribute($"{item.Name}.Unit", item.Unit.ToString());
  2867. }
  2868. nodeStep.SetAttribute("Temperature.ControlMode", parameters.TemperatureControlMode.Value);
  2869. nodeStep.SetAttribute("Temperature.Correct", parameters.TemperatureCorrect.Value);
  2870. nodeStep.SetAttribute("Temperature.PID", parameters.TemperaturePID.Value);
  2871. nodeStep.SetAttribute("Loader.Command", parameters.LoaderCommand.Value);
  2872. nodeStep.SetAttribute("Loader.Speed1", parameters.LoaderSpeed1.Value);
  2873. nodeStep.SetAttribute("Loader.Speed2", parameters.LoaderSpeed2.Value);
  2874. nodeStep.SetAttribute("Loader.Speed3", parameters.LoaderSpeed3.Value);
  2875. nodeStep.SetAttribute("Loader.RPM", parameters.LoaderRPM.Value.ToString());
  2876. nodeStep.SetAttribute("Press.Command", parameters.PressCommand.Value);
  2877. nodeStep.SetAttribute("Press.PID", parameters.PressPID.Value);
  2878. nodeStep.SetAttribute("Press.Set", parameters.PressSet.Value);
  2879. nodeStep.SetAttribute("Press.SlowVacSet", parameters.PressSlowVacSet.Value);
  2880. nodeStep.SetAttribute("Press.ValveAngleSet", parameters.PressValveAngleSet.Value);
  2881. nodeStep.SetAttribute("Press.IsWait", parameters.PressIsWait.Value.ToString());
  2882. nodeStep.SetAttribute("Press.LowWait", parameters.PressLowWait.Value);
  2883. nodeStep.SetAttribute("Press.HighWait", parameters.PressHighWait.Value);
  2884. nodeStep.SetAttribute("Press.WaitUnit", parameters.PressWaitUnit.Value);
  2885. nodeStep.SetAttribute("Press.LowPressWait", parameters.PressLowPressWait.Value);
  2886. nodeStep.SetAttribute("Press.WaitPress", parameters.WaitPress.Value);
  2887. nodeStep.SetAttribute("FilmThickFormula", parameters.FilmThickFormula);
  2888. // nodeStep.SetAttribute("FilmThickFormula", parameters.FilmThickFormula);
  2889. foreach (var item in parameters.AUXSets)
  2890. {
  2891. nodeStep.SetAttribute($"AUX.{item.ControlName}.Set", item.SetValue.Value);
  2892. nodeStep.SetAttribute($"AUX.{item.ControlName}.Check", item.IsCheck.Value.ToString());
  2893. nodeStep.SetAttribute($"AUX.{item.ControlName}.High", item.MaxValue.Value);
  2894. nodeStep.SetAttribute($"AUX.{item.ControlName}.Low", item.MinValue.Value);
  2895. nodeStep.SetAttribute($"AUX.{item.ControlName}.CheckUnit", item.SetUnit.Value);
  2896. }
  2897. return nodeStep;
  2898. }
  2899. public RecipeHistory GetRecipeHistory()
  2900. {
  2901. RecipeHistory recipeHistory = new RecipeHistory();
  2902. recipeHistory.CreatedBy = this.Creator;
  2903. recipeHistory.CreationTime = this.CreateTime;
  2904. recipeHistory.LastRevisedBy = this.Revisor;
  2905. recipeHistory.LastRevisionTime = this.ReviseTime;
  2906. recipeHistory.Recipe_Description = this.Description;
  2907. recipeHistory.Recipe_Type = this.PrefixPath;
  2908. recipeHistory.Recipe_Name = this.Name;
  2909. recipeHistory.Recipe_Path = $"{this.PrefixPath}\\{this.Name}";
  2910. recipeHistory.Recipe_Version = this.RecipeVersion;
  2911. recipeHistory.Recipe_Level = this.RecipeLevel;
  2912. recipeHistory.Recipe_Premission = this.RecipePermission;
  2913. recipeHistory.Recipe_Compare = "";
  2914. recipeHistory.Recipe_Content = GetXmlString();
  2915. return recipeHistory;
  2916. }
  2917. private void LoadConfigs(ObservableCollection<Param> configDefine, XmlNode configNode)
  2918. {
  2919. ConfigItems.Clear();
  2920. foreach (var param in configDefine)
  2921. {
  2922. if (param is DoubleParam param1)
  2923. {
  2924. var config = new DoubleParam()
  2925. {
  2926. Name = param.Name,
  2927. Value = param1.Value,
  2928. DisplayName = param.DisplayName,
  2929. Minimun = param1.Minimun,
  2930. Maximun = param1.Maximun,
  2931. Resolution = param1.Resolution
  2932. };
  2933. if (configNode != null && configNode.Attributes[param1.Name] != null)
  2934. config.Value = configNode.Attributes[param1.Name].Value;
  2935. ConfigItems.Add(config);
  2936. }
  2937. if (param is NumParam paramInt)
  2938. {
  2939. var config = new NumParam()
  2940. {
  2941. Name = paramInt.Name,
  2942. Value = paramInt.Value,
  2943. DisplayName = paramInt.DisplayName,
  2944. };
  2945. if (configNode != null && configNode.Attributes[paramInt.Name] != null)
  2946. {
  2947. int.TryParse(configNode.Attributes[paramInt.Name].Value, out int intValue);
  2948. config.Value = intValue;
  2949. }
  2950. ConfigItems.Add(config);
  2951. }
  2952. if (param is StringParam paramString)
  2953. {
  2954. var config = new StringParam()
  2955. {
  2956. Name = param.Name,
  2957. Value = paramString.Value,
  2958. DisplayName = param.DisplayName,
  2959. };
  2960. if (configNode != null && configNode.Attributes[paramString.Name] != null)
  2961. config.Value = configNode.Attributes[paramString.Name].Value;
  2962. ConfigItems.Add(config);
  2963. }
  2964. }
  2965. }
  2966. public void InitData(string prefixPath, string recipeName, string recipeContent, ObservableCollection<Param> configDefine, string module)
  2967. {
  2968. IsCompatibleWithCurrentFormat = false;
  2969. _module = module;
  2970. Name = recipeName;
  2971. PrefixPath = prefixPath;
  2972. try
  2973. {
  2974. _doc = new XmlDocument();
  2975. _doc.LoadXml(recipeContent);
  2976. if (!LoadHeader(_doc.SelectSingleNode("Aitex/TableRecipeData")))
  2977. return;
  2978. XmlNodeList nodeSteps = _doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{module}']/Step");
  2979. if (nodeSteps == null)
  2980. nodeSteps = _doc.SelectNodes($"Aitex/TableRecipeData/Step");
  2981. LoadSteps(nodeSteps);
  2982. XmlNode nodeConfig =
  2983. _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{module}']/Config");
  2984. if (nodeSteps == null)
  2985. nodeConfig = _doc.SelectSingleNode($"Aitex/TableRecipeData/Config");
  2986. LoadConfigs(configDefine, nodeConfig);
  2987. IsCompatibleWithCurrentFormat = true;
  2988. }
  2989. catch (Exception ex)
  2990. {
  2991. LOG.Write(ex);
  2992. }
  2993. }
  2994. }
  2995. public class Step : PropertyChangedBase
  2996. {
  2997. public delegate void TempValueChangedEventHandler(object sender, SetValueEventArgs e);
  2998. public event TempValueChangedEventHandler TempValueChangedEvent;
  2999. public void OnTempValueChanged(SetValueEventArgs e)
  3000. {
  3001. if (TempValueChangedEvent != null)
  3002. {
  3003. TempValueChangedEvent(this, e);
  3004. }
  3005. }
  3006. public delegate void OhterTempValueChangedEventHandler(object sender, SetValueEventArgs e);
  3007. public event OhterTempValueChangedEventHandler OhterTempValueChangedEvent;
  3008. public void OnOhterTempValueChanged(SetValueEventArgs e)
  3009. {
  3010. if (OhterTempValueChangedEvent != null)
  3011. {
  3012. OhterTempValueChangedEvent(this, e);
  3013. }
  3014. }
  3015. public delegate void MFCValueChangedEventHandler(object sender, SetValueEventArgs e);
  3016. public event MFCValueChangedEventHandler MFCValueChangedEvent;
  3017. public void OnMFCValueChanged(SetValueEventArgs e)
  3018. {
  3019. if (MFCValueChangedEvent != null)
  3020. {
  3021. MFCValueChangedEvent(this, e);
  3022. }
  3023. }
  3024. public delegate void ValveValueChangedEventHandler(object sender, SetValueEventArgs e);
  3025. public event ValveValueChangedEventHandler ValveValueChangedEvent;
  3026. public void OnValveValueChanged(SetValueEventArgs e)
  3027. {
  3028. if (ValveValueChangedEvent != null)
  3029. {
  3030. ValveValueChangedEvent(this, e);
  3031. }
  3032. }
  3033. public delegate void AUXValueChangedEventHandler(object sender, SetValueEventArgs e);
  3034. public event AUXValueChangedEventHandler AUXValueChangedEvent;
  3035. public void OnAUXValueChanged(SetValueEventArgs e)
  3036. {
  3037. if (AUXValueChangedEvent != null)
  3038. {
  3039. AUXValueChangedEvent(this, e);
  3040. }
  3041. }
  3042. public Step()
  3043. {
  3044. SetDelegateEvent();
  3045. }
  3046. public void SetDelegateEvent()
  3047. {
  3048. MFCSetsCollectionChanged();
  3049. TemperatureSetsCollectionChanged();
  3050. ValveSetsCollectionChanged();
  3051. AUXSetsCollectionChanged();
  3052. }
  3053. private void MFCSetsCollectionChanged()
  3054. {
  3055. foreach (var item in MFCSets)
  3056. {
  3057. item.PropertyChanged += MFCIsSaved_PropertyChanged;
  3058. item.ValueChangedEvent += Item_MFCValueChangedEvent;
  3059. }
  3060. MFCSets.CollectionChanged += (s, e) =>
  3061. {
  3062. if (e.OldItems != null)
  3063. {
  3064. foreach (MFCData item in e.OldItems)
  3065. {
  3066. item.PropertyChanged -= MFCIsSaved_PropertyChanged;
  3067. item.ValueChangedEvent -= Item_MFCValueChangedEvent;
  3068. }
  3069. }
  3070. if (e.NewItems != null)
  3071. {
  3072. foreach (MFCData item in e.NewItems)
  3073. {
  3074. item.PropertyChanged += MFCIsSaved_PropertyChanged;
  3075. item.ValueChangedEvent += Item_MFCValueChangedEvent;
  3076. }
  3077. }
  3078. };
  3079. }
  3080. private void TemperatureSetsCollectionChanged()
  3081. {
  3082. foreach (var item in TemperatureSets)
  3083. {
  3084. item.PropertyChanged += TemperatureIsSaved_PropertyChanged;
  3085. item.ValueChangedEvent += Item_TempValueChangedEvent;
  3086. }
  3087. TemperatureSets.CollectionChanged += (s, e) =>
  3088. {
  3089. if (e.OldItems != null)
  3090. {
  3091. foreach (TempSetData item in e.OldItems)
  3092. {
  3093. item.PropertyChanged -= TemperatureIsSaved_PropertyChanged;
  3094. item.ValueChangedEvent -= Item_TempValueChangedEvent;
  3095. }
  3096. }
  3097. if (e.NewItems != null)
  3098. {
  3099. foreach (TempSetData item in e.NewItems)
  3100. {
  3101. item.PropertyChanged += TemperatureIsSaved_PropertyChanged;
  3102. item.ValueChangedEvent += Item_TempValueChangedEvent;
  3103. }
  3104. }
  3105. };
  3106. }
  3107. private void ValveSetsCollectionChanged()
  3108. {
  3109. foreach (var item in ValveSets)
  3110. {
  3111. item.PropertyChanged += ValveIsSaved_PropertyChanged;
  3112. item.ValueChangedEvent += Item_ValveValueChangedEvent;
  3113. }
  3114. ValveSets.CollectionChanged += (s, e) =>
  3115. {
  3116. if (e.OldItems != null)
  3117. {
  3118. foreach (BoolParam item in e.OldItems)
  3119. {
  3120. item.PropertyChanged -= ValveIsSaved_PropertyChanged;
  3121. item.ValueChangedEvent -= Item_ValveValueChangedEvent;
  3122. }
  3123. }
  3124. if (e.NewItems != null)
  3125. {
  3126. foreach (BoolParam item in e.NewItems)
  3127. {
  3128. item.PropertyChanged += ValveIsSaved_PropertyChanged;
  3129. item.ValueChangedEvent += Item_ValveValueChangedEvent;
  3130. }
  3131. }
  3132. };
  3133. }
  3134. private void AUXSetsCollectionChanged()
  3135. {
  3136. foreach (var item in AUXSets)
  3137. {
  3138. item.PropertyChanged += AUXIsSaved_PropertyChanged;
  3139. item.ValueChangedEvent += Item_AUXValueChangedEvent;
  3140. }
  3141. AUXSets.CollectionChanged += (s, e) =>
  3142. {
  3143. if (e.OldItems != null)
  3144. {
  3145. foreach (AUXData item in e.OldItems)
  3146. {
  3147. item.PropertyChanged -= AUXIsSaved_PropertyChanged;
  3148. item.ValueChangedEvent -= Item_AUXValueChangedEvent;
  3149. }
  3150. }
  3151. if (e.NewItems != null)
  3152. {
  3153. foreach (AUXData item in e.NewItems)
  3154. {
  3155. item.PropertyChanged += AUXIsSaved_PropertyChanged;
  3156. item.ValueChangedEvent += Item_AUXValueChangedEvent;
  3157. }
  3158. }
  3159. };
  3160. }
  3161. public void Item_TempValueChangedEvent(object sender, SetValueEventArgs e)
  3162. {
  3163. OnTempValueChanged(e);
  3164. }
  3165. public void Item_MFCValueChangedEvent(object sender, SetValueEventArgs e)
  3166. {
  3167. OnMFCValueChanged(e);
  3168. }
  3169. public void Item_ValveValueChangedEvent(object sender, SetValueEventArgs e)
  3170. {
  3171. OnValveValueChanged(e);
  3172. }
  3173. public void Item_AUXValueChangedEvent(object sender, SetValueEventArgs e)
  3174. {
  3175. OnAUXValueChanged(e);
  3176. }
  3177. public void MFCIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3178. {
  3179. if (e.PropertyName == "IsSaved")
  3180. {
  3181. if (MFCSets.Where(x => x.IsSaved == false).Any())
  3182. {
  3183. MFCIsSaved = false;
  3184. }
  3185. else
  3186. {
  3187. if (MFCSetFlagIsSaved)
  3188. {
  3189. MFCIsSaved = true;
  3190. }
  3191. else
  3192. {
  3193. MFCIsSaved = false;
  3194. }
  3195. }
  3196. }
  3197. }
  3198. public void TemperatureIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3199. {
  3200. if (e.PropertyName == "IsSaved")
  3201. {
  3202. SetTemperatureIsSaved();
  3203. }
  3204. }
  3205. public void ValveIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3206. {
  3207. if (e.PropertyName == "IsSaved")
  3208. {
  3209. if (ValveSets.Where(x => x.IsSaved == false).Any())
  3210. {
  3211. ValveIsSaved = false;
  3212. }
  3213. else
  3214. {
  3215. ValveIsSaved = true;
  3216. }
  3217. }
  3218. }
  3219. public void AUXIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3220. {
  3221. if (e.PropertyName == "IsSaved")
  3222. {
  3223. if (AUXSets.Where(x => x.IsSaved == false).Any())
  3224. {
  3225. AUXIsSaved = false;
  3226. }
  3227. else
  3228. {
  3229. AUXIsSaved = true;
  3230. }
  3231. }
  3232. }
  3233. private void LoaderIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3234. {
  3235. if (e.PropertyName == "IsSaved")
  3236. {
  3237. if (!LoaderCommand.IsSaved || !LoaderSpeed1.IsSaved
  3238. || !LoaderSpeed2.IsSaved || !LoaderSpeed3.IsSaved
  3239. || !LoaderRPM.IsSaved)
  3240. {
  3241. LoaderIsSaved = false;
  3242. }
  3243. else
  3244. {
  3245. LoaderIsSaved = true;
  3246. }
  3247. }
  3248. }
  3249. private void AlarmIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3250. {
  3251. if (e.PropertyName == "IsSaved")
  3252. {
  3253. if (!AlarmConditionTable.IsSaved)
  3254. {
  3255. AlarmIsSaved = false;
  3256. }
  3257. else
  3258. {
  3259. AlarmIsSaved = true;
  3260. }
  3261. }
  3262. else if (e.PropertyName == "Value")
  3263. {
  3264. if (((Param)sender).IsSaved) return;
  3265. SetValueEventArgs setEventArgs = new SetValueEventArgs();
  3266. setEventArgs.Sender = this;
  3267. setEventArgs.ValueName = "Alarm";
  3268. setEventArgs.PropertyName = ((Param)sender).Name;
  3269. if (sender is StringParam)
  3270. {
  3271. setEventArgs.PropertyValue = ((StringParam)sender).Value;
  3272. OnAlarmValueChanged(setEventArgs);
  3273. }
  3274. }
  3275. }
  3276. public delegate void AlarmValueChangedEventHandler(object sender, SetValueEventArgs e);
  3277. public event AlarmValueChangedEventHandler AlarmValueChangedEvent;
  3278. public void OnAlarmValueChanged(SetValueEventArgs e)
  3279. {
  3280. if (AlarmValueChangedEvent != null)
  3281. {
  3282. AlarmValueChangedEvent(this, e);
  3283. }
  3284. }
  3285. private void PressureIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3286. {
  3287. if (e.PropertyName == "IsSaved")
  3288. {
  3289. if (!PressCommand.IsSaved || !PressPID.IsSaved
  3290. || !PressSet.IsSaved || !PressValveAngleSet.IsSaved
  3291. || !PressSlowVacSet.IsSaved || !PressIsWait.IsSaved
  3292. || !PressLowWait.IsSaved || !PressHighWait.IsSaved
  3293. || !PressWaitUnit.IsSaved || !PressLowPressWait.IsSaved
  3294. || !WaitPress.IsSaved)
  3295. {
  3296. PressIsSaved = false;
  3297. }
  3298. else
  3299. {
  3300. PressIsSaved = true;
  3301. }
  3302. }
  3303. else if (e.PropertyName == "Value")
  3304. {
  3305. if (sender is Param)
  3306. {
  3307. if (((Param)sender).IsSaved) return;
  3308. SetValueEventArgs setEventArgs = new SetValueEventArgs();
  3309. setEventArgs.Sender = this;
  3310. setEventArgs.ValueName = "Press";
  3311. setEventArgs.PropertyName = ((Param)sender).Name;
  3312. if (sender is DoubleParam)
  3313. {
  3314. setEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  3315. OnPressureValueChanged(setEventArgs);
  3316. }
  3317. else if (sender is StringParam)
  3318. {
  3319. setEventArgs.PropertyValue = ((StringParam)sender).Value;
  3320. OnPressureValueChanged(setEventArgs);
  3321. }
  3322. }
  3323. }
  3324. }
  3325. public delegate void PressureValueChangedEventHandler(object sender, SetValueEventArgs e);
  3326. public event PressureValueChangedEventHandler PressureValueChangedEvent;
  3327. public void OnPressureValueChanged(SetValueEventArgs e)
  3328. {
  3329. if (PressureValueChangedEvent != null)
  3330. {
  3331. PressureValueChangedEvent(this, e);
  3332. }
  3333. }
  3334. public delegate void LoaderValueChangedEventHandler(object sender, SetValueEventArgs e);
  3335. public event LoaderValueChangedEventHandler LoaderValueChangedEvent;
  3336. public void OnLoaderValueChanged(SetValueEventArgs e)
  3337. {
  3338. if (LoaderValueChangedEvent != null)
  3339. {
  3340. LoaderValueChangedEvent(this, e);
  3341. }
  3342. }
  3343. private void SetTemperatureIsSaved()
  3344. {
  3345. if (TemperatureSets.Where(x => x.IsSaved == false).Any() || !TemperatureControlMode.IsSaved || !TemperatureCorrect.IsSaved || !TemperaturePID.IsSaved)
  3346. {
  3347. TemperatureIsSaved = false;
  3348. }
  3349. else
  3350. {
  3351. if (TemperatureSetsFlagIsSaved)
  3352. {
  3353. TemperatureIsSaved = true;
  3354. }
  3355. else
  3356. {
  3357. TemperatureIsSaved = false;
  3358. }
  3359. }
  3360. }
  3361. public bool UndoMFCChanges()
  3362. {
  3363. if (MFCIsSaved)
  3364. {
  3365. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3366. DialogType.CONFIRM,
  3367. $"Recipe MFC is changed Flag, do you want to save it?"))
  3368. {
  3369. MFCIsSaved = false;
  3370. MFCSetFlagIsSaved = false;
  3371. }
  3372. }
  3373. else
  3374. {
  3375. MFCSetFlagIsSaved = true;
  3376. foreach (var item in MFCSets)
  3377. {
  3378. item.UndoChanges();
  3379. }
  3380. }
  3381. return true;
  3382. }
  3383. public bool UndoGasChanges()
  3384. {
  3385. if (ValveIsSaved)
  3386. {
  3387. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3388. DialogType.CONFIRM,
  3389. $"Recipe Valve is changed Flag, do you want to save it?"))
  3390. {
  3391. ValveIsSaved = false;
  3392. ValveFlagIsSaved = false;
  3393. }
  3394. }
  3395. else
  3396. {
  3397. ValveFlagIsSaved = true;
  3398. foreach (var item in ValveSets)
  3399. {
  3400. item.UndoChanges();
  3401. }
  3402. }
  3403. return true;
  3404. }
  3405. public bool UndoAUXChanges()
  3406. {
  3407. if (AUXIsSaved)
  3408. {
  3409. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3410. DialogType.CONFIRM,
  3411. $"Recipe AUX is changed Flag, do you want to save it?"))
  3412. {
  3413. AUXIsSaved = false;
  3414. AUXFlagIsSaved = false;
  3415. }
  3416. }
  3417. else
  3418. {
  3419. AUXFlagIsSaved = true;
  3420. foreach (var item in AUXSets)
  3421. {
  3422. item.UndoChanges();
  3423. }
  3424. }
  3425. return true;
  3426. }
  3427. public bool UndoTemperatureChanges()
  3428. {
  3429. if (TemperatureIsSaved)
  3430. {
  3431. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3432. DialogType.CONFIRM,
  3433. $"Recipe Temperature is changed Flag, do you want to save it?"))
  3434. {
  3435. TemperatureIsSaved = false;
  3436. TemperatureSetsFlagIsSaved = false;
  3437. }
  3438. }
  3439. else
  3440. {
  3441. TemperatureSetsFlagIsSaved = true;
  3442. foreach (var item in TemperatureSets)
  3443. {
  3444. item.UndoChanges();
  3445. }
  3446. TemperatureControlMode.UndoChanges();
  3447. TemperatureCorrect.UndoChanges();
  3448. TemperaturePID.UndoChanges();
  3449. }
  3450. return true;
  3451. }
  3452. public bool UndoAlarmChanges()
  3453. {
  3454. if (AlarmIsSaved)
  3455. {
  3456. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3457. DialogType.CONFIRM,
  3458. $"Recipe Alarm is changed Flag, do you want to save it?"))
  3459. {
  3460. AlarmIsSaved = false;
  3461. AlarmFlagIsSaved = false;
  3462. }
  3463. }
  3464. else
  3465. {
  3466. AlarmFlagIsSaved = true;
  3467. AlarmIsSaved = true;
  3468. AlarmConditionTable.UndoChanges();
  3469. }
  3470. return true;
  3471. }
  3472. public bool UndoPressChanges()
  3473. {
  3474. if (PressIsSaved)
  3475. {
  3476. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3477. DialogType.CONFIRM,
  3478. $"Recipe Press is changed Flag, do you want to save it?"))
  3479. {
  3480. PressIsSaved = false;
  3481. PressFlagIsSaved = false;
  3482. }
  3483. }
  3484. else
  3485. {
  3486. PressFlagIsSaved = true;
  3487. PressCommand.UndoChanges();
  3488. PressPID.UndoChanges();
  3489. PressSet.UndoChanges();
  3490. PressSlowVacSet.UndoChanges();
  3491. PressValveAngleSet.UndoChanges();
  3492. PressLowPressWait.UndoChanges();
  3493. WaitPress.UndoChanges();
  3494. }
  3495. return true;
  3496. }
  3497. public bool UndoLoaderChanges()
  3498. {
  3499. if (LoaderIsSaved)
  3500. {
  3501. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3502. DialogType.CONFIRM,
  3503. $"Recipe Loader is changed Flag, do you want to save it?"))
  3504. {
  3505. LoaderIsSaved = false;
  3506. }
  3507. }
  3508. else
  3509. {
  3510. LoaderIsSaved = true;
  3511. LoaderCommand.UndoChanges();
  3512. LoaderSpeed1.UndoChanges();
  3513. LoaderSpeed2.UndoChanges();
  3514. LoaderSpeed3.UndoChanges();
  3515. LoaderRPM.UndoChanges();
  3516. }
  3517. return true;
  3518. }
  3519. public string Value { get; set; }
  3520. private int _stepNo;
  3521. public int StepNo
  3522. {
  3523. get => _stepNo; set
  3524. {
  3525. _stepNo = value;
  3526. NotifyOfPropertyChange("StepNo");
  3527. }
  3528. }
  3529. private string _name;
  3530. public string Name
  3531. {
  3532. get => _name; set
  3533. {
  3534. _name = value;
  3535. NotifyOfPropertyChange("Name");
  3536. }
  3537. }
  3538. public string EndBy { get; set; }
  3539. public string Time { get; set; }
  3540. public string SkipWait { get; set; }
  3541. public string Command { get; set; }
  3542. public bool IsChecked { get; set; }
  3543. public Visibility IsVisibility { get; set; } = Visibility.Visible;
  3544. public bool IsnoneConditionCheck { get; set; }
  3545. public string[] ExternalSensorName { get; set; } = new string[] { "SensorTubeATMPressure", "SensorASOpenPosition", "SensorASClosePosition", "SensorEXTIN4", "SensorEXTIN5", "SensorEXTIN6", "SensorEXTIN7" };
  3546. public string[] ExternalSensor { get; set; } = new string[] { "None", "None", "None", "None", "None", "None", "None" };
  3547. public string TempStabilizeSelected { get; set; }
  3548. public string FinishAutoProfile { get; set; }
  3549. public string ReachTemp { get; set; }
  3550. public double ReachTempValue { get; set; }
  3551. public string O2Density { get; set; }
  3552. public int O2DensityValue { get; set; }
  3553. public string ReachPressure { get; set; }
  3554. public string ReachPressureVG { get; set; }
  3555. public string PressureStabilizeVG { get; set; }
  3556. public double ReachPressureValue { get; set; }
  3557. public string PressureStabilizeSelected { get; set; }
  3558. public string ProcessTimeToEnd { get; set; }
  3559. //public string PressureSonserValue { get; set; }
  3560. //public string PressureValveAngle { get; set; }
  3561. //public string PressureSettingVG { get; set; }
  3562. //public string SlowVacuumValue { get; set; }
  3563. //public string PressureAlarmTableNo { get; set; }
  3564. //public string ZAxisPosition { get; set; }
  3565. //public string ZAxisSpeed { get; set; }
  3566. //public string RotatePosition { get; set; }
  3567. public string AbortRecipeTableIndex { get; set; }
  3568. //public string RFSwitch { get; set; }
  3569. //public string RFSetpoint { get; set; }
  3570. //public string RFPowerSetpoint { get; set; }
  3571. //public string C1Setpoint { get; set; }
  3572. //public string C2Setpoint { get; set; }
  3573. //public string ForwardPowerAlarmWatchTable { get; set; }
  3574. //public string PrAlarmWatchTable { get; set; }
  3575. //public string PIAlarmWatchTable { get; set; }
  3576. //public string C1AlarmWatchTable { get; set; }
  3577. //public string C2AlarmWatchTable { get; set; }
  3578. //public string VppAlarmWatchTable { get; set; }
  3579. //public string VdcAlarmWatchTable { get; set; }
  3580. /// <summary>
  3581. /// R 轴方向,CCW(逆时针),CW(顺时针)
  3582. /// </summary>
  3583. // public string RotateDirection { get; set; }
  3584. //public string RotateSpeed { get; set; }
  3585. //public string RotateInterval { get; set; }
  3586. //public string APC_SetPressure { get; set; }
  3587. private bool _mFCSetFlagIsSaved = true;
  3588. public bool MFCSetFlagIsSaved
  3589. {
  3590. get => _mFCSetFlagIsSaved;
  3591. set
  3592. {
  3593. _mFCSetFlagIsSaved = value;
  3594. NotifyOfPropertyChange(nameof(MFCSetFlagIsSaved));
  3595. }
  3596. }
  3597. private bool _mFCIsSaved = true;
  3598. public bool MFCIsSaved
  3599. {
  3600. get => _mFCIsSaved;
  3601. set
  3602. {
  3603. _mFCIsSaved = value;
  3604. NotifyOfPropertyChange(nameof(MFCIsSaved));
  3605. }
  3606. }
  3607. private bool _temperatureSetsFlagIsSaved = true;
  3608. public bool TemperatureSetsFlagIsSaved
  3609. {
  3610. get => _temperatureSetsFlagIsSaved;
  3611. set
  3612. {
  3613. _temperatureSetsFlagIsSaved = value;
  3614. NotifyOfPropertyChange(nameof(TemperatureSetsFlagIsSaved));
  3615. }
  3616. }
  3617. private bool _temperatureIsSaved = true;
  3618. public bool TemperatureIsSaved
  3619. {
  3620. get => _temperatureIsSaved;
  3621. set
  3622. {
  3623. _temperatureIsSaved = value;
  3624. NotifyOfPropertyChange(nameof(TemperatureIsSaved));
  3625. }
  3626. }
  3627. private bool _valveFlagIsSaved = true;
  3628. public bool ValveFlagIsSaved
  3629. {
  3630. get => _valveFlagIsSaved;
  3631. set
  3632. {
  3633. _valveFlagIsSaved = value;
  3634. NotifyOfPropertyChange(nameof(ValveFlagIsSaved));
  3635. }
  3636. }
  3637. private bool _valveIsSaved = true;
  3638. public bool ValveIsSaved
  3639. {
  3640. get => _valveIsSaved;
  3641. set
  3642. {
  3643. _valveIsSaved = value;
  3644. NotifyOfPropertyChange(nameof(ValveIsSaved));
  3645. }
  3646. }
  3647. private bool _auxFlagIsSaved = true;
  3648. public bool AUXFlagIsSaved
  3649. {
  3650. get => _auxFlagIsSaved;
  3651. set
  3652. {
  3653. _auxFlagIsSaved = value;
  3654. NotifyOfPropertyChange(nameof(AUXFlagIsSaved));
  3655. }
  3656. }
  3657. private bool _auxIsSaved = true;
  3658. public bool AUXIsSaved
  3659. {
  3660. get => _auxIsSaved;
  3661. set
  3662. {
  3663. _auxIsSaved = value;
  3664. NotifyOfPropertyChange(nameof(AUXIsSaved));
  3665. }
  3666. }
  3667. private bool _loaderIsSaved = true;
  3668. public bool LoaderIsSaved
  3669. {
  3670. get => _loaderIsSaved;
  3671. set
  3672. {
  3673. _loaderIsSaved = value;
  3674. NotifyOfPropertyChange(nameof(LoaderIsSaved));
  3675. }
  3676. }
  3677. private bool _pressFlagIsSaved = true;
  3678. public bool PressFlagIsSaved
  3679. {
  3680. get => _pressFlagIsSaved;
  3681. set
  3682. {
  3683. _pressFlagIsSaved = value;
  3684. NotifyOfPropertyChange(nameof(PressFlagIsSaved));
  3685. }
  3686. }
  3687. private bool _pressIsSaved = true;
  3688. public bool PressIsSaved
  3689. {
  3690. get => _pressIsSaved;
  3691. set
  3692. {
  3693. _pressIsSaved = value;
  3694. NotifyOfPropertyChange(nameof(PressIsSaved));
  3695. }
  3696. }
  3697. private bool _alarmFlagIsSaved = true;
  3698. public bool AlarmFlagIsSaved
  3699. {
  3700. get => _alarmFlagIsSaved;
  3701. set
  3702. {
  3703. _alarmFlagIsSaved = value;
  3704. NotifyOfPropertyChange(nameof(AlarmFlagIsSaved));
  3705. }
  3706. }
  3707. private bool _alarmIsSaved = true;
  3708. public bool AlarmIsSaved
  3709. {
  3710. get => _alarmIsSaved;
  3711. set
  3712. {
  3713. _alarmIsSaved = value;
  3714. NotifyOfPropertyChange(nameof(AlarmIsSaved));
  3715. }
  3716. }
  3717. public string GasLineN2_Flow { get; set; }
  3718. public string GasLineN3_Flow { get; set; }
  3719. public MFMValue MfmD1Flow { get; set; }
  3720. public ObservableCollection<BoolParam> ValveSets { get; set; } = new ObservableCollection<BoolParam>();
  3721. //public Dictionary<string, MFCData> MFCSets { get; set; } = new Dictionary<string, MFCData>();
  3722. public ObservableCollection<MFCData> MFCSets { get; set; } = new ObservableCollection<MFCData>();
  3723. public Dictionary<string, MFMValue> MFMSets { get; set; } = new Dictionary<string, MFMValue>();
  3724. public Dictionary<string, bool> EXOUSets { get; set; } = new Dictionary<string, bool>();
  3725. public ObservableCollection<TempSetData> TemperatureSets { get; set; } = new ObservableCollection<TempSetData>();
  3726. public Dictionary<string, Dictionary<int, VPData>> VPSets { get; set; } = new Dictionary<string, Dictionary<int, VPData>>();
  3727. public ObservableCollection<AUXData> AUXSets { get; set; } = new ObservableCollection<AUXData>();
  3728. private void Temperature_PropertyChanged(object sender, PropertyChangedEventArgs e)
  3729. {
  3730. if (e.PropertyName == nameof(StringParam.IsSaved))
  3731. {
  3732. SetTemperatureIsSaved();
  3733. }
  3734. else if (e.PropertyName == "Value")
  3735. {
  3736. if (sender is Param)
  3737. {
  3738. if (((Param)sender).IsSaved) return;
  3739. SetValueEventArgs setValueEventArgs = new SetValueEventArgs();
  3740. setValueEventArgs.Sender = this;
  3741. setValueEventArgs.ValueName = ((Param)sender).Name;
  3742. setValueEventArgs.PropertyName = ((Param)sender).Name;
  3743. if (sender is DoubleParam)
  3744. {
  3745. setValueEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  3746. OnTempValueChanged(setValueEventArgs);
  3747. }
  3748. else if (sender is StringParam)
  3749. {
  3750. var tempObj = sender as StringParam;
  3751. if (tempObj.Name == "TemperatureControlMode" || tempObj.Name == "TemperatureCorrect" || tempObj.Name == "TemperaturePID")
  3752. setValueEventArgs.PropertyValue = ((StringParam)sender).Value;
  3753. if (((StringParam)sender).OldValue != ((StringParam)sender).Value)
  3754. {
  3755. OnTempValueChanged(setValueEventArgs);
  3756. }
  3757. }
  3758. }
  3759. }
  3760. }
  3761. private void OtherTemperature_PropertyChanged(object sender, PropertyChangedEventArgs e)
  3762. {
  3763. if (e.PropertyName == nameof(StringParam.IsSaved))
  3764. {
  3765. SetTemperatureIsSaved();
  3766. }
  3767. else if (e.PropertyName == "Value")
  3768. {
  3769. if (sender is Param)
  3770. {
  3771. if (((Param)sender).IsSaved) return;
  3772. SetValueEventArgs setValueEventArgs = new SetValueEventArgs();
  3773. setValueEventArgs.Sender = this;
  3774. setValueEventArgs.ValueName = ((Param)sender).Name;
  3775. setValueEventArgs.PropertyName = ((Param)sender).Name;
  3776. if (sender is DoubleParam)
  3777. {
  3778. setValueEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  3779. OnOhterTempValueChanged(setValueEventArgs);
  3780. }
  3781. else if (sender is StringParam)
  3782. {
  3783. var tempObj = sender as StringParam;
  3784. if (tempObj.Name == "TemperatureControlMode" || tempObj.Name == "TemperatureCorrect" || tempObj.Name == "TemperaturePID")
  3785. {
  3786. setValueEventArgs.PropertyValue = ((StringParam)sender).Value;
  3787. //if (((StringParam)sender).OldValue != ((StringParam)sender).Value)
  3788. //{
  3789. OnOhterTempValueChanged(setValueEventArgs);
  3790. //}
  3791. }
  3792. }
  3793. }
  3794. }
  3795. }
  3796. private StringParam _temperatureControlMode;
  3797. public StringParam TemperatureControlMode
  3798. {
  3799. get => _temperatureControlMode;
  3800. set
  3801. {
  3802. _temperatureControlMode = value;
  3803. _temperatureControlMode.PropertyChanged += OtherTemperature_PropertyChanged;
  3804. NotifyOfPropertyChange(nameof(TemperatureControlMode));
  3805. }
  3806. }
  3807. private StringParam _temperatureCorrect;
  3808. public StringParam TemperatureCorrect
  3809. {
  3810. get => _temperatureCorrect;
  3811. set
  3812. {
  3813. _temperatureCorrect = value;
  3814. _temperatureCorrect.PropertyChanged += OtherTemperature_PropertyChanged;
  3815. NotifyOfPropertyChange(nameof(TemperatureCorrect));
  3816. }
  3817. }
  3818. private StringParam _temperaturePID;
  3819. public StringParam TemperaturePID
  3820. {
  3821. get => _temperaturePID;
  3822. set
  3823. {
  3824. _temperaturePID = value;
  3825. _temperaturePID.PropertyChanged += OtherTemperature_PropertyChanged;
  3826. NotifyOfPropertyChange(nameof(TemperaturePID));
  3827. }
  3828. }
  3829. private StringParam _loaderCommand = new StringParam() { Name = "LoaderCommand", Value = "None" };
  3830. public StringParam LoaderCommand
  3831. {
  3832. get => _loaderCommand;
  3833. set
  3834. {
  3835. _loaderCommand = value;
  3836. _loaderCommand.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3837. NotifyOfPropertyChange(nameof(LoaderCommand));
  3838. }
  3839. }
  3840. private DoubleParam _loaderSpeed1 = new DoubleParam() { Name = "LoaderSpeed1", Value = "0" };
  3841. public DoubleParam LoaderSpeed1
  3842. {
  3843. get => _loaderSpeed1;
  3844. set
  3845. {
  3846. _loaderSpeed1 = value;
  3847. _loaderSpeed1.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3848. NotifyOfPropertyChange(nameof(LoaderSpeed1));
  3849. }
  3850. }
  3851. private DoubleParam _loaderSpeed2 = new DoubleParam() { Name = "LoaderSpeed2", Value = "0" };
  3852. public DoubleParam LoaderSpeed2
  3853. {
  3854. get => _loaderSpeed2;
  3855. set
  3856. {
  3857. _loaderSpeed2 = value;
  3858. _loaderSpeed2.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3859. NotifyOfPropertyChange(nameof(LoaderSpeed2));
  3860. }
  3861. }
  3862. private DoubleParam _loaderSpeed3 = new DoubleParam() { Name = "LoaderSpeed3", Value = "0" };
  3863. public DoubleParam LoaderSpeed3
  3864. {
  3865. get => _loaderSpeed3;
  3866. set
  3867. {
  3868. _loaderSpeed3 = value;
  3869. _loaderSpeed3.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3870. NotifyOfPropertyChange(nameof(LoaderSpeed3));
  3871. }
  3872. }
  3873. private DoubleParam _loaderRPM = new DoubleParam() { Name = "LoaderRPM", Value = "0" };
  3874. public DoubleParam LoaderRPM
  3875. {
  3876. get => _loaderRPM;
  3877. set
  3878. {
  3879. _loaderRPM = value;
  3880. _loaderRPM.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3881. NotifyOfPropertyChange(nameof(LoaderRPM));
  3882. }
  3883. }
  3884. public StringParam _pressCommand = new StringParam() { Name = "PressCommand", Value = "None" };
  3885. public StringParam PressCommand
  3886. {
  3887. get => _pressCommand;
  3888. set
  3889. {
  3890. _pressCommand = value;
  3891. _pressCommand.PropertyChanged += PressureIsSaved_PropertyChanged;
  3892. NotifyOfPropertyChange(nameof(PressCommand));
  3893. }
  3894. }
  3895. private StringParam _pressPID = new StringParam() { Name = "PressPID", Value = "" };
  3896. public StringParam PressPID
  3897. {
  3898. get => _pressPID;
  3899. set
  3900. {
  3901. _pressPID = value;
  3902. _pressPID.PropertyChanged += PressureIsSaved_PropertyChanged;
  3903. NotifyOfPropertyChange(nameof(_pressPID));
  3904. }
  3905. }
  3906. private DoubleParam _pressSet = new DoubleParam() { Name = "PressSet", Value = "0" };
  3907. public DoubleParam PressSet
  3908. {
  3909. get => _pressSet;
  3910. set
  3911. {
  3912. _pressSet = value;
  3913. _pressSet.PropertyChanged += PressureIsSaved_PropertyChanged;
  3914. NotifyOfPropertyChange(nameof(PressSet));
  3915. }
  3916. }
  3917. private StringParam _pressValveAngleSet = new StringParam() { Name = "PressValveAngleSet", Value = "0" };
  3918. public StringParam PressValveAngleSet
  3919. {
  3920. get => _pressValveAngleSet;
  3921. set
  3922. {
  3923. _pressValveAngleSet = value;
  3924. _pressValveAngleSet.PropertyChanged += PressureIsSaved_PropertyChanged;
  3925. NotifyOfPropertyChange(nameof(PressValveAngleSet));
  3926. }
  3927. }
  3928. private DoubleParam _pressSlowVacSet = new DoubleParam() { Name = "PressSlowVacSet", Value = "0" };
  3929. public DoubleParam PressSlowVacSet
  3930. {
  3931. get => _pressSlowVacSet;
  3932. set
  3933. {
  3934. _pressSlowVacSet = value;
  3935. _pressSlowVacSet.PropertyChanged += PressureIsSaved_PropertyChanged;
  3936. NotifyOfPropertyChange(nameof(PressSlowVacSet));
  3937. }
  3938. }
  3939. private BoolParam _pressIsWait = new BoolParam() { Name = "PressIsWait", Value = false };
  3940. public BoolParam PressIsWait
  3941. {
  3942. get => _pressIsWait;
  3943. set
  3944. {
  3945. _pressIsWait = value;
  3946. _pressIsWait.PropertyChanged += PressureIsSaved_PropertyChanged;
  3947. NotifyOfPropertyChange(nameof(PressIsWait));
  3948. }
  3949. }
  3950. private StringParam _pressLowWait = new StringParam() { Name = "PressLowWait", Value = "0" };
  3951. public StringParam PressLowWait
  3952. {
  3953. get => _pressLowWait;
  3954. set
  3955. {
  3956. _pressLowWait = value;
  3957. _pressLowWait.PropertyChanged += PressureIsSaved_PropertyChanged;
  3958. NotifyOfPropertyChange(nameof(PressLowWait));
  3959. }
  3960. }
  3961. public StringParam _pressHighWait = new StringParam() { Name = "PressHighWait", Value = "0" };
  3962. public StringParam PressHighWait
  3963. {
  3964. get => _pressHighWait;
  3965. set
  3966. {
  3967. _pressHighWait = value;
  3968. _pressHighWait.PropertyChanged += PressureIsSaved_PropertyChanged;
  3969. NotifyOfPropertyChange(nameof(PressHighWait));
  3970. }
  3971. }
  3972. private StringParam _pressWaitUnit = new StringParam() { Name = "PressWaitUnit", Value = "Torr" };
  3973. public StringParam PressWaitUnit
  3974. {
  3975. get => _pressWaitUnit;
  3976. set
  3977. {
  3978. _pressWaitUnit = value;
  3979. _pressWaitUnit.PropertyChanged += PressureIsSaved_PropertyChanged;
  3980. NotifyOfPropertyChange(nameof(PressWaitUnit));
  3981. }
  3982. }
  3983. private StringParam _pressLowPressWait = new StringParam() { Name = "PressLowPressWait", Value = "None" };
  3984. public StringParam PressLowPressWait
  3985. {
  3986. get => _pressLowPressWait;
  3987. set
  3988. {
  3989. _pressLowPressWait = value;
  3990. _pressLowPressWait.PropertyChanged += PressureIsSaved_PropertyChanged;
  3991. NotifyOfPropertyChange(nameof(PressLowPressWait));
  3992. }
  3993. }
  3994. private StringParam _waitPress = new StringParam() { Name = "WaitPress", Value = "0" };
  3995. public StringParam WaitPress
  3996. {
  3997. get => _waitPress;
  3998. set
  3999. {
  4000. _waitPress = value;
  4001. _waitPress.PropertyChanged += PressureIsSaved_PropertyChanged;
  4002. NotifyOfPropertyChange(nameof(WaitPress));
  4003. }
  4004. }
  4005. //public string TemperatureProfile { get; set; }
  4006. //public string TemperatureAlarm { get; set; }
  4007. //public string CAPTemperatureAlarm { get; set; }
  4008. //public string CAPSetValue { get; set; }
  4009. //public string CAPRampingValue { get; set; }
  4010. //public string TemperatureStabilize { get; set; }
  4011. //public bool TemperatureReadyCond { get; set; }
  4012. private StringParam _alarmConditionTable = new StringParam() { Name = "AlarmConditionTable", Value = "" };
  4013. public StringParam AlarmConditionTable
  4014. {
  4015. get => _alarmConditionTable;
  4016. set
  4017. {
  4018. _alarmConditionTable = value;
  4019. _alarmConditionTable.PropertyChanged += AlarmIsSaved_PropertyChanged;
  4020. NotifyOfPropertyChange(nameof(AlarmConditionTable));
  4021. }
  4022. }
  4023. //public string EventSetting { get; set; }
  4024. public string FilmThickFormula { get; set; }
  4025. public Dictionary<int, AlarmAction> AlarmActionSets { get; set; } = new Dictionary<int, AlarmAction>();
  4026. public string DictionaryStepTime(Dictionary<string, string> steptimes)
  4027. {
  4028. if (steptimes == null) return null;
  4029. StringBuilder rtn = new StringBuilder();
  4030. foreach (var item in steptimes.Keys)
  4031. {
  4032. if (steptimes[item] == "00:00:00") continue;
  4033. rtn.Append($"{item},{steptimes[item]};");
  4034. }
  4035. if (rtn.Length > 0) rtn.Remove(rtn.Length - 1, 1);
  4036. return rtn.ToString();
  4037. }
  4038. public Dictionary<string, string> StepTimeToDictionary(string stepTime)
  4039. {
  4040. Dictionary<string, string> steptimes = new Dictionary<string, string>();
  4041. string[] tempTimes = stepTime.Split(';');
  4042. foreach (var item in tempTimes)
  4043. {
  4044. string[] subTimes = item.Split(',');
  4045. steptimes.Add(subTimes[0], subTimes[1]);
  4046. }
  4047. return steptimes;
  4048. }
  4049. }
  4050. public class AlarmAction
  4051. {
  4052. public string PtocessingType { get; set; }
  4053. public string PtocessingDetails { get; set; }
  4054. }
  4055. public class MFMValue : PropertyChangedBase
  4056. {
  4057. private string _name;
  4058. public string Name
  4059. {
  4060. get => _name;
  4061. set
  4062. {
  4063. _name = value;
  4064. NotifyOfPropertyChange("Name");
  4065. }
  4066. }
  4067. private string _value;
  4068. public string Value
  4069. {
  4070. get => _value;
  4071. set
  4072. {
  4073. _value = value;
  4074. NotifyOfPropertyChange("Value");
  4075. }
  4076. }
  4077. private string _alarmValue;
  4078. public string AlarmValue
  4079. {
  4080. get => _alarmValue; set
  4081. {
  4082. _alarmValue = value;
  4083. NotifyOfPropertyChange("AlarmValue");
  4084. }
  4085. }
  4086. public override string ToString()
  4087. {
  4088. return $"{Value};{AlarmValue}";
  4089. }
  4090. }
  4091. public class MFMData : MFCData
  4092. { }
  4093. public class MFCData : PropertyChangedBase
  4094. {
  4095. public delegate void ValueChangedEventHandler(object sender, SetValueEventArgs e);
  4096. public event ValueChangedEventHandler ValueChangedEvent;
  4097. public MFCData()
  4098. {
  4099. }
  4100. public void OnValueChanged(SetValueEventArgs e)
  4101. {
  4102. if (ValueChangedEvent != null)
  4103. {
  4104. ValueChangedEvent(this, e);
  4105. }
  4106. }
  4107. private bool _flagIsSaved = true;
  4108. public bool FlagIsSaved
  4109. {
  4110. get => _flagIsSaved;
  4111. set
  4112. {
  4113. _flagIsSaved = value;
  4114. NotifyOfPropertyChange(nameof(FlagIsSaved));
  4115. NotifyOfPropertyChange(nameof(IsSaved));
  4116. }
  4117. }
  4118. public bool IsSaved
  4119. {
  4120. get
  4121. {
  4122. if (SetValue.IsSaved && SetUnit.IsSaved && Rampng.IsSaved && RampngUnit.IsSaved && IsCheck.IsSaved && MaxValue.IsSaved && MinValue.IsSaved)
  4123. {
  4124. if (FlagIsSaved)
  4125. {
  4126. return true;
  4127. }
  4128. else
  4129. {
  4130. return false;
  4131. }
  4132. }
  4133. else
  4134. {
  4135. return false;
  4136. }
  4137. }
  4138. }
  4139. public bool UndoChanges()
  4140. {
  4141. Type type = this.GetType();
  4142. PropertyInfo[] properties = type.GetProperties();
  4143. foreach (var item in properties)
  4144. {
  4145. var obj = item.GetValue(this);
  4146. if (obj is Param)
  4147. {
  4148. ((Param)obj).UndoChanges();
  4149. }
  4150. }
  4151. FlagIsSaved = true;
  4152. return true;
  4153. }
  4154. private void ParamIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  4155. {
  4156. if (e.PropertyName == "IsSaved")
  4157. {
  4158. NotifyOfPropertyChange("IsSaved");
  4159. }
  4160. else if (e.PropertyName == "Value")
  4161. {
  4162. if (sender is Param)
  4163. {
  4164. if (((Param)sender).IsSaved) return;
  4165. SetValueEventArgs tempSetEventArgs = new SetValueEventArgs();
  4166. tempSetEventArgs.Sender = this;
  4167. tempSetEventArgs.ValueName = this.ControlName;
  4168. tempSetEventArgs.PropertyName = ((Param)sender).Name;
  4169. if (sender is DoubleParam)
  4170. {
  4171. tempSetEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  4172. OnValueChanged(tempSetEventArgs);
  4173. }
  4174. else if (sender is IntParam)
  4175. {
  4176. tempSetEventArgs.PropertyValue = ((IntParam)sender).Value.ToString();
  4177. OnValueChanged(tempSetEventArgs);
  4178. }
  4179. else if (sender is StringParam)
  4180. {
  4181. tempSetEventArgs.PropertyValue = ((StringParam)sender).Value;
  4182. OnValueChanged(tempSetEventArgs);
  4183. }
  4184. else if (sender is BoolParam)
  4185. {
  4186. tempSetEventArgs.PropertyValue = ((BoolParam)sender).Value.ToString();
  4187. OnValueChanged(tempSetEventArgs);
  4188. }
  4189. }
  4190. }
  4191. }
  4192. private int _no;
  4193. public int No
  4194. {
  4195. get => _no;
  4196. set
  4197. {
  4198. _no = value;
  4199. NotifyOfPropertyChange("No");
  4200. }
  4201. }
  4202. private string _name;
  4203. public string Name
  4204. {
  4205. get => _name;
  4206. set
  4207. {
  4208. _name = value;
  4209. NotifyOfPropertyChange("Name");
  4210. }
  4211. }
  4212. public string _unit;
  4213. public string Unit
  4214. {
  4215. get => _unit;
  4216. set
  4217. {
  4218. _unit = value;
  4219. NotifyOfPropertyChange("Unit");
  4220. }
  4221. }
  4222. private string _scaleValue;
  4223. public string ScaleValue
  4224. {
  4225. get => _scaleValue;
  4226. set
  4227. {
  4228. _scaleValue = value;
  4229. NotifyOfPropertyChange("ScaleValue");
  4230. }
  4231. }
  4232. private string _displayName;
  4233. public string DisplayName
  4234. {
  4235. get => _displayName;
  4236. set
  4237. {
  4238. _displayName = value;
  4239. NotifyOfPropertyChange("DisplayName");
  4240. }
  4241. }
  4242. private string _controlName;
  4243. public string ControlName
  4244. {
  4245. get => _controlName;
  4246. set
  4247. {
  4248. _controlName = value;
  4249. NotifyOfPropertyChange("ControlName");
  4250. }
  4251. }
  4252. private StringParam _setValue;
  4253. public StringParam SetValue
  4254. {
  4255. get => _setValue;
  4256. set
  4257. {
  4258. if (_setValue != null)
  4259. {
  4260. _setValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4261. }
  4262. _setValue = value;
  4263. _setValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4264. NotifyOfPropertyChange(nameof(SetValue));
  4265. }
  4266. }
  4267. private StringParam _setUnit = new StringParam() { Name = "SetUnit", Value = "SLM" };
  4268. public StringParam SetUnit
  4269. {
  4270. get => _setUnit;
  4271. set
  4272. {
  4273. if (_setUnit != null)
  4274. {
  4275. _setUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4276. }
  4277. _setUnit = value;
  4278. _setUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4279. NotifyOfPropertyChange(nameof(SetUnit));
  4280. }
  4281. }
  4282. private StringParam _rampngUnit = new StringParam() { Name = "RampngUnit", Value = "SLM" };
  4283. public StringParam RampngUnit
  4284. {
  4285. get => _rampngUnit;
  4286. set
  4287. {
  4288. if (_rampngUnit != null)
  4289. {
  4290. _rampngUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4291. }
  4292. _rampngUnit = value;
  4293. _rampngUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4294. NotifyOfPropertyChange("RampngUnit");
  4295. }
  4296. }
  4297. private DoubleParam _rampng;
  4298. public DoubleParam Rampng
  4299. {
  4300. get => _rampng;
  4301. set
  4302. {
  4303. if (_rampng != null)
  4304. {
  4305. _rampng.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4306. }
  4307. _rampng = value;
  4308. NotifyOfPropertyChange("Rampng");
  4309. _rampng.PropertyChanged += ParamIsSaved_PropertyChanged;
  4310. }
  4311. }
  4312. private string _alarmValue;
  4313. public string AlarmValue
  4314. {
  4315. get => _alarmValue; set
  4316. {
  4317. _alarmValue = value;
  4318. NotifyOfPropertyChange("AlarmValue");
  4319. }
  4320. }
  4321. private DoubleParam _maxValue = new DoubleParam() { Name = "MaxValue", Value = "0" };
  4322. public DoubleParam MaxValue
  4323. {
  4324. get => _maxValue; set
  4325. {
  4326. if (_maxValue != null)
  4327. {
  4328. _maxValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4329. }
  4330. _maxValue = value;
  4331. _maxValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4332. NotifyOfPropertyChange("MaxValue");
  4333. }
  4334. }
  4335. private DoubleParam _minValue = new DoubleParam() { Name = "MinValue", Value = "0" };
  4336. public DoubleParam MinValue
  4337. {
  4338. get => _minValue; set
  4339. {
  4340. if (_minValue != null)
  4341. {
  4342. _minValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4343. }
  4344. _minValue = value;
  4345. _minValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4346. NotifyOfPropertyChange("MinValue");
  4347. }
  4348. }
  4349. private BoolParam _isCheck = new BoolParam() { Name = "IsCheck", Value = true };
  4350. public BoolParam IsCheck
  4351. {
  4352. get => _isCheck;
  4353. set
  4354. {
  4355. if (_isCheck != null)
  4356. {
  4357. _isCheck.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4358. }
  4359. _isCheck = value;
  4360. _isCheck.PropertyChanged += ParamIsSaved_PropertyChanged;
  4361. NotifyOfPropertyChange("IsCheck");
  4362. }
  4363. }
  4364. private bool _isEnable = true;
  4365. public bool IsEnable
  4366. {
  4367. get => _isEnable;
  4368. set
  4369. {
  4370. _isEnable = value;
  4371. NotifyOfPropertyChange("IsEnable");
  4372. }
  4373. }
  4374. }
  4375. public class TempSetData : PropertyChangedBase
  4376. {
  4377. public delegate void ValueChangedEventHandler(object sender, SetValueEventArgs e);
  4378. public event ValueChangedEventHandler ValueChangedEvent;
  4379. public void OnValueChanged(SetValueEventArgs e)
  4380. {
  4381. if (ValueChangedEvent != null)
  4382. {
  4383. ValueChangedEvent(this, e);
  4384. }
  4385. }
  4386. public TempSetData() { }
  4387. public bool UndoChanges()
  4388. {
  4389. Type type = this.GetType();
  4390. PropertyInfo[] properties = type.GetProperties();
  4391. foreach (var item in properties)
  4392. {
  4393. var obj = item.GetValue(this);
  4394. if (obj is Param)
  4395. {
  4396. ((Param)obj).UndoChanges();
  4397. }
  4398. }
  4399. return true;
  4400. }
  4401. public bool IsSaved
  4402. {
  4403. get => SetValue.IsSaved && SetUnit.IsSaved && RampngValue.IsSaved && RampngUnit.IsSaved && IsCheck.IsSaved && HighValue.IsSaved && LowValue.IsSaved;
  4404. }
  4405. public TempSetData(string name)
  4406. {
  4407. No = 1;
  4408. Name = name;
  4409. SetValue = new StringParam() { Name = "SetValue", Value = "0" };
  4410. SetUnit = new StringParam() { Name = "SetUnit", Value = "℃" };
  4411. RampngValue = new DoubleParam() { Name = "RampngValue", Value = "0" };
  4412. RampngUnit = new StringParam() { Name = "RampngUnit", Value = "℃/min" };
  4413. IsCheck = new BoolParam() { Name = "IsCheck", Value = false };
  4414. HighValue = new DoubleParam() { Name = "HighValue", Value = "0" };
  4415. LowValue = new DoubleParam() { Name = "LowValue", Value = "0" };
  4416. Unit = "℃";
  4417. }
  4418. private void ParamIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  4419. {
  4420. if (e.PropertyName == nameof(Param.IsSaved))
  4421. {
  4422. NotifyOfPropertyChange(nameof(IsSaved));
  4423. }
  4424. else if (e.PropertyName == "Value")
  4425. {
  4426. if (sender is Param)
  4427. {
  4428. if (((Param)sender).IsSaved) return;
  4429. SetValueEventArgs tempSetEventArgs = new SetValueEventArgs();
  4430. tempSetEventArgs.Sender = this;
  4431. tempSetEventArgs.ValueName = Name;
  4432. tempSetEventArgs.PropertyName = ((Param)sender).Name;
  4433. if (sender is DoubleParam)
  4434. {
  4435. tempSetEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  4436. OnValueChanged(tempSetEventArgs);
  4437. }
  4438. else if (sender is StringParam)
  4439. {
  4440. tempSetEventArgs.PropertyValue = ((StringParam)sender).Value;
  4441. OnValueChanged(tempSetEventArgs);
  4442. }
  4443. }
  4444. }
  4445. }
  4446. public TempSetData(string name, string value) : this(name)
  4447. {
  4448. var listStr = value.Split(';');
  4449. No = 1;
  4450. if (listStr.Length > 8)
  4451. {
  4452. Name = listStr[0];
  4453. SetValue.Value = listStr[1];
  4454. SetUnit.Value = listStr[2];
  4455. RampngValue.Value = listStr[3];
  4456. RampngUnit.Value = listStr[4];
  4457. bool.TryParse(listStr[5], out bool isCheck);
  4458. IsCheck.Value = isCheck;
  4459. double.TryParse(listStr[6], out double highValue);
  4460. HighValue.Value = highValue.ToString();
  4461. double.TryParse(listStr[7], out double lowValue);
  4462. LowValue.Value = lowValue.ToString();
  4463. Unit = listStr[8];
  4464. }
  4465. }
  4466. private int _no;
  4467. public int No
  4468. {
  4469. get => _no;
  4470. set
  4471. {
  4472. _no = value;
  4473. NotifyOfPropertyChange("No");
  4474. }
  4475. }
  4476. private string _name;
  4477. public string Name
  4478. {
  4479. get => _name;
  4480. set
  4481. {
  4482. _name = value;
  4483. NotifyOfPropertyChange("Name");
  4484. }
  4485. }
  4486. private string _displayName;
  4487. public string DisplayName
  4488. {
  4489. get => _displayName;
  4490. set
  4491. {
  4492. _displayName = value;
  4493. NotifyOfPropertyChange("DisplayName");
  4494. }
  4495. }
  4496. private StringParam _setValue;
  4497. public StringParam SetValue
  4498. {
  4499. get => _setValue;
  4500. set
  4501. {
  4502. if (_setValue != null)
  4503. {
  4504. _setValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4505. }
  4506. _setValue = value;
  4507. _setValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4508. NotifyOfPropertyChange("SetValue");
  4509. }
  4510. }
  4511. private StringParam _setUnit;
  4512. public StringParam SetUnit
  4513. {
  4514. get => _setUnit;
  4515. set
  4516. {
  4517. if (_setUnit != null)
  4518. {
  4519. _setUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4520. }
  4521. _setUnit = value;
  4522. _setUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4523. NotifyOfPropertyChange("SetUnit");
  4524. }
  4525. }
  4526. private DoubleParam _rampngValue;
  4527. public DoubleParam RampngValue
  4528. {
  4529. get => _rampngValue;
  4530. set
  4531. {
  4532. if (_rampngValue != null)
  4533. {
  4534. _rampngValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4535. }
  4536. _rampngValue = value;
  4537. _rampngValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4538. NotifyOfPropertyChange("RampngValue");
  4539. }
  4540. }
  4541. private StringParam _rampngUnit;
  4542. public StringParam RampngUnit
  4543. {
  4544. get => _rampngUnit;
  4545. set
  4546. {
  4547. if (_rampngUnit != null)
  4548. {
  4549. _rampngUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4550. }
  4551. _rampngUnit = value;
  4552. _rampngUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4553. NotifyOfPropertyChange("RampngUnit");
  4554. }
  4555. }
  4556. private StringParam _alarmValue;
  4557. public StringParam AlarmValue
  4558. {
  4559. get => _alarmValue;
  4560. set
  4561. {
  4562. _alarmValue = value;
  4563. NotifyOfPropertyChange("AlarmValue");
  4564. }
  4565. }
  4566. private BoolParam _isCheck;
  4567. public BoolParam IsCheck
  4568. {
  4569. get => _isCheck;
  4570. set
  4571. {
  4572. if (_isCheck != null)
  4573. {
  4574. _isCheck.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4575. }
  4576. _isCheck = value;
  4577. _isCheck.PropertyChanged += ParamIsSaved_PropertyChanged;
  4578. NotifyOfPropertyChange("IsCheck");
  4579. }
  4580. }
  4581. private DoubleParam _highValue;
  4582. public DoubleParam HighValue
  4583. {
  4584. get => _highValue;
  4585. set
  4586. {
  4587. if (_highValue != null)
  4588. {
  4589. _highValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4590. }
  4591. _highValue = value;
  4592. _highValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4593. NotifyOfPropertyChange("HighValue");
  4594. }
  4595. }
  4596. private DoubleParam _lowValue;
  4597. public DoubleParam LowValue
  4598. {
  4599. get => _lowValue;
  4600. set
  4601. {
  4602. if (_lowValue != null)
  4603. {
  4604. _lowValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4605. }
  4606. _lowValue = value;
  4607. _lowValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4608. NotifyOfPropertyChange("LowValue");
  4609. }
  4610. }
  4611. private string _unit;
  4612. public string Unit
  4613. {
  4614. get => _unit;
  4615. set
  4616. {
  4617. _unit = value;
  4618. NotifyOfPropertyChange("Unit");
  4619. }
  4620. }
  4621. public override string ToString()
  4622. {
  4623. return $"{Name};{SetValue.Value};{SetUnit.Value};{RampngValue.Value};{RampngUnit.Value};{IsCheck.Value};{HighValue.Value};{LowValue.Value};{Unit}";
  4624. }
  4625. }
  4626. public class VPData : PropertyChangedBase
  4627. {
  4628. private int _no;
  4629. public int No
  4630. {
  4631. get => _no;
  4632. set
  4633. {
  4634. _no = value;
  4635. NotifyOfPropertyChange("No");
  4636. }
  4637. }
  4638. private string _name;
  4639. public string Name
  4640. {
  4641. get => _name;
  4642. set
  4643. {
  4644. _name = value;
  4645. NotifyOfPropertyChange("Name");
  4646. }
  4647. }
  4648. private bool _isCheck;
  4649. public bool IsCheck
  4650. {
  4651. get => _isCheck;
  4652. set
  4653. {
  4654. _isCheck = value;
  4655. NotifyOfPropertyChange("IsCheck");
  4656. }
  4657. }
  4658. }
  4659. public class Combination : PropertyChangedBase
  4660. {
  4661. public ObservableCollection<Param> Params = new ObservableCollection<Param>();
  4662. public Combination() { }
  4663. public Combination(ObservableCollection<Param> value) : base()
  4664. {
  4665. if (value != null && value.Count > 0)
  4666. {
  4667. Params = value;
  4668. StringParam subRecipe = value.FirstOrDefault(x => x.Name == "Combination.SubRecipe") as StringParam;
  4669. this.SubRecipePath = subRecipe != null ? subRecipe.Value : "";
  4670. StringParam alarmRecipe = value.FirstOrDefault(x => x.Name == "Combination.AlarmRecipe") as StringParam;
  4671. this.AlarmRecipePath = alarmRecipe != null ? alarmRecipe.Value : "";
  4672. StringParam alarmCondition = value.FirstOrDefault(x => x.Name == "Combination.AlarmCondition") as StringParam;
  4673. this.AlarmCondition = alarmCondition != null ? alarmCondition.Value : "";
  4674. StringParam leakCheck = value.FirstOrDefault(x => x.Name == "Combination.LeakCheck") as StringParam;
  4675. this.LeakCheck = leakCheck != null ? leakCheck.Value : "";
  4676. StringParam abortRecipe = value.FirstOrDefault(x => x.Name == "Combination.AbortRecipe") as StringParam;
  4677. this.AbortRecipePath = abortRecipe != null ? abortRecipe.Value : "";
  4678. StringParam pressAPCPID = value.FirstOrDefault(x => x.Name == "Combination.PressAPCPID") as StringParam;
  4679. this.PressAPC = pressAPCPID != null ? pressAPCPID.Value : "";
  4680. StringParam tempCorrection = value.FirstOrDefault(x => x.Name == "Combination.TempCorrection") as StringParam;
  4681. this.TempCorrection = tempCorrection != null ? tempCorrection.Value : "";
  4682. StringParam tempPID = value.FirstOrDefault(x => x.Name == "Combination.TempPID") as StringParam;
  4683. this.TempPID = tempPID != null ? tempPID.Value : "";
  4684. StringParam profileCondition = value.FirstOrDefault(x => x.Name == "Combination.ProfileCondition") as StringParam;
  4685. this.ProfileCondition = profileCondition != null ? profileCondition.Value : "";
  4686. StringParam n2PurgeMode = value.FirstOrDefault(x => x.Name == "N2PurgeMode") as StringParam;
  4687. this.N2PurgeMode = n2PurgeMode != null ? n2PurgeMode.Value : "None";
  4688. }
  4689. }
  4690. public Combination(string value) : base()
  4691. {
  4692. SetCombinationValue(value);
  4693. }
  4694. public void SetCombinationValue(string value)
  4695. {
  4696. if (string.IsNullOrEmpty(value) || !value.Contains(";")) return;
  4697. var strList = value.Split(';');
  4698. foreach (var item in strList)
  4699. {
  4700. var subStrList = item.Split(':');
  4701. if (string.IsNullOrEmpty(subStrList[0]) || subStrList.Length != 2) continue;
  4702. switch (subStrList[0])
  4703. {
  4704. case "SubRecipePath":
  4705. SubRecipePath = subStrList[1];
  4706. break;
  4707. case "AlarmRecipePath":
  4708. AlarmRecipePath = subStrList[1];
  4709. break;
  4710. case "AbortRecipePath":
  4711. AbortRecipePath = subStrList[1];
  4712. break;
  4713. case "AlarmCondition":
  4714. AlarmCondition = subStrList[1];
  4715. break;
  4716. case "LeakCheck":
  4717. LeakCheck = subStrList[1];
  4718. break;
  4719. case "PressAPC":
  4720. PressAPC = subStrList[1];
  4721. break;
  4722. case "TempCorrect":
  4723. TempCorrection = subStrList[1];
  4724. break;
  4725. case "TempPID":
  4726. TempPID = subStrList[1];
  4727. break;
  4728. case "ProfileCondition":
  4729. ProfileCondition = subStrList[1];
  4730. break;
  4731. default:
  4732. break;
  4733. }
  4734. }
  4735. }
  4736. private string _subRecipePath = "";
  4737. public string SubRecipePath
  4738. {
  4739. get => _subRecipePath;
  4740. set
  4741. {
  4742. _subRecipePath = value;
  4743. NotifyOfPropertyChange("SubRecipePath");
  4744. }
  4745. }
  4746. private string _alarmRecipePath = "";
  4747. public string AlarmRecipePath
  4748. {
  4749. get => _alarmRecipePath;
  4750. set
  4751. {
  4752. _alarmRecipePath = value;
  4753. NotifyOfPropertyChange("AlarmRecipePath");
  4754. }
  4755. }
  4756. private string _alarmCondition = "";
  4757. public string AlarmCondition
  4758. {
  4759. get => _alarmCondition;
  4760. set
  4761. {
  4762. _alarmCondition = value;
  4763. NotifyOfPropertyChange("AlarmCondition");
  4764. }
  4765. }
  4766. private string _leakCheck = "";
  4767. public string LeakCheck
  4768. {
  4769. get => _leakCheck;
  4770. set
  4771. {
  4772. _leakCheck = value;
  4773. NotifyOfPropertyChange("LeakCheck");
  4774. }
  4775. }
  4776. private string _AbortRecipePath = "";
  4777. public string AbortRecipePath
  4778. {
  4779. get => _AbortRecipePath;
  4780. set
  4781. {
  4782. _AbortRecipePath = value;
  4783. NotifyOfPropertyChange("AbortRecipePath");
  4784. }
  4785. }
  4786. private string _pressAPC = "";
  4787. public string PressAPC
  4788. {
  4789. get => _pressAPC;
  4790. set
  4791. {
  4792. _pressAPC = value;
  4793. NotifyOfPropertyChange("PressAPC");
  4794. }
  4795. }
  4796. private string _tempCorrection = "";
  4797. public string TempCorrection
  4798. {
  4799. get => _tempCorrection;
  4800. set
  4801. {
  4802. _tempCorrection = value;
  4803. NotifyOfPropertyChange("TempCorrection");
  4804. }
  4805. }
  4806. private string _tempPID = "";
  4807. public string TempPID
  4808. {
  4809. get => _tempPID;
  4810. set
  4811. {
  4812. _tempPID = value;
  4813. NotifyOfPropertyChange("TempPID");
  4814. }
  4815. }
  4816. private string _profileCondition = "";
  4817. public string ProfileCondition
  4818. {
  4819. get => _profileCondition;
  4820. set
  4821. {
  4822. _profileCondition = value;
  4823. NotifyOfPropertyChange("ProfileCondition");
  4824. }
  4825. }
  4826. private string _n2PurgeMode = "None";
  4827. public string N2PurgeMode
  4828. {
  4829. get => _n2PurgeMode;
  4830. set
  4831. {
  4832. _n2PurgeMode = value;
  4833. NotifyOfPropertyChange("N2PurgeMode");
  4834. }
  4835. }
  4836. public delegate void ChangedValueHandler(string type, string value);
  4837. public event ChangedValueHandler ChangedValueEvent;
  4838. private void ChangedSelectedFileName(string type, string value)
  4839. {
  4840. if (ChangedValueEvent != null)
  4841. {
  4842. ChangedValueEvent(type, value);
  4843. }
  4844. }
  4845. public void SetN2PurgeModeToParam()
  4846. {
  4847. if (Params.Count > 0)
  4848. {
  4849. StringParam n2PurgeMode = Params.FirstOrDefault(x => x.Name == "N2PurgeMode") as StringParam;
  4850. if (n2PurgeMode != null && n2PurgeMode.Value != this.N2PurgeMode)
  4851. {
  4852. n2PurgeMode.Value = this.N2PurgeMode;
  4853. ChangedSelectedFileName("N2PurgeMode", this.N2PurgeMode);
  4854. }
  4855. }
  4856. }
  4857. public void SetValueToParam()
  4858. {
  4859. if (Params.Count > 0)
  4860. {
  4861. StringParam subRecipe = Params.FirstOrDefault(x => x.Name == "Combination.SubRecipe") as StringParam;
  4862. if (subRecipe != null && subRecipe.Value != this.SubRecipePath)
  4863. {
  4864. subRecipe.Value = this.SubRecipePath;
  4865. ChangedSelectedFileName("SubRecipe", this.SubRecipePath);
  4866. }
  4867. StringParam alarmRecipe = Params.FirstOrDefault(x => x.Name == "Combination.AlarmRecipe") as StringParam;
  4868. if (alarmRecipe != null && alarmRecipe.Value != this.AlarmRecipePath)
  4869. {
  4870. alarmRecipe.Value = this.AlarmRecipePath;
  4871. ChangedSelectedFileName("AlarmRecipe", this.AlarmRecipePath);
  4872. }
  4873. StringParam alarmCondition = Params.FirstOrDefault(x => x.Name == "Combination.AlarmCondition") as StringParam;
  4874. if (alarmCondition != null && alarmCondition.Value != this.AlarmCondition)
  4875. {
  4876. alarmCondition.Value = this.AlarmCondition;
  4877. ChangedSelectedFileName("AlarmCondition", this.AlarmCondition);
  4878. }
  4879. StringParam leakCheck = Params.FirstOrDefault(x => x.Name == "Combination.LeakCheck") as StringParam;
  4880. if (leakCheck != null && leakCheck.Value != this.LeakCheck)
  4881. {
  4882. leakCheck.Value = this.LeakCheck;
  4883. ChangedSelectedFileName("LeakCheck", this.LeakCheck);
  4884. }
  4885. StringParam abortRecipe = Params.FirstOrDefault(x => x.Name == "Combination.AbortRecipe") as StringParam;
  4886. if (abortRecipe != null && abortRecipe.Value != this.AbortRecipePath)
  4887. {
  4888. abortRecipe.Value = this.AbortRecipePath;
  4889. ChangedSelectedFileName("AbortRecipe", this.AbortRecipePath);
  4890. }
  4891. StringParam pressAPCPID = Params.FirstOrDefault(x => x.Name == "Combination.PressAPCPID") as StringParam;
  4892. if (pressAPCPID != null && pressAPCPID.Value != this.PressAPC)
  4893. {
  4894. pressAPCPID.Value = this.PressAPC;
  4895. ChangedSelectedFileName("PressAPCPID", this.PressAPC);
  4896. }
  4897. StringParam tempCorrection = Params.FirstOrDefault(x => x.Name == "Combination.TempCorrection") as StringParam;
  4898. if (tempCorrection != null && tempCorrection.Value != this.TempCorrection)
  4899. {
  4900. tempCorrection.Value = this.TempCorrection;
  4901. ChangedSelectedFileName("TempCorrection", this.TempCorrection);
  4902. }
  4903. StringParam tempPID = Params.FirstOrDefault(x => x.Name == "Combination.TempPID") as StringParam;
  4904. if (tempPID != null && tempPID.Value != this.TempPID)
  4905. {
  4906. tempPID.Value = this.TempPID;
  4907. ChangedSelectedFileName("TempPID", this.TempPID);
  4908. }
  4909. StringParam profileCondition = Params.FirstOrDefault(x => x.Name == "Combination.ProfileCondition") as StringParam;
  4910. if (profileCondition != null && profileCondition.Value != this.ProfileCondition)
  4911. {
  4912. profileCondition.Value = this.ProfileCondition;
  4913. ChangedSelectedFileName("ProfileCondition", this.ProfileCondition);
  4914. }
  4915. StringParam n2PurgeMode = Params.FirstOrDefault(x => x.Name == "N2PurgeMode") as StringParam;
  4916. if (n2PurgeMode != null && n2PurgeMode.Value != this.N2PurgeMode)
  4917. {
  4918. n2PurgeMode.Value = this.N2PurgeMode;
  4919. ChangedSelectedFileName("N2PurgeMode", this.N2PurgeMode);
  4920. }
  4921. }
  4922. }
  4923. public override string ToString()
  4924. {
  4925. List<string> strList = new List<string>
  4926. {
  4927. $"SubRecipePath:{SubRecipePath}",
  4928. $"AlarmRecipePath:{AlarmRecipePath}",
  4929. $"AlarmCondition:{AlarmCondition}",
  4930. $"LeakCheck:{LeakCheck}",
  4931. $"AbortRecipePath:{AbortRecipePath}",
  4932. $"PressAPC:{PressAPC}",
  4933. $"TempCorrect:{TempCorrection}",
  4934. $"TempPID:{TempPID}",
  4935. $"ProfileCondition:{ProfileCondition}"
  4936. };
  4937. string toolType = (string)QueryDataClient.Instance.Service.GetConfig("System.SetUp.ToolType");
  4938. if (toolType != null && "SIBCN" == toolType)
  4939. {
  4940. strList.Add($"N2PurgeMode:{N2PurgeMode}");
  4941. }
  4942. return string.Join(";", strList);
  4943. }
  4944. }
  4945. public class AUXData : PropertyChangedBase
  4946. {
  4947. public delegate void ValueChangedEventHandler(object sender, SetValueEventArgs e);
  4948. public event ValueChangedEventHandler ValueChangedEvent;
  4949. public void OnValueChanged(SetValueEventArgs e)
  4950. {
  4951. if (ValueChangedEvent != null)
  4952. {
  4953. ValueChangedEvent(this, e);
  4954. }
  4955. }
  4956. public bool IsSaved
  4957. {
  4958. get => SetValue.IsSaved && SetUnit.IsSaved && Rampng.IsSaved && RampngUnit.IsSaved && IsCheck.IsSaved && MaxValue.IsSaved && MinValue.IsSaved;
  4959. }
  4960. public bool UndoChanges()
  4961. {
  4962. Type type = this.GetType();
  4963. PropertyInfo[] properties = type.GetProperties();
  4964. foreach (var item in properties)
  4965. {
  4966. var obj = item.GetValue(this);
  4967. if (obj is Param)
  4968. {
  4969. ((Param)obj).UndoChanges();
  4970. }
  4971. }
  4972. return true;
  4973. }
  4974. public bool UndoChanges(AUXData oldAUXData)
  4975. {
  4976. Type type = this.GetType();
  4977. PropertyInfo[] properties = type.GetProperties();
  4978. Type oldType = oldAUXData.GetType();
  4979. PropertyInfo[] oldProperties = oldType.GetProperties();
  4980. foreach (var item in properties)
  4981. {
  4982. var oldprop = oldProperties.FirstOrDefault(x => x.Name == item.Name);
  4983. if (oldprop != null)
  4984. {
  4985. var oldObj = oldprop.GetValue(oldAUXData);
  4986. if (oldObj != null)
  4987. {
  4988. var obj = item.GetValue(this);
  4989. if (obj is Param)
  4990. {
  4991. if (oldObj != null && ((Param)oldObj).IsSaved != ((Param)obj).IsSaved)
  4992. ((Param)obj).UndoChanges();
  4993. }
  4994. }
  4995. }
  4996. }
  4997. return true;
  4998. }
  4999. private void ParamIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  5000. {
  5001. if (e.PropertyName == nameof(Param.IsSaved))
  5002. {
  5003. NotifyOfPropertyChange("IsSaved");
  5004. }
  5005. else if (e.PropertyName == nameof(DoubleParam.Value))
  5006. {
  5007. if (sender is Param)
  5008. {
  5009. if (((Param)sender).IsSaved) return;
  5010. SetValueEventArgs tempSetEventArgs = new SetValueEventArgs();
  5011. tempSetEventArgs.Sender = this;
  5012. tempSetEventArgs.ValueName = this.ControlName;
  5013. tempSetEventArgs.PropertyName = ((Param)sender).Name;
  5014. if (sender is DoubleParam)
  5015. {
  5016. tempSetEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  5017. OnValueChanged(tempSetEventArgs);
  5018. }
  5019. else if (sender is StringParam)
  5020. {
  5021. tempSetEventArgs.PropertyValue = ((StringParam)sender).Value;
  5022. OnValueChanged(tempSetEventArgs);
  5023. }
  5024. else if (sender is BoolParam)
  5025. {
  5026. tempSetEventArgs.PropertyValue = ((BoolParam)sender).Value.ToString();
  5027. OnValueChanged(tempSetEventArgs);
  5028. }
  5029. }
  5030. }
  5031. }
  5032. private int _no;
  5033. public int No
  5034. {
  5035. get => _no;
  5036. set
  5037. {
  5038. _no = value;
  5039. NotifyOfPropertyChange("No");
  5040. }
  5041. }
  5042. private string _name;
  5043. public string Name
  5044. {
  5045. get => _name;
  5046. set
  5047. {
  5048. _name = value;
  5049. NotifyOfPropertyChange("Name");
  5050. }
  5051. }
  5052. public string _unit;
  5053. public string Unit
  5054. {
  5055. get => _unit;
  5056. set
  5057. {
  5058. _unit = value;
  5059. NotifyOfPropertyChange("Unit");
  5060. }
  5061. }
  5062. private string _displayName;
  5063. public string DisplayName
  5064. {
  5065. get => _displayName;
  5066. set
  5067. {
  5068. _displayName = value;
  5069. NotifyOfPropertyChange("DisplayName");
  5070. }
  5071. }
  5072. private string _controlName;
  5073. public string ControlName
  5074. {
  5075. get => _controlName;
  5076. set
  5077. {
  5078. _controlName = value;
  5079. NotifyOfPropertyChange("ControlName");
  5080. }
  5081. }
  5082. private DoubleParam _setValue;
  5083. public DoubleParam SetValue
  5084. {
  5085. get => _setValue;
  5086. set
  5087. {
  5088. if (_setValue != null)
  5089. {
  5090. _setValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5091. }
  5092. _setValue = value;
  5093. _setValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  5094. NotifyOfPropertyChange(nameof(SetValue));
  5095. }
  5096. }
  5097. private StringParam _setUnit;// = "SLM";
  5098. public StringParam SetUnit
  5099. {
  5100. get => _setUnit;
  5101. set
  5102. {
  5103. if (_setUnit != null)
  5104. {
  5105. _setUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5106. }
  5107. _setUnit = value;
  5108. _setUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  5109. NotifyOfPropertyChange(nameof(SetUnit));
  5110. }
  5111. }
  5112. private StringParam _rampngUnit = new StringParam() { Name = "RampngUnit", Value = "SLM" };// = "SLM";
  5113. public StringParam RampngUnit
  5114. {
  5115. get => _rampngUnit;
  5116. set
  5117. {
  5118. if (_rampngUnit != null)
  5119. {
  5120. _rampngUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5121. }
  5122. _rampngUnit = value;
  5123. _rampngUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  5124. NotifyOfPropertyChange("RampngUnit");
  5125. }
  5126. }
  5127. private DoubleParam _rampng = new DoubleParam() { Name = "Rampng", Value = "0" };
  5128. public DoubleParam Rampng
  5129. {
  5130. get => _rampng; set
  5131. {
  5132. if (_rampng != null)
  5133. {
  5134. _rampng.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5135. }
  5136. _rampng = value;
  5137. _rampng.PropertyChanged += ParamIsSaved_PropertyChanged;
  5138. NotifyOfPropertyChange("Rampng");
  5139. }
  5140. }
  5141. private string _alarmValue;
  5142. public string AlarmValue
  5143. {
  5144. get => _alarmValue; set
  5145. {
  5146. _alarmValue = value;
  5147. NotifyOfPropertyChange("AlarmValue");
  5148. }
  5149. }
  5150. private DoubleParam _maxValue;
  5151. public DoubleParam MaxValue
  5152. {
  5153. get => _maxValue; set
  5154. {
  5155. if (_maxValue != null)
  5156. {
  5157. _maxValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5158. }
  5159. _maxValue = value;
  5160. _maxValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  5161. NotifyOfPropertyChange("MaxValue");
  5162. }
  5163. }
  5164. private DoubleParam _minValue;
  5165. public DoubleParam MinValue
  5166. {
  5167. get => _minValue; set
  5168. {
  5169. if (_minValue != null)
  5170. {
  5171. _minValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5172. }
  5173. _minValue = value;
  5174. _minValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  5175. NotifyOfPropertyChange("MinValue");
  5176. }
  5177. }
  5178. private BoolParam _isCheck;
  5179. public BoolParam IsCheck
  5180. {
  5181. get => _isCheck;
  5182. set
  5183. {
  5184. if (_isCheck != null)
  5185. {
  5186. _isCheck.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5187. }
  5188. _isCheck = value;
  5189. _isCheck.PropertyChanged += ParamIsSaved_PropertyChanged;
  5190. NotifyOfPropertyChange("IsCheck");
  5191. }
  5192. }
  5193. private bool _isEnable = true;
  5194. public bool IsEnable
  5195. {
  5196. get => _isEnable;
  5197. set
  5198. {
  5199. _isEnable = value;
  5200. NotifyOfPropertyChange("IsEnable");
  5201. }
  5202. }
  5203. }
  5204. public class SetValueEventArgs : EventArgs
  5205. {
  5206. private Object _sender;
  5207. public Object Sender
  5208. {
  5209. get => _sender;
  5210. set
  5211. {
  5212. _sender = value;
  5213. }
  5214. }
  5215. private string _valueName;
  5216. public string ValueName
  5217. {
  5218. get => _valueName;
  5219. set
  5220. {
  5221. _valueName = value;
  5222. }
  5223. }
  5224. private string _propertyName;
  5225. public string PropertyName
  5226. {
  5227. get => _propertyName;
  5228. set
  5229. {
  5230. _propertyName = value;
  5231. }
  5232. }
  5233. private string _propertyValue;
  5234. public string PropertyValue
  5235. {
  5236. get => _propertyValue;
  5237. set
  5238. {
  5239. _propertyValue = value;
  5240. }
  5241. }
  5242. public SetValueEventArgs()
  5243. {
  5244. }
  5245. }
  5246. }