RecipeProcessEditViewModel.cs 141 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.IOCore;
  3. using Aitex.Core.Util;
  4. using Caliburn.Micro;
  5. using Caliburn.Micro.Core;
  6. using DocumentFormat.OpenXml.Bibliography;
  7. using DocumentFormat.OpenXml.Office2010.Excel;
  8. using FurnaceUI.Client.Dialog;
  9. using FurnaceUI.Common;
  10. using FurnaceUI.Models;
  11. using FurnaceUI.Views.Editors;
  12. using FurnaceUI.Views.Parameter;
  13. using Mapster;
  14. using MECF.Framework.Common.Communications;
  15. using MECF.Framework.Common.DataCenter;
  16. using MECF.Framework.Common.OperationCenter;
  17. using MECF.Framework.Common.RecipeCenter;
  18. using MECF.Framework.Common.Utilities;
  19. using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
  20. using MECF.Framework.UI.Client.CenterViews.Dialogs;
  21. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  22. using MECF.Framework.UI.Client.CenterViews.Parameter;
  23. using MECF.Framework.UI.Client.ClientBase;
  24. using OpenSEMI.ClientBase;
  25. using OpenSEMI.Ctrlib.Controls;
  26. using RecipeEditorLib.RecipeModel.Params;
  27. using SciChart.Core.Extensions;
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Collections.ObjectModel;
  31. using System.Linq;
  32. using System.Threading.Tasks;
  33. using System.Windows;
  34. using System.Windows.Controls;
  35. using System.Windows.Input;
  36. using System.Windows.Media;
  37. namespace FurnaceUI.Views.Recipes
  38. {
  39. public class RecipeProcessEditViewModel : FurnaceUIViewModelBase
  40. {
  41. public string DefaultUnit { get; set; }
  42. public string ToolType { get; set; }
  43. public string _defaultUnit
  44. {
  45. get { return DefaultUnit + "/S"; }
  46. }
  47. #region MFCs
  48. [Subscription("PM1.MFC1.DeviceData")]
  49. public AITMfcData MFC1Data { get; set; }
  50. [Subscription("PM1.MFC2.DeviceData")]
  51. public AITMfcData MFC2Data { get; set; }
  52. [Subscription("PM1.MFC3.DeviceData")]
  53. public AITMfcData MFC3Data { get; set; }
  54. [Subscription("PM1.MFC4.DeviceData")]
  55. public AITMfcData MFC4Data { get; set; }
  56. [Subscription("PM1.MFC5.DeviceData")]
  57. public AITMfcData MFC5Data { get; set; }
  58. [Subscription("PM1.MFC6.DeviceData")]
  59. public AITMfcData MFC6Data { get; set; }
  60. [Subscription("PM1.MFC7.DeviceData")]
  61. public AITMfcData MFC7Data { get; set; }
  62. [Subscription("PM1.MFC8.DeviceData")]
  63. public AITMfcData MFC8Data { get; set; }
  64. [Subscription("PM1.MFC9.DeviceData")]
  65. public AITMfcData MFC9Data { get; set; }
  66. [Subscription("PM1.MFC10.DeviceData")]
  67. public AITMfcData MFC10Data { get; set; }
  68. [Subscription("PM1.MFC11.DeviceData")]
  69. public AITMfcData MFC11Data { get; set; }
  70. [Subscription("PM1.MFC12.DeviceData")]
  71. public AITMfcData MFC12Data { get; set; }
  72. [Subscription("PM1.MFC13.DeviceData")]
  73. public AITMfcData MFC13Data { get; set; }
  74. [Subscription("PM1.MFC14.DeviceData")]
  75. public AITMfcData MFC14Data { get; set; }
  76. [Subscription("PM1.MFC15.DeviceData")]
  77. public AITMfcData MFC15Data { get; set; }
  78. [Subscription("PM1.MFC16.DeviceData")]
  79. public AITMfcData MFC16Data { get; set; }
  80. [Subscription("PM1.MFC17.DeviceData")]
  81. public AITMfcData MFC17Data { get; set; }
  82. [Subscription("PM1.MFC31.DeviceData")]
  83. public AITMfcData MFC31Data { get; set; }
  84. [Subscription("PM1.MFC32.DeviceData")]
  85. public AITMfcData MFC32Data { get; set; }
  86. [Subscription("PM1.MFC51.DeviceData")]
  87. public AITMfcData MFC51Data { get; set; }
  88. [Subscription("PM1.MFM57.DeviceData")]
  89. public AITWaterFlowMeterData MFM57Flow { get; set; }
  90. [Subscription("PM1.MFM1.DeviceData")]
  91. public AITWaterFlowMeterData MFM1Flow { get; set; }
  92. #endregion
  93. [Subscription("PM1.EditRecipeStepNo")]
  94. public int EditRecipeStepNo { get; set; }
  95. [Subscription("PM1.EditRecipeName")]
  96. public string EditRecipeName { get; set; }
  97. [Subscription("PM1.EditRecipeStepName")]
  98. public string EditRecipeStepName { get; set; }
  99. private UIElement _parent;
  100. public void SetParent(UIElement parent)
  101. {
  102. _parent = parent;
  103. }
  104. private readonly RecipeProvider _recipeProvider = new RecipeProvider();
  105. private Dictionary<string, ObservableCollection<RecipeTemplateColumnBase>> RecipeTemplate;
  106. private Dictionary<string, string> TemperatureValues { get; set; } = new Dictionary<string, string>();
  107. public ObservableCollection<TempSetData> HeadLst { get; set; } = new ObservableCollection<TempSetData>();
  108. private RecipeDataBase _CurrentRecipe = new RecipeDataBase();
  109. public RecipeDataBase CurrentRecipe
  110. {
  111. get { return _CurrentRecipe; }
  112. set { _CurrentRecipe = value; this.NotifyOfPropertyChange(nameof(CurrentRecipe)); }
  113. }
  114. private double _boatZAxisLimitSpeed;
  115. public double BoatZAxisLimitSpeed
  116. {
  117. get => _boatZAxisLimitSpeed;
  118. set
  119. {
  120. _boatZAxisLimitSpeed = value;
  121. NotifyOfPropertyChange(nameof(BoatZAxisLimitSpeed));
  122. }
  123. }
  124. private double _boatRAxisLimitSpeed;
  125. public double BoatRAxisLimitSpeed
  126. {
  127. get => _boatRAxisLimitSpeed;
  128. set
  129. {
  130. _boatRAxisLimitSpeed = value;
  131. NotifyOfPropertyChange(nameof(BoatRAxisLimitSpeed));
  132. }
  133. }
  134. private bool _isStandbyChecked;
  135. public bool IsStandbyChecked
  136. {
  137. get => _isStandbyChecked;
  138. set
  139. {
  140. _isStandbyChecked = value;
  141. NotifyOfPropertyChange(nameof(IsStandbyChecked));
  142. }
  143. }
  144. private bool _isStandbyCheckedHide;
  145. public bool IsStandbyCheckedHide
  146. {
  147. get => _isStandbyCheckedHide;
  148. set
  149. {
  150. _isStandbyCheckedHide = value;
  151. NotifyOfPropertyChange(nameof(IsStandbyCheckedHide));
  152. }
  153. }
  154. private bool _isStandbyCheckedSelect = false;
  155. private bool _isStandbyEnabled;
  156. public bool IsStandbyEnabled
  157. {
  158. get => _isStandbyEnabled;
  159. set
  160. {
  161. _isStandbyEnabled = value;
  162. NotifyOfPropertyChange(nameof(IsStandbyEnabled));
  163. }
  164. }
  165. private bool _isCommandConditionEventEnabled;
  166. public bool IsCommandConditionEventEnabled
  167. {
  168. get => _isCommandConditionEventEnabled;
  169. set
  170. {
  171. _isCommandConditionEventEnabled = value;
  172. NotifyOfPropertyChange(nameof(IsCommandConditionEventEnabled));
  173. }
  174. }
  175. private Visibility _isProcessVisibility = Visibility.Visible;
  176. public Visibility IsProcessVisibility
  177. {
  178. get => _isProcessVisibility;
  179. set
  180. {
  181. _isProcessVisibility = value;
  182. NotifyOfPropertyChange(nameof(IsProcessVisibility));
  183. }
  184. }
  185. private string _selectBtnName;
  186. public string SelectBtnName
  187. {
  188. get { return _selectBtnName; }
  189. set { _selectBtnName = value; this.NotifyOfPropertyChange(nameof(SelectBtnName)); }
  190. }
  191. private Step _selectedRecipeStep = null;
  192. public Step SelectedRecipeStep
  193. {
  194. get => _selectedRecipeStep;
  195. set
  196. {
  197. _selectedRecipeStep = value;
  198. NotifyOfPropertyChange(nameof(SelectedRecipeStep));
  199. }
  200. }
  201. private int _IndexNoDefault = 0;
  202. public int IndexNoDefault
  203. {
  204. get { return _IndexNoDefault; }
  205. set
  206. {
  207. _IndexNoDefault = value;
  208. NotifyOfPropertyChange(nameof(IndexNoDefault));
  209. }
  210. }
  211. public string SelectedStepName { get; set; }
  212. private int _selectIndex = 0;
  213. public int SelectIndex
  214. {
  215. get { return _selectIndex; }
  216. set
  217. {
  218. _selectIndex = value;
  219. NotifyOfPropertyChange(nameof(SelectIndex));
  220. }
  221. }
  222. private bool _appendStepItemIsEnabled;
  223. public bool AppendStepItemIsEnabled
  224. {
  225. get => _appendStepItemIsEnabled;
  226. set
  227. {
  228. _appendStepItemIsEnabled = value;
  229. NotifyOfPropertyChange(nameof(AppendStepItemIsEnabled));
  230. }
  231. }
  232. private bool _overWriteCopyIsEnabled;
  233. public bool OverWriteCopyIsEnabled
  234. {
  235. get => _overWriteCopyIsEnabled;
  236. set
  237. {
  238. _overWriteCopyIsEnabled = value;
  239. NotifyOfPropertyChange(nameof(OverWriteCopyIsEnabled));
  240. }
  241. }
  242. private bool _insertCopyIsEnabled;
  243. public bool InsertCopyIsEnabled
  244. {
  245. get => _insertCopyIsEnabled;
  246. set
  247. {
  248. _insertCopyIsEnabled = value;
  249. NotifyOfPropertyChange(nameof(InsertCopyIsEnabled));
  250. }
  251. }
  252. private bool _prevStepOverwriteIsEnabled;
  253. public bool PrevStepOverwriteIsEnabled
  254. {
  255. get => _prevStepOverwriteIsEnabled;
  256. set
  257. {
  258. _prevStepOverwriteIsEnabled = value;
  259. NotifyOfPropertyChange(nameof(PrevStepOverwriteIsEnabled));
  260. }
  261. }
  262. private bool _prevStepInsertIsEnabled;
  263. public bool PrevStepInsertIsEnabled
  264. {
  265. get => _prevStepInsertIsEnabled;
  266. set
  267. {
  268. _prevStepInsertIsEnabled = value;
  269. NotifyOfPropertyChange(nameof(PrevStepInsertIsEnabled));
  270. }
  271. }
  272. private bool _prevStepItemIsEnabled;
  273. public bool PrevStepItemIsEnabled
  274. {
  275. get => _prevStepItemIsEnabled;
  276. set
  277. {
  278. _prevStepItemIsEnabled = value;
  279. NotifyOfPropertyChange(nameof(PrevStepItemIsEnabled));
  280. }
  281. }
  282. private bool _currStepDeleteIsEnabled;
  283. public bool CurrStepDeleteIsEnabled
  284. {
  285. get => _currStepDeleteIsEnabled;
  286. set
  287. {
  288. _currStepDeleteIsEnabled = value;
  289. NotifyOfPropertyChange(nameof(CurrStepDeleteIsEnabled));
  290. }
  291. }
  292. private bool _multStepsDeleteIsEnabled;
  293. public bool MultStepsDeleteIsEnabled
  294. {
  295. get => _multStepsDeleteIsEnabled;
  296. set
  297. {
  298. _multStepsDeleteIsEnabled = value;
  299. NotifyOfPropertyChange(nameof(MultStepsDeleteIsEnabled));
  300. }
  301. }
  302. private bool _settingButtonEnable = true;
  303. public bool SettingButtonEnable
  304. {
  305. get => _settingButtonEnable;
  306. set
  307. {
  308. _settingButtonEnable = value;
  309. NotifyOfPropertyChange(nameof(SettingButtonEnable));
  310. }
  311. }
  312. private string _eventSetting;
  313. public string EventSetting
  314. {
  315. get => _eventSetting;
  316. set
  317. {
  318. _eventSetting = value;
  319. NotifyOfPropertyChange(nameof(EventSetting));
  320. }
  321. }
  322. public bool IsEnable => CGlobal.RecipeProcessEditViewEnable;//是否是View模式
  323. RecipeTempSetViewModel recipeTempSetViewModel = null;
  324. #region"Loader Set Value"
  325. private Visibility _loaderSet3SpeedVisibility = Visibility.Hidden;
  326. public Visibility LoaderSet3SpeedVisibility
  327. {
  328. get => _loaderSet3SpeedVisibility;
  329. set
  330. {
  331. _loaderSet3SpeedVisibility = value;
  332. NotifyOfPropertyChange(nameof(LoaderSet3SpeedVisibility));
  333. }
  334. }
  335. private Visibility _loaderSetSpeedVisibility = Visibility.Hidden;
  336. public Visibility LoaderSetSpeedVisibility
  337. {
  338. get => _loaderSetSpeedVisibility;
  339. set
  340. {
  341. _loaderSetSpeedVisibility = value;
  342. NotifyOfPropertyChange(nameof(LoaderSetSpeedVisibility));
  343. }
  344. }
  345. private Visibility _loaderSetSpeedFloatVisibility = Visibility.Hidden;
  346. public Visibility LoaderSetSpeedFloatVisibility
  347. {
  348. get => _loaderSetSpeedFloatVisibility;
  349. set
  350. {
  351. _loaderSetSpeedFloatVisibility = value;
  352. NotifyOfPropertyChange(nameof(LoaderSetSpeedFloatVisibility));
  353. }
  354. }
  355. public bool CommandBtnVisibility
  356. {
  357. get
  358. {
  359. return GetCommandBtnVisibility();
  360. }
  361. set { }
  362. }
  363. public bool CommandBtnHeight
  364. {
  365. get
  366. {
  367. return !CommandBtnVisibility;
  368. }
  369. set { }
  370. }
  371. private bool GetCommandBtnVisibility()
  372. {
  373. List<string> noNeedEndRecipeType = new List<string>() {
  374. "reset"
  375. };
  376. var isContainsType = noNeedEndRecipeType.Contains(CurrentRecipe.PrefixPath.Split('\\').LastOrDefault());
  377. if (null == CurrentRecipe || string.IsNullOrEmpty(CurrentRecipe.PrefixPath) || isContainsType)
  378. {
  379. return false;
  380. }
  381. return true;
  382. }
  383. public void SetShowLoaderValuePanel(string selectedCmd)
  384. {
  385. switch (selectedCmd)
  386. {
  387. case "Boat Load":
  388. case "Boat Unload":
  389. LoaderSet3SpeedVisibility = Visibility.Visible;
  390. LoaderSetSpeedVisibility = Visibility.Hidden;
  391. LoaderSetSpeedFloatVisibility = Visibility.Hidden;
  392. break;
  393. case "Boat Rotate":
  394. LoaderSet3SpeedVisibility = Visibility.Hidden;
  395. LoaderSetSpeedVisibility = Visibility.Hidden;
  396. LoaderSetSpeedFloatVisibility = Visibility.Visible;
  397. break;
  398. case "Boat CAP2":
  399. LoaderSet3SpeedVisibility = Visibility.Hidden;
  400. LoaderSetSpeedVisibility = Visibility.Visible;
  401. LoaderSetSpeedFloatVisibility = Visibility.Hidden;
  402. break;
  403. case "Stop(Include R-axis)":
  404. case "Boat Rotate Stop":
  405. case "Boat Loader Home":
  406. case "None":
  407. case "NONE":
  408. LoaderSet3SpeedVisibility = Visibility.Hidden;
  409. LoaderSetSpeedVisibility = Visibility.Hidden;
  410. LoaderSetSpeedFloatVisibility = Visibility.Hidden;
  411. break;
  412. default:
  413. break;
  414. }
  415. }
  416. //public void SetLoaderValue(string selectedCmd, string Values)
  417. //{
  418. // switch (selectedCmd)
  419. // {
  420. // case "Boat Load":
  421. // case "Boat Unload":
  422. // if (string.IsNullOrEmpty(Values)) return;
  423. // string[] list = Values.Split(';');
  424. // if (list.Length < 3) return;
  425. // Loader3Speed1 = int.Parse(list[0]);
  426. // Loader3Speed2 = int.Parse(list[1]);
  427. // Loader3Speed3 = int.Parse(list[2]);
  428. // break;
  429. // case "Boat Rotate":
  430. // if (string.IsNullOrEmpty(Values)) return;
  431. // LoaderFloatRPM = double.Parse(Values);
  432. // break;
  433. // case "Boat CAP2":
  434. // if (string.IsNullOrEmpty(Values)) return;
  435. // LoaderSpeed = int.Parse(Values);
  436. // break;
  437. // case "Stop(Include R-axis)":
  438. // case "Boat Rotate Stop":
  439. // case "Boat Loader Home":
  440. // case "None":
  441. // break;
  442. // default:
  443. // break;
  444. // }
  445. //}
  446. //public string GetSaveLoaderValue(string selectedCmd)
  447. //{
  448. // switch (selectedCmd)
  449. // {
  450. // case "Boat Load":
  451. // case "Boat Unload":
  452. // return $"{Loader3Speed1};{Loader3Speed2};{Loader3Speed3}";
  453. // case "Boat Rotate":
  454. // return LoaderFloatRPM.ToString();
  455. // case "Boat CAP2":
  456. // return LoaderSpeed.ToString();
  457. // case "Stop(Include R-axis)":
  458. // case "Boat Rotate Stop":
  459. // case "Boat Loader Home":
  460. // case "None":
  461. // return "";
  462. // default:
  463. // return "";
  464. // }
  465. //}
  466. private void ClearLoaderSetValue()
  467. {
  468. if (SelectedRecipeStep != null)
  469. {
  470. SelectedRecipeStep.LoaderSpeed1.Value = "0";
  471. SelectedRecipeStep.LoaderSpeed1.IsSaved = true;
  472. SelectedRecipeStep.LoaderSpeed2.Value = "0";
  473. SelectedRecipeStep.LoaderSpeed2.IsSaved = true;
  474. SelectedRecipeStep.LoaderSpeed3.Value = "0";
  475. SelectedRecipeStep.LoaderSpeed3.IsSaved = true;
  476. SelectedRecipeStep.LoaderRPM.Value = "0";
  477. SelectedRecipeStep.LoaderRPM.IsSaved = true;
  478. }
  479. }
  480. #endregion
  481. #region"PressVisibility"
  482. private Visibility _pressVisibility = Visibility.Hidden;
  483. public Visibility PressVisibility
  484. {
  485. get => _pressVisibility;
  486. set
  487. {
  488. _pressVisibility = value;
  489. NotifyOfPropertyChange(nameof(PressVisibility));
  490. }
  491. }
  492. private Visibility _pressSlowVacVisibility = Visibility.Hidden;
  493. public Visibility PressSlowVacVisibility
  494. {
  495. get => _pressSlowVacVisibility;
  496. set
  497. {
  498. _pressSlowVacVisibility = value;
  499. NotifyOfPropertyChange(nameof(PressSlowVacVisibility));
  500. }
  501. }
  502. private Visibility _pressValveAngleVisibility = Visibility.Hidden;
  503. public Visibility PressValveAngleVisibility
  504. {
  505. get => _pressValveAngleVisibility;
  506. set
  507. {
  508. _pressValveAngleVisibility = value;
  509. NotifyOfPropertyChange(nameof(PressValveAngleVisibility));
  510. }
  511. }
  512. private Visibility _pressWaitVisibility = Visibility.Hidden;
  513. public Visibility PressWaitVisibility
  514. {
  515. get => _pressWaitVisibility;
  516. set
  517. {
  518. _pressWaitVisibility = value;
  519. NotifyOfPropertyChange(nameof(PressWaitVisibility));
  520. }
  521. }
  522. public void SetShowPressPanel(string selectedCmd)
  523. {
  524. if (!"Valve Angle".Equals(selectedCmd))
  525. {
  526. SelectedRecipeStep.PressValveAngleSet.Value = "0";
  527. }
  528. switch (selectedCmd)
  529. {
  530. case "Press":
  531. case "Press2":
  532. case "Valve Angle":
  533. PressWaitBtnIsEnabled = true;
  534. break;
  535. default:
  536. PressWaitBtnIsEnabled = false;
  537. break;
  538. }
  539. PressWaitIsEnabled = false;
  540. switch (selectedCmd)
  541. {
  542. case "None":
  543. PressVisibility = Visibility.Hidden;
  544. PressSlowVacVisibility = Visibility.Hidden;
  545. PressValveAngleVisibility = Visibility.Hidden;
  546. PressWaitVisibility = Visibility.Hidden;
  547. break;
  548. case "Press":
  549. case "Press2":
  550. PressVisibility = Visibility.Visible;
  551. PressSlowVacVisibility = Visibility.Hidden;
  552. PressValveAngleVisibility = Visibility.Hidden;
  553. PressWaitVisibility = Visibility.Hidden;
  554. break;
  555. case "Slow Vac":
  556. PressVisibility = Visibility.Hidden;
  557. PressSlowVacVisibility = Visibility.Visible;
  558. PressValveAngleVisibility = Visibility.Hidden;
  559. PressWaitVisibility = Visibility.Hidden;
  560. break;
  561. case "Valve Angle":
  562. PressVisibility = Visibility.Hidden;
  563. PressSlowVacVisibility = Visibility.Hidden;
  564. PressValveAngleVisibility = Visibility.Visible;
  565. PressWaitVisibility = Visibility.Hidden;
  566. break;
  567. case "Full Open":
  568. case "Full Close":
  569. case "Hold":
  570. case "Zero Set":
  571. case "Cancel Zero":
  572. PressVisibility = Visibility.Hidden;
  573. PressSlowVacVisibility = Visibility.Hidden;
  574. PressValveAngleVisibility = Visibility.Hidden;
  575. PressWaitVisibility = Visibility.Hidden;
  576. break;
  577. case "WaitPressUp1":
  578. case "WaitPressDown1":
  579. case "WaitPressUp2":
  580. case "WaitPressDown2":
  581. PressVisibility = Visibility.Hidden;
  582. PressSlowVacVisibility = Visibility.Hidden;
  583. PressValveAngleVisibility = Visibility.Hidden;
  584. if (selectedCmd == "WaitPressUp1" || selectedCmd == "WaitPressDown1")
  585. {
  586. if (view1 != null)
  587. {
  588. view1.TxtPressWait.KeepDecimals = 3;
  589. }
  590. }
  591. else
  592. {
  593. if (view1 != null)
  594. {
  595. view1.TxtPressWait.KeepDecimals = 1;
  596. }
  597. }
  598. PressWaitVisibility = Visibility.Visible;
  599. PressWaitIsEnabled = true;
  600. break;
  601. default:
  602. break;
  603. }
  604. }
  605. //public void SetPressValue(string selectedCmd, string Values)
  606. //{
  607. // if (string.IsNullOrEmpty(Values))
  608. // {
  609. // if (selectedCmd == "None")
  610. // {
  611. // PressPID = "";
  612. // PressSet = 0f;
  613. // PressSlowVacSet = 0f;
  614. // PressValveAngleSet = 0f;
  615. // LowPressWait = "";
  616. // PressWait = 0f;
  617. // }
  618. // return;
  619. // }
  620. // string[] list = Values.Split(';');
  621. // if (list.Length < 4) return;
  622. // switch (selectedCmd)
  623. // {
  624. // case "None":
  625. // PressPID = "";
  626. // PressSet = 0f;
  627. // break;
  628. // case "Press":
  629. // case "Press2":
  630. // PressPID = list[0];
  631. // double.TryParse(list[1], out double pressSet);
  632. // PressSet = pressSet;
  633. // break;
  634. // case "Slow Vac":
  635. // double.TryParse(list[1], out double pressSlowVacSet);
  636. // PressSlowVacSet = pressSlowVacSet;
  637. // break;
  638. // case "Valve Angle":
  639. // double.TryParse(list[1], out double pressValveAngleSet);
  640. // PressValveAngleSet = pressValveAngleSet;
  641. // LowPressWait = list[2];
  642. // break;
  643. // case "Full Open":
  644. // case "Full Close":
  645. // case "Hold":
  646. // case "Zero Set":
  647. // case "Cancel Zero":
  648. // break;
  649. // case "WaitPressUp1":
  650. // case "WaitPressDown1":
  651. // case "WaitPressUp2":
  652. // case "WaitPressDown2":
  653. // double.TryParse(list[1], out double presswait);
  654. // PressWait = presswait;
  655. // break;
  656. // default:
  657. // break;
  658. // }
  659. //}
  660. //public string GetSavePressValue(string selectedCmd)
  661. //{
  662. // string[] pressStringList = new string[4] { "", "", "", "" };
  663. // pressStringList[0] = PressPID;
  664. // switch (selectedCmd)
  665. // {
  666. // case "Press":
  667. // case "Press2":
  668. // pressStringList[1] = PressSet.ToString();
  669. // break;
  670. // case "Slow Vac":
  671. // pressStringList[1] = PressSlowVacSet.ToString();
  672. // break;
  673. // case "Valve Angle":
  674. // pressStringList[1] = PressValveAngleSet.ToString();
  675. // pressStringList[2] = LowPressWait;
  676. // break;
  677. // case "Full Open":
  678. // case "Full Close":
  679. // case "Hold":
  680. // case "Zero Set":
  681. // case "Cancel Zero":
  682. // pressStringList[0] = "";
  683. // pressStringList[1] = "";
  684. // pressStringList[2] = "";
  685. // pressStringList[3] = "";
  686. // break;
  687. // case "WaitPressUp1":
  688. // case "WaitPressDown1":
  689. // case "WaitPressUp2":
  690. // case "WaitPressDown2":
  691. // pressStringList[1] = PressWait.ToString();
  692. // break;
  693. // default:
  694. // pressStringList[0] = "";
  695. // pressStringList[1] = "";
  696. // pressStringList[2] = "";
  697. // pressStringList[3] = "";
  698. // break;
  699. // }
  700. // return string.Join(";", pressStringList);
  701. //}
  702. //private string _pressPID;
  703. //public string PressPID
  704. //{
  705. // get => _pressPID;
  706. // set
  707. // {
  708. // _pressPID = value;
  709. // NotifyOfPropertyChange(nameof(PressPID));
  710. // }
  711. //}
  712. //private double _pressSet;
  713. //public double PressSet
  714. //{
  715. // get => _pressSet;
  716. // set
  717. // {
  718. // _pressSet = value;
  719. // NotifyOfPropertyChange(nameof(PressSet));
  720. // }
  721. //}
  722. //private double _pressSlowVacSet;
  723. //public double PressSlowVacSet
  724. //{
  725. // get => _pressSlowVacSet;
  726. // set
  727. // {
  728. // _pressSlowVacSet = value;
  729. // NotifyOfPropertyChange(nameof(PressSlowVacSet));
  730. // }
  731. //}
  732. //private double _pressValveAngleSet;
  733. //public double PressValveAngleSet
  734. //{
  735. // get => _pressValveAngleSet;
  736. // set
  737. // {
  738. // _pressValveAngleSet = value;
  739. // NotifyOfPropertyChange(nameof(PressValveAngleSet));
  740. // }
  741. //}
  742. //private string _lowPressWait;
  743. //public string LowPressWait
  744. //{
  745. // get => _lowPressWait;
  746. // set
  747. // {
  748. // _lowPressWait = value;
  749. // NotifyOfPropertyChange(nameof(LowPressWait));
  750. // }
  751. //}
  752. //private double _pressWait;
  753. //public double PressWait
  754. //{
  755. // get => _pressWait;
  756. // set
  757. // {
  758. // _pressWait = value;
  759. // NotifyOfPropertyChange(nameof(PressWait));
  760. // }
  761. //}
  762. //private void ClearPressSetValue()
  763. //{
  764. // if (SelectedRecipeStep != null)
  765. // {
  766. // SelectedRecipeStep.PressPID = "None";
  767. // SelectedRecipeStep.PressSet = 0;
  768. // SelectedRecipeStep.PressSlowVacSet = 0;
  769. // SelectedRecipeStep.PressValveAngleSet = "0";
  770. // SelectedRecipeStep.PressLowWait = "None";
  771. // SelectedRecipeStep.PressWait = 0;
  772. // }
  773. //}
  774. #endregion
  775. #region AlarmRecipe Visibility
  776. public bool IsAlarmReicpe => RecipeType.ToLower() == "alarm";
  777. public bool IsAbortReicpe => RecipeType.ToLower() == "abort";
  778. public bool IsSubReicpe => RecipeType.ToLower() == "sub";
  779. public bool IsTableVisibility => IsAlarmReicpe || IsAbortReicpe || IsSubReicpe;
  780. public bool IsRecipeHeaderVisibility => !IsTableVisibility;
  781. public bool IsVPDataListVisibility => !IsTableVisibility;
  782. public bool IsCombinationVisibility => !IsTableVisibility;
  783. #endregion
  784. private bool _pressWaitIsEnabled = false;
  785. public bool PressWaitIsEnabled
  786. {
  787. get => _pressWaitIsEnabled;
  788. set
  789. {
  790. _pressWaitIsEnabled = value;
  791. NotifyOfPropertyChange(nameof(PressWaitIsEnabled));
  792. }
  793. }
  794. private bool _pressWaitBtnIsEnabled = false;
  795. public bool PressWaitBtnIsEnabled
  796. {
  797. get => _pressWaitBtnIsEnabled;
  798. set
  799. {
  800. _pressWaitBtnIsEnabled = value;
  801. NotifyOfPropertyChange(nameof(PressWaitBtnIsEnabled));
  802. }
  803. }
  804. private void RefreshUpdate()
  805. {
  806. SetChangedStepRefreshUpdate();
  807. SetCmdIsEnabled();
  808. if (NewSteps == null || NewSteps.Count == 0 || NewSteps.Contains(SelectedRecipeStep)) return;
  809. var steps = CurrentRecipe.Steps.ToList();
  810. int currentIndex = steps.IndexOf(SelectedRecipeStep);
  811. if (currentIndex < 0) return;
  812. int index = steps.IndexOf(NewSteps.First());
  813. if (currentIndex < index)//向上翻
  814. {
  815. if (currentPage <= 1)
  816. {
  817. return;
  818. }
  819. currentPage = currentPage - 1;
  820. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  821. IndexNoDefault = pageSize - 1;
  822. if (IndexNoDefault >= NewSteps.Count)
  823. {
  824. IndexNoDefault = NewSteps.Count - 1;
  825. }
  826. }
  827. else//向下翻
  828. {
  829. if (currentPage >= GetTotalPage())
  830. {
  831. return;
  832. }
  833. currentPage = currentPage + 1;
  834. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  835. IndexNoDefault = 0;
  836. }
  837. }
  838. private bool _noStandbyOrEndIsEnabled = false;
  839. public bool NoStandbyOrEndIsEnabled
  840. {
  841. get => _noStandbyOrEndIsEnabled;
  842. set
  843. {
  844. _noStandbyOrEndIsEnabled = value;
  845. NotifyOfPropertyChange(nameof(NoStandbyOrEndIsEnabled));
  846. }
  847. }
  848. private Visibility _standbyIsVisibility = Visibility.Visible;
  849. public Visibility StandbyIsVisibility
  850. {
  851. get => _standbyIsVisibility;
  852. set
  853. {
  854. _standbyIsVisibility = value;
  855. NotifyOfPropertyChange(nameof(StandbyIsVisibility));
  856. }
  857. }
  858. private void SetChangedStepRefreshUpdate()
  859. {
  860. if (CurrentRecipe.Steps == null || CurrentRecipe.Steps.Count < 1)
  861. {
  862. return;
  863. }
  864. var endName = "";
  865. if (SelectedRecipeStep.Name.Contains(":") && SelectedRecipeStep.Name.Split(':').Length > 1)
  866. {
  867. endName = SelectedRecipeStep.Name.Split(':')[1].Trim().ToLower();
  868. }
  869. else
  870. {
  871. endName = SelectedRecipeStep.Name.Trim().ToLower();
  872. }
  873. if (SelectedRecipeStep.Name == "Standby" || endName == "end")
  874. {
  875. NoStandbyOrEndIsEnabled = false;
  876. StandbyIsVisibility = Visibility.Visible;
  877. // LoaderSetSpeedFloatVisibility= Visibility.Hidden;
  878. // LoaderSet3SpeedVisibility= Visibility.Visible;
  879. // LoaderSetSpeedVisibility = Visibility.Hidden;
  880. }
  881. else
  882. {
  883. NoStandbyOrEndIsEnabled = true && SettingButtonEnable;
  884. StandbyIsVisibility = Visibility.Visible;
  885. }
  886. }
  887. private void SetCmdIsEnabled()
  888. {
  889. AppendStepItemIsEnabled = true;
  890. if (CurrentRecipe.Steps == null || CurrentRecipe.Steps.Count == 0 || SelectedRecipeStep.Name == "Standby" || (CurrentRecipe.RecipeChamberType == RecipeDataBase.ProcessType && SelectedRecipeStep == CurrentRecipe.Steps.LastOrDefault()))
  891. {
  892. AppendStepItemIsEnabled = false;
  893. OverWriteCopyIsEnabled = false;
  894. InsertCopyIsEnabled = false;
  895. PrevStepOverwriteIsEnabled = false;
  896. PrevStepInsertIsEnabled = false;
  897. PrevStepItemIsEnabled = false;
  898. CurrStepDeleteIsEnabled = false;
  899. MultStepsDeleteIsEnabled = false;
  900. }
  901. else
  902. {
  903. if (CurrentRecipe.RecipeChamberType == RecipeDataBase.ProcessType)
  904. {
  905. AppendStepItemIsEnabled = true;
  906. InsertCopyIsEnabled = true;
  907. PrevStepItemIsEnabled = false;
  908. SetCurrAndMultStepDeleteIsEnabled();
  909. if (CurrentRecipe.Steps[1].StepNo == SelectedRecipeStep.StepNo)
  910. {
  911. OverWriteCopyIsEnabled = true;
  912. PrevStepOverwriteIsEnabled = false;
  913. PrevStepInsertIsEnabled = false;
  914. }
  915. else
  916. {
  917. OverWriteCopyIsEnabled = true;
  918. PrevStepOverwriteIsEnabled = true;
  919. PrevStepInsertIsEnabled = true;
  920. }
  921. }
  922. else
  923. {
  924. AppendStepItemIsEnabled = true;
  925. OverWriteCopyIsEnabled = true;
  926. InsertCopyIsEnabled = true;
  927. PrevStepItemIsEnabled = false;
  928. SetCurrAndMultStepDeleteIsEnabled();
  929. if (CurrentRecipe.Steps[0].StepNo == SelectedRecipeStep.StepNo)
  930. {
  931. PrevStepOverwriteIsEnabled = false;
  932. PrevStepInsertIsEnabled = false;
  933. }
  934. else
  935. {
  936. PrevStepOverwriteIsEnabled = true;
  937. PrevStepInsertIsEnabled = true;
  938. }
  939. }
  940. //OverWriteCopyIsEnabled = true;
  941. //InsertCopyIsEnabled = true;
  942. //PrevStepOverwriteIsEnabled = true;
  943. //PrevStepInsertIsEnabled = true;
  944. //PrevStepItemIsEnabled = true;
  945. //CurrStepDeleteIsEnabled = true;
  946. //MultStepsDeleteIsEnabled = true;
  947. //if (CurrentRecipe.RecipeChamberType == RecipeDataBase.ProcessType)
  948. // if (CurrentRecipe.Steps[1].StepNo == SelectedRecipeStep.StepNo)
  949. // {
  950. // AppendStepItemIsEnabled = true;
  951. // OverWriteCopyIsEnabled = false;
  952. // InsertCopyIsEnabled = true;
  953. // PrevStepOverwriteIsEnabled = false;
  954. // PrevStepInsertIsEnabled = false;
  955. // PrevStepItemIsEnabled = false;
  956. // CurrStepDeleteIsEnabled = true;
  957. // MultStepsDeleteIsEnabled = true;
  958. // }
  959. // else
  960. // {
  961. // OverWriteCopyIsEnabled = true;
  962. // InsertCopyIsEnabled = true;
  963. // PrevStepOverwriteIsEnabled = true;
  964. // PrevStepInsertIsEnabled = true;
  965. // PrevStepItemIsEnabled = false;
  966. // CurrStepDeleteIsEnabled = true;
  967. // MultStepsDeleteIsEnabled = true;
  968. // }
  969. //else
  970. //{
  971. // if (CurrentRecipe.Steps[0].StepNo == SelectedRecipeStep.StepNo)
  972. // {
  973. // AppendStepItemIsEnabled = true;
  974. // OverWriteCopyIsEnabled = true;
  975. // InsertCopyIsEnabled = true;
  976. // PrevStepOverwriteIsEnabled = false;
  977. // PrevStepInsertIsEnabled = false;
  978. // PrevStepItemIsEnabled = false;
  979. // CurrStepDeleteIsEnabled = true;
  980. // MultStepsDeleteIsEnabled = true;
  981. // }
  982. // else
  983. // {
  984. // OverWriteCopyIsEnabled = true;
  985. // InsertCopyIsEnabled = true;
  986. // PrevStepOverwriteIsEnabled = true;
  987. // PrevStepInsertIsEnabled = true;
  988. // PrevStepItemIsEnabled = false;
  989. // CurrStepDeleteIsEnabled = true;
  990. // MultStepsDeleteIsEnabled = true;
  991. // }
  992. //}
  993. }
  994. IsCommandConditionEventEnabled = SettingButtonEnable;
  995. IsStandbyEnabled = SettingButtonEnable && (RecipeType.ToLower() == "process");
  996. }
  997. private void SetCurrAndMultStepDeleteIsEnabled()
  998. {
  999. if (CurrentRecipe.RecipeChamberType == "Process")
  1000. {
  1001. if ((CurrentRecipe.Steps.Count < 4))
  1002. {
  1003. CurrStepDeleteIsEnabled = false;
  1004. MultStepsDeleteIsEnabled = false;
  1005. }
  1006. else
  1007. {
  1008. MultStepsDeleteIsEnabled = true;
  1009. if (SelectedRecipeStep.Name == "Standby" || SelectedRecipeStep.Name == "End")
  1010. {
  1011. CurrStepDeleteIsEnabled = false;
  1012. }
  1013. else
  1014. {
  1015. CurrStepDeleteIsEnabled = true;
  1016. }
  1017. }
  1018. }
  1019. else
  1020. {
  1021. if ((CurrentRecipe.Steps.Count < 2))
  1022. {
  1023. CurrStepDeleteIsEnabled = false;
  1024. MultStepsDeleteIsEnabled = false;
  1025. }
  1026. else
  1027. {
  1028. CurrStepDeleteIsEnabled = true;
  1029. MultStepsDeleteIsEnabled = true;
  1030. }
  1031. }
  1032. }
  1033. private string _selectedGasSetting2;
  1034. public string SelectedGasSetting2
  1035. {
  1036. get
  1037. {
  1038. return _selectedGasSetting2;
  1039. }
  1040. set
  1041. {
  1042. _selectedGasSetting2 = value;
  1043. NotifyOfPropertyChange(nameof(SelectedGasSetting2));
  1044. }
  1045. }
  1046. private string _selectedGasSetting3;
  1047. public string SelectedGasSetting3
  1048. {
  1049. get
  1050. {
  1051. return _selectedGasSetting3;
  1052. }
  1053. set
  1054. {
  1055. _selectedGasSetting3 = value;
  1056. NotifyOfPropertyChange(nameof(SelectedGasSetting3));
  1057. }
  1058. }
  1059. private string _selectedGasSetting4;
  1060. public string SelectedGasSetting4
  1061. {
  1062. get
  1063. {
  1064. return _selectedGasSetting4;
  1065. }
  1066. set
  1067. {
  1068. _selectedGasSetting4 = value;
  1069. NotifyOfPropertyChange(nameof(SelectedGasSetting4));
  1070. }
  1071. }
  1072. private string _selectedGasSetting5;
  1073. public string SelectedGasSetting5
  1074. {
  1075. get
  1076. {
  1077. return _selectedGasSetting5;
  1078. }
  1079. set
  1080. {
  1081. _selectedGasSetting5 = value;
  1082. NotifyOfPropertyChange(nameof(SelectedGasSetting5));
  1083. }
  1084. }
  1085. private string _selectedGasSetting6;
  1086. public string SelectedGasSetting6
  1087. {
  1088. get
  1089. {
  1090. return _selectedGasSetting6;
  1091. }
  1092. set
  1093. {
  1094. _selectedGasSetting6 = value;
  1095. NotifyOfPropertyChange(nameof(SelectedGasSetting6));
  1096. }
  1097. }
  1098. private List<ConfigNode> _ConfigNodes = new List<ConfigNode>();
  1099. public List<ConfigNode> ConfigNodes
  1100. {
  1101. get { return _ConfigNodes; }
  1102. set
  1103. {
  1104. _ConfigNodes = value;
  1105. NotifyOfPropertyChange(nameof(ConfigNodes));
  1106. }
  1107. }
  1108. //private ObservableCollection<MFCData> _mFCDatas = new ObservableCollection<MFCData>();
  1109. //public ObservableCollection<TempSetData> TempList { get; set; } = new ObservableCollection<TempSetData>();
  1110. //public ObservableCollection<MFCData> MFCDataList
  1111. //{
  1112. // get => _mFCDatas;
  1113. // set
  1114. // {
  1115. // _mFCDatas = value;
  1116. // NotifyOfPropertyChange(nameof(MFCDataList));
  1117. // }
  1118. //}
  1119. private string _pressureUnit;
  1120. public string PressureUnit
  1121. {
  1122. get => _pressureUnit;
  1123. set
  1124. {
  1125. _pressureUnit = value;
  1126. NotifyOfPropertyChange(nameof(PressureUnit));
  1127. }
  1128. }
  1129. public string RecipeType { get; set; }
  1130. private RecipeProcessEditView view1;
  1131. private int _tableIndex;
  1132. public RecipeProcessEditViewModel(string strPrefixPath, string strRecipeName, string permission = "", int tableIndex = 1)
  1133. {
  1134. PumpDict.Clear();
  1135. PumpDict.Add("DPR", "ValveAV91");
  1136. PumpDict.Add("AGV", "AGVPump");
  1137. PumpDict.Add("MBP", "BothPump");
  1138. PumpDict.Add("DP", "AUCPump");
  1139. PumpDict.Add("BWR", "ValveBWR");
  1140. OtherPumpDict.Clear();
  1141. OtherPumpDict.Add("F2Cln", "F2Cln");
  1142. OtherPumpDict.Add("HFCln", "HFCln");
  1143. OtherPumpDict.Add("HTR1", "HTR1");
  1144. OtherPumpDict.Add("HTR2", "HTR2");
  1145. OtherPumpDict.Add("HTR3", "HTR3");
  1146. DefaultUnit = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.APC.PressureUnit");
  1147. RecipeTemplate = _recipeProvider.GetGroupRecipeTemplate();
  1148. CurrentRecipe.PrefixPath = strPrefixPath;
  1149. CurrentRecipe.Name = strRecipeName;
  1150. CurrentRecipe.RecipePermission = permission;
  1151. _tableIndex = tableIndex;
  1152. }
  1153. protected override void OnViewLoaded(object view)
  1154. {
  1155. base.OnViewLoaded(view);
  1156. view1 = (RecipeProcessEditView)view;
  1157. BoatZAxisLimitSpeed = (double)QueryDataClient.Instance.Service.GetConfig($"Boat.BoatElevatorServo.BoatZAxisLimitSpeed");
  1158. BoatRAxisLimitSpeed = (double)QueryDataClient.Instance.Service.GetConfig($"Boat.BoatRotationServo.BoatRAxisLimitSpeed");
  1159. }
  1160. protected override void OnActivate()
  1161. {
  1162. base.OnActivate();
  1163. InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorRecipeOK", "");
  1164. }
  1165. protected override void OnDeactivate(bool close)
  1166. {
  1167. base.OnDeactivate(close);
  1168. InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorPROCManualOK", "");
  1169. }
  1170. protected override void OnInitialize()
  1171. {
  1172. base.OnInitialize();
  1173. ToolType = (string)QueryDataClient.Instance.Service.GetConfig("System.SetUp.ToolType");
  1174. // GetHeaderConfig();
  1175. LoadData();
  1176. RefreshUpdate();
  1177. currentPage = GetcurrentPage();
  1178. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  1179. }
  1180. private void LoadData()
  1181. {
  1182. if (RecipeType.ToLower() == "process" || RecipeType.ToLower() == "sub")
  1183. {
  1184. IsProcessVisibility = Visibility.Visible;
  1185. }
  1186. else
  1187. {
  1188. IsProcessVisibility = Visibility.Hidden;
  1189. }
  1190. CurrentRecipe.Clear();
  1191. var recipeContent = _recipeProvider.LoadRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name);
  1192. if (string.IsNullOrEmpty(recipeContent))
  1193. {
  1194. System.Windows.MessageBox.Show($"{CurrentRecipe.PrefixPath}\\{CurrentRecipe.Name} is empty, please confirm the file is valid.");
  1195. return;
  1196. }
  1197. // CurrentRecipe.RecipeChamberType = "OriginChamber";
  1198. CurrentRecipe.InitData(CurrentRecipe.PrefixPath, CurrentRecipe.Name, recipeContent, "PM1", _tableIndex);
  1199. if (CurrentRecipe.Steps.Count > 0)
  1200. {
  1201. if (!string.IsNullOrEmpty(SelectedStepName))
  1202. {
  1203. //根据名称找到对应的Index
  1204. var steps = CurrentRecipe.Steps.Where(p => SelectedStepName.EndsWith(p.Name)).FirstOrDefault();
  1205. if (steps != null)
  1206. {
  1207. IndexNoDefault = CurrentRecipe.Steps.IndexOf(steps);
  1208. }
  1209. }
  1210. if (CurrentRecipe.Steps.Count > IndexNoDefault)
  1211. {
  1212. SelectStep(CurrentRecipe.Steps[IndexNoDefault]);
  1213. }
  1214. }
  1215. IsCommandConditionEventEnabled = true;
  1216. PressureUnit = "(" + (string)QueryDataClient.Instance.Service.GetConfig("PM1.APC.PressureUnit") + ")";
  1217. }
  1218. public void SwitchPage(string page)
  1219. {
  1220. var windowManager = IoC.Get<IWindowManager>();
  1221. switch (page)
  1222. {
  1223. case "GFCSetting":
  1224. RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new RecipeGasPanelSettingViewModel
  1225. {
  1226. SelectedStepNo = SelectedRecipeStep.StepNo,
  1227. SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}",
  1228. CurrentRecipe = CurrentRecipe,
  1229. SelectedStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault()
  1230. };
  1231. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  1232. (windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Recipe Gas Panel Setting");
  1233. break;
  1234. }
  1235. }
  1236. private void RecipeGasPanelSettingViewModel_ChangedStepEvent(Step step)
  1237. {
  1238. SelectStep(step);
  1239. }
  1240. private Step OldStep;
  1241. private Dictionary<string, string> PumpDict = new Dictionary<string, string>();
  1242. private Dictionary<string, string> OtherPumpDict = new Dictionary<string, string>();
  1243. public void SelectStep(object step)
  1244. {
  1245. if (step == null || !(step is Step))
  1246. {
  1247. return;
  1248. }
  1249. var step1 = (Step)step;
  1250. var SelectedStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == step1.StepNo).FirstOrDefault();
  1251. if (OldStep != null && step1.StepNo != OldStep.StepNo)
  1252. {
  1253. var selectedOldStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == OldStep.StepNo).FirstOrDefault();
  1254. if (step1 != null && step1.TemperatureControlMode != null && !string.IsNullOrEmpty(step1.TemperatureControlMode.Value))
  1255. {
  1256. if (step1.TemperatureControlMode.Value.Contains("Profile"))
  1257. {
  1258. SelectBtnName = "Profile";
  1259. }
  1260. else
  1261. {
  1262. SelectBtnName = step1.TemperatureControlMode.Value;
  1263. }
  1264. }
  1265. else
  1266. {
  1267. SelectBtnName = "";
  1268. }
  1269. //if (selectedOldStep != null)
  1270. //{
  1271. // selectedOldStep.LoaderValue = GetSaveLoaderValue(selectedOldStep.LoaderCommand);
  1272. // selectedOldStep.PressValue = GetSavePressValue(selectedOldStep.PressCommand);
  1273. //}
  1274. }
  1275. OldStep = step1;
  1276. string strName = step1.Name == null ? step1.Name : step1.Name?.Trim();
  1277. SelectedRecipeStep = SelectedStep;
  1278. //if (SelectedRecipeStep.Name != EditRecipeStepName || SelectedRecipeStep.StepNo != step1.StepNo)
  1279. //{
  1280. SetShowLoaderValuePanel(SelectedRecipeStep.LoaderCommand.Value);
  1281. SetShowPressPanel(SelectedRecipeStep.PressCommand.Value);
  1282. InvokeClient.Instance.Service.DoOperation($"PM1.SetEditRecipeStepName", SelectedRecipeStep.Name);
  1283. new Task(() =>
  1284. {
  1285. var selectedStep = step1;
  1286. if (selectedStep.MFCSets != null && selectedStep.MFCSets.Count > 0)
  1287. {
  1288. Dictionary<string, string> dictMFC = new Dictionary<string, string>();
  1289. foreach (var mfc in selectedStep.MFCSets)
  1290. {
  1291. dictMFC[mfc.ControlName] = $"{mfc.SetValue.Value};{mfc.Rampng.Value};{mfc.AlarmValue}";
  1292. }
  1293. InvokeClient.Instance.Service.DoOperation($"PM1.SetAllMfcVirtualValue", dictMFC);
  1294. }
  1295. if (selectedStep.ValveSets != null && selectedStep.ValveSets.Count > 0)
  1296. {
  1297. Dictionary<string, bool> dictValve = new Dictionary<string, bool>();
  1298. foreach (var item in selectedStep.ValveSets)
  1299. {
  1300. if (PumpDict.ContainsKey(item.Name))
  1301. {
  1302. // dictValve[PumpDict[key]] = selectedStep.ValveSets[key] == "Open" ? true : false;
  1303. }
  1304. else if (OtherPumpDict.ContainsKey(item.Name))
  1305. { }
  1306. else
  1307. {
  1308. dictValve[item.Name] = item.Value;
  1309. }
  1310. }
  1311. InvokeClient.Instance.Service.DoOperation($"PM1.SetAll{AITValveOperation.GVVirtualTurnValve}", dictValve);
  1312. }
  1313. }).Start();
  1314. //if (selectedStep.TemperatureSets != null)
  1315. //{
  1316. // TempList.Clear();
  1317. // selectedStep.TemperatureSets.ToList().ForEach(x => TempList.Add(x));
  1318. //}
  1319. //SetLoaderValue(selectedStep.LoaderCommand, selectedStep.LoaderValue);
  1320. //SetPressValue(selectedStep.PressCommand, selectedStep.PressValue);
  1321. //}
  1322. RefreshUpdate();
  1323. }
  1324. #region"StepEdit"
  1325. public Step selectStep { get; set; } = new Step();
  1326. public void StepEdit(string stepEditCmd)
  1327. {
  1328. var windowManager = IoC.Get<IWindowManager>();
  1329. switch (stepEditCmd)
  1330. {
  1331. case "Append":
  1332. AppendStep2();
  1333. break;
  1334. case "InsertCopy":
  1335. InsertCopyStep();
  1336. break;
  1337. case "OverWrite"://任何步骤的内容都可以覆盖到选定的步骤中
  1338. OverWriteStep();
  1339. break;
  1340. case "PrevStepOverwrite"://用上一步的内容覆盖所选步骤
  1341. if (DialogButton.No == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  1342. DialogType.CONFIRM,
  1343. $"Make sure to PrevStep Overwrite the selected step?"))
  1344. {
  1345. return;
  1346. }
  1347. PrevStepOverwriteStep();
  1348. break;
  1349. case "PrevStepInsert"://在选定步骤之前,插入带有前一步内容的新步骤。
  1350. if (DialogButton.No == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  1351. DialogType.CONFIRM,
  1352. $"Make sure to PrevStep nsert the selected step?"))
  1353. {
  1354. return;
  1355. }
  1356. InsertPrevStep();
  1357. break;
  1358. case "PrevStepItem":
  1359. break;
  1360. case "CurrStepDelete":
  1361. if (DialogButton.No == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  1362. DialogType.CONFIRM,
  1363. $"Make sure to delete the selected step?"))
  1364. {
  1365. return;
  1366. }
  1367. if (SelectedRecipeStep == null || CurrentRecipe == null)
  1368. { return; }
  1369. CurrDeleteStep();
  1370. break;
  1371. case "MultStepsDelete":
  1372. RecipeStepDeleteDialogViewModel recipedeleteDialog = new RecipeStepDeleteDialogViewModel(CurrentRecipe);
  1373. (windowManager as WindowManager)?.ShowDialogWithTitle(recipedeleteDialog, null, "Delete Recipe Step");
  1374. IndexNoDefault = 0;
  1375. if (CurrentRecipe.Steps.Count > 0)
  1376. {
  1377. selectStep = CurrentRecipe.Steps[0];
  1378. }
  1379. break;
  1380. default:
  1381. break;
  1382. }
  1383. // var totalPage = GetTotalPage();
  1384. currentPage = GetcurrentPage();
  1385. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  1386. //currentPage = totalPage;
  1387. if (selectStep != null && selectStep.StepNo >= 0)
  1388. {
  1389. SelectStep(selectStep);
  1390. }
  1391. }
  1392. private void OverWriteStep()
  1393. {
  1394. var windowManager = IoC.Get<IWindowManager>();
  1395. if (CurrentRecipe == null) return;
  1396. RecipeStepSelectDialogViewModel recipeStepSelectDialogViewModel = new RecipeStepSelectDialogViewModel(CurrentRecipe);
  1397. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepSelectDialogViewModel, null, "Select Recipe Step"))
  1398. {
  1399. var tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1400. CurrentRecipe.ShallowCopyStep(ref tempStep, recipeStepSelectDialogViewModel.SelectedStep);
  1401. selectStep = SelectedRecipeStep;
  1402. if (selectStep != null && selectStep.StepNo >= 0)
  1403. {
  1404. SelectStep(selectStep);
  1405. }
  1406. }
  1407. }
  1408. private void PrevStepOverwriteStep()
  1409. {
  1410. int index = -1;
  1411. index = SelectedRecipeStep.StepNo;
  1412. if (index > 1)
  1413. {
  1414. var setStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1415. CurrentRecipe.ShallowCopyStep(ref setStep, CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo - 1).FirstOrDefault());
  1416. selectStep = SelectedRecipeStep;
  1417. }
  1418. }
  1419. public void CurrDeleteStep()
  1420. {
  1421. int index = -1;
  1422. index = SelectedRecipeStep.StepNo;
  1423. CurrentRecipe.Steps.Remove(CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault());
  1424. if (CurrentRecipe.RecipeChamberType != RecipeDataBase.ProcessType)
  1425. {
  1426. for (int i = index; i < this.CurrentRecipe.Steps.Count + 1; i++)
  1427. {
  1428. this.CurrentRecipe.Steps[i - 1].StepNo = i;
  1429. }
  1430. }
  1431. else
  1432. {
  1433. for (int i = index; i < this.CurrentRecipe.Steps.Count + 1; i++)
  1434. {
  1435. this.CurrentRecipe.Steps[i - 1].StepNo = i - 1;
  1436. }
  1437. }
  1438. if (index > CurrentRecipe.Steps.Count - 1)
  1439. {
  1440. IndexNoDefault = CurrentRecipe.Steps.Count - 1;
  1441. }
  1442. else
  1443. {
  1444. IndexNoDefault = CurrentRecipe.Steps.IndexOf(CurrentRecipe.Steps.FirstOrDefault(x => x.StepNo == index));
  1445. }
  1446. if (CurrentRecipe != null && CurrentRecipe.Steps.Count > 0)
  1447. {
  1448. RefreshUpdate();
  1449. selectStep = CurrentRecipe.Steps[IndexNoDefault];
  1450. }
  1451. }
  1452. public void InsertPrevStep()
  1453. {
  1454. var foundPrevStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo - 1).FirstOrDefault();
  1455. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1456. if (foundPrevStep != null && foundStep != null)
  1457. {
  1458. var tempStep = CurrentRecipe.CreateStep();
  1459. CurrentRecipe.CloneStep(ref tempStep, foundPrevStep);
  1460. tempStep.StepNo = foundPrevStep.StepNo + 1;
  1461. foreach (var item in this.CurrentRecipe.Steps)
  1462. {
  1463. if (item.StepNo >= tempStep.StepNo)
  1464. {
  1465. item.StepNo += 1;
  1466. }
  1467. }
  1468. Step step = CurrentRecipe.Steps.FirstOrDefault(x => x.Name == "Standby");
  1469. CurrentRecipe.SetDelegateEvent(tempStep);
  1470. if (step == null)
  1471. {
  1472. this.CurrentRecipe.Steps.Insert(foundPrevStep.StepNo, tempStep);
  1473. }
  1474. else
  1475. {
  1476. this.CurrentRecipe.Steps.Insert(foundPrevStep.StepNo + 1, tempStep);
  1477. }
  1478. if (step == null)
  1479. {
  1480. IndexNoDefault = SelectedRecipeStep.StepNo - 1;
  1481. }
  1482. else
  1483. {
  1484. IndexNoDefault = SelectedRecipeStep.StepNo;
  1485. }
  1486. selectStep = CurrentRecipe.Steps[IndexNoDefault];
  1487. }
  1488. }
  1489. private void AppendStep()
  1490. {
  1491. if (CurrentRecipe.RecipeChamberType == "Process")
  1492. {
  1493. var last = CurrentRecipe.Steps.LastOrDefault();
  1494. CurrentRecipe.Steps.RemoveWhere(a => a.StepNo == last.StepNo);
  1495. var newStep = CurrentRecipe.CreateStep();
  1496. CurrentRecipe.Steps.Add(newStep);
  1497. int TempSelectIndex = 0;
  1498. Step step = CurrentRecipe.Steps.FirstOrDefault(x => x.Name == "Standby");
  1499. for (int i = 0; i < this.CurrentRecipe.Steps.Count; i++)
  1500. {
  1501. if (step == null)
  1502. {
  1503. this.CurrentRecipe.Steps[i].StepNo = i + 1;
  1504. }
  1505. else
  1506. {
  1507. this.CurrentRecipe.Steps[i].StepNo = i;
  1508. }
  1509. TempSelectIndex = i;
  1510. }
  1511. IndexNoDefault = TempSelectIndex;
  1512. last.StepNo = CurrentRecipe.Steps.LastOrDefault().StepNo + 1;
  1513. CurrentRecipe.Steps.Add(last);
  1514. selectStep = CurrentRecipe.Steps[newStep.StepNo - 1];
  1515. }
  1516. else
  1517. {
  1518. var newStep = CurrentRecipe.CreateStep();
  1519. CurrentRecipe.Steps.Add(newStep);
  1520. int TempSelectIndex = 0;
  1521. Step step = CurrentRecipe.Steps.FirstOrDefault(x => x.Name == "Standby");
  1522. for (int i = 0; i < this.CurrentRecipe.Steps.Count; i++)
  1523. {
  1524. if (step == null)
  1525. {
  1526. this.CurrentRecipe.Steps[i].StepNo = i + 1;
  1527. }
  1528. else
  1529. {
  1530. this.CurrentRecipe.Steps[i].StepNo = i;
  1531. }
  1532. TempSelectIndex = i;
  1533. }
  1534. IndexNoDefault = TempSelectIndex;
  1535. selectStep = CurrentRecipe.Steps[TempSelectIndex];
  1536. }
  1537. }
  1538. public void AppendStep2()
  1539. {
  1540. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1541. int foundIndex = this.CurrentRecipe.Steps.IndexOf(foundStep);
  1542. if (foundStep != null)
  1543. {
  1544. var tempStep = CurrentRecipe.CreateStep();
  1545. CurrentRecipe.CloneStep(ref tempStep, foundStep);
  1546. tempStep.StepNo = foundStep.StepNo + 1;
  1547. tempStep.Name = $"Name{tempStep.StepNo}";
  1548. foreach (var item in this.CurrentRecipe.Steps)
  1549. {
  1550. if (item.StepNo >= tempStep.StepNo)
  1551. {
  1552. item.StepNo += 1;
  1553. }
  1554. }
  1555. IndexNoDefault = foundIndex + 1;
  1556. this.CurrentRecipe.Steps.Insert(foundIndex + 1, tempStep);
  1557. selectStep = CurrentRecipe.Steps[foundIndex + 1];
  1558. }
  1559. }
  1560. public void InsertCopyStep()
  1561. {
  1562. var windowManager = IoC.Get<IWindowManager>();
  1563. if (CurrentRecipe == null) return;
  1564. RecipeStepSelectDialogViewModel recipeStepSelectDialogViewModel = new RecipeStepSelectDialogViewModel(CurrentRecipe);
  1565. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepSelectDialogViewModel, null, "Select Recipe Step"))
  1566. {
  1567. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1568. if (foundStep != null)
  1569. {
  1570. var tempStep = CurrentRecipe.CreateStep();
  1571. CurrentRecipe.CloneStep(ref tempStep, recipeStepSelectDialogViewModel.SelectedStep);
  1572. tempStep.StepNo = foundStep.StepNo;
  1573. int insertIndex = this.CurrentRecipe.Steps.IndexOf(foundStep);
  1574. CurrentRecipe.SetDelegateEvent(tempStep);
  1575. this.CurrentRecipe.Steps.Insert(insertIndex, tempStep);
  1576. if (CurrentRecipe.RecipeChamberType != RecipeDataBase.ProcessType)
  1577. {
  1578. for (int i = tempStep.StepNo; i < this.CurrentRecipe.Steps.Count + 1; i++)
  1579. {
  1580. this.CurrentRecipe.Steps[i - 1].StepNo = i;
  1581. }
  1582. }
  1583. else
  1584. {
  1585. for (int i = tempStep.StepNo; i < this.CurrentRecipe.Steps.Count; i++)
  1586. {
  1587. this.CurrentRecipe.Steps[i].StepNo = i;
  1588. }
  1589. }
  1590. selectStep = CurrentRecipe.Steps[insertIndex];
  1591. }
  1592. }
  1593. }
  1594. #endregion
  1595. public void RecipeSingMFCIsChangeClick(object value)
  1596. {
  1597. if (value is MFCData)
  1598. {
  1599. var mfc = value as MFCData;
  1600. if (mfc.IsSaved)
  1601. {
  1602. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  1603. DialogType.CONFIRM,
  1604. $"Recipe single MFC is changed Flag, do you want to save it?"))
  1605. {
  1606. mfc.FlagIsSaved = false;
  1607. }
  1608. }
  1609. else
  1610. {
  1611. mfc.FlagIsSaved = true;
  1612. mfc.UndoChanges();
  1613. }
  1614. }
  1615. }
  1616. //撤销修改
  1617. public void RecipeIsChangeClick(object cmdName, object value)
  1618. {
  1619. if (value == null)
  1620. return;
  1621. var windowManager = IoC.Get<IWindowManager>();
  1622. switch ((string)cmdName)
  1623. {
  1624. case "Alarm":
  1625. ((Step)value).UndoAlarmChanges();
  1626. break;
  1627. case "MFC":
  1628. ((Step)value).UndoMFCChanges();
  1629. break;
  1630. case "Gas":
  1631. ((Step)value).UndoGasChanges();
  1632. break;
  1633. case "AUX":
  1634. ((Step)value).UndoAUXChanges();
  1635. break;
  1636. case "Press":
  1637. ((Step)value).UndoPressChanges();
  1638. SetShowPressPanel(((Step)value).PressCommand.Value);
  1639. break;
  1640. case "Temp":
  1641. ((Step)value).UndoTemperatureChanges();
  1642. break;
  1643. case "Loader":
  1644. ((Step)value).UndoLoaderChanges();
  1645. SetShowLoaderValuePanel(((Step)value).LoaderCommand.Value);
  1646. break;
  1647. default:
  1648. break;
  1649. }
  1650. }
  1651. public void TempSetClick(object sender)
  1652. {
  1653. string stSetValue = ShowNumberKeyboard(sender as Button, "", 1);
  1654. if (stSetValue != "Cancel")
  1655. {
  1656. foreach (var item in SelectedRecipeStep.TemperatureSets)
  1657. {
  1658. item.SetValue.SetValue(stSetValue);
  1659. }
  1660. }
  1661. }
  1662. public void RampSetClick(object sender)
  1663. {
  1664. string strSetRamp = ShowNumberKeyboard(sender as Button, "", 1);
  1665. if (strSetRamp != "Cancel")
  1666. {
  1667. foreach (var item in SelectedRecipeStep.TemperatureSets)
  1668. {
  1669. item.RampngValue.SetValue(strSetRamp);
  1670. }
  1671. }
  1672. }
  1673. private string ShowNumberKeyboard(Control control, string defaultValue, int keepDecimals = -1)
  1674. {
  1675. NumberKeyboard numberKeyboard = new NumberKeyboard("", defaultValue);
  1676. numberKeyboard.KeepDecimals = keepDecimals;
  1677. var point = control.PointFromScreen(new Point(0, 0));
  1678. double wx = SystemParameters.WorkArea.Width;
  1679. double hy = SystemParameters.WorkArea.Height;
  1680. if (-point.Y + control.ActualHeight + 5 + numberKeyboard.Height < hy)
  1681. {
  1682. numberKeyboard.Top = -point.Y + control.ActualHeight + 5;
  1683. }
  1684. else
  1685. {
  1686. numberKeyboard.Top = -point.Y - numberKeyboard.Height - 5;
  1687. }
  1688. if (-point.X + numberKeyboard.Width < wx)
  1689. {
  1690. numberKeyboard.Left = -point.X;
  1691. }
  1692. else
  1693. {
  1694. numberKeyboard.Left = -point.X - (numberKeyboard.Width - control.ActualWidth);
  1695. }
  1696. if ((bool)numberKeyboard.ShowDialog())
  1697. return numberKeyboard.ValueString;
  1698. else
  1699. return "Cancel";
  1700. }
  1701. private string GetTemperatureControlMode(string val)
  1702. {
  1703. if (string.IsNullOrEmpty(val) || !val.Contains("—"))
  1704. {
  1705. return val;
  1706. }
  1707. var temperatureControlModes = val.Split('—').ToList();
  1708. SelectBtnName = temperatureControlModes.LastOrDefault();
  1709. if (temperatureControlModes.Count == 1)
  1710. {
  1711. SelectBtnName = "";
  1712. }
  1713. return temperatureControlModes.FirstOrDefault();
  1714. }
  1715. public void TempTextClick(string type, object sender)
  1716. {
  1717. var windowManager = IoC.Get<IWindowManager>();
  1718. switch (type)
  1719. {
  1720. case "Mode":
  1721. RecipeTempModeViewModel recipeTempModeViewModel = new RecipeTempModeViewModel();
  1722. recipeTempModeViewModel.CurrentRecipe = CurrentRecipe;
  1723. recipeTempModeViewModel.SelectProfileTable = SelectedRecipeStep.TemperatureControlMode.Value;
  1724. recipeTempModeViewModel.SelectBtnName = SelectBtnName;
  1725. var rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(recipeTempModeViewModel, null, "Temp Mode");
  1726. if ((bool)rtn)
  1727. {
  1728. SelectBtnName = recipeTempModeViewModel.SelectBtnName;
  1729. //SelectedRecipeStep.TemperatureControlMode.Value =recipeTempModeViewModel.ResultString;
  1730. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1731. if (foundStep != null)
  1732. {
  1733. if (null != recipeTempModeViewModel && !string.IsNullOrEmpty(recipeTempModeViewModel.ResultString) && recipeTempModeViewModel.ResultString.Contains("Profile"))
  1734. {
  1735. SelectBtnName = "Profile";
  1736. }
  1737. foundStep.TemperatureControlMode.SetValue(recipeTempModeViewModel.ResultString);
  1738. }
  1739. }
  1740. break;
  1741. case "Correct":
  1742. TempCorrectionEditViewModel tempCorrectionEditViewModel = new TempCorrectionEditViewModel();
  1743. tempCorrectionEditViewModel.CurrentRecipe = CurrentRecipe;
  1744. tempCorrectionEditViewModel.ResultString = SelectedRecipeStep.TemperatureCorrect.Value;
  1745. tempCorrectionEditViewModel.IsEnabledControl = false;
  1746. tempCorrectionEditViewModel.AutoSelectVisibility = Visibility.Visible;
  1747. // tempOffsetTableViewModel.SelectedRecipeStep = SelectedRecipeStep;
  1748. rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(tempCorrectionEditViewModel, null, "Temp Correct Table");
  1749. if ((bool)rtn)
  1750. {
  1751. // SelectedRecipeStep.TemperatureCorrect.Value = tempCorrectionEditViewModel.ResultString;
  1752. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1753. if (foundStep != null)
  1754. {
  1755. foundStep.TemperatureCorrect.SetValue(tempCorrectionEditViewModel.ResultString);
  1756. }
  1757. }
  1758. break;
  1759. case "PID":
  1760. TempOffsetTableViewModel tempOffsetTableViewModel1 = new TempOffsetTableViewModel();
  1761. tempOffsetTableViewModel1.TempOffsetTableSelected = SelectedRecipeStep.TemperaturePID.Value;
  1762. tempOffsetTableViewModel1.CurrentRecipe = CurrentRecipe;
  1763. tempOffsetTableViewModel1.IsEnabledControl = false;
  1764. tempOffsetTableViewModel1.SelectedRecipeStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1765. rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(tempOffsetTableViewModel1, null, "Temp PID Table");
  1766. if ((bool)rtn)
  1767. {
  1768. // SelectedRecipeStep.TemperaturePID.Value = tempOffsetTableViewModel1.TempOffsetTableSelected;
  1769. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1770. if (foundStep != null)
  1771. {
  1772. foundStep.TemperaturePID.SetValue(tempOffsetTableViewModel1.TempOffsetTableSelected);
  1773. }
  1774. }
  1775. break;
  1776. default:
  1777. break;
  1778. }
  1779. }
  1780. //public void TempTextChanged(string type, object sender, object item)
  1781. //{
  1782. // if (!string.IsNullOrEmpty(type) && item != null && sender != null)
  1783. // {
  1784. // TempSetData tempData = (TempSetData)item;
  1785. // string value = ((TextBox)sender).Text;
  1786. // int stepNo = SelectedRecipeStep.StepNo;
  1787. // var step = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault();
  1788. // if (step != null)
  1789. // {
  1790. // var tempValue = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().TemperatureSets.Where(x => x.Name == tempData.Name).FirstOrDefault();
  1791. // if (tempValue == null) return;
  1792. // switch (type)
  1793. // {
  1794. // case "Value":
  1795. // tempValue.SetValue.Value = value;
  1796. // break;
  1797. // case "Ramp":
  1798. // tempValue.RampngValue.Value = value;
  1799. // break;
  1800. // default:
  1801. // break;
  1802. // }
  1803. // }
  1804. // }
  1805. //}
  1806. private bool isEditMFC = false;
  1807. public void StepEdit(object cmdName, object value)
  1808. {
  1809. var windowManager = IoC.Get<IWindowManager>();
  1810. switch ((string)cmdName)
  1811. {
  1812. case "StepName":
  1813. RecipeStepNameViewModel recipeStepNameViewModel = new RecipeStepNameViewModel() { SelectedStepName = SelectedRecipeStep.Name };
  1814. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepNameViewModel, null, "Recipe Step Name"))
  1815. {
  1816. SelectedRecipeStep.Name = recipeStepNameViewModel.SelectedStepName;
  1817. }
  1818. break;
  1819. case "StepTime":
  1820. RecipeStepTimeViewModel recipeStepTimeViewModel = new RecipeStepTimeViewModel("StepTime");
  1821. if (CurrentRecipe.Steps.Count > 0)
  1822. {
  1823. var timeValue = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().Time;
  1824. recipeStepTimeViewModel.SelectTime = (timeValue == null || timeValue.Contains(':')) ? "Value" : timeValue;
  1825. if (recipeStepTimeViewModel.SelectTime == "Value")
  1826. {
  1827. recipeStepTimeViewModel.SelectValueTime = timeValue;
  1828. }
  1829. (windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepTimeViewModel, null, "Step Time Set");
  1830. if (recipeStepTimeViewModel.IsSave)
  1831. {
  1832. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().Time = recipeStepTimeViewModel.SelectTime;
  1833. if (recipeStepTimeViewModel.SelectTime == "Value")
  1834. {
  1835. SelectedRecipeStep.Time = recipeStepTimeViewModel.SelectTime + ":" + recipeStepTimeViewModel.SelectValueTime;
  1836. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault() != null)
  1837. {
  1838. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().Time = recipeStepTimeViewModel.SelectValueTime;
  1839. }
  1840. }
  1841. else
  1842. {
  1843. SelectedRecipeStep.Time = recipeStepTimeViewModel.SelectTime + ":" + recipeStepTimeViewModel.RecipeStepTime[recipeStepTimeViewModel.SelectTime];
  1844. }
  1845. }
  1846. }
  1847. break;
  1848. case "RecipeCommand":
  1849. RecipeCommandViewModel recipeCommandViewModel = new RecipeCommandViewModel();
  1850. ObservableCollection<ShowStep> loopStepNames = new ObservableCollection<ShowStep>(CurrentRecipe.Steps.OrderBy(x => x.StepNo).Where(x => x.StepNo < SelectedRecipeStep.StepNo && x.Name != "Standby").Select(x => new ShowStep() { StepNo = x.StepNo, StepName = x.Name }).ToList());
  1851. ObservableCollection<ShowStep> jumpStepNames = new ObservableCollection<ShowStep>(CurrentRecipe.Steps.OrderBy(x => x.StepNo).Where(x => x.StepNo != SelectedRecipeStep.StepNo).Select(x => new ShowStep() { StepNo = x.StepNo, StepName = x.Name }).ToList());
  1852. recipeCommandViewModel.LoopStepNames = loopStepNames;
  1853. recipeCommandViewModel.JumpStepNames = jumpStepNames;
  1854. recipeCommandViewModel.SelectedRecipeStep = SelectedRecipeStep;
  1855. recipeCommandViewModel.SelectRecipeCommand = SelectedRecipeStep.Command;
  1856. recipeCommandViewModel.RecipeData = CurrentRecipe;
  1857. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeCommandViewModel, null, "Recipe Command"))
  1858. {
  1859. SelectedRecipeStep.Command = recipeCommandViewModel.SelectRecipeCommand;
  1860. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().Command = SelectedRecipeStep.Command;
  1861. }
  1862. break;
  1863. case "ConditionCheck":
  1864. RecipeConditionCheckSetViewModel recipeConditionCheckSetViewModel = new RecipeConditionCheckSetViewModel();
  1865. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ExternalSensor != null)
  1866. {
  1867. recipeConditionCheckSetViewModel.RecipeConditions.ExternalSensor = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ExternalSensor;
  1868. }
  1869. var step = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1870. if (step != null)
  1871. {
  1872. recipeConditionCheckSetViewModel.RecipeConditions.TempStabizeSelected = step.TempStabilizeSelected;
  1873. recipeConditionCheckSetViewModel.RecipeConditions.FinishAutoProfile = step.FinishAutoProfile;
  1874. recipeConditionCheckSetViewModel.RecipeConditions.ReachTemp = step.ReachTemp;
  1875. recipeConditionCheckSetViewModel.RecipeConditions.ReachTempValue = step.ReachTempValue;
  1876. recipeConditionCheckSetViewModel.RecipeConditions.O2Density = step.O2Density;
  1877. recipeConditionCheckSetViewModel.RecipeConditions.O2DensityValue = step.O2DensityValue;
  1878. recipeConditionCheckSetViewModel.RecipeConditions.ReachPressure = step.ReachPressure;
  1879. recipeConditionCheckSetViewModel.RecipeConditions.ReachPressureVG = step.ReachPressureVG;
  1880. recipeConditionCheckSetViewModel.RecipeConditions.ReachPressureValue = step.ReachPressureValue;
  1881. recipeConditionCheckSetViewModel.RecipeConditions.PressureStabilizeVG = step.PressureStabilizeVG;
  1882. recipeConditionCheckSetViewModel.RecipeConditions.PressureStabilizeSelected = step.PressureStabilizeSelected;
  1883. recipeConditionCheckSetViewModel.RecipeConditions.ProcessTimeToEnd = step.ProcessTimeToEnd;
  1884. }
  1885. var result = (windowManager as WindowManager)?.ShowDialogWithTitle(recipeConditionCheckSetViewModel, null, "Condition Check");
  1886. if (recipeConditionCheckSetViewModel.IsSave)
  1887. {
  1888. if (recipeConditionCheckSetViewModel.IsNone)
  1889. {
  1890. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().IsnoneConditionCheck = true;
  1891. }
  1892. else
  1893. {
  1894. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().IsnoneConditionCheck = false;
  1895. }
  1896. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ExternalSensor = recipeConditionCheckSetViewModel.RecipeConditions.ExternalSensor;
  1897. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ExternalSensorName = recipeConditionCheckSetViewModel.RecipeConditions.ExternalSensorName;
  1898. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().TempStabilizeSelected = recipeConditionCheckSetViewModel.RecipeConditions.TempStabizeSelected;
  1899. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().FinishAutoProfile = recipeConditionCheckSetViewModel.RecipeConditions.FinishAutoProfile;
  1900. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachTemp = recipeConditionCheckSetViewModel.RecipeConditions.ReachTemp;
  1901. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachTempValue = recipeConditionCheckSetViewModel.RecipeConditions.ReachTempValue;
  1902. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().O2Density = recipeConditionCheckSetViewModel.RecipeConditions.O2Density;
  1903. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().O2DensityValue = recipeConditionCheckSetViewModel.RecipeConditions.O2DensityValue;
  1904. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachPressure = recipeConditionCheckSetViewModel.RecipeConditions.ReachPressure;
  1905. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachPressureVG = recipeConditionCheckSetViewModel.RecipeConditions.ReachPressureVG;
  1906. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureStabilizeVG = recipeConditionCheckSetViewModel.RecipeConditions.PressureStabilizeVG;
  1907. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachPressureValue = recipeConditionCheckSetViewModel.RecipeConditions.ReachPressureValue;
  1908. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureStabilizeSelected = recipeConditionCheckSetViewModel.RecipeConditions.PressureStabilizeSelected;
  1909. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ProcessTimeToEnd = recipeConditionCheckSetViewModel.RecipeConditions.ProcessTimeToEnd;
  1910. }
  1911. if (recipeConditionCheckSetViewModel.IsNone)//不存数据处理
  1912. { }
  1913. break;
  1914. case "AlarmAction":
  1915. Combination combination = new Combination(CurrentRecipe.ConfigItems);
  1916. AlarmConditionEditViewModel alarmConditionViewModel = new AlarmConditionEditViewModel($"Parameter\\AlarmCondition", combination.AlarmCondition, SelectedRecipeStep.AlarmConditionTable.Value);
  1917. alarmConditionViewModel.IsEnableEdit = false;
  1918. alarmConditionViewModel.RecipeType = CurrentRecipe.RecipeChamberType;
  1919. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(alarmConditionViewModel, null, "Alarm Action"))
  1920. {
  1921. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmConditionTable.SetValue(alarmConditionViewModel.ReturnString);
  1922. }
  1923. //RecipeAlarmActionViewModel recipeAlarmActionViewModel = new RecipeAlarmActionViewModel
  1924. //{
  1925. // CurrentRecipe = CurrentRecipe,
  1926. // CurrentStepName = SelectedRecipeStep.Name,
  1927. // TableIndex = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmTableIndex,
  1928. // AlarmActions = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmActionSets
  1929. //};
  1930. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeAlarmActionViewModel, null, "Alarm Action"))
  1931. //{
  1932. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmTableIndex = recipeAlarmActionViewModel.TableIndex;
  1933. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmActionSets = recipeAlarmActionViewModel.AlarmActions;
  1934. //}
  1935. break;
  1936. case "TempSetting":
  1937. if (recipeTempSetViewModel is null)
  1938. {
  1939. recipeTempSetViewModel = new RecipeTempSetViewModel
  1940. {
  1941. RecipeTemplate = RecipeTemplate
  1942. };
  1943. }
  1944. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().TemperatureSets != null)
  1945. {
  1946. var tempSets = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1947. recipeTempSetViewModel.TemperatureValues = tempSets.TemperatureSets;
  1948. //tempSets.TemperatureSets.ToList().ForEach(x => recipeTempSetViewModel.TemperatureValues.Add(x));
  1949. }
  1950. recipeTempSetViewModel.StepType = SelectedRecipeStep.Name;
  1951. recipeTempSetViewModel.RecipeType = RecipeType;
  1952. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTempSetViewModel, null, "Temp Detail"))
  1953. {
  1954. if (recipeTempSetViewModel.TemperatureValues != null && recipeTempSetViewModel.TemperatureValues.Count > 0 && recipeTempSetViewModel.IsSave)
  1955. {
  1956. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().TemperatureSets != null)
  1957. {
  1958. // var tempSets = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1959. // tempSets.TemperatureSets = recipeTempSetViewModel.TempSetDataList;
  1960. }
  1961. }
  1962. }
  1963. break;
  1964. case "GASSetting":
  1965. RecipeMFCSettingViewModel recipeMFCSettingViewModel = new RecipeMFCSettingViewModel();
  1966. //InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorRecipeOK", "");
  1967. recipeMFCSettingViewModel.MFCSets = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().MFCSets;
  1968. //recipeGASSettingViewModel.MFMSets = new MFMValue() { AlarmValue = tempMFMSets.AlarmValue, IsNotifying = tempMFMSets.IsNotifying, Name = tempMFMSets.Name, Value = tempMFMSets.Value };
  1969. recipeMFCSettingViewModel.RecipeType = RecipeType;
  1970. recipeMFCSettingViewModel.RecipeTemplate = RecipeTemplate;
  1971. if (!(bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeMFCSettingViewModel, null, "MFC Detail"))
  1972. {
  1973. //InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorPROCManualOK", "");
  1974. return;
  1975. }
  1976. //InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorPROCManualOK", "");
  1977. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().MFCSets != null)
  1978. {
  1979. if (recipeMFCSettingViewModel.MFCSets != null && recipeMFCSettingViewModel.MFCSets.Count > 0)
  1980. {
  1981. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().MFCSets = recipeMFCSettingViewModel.MFCSets;
  1982. UpdateMFCShow();
  1983. }
  1984. }
  1985. break;
  1986. case "PressureSetting":
  1987. RecipePressureSettingViewModel recipePressureSettingViewModel = new RecipePressureSettingViewModel();
  1988. var tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1989. // recipePressureSettingViewModel.PressureSonsorValue = tempStep.PressureSonserValue;
  1990. // recipePressureSettingViewModel.PressureValveAngleValue = tempStep.PressureValveAngle;
  1991. // recipePressureSettingViewModel.PressureSettingVG = tempStep.PressureSettingVG;
  1992. //if (!string.IsNullOrEmpty(tempStep.PressureAlarmTableNo))
  1993. //{
  1994. // if (tempStep.PressureAlarmTableNo.ToLower() == "none")
  1995. // recipePressureSettingViewModel.PressureAlarmWatchTable = "None";
  1996. // else
  1997. // recipePressureSettingViewModel.PressureAlarmWatchTable = tempStep.PressureAlarmTableNo;
  1998. //}
  1999. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipePressureSettingViewModel, null, "Recipe Pressure Setting"))
  2000. //{
  2001. // if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault() != null)
  2002. // {
  2003. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureSonserValue = recipePressureSettingViewModel.PressureSonsorValue;
  2004. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureValveAngle = recipePressureSettingViewModel.PressureValveAngleValue;
  2005. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureAlarmTableNo = recipePressureSettingViewModel.PressureAlarmWatchTable;
  2006. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureSettingVG = recipePressureSettingViewModel.PressureSettingVG;
  2007. // // SelectedRecipeStep.PressureSonserValue = $"{recipePressureSettingViewModel.PressureSonsorValue}";
  2008. // }
  2009. //}
  2010. break;
  2011. case "RFSetting":
  2012. //RecipeRFPressureSettingViewModel recipeRFPressureSettingViewModel = new RecipeRFPressureSettingViewModel();
  2013. //var tempRecipeStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2014. //recipeRFPressureSettingViewModel.RFSwitch = tempRecipeStep.RFSwitch;
  2015. //recipeRFPressureSettingViewModel.RFSetPointValue = tempRecipeStep.RFSetpoint;
  2016. //recipeRFPressureSettingViewModel.C1SetPointValue = tempRecipeStep.C1Setpoint;
  2017. //recipeRFPressureSettingViewModel.C2SetPointValue = tempRecipeStep.C2Setpoint;
  2018. //recipeRFPressureSettingViewModel.ForwardPowerAlarmWatchSetPointValue = tempRecipeStep.ForwardPowerAlarmWatchTable;
  2019. //recipeRFPressureSettingViewModel.PrAlarmWatchSetPointValue = tempRecipeStep.PrAlarmWatchTable;
  2020. //recipeRFPressureSettingViewModel.PIAlarmWatchSetPointValue = tempRecipeStep.PIAlarmWatchTable;
  2021. //recipeRFPressureSettingViewModel.C1AlarmWatchSetPointValue = tempRecipeStep.C1AlarmWatchTable;
  2022. //recipeRFPressureSettingViewModel.C2AlarmWatchSetPointValue = tempRecipeStep.C2AlarmWatchTable;
  2023. //recipeRFPressureSettingViewModel.VppAlarmWatchSetPointValue = tempRecipeStep.VppAlarmWatchTable;
  2024. //recipeRFPressureSettingViewModel.VdcAlarmWatchSetPointValue = tempRecipeStep.VdcAlarmWatchTable;
  2025. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeRFPressureSettingViewModel, null, "Recipe RF Setting"))
  2026. //{
  2027. // if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault() != null)
  2028. // {
  2029. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RFSwitch = recipeRFPressureSettingViewModel.RFSwitch;
  2030. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RFSetpoint = recipeRFPressureSettingViewModel.RFSetPointValue;
  2031. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().C1Setpoint = recipeRFPressureSettingViewModel.C1SetPointValue;
  2032. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().C2Setpoint = recipeRFPressureSettingViewModel.C2SetPointValue;
  2033. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ForwardPowerAlarmWatchTable = recipeRFPressureSettingViewModel.ForwardPowerAlarmWatchSetPointValue;
  2034. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PrAlarmWatchTable = recipeRFPressureSettingViewModel.PrAlarmWatchSetPointValue;
  2035. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PIAlarmWatchTable = recipeRFPressureSettingViewModel.PIAlarmWatchSetPointValue;
  2036. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().C1AlarmWatchTable = recipeRFPressureSettingViewModel.C1AlarmWatchSetPointValue;
  2037. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().C2AlarmWatchTable = recipeRFPressureSettingViewModel.C2AlarmWatchSetPointValue;
  2038. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().VppAlarmWatchTable = recipeRFPressureSettingViewModel.VppAlarmWatchSetPointValue;
  2039. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().VdcAlarmWatchTable = recipeRFPressureSettingViewModel.VdcAlarmWatchSetPointValue;
  2040. // // SelectedRecipeStep.RFSetting = $"{recipeRFPressureSettingViewModel.RFSetPointValue}";
  2041. // }
  2042. //}
  2043. break;
  2044. case "Loader":
  2045. RecipeLoaderCommandViewModel recipeLoaderCommandViewModel = new RecipeLoaderCommandViewModel();
  2046. tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2047. recipeLoaderCommandViewModel.SelectedCmd = tempStep.LoaderCommand.Value;
  2048. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeLoaderCommandViewModel, null, "Loader Command"))
  2049. {
  2050. if (tempStep.LoaderCommand.Value != recipeLoaderCommandViewModel.ReturnString)
  2051. {
  2052. ClearLoaderSetValue();
  2053. }
  2054. tempStep.LoaderCommand.SetValue(recipeLoaderCommandViewModel.ReturnString);
  2055. SelectedRecipeStep.LoaderCommand.SetValue(recipeLoaderCommandViewModel.ReturnString);
  2056. SetShowLoaderValuePanel(recipeLoaderCommandViewModel.ReturnString);
  2057. }
  2058. break;
  2059. case "Pressure":
  2060. RecipePressCommandViewModel recipePressCommandViewModel = new RecipePressCommandViewModel();
  2061. tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2062. recipePressCommandViewModel.SelectedCmd = tempStep.PressCommand.Value;
  2063. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipePressCommandViewModel, null, "Press Command"))
  2064. {
  2065. tempStep.PressCommand.SetValue(recipePressCommandViewModel.ReturnString);
  2066. SelectedRecipeStep.PressCommand.SetValue(recipePressCommandViewModel.ReturnString);
  2067. SetShowPressPanel(recipePressCommandViewModel.ReturnString);
  2068. }
  2069. break;
  2070. case "PressureWait":
  2071. RecipePressureWaitViewModel recipePressureWaitViewModel = new RecipePressureWaitViewModel();
  2072. tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2073. var destinationStep = tempStep.Adapt<Step>();
  2074. destinationStep.StepNo = tempStep.StepNo;
  2075. destinationStep.PressWaitUnit.SetValue((string)QueryDataClient.Instance.Service.GetConfig($"PM1.APC.PressureUnit"));
  2076. recipePressureWaitViewModel.SelectedStep = destinationStep;
  2077. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipePressureWaitViewModel, null, "Press WaitSet"))
  2078. {
  2079. tempStep.PressIsWait = recipePressureWaitViewModel.SelectedStep.PressIsWait;
  2080. tempStep.PressLowWait = recipePressureWaitViewModel.SelectedStep.PressLowWait;
  2081. tempStep.PressHighWait = recipePressureWaitViewModel.SelectedStep.PressHighWait;
  2082. tempStep.PressWaitUnit = recipePressureWaitViewModel.SelectedStep.PressWaitUnit;
  2083. }
  2084. break;
  2085. case "Pattern":
  2086. if (SelectedRecipeStep != null)
  2087. {
  2088. string toolType = (string)QueryDataClient.Instance.Service.GetConfig("System.SetUp.ToolType");
  2089. isEditMFC = true;
  2090. if (ConstantsCommon.ELK.Equals(toolType))
  2091. {
  2092. using (FurnaceUI.Views.Editors.ELK.RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new FurnaceUI.Views.Editors.ELK.RecipeGasPanelSettingViewModel())
  2093. {
  2094. recipeGasPanelSettingViewModel.CurrentRecipe = CurrentRecipe;
  2095. recipeGasPanelSettingViewModel.SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}";
  2096. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  2097. recipeGasPanelSettingViewModel.SelectedStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2098. bool rtn = (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Recipe Gas View");
  2099. if (rtn)
  2100. {
  2101. isEditMFC = false;
  2102. }
  2103. }
  2104. }
  2105. else if (ConstantsCommon.SIBCN.Equals(toolType))
  2106. {
  2107. using (FurnaceUI.Views.Editors.SiBCN.RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new FurnaceUI.Views.Editors.SiBCN.RecipeGasPanelSettingViewModel())
  2108. {
  2109. recipeGasPanelSettingViewModel.CurrentRecipe = CurrentRecipe;
  2110. recipeGasPanelSettingViewModel.SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}";
  2111. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  2112. recipeGasPanelSettingViewModel.SelectedStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2113. bool rtn = (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Valve");
  2114. if (rtn)
  2115. {
  2116. isEditMFC = false;
  2117. }
  2118. }
  2119. }
  2120. else if (ConstantsCommon.TiN.Equals(toolType))
  2121. {
  2122. using (FurnaceUI.Views.Editors.TiN.RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new FurnaceUI.Views.Editors.TiN.RecipeGasPanelSettingViewModel())
  2123. {
  2124. recipeGasPanelSettingViewModel.CurrentRecipe = CurrentRecipe;
  2125. recipeGasPanelSettingViewModel.SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}";
  2126. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  2127. recipeGasPanelSettingViewModel.SelectedStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2128. bool rtn = (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Valve");
  2129. if (rtn)
  2130. {
  2131. isEditMFC = false;
  2132. }
  2133. }
  2134. }
  2135. else
  2136. {
  2137. RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new RecipeGasPanelSettingViewModel();
  2138. recipeGasPanelSettingViewModel.CurrentRecipe = CurrentRecipe;
  2139. recipeGasPanelSettingViewModel.SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}";
  2140. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  2141. recipeGasPanelSettingViewModel.SelectedStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2142. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Valve"))
  2143. {
  2144. }
  2145. }
  2146. }
  2147. break;
  2148. case "BoatElevatorSetting":
  2149. //BoatElevatorSettingViewModel boatElevatorSettingViewModel = new BoatElevatorSettingViewModel();
  2150. //boatElevatorSettingViewModel.SelectedRecipeStep = SelectedRecipeStep;
  2151. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(boatElevatorSettingViewModel, null, "BoatElevator Setting"))
  2152. //{
  2153. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ZAxisPosition = boatElevatorSettingViewModel.SelectedRecipeStep.ZAxisPosition;
  2154. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ZAxisSpeed = boatElevatorSettingViewModel.SelectedRecipeStep.ZAxisSpeed;
  2155. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RotatePosition = boatElevatorSettingViewModel.SelectedRecipeStep.RotatePosition;
  2156. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RotateSpeed = boatElevatorSettingViewModel.SelectedRecipeStep.RotateSpeed;
  2157. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RotateInterval = boatElevatorSettingViewModel.SelectedRecipeStep.RotateInterval;
  2158. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RotateDirection = boatElevatorSettingViewModel.SelectedRecipeStep.RotateDirection;
  2159. //}
  2160. break;
  2161. case "AUX":
  2162. if (SelectedRecipeStep == null || SelectedRecipeStep.AUXSets.Count == 0)
  2163. { return; }
  2164. RecipeAUXSetViewModel recipeAUXSetViewModel = new RecipeAUXSetViewModel();
  2165. recipeAUXSetViewModel.AUXDataList = SelectedRecipeStep.AUXSets;
  2166. if (!(bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeAUXSetViewModel, null, "AUX Set"))
  2167. {
  2168. // SelectedRecipeStep.UndoAUXChanges();
  2169. }
  2170. break;
  2171. case "RecipeHeader":
  2172. RecipeHeaderViewModel recipeHeaderViewModel = new RecipeHeaderViewModel();
  2173. recipeHeaderViewModel.CombinationData = new Combination(CurrentRecipe.ConfigItems);
  2174. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeHeaderViewModel, null, "Recipe Header"))
  2175. {
  2176. recipeHeaderViewModel.CombinationData.SetValueToParam();
  2177. }
  2178. break;
  2179. case "Combination":
  2180. RecipeCombinationViewModel recipeCombinationViewModel = new RecipeCombinationViewModel();
  2181. recipeCombinationViewModel.CombinationData = new Combination(CurrentRecipe.ConfigItems);
  2182. recipeCombinationViewModel.CombinationData.ChangedValueEvent += CombinationData_ChangedValueEvent;
  2183. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeCombinationViewModel, null, "Combination"))
  2184. {
  2185. recipeCombinationViewModel.CombinationData.SetValueToParam();
  2186. }
  2187. break;
  2188. case "VPDataList":
  2189. RecipeVPItemSelectViewModel recipeVPItemSelectViewModel = new RecipeVPItemSelectViewModel();
  2190. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeVPItemSelectViewModel, null, "VP Item Select"))
  2191. {
  2192. }
  2193. break;
  2194. case "AbortRecipe":
  2195. Step currentStep = CurrentRecipe.Steps.FirstOrDefault(x => x.StepNo == SelectedRecipeStep.StepNo);
  2196. StringParam abortCombination = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "Combination.AbortRecipe") as StringParam;
  2197. if (string.IsNullOrEmpty(abortCombination.Value))
  2198. {
  2199. DialogBox.ShowError("Please select abort recipe first!");
  2200. }
  2201. var retRecipe = RecipeTableSelect.ShowDialog($"Furnace\\abort", abortCombination.Value, false);
  2202. if (!string.IsNullOrEmpty(retRecipe))
  2203. {
  2204. currentStep.AbortRecipeTableIndex = retRecipe;
  2205. SelectedRecipeStep.AbortRecipeTableIndex = retRecipe;
  2206. }
  2207. break;
  2208. case "SkipOrWait":
  2209. RecipeSkipWaitCommandViewModel recipeSkipWaitCommandViewModel = new RecipeSkipWaitCommandViewModel();
  2210. recipeSkipWaitCommandViewModel.SkipWait = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().SkipWait;
  2211. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeSkipWaitCommandViewModel, null, "Skip or wait command"))
  2212. {
  2213. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().SkipWait = recipeSkipWaitCommandViewModel.RtnString;
  2214. SelectedRecipeStep.SkipWait = recipeSkipWaitCommandViewModel.RtnString;
  2215. }
  2216. break;
  2217. default:
  2218. break;
  2219. }
  2220. }
  2221. private void CombinationData_ChangedValueEvent(string type, string value)
  2222. {
  2223. string prefix = "";
  2224. switch (type)
  2225. {
  2226. case "SubRecipe":
  2227. break;
  2228. case "AlarmRecipe":
  2229. break;
  2230. case "AbortRecipePath":
  2231. break;
  2232. case "AlarmCondition":
  2233. break;
  2234. case "LeakCheck":
  2235. break;
  2236. case "PressAPCPID":
  2237. prefix = $"Parameter\\APCPID";
  2238. var pressAPCDictData = LoadData(prefix, value);
  2239. foreach (var item in CurrentRecipe.Steps)
  2240. {
  2241. if (item.PressPID.Value.Contains(","))
  2242. {
  2243. var pidList = item.PressPID.Value.Split(',');
  2244. if (pidList.Count() > 2)
  2245. {
  2246. pidList[0] = $"{prefix}\\{value}";
  2247. int pressAPCTempNo = 0;
  2248. int.TryParse(pidList[1], out pressAPCTempNo);
  2249. if (pressAPCDictData != null && pressAPCDictData.ContainsKey(pressAPCTempNo))
  2250. {
  2251. pidList[2] = pressAPCDictData[pressAPCTempNo];
  2252. }
  2253. item.PressPID.Value = string.Join(",", pidList);
  2254. }
  2255. }
  2256. }
  2257. break;
  2258. case "TempCorrection":
  2259. prefix = $"Parameter\\TempCorrection";
  2260. var tempCorDictData = LoadData(prefix, value);
  2261. foreach (var item in CurrentRecipe.Steps)
  2262. {
  2263. if (item.TemperatureCorrect.Value.Contains(","))
  2264. {
  2265. var pidList = item.TemperatureCorrect.Value.Split(',');
  2266. if (pidList.Count() > 2)
  2267. {
  2268. pidList[0] = $"{prefix}\\{value}";
  2269. int tempCorTempNo = 0;
  2270. int.TryParse(pidList[1], out tempCorTempNo);
  2271. if (tempCorDictData != null && tempCorDictData.ContainsKey(tempCorTempNo))
  2272. {
  2273. pidList[2] = tempCorDictData[tempCorTempNo];
  2274. }
  2275. item.TemperatureCorrect.Value = string.Join(",", pidList);
  2276. }
  2277. }
  2278. }
  2279. break;
  2280. case "TempPID":
  2281. prefix = $"Parameter\\TempPID";
  2282. var tempPIDDictData = LoadData(prefix, value);
  2283. foreach (var item in CurrentRecipe.Steps)
  2284. {
  2285. if (item.TemperaturePID.Value.Contains(","))
  2286. {
  2287. var pidList = item.TemperaturePID.Value.Split(',');
  2288. if (pidList.Count() > 2)
  2289. {
  2290. pidList[0] = $"{prefix}\\{value}";
  2291. int tempTempNo = 0;
  2292. int.TryParse(pidList[1], out tempTempNo);
  2293. if (tempPIDDictData != null && tempPIDDictData.ContainsKey(tempTempNo))
  2294. {
  2295. pidList[2] = tempPIDDictData[tempTempNo];
  2296. }
  2297. }
  2298. item.TemperaturePID.Value = string.Join(",", pidList);
  2299. }
  2300. }
  2301. break;
  2302. case "ProfileCondition":
  2303. break;
  2304. default:
  2305. break;
  2306. }
  2307. }
  2308. public TempPIDParameterData CurrentParameter { get; set; } = new TempPIDParameterData();
  2309. private readonly ParameterProvider _parameterProvider = new ParameterProvider();
  2310. private Dictionary<int, string> LoadData(string PrefixPath, string name)
  2311. {
  2312. var recipeContent = _parameterProvider.LoadParameter(PrefixPath, name);
  2313. if (string.IsNullOrEmpty(recipeContent))
  2314. {
  2315. System.Windows.MessageBox.Show($"{PrefixPath}\\{name} is empty, please confirm the file is valid.");
  2316. return null;
  2317. }
  2318. var parameter = new TempPIDParameterData();
  2319. parameter.PrefixPath = PrefixPath;
  2320. parameter.Name = name;
  2321. parameter.InitData(PrefixPath, name, recipeContent, "");
  2322. var dictData = new Dictionary<int, string>();
  2323. if (parameter != null && parameter.Steps.Count > 0)
  2324. {
  2325. foreach (var item in parameter.Steps)
  2326. {
  2327. dictData.Add(item.StepNo, item.Name);
  2328. }
  2329. }
  2330. return dictData;
  2331. }
  2332. public void LowPressWaitTextChanged(object sender, object item)
  2333. {
  2334. if (SelectedRecipeStep == null)
  2335. {
  2336. DialogBox.ShowWarning("The current step is empty!");
  2337. return;
  2338. }
  2339. SelectExistViewModel selectExistViewModel = new SelectExistViewModel();
  2340. selectExistViewModel.ProductZeroStr = SelectedRecipeStep.PressLowPressWait.Value;
  2341. var windowManager = IoC.Get<IWindowManager>();
  2342. var dialogReturn = (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(selectExistViewModel, null, "Select");
  2343. if ((bool)dialogReturn)
  2344. {
  2345. SelectedRecipeStep.PressLowPressWait.SetValue(selectExistViewModel.DialogResultString);
  2346. }
  2347. }
  2348. public void UpdateTotalTime()
  2349. {
  2350. if (CurrentRecipe != null && CurrentRecipe.ConfigItems != null)
  2351. {
  2352. var param = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "RecipeTime");
  2353. string outAlarmSet = "0";
  2354. if (param != null && param is StringParam)
  2355. {
  2356. List<double> timeList = new List<double>();
  2357. foreach (var item in CurrentRecipe.Steps)
  2358. {
  2359. var timeStr = item.Time;
  2360. if (timeStr != null)
  2361. {
  2362. double hhTime = 0;
  2363. double mmTime = 0;
  2364. double ssTime = 0;
  2365. var strs = timeStr.Split(':');
  2366. if (strs.Length < 3) continue;
  2367. double.TryParse(strs[0], out hhTime);
  2368. double.TryParse(strs[1], out mmTime);
  2369. double.TryParse(strs[2], out ssTime);
  2370. timeList.Add(hhTime * 3600 + mmTime * 60 + ssTime);
  2371. }
  2372. else
  2373. {
  2374. continue;
  2375. }
  2376. }
  2377. string sumValue = timeList.ToArray().Sum().ToString();
  2378. if (((StringParam)param).Value != sumValue)
  2379. {
  2380. ((StringParam)param).Value = sumValue;
  2381. //outAlarmSet = (timeList.ToArray().Sum() * 10).ToString();
  2382. }
  2383. }
  2384. var paramTimeOut = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "TimeOutAlarmSet");
  2385. if (paramTimeOut != null && param is DoubleParam)
  2386. {
  2387. if (outAlarmSet != "0")
  2388. {
  2389. ((DoubleParam)paramTimeOut).Value = outAlarmSet;
  2390. }
  2391. }
  2392. }
  2393. }
  2394. public void RecipeSave()
  2395. {
  2396. List<string> noNeedEndRecipeType = new List<string>() {
  2397. "reset",
  2398. "idle",
  2399. "abort",
  2400. "sub",
  2401. "alarm",
  2402. };
  2403. var SelectedStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2404. //if (SelectedStep != null)
  2405. //{
  2406. // SelectedStep.LoaderValue = GetSaveLoaderValue(SelectedStep.LoaderCommand);
  2407. // SelectedStep.PressValue = GetSavePressValue(SelectedStep.PressCommand);
  2408. //}
  2409. RecipePermissionSelectViewModel dialog = new RecipePermissionSelectViewModel("Save recipe and permission", CurrentRecipe.RecipePermission, CurrentRecipe.Description);
  2410. WindowManager wm = new WindowManager();
  2411. bool? dialogReturn = wm.ShowDialog(dialog);
  2412. if (!dialogReturn.HasValue || !dialogReturn.Value)
  2413. return;
  2414. this.CurrentRecipe.ReviseTime = DateTime.Now;
  2415. CurrentRecipe.Description = dialog.RecipeComment;
  2416. InvokeClient.Instance.Service.DoOperation("SetRecipeEditHistory", this.CurrentRecipe.GetRecipeHistory());
  2417. List<string> names = new List<string>();
  2418. string filmFormula = string.Empty;
  2419. Step step = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2420. if (string.IsNullOrEmpty(CurrentRecipe.Name))
  2421. {
  2422. DialogBox.ShowWarning("Recipe name is empty,can not save!");
  2423. return;
  2424. }
  2425. bool bStandby = false, bEnd;
  2426. foreach (Step recipestep in CurrentRecipe.Steps)
  2427. {
  2428. if (recipestep.StepNo == 0)
  2429. bStandby = true;
  2430. //DialogBox.ShowWarning($"{recipestep.TemperatureControlMode}");
  2431. //DialogBox.ShowWarning($"{recipestep.TemperatureCorrect}");
  2432. //DialogBox.ShowWarning($"{recipestep.TemperaturePID}");
  2433. //if (string.IsNullOrEmpty(filmFormula))
  2434. // filmFormula = recipestep.FilmThickFormula;
  2435. //if (filmFormula != recipestep.FilmThickFormula)
  2436. //{
  2437. // DialogBox.ShowWarning($"The step film thicknesss formula of step number {recipestep.StepNo} is different,can not save!");
  2438. // return;
  2439. //}
  2440. if (string.IsNullOrEmpty(recipestep.Name) || string.IsNullOrEmpty(recipestep.Time))
  2441. {
  2442. if (recipestep.Name != "Standby")
  2443. {
  2444. DialogBox.ShowWarning($"The step name or time of step number {recipestep.StepNo} is empty,can not save!");
  2445. return;
  2446. }
  2447. }
  2448. if (names.Where(x => x == recipestep.Name).FirstOrDefault() != null)
  2449. {
  2450. DialogBox.ShowWarning("Step name cannot be duplicated!");
  2451. return;
  2452. }
  2453. names.Add(recipestep.Name);
  2454. bEnd = bStandby ? recipestep.StepNo == CurrentRecipe.Steps.Count - 1 : recipestep.StepNo == CurrentRecipe.Steps.Count;
  2455. //// "reset/Idle/abort/sub"类型的Recipe不需要End结尾
  2456. if (bEnd == true && noNeedEndRecipeType.Contains(CurrentRecipe.RecipeChamberType.ToLower()))
  2457. {
  2458. bEnd = false;
  2459. }
  2460. //是否是最后一步
  2461. if (bEnd)
  2462. {
  2463. if (!recipestep.Name.ToUpper().Contains("END"))
  2464. {
  2465. DialogBox.ShowWarning("The step command of last step must be 'END',please check!");
  2466. return;
  2467. }
  2468. }
  2469. }
  2470. // step.SetStepValues(SelectedRecipeStep);
  2471. this.CurrentRecipe.Revisor = BaseApp.Instance.UserContext.LoginName;
  2472. this.CurrentRecipe.ReviseTime = DateTime.Now;
  2473. this.CurrentRecipe.RecipeLevel = this.LevelDisplay;
  2474. this.CurrentRecipe.RecipePermission = dialog.RecipeComment;
  2475. UpdateTotalTime();
  2476. var result = this._recipeProvider.SaveRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name, CurrentRecipe.GetXmlString());
  2477. if (result)
  2478. {
  2479. ((Window)GetView()).DialogResult = true;
  2480. }
  2481. }
  2482. public List<ConfigNode> GetMfcItem()
  2483. {
  2484. this.SystemName = "System";
  2485. ConfigNodes = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  2486. var MfcItems = ConfigNodes.Where(x => x.Display == "Parameter").FirstOrDefault().SubNodes.Where(y => y.Name == "MFC").FirstOrDefault().SubNodes;
  2487. return MfcItems;
  2488. }
  2489. public void RecipeCancel()
  2490. {
  2491. if (DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM, " You confirm that you want to unsave the recipe and exit the interface?") == DialogButton.No)
  2492. return;
  2493. ((Window)GetView()).DialogResult = false;
  2494. }
  2495. public void PressPIDChick()
  2496. {
  2497. var windowManager = IoC.Get<IWindowManager>();
  2498. StringParam pressAPC = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "Combination.PressAPCPID") as StringParam;
  2499. if (pressAPC == null)
  2500. {
  2501. DialogBox.ShowDialog(DialogButton.Cancel, DialogType.INFO, "Please set the combination file first");
  2502. return;
  2503. }
  2504. APCPIDEditViewModel aPCPIDEditViewModel = new APCPIDEditViewModel();
  2505. aPCPIDEditViewModel.IsEditEnabled = false;
  2506. aPCPIDEditViewModel.CurrentRecipe = CurrentRecipe;
  2507. var rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(aPCPIDEditViewModel, null, "APC PID Table");
  2508. if ((bool)rtn && SelectedRecipeStep != null)
  2509. SelectedRecipeStep.PressPID.SetValue(aPCPIDEditViewModel.RetrunString);
  2510. }
  2511. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  2512. {
  2513. base.InvokeAfterUpdateProperty(data);
  2514. if (SelectedRecipeStep != null)
  2515. {
  2516. if (CurrentRecipe.RecipeChamberType == RecipeDataBase.ProcessType)
  2517. {
  2518. SelectIndex = SelectedRecipeStep.StepNo + 1;
  2519. }
  2520. else
  2521. {
  2522. SelectIndex = SelectedRecipeStep.StepNo;
  2523. }
  2524. }
  2525. if (CurrentRecipe.Steps != null && CurrentRecipe.Steps.Count > 0 && CheckValueChange(data))
  2526. {
  2527. // UpdateRecipeGASSetting(data);
  2528. //SelectStep(CurrentRecipe.Steps[EditRecipeStepNo]);
  2529. }
  2530. // UpdateGASSetting();
  2531. oldresult = data;
  2532. SetCmdIsEnabled();
  2533. }
  2534. Dictionary<string, object> oldresult;
  2535. private bool CheckValueChange(Dictionary<string, object> result)
  2536. {
  2537. Dictionary<string, object> temp = result;
  2538. if (oldresult == null)
  2539. {
  2540. oldresult = result;
  2541. return true;
  2542. }
  2543. else
  2544. {
  2545. List<string> strkeys = new List<string>();
  2546. foreach (var key in result.Keys)
  2547. {
  2548. if (_subscribedKeys.Contains(key) && oldresult.ContainsKey(key) && result.ContainsKey(key))
  2549. {
  2550. if (result[key].GetType() == typeof(AITValveData) && ((AITValveData)oldresult[key]).VirtualFeedback != ((AITValveData)result[key]).VirtualFeedback)
  2551. {
  2552. return true;
  2553. }
  2554. else if (result[key].GetType() == typeof(AITMfcData) && ((AITMfcData)oldresult[key]).VirtualSetPoint != ((AITMfcData)result[key]).VirtualSetPoint)
  2555. {
  2556. return true;
  2557. }
  2558. else if (result[key].GetType() == typeof(bool) && (bool)oldresult[key] != (bool)result[key])
  2559. {
  2560. return true;
  2561. }
  2562. }
  2563. }
  2564. }
  2565. return false;
  2566. }
  2567. public void SetValue(object sender)
  2568. {
  2569. string value = ((TextBox)sender).Text;
  2570. NumberKeyboard fullKeyboard = new NumberKeyboard("", value);
  2571. if ((bool)fullKeyboard.ShowDialog())
  2572. {
  2573. ((TextBox)sender).Text = fullKeyboard.ValueString;
  2574. }
  2575. }
  2576. public void SetValue(object sender, string isFullKeyboard = "")
  2577. {
  2578. string value = ((TextBox)sender).Text;
  2579. if (!string.IsNullOrEmpty(isFullKeyboard))
  2580. {
  2581. FullKeyboard fullKeyboard1 = new FullKeyboard("", value);
  2582. if ((bool)fullKeyboard1.ShowDialog())
  2583. {
  2584. ((TextBox)sender).Text = fullKeyboard1.ValueString;
  2585. }
  2586. }
  2587. else
  2588. {
  2589. NumberKeyboard fullKeyboard = new NumberKeyboard("", value);
  2590. if ((bool)fullKeyboard.ShowDialog())
  2591. {
  2592. ((TextBox)sender).Text = fullKeyboard.ValueString;
  2593. }
  2594. }
  2595. }
  2596. public void MFCTextChanged(string type, object sender, object item)
  2597. {
  2598. if (!string.IsNullOrEmpty(type) && item != null && sender != null)
  2599. {
  2600. //if (isEditMFC) return;
  2601. MFCData mFCData = (MFCData)item;
  2602. string value = ((TextBox)sender).Text;
  2603. switch (type)
  2604. {
  2605. case "Value":
  2606. double setValue = 0;
  2607. double.TryParse(value, out setValue);
  2608. double.TryParse(mFCData.ScaleValue, out double maxData);
  2609. if (setValue > maxData)
  2610. {
  2611. DialogBox.ShowWarning($"{mFCData.ControlName} Out of the setting range {0}~{maxData}!");
  2612. ((TextBoxEx)sender).ChangedColor = ((TextBoxEx)sender).NormalColor;
  2613. SetSetPointValue(mFCData.ControlName, $"0");
  2614. return;
  2615. }
  2616. else
  2617. {
  2618. BrushConverter brushConverter = new BrushConverter();
  2619. if (setValue > 0)
  2620. {
  2621. ((TextBoxEx)sender).ChangedColor = (Brush)brushConverter.ConvertFromString("Yellow");
  2622. }
  2623. InvokeClient.Instance.Service.DoOperation($"PM1.{mFCData.ControlName}.SetMfcVirtualValue", $"{value};{mFCData.Rampng.Value};{mFCData.AlarmValue}");
  2624. }
  2625. break;
  2626. case "Rampng":
  2627. InvokeClient.Instance.Service.DoOperation($"PM1.{mFCData.ControlName}.SetMfcVirtualValue", $"{mFCData.SetValue.Value};{value};{mFCData.AlarmValue}");
  2628. SetRampngValue(mFCData.DisplayName, value);
  2629. break;
  2630. default:
  2631. break;
  2632. }
  2633. }
  2634. }
  2635. private void SetSetPointValue(string name, string value)
  2636. {
  2637. if (double.TryParse(value, out double getValue))
  2638. {
  2639. var stepNo = 0;
  2640. if (!_isStandbyCheckedSelect)
  2641. stepNo = SelectedRecipeStep.StepNo;
  2642. var step = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault();
  2643. if (step != null)
  2644. {
  2645. var mfc = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().MFCSets.FirstOrDefault(x => x.ControlName == name);
  2646. if (mfc != null)
  2647. {
  2648. mfc.SetValue.SetValue(value);
  2649. }
  2650. }
  2651. }
  2652. }
  2653. public void PressTextChanged(string type, object sender, object item)
  2654. {
  2655. if (!string.IsNullOrEmpty(type) && item != null && sender != null)
  2656. {
  2657. Step step = (Step)item;
  2658. if (step.StepNo != OldStep.StepNo)
  2659. {
  2660. return;
  2661. }
  2662. //string value = ((TextBox)sender).Text;
  2663. //switch (type)
  2664. //{
  2665. // case "PressSet":
  2666. // step.PressSet.IsSaved = false;
  2667. // break;
  2668. // case "PressSlowVacSet":
  2669. // step.PressSlowVacSet.IsSaved = false;
  2670. // break;
  2671. // case "PressValveAngleSet":
  2672. // step.PressValveAngleSet.IsSaved = false;
  2673. // break;
  2674. // case "PressLowPressWait":
  2675. // step.PressLowPressWait.IsSaved = false;
  2676. // break;
  2677. // case "WaitPress":
  2678. // step.WaitPress.IsSaved = false;
  2679. // break;
  2680. // default:
  2681. // break;
  2682. //}
  2683. }
  2684. }
  2685. //public void PressValidated(string type, object sender, object item)
  2686. //{
  2687. // if (!string.IsNullOrEmpty(type) && item != null && sender != null)
  2688. // {
  2689. // Step step = (Step)item;
  2690. // if (step.StepNo != OldStep.StepNo)
  2691. // {
  2692. // return;
  2693. // }
  2694. // string value = ((TextBox)sender).Text;
  2695. // switch (type)
  2696. // {
  2697. // case "PressSet":
  2698. // step.PressSet.IsSaved = false;
  2699. // break;
  2700. // case "PressSlowVacSet":
  2701. // step.PressSlowVacSet.IsSaved = false;
  2702. // break;
  2703. // case "PressValveAngleSet":
  2704. // step.PressValveAngleSet.IsSaved = false;
  2705. // break;
  2706. // case "PressLowPressWait":
  2707. // step.PressLowPressWait.IsSaved = false;
  2708. // break;
  2709. // case "WaitPress":
  2710. // step.WaitPress.IsSaved = false;
  2711. // break;
  2712. // default:
  2713. // break;
  2714. // }
  2715. // }
  2716. //}
  2717. private void SetRampngValue(string name, string value)
  2718. {
  2719. if (double.TryParse(value, out double getValue))
  2720. {
  2721. var stepNo = 0;
  2722. if (!_isStandbyCheckedSelect)
  2723. stepNo = SelectedRecipeStep.StepNo;
  2724. var step = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault();
  2725. if (step != null)
  2726. {
  2727. var mfc = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().MFCSets.FirstOrDefault(x => x.ControlName == name);
  2728. if (mfc != null)
  2729. {
  2730. mfc.Rampng.SetValue(value);
  2731. }
  2732. }
  2733. }
  2734. }
  2735. private void UpdateMFCShow()
  2736. {
  2737. var mfcDict = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().MFCSets;
  2738. foreach (var item in mfcDict)
  2739. {
  2740. //var mfc = MFCDataList.FirstOrDefault(x => x.Name == item.Key.Replace(".Flow", ""));
  2741. //if (mfc != null)
  2742. //{
  2743. // mfc.IsCheck = item.Value.IsCheck;
  2744. //}
  2745. }
  2746. }
  2747. private void UpdateRecipeGASSetting(Dictionary<string, object> result)
  2748. {
  2749. var stepNo = 0;
  2750. if (!_isStandbyCheckedSelect)
  2751. stepNo = SelectedRecipeStep.StepNo;
  2752. var step = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault();
  2753. if (step != null)
  2754. {
  2755. var mfcSets = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().MFCSets;
  2756. var valveSets = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().ValveSets;
  2757. foreach (var key in result.Keys)
  2758. {
  2759. //if (result[key].GetType() == typeof(AITValveData))
  2760. //{
  2761. // var valveData = (AITValveData)result[key];
  2762. // if (valveSets.ContainsKey(valveData.DeviceName))
  2763. // {
  2764. // valveSets[valveData.DeviceName] = valveData.VirtualFeedback ? "Open" : "Close";
  2765. // }
  2766. //}else
  2767. if (result[key].GetType() == typeof(AITMfcData))
  2768. {
  2769. var mfcData = (AITMfcData)result[key];
  2770. var name = $"{mfcData.DeviceName}.Flow";
  2771. var findMFC = mfcSets.FirstOrDefault(x => x.ControlName == name);
  2772. if (findMFC != null)
  2773. {
  2774. findMFC.SetValue.Value = mfcData.VirtualSetPoint.ToString();
  2775. findMFC.Rampng.Value = mfcData.VirtualRamping.ToString();
  2776. findMFC.AlarmValue = mfcData.VirtualAlarmWatchTable;
  2777. }
  2778. }
  2779. }
  2780. CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().MFCSets = mfcSets;
  2781. CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().ValveSets = valveSets;
  2782. }
  2783. }
  2784. private void UpdateGASSetting()
  2785. {
  2786. if (_isStandbyCheckedSelect)
  2787. return;
  2788. List<AITMfcData> mfcDatas = new List<AITMfcData>()
  2789. {
  2790. MFC1Data,
  2791. MFC2Data,
  2792. MFC3Data,
  2793. MFC4Data,
  2794. MFC5Data,
  2795. MFC6Data,
  2796. MFC7Data,
  2797. MFC8Data,
  2798. MFC9Data,
  2799. MFC10Data,
  2800. MFC11Data,
  2801. MFC12Data,
  2802. MFC13Data,
  2803. MFC14Data,
  2804. MFC15Data,
  2805. MFC16Data,
  2806. MFC17Data,
  2807. MFC31Data,
  2808. MFC32Data,
  2809. //MFC51Data,
  2810. };
  2811. for (int i = 0; i < mfcDatas.Count; i++)
  2812. {
  2813. if (SelectedRecipeStep != null)
  2814. {
  2815. if (mfcDatas[i] == null) continue;
  2816. var mfc = SelectedRecipeStep.MFCSets.FirstOrDefault(x => x.ControlName == mfcDatas[i].DeviceName);
  2817. mfc.SetValue.Value = mfcDatas[i].VirtualSetPoint.ToString();
  2818. mfc.Rampng.Value = mfcDatas[i].VirtualRamping.ToString();
  2819. }
  2820. }
  2821. }
  2822. public void SelecteTable()
  2823. {
  2824. CurrentRecipe.Tables.FirstOrDefault(x => x.Index == CurrentRecipe.TableIndex).TableData.Steps.Clear();
  2825. CurrentRecipe.Steps.ToList().ForEach(x =>
  2826. {
  2827. var tempStep = x.Adapt<Step>();
  2828. CurrentRecipe.Tables.FirstOrDefault(y => y.Index == CurrentRecipe.TableIndex).TableData.Steps.Add(tempStep);
  2829. });
  2830. CurrentRecipe.StepCloneChangedIndex();
  2831. int getIndex = RecipeTableSelect.ShowDialogGetTableIndex(CurrentRecipe, RecipeType);
  2832. //SelectStep(CurrentRecipe.Steps.FirstOrDefault());
  2833. if (getIndex != -1)
  2834. {
  2835. while (CurrentRecipe.Steps.Count > 0)
  2836. {
  2837. CurrentRecipe.Steps.RemoveAt(0);
  2838. }
  2839. CurrentRecipe.Tables.FirstOrDefault(x => x.Index == (getIndex + 1)).TableData.Steps.ToList().ForEach(x =>
  2840. {
  2841. Step tempStep = x.Adapt<Step>();
  2842. CurrentRecipe.SetDelegateEvent(tempStep);
  2843. CurrentRecipe.Steps.Add(tempStep);
  2844. });
  2845. currentPage = 1;
  2846. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  2847. SelectStep(CurrentRecipe.Steps.FirstOrDefault());
  2848. }
  2849. }
  2850. private int currentPage = 1;
  2851. private int pageSize = 10;
  2852. private int totalPage = 0;
  2853. private ObservableCollection<Step> _newSteps = new ObservableCollection<Step>();
  2854. public ObservableCollection<Step> NewSteps
  2855. {
  2856. get
  2857. {
  2858. return _newSteps;
  2859. }
  2860. set
  2861. {
  2862. _newSteps = value;
  2863. NotifyOfPropertyChange(nameof(NewSteps));
  2864. }
  2865. }
  2866. public void PageLineTop()
  2867. {
  2868. if (currentPage <= 1)
  2869. {
  2870. return;
  2871. }
  2872. currentPage = currentPage - 1;
  2873. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  2874. IndexNoDefault = 9;
  2875. SelectStep(NewSteps[IndexNoDefault]);
  2876. RefreshUpdate();
  2877. }
  2878. public void PageTop()
  2879. {
  2880. if (IndexNoDefault == 0)
  2881. {
  2882. PageLineTop();
  2883. if (currentPage != 1)
  2884. {
  2885. IndexNoDefault = NewSteps.Count - 1;
  2886. }
  2887. return;
  2888. }
  2889. IndexNoDefault = IndexNoDefault - 1;
  2890. SelectStep(NewSteps[IndexNoDefault]);
  2891. RefreshUpdate();
  2892. }
  2893. public void PageDown()
  2894. {
  2895. if (IndexNoDefault == CurrentRecipe.Steps.Count || SelectedRecipeStep == CurrentRecipe.Steps.LastOrDefault())
  2896. {
  2897. return;
  2898. }
  2899. IndexNoDefault = IndexNoDefault + 1;
  2900. if ((IndexNoDefault % pageSize) == 0)
  2901. {
  2902. PageLineDown();
  2903. }
  2904. SelectStep(NewSteps[IndexNoDefault]);
  2905. RefreshUpdate();
  2906. }
  2907. public void PageLineDown()
  2908. {
  2909. if (currentPage >= GetTotalPage())
  2910. {
  2911. return;
  2912. }
  2913. currentPage = currentPage + 1;
  2914. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  2915. IndexNoDefault = 0;
  2916. SelectStep(NewSteps[IndexNoDefault]);
  2917. RefreshUpdate();
  2918. }
  2919. public int GetTotalPage()
  2920. {
  2921. var totalPage = CurrentRecipe.Steps.Count / pageSize;
  2922. if ((CurrentRecipe.Steps.Count % pageSize) > 0)
  2923. {
  2924. totalPage = totalPage + 1;
  2925. }
  2926. return totalPage;
  2927. }
  2928. public int GetcurrentPage()
  2929. {
  2930. var currentPage = IndexNoDefault / pageSize;
  2931. if ((IndexNoDefault % pageSize) > 0)
  2932. {
  2933. currentPage = currentPage + 1;
  2934. }
  2935. if (currentPage == 0) currentPage++;
  2936. return currentPage;
  2937. }
  2938. }
  2939. }