RecipeDataBase.cs 226 KB

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