RecipeDataBase.cs 232 KB

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