RecipeDataBase.cs 232 KB

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