RecipeDataBase.cs 232 KB

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