RecipeProcessEditViewModel.cs 140 KB

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