RecipeDataBase.cs 232 KB

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