RecipeProcessEditViewModel.cs 141 KB

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