RecipeDataBase.cs 232 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593
  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 void FastLoadSteps(XmlNodeList steps)
  2217. {
  2218. Steps.Clear();
  2219. PopSettingSteps.Clear();
  2220. StepTolerances.Clear();
  2221. StepNos.Clear();
  2222. if (steps.Count == 0)
  2223. return;
  2224. ConcurrentDictionary<int, Step> cache = new ConcurrentDictionary<int, Step>();
  2225. Step step = this.CreateStep(steps[0]);
  2226. StepNos.Add(step.StepNo);
  2227. Steps.Add(step);
  2228. Parallel.For(1, steps.Count - 1, index =>
  2229. {
  2230. Step tempStep = CreateStep(step, steps.Item(index));
  2231. cache[tempStep.StepNo] = tempStep;
  2232. });
  2233. foreach (var item in cache)
  2234. {
  2235. StepNos.Add(item.Key);
  2236. Steps.Add(item.Value);
  2237. }
  2238. //if (steps.Count != 0)
  2239. //{
  2240. // Step step = this.CreateStep(steps[0]);
  2241. // var query1 = (from XmlNode n in steps select n).ToList();
  2242. // query1.RemoveAt(0);
  2243. // var allSteps = query1.AsParallel().AsOrdered()
  2244. // .Select(x => this.CreateStep(Steps[0], x));
  2245. // StepNos.Add(step.StepNo);
  2246. // Steps.Add(step);
  2247. // foreach (var item in allSteps)
  2248. // {
  2249. // StepNos.Add(item.StepNo);
  2250. // Steps.Add(item);
  2251. // }
  2252. //}
  2253. }
  2254. private void LoadConfigs(XmlNode configNode)
  2255. {
  2256. if (configNode == null)
  2257. return;
  2258. foreach (Param configItem in ConfigItems)
  2259. {
  2260. if (configNode.Attributes[configItem.Name] != null)
  2261. {
  2262. if (configItem is StringParam)
  2263. (configItem as StringParam).Value = configNode.Attributes[configItem.Name]?.Value;
  2264. else if (configItem is DoubleParam)
  2265. (configItem as DoubleParam).Value = configNode.Attributes[configItem.Name]?.Value;
  2266. }
  2267. }
  2268. }
  2269. private string GetConditionCheckXmlString(Step parameters)
  2270. {
  2271. StringBuilder conditionCheckStr = new StringBuilder();
  2272. string externalSensor = "";
  2273. string[] tempStr = new string[] { "", "", "", "", "", "", "" };
  2274. for (int i = 0; i < tempStr.Count(); i++)
  2275. {
  2276. tempStr[i] = $"{parameters.ExternalSensorName[i]}.{parameters.ExternalSensor[i]}";
  2277. }
  2278. externalSensor = $"ExternalSensor:{string.Join(",", tempStr.Select(x => x.ToString()))}";
  2279. conditionCheckStr.Append($"{externalSensor};");
  2280. conditionCheckStr.Append($"TempStabilize:{parameters.TempStabilizeSelected};");
  2281. conditionCheckStr.Append($"FinishAutoProfile:{parameters.FinishAutoProfile};");
  2282. //conditionCheckStr.Append($"TempUpper:{parameters.TempUpper.ToString()};");
  2283. //conditionCheckStr.Append($"TempLower:{parameters.TempLower.ToString()};");
  2284. if (parameters.ReachTemp == "None")
  2285. {
  2286. conditionCheckStr.Append($"ReachTemp:{parameters.ReachTemp};");
  2287. }
  2288. else
  2289. {
  2290. conditionCheckStr.Append($"ReachTemp:{parameters.ReachTemp},{parameters.ReachTempValue.ToString()};");
  2291. }
  2292. if (parameters.O2Density == "None")
  2293. {
  2294. conditionCheckStr.Append($"O2Density:{parameters.O2Density};");
  2295. }
  2296. else
  2297. {
  2298. conditionCheckStr.Append($"O2Density:{parameters.O2Density},{parameters.O2DensityValue.ToString()};");
  2299. }
  2300. //conditionCheckStr.Append($"PressureUpper:{parameters.PressureUpper.ToString()};");
  2301. //conditionCheckStr.Append($"PressureLower:{parameters.PressureLower.ToString()};");
  2302. if (parameters.ReachPressure == "None")
  2303. {
  2304. conditionCheckStr.Append($"ReachPressureWait:{parameters.ReachPressure};");
  2305. }
  2306. else
  2307. {
  2308. conditionCheckStr.Append($"ReachPressure:{parameters.ReachPressure},{parameters.ReachPressureVG},{parameters.ReachPressureValue.ToString()};");
  2309. }
  2310. conditionCheckStr.Append($"PressureStabilize:{parameters.PressureStabilizeSelected},{parameters.PressureStabilizeVG}");
  2311. conditionCheckStr.Append($"ProcessTimeToEnd:{parameters.ProcessTimeToEnd}");
  2312. return conditionCheckStr.ToString();
  2313. }
  2314. private void CreateTablesXml(XmlElement nodeData)
  2315. {
  2316. XmlNode nodeTables = _doc.SelectSingleNode($"Aitex/TableRecipeData/Tables");
  2317. if (nodeTables == null) //创建Recipe文件
  2318. {
  2319. nodeTables = _doc.CreateElement("Tables");
  2320. nodeData.AppendChild(nodeTables);
  2321. nodeTables.RemoveAll();
  2322. int tableCount = 20;
  2323. if (_chamberType.ToLower() == "abort")
  2324. {
  2325. tableCount = 10;
  2326. }
  2327. for (int i = 1; i <= tableCount; i++)
  2328. {
  2329. XmlElement nodeTable = _doc.CreateElement("Table");
  2330. nodeTable.SetAttribute("Index", i.ToString());
  2331. nodeTable.SetAttribute("EndStatus", "");
  2332. nodeTable.SetAttribute("Name", "");
  2333. nodeTables.AppendChild(nodeTable);
  2334. }
  2335. }
  2336. }
  2337. private void SaveTables(XmlElement nodeData, List<XmlElement> steps, int tableIndex = 1)
  2338. {
  2339. //XmlNode nodeTables = nodeData.SelectSingleNode($"Aitex/TableRecipeData/Tables");
  2340. XmlElement selectednodeTable = (XmlElement)nodeData.ChildNodes[0].SelectSingleNode($"Table[@Index='{tableIndex}']");
  2341. var table = this.Tables.FirstOrDefault(x => x.Index == tableIndex);
  2342. if (selectednodeTable == null || table == null)
  2343. return;
  2344. selectednodeTable.SetAttribute("EndStatus", table.EndStatus);
  2345. selectednodeTable.SetAttribute("Name", table.Name);
  2346. while (selectednodeTable.FirstChild != null)
  2347. {
  2348. selectednodeTable.RemoveChild(selectednodeTable.FirstChild);
  2349. }
  2350. steps.ForEach(x => selectednodeTable.AppendChild(x));
  2351. }
  2352. public string GetXmlString()
  2353. {
  2354. XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableRecipeData") as XmlElement;
  2355. nodeData.SetAttribute("CreatedBy", Creator);
  2356. nodeData.SetAttribute("CreationTime", CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  2357. nodeData.SetAttribute("LastRevisedBy", Revisor);
  2358. nodeData.SetAttribute("LastRevisionTime", ReviseTime.ToString("yyyy-MM-dd HH:mm:ss"));
  2359. nodeData.SetAttribute("Description", Description);
  2360. nodeData.SetAttribute("RecipeChamberType", RecipeChamberType);
  2361. nodeData.SetAttribute("RecipeVersion", RecipeVersion);
  2362. nodeData.SetAttribute("RecipePermission", RecipePermission);
  2363. nodeData.SetAttribute("RecipeLevel", RecipeLevel);
  2364. nodeData.SetAttribute("TableIndex", TableIndex.ToString());
  2365. if (!SaveTableRecipeTypes.Contains(RecipeChamberType))
  2366. {
  2367. XmlNode nodeModule = _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{_module}']");
  2368. if (nodeModule == null)
  2369. {
  2370. nodeModule = _doc.CreateElement("Module");
  2371. nodeData.AppendChild(nodeModule);
  2372. }
  2373. nodeModule.RemoveAll();
  2374. (nodeModule as XmlElement).SetAttribute("Name", _module);
  2375. int i = 0;
  2376. foreach (Step parameters in Steps)
  2377. {
  2378. XmlElement nodeWarning = _doc.CreateElement("Warning");
  2379. XmlElement nodeAlarm = _doc.CreateElement("Alarm");
  2380. Dictionary<string, XmlElement> nodePop = new Dictionary<string, XmlElement>();
  2381. foreach (string key in PopEnable.Keys)
  2382. {
  2383. nodePop.Add(key, _doc.CreateElement(key));
  2384. }
  2385. XmlElement nodeStep = _doc.CreateElement("Step");
  2386. if (ToleranceEnable)
  2387. {
  2388. nodeStep.AppendChild(nodeWarning);
  2389. nodeStep.AppendChild(nodeAlarm);
  2390. }
  2391. nodeStep.SetAttribute("StepNo", parameters.StepNo.ToString());
  2392. nodeStep.SetAttribute("Name", parameters.Name);
  2393. nodeStep.SetAttribute("EndBy", parameters.EndBy);
  2394. nodeStep.SetAttribute("Time", parameters.Time);
  2395. nodeStep.SetAttribute("SkipWait", parameters.SkipWait);
  2396. nodeStep.SetAttribute("Command", parameters.Command);
  2397. nodeStep.SetAttribute("AlarmIsSaved", parameters.AlarmIsSaved.ToString());
  2398. nodeStep.SetAttribute("MFCIsSaved", parameters.MFCIsSaved.ToString());
  2399. nodeStep.SetAttribute("ValveIsSaved", parameters.ValveIsSaved.ToString());
  2400. nodeStep.SetAttribute("PressIsSaved", parameters.PressIsSaved.ToString());
  2401. nodeStep.SetAttribute("AUXIsSaved", parameters.AUXIsSaved.ToString());
  2402. nodeStep.SetAttribute("TemperatureIsSaved", parameters.TemperatureIsSaved.ToString());
  2403. if (parameters.IsnoneConditionCheck)
  2404. {
  2405. nodeStep.SetAttribute("ConditionCheck", "none");
  2406. }
  2407. else
  2408. {
  2409. nodeStep.SetAttribute("ConditionCheck", GetConditionCheckXmlString(parameters));
  2410. }
  2411. //nodeStep.SetAttribute("PressureSonserValue", parameters.PressureSonserValue);
  2412. //nodeStep.SetAttribute("PressureSonserValue", parameters.PressureSonserValue);
  2413. //nodeStep.SetAttribute("PressureValveAngle", parameters.PressureValveAngle);
  2414. //nodeStep.SetAttribute("PressureSettingVG", parameters.PressureSettingVG);
  2415. //nodeStep.SetAttribute("SlowVacuumValue", parameters.SlowVacuumValue);
  2416. //nodeStep.SetAttribute("PressureAlarmTableNo", parameters.PressureAlarmTableNo);
  2417. //nodeStep.SetAttribute("ZAxisPosition", parameters.ZAxisPosition);
  2418. //nodeStep.SetAttribute("ZAxisSpeed", parameters.ZAxisSpeed);
  2419. //nodeStep.SetAttribute("RotateDirection", parameters.RotateDirection);
  2420. //nodeStep.SetAttribute("RotatePosition", parameters.RotatePosition);
  2421. //nodeStep.SetAttribute("RotateSpeed", parameters.RotateSpeed);
  2422. //nodeStep.SetAttribute("RotateInterval", parameters.RotateInterval);
  2423. //nodeStep.SetAttribute("APC.SetPressure", parameters.APC_SetPressure);
  2424. //nodeStep.SetAttribute("MfmD1Flow", parameters.MfmD1Flow.ToString());
  2425. //nodeStep.SetAttribute("RFSwitch", parameters.RFSwitch);
  2426. //nodeStep.SetAttribute("RFSetpoint", parameters.RFSetpoint);
  2427. //nodeStep.SetAttribute("RFPowerSetpoint", parameters.RFPowerSetpoint);
  2428. //nodeStep.SetAttribute("CAPSetValue", parameters.CAPSetValue);
  2429. //nodeStep.SetAttribute("CAPRampingValue", parameters.CAPRampingValue);
  2430. //nodeStep.SetAttribute("C1Setpoint", parameters.C1Setpoint);
  2431. //nodeStep.SetAttribute("C2Setpoint", parameters.C2Setpoint);
  2432. //nodeStep.SetAttribute("ForwardPowerAlarmWatchTable", parameters.ForwardPowerAlarmWatchTable);
  2433. //nodeStep.SetAttribute("C1AlarmWatchTable", parameters.C1AlarmWatchTable);
  2434. //nodeStep.SetAttribute("C2AlarmWatchTable", parameters.C2AlarmWatchTable);
  2435. //nodeStep.SetAttribute("PrAlarmWatchTable", parameters.PrAlarmWatchTable);
  2436. //nodeStep.SetAttribute("PIAlarmWatchTable", parameters.PIAlarmWatchTable);
  2437. //nodeStep.SetAttribute("VppAlarmWatchTable", parameters.VppAlarmWatchTable);
  2438. //nodeStep.SetAttribute("VdcAlarmWatchTable", parameters.VdcAlarmWatchTable);
  2439. nodeStep.SetAttribute("AlarmConditionTable", parameters.AlarmConditionTable.Value);
  2440. nodeStep.SetAttribute("AbortRecipeTableIndex", parameters.AbortRecipeTableIndex);
  2441. //nodeStep.SetAttribute("EventSetting", parameters.EventSetting);
  2442. var dpParam = parameters.ValveSets.FirstOrDefault(x => x.Name == "DP");
  2443. foreach (var item in parameters.ValveSets)
  2444. {
  2445. if (item.Name == "MBP")
  2446. {
  2447. if (dpParam != null)
  2448. {
  2449. nodeStep.SetAttribute(item.Name, dpParam.Value ? "Open" : "Close");
  2450. }
  2451. else
  2452. {
  2453. nodeStep.SetAttribute(item.Name, item.Value ? "Open" : "Close");
  2454. }
  2455. }
  2456. else
  2457. {
  2458. nodeStep.SetAttribute(item.Name, item.Value ? "Open" : "Close");
  2459. }
  2460. }
  2461. foreach (var item in parameters.MFCSets)
  2462. {
  2463. nodeStep.SetAttribute($"{item.ControlName}.Flow.IsSaved", item.IsSaved.ToString());
  2464. nodeStep.SetAttribute($"{item.ControlName}.Flow.Set", item.SetValue.Value);
  2465. nodeStep.SetAttribute($"{item.ControlName}.Flow.SetUnit", item.SetUnit.Value);
  2466. nodeStep.SetAttribute($"{item.ControlName}.Flow.Ramprate", item.Rampng.Value);
  2467. nodeStep.SetAttribute($"{item.ControlName}.Flow.RamprateUnit", item.RampngUnit.Value);
  2468. nodeStep.SetAttribute($"{item.ControlName}.Flow.Check", item.IsCheck.Value.ToString());
  2469. nodeStep.SetAttribute($"{item.ControlName}.Flow.High", item.MaxValue.Value.ToString());
  2470. nodeStep.SetAttribute($"{item.ControlName}.Flow.Low", item.MinValue.Value.ToString());
  2471. nodeStep.SetAttribute($"{item.ControlName}.Flow.Unit", item.Unit);
  2472. }
  2473. foreach (var item in parameters.MFMSets)
  2474. {
  2475. nodeStep.SetAttribute(item.Key, parameters.MFMSets[item.Key].ToString());
  2476. }
  2477. foreach (var item in parameters.EXOUSets.Keys)
  2478. {
  2479. nodeStep.SetAttribute(item, parameters.EXOUSets[item].ToString());
  2480. }
  2481. foreach (var item in parameters.TemperatureSets)
  2482. {
  2483. nodeStep.SetAttribute($"{item.Name}.ZoneName", item.Name);
  2484. nodeStep.SetAttribute($"{item.Name}.Set", item.SetValue.Value);
  2485. nodeStep.SetAttribute($"{item.Name}.SetUnit", item.SetUnit.Value);
  2486. nodeStep.SetAttribute($"{item.Name}.Ramprate", item.RampngValue.Value);
  2487. nodeStep.SetAttribute($"{item.Name}.RamprateUnit", item.RampngUnit.Value);
  2488. nodeStep.SetAttribute($"{item.Name}.Check", item.IsCheck.Value.ToString());
  2489. nodeStep.SetAttribute($"{item.Name}.High", item.HighValue.Value.ToString());
  2490. nodeStep.SetAttribute($"{item.Name}.Low", item.LowValue.Value.ToString());
  2491. nodeStep.SetAttribute($"{item.Name}.Unit", item.Unit.ToString());
  2492. }
  2493. nodeStep.SetAttribute("Temperature.ControlMode", parameters.TemperatureControlMode.Value);
  2494. nodeStep.SetAttribute("Temperature.Correct", parameters.TemperatureCorrect.Value);
  2495. nodeStep.SetAttribute("Temperature.PID", parameters.TemperaturePID.Value);
  2496. nodeStep.SetAttribute("Loader.Command", parameters.LoaderCommand.Value);
  2497. nodeStep.SetAttribute("Loader.Speed1", parameters.LoaderSpeed1.Value);
  2498. nodeStep.SetAttribute("Loader.Speed2", parameters.LoaderSpeed2.Value);
  2499. nodeStep.SetAttribute("Loader.Speed3", parameters.LoaderSpeed3.Value);
  2500. nodeStep.SetAttribute("Loader.RPM", parameters.LoaderRPM.Value.ToString());
  2501. nodeStep.SetAttribute("Press.Command", parameters.PressCommand.Value);
  2502. nodeStep.SetAttribute("Press.PID", parameters.PressPID.Value);
  2503. // nodeStep.SetAttribute("Press.Set", parameters.PressSet.Value);
  2504. nodeStep.SetAttribute("Press.Set", GetPressSetValue(parameters));
  2505. // nodeStep.SetAttribute("Press.SlowVacSet", parameters.PressSlowVacSet.Value);
  2506. nodeStep.SetAttribute("Press.SlowVacSet", GetPressSlowVacSet(parameters));
  2507. // nodeStep.SetAttribute("Press.ValveAngleSet", parameters.PressValveAngleSet.Value);
  2508. nodeStep.SetAttribute("Press.ValveAngleSet", RecipeDataBase.GetValveAngleSet(parameters));
  2509. nodeStep.SetAttribute("Press.IsWait", parameters.PressIsWait.Value.ToString());
  2510. nodeStep.SetAttribute("Press.LowWait", parameters.PressLowWait.Value);
  2511. nodeStep.SetAttribute("Press.HighWait", parameters.PressHighWait.Value);
  2512. nodeStep.SetAttribute("Press.WaitUnit", parameters.PressWaitUnit.Value);
  2513. nodeStep.SetAttribute("Press.LowPressWait", parameters.PressLowPressWait.Value);
  2514. // nodeStep.SetAttribute("Press.WaitPress", parameters.WaitPress.Value);
  2515. nodeStep.SetAttribute("Press.WaitPress", RecipeDataBase.GetWaitPress(parameters));
  2516. nodeStep.SetAttribute("FilmThickFormula", parameters.FilmThickFormula);
  2517. foreach (var item in parameters.AUXSets)
  2518. {
  2519. nodeStep.SetAttribute($"AUX.{item.ControlName}.Set", item.SetValue.Value);
  2520. nodeStep.SetAttribute($"AUX.{item.ControlName}.Check", item.IsCheck.Value.ToString());
  2521. nodeStep.SetAttribute($"AUX.{item.ControlName}.High", item.MaxValue.Value);
  2522. nodeStep.SetAttribute($"AUX.{item.ControlName}.Low", item.MinValue.Value);
  2523. nodeStep.SetAttribute($"AUX.{item.ControlName}.CheckUnit", item.SetUnit.Value);
  2524. }
  2525. nodeModule.AppendChild(nodeStep);
  2526. i++;
  2527. }
  2528. XmlElement nodeConfig = _doc.CreateElement("Config");
  2529. foreach (Param parameter in ConfigItems)
  2530. {
  2531. if (parameter.Visible == System.Windows.Visibility.Visible)
  2532. {
  2533. if (parameter is IntParam)
  2534. nodeConfig.SetAttribute(parameter.Name, ((IntParam)parameter).Value.ToString());
  2535. else if (parameter is DoubleParam)
  2536. {
  2537. string strValue = ((DoubleParam)parameter).Value;
  2538. bool succed = double.TryParse(strValue, out double dValue);
  2539. if (!succed)
  2540. {
  2541. MessageBox.Show($"The set value of {parameter.DisplayName} is {strValue}, not a valid value");
  2542. return null;
  2543. }
  2544. var config = ConfigItems.Where(m => m.Name == parameter.Name).FirstOrDefault();
  2545. if (config is DoubleParam param1)
  2546. {
  2547. if (param1.Minimun == 0 && param1.Maximun == 0)
  2548. {
  2549. //没有设定范围
  2550. }
  2551. else if (dValue > param1.Maximun || dValue < param1.Minimun)
  2552. {
  2553. MessageBox.Show($"The set value of {parameter.DisplayName} is {dValue}, out of the range {param1.Minimun}~{param1.Maximun}");
  2554. return null;
  2555. }
  2556. }
  2557. nodeConfig.SetAttribute(parameter.Name, ((DoubleParam)parameter).Value.ToString());
  2558. }
  2559. else if (parameter is StringParam)
  2560. nodeConfig.SetAttribute(parameter.Name, ((StringParam)parameter).Value?.ToString());
  2561. else if (parameter is ComboxParam)
  2562. nodeConfig.SetAttribute(parameter.Name, ((ComboxParam)parameter).Value.ToString());
  2563. else if (parameter is LoopComboxParam)
  2564. nodeConfig.SetAttribute(parameter.Name, ((LoopComboxParam)parameter).Value.ToString());
  2565. else if (parameter is PositionParam)
  2566. nodeConfig.SetAttribute(parameter.Name, ((PositionParam)parameter).Value.ToString());
  2567. else if (parameter is BoolParam)
  2568. nodeConfig.SetAttribute(parameter.Name, ((BoolParam)parameter).Value.ToString());
  2569. else if (parameter is StepParam)
  2570. nodeConfig.SetAttribute(parameter.Name, ((StepParam)parameter).Value.ToString());
  2571. else if (parameter is MultipleSelectParam)
  2572. {
  2573. List<string> selected = new List<string>();
  2574. ((MultipleSelectParam)parameter).Options.Apply(
  2575. opt =>
  2576. {
  2577. if (opt.IsChecked)
  2578. selected.Add(opt.ControlName);
  2579. }
  2580. );
  2581. nodeConfig.SetAttribute(parameter.Name, string.Join(",", selected));
  2582. }
  2583. }
  2584. }
  2585. nodeModule.AppendChild(nodeConfig);
  2586. }
  2587. else
  2588. {
  2589. var CurrentTableSteps = Tables.FirstOrDefault(x => x.Index == TableIndex).TableData.Steps;
  2590. CurrentTableSteps.Clear();
  2591. Steps.ToList().ForEach(x => CurrentTableSteps.Add(x));
  2592. CreateTablesXml(nodeData);
  2593. foreach (var item in Tables)
  2594. {
  2595. List<XmlElement> StepsXmlElement = new List<XmlElement>();
  2596. foreach (Step parameters in item.TableData.Steps)
  2597. {
  2598. StepsXmlElement.Add(StepToXmlElement(parameters));
  2599. }
  2600. SaveTables(nodeData, StepsXmlElement, item.Index);
  2601. }
  2602. }
  2603. return _doc.OuterXml;
  2604. }
  2605. public static string GetPressPidValue(Step parameters)
  2606. {
  2607. string cmd = parameters.PressCommand.Value;
  2608. if (cmd == "Slow Vac" || cmd == "Valve Angle" || cmd == "Full Open" || cmd == "Full Close" || cmd == "Hold" ||
  2609. cmd == "WaitPressUp1" || cmd == "WaitPressDown1" || cmd == "WaitPressUp2" || cmd == "WaitPressDown2" || cmd == "Zero Set" || cmd == "Cancel Zero")
  2610. {
  2611. return "";
  2612. }
  2613. return parameters.PressPID.Value.Replace(",", ":");
  2614. }
  2615. public static string GetPressSetValue(Step parameters)
  2616. {
  2617. string rtn = "0";
  2618. string cmd = parameters.PressCommand.Value;
  2619. if (cmd == "Press" || cmd == "Press2")
  2620. {
  2621. rtn = parameters.PressSet.Value;
  2622. }
  2623. return rtn;
  2624. }
  2625. public static string GetPressSlowVacSet(Step parameters)
  2626. {
  2627. string rtn = "0";
  2628. string cmd = parameters.PressCommand.Value;
  2629. if (cmd == "Slow Vac")
  2630. {
  2631. rtn = parameters.PressSlowVacSet.Value;
  2632. }
  2633. return rtn;
  2634. }
  2635. public static string GetValveAngleSet(Step parameters)
  2636. {
  2637. string rtn = "0";
  2638. string cmd = parameters.PressCommand.Value;
  2639. if (cmd == "Valve Angle")
  2640. {
  2641. rtn = parameters.PressValveAngleSet.Value;
  2642. }
  2643. return rtn;
  2644. }
  2645. public static string GetWaitPress(Step parameters)
  2646. {
  2647. string rtn = "0";
  2648. string cmd = parameters.PressCommand.Value;
  2649. if (cmd == "WaitPressUp1" || cmd == "WaitPressDown1" || cmd == "WaitPressUp2" || cmd == "WaitPressDown2")
  2650. {
  2651. rtn = parameters.WaitPress.Value;
  2652. }
  2653. return rtn;
  2654. }
  2655. private XmlElement StepToXmlElement(Step parameters)
  2656. {
  2657. XmlElement nodeStep = _doc.CreateElement("Step");
  2658. if (ToleranceEnable)
  2659. {
  2660. //nodeStep.AppendChild(nodeWarning);
  2661. //nodeStep.AppendChild(nodeAlarm);
  2662. }
  2663. nodeStep.SetAttribute("StepNo", parameters.StepNo.ToString());
  2664. nodeStep.SetAttribute("Name", parameters.Name);
  2665. nodeStep.SetAttribute("EndBy", parameters.EndBy);
  2666. nodeStep.SetAttribute("Time", parameters.Time);
  2667. nodeStep.SetAttribute("SkipWait", parameters.SkipWait);
  2668. nodeStep.SetAttribute("Command", parameters.Command);
  2669. nodeStep.SetAttribute("AlarmIsSaved", parameters.AlarmIsSaved.ToString());
  2670. nodeStep.SetAttribute("MFCIsSaved", parameters.MFCIsSaved.ToString());
  2671. nodeStep.SetAttribute("ValveIsSaved", parameters.ValveIsSaved.ToString());
  2672. nodeStep.SetAttribute("PressIsSaved", parameters.PressIsSaved.ToString());
  2673. nodeStep.SetAttribute("AUXIsSaved", parameters.AUXIsSaved.ToString());
  2674. nodeStep.SetAttribute("TemperatureIsSaved", parameters.TemperatureIsSaved.ToString());
  2675. if (parameters.IsnoneConditionCheck)
  2676. {
  2677. nodeStep.SetAttribute("ConditionCheck", "none");
  2678. }
  2679. else
  2680. {
  2681. nodeStep.SetAttribute("ConditionCheck", GetConditionCheckXmlString(parameters));
  2682. }
  2683. nodeStep.SetAttribute("AlarmConditionTable", parameters.AlarmConditionTable.Value);
  2684. nodeStep.SetAttribute("AbortRecipeTableIndex", parameters.AbortRecipeTableIndex);
  2685. foreach (var item in parameters.ValveSets)
  2686. {
  2687. nodeStep.SetAttribute(item.Name, item.Value ? "Open" : "Close");
  2688. }
  2689. foreach (var item in parameters.MFCSets)
  2690. {
  2691. nodeStep.SetAttribute($"{item.ControlName}.Flow.IsSaved", item.IsSaved.ToString());
  2692. nodeStep.SetAttribute($"{item.ControlName}.Flow.Set", item.SetValue.Value);
  2693. nodeStep.SetAttribute($"{item.ControlName}.Flow.SetUnit", item.SetUnit.Value);
  2694. nodeStep.SetAttribute($"{item.ControlName}.Flow.Ramprate", item.Rampng.Value);
  2695. nodeStep.SetAttribute($"{item.ControlName}.Flow.RamprateUnit", item.RampngUnit.Value);
  2696. nodeStep.SetAttribute($"{item.ControlName}.Flow.Check", item.IsCheck.Value.ToString());
  2697. nodeStep.SetAttribute($"{item.ControlName}.Flow.High", item.MaxValue.Value.ToString());
  2698. nodeStep.SetAttribute($"{item.ControlName}.Flow.Low", item.MinValue.Value.ToString());
  2699. nodeStep.SetAttribute($"{item.ControlName}.Flow.Unit", item.Unit);
  2700. }
  2701. foreach (var item in parameters.MFMSets)
  2702. {
  2703. nodeStep.SetAttribute(item.Key, parameters.MFMSets[item.Key].ToString());
  2704. }
  2705. foreach (var item in parameters.EXOUSets.Keys)
  2706. {
  2707. nodeStep.SetAttribute(item, parameters.EXOUSets[item].ToString());
  2708. }
  2709. foreach (var item in parameters.TemperatureSets)
  2710. {
  2711. nodeStep.SetAttribute($"{item.Name}.ZoneName", item.Name);
  2712. nodeStep.SetAttribute($"{item.Name}.Set", item.SetValue.Value);
  2713. nodeStep.SetAttribute($"{item.Name}.SetUnit", item.SetUnit.Value);
  2714. nodeStep.SetAttribute($"{item.Name}.Ramprate", item.RampngValue.Value);
  2715. nodeStep.SetAttribute($"{item.Name}.RamprateUnit", item.RampngUnit.Value);
  2716. nodeStep.SetAttribute($"{item.Name}.Check", item.IsCheck.Value.ToString());
  2717. nodeStep.SetAttribute($"{item.Name}.High", item.HighValue.Value.ToString());
  2718. nodeStep.SetAttribute($"{item.Name}.Low", item.LowValue.Value.ToString());
  2719. nodeStep.SetAttribute($"{item.Name}.Unit", item.Unit.ToString());
  2720. }
  2721. nodeStep.SetAttribute("Temperature.ControlMode", parameters.TemperatureControlMode.Value);
  2722. nodeStep.SetAttribute("Temperature.Correct", parameters.TemperatureCorrect.Value);
  2723. nodeStep.SetAttribute("Temperature.PID", parameters.TemperaturePID.Value);
  2724. nodeStep.SetAttribute("Loader.Command", parameters.LoaderCommand.Value);
  2725. nodeStep.SetAttribute("Loader.Speed1", parameters.LoaderSpeed1.Value);
  2726. nodeStep.SetAttribute("Loader.Speed2", parameters.LoaderSpeed2.Value);
  2727. nodeStep.SetAttribute("Loader.Speed3", parameters.LoaderSpeed3.Value);
  2728. nodeStep.SetAttribute("Loader.RPM", parameters.LoaderRPM.Value.ToString());
  2729. nodeStep.SetAttribute("Press.Command", parameters.PressCommand.Value);
  2730. nodeStep.SetAttribute("Press.PID", parameters.PressPID.Value);
  2731. nodeStep.SetAttribute("Press.Set", parameters.PressSet.Value);
  2732. nodeStep.SetAttribute("Press.SlowVacSet", parameters.PressSlowVacSet.Value);
  2733. nodeStep.SetAttribute("Press.ValveAngleSet", parameters.PressValveAngleSet.Value);
  2734. nodeStep.SetAttribute("Press.IsWait", parameters.PressIsWait.Value.ToString());
  2735. nodeStep.SetAttribute("Press.LowWait", parameters.PressLowWait.Value);
  2736. nodeStep.SetAttribute("Press.HighWait", parameters.PressHighWait.Value);
  2737. nodeStep.SetAttribute("Press.WaitUnit", parameters.PressWaitUnit.Value);
  2738. nodeStep.SetAttribute("Press.LowPressWait", parameters.PressLowPressWait.Value);
  2739. nodeStep.SetAttribute("Press.WaitPress", parameters.WaitPress.Value);
  2740. nodeStep.SetAttribute("FilmThickFormula", parameters.FilmThickFormula);
  2741. // nodeStep.SetAttribute("FilmThickFormula", parameters.FilmThickFormula);
  2742. foreach (var item in parameters.AUXSets)
  2743. {
  2744. nodeStep.SetAttribute($"AUX.{item.ControlName}.Set", item.SetValue.Value);
  2745. nodeStep.SetAttribute($"AUX.{item.ControlName}.Check", item.IsCheck.Value.ToString());
  2746. nodeStep.SetAttribute($"AUX.{item.ControlName}.High", item.MaxValue.Value);
  2747. nodeStep.SetAttribute($"AUX.{item.ControlName}.Low", item.MinValue.Value);
  2748. nodeStep.SetAttribute($"AUX.{item.ControlName}.CheckUnit", item.SetUnit.Value);
  2749. }
  2750. return nodeStep;
  2751. }
  2752. public RecipeHistory GetRecipeHistory()
  2753. {
  2754. RecipeHistory recipeHistory = new RecipeHistory();
  2755. recipeHistory.CreatedBy = this.Creator;
  2756. recipeHistory.CreationTime = this.CreateTime;
  2757. recipeHistory.LastRevisedBy = this.Revisor;
  2758. recipeHistory.LastRevisionTime = this.ReviseTime;
  2759. recipeHistory.Recipe_Description = this.Description;
  2760. recipeHistory.Recipe_Type = this.PrefixPath;
  2761. recipeHistory.Recipe_Name = this.Name;
  2762. recipeHistory.Recipe_Path = $"{this.PrefixPath}\\{this.Name}";
  2763. recipeHistory.Recipe_Version = this.RecipeVersion;
  2764. recipeHistory.Recipe_Level = this.RecipeLevel;
  2765. recipeHistory.Recipe_Premission = this.RecipePermission;
  2766. recipeHistory.Recipe_Compare = "";
  2767. recipeHistory.Recipe_Content = GetXmlString();
  2768. return recipeHistory;
  2769. }
  2770. private void LoadConfigs(ObservableCollection<Param> configDefine, XmlNode configNode)
  2771. {
  2772. ConfigItems.Clear();
  2773. foreach (var param in configDefine)
  2774. {
  2775. if (param is DoubleParam param1)
  2776. {
  2777. var config = new DoubleParam()
  2778. {
  2779. Name = param.Name,
  2780. Value = param1.Value,
  2781. DisplayName = param.DisplayName,
  2782. Minimun = param1.Minimun,
  2783. Maximun = param1.Maximun,
  2784. Resolution = param1.Resolution
  2785. };
  2786. if (configNode != null && configNode.Attributes[param1.Name] != null)
  2787. config.Value = configNode.Attributes[param1.Name].Value;
  2788. ConfigItems.Add(config);
  2789. }
  2790. if (param is NumParam paramInt)
  2791. {
  2792. var config = new NumParam()
  2793. {
  2794. Name = paramInt.Name,
  2795. Value = paramInt.Value,
  2796. DisplayName = paramInt.DisplayName,
  2797. };
  2798. if (configNode != null && configNode.Attributes[paramInt.Name] != null)
  2799. {
  2800. int.TryParse(configNode.Attributes[paramInt.Name].Value, out int intValue);
  2801. config.Value = intValue;
  2802. }
  2803. ConfigItems.Add(config);
  2804. }
  2805. if (param is StringParam paramString)
  2806. {
  2807. var config = new StringParam()
  2808. {
  2809. Name = param.Name,
  2810. Value = paramString.Value,
  2811. DisplayName = param.DisplayName,
  2812. };
  2813. if (configNode != null && configNode.Attributes[paramString.Name] != null)
  2814. config.Value = configNode.Attributes[paramString.Name].Value;
  2815. ConfigItems.Add(config);
  2816. }
  2817. }
  2818. }
  2819. public void InitData(string prefixPath, string recipeName, string recipeContent, ObservableCollection<Param> configDefine, string module)
  2820. {
  2821. IsCompatibleWithCurrentFormat = false;
  2822. _module = module;
  2823. Name = recipeName;
  2824. PrefixPath = prefixPath;
  2825. try
  2826. {
  2827. _doc = new XmlDocument();
  2828. _doc.LoadXml(recipeContent);
  2829. if (!LoadHeader(_doc.SelectSingleNode("Aitex/TableRecipeData")))
  2830. return;
  2831. XmlNodeList nodeSteps = _doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{module}']/Step");
  2832. if (nodeSteps == null)
  2833. nodeSteps = _doc.SelectNodes($"Aitex/TableRecipeData/Step");
  2834. LoadSteps(nodeSteps);
  2835. XmlNode nodeConfig =
  2836. _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{module}']/Config");
  2837. if (nodeSteps == null)
  2838. nodeConfig = _doc.SelectSingleNode($"Aitex/TableRecipeData/Config");
  2839. LoadConfigs(configDefine, nodeConfig);
  2840. IsCompatibleWithCurrentFormat = true;
  2841. }
  2842. catch (Exception ex)
  2843. {
  2844. LOG.Write(ex);
  2845. }
  2846. }
  2847. }
  2848. public class Step : PropertyChangedBase
  2849. {
  2850. public delegate void TempValueChangedEventHandler(object sender, SetValueEventArgs e);
  2851. public event TempValueChangedEventHandler TempValueChangedEvent;
  2852. public void OnTempValueChanged(SetValueEventArgs e)
  2853. {
  2854. if (TempValueChangedEvent != null)
  2855. {
  2856. TempValueChangedEvent(this, e);
  2857. }
  2858. }
  2859. public delegate void OhterTempValueChangedEventHandler(object sender, SetValueEventArgs e);
  2860. public event OhterTempValueChangedEventHandler OhterTempValueChangedEvent;
  2861. public void OnOhterTempValueChanged(SetValueEventArgs e)
  2862. {
  2863. if (OhterTempValueChangedEvent != null)
  2864. {
  2865. OhterTempValueChangedEvent(this, e);
  2866. }
  2867. }
  2868. public delegate void MFCValueChangedEventHandler(object sender, SetValueEventArgs e);
  2869. public event MFCValueChangedEventHandler MFCValueChangedEvent;
  2870. public void OnMFCValueChanged(SetValueEventArgs e)
  2871. {
  2872. if (MFCValueChangedEvent != null)
  2873. {
  2874. MFCValueChangedEvent(this, e);
  2875. }
  2876. }
  2877. public delegate void ValveValueChangedEventHandler(object sender, SetValueEventArgs e);
  2878. public event ValveValueChangedEventHandler ValveValueChangedEvent;
  2879. public void OnValveValueChanged(SetValueEventArgs e)
  2880. {
  2881. if (ValveValueChangedEvent != null)
  2882. {
  2883. ValveValueChangedEvent(this, e);
  2884. }
  2885. }
  2886. public delegate void AUXValueChangedEventHandler(object sender, SetValueEventArgs e);
  2887. public event AUXValueChangedEventHandler AUXValueChangedEvent;
  2888. public void OnAUXValueChanged(SetValueEventArgs e)
  2889. {
  2890. if (AUXValueChangedEvent != null)
  2891. {
  2892. AUXValueChangedEvent(this, e);
  2893. }
  2894. }
  2895. public Step()
  2896. {
  2897. SetDelegateEvent();
  2898. }
  2899. public void SetDelegateEvent()
  2900. {
  2901. MFCSetsCollectionChanged();
  2902. TemperatureSetsCollectionChanged();
  2903. ValveSetsCollectionChanged();
  2904. AUXSetsCollectionChanged();
  2905. }
  2906. private void MFCSetsCollectionChanged()
  2907. {
  2908. foreach (var item in MFCSets)
  2909. {
  2910. item.PropertyChanged += MFCIsSaved_PropertyChanged;
  2911. item.ValueChangedEvent += Item_MFCValueChangedEvent;
  2912. }
  2913. MFCSets.CollectionChanged += (s, e) =>
  2914. {
  2915. if (e.OldItems != null)
  2916. {
  2917. foreach (MFCData item in e.OldItems)
  2918. {
  2919. item.PropertyChanged -= MFCIsSaved_PropertyChanged;
  2920. item.ValueChangedEvent -= Item_MFCValueChangedEvent;
  2921. }
  2922. }
  2923. if (e.NewItems != null)
  2924. {
  2925. foreach (MFCData item in e.NewItems)
  2926. {
  2927. item.PropertyChanged += MFCIsSaved_PropertyChanged;
  2928. item.ValueChangedEvent += Item_MFCValueChangedEvent;
  2929. }
  2930. }
  2931. };
  2932. }
  2933. private void TemperatureSetsCollectionChanged()
  2934. {
  2935. foreach (var item in TemperatureSets)
  2936. {
  2937. item.PropertyChanged += TemperatureIsSaved_PropertyChanged;
  2938. item.ValueChangedEvent += Item_TempValueChangedEvent;
  2939. }
  2940. TemperatureSets.CollectionChanged += (s, e) =>
  2941. {
  2942. if (e.OldItems != null)
  2943. {
  2944. foreach (TempSetData item in e.OldItems)
  2945. {
  2946. item.PropertyChanged -= TemperatureIsSaved_PropertyChanged;
  2947. item.ValueChangedEvent -= Item_TempValueChangedEvent;
  2948. }
  2949. }
  2950. if (e.NewItems != null)
  2951. {
  2952. foreach (TempSetData item in e.NewItems)
  2953. {
  2954. item.PropertyChanged += TemperatureIsSaved_PropertyChanged;
  2955. item.ValueChangedEvent += Item_TempValueChangedEvent;
  2956. }
  2957. }
  2958. };
  2959. }
  2960. private void ValveSetsCollectionChanged()
  2961. {
  2962. foreach (var item in ValveSets)
  2963. {
  2964. item.PropertyChanged += ValveIsSaved_PropertyChanged;
  2965. item.ValueChangedEvent += Item_ValveValueChangedEvent;
  2966. }
  2967. ValveSets.CollectionChanged += (s, e) =>
  2968. {
  2969. if (e.OldItems != null)
  2970. {
  2971. foreach (BoolParam item in e.OldItems)
  2972. {
  2973. item.PropertyChanged -= ValveIsSaved_PropertyChanged;
  2974. item.ValueChangedEvent -= Item_ValveValueChangedEvent;
  2975. }
  2976. }
  2977. if (e.NewItems != null)
  2978. {
  2979. foreach (BoolParam item in e.NewItems)
  2980. {
  2981. item.PropertyChanged += ValveIsSaved_PropertyChanged;
  2982. item.ValueChangedEvent += Item_ValveValueChangedEvent;
  2983. }
  2984. }
  2985. };
  2986. }
  2987. private void AUXSetsCollectionChanged()
  2988. {
  2989. foreach (var item in AUXSets)
  2990. {
  2991. item.PropertyChanged += AUXIsSaved_PropertyChanged;
  2992. item.ValueChangedEvent += Item_AUXValueChangedEvent;
  2993. }
  2994. AUXSets.CollectionChanged += (s, e) =>
  2995. {
  2996. if (e.OldItems != null)
  2997. {
  2998. foreach (AUXData item in e.OldItems)
  2999. {
  3000. item.PropertyChanged -= AUXIsSaved_PropertyChanged;
  3001. item.ValueChangedEvent -= Item_AUXValueChangedEvent;
  3002. }
  3003. }
  3004. if (e.NewItems != null)
  3005. {
  3006. foreach (AUXData item in e.NewItems)
  3007. {
  3008. item.PropertyChanged += AUXIsSaved_PropertyChanged;
  3009. item.ValueChangedEvent += Item_AUXValueChangedEvent;
  3010. }
  3011. }
  3012. };
  3013. }
  3014. public void Item_TempValueChangedEvent(object sender, SetValueEventArgs e)
  3015. {
  3016. OnTempValueChanged(e);
  3017. }
  3018. public void Item_MFCValueChangedEvent(object sender, SetValueEventArgs e)
  3019. {
  3020. OnMFCValueChanged(e);
  3021. }
  3022. public void Item_ValveValueChangedEvent(object sender, SetValueEventArgs e)
  3023. {
  3024. OnValveValueChanged(e);
  3025. }
  3026. public void Item_AUXValueChangedEvent(object sender, SetValueEventArgs e)
  3027. {
  3028. OnAUXValueChanged(e);
  3029. }
  3030. public void MFCIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3031. {
  3032. if (e.PropertyName == "IsSaved")
  3033. {
  3034. if (MFCSets.Where(x => x.IsSaved == false).Any())
  3035. {
  3036. MFCIsSaved = false;
  3037. }
  3038. else
  3039. {
  3040. if (MFCSetFlagIsSaved)
  3041. {
  3042. MFCIsSaved = true;
  3043. }
  3044. else
  3045. {
  3046. MFCIsSaved = false;
  3047. }
  3048. }
  3049. }
  3050. }
  3051. public void TemperatureIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3052. {
  3053. if (e.PropertyName == "IsSaved")
  3054. {
  3055. SetTemperatureIsSaved();
  3056. }
  3057. }
  3058. public void ValveIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3059. {
  3060. if (e.PropertyName == "IsSaved")
  3061. {
  3062. if (ValveSets.Where(x => x.IsSaved == false).Any())
  3063. {
  3064. ValveIsSaved = false;
  3065. }
  3066. else
  3067. {
  3068. ValveIsSaved = true;
  3069. }
  3070. }
  3071. }
  3072. public void AUXIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3073. {
  3074. if (e.PropertyName == "IsSaved")
  3075. {
  3076. if (AUXSets.Where(x => x.IsSaved == false).Any())
  3077. {
  3078. AUXIsSaved = false;
  3079. }
  3080. else
  3081. {
  3082. AUXIsSaved = true;
  3083. }
  3084. }
  3085. }
  3086. private void LoaderIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3087. {
  3088. if (e.PropertyName == "IsSaved")
  3089. {
  3090. if (!LoaderCommand.IsSaved || !LoaderSpeed1.IsSaved
  3091. || !LoaderSpeed2.IsSaved || !LoaderSpeed3.IsSaved
  3092. || !LoaderRPM.IsSaved)
  3093. {
  3094. LoaderIsSaved = false;
  3095. }
  3096. else
  3097. {
  3098. LoaderIsSaved = true;
  3099. }
  3100. }
  3101. }
  3102. private void AlarmIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3103. {
  3104. if (e.PropertyName == "IsSaved")
  3105. {
  3106. if (!AlarmConditionTable.IsSaved)
  3107. {
  3108. AlarmIsSaved = false;
  3109. }
  3110. else
  3111. {
  3112. AlarmIsSaved = true;
  3113. }
  3114. }
  3115. else if (e.PropertyName == "Value")
  3116. {
  3117. if (((Param)sender).IsSaved) return;
  3118. SetValueEventArgs setEventArgs = new SetValueEventArgs();
  3119. setEventArgs.Sender = this;
  3120. setEventArgs.ValueName = "Alarm";
  3121. setEventArgs.PropertyName = ((Param)sender).Name;
  3122. if (sender is StringParam)
  3123. {
  3124. setEventArgs.PropertyValue = ((StringParam)sender).Value;
  3125. OnAlarmValueChanged(setEventArgs);
  3126. }
  3127. }
  3128. }
  3129. public delegate void AlarmValueChangedEventHandler(object sender, SetValueEventArgs e);
  3130. public event AlarmValueChangedEventHandler AlarmValueChangedEvent;
  3131. public void OnAlarmValueChanged(SetValueEventArgs e)
  3132. {
  3133. if (AlarmValueChangedEvent != null)
  3134. {
  3135. AlarmValueChangedEvent(this, e);
  3136. }
  3137. }
  3138. private void PressureIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  3139. {
  3140. if (e.PropertyName == "IsSaved")
  3141. {
  3142. if (!PressCommand.IsSaved || !PressPID.IsSaved
  3143. || !PressSet.IsSaved || !PressValveAngleSet.IsSaved
  3144. || !PressSlowVacSet.IsSaved || !PressIsWait.IsSaved
  3145. || !PressLowWait.IsSaved || !PressHighWait.IsSaved
  3146. || !PressWaitUnit.IsSaved || !PressLowPressWait.IsSaved
  3147. || !WaitPress.IsSaved)
  3148. {
  3149. PressIsSaved = false;
  3150. }
  3151. else
  3152. {
  3153. PressIsSaved = true;
  3154. }
  3155. }
  3156. else if (e.PropertyName == "Value")
  3157. {
  3158. if (sender is Param)
  3159. {
  3160. if (((Param)sender).IsSaved) return;
  3161. SetValueEventArgs setEventArgs = new SetValueEventArgs();
  3162. setEventArgs.Sender = this;
  3163. setEventArgs.ValueName = "Press";
  3164. setEventArgs.PropertyName = ((Param)sender).Name;
  3165. if (sender is DoubleParam)
  3166. {
  3167. setEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  3168. OnPressureValueChanged(setEventArgs);
  3169. }
  3170. else if (sender is StringParam)
  3171. {
  3172. setEventArgs.PropertyValue = ((StringParam)sender).Value;
  3173. OnPressureValueChanged(setEventArgs);
  3174. }
  3175. }
  3176. }
  3177. }
  3178. public delegate void PressureValueChangedEventHandler(object sender, SetValueEventArgs e);
  3179. public event PressureValueChangedEventHandler PressureValueChangedEvent;
  3180. public void OnPressureValueChanged(SetValueEventArgs e)
  3181. {
  3182. if (PressureValueChangedEvent != null)
  3183. {
  3184. PressureValueChangedEvent(this, e);
  3185. }
  3186. }
  3187. public delegate void LoaderValueChangedEventHandler(object sender, SetValueEventArgs e);
  3188. public event LoaderValueChangedEventHandler LoaderValueChangedEvent;
  3189. public void OnLoaderValueChanged(SetValueEventArgs e)
  3190. {
  3191. if (LoaderValueChangedEvent != null)
  3192. {
  3193. LoaderValueChangedEvent(this, e);
  3194. }
  3195. }
  3196. private void SetTemperatureIsSaved()
  3197. {
  3198. if (TemperatureSets.Where(x => x.IsSaved == false).Any() || !TemperatureControlMode.IsSaved || !TemperatureCorrect.IsSaved || !TemperaturePID.IsSaved)
  3199. {
  3200. TemperatureIsSaved = false;
  3201. }
  3202. else
  3203. {
  3204. if (TemperatureSetsFlagIsSaved)
  3205. {
  3206. TemperatureIsSaved = true;
  3207. }
  3208. else
  3209. {
  3210. TemperatureIsSaved = false;
  3211. }
  3212. }
  3213. }
  3214. public bool UndoMFCChanges()
  3215. {
  3216. if (MFCIsSaved)
  3217. {
  3218. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3219. DialogType.CONFIRM,
  3220. $"Recipe MFC is changed Flag, do you want to save it?"))
  3221. {
  3222. MFCIsSaved = false;
  3223. MFCSetFlagIsSaved = false;
  3224. }
  3225. }
  3226. else
  3227. {
  3228. MFCSetFlagIsSaved = true;
  3229. foreach (var item in MFCSets)
  3230. {
  3231. item.UndoChanges();
  3232. }
  3233. }
  3234. return true;
  3235. }
  3236. public bool UndoGasChanges()
  3237. {
  3238. if (ValveIsSaved)
  3239. {
  3240. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3241. DialogType.CONFIRM,
  3242. $"Recipe Valve is changed Flag, do you want to save it?"))
  3243. {
  3244. ValveIsSaved = false;
  3245. ValveFlagIsSaved = false;
  3246. }
  3247. }
  3248. else
  3249. {
  3250. ValveFlagIsSaved = true;
  3251. foreach (var item in ValveSets)
  3252. {
  3253. item.UndoChanges();
  3254. }
  3255. }
  3256. return true;
  3257. }
  3258. public bool UndoAUXChanges()
  3259. {
  3260. if (AUXIsSaved)
  3261. {
  3262. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3263. DialogType.CONFIRM,
  3264. $"Recipe AUX is changed Flag, do you want to save it?"))
  3265. {
  3266. AUXIsSaved = false;
  3267. AUXFlagIsSaved = false;
  3268. }
  3269. }
  3270. else
  3271. {
  3272. AUXFlagIsSaved = true;
  3273. foreach (var item in AUXSets)
  3274. {
  3275. item.UndoChanges();
  3276. }
  3277. }
  3278. return true;
  3279. }
  3280. public bool UndoTemperatureChanges()
  3281. {
  3282. if (TemperatureIsSaved)
  3283. {
  3284. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3285. DialogType.CONFIRM,
  3286. $"Recipe Temperature is changed Flag, do you want to save it?"))
  3287. {
  3288. TemperatureIsSaved = false;
  3289. TemperatureSetsFlagIsSaved = false;
  3290. }
  3291. }
  3292. else
  3293. {
  3294. TemperatureSetsFlagIsSaved = true;
  3295. foreach (var item in TemperatureSets)
  3296. {
  3297. item.UndoChanges();
  3298. }
  3299. TemperatureControlMode.UndoChanges();
  3300. TemperatureCorrect.UndoChanges();
  3301. TemperaturePID.UndoChanges();
  3302. }
  3303. return true;
  3304. }
  3305. public bool UndoAlarmChanges()
  3306. {
  3307. if (AlarmIsSaved)
  3308. {
  3309. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3310. DialogType.CONFIRM,
  3311. $"Recipe Alarm is changed Flag, do you want to save it?"))
  3312. {
  3313. AlarmIsSaved = false;
  3314. AlarmFlagIsSaved = false;
  3315. }
  3316. }
  3317. else
  3318. {
  3319. AlarmFlagIsSaved = true;
  3320. AlarmIsSaved = true;
  3321. AlarmConditionTable.UndoChanges();
  3322. }
  3323. return true;
  3324. }
  3325. public bool UndoPressChanges()
  3326. {
  3327. if (PressIsSaved)
  3328. {
  3329. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3330. DialogType.CONFIRM,
  3331. $"Recipe Press is changed Flag, do you want to save it?"))
  3332. {
  3333. PressIsSaved = false;
  3334. PressFlagIsSaved = false;
  3335. }
  3336. }
  3337. else
  3338. {
  3339. PressFlagIsSaved = true;
  3340. PressCommand.UndoChanges();
  3341. PressPID.UndoChanges();
  3342. PressSet.UndoChanges();
  3343. PressSlowVacSet.UndoChanges();
  3344. PressValveAngleSet.UndoChanges();
  3345. PressLowPressWait.UndoChanges();
  3346. WaitPress.UndoChanges();
  3347. }
  3348. return true;
  3349. }
  3350. public bool UndoLoaderChanges()
  3351. {
  3352. if (LoaderIsSaved)
  3353. {
  3354. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  3355. DialogType.CONFIRM,
  3356. $"Recipe Loader is changed Flag, do you want to save it?"))
  3357. {
  3358. LoaderIsSaved = false;
  3359. }
  3360. }
  3361. else
  3362. {
  3363. LoaderIsSaved = true;
  3364. LoaderCommand.UndoChanges();
  3365. LoaderSpeed1.UndoChanges();
  3366. LoaderSpeed2.UndoChanges();
  3367. LoaderSpeed3.UndoChanges();
  3368. LoaderRPM.UndoChanges();
  3369. }
  3370. return true;
  3371. }
  3372. public string Value { get; set; }
  3373. private int _stepNo;
  3374. public int StepNo
  3375. {
  3376. get => _stepNo; set
  3377. {
  3378. _stepNo = value;
  3379. NotifyOfPropertyChange("StepNo");
  3380. }
  3381. }
  3382. private string _name;
  3383. public string Name
  3384. {
  3385. get => _name; set
  3386. {
  3387. _name = value;
  3388. NotifyOfPropertyChange("Name");
  3389. }
  3390. }
  3391. public string EndBy { get; set; }
  3392. public string Time { get; set; }
  3393. public string SkipWait { get; set; }
  3394. public string Command { get; set; }
  3395. public bool IsChecked { get; set; }
  3396. public Visibility IsVisibility { get; set; } = Visibility.Visible;
  3397. public bool IsnoneConditionCheck { get; set; }
  3398. public string[] ExternalSensorName { get; set; } = new string[] { "SensorTubeATMPressure", "SensorASOpenPosition", "SensorASClosePosition", "SensorEXTIN4", "SensorEXTIN5", "SensorEXTIN6", "SensorEXTIN7" };
  3399. public string[] ExternalSensor { get; set; } = new string[] { "None", "None", "None", "None", "None", "None", "None" };
  3400. public string TempStabilizeSelected { get; set; }
  3401. public string FinishAutoProfile { get; set; }
  3402. public string ReachTemp { get; set; }
  3403. public double ReachTempValue { get; set; }
  3404. public string O2Density { get; set; }
  3405. public int O2DensityValue { get; set; }
  3406. public string ReachPressure { get; set; }
  3407. public string ReachPressureVG { get; set; }
  3408. public string PressureStabilizeVG { get; set; }
  3409. public double ReachPressureValue { get; set; }
  3410. public string PressureStabilizeSelected { get; set; }
  3411. public string ProcessTimeToEnd { get; set; }
  3412. //public string PressureSonserValue { get; set; }
  3413. //public string PressureValveAngle { get; set; }
  3414. //public string PressureSettingVG { get; set; }
  3415. //public string SlowVacuumValue { get; set; }
  3416. //public string PressureAlarmTableNo { get; set; }
  3417. //public string ZAxisPosition { get; set; }
  3418. //public string ZAxisSpeed { get; set; }
  3419. //public string RotatePosition { get; set; }
  3420. public string AbortRecipeTableIndex { get; set; }
  3421. //public string RFSwitch { get; set; }
  3422. //public string RFSetpoint { get; set; }
  3423. //public string RFPowerSetpoint { get; set; }
  3424. //public string C1Setpoint { get; set; }
  3425. //public string C2Setpoint { get; set; }
  3426. //public string ForwardPowerAlarmWatchTable { get; set; }
  3427. //public string PrAlarmWatchTable { get; set; }
  3428. //public string PIAlarmWatchTable { get; set; }
  3429. //public string C1AlarmWatchTable { get; set; }
  3430. //public string C2AlarmWatchTable { get; set; }
  3431. //public string VppAlarmWatchTable { get; set; }
  3432. //public string VdcAlarmWatchTable { get; set; }
  3433. /// <summary>
  3434. /// R 轴方向,CCW(逆时针),CW(顺时针)
  3435. /// </summary>
  3436. // public string RotateDirection { get; set; }
  3437. //public string RotateSpeed { get; set; }
  3438. //public string RotateInterval { get; set; }
  3439. //public string APC_SetPressure { get; set; }
  3440. private bool _mFCSetFlagIsSaved = true;
  3441. public bool MFCSetFlagIsSaved
  3442. {
  3443. get => _mFCSetFlagIsSaved;
  3444. set
  3445. {
  3446. _mFCSetFlagIsSaved = value;
  3447. NotifyOfPropertyChange(nameof(MFCSetFlagIsSaved));
  3448. }
  3449. }
  3450. private bool _mFCIsSaved = true;
  3451. public bool MFCIsSaved
  3452. {
  3453. get => _mFCIsSaved;
  3454. set
  3455. {
  3456. _mFCIsSaved = value;
  3457. NotifyOfPropertyChange(nameof(MFCIsSaved));
  3458. }
  3459. }
  3460. private bool _temperatureSetsFlagIsSaved = true;
  3461. public bool TemperatureSetsFlagIsSaved
  3462. {
  3463. get => _temperatureSetsFlagIsSaved;
  3464. set
  3465. {
  3466. _temperatureSetsFlagIsSaved = value;
  3467. NotifyOfPropertyChange(nameof(TemperatureSetsFlagIsSaved));
  3468. }
  3469. }
  3470. private bool _temperatureIsSaved = true;
  3471. public bool TemperatureIsSaved
  3472. {
  3473. get => _temperatureIsSaved;
  3474. set
  3475. {
  3476. _temperatureIsSaved = value;
  3477. NotifyOfPropertyChange(nameof(TemperatureIsSaved));
  3478. }
  3479. }
  3480. private bool _valveFlagIsSaved = true;
  3481. public bool ValveFlagIsSaved
  3482. {
  3483. get => _valveFlagIsSaved;
  3484. set
  3485. {
  3486. _valveFlagIsSaved = value;
  3487. NotifyOfPropertyChange(nameof(ValveFlagIsSaved));
  3488. }
  3489. }
  3490. private bool _valveIsSaved = true;
  3491. public bool ValveIsSaved
  3492. {
  3493. get => _valveIsSaved;
  3494. set
  3495. {
  3496. _valveIsSaved = value;
  3497. NotifyOfPropertyChange(nameof(ValveIsSaved));
  3498. }
  3499. }
  3500. private bool _auxFlagIsSaved = true;
  3501. public bool AUXFlagIsSaved
  3502. {
  3503. get => _auxFlagIsSaved;
  3504. set
  3505. {
  3506. _auxFlagIsSaved = value;
  3507. NotifyOfPropertyChange(nameof(AUXFlagIsSaved));
  3508. }
  3509. }
  3510. private bool _auxIsSaved = true;
  3511. public bool AUXIsSaved
  3512. {
  3513. get => _auxIsSaved;
  3514. set
  3515. {
  3516. _auxIsSaved = value;
  3517. NotifyOfPropertyChange(nameof(AUXIsSaved));
  3518. }
  3519. }
  3520. private bool _loaderIsSaved = true;
  3521. public bool LoaderIsSaved
  3522. {
  3523. get => _loaderIsSaved;
  3524. set
  3525. {
  3526. _loaderIsSaved = value;
  3527. NotifyOfPropertyChange(nameof(LoaderIsSaved));
  3528. }
  3529. }
  3530. private bool _pressFlagIsSaved = true;
  3531. public bool PressFlagIsSaved
  3532. {
  3533. get => _pressFlagIsSaved;
  3534. set
  3535. {
  3536. _pressFlagIsSaved = value;
  3537. NotifyOfPropertyChange(nameof(PressFlagIsSaved));
  3538. }
  3539. }
  3540. private bool _pressIsSaved = true;
  3541. public bool PressIsSaved
  3542. {
  3543. get => _pressIsSaved;
  3544. set
  3545. {
  3546. _pressIsSaved = value;
  3547. NotifyOfPropertyChange(nameof(PressIsSaved));
  3548. }
  3549. }
  3550. private bool _alarmFlagIsSaved = true;
  3551. public bool AlarmFlagIsSaved
  3552. {
  3553. get => _alarmFlagIsSaved;
  3554. set
  3555. {
  3556. _alarmFlagIsSaved = value;
  3557. NotifyOfPropertyChange(nameof(AlarmFlagIsSaved));
  3558. }
  3559. }
  3560. private bool _alarmIsSaved = true;
  3561. public bool AlarmIsSaved
  3562. {
  3563. get => _alarmIsSaved;
  3564. set
  3565. {
  3566. _alarmIsSaved = value;
  3567. NotifyOfPropertyChange(nameof(AlarmIsSaved));
  3568. }
  3569. }
  3570. public string GasLineN2_Flow { get; set; }
  3571. public string GasLineN3_Flow { get; set; }
  3572. public MFMValue MfmD1Flow { get; set; }
  3573. public ObservableCollection<BoolParam> ValveSets { get; set; } = new ObservableCollection<BoolParam>();
  3574. //public Dictionary<string, MFCData> MFCSets { get; set; } = new Dictionary<string, MFCData>();
  3575. public ObservableCollection<MFCData> MFCSets { get; set; } = new ObservableCollection<MFCData>();
  3576. public Dictionary<string, MFMValue> MFMSets { get; set; } = new Dictionary<string, MFMValue>();
  3577. public Dictionary<string, bool> EXOUSets { get; set; } = new Dictionary<string, bool>();
  3578. public ObservableCollection<TempSetData> TemperatureSets { get; set; } = new ObservableCollection<TempSetData>();
  3579. public Dictionary<string, Dictionary<int, VPData>> VPSets { get; set; } = new Dictionary<string, Dictionary<int, VPData>>();
  3580. public ObservableCollection<AUXData> AUXSets { get; set; } = new ObservableCollection<AUXData>();
  3581. private void Temperature_PropertyChanged(object sender, PropertyChangedEventArgs e)
  3582. {
  3583. if (e.PropertyName == nameof(StringParam.IsSaved))
  3584. {
  3585. SetTemperatureIsSaved();
  3586. }
  3587. else if (e.PropertyName == "Value")
  3588. {
  3589. if (sender is Param)
  3590. {
  3591. if (((Param)sender).IsSaved) return;
  3592. SetValueEventArgs setValueEventArgs = new SetValueEventArgs();
  3593. setValueEventArgs.Sender = this;
  3594. setValueEventArgs.ValueName = ((Param)sender).Name;
  3595. setValueEventArgs.PropertyName = ((Param)sender).Name;
  3596. if (sender is DoubleParam)
  3597. {
  3598. setValueEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  3599. OnTempValueChanged(setValueEventArgs);
  3600. }
  3601. else if (sender is StringParam)
  3602. {
  3603. var tempObj = sender as StringParam;
  3604. if (tempObj.Name == "TemperatureControlMode" || tempObj.Name == "TemperatureCorrect" || tempObj.Name == "TemperaturePID")
  3605. setValueEventArgs.PropertyValue = ((StringParam)sender).Value;
  3606. if (((StringParam)sender).OldValue != ((StringParam)sender).Value)
  3607. {
  3608. OnTempValueChanged(setValueEventArgs);
  3609. }
  3610. }
  3611. }
  3612. }
  3613. }
  3614. private void OtherTemperature_PropertyChanged(object sender, PropertyChangedEventArgs e)
  3615. {
  3616. if (e.PropertyName == nameof(StringParam.IsSaved))
  3617. {
  3618. SetTemperatureIsSaved();
  3619. }
  3620. else if (e.PropertyName == "Value")
  3621. {
  3622. if (sender is Param)
  3623. {
  3624. if (((Param)sender).IsSaved) return;
  3625. SetValueEventArgs setValueEventArgs = new SetValueEventArgs();
  3626. setValueEventArgs.Sender = this;
  3627. setValueEventArgs.ValueName = ((Param)sender).Name;
  3628. setValueEventArgs.PropertyName = ((Param)sender).Name;
  3629. if (sender is DoubleParam)
  3630. {
  3631. setValueEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  3632. OnOhterTempValueChanged(setValueEventArgs);
  3633. }
  3634. else if (sender is StringParam)
  3635. {
  3636. var tempObj = sender as StringParam;
  3637. if (tempObj.Name == "TemperatureControlMode" || tempObj.Name == "TemperatureCorrect" || tempObj.Name == "TemperaturePID")
  3638. {
  3639. setValueEventArgs.PropertyValue = ((StringParam)sender).Value;
  3640. //if (((StringParam)sender).OldValue != ((StringParam)sender).Value)
  3641. //{
  3642. OnOhterTempValueChanged(setValueEventArgs);
  3643. //}
  3644. }
  3645. }
  3646. }
  3647. }
  3648. }
  3649. private StringParam _temperatureControlMode;
  3650. public StringParam TemperatureControlMode
  3651. {
  3652. get => _temperatureControlMode;
  3653. set
  3654. {
  3655. _temperatureControlMode = value;
  3656. _temperatureControlMode.PropertyChanged += OtherTemperature_PropertyChanged;
  3657. NotifyOfPropertyChange(nameof(TemperatureControlMode));
  3658. }
  3659. }
  3660. private StringParam _temperatureCorrect;
  3661. public StringParam TemperatureCorrect
  3662. {
  3663. get => _temperatureCorrect;
  3664. set
  3665. {
  3666. _temperatureCorrect = value;
  3667. _temperatureCorrect.PropertyChanged += OtherTemperature_PropertyChanged;
  3668. NotifyOfPropertyChange(nameof(TemperatureCorrect));
  3669. }
  3670. }
  3671. private StringParam _temperaturePID;
  3672. public StringParam TemperaturePID
  3673. {
  3674. get => _temperaturePID;
  3675. set
  3676. {
  3677. _temperaturePID = value;
  3678. _temperaturePID.PropertyChanged += OtherTemperature_PropertyChanged;
  3679. NotifyOfPropertyChange(nameof(TemperaturePID));
  3680. }
  3681. }
  3682. private StringParam _loaderCommand = new StringParam() { Name = "LoaderCommand", Value = "None" };
  3683. public StringParam LoaderCommand
  3684. {
  3685. get => _loaderCommand;
  3686. set
  3687. {
  3688. _loaderCommand = value;
  3689. _loaderCommand.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3690. NotifyOfPropertyChange(nameof(LoaderCommand));
  3691. }
  3692. }
  3693. private DoubleParam _loaderSpeed1 = new DoubleParam() { Name = "LoaderSpeed1", Value = "0" };
  3694. public DoubleParam LoaderSpeed1
  3695. {
  3696. get => _loaderSpeed1;
  3697. set
  3698. {
  3699. _loaderSpeed1 = value;
  3700. _loaderSpeed1.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3701. NotifyOfPropertyChange(nameof(LoaderSpeed1));
  3702. }
  3703. }
  3704. private DoubleParam _loaderSpeed2 = new DoubleParam() { Name = "LoaderSpeed2", Value = "0" };
  3705. public DoubleParam LoaderSpeed2
  3706. {
  3707. get => _loaderSpeed2;
  3708. set
  3709. {
  3710. _loaderSpeed2 = value;
  3711. _loaderSpeed2.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3712. NotifyOfPropertyChange(nameof(LoaderSpeed2));
  3713. }
  3714. }
  3715. private DoubleParam _loaderSpeed3 = new DoubleParam() { Name = "LoaderSpeed3", Value = "0" };
  3716. public DoubleParam LoaderSpeed3
  3717. {
  3718. get => _loaderSpeed3;
  3719. set
  3720. {
  3721. _loaderSpeed3 = value;
  3722. _loaderSpeed3.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3723. NotifyOfPropertyChange(nameof(LoaderSpeed3));
  3724. }
  3725. }
  3726. private DoubleParam _loaderRPM = new DoubleParam() { Name = "LoaderRPM", Value = "0" };
  3727. public DoubleParam LoaderRPM
  3728. {
  3729. get => _loaderRPM;
  3730. set
  3731. {
  3732. _loaderRPM = value;
  3733. _loaderRPM.PropertyChanged += LoaderIsSaved_PropertyChanged;
  3734. NotifyOfPropertyChange(nameof(LoaderRPM));
  3735. }
  3736. }
  3737. public StringParam _pressCommand = new StringParam() { Name = "PressCommand", Value = "None" };
  3738. public StringParam PressCommand
  3739. {
  3740. get => _pressCommand;
  3741. set
  3742. {
  3743. _pressCommand = value;
  3744. _pressCommand.PropertyChanged += PressureIsSaved_PropertyChanged;
  3745. NotifyOfPropertyChange(nameof(PressCommand));
  3746. }
  3747. }
  3748. private StringParam _pressPID = new StringParam() { Name = "PressPID", Value = "" };
  3749. public StringParam PressPID
  3750. {
  3751. get => _pressPID;
  3752. set
  3753. {
  3754. _pressPID = value;
  3755. _pressPID.PropertyChanged += PressureIsSaved_PropertyChanged;
  3756. NotifyOfPropertyChange(nameof(_pressPID));
  3757. }
  3758. }
  3759. private DoubleParam _pressSet = new DoubleParam() { Name = "PressSet", Value = "0" };
  3760. public DoubleParam PressSet
  3761. {
  3762. get => _pressSet;
  3763. set
  3764. {
  3765. _pressSet = value;
  3766. _pressSet.PropertyChanged += PressureIsSaved_PropertyChanged;
  3767. NotifyOfPropertyChange(nameof(PressSet));
  3768. }
  3769. }
  3770. private StringParam _pressValveAngleSet = new StringParam() { Name = "PressValveAngleSet", Value = "0" };
  3771. public StringParam PressValveAngleSet
  3772. {
  3773. get => _pressValveAngleSet;
  3774. set
  3775. {
  3776. _pressValveAngleSet = value;
  3777. _pressValveAngleSet.PropertyChanged += PressureIsSaved_PropertyChanged;
  3778. NotifyOfPropertyChange(nameof(PressValveAngleSet));
  3779. }
  3780. }
  3781. private DoubleParam _pressSlowVacSet = new DoubleParam() { Name = "PressSlowVacSet", Value = "0" };
  3782. public DoubleParam PressSlowVacSet
  3783. {
  3784. get => _pressSlowVacSet;
  3785. set
  3786. {
  3787. _pressSlowVacSet = value;
  3788. _pressSlowVacSet.PropertyChanged += PressureIsSaved_PropertyChanged;
  3789. NotifyOfPropertyChange(nameof(PressSlowVacSet));
  3790. }
  3791. }
  3792. private BoolParam _pressIsWait = new BoolParam() { Name = "PressIsWait", Value = false };
  3793. public BoolParam PressIsWait
  3794. {
  3795. get => _pressIsWait;
  3796. set
  3797. {
  3798. _pressIsWait = value;
  3799. _pressIsWait.PropertyChanged += PressureIsSaved_PropertyChanged;
  3800. NotifyOfPropertyChange(nameof(PressIsWait));
  3801. }
  3802. }
  3803. private StringParam _pressLowWait = new StringParam() { Name = "PressLowWait", Value = "0" };
  3804. public StringParam PressLowWait
  3805. {
  3806. get => _pressLowWait;
  3807. set
  3808. {
  3809. _pressLowWait = value;
  3810. _pressLowWait.PropertyChanged += PressureIsSaved_PropertyChanged;
  3811. NotifyOfPropertyChange(nameof(PressLowWait));
  3812. }
  3813. }
  3814. public StringParam _pressHighWait = new StringParam() { Name = "PressHighWait", Value = "0" };
  3815. public StringParam PressHighWait
  3816. {
  3817. get => _pressHighWait;
  3818. set
  3819. {
  3820. _pressHighWait = value;
  3821. _pressHighWait.PropertyChanged += PressureIsSaved_PropertyChanged;
  3822. NotifyOfPropertyChange(nameof(PressHighWait));
  3823. }
  3824. }
  3825. private StringParam _pressWaitUnit = new StringParam() { Name = "PressWaitUnit", Value = "Torr" };
  3826. public StringParam PressWaitUnit
  3827. {
  3828. get => _pressWaitUnit;
  3829. set
  3830. {
  3831. _pressWaitUnit = value;
  3832. _pressWaitUnit.PropertyChanged += PressureIsSaved_PropertyChanged;
  3833. NotifyOfPropertyChange(nameof(PressWaitUnit));
  3834. }
  3835. }
  3836. private StringParam _pressLowPressWait = new StringParam() { Name = "PressLowPressWait", Value = "None" };
  3837. public StringParam PressLowPressWait
  3838. {
  3839. get => _pressLowPressWait;
  3840. set
  3841. {
  3842. _pressLowPressWait = value;
  3843. _pressLowPressWait.PropertyChanged += PressureIsSaved_PropertyChanged;
  3844. NotifyOfPropertyChange(nameof(PressLowPressWait));
  3845. }
  3846. }
  3847. private StringParam _waitPress = new StringParam() { Name = "WaitPress", Value = "0" };
  3848. public StringParam WaitPress
  3849. {
  3850. get => _waitPress;
  3851. set
  3852. {
  3853. _waitPress = value;
  3854. _waitPress.PropertyChanged += PressureIsSaved_PropertyChanged;
  3855. NotifyOfPropertyChange(nameof(WaitPress));
  3856. }
  3857. }
  3858. //public string TemperatureProfile { get; set; }
  3859. //public string TemperatureAlarm { get; set; }
  3860. //public string CAPTemperatureAlarm { get; set; }
  3861. //public string CAPSetValue { get; set; }
  3862. //public string CAPRampingValue { get; set; }
  3863. //public string TemperatureStabilize { get; set; }
  3864. //public bool TemperatureReadyCond { get; set; }
  3865. private StringParam _alarmConditionTable = new StringParam() { Name = "AlarmConditionTable", Value = "" };
  3866. public StringParam AlarmConditionTable
  3867. {
  3868. get => _alarmConditionTable;
  3869. set
  3870. {
  3871. _alarmConditionTable = value;
  3872. _alarmConditionTable.PropertyChanged += AlarmIsSaved_PropertyChanged;
  3873. NotifyOfPropertyChange(nameof(AlarmConditionTable));
  3874. }
  3875. }
  3876. //public string EventSetting { get; set; }
  3877. public string FilmThickFormula { get; set; }
  3878. public Dictionary<int, AlarmAction> AlarmActionSets { get; set; } = new Dictionary<int, AlarmAction>();
  3879. public string DictionaryStepTime(Dictionary<string, string> steptimes)
  3880. {
  3881. if (steptimes == null) return null;
  3882. StringBuilder rtn = new StringBuilder();
  3883. foreach (var item in steptimes.Keys)
  3884. {
  3885. if (steptimes[item] == "00:00:00") continue;
  3886. rtn.Append($"{item},{steptimes[item]};");
  3887. }
  3888. if (rtn.Length > 0) rtn.Remove(rtn.Length - 1, 1);
  3889. return rtn.ToString();
  3890. }
  3891. public Dictionary<string, string> StepTimeToDictionary(string stepTime)
  3892. {
  3893. Dictionary<string, string> steptimes = new Dictionary<string, string>();
  3894. string[] tempTimes = stepTime.Split(';');
  3895. foreach (var item in tempTimes)
  3896. {
  3897. string[] subTimes = item.Split(',');
  3898. steptimes.Add(subTimes[0], subTimes[1]);
  3899. }
  3900. return steptimes;
  3901. }
  3902. }
  3903. public class AlarmAction
  3904. {
  3905. public string PtocessingType { get; set; }
  3906. public string PtocessingDetails { get; set; }
  3907. }
  3908. public class MFMValue : PropertyChangedBase
  3909. {
  3910. private string _name;
  3911. public string Name
  3912. {
  3913. get => _name;
  3914. set
  3915. {
  3916. _name = value;
  3917. NotifyOfPropertyChange("Name");
  3918. }
  3919. }
  3920. private string _value;
  3921. public string Value
  3922. {
  3923. get => _value;
  3924. set
  3925. {
  3926. _value = value;
  3927. NotifyOfPropertyChange("Value");
  3928. }
  3929. }
  3930. private string _alarmValue;
  3931. public string AlarmValue
  3932. {
  3933. get => _alarmValue; set
  3934. {
  3935. _alarmValue = value;
  3936. NotifyOfPropertyChange("AlarmValue");
  3937. }
  3938. }
  3939. public override string ToString()
  3940. {
  3941. return $"{Value};{AlarmValue}";
  3942. }
  3943. }
  3944. public class MFMData : MFCData
  3945. { }
  3946. public class MFCData : PropertyChangedBase
  3947. {
  3948. public delegate void ValueChangedEventHandler(object sender, SetValueEventArgs e);
  3949. public event ValueChangedEventHandler ValueChangedEvent;
  3950. public MFCData()
  3951. {
  3952. }
  3953. public void OnValueChanged(SetValueEventArgs e)
  3954. {
  3955. if (ValueChangedEvent != null)
  3956. {
  3957. ValueChangedEvent(this, e);
  3958. }
  3959. }
  3960. private bool _flagIsSaved = true;
  3961. public bool FlagIsSaved
  3962. {
  3963. get => _flagIsSaved;
  3964. set
  3965. {
  3966. _flagIsSaved = value;
  3967. NotifyOfPropertyChange(nameof(FlagIsSaved));
  3968. NotifyOfPropertyChange(nameof(IsSaved));
  3969. }
  3970. }
  3971. public bool IsSaved
  3972. {
  3973. get
  3974. {
  3975. if (SetValue.IsSaved && SetUnit.IsSaved && Rampng.IsSaved && RampngUnit.IsSaved && IsCheck.IsSaved && MaxValue.IsSaved && MinValue.IsSaved)
  3976. {
  3977. if (FlagIsSaved)
  3978. {
  3979. return true;
  3980. }
  3981. else
  3982. {
  3983. return false;
  3984. }
  3985. }
  3986. else
  3987. {
  3988. return false;
  3989. }
  3990. }
  3991. }
  3992. public bool UndoChanges()
  3993. {
  3994. Type type = this.GetType();
  3995. PropertyInfo[] properties = type.GetProperties();
  3996. foreach (var item in properties)
  3997. {
  3998. var obj = item.GetValue(this);
  3999. if (obj is Param)
  4000. {
  4001. ((Param)obj).UndoChanges();
  4002. }
  4003. }
  4004. FlagIsSaved = true;
  4005. return true;
  4006. }
  4007. private void ParamIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  4008. {
  4009. if (e.PropertyName == "IsSaved")
  4010. {
  4011. NotifyOfPropertyChange("IsSaved");
  4012. }
  4013. else if (e.PropertyName == "Value")
  4014. {
  4015. if (sender is Param)
  4016. {
  4017. if (((Param)sender).IsSaved) return;
  4018. SetValueEventArgs tempSetEventArgs = new SetValueEventArgs();
  4019. tempSetEventArgs.Sender = this;
  4020. tempSetEventArgs.ValueName = this.ControlName;
  4021. tempSetEventArgs.PropertyName = ((Param)sender).Name;
  4022. if (sender is DoubleParam)
  4023. {
  4024. tempSetEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  4025. OnValueChanged(tempSetEventArgs);
  4026. }
  4027. else if (sender is IntParam)
  4028. {
  4029. tempSetEventArgs.PropertyValue = ((IntParam)sender).Value.ToString();
  4030. OnValueChanged(tempSetEventArgs);
  4031. }
  4032. else if (sender is StringParam)
  4033. {
  4034. tempSetEventArgs.PropertyValue = ((StringParam)sender).Value;
  4035. OnValueChanged(tempSetEventArgs);
  4036. }
  4037. else if (sender is BoolParam)
  4038. {
  4039. tempSetEventArgs.PropertyValue = ((BoolParam)sender).Value.ToString();
  4040. OnValueChanged(tempSetEventArgs);
  4041. }
  4042. }
  4043. }
  4044. }
  4045. private int _no;
  4046. public int No
  4047. {
  4048. get => _no;
  4049. set
  4050. {
  4051. _no = value;
  4052. NotifyOfPropertyChange("No");
  4053. }
  4054. }
  4055. private string _name;
  4056. public string Name
  4057. {
  4058. get => _name;
  4059. set
  4060. {
  4061. _name = value;
  4062. NotifyOfPropertyChange("Name");
  4063. }
  4064. }
  4065. public string _unit;
  4066. public string Unit
  4067. {
  4068. get => _unit;
  4069. set
  4070. {
  4071. _unit = value;
  4072. NotifyOfPropertyChange("Unit");
  4073. }
  4074. }
  4075. private string _scaleValue;
  4076. public string ScaleValue
  4077. {
  4078. get => _scaleValue;
  4079. set
  4080. {
  4081. _scaleValue = value;
  4082. NotifyOfPropertyChange("ScaleValue");
  4083. }
  4084. }
  4085. private string _displayName;
  4086. public string DisplayName
  4087. {
  4088. get => _displayName;
  4089. set
  4090. {
  4091. _displayName = value;
  4092. NotifyOfPropertyChange("DisplayName");
  4093. }
  4094. }
  4095. private string _controlName;
  4096. public string ControlName
  4097. {
  4098. get => _controlName;
  4099. set
  4100. {
  4101. _controlName = value;
  4102. NotifyOfPropertyChange("ControlName");
  4103. }
  4104. }
  4105. private StringParam _setValue;
  4106. public StringParam SetValue
  4107. {
  4108. get => _setValue;
  4109. set
  4110. {
  4111. if (_setValue != null)
  4112. {
  4113. _setValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4114. }
  4115. _setValue = value;
  4116. _setValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4117. NotifyOfPropertyChange(nameof(SetValue));
  4118. }
  4119. }
  4120. private StringParam _setUnit = new StringParam() { Name = "SetUnit", Value = "SLM" };
  4121. public StringParam SetUnit
  4122. {
  4123. get => _setUnit;
  4124. set
  4125. {
  4126. if (_setUnit != null)
  4127. {
  4128. _setUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4129. }
  4130. _setUnit = value;
  4131. _setUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4132. NotifyOfPropertyChange(nameof(SetUnit));
  4133. }
  4134. }
  4135. private StringParam _rampngUnit = new StringParam() { Name = "RampngUnit", Value = "SLM" };
  4136. public StringParam RampngUnit
  4137. {
  4138. get => _rampngUnit;
  4139. set
  4140. {
  4141. if (_rampngUnit != null)
  4142. {
  4143. _rampngUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4144. }
  4145. _rampngUnit = value;
  4146. _rampngUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4147. NotifyOfPropertyChange("RampngUnit");
  4148. }
  4149. }
  4150. private DoubleParam _rampng;
  4151. public DoubleParam Rampng
  4152. {
  4153. get => _rampng;
  4154. set
  4155. {
  4156. if (_rampng != null)
  4157. {
  4158. _rampng.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4159. }
  4160. _rampng = value;
  4161. NotifyOfPropertyChange("Rampng");
  4162. _rampng.PropertyChanged += ParamIsSaved_PropertyChanged;
  4163. }
  4164. }
  4165. private string _alarmValue;
  4166. public string AlarmValue
  4167. {
  4168. get => _alarmValue; set
  4169. {
  4170. _alarmValue = value;
  4171. NotifyOfPropertyChange("AlarmValue");
  4172. }
  4173. }
  4174. private DoubleParam _maxValue = new DoubleParam() { Name = "MaxValue", Value = "0" };
  4175. public DoubleParam MaxValue
  4176. {
  4177. get => _maxValue; set
  4178. {
  4179. if (_maxValue != null)
  4180. {
  4181. _maxValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4182. }
  4183. _maxValue = value;
  4184. _maxValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4185. NotifyOfPropertyChange("MaxValue");
  4186. }
  4187. }
  4188. private DoubleParam _minValue = new DoubleParam() { Name = "MinValue", Value = "0" };
  4189. public DoubleParam MinValue
  4190. {
  4191. get => _minValue; set
  4192. {
  4193. if (_minValue != null)
  4194. {
  4195. _minValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4196. }
  4197. _minValue = value;
  4198. _minValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4199. NotifyOfPropertyChange("MinValue");
  4200. }
  4201. }
  4202. private BoolParam _isCheck = new BoolParam() { Name = "IsCheck", Value = true };
  4203. public BoolParam IsCheck
  4204. {
  4205. get => _isCheck;
  4206. set
  4207. {
  4208. if (_isCheck != null)
  4209. {
  4210. _isCheck.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4211. }
  4212. _isCheck = value;
  4213. _isCheck.PropertyChanged += ParamIsSaved_PropertyChanged;
  4214. NotifyOfPropertyChange("IsCheck");
  4215. }
  4216. }
  4217. private bool _isEnable = true;
  4218. public bool IsEnable
  4219. {
  4220. get => _isEnable;
  4221. set
  4222. {
  4223. _isEnable = value;
  4224. NotifyOfPropertyChange("IsEnable");
  4225. }
  4226. }
  4227. }
  4228. public class TempSetData : PropertyChangedBase
  4229. {
  4230. public delegate void ValueChangedEventHandler(object sender, SetValueEventArgs e);
  4231. public event ValueChangedEventHandler ValueChangedEvent;
  4232. public void OnValueChanged(SetValueEventArgs e)
  4233. {
  4234. if (ValueChangedEvent != null)
  4235. {
  4236. ValueChangedEvent(this, e);
  4237. }
  4238. }
  4239. public TempSetData() { }
  4240. public bool UndoChanges()
  4241. {
  4242. Type type = this.GetType();
  4243. PropertyInfo[] properties = type.GetProperties();
  4244. foreach (var item in properties)
  4245. {
  4246. var obj = item.GetValue(this);
  4247. if (obj is Param)
  4248. {
  4249. ((Param)obj).UndoChanges();
  4250. }
  4251. }
  4252. return true;
  4253. }
  4254. public bool IsSaved
  4255. {
  4256. get => SetValue.IsSaved && SetUnit.IsSaved && RampngValue.IsSaved && RampngUnit.IsSaved && IsCheck.IsSaved && HighValue.IsSaved && LowValue.IsSaved;
  4257. }
  4258. public TempSetData(string name)
  4259. {
  4260. No = 1;
  4261. Name = name;
  4262. SetValue = new StringParam() { Name = "SetValue", Value = "0" };
  4263. SetUnit = new StringParam() { Name = "SetUnit", Value = "℃" };
  4264. RampngValue = new DoubleParam() { Name = "RampngValue", Value = "0" };
  4265. RampngUnit = new StringParam() { Name = "RampngUnit", Value = "℃/min" };
  4266. IsCheck = new BoolParam() { Name = "IsCheck", Value = false };
  4267. HighValue = new DoubleParam() { Name = "HighValue", Value = "0" };
  4268. LowValue = new DoubleParam() { Name = "LowValue", Value = "0" };
  4269. Unit = "℃";
  4270. }
  4271. private void ParamIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  4272. {
  4273. if (e.PropertyName == nameof(Param.IsSaved))
  4274. {
  4275. NotifyOfPropertyChange(nameof(IsSaved));
  4276. }
  4277. else if (e.PropertyName == "Value")
  4278. {
  4279. if (sender is Param)
  4280. {
  4281. if (((Param)sender).IsSaved) return;
  4282. SetValueEventArgs tempSetEventArgs = new SetValueEventArgs();
  4283. tempSetEventArgs.Sender = this;
  4284. tempSetEventArgs.ValueName = Name;
  4285. tempSetEventArgs.PropertyName = ((Param)sender).Name;
  4286. if (sender is DoubleParam)
  4287. {
  4288. tempSetEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  4289. OnValueChanged(tempSetEventArgs);
  4290. }
  4291. else if (sender is StringParam)
  4292. {
  4293. tempSetEventArgs.PropertyValue = ((StringParam)sender).Value;
  4294. OnValueChanged(tempSetEventArgs);
  4295. }
  4296. }
  4297. }
  4298. }
  4299. public TempSetData(string name, string value) : this(name)
  4300. {
  4301. var listStr = value.Split(';');
  4302. No = 1;
  4303. if (listStr.Length > 8)
  4304. {
  4305. Name = listStr[0];
  4306. SetValue.Value = listStr[1];
  4307. SetUnit.Value = listStr[2];
  4308. RampngValue.Value = listStr[3];
  4309. RampngUnit.Value = listStr[4];
  4310. bool.TryParse(listStr[5], out bool isCheck);
  4311. IsCheck.Value = isCheck;
  4312. double.TryParse(listStr[6], out double highValue);
  4313. HighValue.Value = highValue.ToString();
  4314. double.TryParse(listStr[7], out double lowValue);
  4315. LowValue.Value = lowValue.ToString();
  4316. Unit = listStr[8];
  4317. }
  4318. }
  4319. private int _no;
  4320. public int No
  4321. {
  4322. get => _no;
  4323. set
  4324. {
  4325. _no = value;
  4326. NotifyOfPropertyChange("No");
  4327. }
  4328. }
  4329. private string _name;
  4330. public string Name
  4331. {
  4332. get => _name;
  4333. set
  4334. {
  4335. _name = value;
  4336. NotifyOfPropertyChange("Name");
  4337. }
  4338. }
  4339. private string _displayName;
  4340. public string DisplayName
  4341. {
  4342. get => _displayName;
  4343. set
  4344. {
  4345. _displayName = value;
  4346. NotifyOfPropertyChange("DisplayName");
  4347. }
  4348. }
  4349. private StringParam _setValue;
  4350. public StringParam SetValue
  4351. {
  4352. get => _setValue;
  4353. set
  4354. {
  4355. if (_setValue != null)
  4356. {
  4357. _setValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4358. }
  4359. _setValue = value;
  4360. _setValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4361. NotifyOfPropertyChange("SetValue");
  4362. }
  4363. }
  4364. private StringParam _setUnit;
  4365. public StringParam SetUnit
  4366. {
  4367. get => _setUnit;
  4368. set
  4369. {
  4370. if (_setUnit != null)
  4371. {
  4372. _setUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4373. }
  4374. _setUnit = value;
  4375. _setUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4376. NotifyOfPropertyChange("SetUnit");
  4377. }
  4378. }
  4379. private DoubleParam _rampngValue;
  4380. public DoubleParam RampngValue
  4381. {
  4382. get => _rampngValue;
  4383. set
  4384. {
  4385. if (_rampngValue != null)
  4386. {
  4387. _rampngValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4388. }
  4389. _rampngValue = value;
  4390. _rampngValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4391. NotifyOfPropertyChange("RampngValue");
  4392. }
  4393. }
  4394. private StringParam _rampngUnit;
  4395. public StringParam RampngUnit
  4396. {
  4397. get => _rampngUnit;
  4398. set
  4399. {
  4400. if (_rampngUnit != null)
  4401. {
  4402. _rampngUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4403. }
  4404. _rampngUnit = value;
  4405. _rampngUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4406. NotifyOfPropertyChange("RampngUnit");
  4407. }
  4408. }
  4409. private StringParam _alarmValue;
  4410. public StringParam AlarmValue
  4411. {
  4412. get => _alarmValue;
  4413. set
  4414. {
  4415. _alarmValue = value;
  4416. NotifyOfPropertyChange("AlarmValue");
  4417. }
  4418. }
  4419. private BoolParam _isCheck;
  4420. public BoolParam IsCheck
  4421. {
  4422. get => _isCheck;
  4423. set
  4424. {
  4425. if (_isCheck != null)
  4426. {
  4427. _isCheck.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4428. }
  4429. _isCheck = value;
  4430. _isCheck.PropertyChanged += ParamIsSaved_PropertyChanged;
  4431. NotifyOfPropertyChange("IsCheck");
  4432. }
  4433. }
  4434. private DoubleParam _highValue;
  4435. public DoubleParam HighValue
  4436. {
  4437. get => _highValue;
  4438. set
  4439. {
  4440. if (_highValue != null)
  4441. {
  4442. _highValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4443. }
  4444. _highValue = value;
  4445. _highValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4446. NotifyOfPropertyChange("HighValue");
  4447. }
  4448. }
  4449. private DoubleParam _lowValue;
  4450. public DoubleParam LowValue
  4451. {
  4452. get => _lowValue;
  4453. set
  4454. {
  4455. if (_lowValue != null)
  4456. {
  4457. _lowValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4458. }
  4459. _lowValue = value;
  4460. _lowValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4461. NotifyOfPropertyChange("LowValue");
  4462. }
  4463. }
  4464. private string _unit;
  4465. public string Unit
  4466. {
  4467. get => _unit;
  4468. set
  4469. {
  4470. _unit = value;
  4471. NotifyOfPropertyChange("Unit");
  4472. }
  4473. }
  4474. public override string ToString()
  4475. {
  4476. return $"{Name};{SetValue.Value};{SetUnit.Value};{RampngValue.Value};{RampngUnit.Value};{IsCheck.Value};{HighValue.Value};{LowValue.Value};{Unit}";
  4477. }
  4478. }
  4479. public class VPData : PropertyChangedBase
  4480. {
  4481. private int _no;
  4482. public int No
  4483. {
  4484. get => _no;
  4485. set
  4486. {
  4487. _no = value;
  4488. NotifyOfPropertyChange("No");
  4489. }
  4490. }
  4491. private string _name;
  4492. public string Name
  4493. {
  4494. get => _name;
  4495. set
  4496. {
  4497. _name = value;
  4498. NotifyOfPropertyChange("Name");
  4499. }
  4500. }
  4501. private bool _isCheck;
  4502. public bool IsCheck
  4503. {
  4504. get => _isCheck;
  4505. set
  4506. {
  4507. _isCheck = value;
  4508. NotifyOfPropertyChange("IsCheck");
  4509. }
  4510. }
  4511. }
  4512. public class Combination : PropertyChangedBase
  4513. {
  4514. public ObservableCollection<Param> Params = new ObservableCollection<Param>();
  4515. public Combination() { }
  4516. public Combination(ObservableCollection<Param> value) : base()
  4517. {
  4518. if (value != null && value.Count > 0)
  4519. {
  4520. Params = value;
  4521. StringParam subRecipe = value.FirstOrDefault(x => x.Name == "Combination.SubRecipe") as StringParam;
  4522. this.SubRecipePath = subRecipe != null ? subRecipe.Value : "";
  4523. StringParam alarmRecipe = value.FirstOrDefault(x => x.Name == "Combination.AlarmRecipe") as StringParam;
  4524. this.AlarmRecipePath = alarmRecipe != null ? alarmRecipe.Value : "";
  4525. StringParam alarmCondition = value.FirstOrDefault(x => x.Name == "Combination.AlarmCondition") as StringParam;
  4526. this.AlarmCondition = alarmCondition != null ? alarmCondition.Value : "";
  4527. StringParam leakCheck = value.FirstOrDefault(x => x.Name == "Combination.LeakCheck") as StringParam;
  4528. this.LeakCheck = leakCheck != null ? leakCheck.Value : "";
  4529. StringParam abortRecipe = value.FirstOrDefault(x => x.Name == "Combination.AbortRecipe") as StringParam;
  4530. this.AbortRecipePath = abortRecipe != null ? abortRecipe.Value : "";
  4531. StringParam pressAPCPID = value.FirstOrDefault(x => x.Name == "Combination.PressAPCPID") as StringParam;
  4532. this.PressAPC = pressAPCPID != null ? pressAPCPID.Value : "";
  4533. StringParam tempCorrection = value.FirstOrDefault(x => x.Name == "Combination.TempCorrection") as StringParam;
  4534. this.TempCorrection = tempCorrection != null ? tempCorrection.Value : "";
  4535. StringParam tempPID = value.FirstOrDefault(x => x.Name == "Combination.TempPID") as StringParam;
  4536. this.TempPID = tempPID != null ? tempPID.Value : "";
  4537. StringParam profileCondition = value.FirstOrDefault(x => x.Name == "Combination.ProfileCondition") as StringParam;
  4538. this.ProfileCondition = profileCondition != null ? profileCondition.Value : "";
  4539. StringParam n2PurgeMode = value.FirstOrDefault(x => x.Name == "N2PurgeMode") as StringParam;
  4540. this.N2PurgeMode = n2PurgeMode != null ? n2PurgeMode.Value : "None";
  4541. }
  4542. }
  4543. public Combination(string value) : base()
  4544. {
  4545. SetCombinationValue(value);
  4546. }
  4547. public void SetCombinationValue(string value)
  4548. {
  4549. if (string.IsNullOrEmpty(value) || !value.Contains(";")) return;
  4550. var strList = value.Split(';');
  4551. foreach (var item in strList)
  4552. {
  4553. var subStrList = item.Split(':');
  4554. if (string.IsNullOrEmpty(subStrList[0]) || subStrList.Length != 2) continue;
  4555. switch (subStrList[0])
  4556. {
  4557. case "SubRecipePath":
  4558. SubRecipePath = subStrList[1];
  4559. break;
  4560. case "AlarmRecipePath":
  4561. AlarmRecipePath = subStrList[1];
  4562. break;
  4563. case "AbortRecipePath":
  4564. AbortRecipePath = subStrList[1];
  4565. break;
  4566. case "AlarmCondition":
  4567. AlarmCondition = subStrList[1];
  4568. break;
  4569. case "LeakCheck":
  4570. LeakCheck = subStrList[1];
  4571. break;
  4572. case "PressAPC":
  4573. PressAPC = subStrList[1];
  4574. break;
  4575. case "TempCorrect":
  4576. TempCorrection = subStrList[1];
  4577. break;
  4578. case "TempPID":
  4579. TempPID = subStrList[1];
  4580. break;
  4581. case "ProfileCondition":
  4582. ProfileCondition = subStrList[1];
  4583. break;
  4584. default:
  4585. break;
  4586. }
  4587. }
  4588. }
  4589. private string _subRecipePath = "";
  4590. public string SubRecipePath
  4591. {
  4592. get => _subRecipePath;
  4593. set
  4594. {
  4595. _subRecipePath = value;
  4596. NotifyOfPropertyChange("SubRecipePath");
  4597. }
  4598. }
  4599. private string _alarmRecipePath = "";
  4600. public string AlarmRecipePath
  4601. {
  4602. get => _alarmRecipePath;
  4603. set
  4604. {
  4605. _alarmRecipePath = value;
  4606. NotifyOfPropertyChange("AlarmRecipePath");
  4607. }
  4608. }
  4609. private string _alarmCondition = "";
  4610. public string AlarmCondition
  4611. {
  4612. get => _alarmCondition;
  4613. set
  4614. {
  4615. _alarmCondition = value;
  4616. NotifyOfPropertyChange("AlarmCondition");
  4617. }
  4618. }
  4619. private string _leakCheck = "";
  4620. public string LeakCheck
  4621. {
  4622. get => _leakCheck;
  4623. set
  4624. {
  4625. _leakCheck = value;
  4626. NotifyOfPropertyChange("LeakCheck");
  4627. }
  4628. }
  4629. private string _AbortRecipePath = "";
  4630. public string AbortRecipePath
  4631. {
  4632. get => _AbortRecipePath;
  4633. set
  4634. {
  4635. _AbortRecipePath = value;
  4636. NotifyOfPropertyChange("AbortRecipePath");
  4637. }
  4638. }
  4639. private string _pressAPC = "";
  4640. public string PressAPC
  4641. {
  4642. get => _pressAPC;
  4643. set
  4644. {
  4645. _pressAPC = value;
  4646. NotifyOfPropertyChange("PressAPC");
  4647. }
  4648. }
  4649. private string _tempCorrection = "";
  4650. public string TempCorrection
  4651. {
  4652. get => _tempCorrection;
  4653. set
  4654. {
  4655. _tempCorrection = value;
  4656. NotifyOfPropertyChange("TempCorrection");
  4657. }
  4658. }
  4659. private string _tempPID = "";
  4660. public string TempPID
  4661. {
  4662. get => _tempPID;
  4663. set
  4664. {
  4665. _tempPID = value;
  4666. NotifyOfPropertyChange("TempPID");
  4667. }
  4668. }
  4669. private string _profileCondition = "";
  4670. public string ProfileCondition
  4671. {
  4672. get => _profileCondition;
  4673. set
  4674. {
  4675. _profileCondition = value;
  4676. NotifyOfPropertyChange("ProfileCondition");
  4677. }
  4678. }
  4679. private string _n2PurgeMode = "None";
  4680. public string N2PurgeMode
  4681. {
  4682. get => _n2PurgeMode;
  4683. set
  4684. {
  4685. _n2PurgeMode = value;
  4686. NotifyOfPropertyChange("N2PurgeMode");
  4687. }
  4688. }
  4689. public delegate void ChangedValueHandler(string type, string value);
  4690. public event ChangedValueHandler ChangedValueEvent;
  4691. private void ChangedSelectedFileName(string type, string value)
  4692. {
  4693. if (ChangedValueEvent != null)
  4694. {
  4695. ChangedValueEvent(type, value);
  4696. }
  4697. }
  4698. public void SetN2PurgeModeToParam()
  4699. {
  4700. if (Params.Count > 0)
  4701. {
  4702. StringParam n2PurgeMode = Params.FirstOrDefault(x => x.Name == "N2PurgeMode") as StringParam;
  4703. if (n2PurgeMode != null && n2PurgeMode.Value != this.N2PurgeMode)
  4704. {
  4705. n2PurgeMode.Value = this.N2PurgeMode;
  4706. ChangedSelectedFileName("N2PurgeMode", this.N2PurgeMode);
  4707. }
  4708. }
  4709. }
  4710. public void SetValueToParam()
  4711. {
  4712. if (Params.Count > 0)
  4713. {
  4714. StringParam subRecipe = Params.FirstOrDefault(x => x.Name == "Combination.SubRecipe") as StringParam;
  4715. if (subRecipe != null && subRecipe.Value != this.SubRecipePath)
  4716. {
  4717. subRecipe.Value = this.SubRecipePath;
  4718. ChangedSelectedFileName("SubRecipe", this.SubRecipePath);
  4719. }
  4720. StringParam alarmRecipe = Params.FirstOrDefault(x => x.Name == "Combination.AlarmRecipe") as StringParam;
  4721. if (alarmRecipe != null && alarmRecipe.Value != this.AlarmRecipePath)
  4722. {
  4723. alarmRecipe.Value = this.AlarmRecipePath;
  4724. ChangedSelectedFileName("AlarmRecipe", this.AlarmRecipePath);
  4725. }
  4726. StringParam alarmCondition = Params.FirstOrDefault(x => x.Name == "Combination.AlarmCondition") as StringParam;
  4727. if (alarmCondition != null && alarmCondition.Value != this.AlarmCondition)
  4728. {
  4729. alarmCondition.Value = this.AlarmCondition;
  4730. ChangedSelectedFileName("AlarmCondition", this.AlarmCondition);
  4731. }
  4732. StringParam leakCheck = Params.FirstOrDefault(x => x.Name == "Combination.LeakCheck") as StringParam;
  4733. if (leakCheck != null && leakCheck.Value != this.LeakCheck)
  4734. {
  4735. leakCheck.Value = this.LeakCheck;
  4736. ChangedSelectedFileName("LeakCheck", this.LeakCheck);
  4737. }
  4738. StringParam abortRecipe = Params.FirstOrDefault(x => x.Name == "Combination.AbortRecipe") as StringParam;
  4739. if (abortRecipe != null && abortRecipe.Value != this.AbortRecipePath)
  4740. {
  4741. abortRecipe.Value = this.AbortRecipePath;
  4742. ChangedSelectedFileName("AbortRecipe", this.AbortRecipePath);
  4743. }
  4744. StringParam pressAPCPID = Params.FirstOrDefault(x => x.Name == "Combination.PressAPCPID") as StringParam;
  4745. if (pressAPCPID != null && pressAPCPID.Value != this.PressAPC)
  4746. {
  4747. pressAPCPID.Value = this.PressAPC;
  4748. ChangedSelectedFileName("PressAPCPID", this.PressAPC);
  4749. }
  4750. StringParam tempCorrection = Params.FirstOrDefault(x => x.Name == "Combination.TempCorrection") as StringParam;
  4751. if (tempCorrection != null && tempCorrection.Value != this.TempCorrection)
  4752. {
  4753. tempCorrection.Value = this.TempCorrection;
  4754. ChangedSelectedFileName("TempCorrection", this.TempCorrection);
  4755. }
  4756. StringParam tempPID = Params.FirstOrDefault(x => x.Name == "Combination.TempPID") as StringParam;
  4757. if (tempPID != null && tempPID.Value != this.TempPID)
  4758. {
  4759. tempPID.Value = this.TempPID;
  4760. ChangedSelectedFileName("TempPID", this.TempPID);
  4761. }
  4762. StringParam profileCondition = Params.FirstOrDefault(x => x.Name == "Combination.ProfileCondition") as StringParam;
  4763. if (profileCondition != null && profileCondition.Value != this.ProfileCondition)
  4764. {
  4765. profileCondition.Value = this.ProfileCondition;
  4766. ChangedSelectedFileName("ProfileCondition", this.ProfileCondition);
  4767. }
  4768. StringParam n2PurgeMode = Params.FirstOrDefault(x => x.Name == "N2PurgeMode") as StringParam;
  4769. if (n2PurgeMode != null && n2PurgeMode.Value != this.N2PurgeMode)
  4770. {
  4771. n2PurgeMode.Value = this.N2PurgeMode;
  4772. ChangedSelectedFileName("N2PurgeMode", this.N2PurgeMode);
  4773. }
  4774. }
  4775. }
  4776. public override string ToString()
  4777. {
  4778. List<string> strList = new List<string>
  4779. {
  4780. $"SubRecipePath:{SubRecipePath}",
  4781. $"AlarmRecipePath:{AlarmRecipePath}",
  4782. $"AlarmCondition:{AlarmCondition}",
  4783. $"LeakCheck:{LeakCheck}",
  4784. $"AbortRecipePath:{AbortRecipePath}",
  4785. $"PressAPC:{PressAPC}",
  4786. $"TempCorrect:{TempCorrection}",
  4787. $"TempPID:{TempPID}",
  4788. $"ProfileCondition:{ProfileCondition}"
  4789. };
  4790. string toolType = (string)QueryDataClient.Instance.Service.GetConfig("System.SetUp.ToolType");
  4791. if (toolType != null && "SIBCN" == toolType)
  4792. {
  4793. strList.Add($"N2PurgeMode:{N2PurgeMode}");
  4794. }
  4795. return string.Join(";", strList);
  4796. }
  4797. }
  4798. public class AUXData : PropertyChangedBase
  4799. {
  4800. public delegate void ValueChangedEventHandler(object sender, SetValueEventArgs e);
  4801. public event ValueChangedEventHandler ValueChangedEvent;
  4802. public void OnValueChanged(SetValueEventArgs e)
  4803. {
  4804. if (ValueChangedEvent != null)
  4805. {
  4806. ValueChangedEvent(this, e);
  4807. }
  4808. }
  4809. public bool IsSaved
  4810. {
  4811. get => SetValue.IsSaved && SetUnit.IsSaved && Rampng.IsSaved && RampngUnit.IsSaved && IsCheck.IsSaved && MaxValue.IsSaved && MinValue.IsSaved;
  4812. }
  4813. public bool UndoChanges()
  4814. {
  4815. Type type = this.GetType();
  4816. PropertyInfo[] properties = type.GetProperties();
  4817. foreach (var item in properties)
  4818. {
  4819. var obj = item.GetValue(this);
  4820. if (obj is Param)
  4821. {
  4822. ((Param)obj).UndoChanges();
  4823. }
  4824. }
  4825. return true;
  4826. }
  4827. public bool UndoChanges(AUXData oldAUXData)
  4828. {
  4829. Type type = this.GetType();
  4830. PropertyInfo[] properties = type.GetProperties();
  4831. Type oldType = oldAUXData.GetType();
  4832. PropertyInfo[] oldProperties = oldType.GetProperties();
  4833. foreach (var item in properties)
  4834. {
  4835. var oldprop = oldProperties.FirstOrDefault(x => x.Name == item.Name);
  4836. if (oldprop != null)
  4837. {
  4838. var oldObj = oldprop.GetValue(oldAUXData);
  4839. if (oldObj != null)
  4840. {
  4841. var obj = item.GetValue(this);
  4842. if (obj is Param)
  4843. {
  4844. if (oldObj != null && ((Param)oldObj).IsSaved != ((Param)obj).IsSaved)
  4845. ((Param)obj).UndoChanges();
  4846. }
  4847. }
  4848. }
  4849. }
  4850. return true;
  4851. }
  4852. private void ParamIsSaved_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  4853. {
  4854. if (e.PropertyName == nameof(Param.IsSaved))
  4855. {
  4856. NotifyOfPropertyChange("IsSaved");
  4857. }
  4858. else if (e.PropertyName == nameof(DoubleParam.Value))
  4859. {
  4860. if (sender is Param)
  4861. {
  4862. if (((Param)sender).IsSaved) return;
  4863. SetValueEventArgs tempSetEventArgs = new SetValueEventArgs();
  4864. tempSetEventArgs.Sender = this;
  4865. tempSetEventArgs.ValueName = this.ControlName;
  4866. tempSetEventArgs.PropertyName = ((Param)sender).Name;
  4867. if (sender is DoubleParam)
  4868. {
  4869. tempSetEventArgs.PropertyValue = ((DoubleParam)sender).Value;
  4870. OnValueChanged(tempSetEventArgs);
  4871. }
  4872. else if (sender is StringParam)
  4873. {
  4874. tempSetEventArgs.PropertyValue = ((StringParam)sender).Value;
  4875. OnValueChanged(tempSetEventArgs);
  4876. }
  4877. else if (sender is BoolParam)
  4878. {
  4879. tempSetEventArgs.PropertyValue = ((BoolParam)sender).Value.ToString();
  4880. OnValueChanged(tempSetEventArgs);
  4881. }
  4882. }
  4883. }
  4884. }
  4885. private int _no;
  4886. public int No
  4887. {
  4888. get => _no;
  4889. set
  4890. {
  4891. _no = value;
  4892. NotifyOfPropertyChange("No");
  4893. }
  4894. }
  4895. private string _name;
  4896. public string Name
  4897. {
  4898. get => _name;
  4899. set
  4900. {
  4901. _name = value;
  4902. NotifyOfPropertyChange("Name");
  4903. }
  4904. }
  4905. public string _unit;
  4906. public string Unit
  4907. {
  4908. get => _unit;
  4909. set
  4910. {
  4911. _unit = value;
  4912. NotifyOfPropertyChange("Unit");
  4913. }
  4914. }
  4915. private string _displayName;
  4916. public string DisplayName
  4917. {
  4918. get => _displayName;
  4919. set
  4920. {
  4921. _displayName = value;
  4922. NotifyOfPropertyChange("DisplayName");
  4923. }
  4924. }
  4925. private string _controlName;
  4926. public string ControlName
  4927. {
  4928. get => _controlName;
  4929. set
  4930. {
  4931. _controlName = value;
  4932. NotifyOfPropertyChange("ControlName");
  4933. }
  4934. }
  4935. private DoubleParam _setValue;
  4936. public DoubleParam SetValue
  4937. {
  4938. get => _setValue;
  4939. set
  4940. {
  4941. if (_setValue != null)
  4942. {
  4943. _setValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4944. }
  4945. _setValue = value;
  4946. _setValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  4947. NotifyOfPropertyChange(nameof(SetValue));
  4948. }
  4949. }
  4950. private StringParam _setUnit;// = "SLM";
  4951. public StringParam SetUnit
  4952. {
  4953. get => _setUnit;
  4954. set
  4955. {
  4956. if (_setUnit != null)
  4957. {
  4958. _setUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4959. }
  4960. _setUnit = value;
  4961. _setUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4962. NotifyOfPropertyChange(nameof(SetUnit));
  4963. }
  4964. }
  4965. private StringParam _rampngUnit = new StringParam() { Name = "RampngUnit", Value = "SLM" };// = "SLM";
  4966. public StringParam RampngUnit
  4967. {
  4968. get => _rampngUnit;
  4969. set
  4970. {
  4971. if (_rampngUnit != null)
  4972. {
  4973. _rampngUnit.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4974. }
  4975. _rampngUnit = value;
  4976. _rampngUnit.PropertyChanged += ParamIsSaved_PropertyChanged;
  4977. NotifyOfPropertyChange("RampngUnit");
  4978. }
  4979. }
  4980. private DoubleParam _rampng = new DoubleParam() { Name = "Rampng", Value = "0" };
  4981. public DoubleParam Rampng
  4982. {
  4983. get => _rampng; set
  4984. {
  4985. if (_rampng != null)
  4986. {
  4987. _rampng.PropertyChanged -= ParamIsSaved_PropertyChanged;
  4988. }
  4989. _rampng = value;
  4990. _rampng.PropertyChanged += ParamIsSaved_PropertyChanged;
  4991. NotifyOfPropertyChange("Rampng");
  4992. }
  4993. }
  4994. private string _alarmValue;
  4995. public string AlarmValue
  4996. {
  4997. get => _alarmValue; set
  4998. {
  4999. _alarmValue = value;
  5000. NotifyOfPropertyChange("AlarmValue");
  5001. }
  5002. }
  5003. private DoubleParam _maxValue;
  5004. public DoubleParam MaxValue
  5005. {
  5006. get => _maxValue; set
  5007. {
  5008. if (_maxValue != null)
  5009. {
  5010. _maxValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5011. }
  5012. _maxValue = value;
  5013. _maxValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  5014. NotifyOfPropertyChange("MaxValue");
  5015. }
  5016. }
  5017. private DoubleParam _minValue;
  5018. public DoubleParam MinValue
  5019. {
  5020. get => _minValue; set
  5021. {
  5022. if (_minValue != null)
  5023. {
  5024. _minValue.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5025. }
  5026. _minValue = value;
  5027. _minValue.PropertyChanged += ParamIsSaved_PropertyChanged;
  5028. NotifyOfPropertyChange("MinValue");
  5029. }
  5030. }
  5031. private BoolParam _isCheck;
  5032. public BoolParam IsCheck
  5033. {
  5034. get => _isCheck;
  5035. set
  5036. {
  5037. if (_isCheck != null)
  5038. {
  5039. _isCheck.PropertyChanged -= ParamIsSaved_PropertyChanged;
  5040. }
  5041. _isCheck = value;
  5042. _isCheck.PropertyChanged += ParamIsSaved_PropertyChanged;
  5043. NotifyOfPropertyChange("IsCheck");
  5044. }
  5045. }
  5046. private bool _isEnable = true;
  5047. public bool IsEnable
  5048. {
  5049. get => _isEnable;
  5050. set
  5051. {
  5052. _isEnable = value;
  5053. NotifyOfPropertyChange("IsEnable");
  5054. }
  5055. }
  5056. }
  5057. public class SetValueEventArgs : EventArgs
  5058. {
  5059. private Object _sender;
  5060. public Object Sender
  5061. {
  5062. get => _sender;
  5063. set
  5064. {
  5065. _sender = value;
  5066. }
  5067. }
  5068. private string _valueName;
  5069. public string ValueName
  5070. {
  5071. get => _valueName;
  5072. set
  5073. {
  5074. _valueName = value;
  5075. }
  5076. }
  5077. private string _propertyName;
  5078. public string PropertyName
  5079. {
  5080. get => _propertyName;
  5081. set
  5082. {
  5083. _propertyName = value;
  5084. }
  5085. }
  5086. private string _propertyValue;
  5087. public string PropertyValue
  5088. {
  5089. get => _propertyValue;
  5090. set
  5091. {
  5092. _propertyValue = value;
  5093. }
  5094. }
  5095. public SetValueEventArgs()
  5096. {
  5097. }
  5098. }
  5099. }