RecipeDataBase.cs 231 KB

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