RecipeProcessEditViewModel.cs 140 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133
  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. }
  806. else//向下翻
  807. {
  808. if (currentPage >= GetTotalPage())
  809. {
  810. return;
  811. }
  812. currentPage = currentPage + 1;
  813. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  814. IndexNoDefault = 0;
  815. }
  816. }
  817. private bool _noStandbyOrEndIsEnabled = false;
  818. public bool NoStandbyOrEndIsEnabled
  819. {
  820. get => _noStandbyOrEndIsEnabled;
  821. set
  822. {
  823. _noStandbyOrEndIsEnabled = value;
  824. NotifyOfPropertyChange(nameof(NoStandbyOrEndIsEnabled));
  825. }
  826. }
  827. private Visibility _standbyIsVisibility = Visibility.Visible;
  828. public Visibility StandbyIsVisibility
  829. {
  830. get => _standbyIsVisibility;
  831. set
  832. {
  833. _standbyIsVisibility = value;
  834. NotifyOfPropertyChange(nameof(StandbyIsVisibility));
  835. }
  836. }
  837. private void SetChangedStepRefreshUpdate()
  838. {
  839. if (CurrentRecipe.Steps == null || CurrentRecipe.Steps.Count < 1)
  840. {
  841. return;
  842. }
  843. var endName = "";
  844. if (SelectedRecipeStep.Name.Contains(":") && SelectedRecipeStep.Name.Split(':').Length > 1)
  845. {
  846. endName = SelectedRecipeStep.Name.Split(':')[1].Trim().ToLower();
  847. }
  848. else
  849. {
  850. endName = SelectedRecipeStep.Name.Trim().ToLower();
  851. }
  852. if (SelectedRecipeStep.Name == "Standby" || endName == "end")
  853. {
  854. NoStandbyOrEndIsEnabled = false;
  855. StandbyIsVisibility = Visibility.Visible;
  856. // LoaderSetSpeedFloatVisibility= Visibility.Hidden;
  857. // LoaderSet3SpeedVisibility= Visibility.Visible;
  858. // LoaderSetSpeedVisibility = Visibility.Hidden;
  859. }
  860. else
  861. {
  862. NoStandbyOrEndIsEnabled = true && SettingButtonEnable;
  863. StandbyIsVisibility = Visibility.Visible;
  864. }
  865. }
  866. private void SetCmdIsEnabled()
  867. {
  868. AppendStepItemIsEnabled = true;
  869. if (CurrentRecipe.Steps == null || CurrentRecipe.Steps.Count == 0 || SelectedRecipeStep.Name == "Standby" || (CurrentRecipe.RecipeChamberType == RecipeDataBase.ProcessType && SelectedRecipeStep == CurrentRecipe.Steps.LastOrDefault()))
  870. {
  871. AppendStepItemIsEnabled = false;
  872. OverWriteCopyIsEnabled = false;
  873. InsertCopyIsEnabled = false;
  874. PrevStepOverwriteIsEnabled = false;
  875. PrevStepInsertIsEnabled = false;
  876. PrevStepItemIsEnabled = false;
  877. CurrStepDeleteIsEnabled = false;
  878. MultStepsDeleteIsEnabled = false;
  879. }
  880. else
  881. {
  882. if (CurrentRecipe.RecipeChamberType == RecipeDataBase.ProcessType)
  883. {
  884. AppendStepItemIsEnabled = true;
  885. InsertCopyIsEnabled = true;
  886. PrevStepItemIsEnabled = false;
  887. SetCurrAndMultStepDeleteIsEnabled();
  888. if (CurrentRecipe.Steps[1].StepNo == SelectedRecipeStep.StepNo)
  889. {
  890. OverWriteCopyIsEnabled = true;
  891. PrevStepOverwriteIsEnabled = false;
  892. PrevStepInsertIsEnabled = false;
  893. }
  894. else
  895. {
  896. OverWriteCopyIsEnabled = true;
  897. PrevStepOverwriteIsEnabled = true;
  898. PrevStepInsertIsEnabled = true;
  899. }
  900. }
  901. else
  902. {
  903. AppendStepItemIsEnabled = true;
  904. OverWriteCopyIsEnabled = true;
  905. InsertCopyIsEnabled = true;
  906. PrevStepItemIsEnabled = false;
  907. SetCurrAndMultStepDeleteIsEnabled();
  908. if (CurrentRecipe.Steps[0].StepNo == SelectedRecipeStep.StepNo)
  909. {
  910. PrevStepOverwriteIsEnabled = false;
  911. PrevStepInsertIsEnabled = false;
  912. }
  913. else
  914. {
  915. PrevStepOverwriteIsEnabled = true;
  916. PrevStepInsertIsEnabled = true;
  917. }
  918. }
  919. //OverWriteCopyIsEnabled = true;
  920. //InsertCopyIsEnabled = true;
  921. //PrevStepOverwriteIsEnabled = true;
  922. //PrevStepInsertIsEnabled = true;
  923. //PrevStepItemIsEnabled = true;
  924. //CurrStepDeleteIsEnabled = true;
  925. //MultStepsDeleteIsEnabled = true;
  926. //if (CurrentRecipe.RecipeChamberType == RecipeDataBase.ProcessType)
  927. // if (CurrentRecipe.Steps[1].StepNo == SelectedRecipeStep.StepNo)
  928. // {
  929. // AppendStepItemIsEnabled = true;
  930. // OverWriteCopyIsEnabled = false;
  931. // InsertCopyIsEnabled = true;
  932. // PrevStepOverwriteIsEnabled = false;
  933. // PrevStepInsertIsEnabled = false;
  934. // PrevStepItemIsEnabled = false;
  935. // CurrStepDeleteIsEnabled = true;
  936. // MultStepsDeleteIsEnabled = true;
  937. // }
  938. // else
  939. // {
  940. // OverWriteCopyIsEnabled = true;
  941. // InsertCopyIsEnabled = true;
  942. // PrevStepOverwriteIsEnabled = true;
  943. // PrevStepInsertIsEnabled = true;
  944. // PrevStepItemIsEnabled = false;
  945. // CurrStepDeleteIsEnabled = true;
  946. // MultStepsDeleteIsEnabled = true;
  947. // }
  948. //else
  949. //{
  950. // if (CurrentRecipe.Steps[0].StepNo == SelectedRecipeStep.StepNo)
  951. // {
  952. // AppendStepItemIsEnabled = true;
  953. // OverWriteCopyIsEnabled = true;
  954. // InsertCopyIsEnabled = true;
  955. // PrevStepOverwriteIsEnabled = false;
  956. // PrevStepInsertIsEnabled = false;
  957. // PrevStepItemIsEnabled = false;
  958. // CurrStepDeleteIsEnabled = true;
  959. // MultStepsDeleteIsEnabled = true;
  960. // }
  961. // else
  962. // {
  963. // OverWriteCopyIsEnabled = true;
  964. // InsertCopyIsEnabled = true;
  965. // PrevStepOverwriteIsEnabled = true;
  966. // PrevStepInsertIsEnabled = true;
  967. // PrevStepItemIsEnabled = false;
  968. // CurrStepDeleteIsEnabled = true;
  969. // MultStepsDeleteIsEnabled = true;
  970. // }
  971. //}
  972. }
  973. IsCommandConditionEventEnabled = SettingButtonEnable;
  974. IsStandbyEnabled = SettingButtonEnable && (RecipeType.ToLower() == "process");
  975. }
  976. private void SetCurrAndMultStepDeleteIsEnabled()
  977. {
  978. if (CurrentRecipe.RecipeChamberType == "Process")
  979. {
  980. if ((CurrentRecipe.Steps.Count < 4))
  981. {
  982. CurrStepDeleteIsEnabled = false;
  983. MultStepsDeleteIsEnabled = false;
  984. }
  985. else
  986. {
  987. MultStepsDeleteIsEnabled = true;
  988. if (SelectedRecipeStep.Name == "Standby" || SelectedRecipeStep.Name == "End")
  989. {
  990. CurrStepDeleteIsEnabled = false;
  991. }
  992. else
  993. {
  994. CurrStepDeleteIsEnabled = true;
  995. }
  996. }
  997. }
  998. else
  999. {
  1000. if ((CurrentRecipe.Steps.Count < 2))
  1001. {
  1002. CurrStepDeleteIsEnabled = false;
  1003. MultStepsDeleteIsEnabled = false;
  1004. }
  1005. else
  1006. {
  1007. CurrStepDeleteIsEnabled = true;
  1008. MultStepsDeleteIsEnabled = true;
  1009. }
  1010. }
  1011. }
  1012. private string _selectedGasSetting2;
  1013. public string SelectedGasSetting2
  1014. {
  1015. get
  1016. {
  1017. return _selectedGasSetting2;
  1018. }
  1019. set
  1020. {
  1021. _selectedGasSetting2 = value;
  1022. NotifyOfPropertyChange(nameof(SelectedGasSetting2));
  1023. }
  1024. }
  1025. private string _selectedGasSetting3;
  1026. public string SelectedGasSetting3
  1027. {
  1028. get
  1029. {
  1030. return _selectedGasSetting3;
  1031. }
  1032. set
  1033. {
  1034. _selectedGasSetting3 = value;
  1035. NotifyOfPropertyChange(nameof(SelectedGasSetting3));
  1036. }
  1037. }
  1038. private string _selectedGasSetting4;
  1039. public string SelectedGasSetting4
  1040. {
  1041. get
  1042. {
  1043. return _selectedGasSetting4;
  1044. }
  1045. set
  1046. {
  1047. _selectedGasSetting4 = value;
  1048. NotifyOfPropertyChange(nameof(SelectedGasSetting4));
  1049. }
  1050. }
  1051. private string _selectedGasSetting5;
  1052. public string SelectedGasSetting5
  1053. {
  1054. get
  1055. {
  1056. return _selectedGasSetting5;
  1057. }
  1058. set
  1059. {
  1060. _selectedGasSetting5 = value;
  1061. NotifyOfPropertyChange(nameof(SelectedGasSetting5));
  1062. }
  1063. }
  1064. private string _selectedGasSetting6;
  1065. public string SelectedGasSetting6
  1066. {
  1067. get
  1068. {
  1069. return _selectedGasSetting6;
  1070. }
  1071. set
  1072. {
  1073. _selectedGasSetting6 = value;
  1074. NotifyOfPropertyChange(nameof(SelectedGasSetting6));
  1075. }
  1076. }
  1077. private List<ConfigNode> _ConfigNodes = new List<ConfigNode>();
  1078. public List<ConfigNode> ConfigNodes
  1079. {
  1080. get { return _ConfigNodes; }
  1081. set
  1082. {
  1083. _ConfigNodes = value;
  1084. NotifyOfPropertyChange(nameof(ConfigNodes));
  1085. }
  1086. }
  1087. //private ObservableCollection<MFCData> _mFCDatas = new ObservableCollection<MFCData>();
  1088. //public ObservableCollection<TempSetData> TempList { get; set; } = new ObservableCollection<TempSetData>();
  1089. //public ObservableCollection<MFCData> MFCDataList
  1090. //{
  1091. // get => _mFCDatas;
  1092. // set
  1093. // {
  1094. // _mFCDatas = value;
  1095. // NotifyOfPropertyChange(nameof(MFCDataList));
  1096. // }
  1097. //}
  1098. private string _pressureUnit;
  1099. public string PressureUnit
  1100. {
  1101. get => _pressureUnit;
  1102. set
  1103. {
  1104. _pressureUnit = value;
  1105. NotifyOfPropertyChange(nameof(PressureUnit));
  1106. }
  1107. }
  1108. public string RecipeType { get; set; }
  1109. private RecipeProcessEditView view1;
  1110. public RecipeProcessEditViewModel(string strPrefixPath, string strRecipeName, string permission = "")
  1111. {
  1112. PumpDict.Clear();
  1113. PumpDict.Add("DPR", "ValveAV91");
  1114. PumpDict.Add("AGV", "AGVPump");
  1115. PumpDict.Add("MBP", "BothPump");
  1116. PumpDict.Add("DP", "AUCPump");
  1117. PumpDict.Add("BWR", "ValveBWR");
  1118. OtherPumpDict.Clear();
  1119. OtherPumpDict.Add("F2Cln", "F2Cln");
  1120. OtherPumpDict.Add("HFCln", "HFCln");
  1121. OtherPumpDict.Add("HTR1", "HTR1");
  1122. OtherPumpDict.Add("HTR2", "HTR2");
  1123. OtherPumpDict.Add("HTR3", "HTR3");
  1124. DefaultUnit = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.APC.PressureUnit");
  1125. RecipeTemplate = _recipeProvider.GetGroupRecipeTemplate();
  1126. CurrentRecipe.PrefixPath = strPrefixPath;
  1127. CurrentRecipe.Name = strRecipeName;
  1128. CurrentRecipe.RecipePermission = permission;
  1129. }
  1130. protected override void OnViewLoaded(object view)
  1131. {
  1132. base.OnViewLoaded(view);
  1133. view1 = (RecipeProcessEditView)view;
  1134. }
  1135. protected override void OnActivate()
  1136. {
  1137. base.OnActivate();
  1138. InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorRecipeOK", "");
  1139. }
  1140. protected override void OnDeactivate(bool close)
  1141. {
  1142. base.OnDeactivate(close);
  1143. InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorPROCManualOK", "");
  1144. }
  1145. protected override void OnInitialize()
  1146. {
  1147. base.OnInitialize();
  1148. ToolType = (string)QueryDataClient.Instance.Service.GetConfig("System.SetUp.ToolType");
  1149. // GetHeaderConfig();
  1150. LoadData();
  1151. RefreshUpdate();
  1152. currentPage = GetcurrentPage();
  1153. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  1154. }
  1155. private void LoadData()
  1156. {
  1157. if (RecipeType.ToLower() == "process" || RecipeType.ToLower() == "sub")
  1158. {
  1159. IsProcessVisibility = Visibility.Visible;
  1160. }
  1161. else
  1162. {
  1163. IsProcessVisibility = Visibility.Hidden;
  1164. }
  1165. CurrentRecipe.Clear();
  1166. var recipeContent = _recipeProvider.LoadRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name);
  1167. if (string.IsNullOrEmpty(recipeContent))
  1168. {
  1169. System.Windows.MessageBox.Show($"{CurrentRecipe.PrefixPath}\\{CurrentRecipe.Name} is empty, please confirm the file is valid.");
  1170. return;
  1171. }
  1172. // CurrentRecipe.RecipeChamberType = "OriginChamber";
  1173. CurrentRecipe.InitData(CurrentRecipe.PrefixPath, CurrentRecipe.Name, recipeContent, "PM1");
  1174. if (CurrentRecipe.Steps.Count > 0)
  1175. {
  1176. if (!string.IsNullOrEmpty(SelectedStepName))
  1177. {
  1178. //根据名称找到对应的Index
  1179. var steps = CurrentRecipe.Steps.Where(p => SelectedStepName.EndsWith(p.Name)).FirstOrDefault();
  1180. if (steps != null)
  1181. {
  1182. IndexNoDefault = CurrentRecipe.Steps.IndexOf(steps);
  1183. }
  1184. }
  1185. if (CurrentRecipe.Steps.Count > IndexNoDefault)
  1186. {
  1187. SelectStep(CurrentRecipe.Steps[IndexNoDefault]);
  1188. }
  1189. }
  1190. IsCommandConditionEventEnabled = true;
  1191. PressureUnit = "(" + (string)QueryDataClient.Instance.Service.GetConfig("PM1.APC.PressureUnit") + ")";
  1192. }
  1193. public void SwitchPage(string page)
  1194. {
  1195. var windowManager = IoC.Get<IWindowManager>();
  1196. switch (page)
  1197. {
  1198. case "GFCSetting":
  1199. RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new RecipeGasPanelSettingViewModel
  1200. {
  1201. SelectedStepNo = SelectedRecipeStep.StepNo,
  1202. SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}",
  1203. CurrentRecipe = CurrentRecipe,
  1204. SelectedStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault()
  1205. };
  1206. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  1207. (windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Recipe Gas Panel Setting");
  1208. break;
  1209. }
  1210. }
  1211. private void RecipeGasPanelSettingViewModel_ChangedStepEvent(Step step)
  1212. {
  1213. SelectStep(step);
  1214. }
  1215. private Step OldStep;
  1216. private Dictionary<string, string> PumpDict = new Dictionary<string, string>();
  1217. private Dictionary<string, string> OtherPumpDict = new Dictionary<string, string>();
  1218. public void SelectStep(object sender, object step)
  1219. {
  1220. var textBox = sender as UIElement;
  1221. if (textBox != null)
  1222. {
  1223. Keyboard.Focus(textBox);
  1224. }
  1225. SelectStep(step);
  1226. }
  1227. public void SelectStep(object step)
  1228. {
  1229. if (step == null || !(step is Step))
  1230. {
  1231. return;
  1232. }
  1233. var step1 = (Step)step;
  1234. var SelectedStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == step1.StepNo).FirstOrDefault();
  1235. if (OldStep != null && step1.StepNo != OldStep.StepNo)
  1236. {
  1237. var selectedOldStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == OldStep.StepNo).FirstOrDefault();
  1238. if (step1 != null && step1.TemperatureControlMode != null && !string.IsNullOrEmpty(step1.TemperatureControlMode.Value))
  1239. {
  1240. if (step1.TemperatureControlMode.Value.Contains("Profile"))
  1241. {
  1242. SelectBtnName = "Profile";
  1243. }
  1244. else
  1245. {
  1246. SelectBtnName = step1.TemperatureControlMode.Value;
  1247. }
  1248. }
  1249. else
  1250. {
  1251. SelectBtnName = "";
  1252. }
  1253. //if (selectedOldStep != null)
  1254. //{
  1255. // selectedOldStep.LoaderValue = GetSaveLoaderValue(selectedOldStep.LoaderCommand);
  1256. // selectedOldStep.PressValue = GetSavePressValue(selectedOldStep.PressCommand);
  1257. //}
  1258. }
  1259. OldStep = step1;
  1260. string strName = step1.Name == null ? step1.Name : step1.Name?.Trim();
  1261. SelectedRecipeStep = SelectedStep;
  1262. //if (SelectedRecipeStep.Name != EditRecipeStepName || SelectedRecipeStep.StepNo != step1.StepNo)
  1263. //{
  1264. SetShowLoaderValuePanel(SelectedRecipeStep.LoaderCommand.Value);
  1265. SetShowPressPanel(SelectedRecipeStep.PressCommand.Value);
  1266. InvokeClient.Instance.Service.DoOperation($"PM1.SetEditRecipeStepName", SelectedRecipeStep.Name);
  1267. new Task(() =>
  1268. {
  1269. var selectedStep = step1;
  1270. if (selectedStep.MFCSets != null && selectedStep.MFCSets.Count > 0)
  1271. {
  1272. Dictionary<string, string> dictMFC = new Dictionary<string, string>();
  1273. foreach (var mfc in selectedStep.MFCSets)
  1274. {
  1275. dictMFC[mfc.ControlName] = $"{mfc.SetValue.Value};{mfc.Rampng.Value};{mfc.AlarmValue}";
  1276. }
  1277. InvokeClient.Instance.Service.DoOperation($"PM1.SetAllMfcVirtualValue", dictMFC);
  1278. }
  1279. if (selectedStep.ValveSets != null && selectedStep.ValveSets.Count > 0)
  1280. {
  1281. Dictionary<string, bool> dictValve = new Dictionary<string, bool>();
  1282. foreach (var item in selectedStep.ValveSets)
  1283. {
  1284. if (PumpDict.ContainsKey(item.Name))
  1285. {
  1286. // dictValve[PumpDict[key]] = selectedStep.ValveSets[key] == "Open" ? true : false;
  1287. }
  1288. else if (OtherPumpDict.ContainsKey(item.Name))
  1289. { }
  1290. else
  1291. {
  1292. dictValve[item.Name] = item.Value;
  1293. }
  1294. }
  1295. InvokeClient.Instance.Service.DoOperation($"PM1.SetAll{AITValveOperation.GVVirtualTurnValve}", dictValve);
  1296. }
  1297. }).Start();
  1298. //if (selectedStep.TemperatureSets != null)
  1299. //{
  1300. // TempList.Clear();
  1301. // selectedStep.TemperatureSets.ToList().ForEach(x => TempList.Add(x));
  1302. //}
  1303. //SetLoaderValue(selectedStep.LoaderCommand, selectedStep.LoaderValue);
  1304. //SetPressValue(selectedStep.PressCommand, selectedStep.PressValue);
  1305. //}
  1306. RefreshUpdate();
  1307. }
  1308. #region"StepEdit"
  1309. public Step selectStep { get; set; } = new Step();
  1310. public void StepEdit(string stepEditCmd)
  1311. {
  1312. var windowManager = IoC.Get<IWindowManager>();
  1313. switch (stepEditCmd)
  1314. {
  1315. case "Append":
  1316. AppendStep2();
  1317. break;
  1318. case "InsertCopy":
  1319. InsertCopyStep();
  1320. break;
  1321. case "OverWrite"://任何步骤的内容都可以覆盖到选定的步骤中
  1322. OverWriteStep();
  1323. break;
  1324. case "PrevStepOverwrite"://用上一步的内容覆盖所选步骤
  1325. if (DialogButton.No == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  1326. DialogType.CONFIRM,
  1327. $"Make sure to PrevStep Overwrite the selected step?"))
  1328. {
  1329. return;
  1330. }
  1331. PrevStepOverwriteStep();
  1332. break;
  1333. case "PrevStepInsert"://在选定步骤之前,插入带有前一步内容的新步骤。
  1334. if (DialogButton.No == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  1335. DialogType.CONFIRM,
  1336. $"Make sure to PrevStep nsert the selected step?"))
  1337. {
  1338. return;
  1339. }
  1340. InsertPrevStep();
  1341. break;
  1342. case "PrevStepItem":
  1343. break;
  1344. case "CurrStepDelete":
  1345. if (DialogButton.No == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  1346. DialogType.CONFIRM,
  1347. $"Make sure to delete the selected step?"))
  1348. {
  1349. return;
  1350. }
  1351. if (SelectedRecipeStep == null || CurrentRecipe == null)
  1352. { return; }
  1353. CurrDeleteStep();
  1354. break;
  1355. case "MultStepsDelete":
  1356. RecipeStepDeleteDialogViewModel recipedeleteDialog = new RecipeStepDeleteDialogViewModel(CurrentRecipe);
  1357. (windowManager as WindowManager)?.ShowDialogWithTitle(recipedeleteDialog, null, "Delete Recipe Step");
  1358. IndexNoDefault = 0;
  1359. if (CurrentRecipe.Steps.Count > 0)
  1360. {
  1361. selectStep = CurrentRecipe.Steps[0];
  1362. }
  1363. break;
  1364. default:
  1365. break;
  1366. }
  1367. // var totalPage = GetTotalPage();
  1368. currentPage = GetcurrentPage();
  1369. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  1370. //currentPage = totalPage;
  1371. if (selectStep != null && selectStep.StepNo >= 0)
  1372. {
  1373. SelectStep(selectStep);
  1374. }
  1375. }
  1376. private void OverWriteStep()
  1377. {
  1378. var windowManager = IoC.Get<IWindowManager>();
  1379. if (CurrentRecipe == null) return;
  1380. RecipeStepSelectDialogViewModel recipeStepSelectDialogViewModel = new RecipeStepSelectDialogViewModel(CurrentRecipe);
  1381. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepSelectDialogViewModel, null, "Select Recipe Step"))
  1382. {
  1383. var tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1384. CurrentRecipe.ShallowCopyStep(ref tempStep, recipeStepSelectDialogViewModel.SelectedStep);
  1385. CurrentRecipe.SetDelegateEvent(tempStep);
  1386. selectStep = SelectedRecipeStep;
  1387. }
  1388. }
  1389. private void PrevStepOverwriteStep()
  1390. {
  1391. int index = -1;
  1392. index = SelectedRecipeStep.StepNo;
  1393. if (index > 1)
  1394. {
  1395. var setStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1396. CurrentRecipe.ShallowCopyStep(ref setStep, CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo - 1).FirstOrDefault());
  1397. selectStep = SelectedRecipeStep;
  1398. }
  1399. }
  1400. public void CurrDeleteStep()
  1401. {
  1402. int index = -1;
  1403. index = SelectedRecipeStep.StepNo;
  1404. CurrentRecipe.Steps.Remove(CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault());
  1405. if (CurrentRecipe.RecipeChamberType != RecipeDataBase.ProcessType)
  1406. {
  1407. for (int i = index; i < this.CurrentRecipe.Steps.Count + 1; i++)
  1408. {
  1409. this.CurrentRecipe.Steps[i - 1].StepNo = i;
  1410. }
  1411. }
  1412. else
  1413. {
  1414. for (int i = index; i < this.CurrentRecipe.Steps.Count + 1; i++)
  1415. {
  1416. this.CurrentRecipe.Steps[i - 1].StepNo = i - 1;
  1417. }
  1418. }
  1419. if (index > CurrentRecipe.Steps.Count - 1)
  1420. {
  1421. IndexNoDefault = CurrentRecipe.Steps.Count - 1;
  1422. }
  1423. else
  1424. {
  1425. IndexNoDefault = CurrentRecipe.Steps.IndexOf(CurrentRecipe.Steps.FirstOrDefault(x => x.StepNo == index));
  1426. }
  1427. if (CurrentRecipe != null && CurrentRecipe.Steps.Count > 0)
  1428. {
  1429. RefreshUpdate();
  1430. selectStep = CurrentRecipe.Steps[IndexNoDefault];
  1431. }
  1432. }
  1433. public void InsertPrevStep()
  1434. {
  1435. var foundPrevStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo - 1).FirstOrDefault();
  1436. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1437. if (foundPrevStep != null && foundStep != null)
  1438. {
  1439. var tempStep = CurrentRecipe.CreateStep();
  1440. CurrentRecipe.CloneStep(ref tempStep, foundPrevStep);
  1441. tempStep.StepNo = foundPrevStep.StepNo + 1;
  1442. foreach (var item in this.CurrentRecipe.Steps)
  1443. {
  1444. if (item.StepNo >= tempStep.StepNo)
  1445. {
  1446. item.StepNo += 1;
  1447. }
  1448. }
  1449. Step step = CurrentRecipe.Steps.FirstOrDefault(x => x.Name == "Standby");
  1450. CurrentRecipe.SetDelegateEvent(tempStep);
  1451. if (step == null)
  1452. {
  1453. this.CurrentRecipe.Steps.Insert(foundPrevStep.StepNo, tempStep);
  1454. }
  1455. else
  1456. {
  1457. this.CurrentRecipe.Steps.Insert(foundPrevStep.StepNo + 1, tempStep);
  1458. }
  1459. if (step == null)
  1460. {
  1461. IndexNoDefault = SelectedRecipeStep.StepNo - 1;
  1462. }
  1463. else
  1464. {
  1465. IndexNoDefault = SelectedRecipeStep.StepNo;
  1466. }
  1467. selectStep = CurrentRecipe.Steps[IndexNoDefault];
  1468. }
  1469. }
  1470. private void AppendStep()
  1471. {
  1472. if (CurrentRecipe.RecipeChamberType == "Process")
  1473. {
  1474. var last = CurrentRecipe.Steps.LastOrDefault();
  1475. CurrentRecipe.Steps.RemoveWhere(a => a.StepNo == last.StepNo);
  1476. var newStep = CurrentRecipe.CreateStep();
  1477. CurrentRecipe.Steps.Add(newStep);
  1478. int TempSelectIndex = 0;
  1479. Step step = CurrentRecipe.Steps.FirstOrDefault(x => x.Name == "Standby");
  1480. for (int i = 0; i < this.CurrentRecipe.Steps.Count; i++)
  1481. {
  1482. if (step == null)
  1483. {
  1484. this.CurrentRecipe.Steps[i].StepNo = i + 1;
  1485. }
  1486. else
  1487. {
  1488. this.CurrentRecipe.Steps[i].StepNo = i;
  1489. }
  1490. TempSelectIndex = i;
  1491. }
  1492. IndexNoDefault = TempSelectIndex;
  1493. last.StepNo = CurrentRecipe.Steps.LastOrDefault().StepNo + 1;
  1494. CurrentRecipe.Steps.Add(last);
  1495. selectStep = CurrentRecipe.Steps[newStep.StepNo - 1];
  1496. }
  1497. else
  1498. {
  1499. var newStep = CurrentRecipe.CreateStep();
  1500. CurrentRecipe.Steps.Add(newStep);
  1501. int TempSelectIndex = 0;
  1502. Step step = CurrentRecipe.Steps.FirstOrDefault(x => x.Name == "Standby");
  1503. for (int i = 0; i < this.CurrentRecipe.Steps.Count; i++)
  1504. {
  1505. if (step == null)
  1506. {
  1507. this.CurrentRecipe.Steps[i].StepNo = i + 1;
  1508. }
  1509. else
  1510. {
  1511. this.CurrentRecipe.Steps[i].StepNo = i;
  1512. }
  1513. TempSelectIndex = i;
  1514. }
  1515. IndexNoDefault = TempSelectIndex;
  1516. selectStep = CurrentRecipe.Steps[TempSelectIndex];
  1517. }
  1518. }
  1519. public void AppendStep2()
  1520. {
  1521. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1522. int foundIndex = this.CurrentRecipe.Steps.IndexOf(foundStep);
  1523. if (foundStep != null)
  1524. {
  1525. var tempStep = CurrentRecipe.CreateStep();
  1526. CurrentRecipe.CloneStep(ref tempStep, foundStep);
  1527. tempStep.StepNo = foundStep.StepNo + 1;
  1528. tempStep.Name = $"Name{tempStep.StepNo}";
  1529. foreach (var item in this.CurrentRecipe.Steps)
  1530. {
  1531. if (item.StepNo >= tempStep.StepNo)
  1532. {
  1533. item.StepNo += 1;
  1534. }
  1535. }
  1536. IndexNoDefault = foundIndex + 1;
  1537. this.CurrentRecipe.Steps.Insert(foundIndex + 1, tempStep);
  1538. selectStep = CurrentRecipe.Steps[foundIndex + 1];
  1539. }
  1540. }
  1541. public void InsertCopyStep()
  1542. {
  1543. var windowManager = IoC.Get<IWindowManager>();
  1544. if (CurrentRecipe == null) return;
  1545. RecipeStepSelectDialogViewModel recipeStepSelectDialogViewModel = new RecipeStepSelectDialogViewModel(CurrentRecipe);
  1546. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepSelectDialogViewModel, null, "Select Recipe Step"))
  1547. {
  1548. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1549. if (foundStep != null)
  1550. {
  1551. var tempStep = CurrentRecipe.CreateStep();
  1552. CurrentRecipe.CloneStep(ref tempStep, recipeStepSelectDialogViewModel.SelectedStep);
  1553. tempStep.StepNo = foundStep.StepNo;
  1554. int insertIndex = this.CurrentRecipe.Steps.IndexOf(foundStep);
  1555. CurrentRecipe.SetDelegateEvent(tempStep);
  1556. this.CurrentRecipe.Steps.Insert(insertIndex, tempStep);
  1557. if (CurrentRecipe.RecipeChamberType != RecipeDataBase.ProcessType)
  1558. {
  1559. for (int i = tempStep.StepNo; i < this.CurrentRecipe.Steps.Count + 1; i++)
  1560. {
  1561. this.CurrentRecipe.Steps[i - 1].StepNo = i;
  1562. }
  1563. }
  1564. else
  1565. {
  1566. for (int i = tempStep.StepNo; i < this.CurrentRecipe.Steps.Count; i++)
  1567. {
  1568. this.CurrentRecipe.Steps[i].StepNo = i;
  1569. }
  1570. }
  1571. selectStep = CurrentRecipe.Steps[insertIndex];
  1572. }
  1573. }
  1574. }
  1575. #endregion
  1576. public void RecipeSingMFCIsChangeClick(object value)
  1577. {
  1578. if (value is MFCData)
  1579. {
  1580. var mfc = value as MFCData;
  1581. if (mfc.IsSaved)
  1582. {
  1583. if (DialogButton.Yes == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  1584. DialogType.CONFIRM,
  1585. $"Recipe single MFC is changed Flag, do you want to save it?"))
  1586. {
  1587. mfc.FlagIsSaved = false;
  1588. }
  1589. }
  1590. else
  1591. {
  1592. mfc.FlagIsSaved = true;
  1593. mfc.UndoChanges();
  1594. }
  1595. }
  1596. }
  1597. //撤销修改
  1598. public void RecipeIsChangeClick(object cmdName, object value)
  1599. {
  1600. if (value == null)
  1601. return;
  1602. var windowManager = IoC.Get<IWindowManager>();
  1603. switch ((string)cmdName)
  1604. {
  1605. case "Alarm":
  1606. ((Step)value).UndoAlarmChanges();
  1607. break;
  1608. case "MFC":
  1609. ((Step)value).UndoMFCChanges();
  1610. break;
  1611. case "Gas":
  1612. ((Step)value).UndoGasChanges();
  1613. break;
  1614. case "AUX":
  1615. ((Step)value).UndoAUXChanges();
  1616. break;
  1617. case "Press":
  1618. ((Step)value).UndoPressChanges();
  1619. SetShowPressPanel(((Step)value).PressCommand.Value);
  1620. break;
  1621. case "Temp":
  1622. ((Step)value).UndoTemperatureChanges();
  1623. break;
  1624. case "Loader":
  1625. ((Step)value).UndoLoaderChanges();
  1626. SetShowLoaderValuePanel(((Step)value).LoaderCommand.Value);
  1627. break;
  1628. default:
  1629. break;
  1630. }
  1631. }
  1632. public void TempSetClick(object sender)
  1633. {
  1634. string stSetValue = ShowNumberKeyboard(sender as Button, "", 1);
  1635. if (stSetValue != "Cancel")
  1636. {
  1637. foreach (var item in SelectedRecipeStep.TemperatureSets)
  1638. {
  1639. item.SetValue.SetValue(stSetValue);
  1640. }
  1641. }
  1642. }
  1643. public void RampSetClick(object sender)
  1644. {
  1645. string strSetRamp = ShowNumberKeyboard(sender as Button, "", 1);
  1646. if (strSetRamp != "Cancel")
  1647. {
  1648. foreach (var item in SelectedRecipeStep.TemperatureSets)
  1649. {
  1650. item.RampngValue.SetValue(strSetRamp);
  1651. }
  1652. }
  1653. }
  1654. private string ShowNumberKeyboard(Control control, string defaultValue, int keepDecimals = -1)
  1655. {
  1656. NumberKeyboard numberKeyboard = new NumberKeyboard("", defaultValue);
  1657. numberKeyboard.KeepDecimals = keepDecimals;
  1658. var point = control.PointFromScreen(new Point(0, 0));
  1659. double wx = SystemParameters.WorkArea.Width;
  1660. double hy = SystemParameters.WorkArea.Height;
  1661. if (-point.Y + control.ActualHeight + 5 + numberKeyboard.Height < hy)
  1662. {
  1663. numberKeyboard.Top = -point.Y + control.ActualHeight + 5;
  1664. }
  1665. else
  1666. {
  1667. numberKeyboard.Top = -point.Y - numberKeyboard.Height - 5;
  1668. }
  1669. if (-point.X + numberKeyboard.Width < wx)
  1670. {
  1671. numberKeyboard.Left = -point.X;
  1672. }
  1673. else
  1674. {
  1675. numberKeyboard.Left = -point.X - (numberKeyboard.Width - control.ActualWidth);
  1676. }
  1677. if ((bool)numberKeyboard.ShowDialog())
  1678. return numberKeyboard.ValueString;
  1679. else
  1680. return "Cancel";
  1681. }
  1682. private string GetTemperatureControlMode(string val)
  1683. {
  1684. if (string.IsNullOrEmpty(val) || !val.Contains("—"))
  1685. {
  1686. return val;
  1687. }
  1688. var temperatureControlModes = val.Split('—').ToList();
  1689. SelectBtnName = temperatureControlModes.LastOrDefault();
  1690. if (temperatureControlModes.Count == 1)
  1691. {
  1692. SelectBtnName = "";
  1693. }
  1694. return temperatureControlModes.FirstOrDefault();
  1695. }
  1696. public void TempTextClick(string type, object sender)
  1697. {
  1698. var windowManager = IoC.Get<IWindowManager>();
  1699. switch (type)
  1700. {
  1701. case "Mode":
  1702. RecipeTempModeViewModel recipeTempModeViewModel = new RecipeTempModeViewModel();
  1703. recipeTempModeViewModel.CurrentRecipe = CurrentRecipe;
  1704. recipeTempModeViewModel.SelectProfileTable = SelectedRecipeStep.TemperatureControlMode.Value;
  1705. recipeTempModeViewModel.SelectBtnName = SelectBtnName;
  1706. var rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(recipeTempModeViewModel, null, "Temp Mode");
  1707. if ((bool)rtn)
  1708. {
  1709. SelectBtnName = recipeTempModeViewModel.SelectBtnName;
  1710. //SelectedRecipeStep.TemperatureControlMode.Value =recipeTempModeViewModel.ResultString;
  1711. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1712. if (foundStep != null)
  1713. {
  1714. if (null != recipeTempModeViewModel && !string.IsNullOrEmpty(recipeTempModeViewModel.ResultString) && recipeTempModeViewModel.ResultString.Contains("Profile"))
  1715. {
  1716. SelectBtnName = "Profile";
  1717. }
  1718. foundStep.TemperatureControlMode.SetValue(recipeTempModeViewModel.ResultString);
  1719. }
  1720. }
  1721. break;
  1722. case "Correct":
  1723. TempCorrectionEditViewModel tempCorrectionEditViewModel = new TempCorrectionEditViewModel();
  1724. tempCorrectionEditViewModel.CurrentRecipe = CurrentRecipe;
  1725. tempCorrectionEditViewModel.ResultString = SelectedRecipeStep.TemperatureCorrect.Value;
  1726. tempCorrectionEditViewModel.IsEnabledControl = false;
  1727. tempCorrectionEditViewModel.AutoSelectVisibility = Visibility.Visible;
  1728. // tempOffsetTableViewModel.SelectedRecipeStep = SelectedRecipeStep;
  1729. rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(tempCorrectionEditViewModel, null, "Temp Correct Table");
  1730. if ((bool)rtn)
  1731. {
  1732. // SelectedRecipeStep.TemperatureCorrect.Value = tempCorrectionEditViewModel.ResultString;
  1733. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1734. if (foundStep != null)
  1735. {
  1736. foundStep.TemperatureCorrect.SetValue(tempCorrectionEditViewModel.ResultString);
  1737. }
  1738. }
  1739. break;
  1740. case "PID":
  1741. TempOffsetTableViewModel tempOffsetTableViewModel1 = new TempOffsetTableViewModel();
  1742. tempOffsetTableViewModel1.TempOffsetTableSelected = SelectedRecipeStep.TemperaturePID.Value;
  1743. tempOffsetTableViewModel1.CurrentRecipe = CurrentRecipe;
  1744. tempOffsetTableViewModel1.IsEnabledControl = false;
  1745. tempOffsetTableViewModel1.SelectedRecipeStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1746. rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(tempOffsetTableViewModel1, null, "Temp PID Table");
  1747. if ((bool)rtn)
  1748. {
  1749. // SelectedRecipeStep.TemperaturePID.Value = tempOffsetTableViewModel1.TempOffsetTableSelected;
  1750. var foundStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1751. if (foundStep != null)
  1752. {
  1753. foundStep.TemperaturePID.SetValue(tempOffsetTableViewModel1.TempOffsetTableSelected);
  1754. }
  1755. }
  1756. break;
  1757. default:
  1758. break;
  1759. }
  1760. }
  1761. //public void TempTextChanged(string type, object sender, object item)
  1762. //{
  1763. // if (!string.IsNullOrEmpty(type) && item != null && sender != null)
  1764. // {
  1765. // TempSetData tempData = (TempSetData)item;
  1766. // string value = ((TextBox)sender).Text;
  1767. // int stepNo = SelectedRecipeStep.StepNo;
  1768. // var step = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault();
  1769. // if (step != null)
  1770. // {
  1771. // var tempValue = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().TemperatureSets.Where(x => x.Name == tempData.Name).FirstOrDefault();
  1772. // if (tempValue == null) return;
  1773. // switch (type)
  1774. // {
  1775. // case "Value":
  1776. // tempValue.SetValue.Value = value;
  1777. // break;
  1778. // case "Ramp":
  1779. // tempValue.RampngValue.Value = value;
  1780. // break;
  1781. // default:
  1782. // break;
  1783. // }
  1784. // }
  1785. // }
  1786. //}
  1787. private bool isEditMFC = false;
  1788. public void StepEdit(object cmdName, object value)
  1789. {
  1790. var windowManager = IoC.Get<IWindowManager>();
  1791. switch ((string)cmdName)
  1792. {
  1793. case "StepName":
  1794. RecipeStepNameViewModel recipeStepNameViewModel = new RecipeStepNameViewModel() { SelectedStepName = SelectedRecipeStep.Name };
  1795. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepNameViewModel, null, "Recipe Step Name"))
  1796. {
  1797. SelectedRecipeStep.Name = recipeStepNameViewModel.SelectedStepName;
  1798. }
  1799. break;
  1800. case "StepTime":
  1801. RecipeStepTimeViewModel recipeStepTimeViewModel = new RecipeStepTimeViewModel("StepTime");
  1802. if (CurrentRecipe.Steps.Count > 0)
  1803. {
  1804. var timeValue = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().Time;
  1805. recipeStepTimeViewModel.SelectTime = (timeValue == null || timeValue.Contains(':')) ? "Value" : timeValue;
  1806. if (recipeStepTimeViewModel.SelectTime == "Value")
  1807. {
  1808. recipeStepTimeViewModel.SelectValueTime = timeValue;
  1809. }
  1810. (windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepTimeViewModel, null, "Step Time Set");
  1811. if (recipeStepTimeViewModel.IsSave)
  1812. {
  1813. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().Time = recipeStepTimeViewModel.SelectTime;
  1814. if (recipeStepTimeViewModel.SelectTime == "Value")
  1815. {
  1816. SelectedRecipeStep.Time = recipeStepTimeViewModel.SelectTime + ":" + recipeStepTimeViewModel.SelectValueTime;
  1817. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault() != null)
  1818. {
  1819. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().Time = recipeStepTimeViewModel.SelectValueTime;
  1820. }
  1821. }
  1822. else
  1823. {
  1824. SelectedRecipeStep.Time = recipeStepTimeViewModel.SelectTime + ":" + recipeStepTimeViewModel.RecipeStepTime[recipeStepTimeViewModel.SelectTime];
  1825. }
  1826. }
  1827. }
  1828. break;
  1829. case "RecipeCommand":
  1830. RecipeCommandViewModel recipeCommandViewModel = new RecipeCommandViewModel();
  1831. 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());
  1832. 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());
  1833. recipeCommandViewModel.LoopStepNames = loopStepNames;
  1834. recipeCommandViewModel.JumpStepNames = jumpStepNames;
  1835. recipeCommandViewModel.SelectedRecipeStep = SelectedRecipeStep;
  1836. recipeCommandViewModel.SelectRecipeCommand = SelectedRecipeStep.Command;
  1837. recipeCommandViewModel.RecipeData = CurrentRecipe;
  1838. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeCommandViewModel, null, "Recipe Command"))
  1839. {
  1840. SelectedRecipeStep.Command = recipeCommandViewModel.SelectRecipeCommand;
  1841. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().Command = SelectedRecipeStep.Command;
  1842. }
  1843. break;
  1844. case "ConditionCheck":
  1845. RecipeConditionCheckSetViewModel recipeConditionCheckSetViewModel = new RecipeConditionCheckSetViewModel();
  1846. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ExternalSensor != null)
  1847. {
  1848. recipeConditionCheckSetViewModel.RecipeConditions.ExternalSensor = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ExternalSensor;
  1849. }
  1850. var step = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1851. if (step != null)
  1852. {
  1853. recipeConditionCheckSetViewModel.RecipeConditions.TempStabizeSelected = step.TempStabilizeSelected;
  1854. recipeConditionCheckSetViewModel.RecipeConditions.FinishAutoProfile = step.FinishAutoProfile;
  1855. recipeConditionCheckSetViewModel.RecipeConditions.ReachTemp = step.ReachTemp;
  1856. recipeConditionCheckSetViewModel.RecipeConditions.ReachTempValue = step.ReachTempValue;
  1857. recipeConditionCheckSetViewModel.RecipeConditions.O2Density = step.O2Density;
  1858. recipeConditionCheckSetViewModel.RecipeConditions.O2DensityValue = step.O2DensityValue;
  1859. recipeConditionCheckSetViewModel.RecipeConditions.ReachPressure = step.ReachPressure;
  1860. recipeConditionCheckSetViewModel.RecipeConditions.ReachPressureVG = step.ReachPressureVG;
  1861. recipeConditionCheckSetViewModel.RecipeConditions.ReachPressureValue = step.ReachPressureValue;
  1862. recipeConditionCheckSetViewModel.RecipeConditions.PressureStabilizeVG = step.PressureStabilizeVG;
  1863. recipeConditionCheckSetViewModel.RecipeConditions.PressureStabilizeSelected = step.PressureStabilizeSelected;
  1864. recipeConditionCheckSetViewModel.RecipeConditions.ProcessTimeToEnd = step.ProcessTimeToEnd;
  1865. }
  1866. var result = (windowManager as WindowManager)?.ShowDialogWithTitle(recipeConditionCheckSetViewModel, null, "Condition Check");
  1867. if (recipeConditionCheckSetViewModel.IsSave)
  1868. {
  1869. if (recipeConditionCheckSetViewModel.IsNone)
  1870. {
  1871. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().IsnoneConditionCheck = true;
  1872. }
  1873. else
  1874. {
  1875. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().IsnoneConditionCheck = false;
  1876. }
  1877. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ExternalSensor = recipeConditionCheckSetViewModel.RecipeConditions.ExternalSensor;
  1878. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ExternalSensorName = recipeConditionCheckSetViewModel.RecipeConditions.ExternalSensorName;
  1879. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().TempStabilizeSelected = recipeConditionCheckSetViewModel.RecipeConditions.TempStabizeSelected;
  1880. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().FinishAutoProfile = recipeConditionCheckSetViewModel.RecipeConditions.FinishAutoProfile;
  1881. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachTemp = recipeConditionCheckSetViewModel.RecipeConditions.ReachTemp;
  1882. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachTempValue = recipeConditionCheckSetViewModel.RecipeConditions.ReachTempValue;
  1883. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().O2Density = recipeConditionCheckSetViewModel.RecipeConditions.O2Density;
  1884. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().O2DensityValue = recipeConditionCheckSetViewModel.RecipeConditions.O2DensityValue;
  1885. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachPressure = recipeConditionCheckSetViewModel.RecipeConditions.ReachPressure;
  1886. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachPressureVG = recipeConditionCheckSetViewModel.RecipeConditions.ReachPressureVG;
  1887. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureStabilizeVG = recipeConditionCheckSetViewModel.RecipeConditions.PressureStabilizeVG;
  1888. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ReachPressureValue = recipeConditionCheckSetViewModel.RecipeConditions.ReachPressureValue;
  1889. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureStabilizeSelected = recipeConditionCheckSetViewModel.RecipeConditions.PressureStabilizeSelected;
  1890. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ProcessTimeToEnd = recipeConditionCheckSetViewModel.RecipeConditions.ProcessTimeToEnd;
  1891. }
  1892. if (recipeConditionCheckSetViewModel.IsNone)//不存数据处理
  1893. { }
  1894. break;
  1895. case "AlarmAction":
  1896. Combination combination = new Combination(CurrentRecipe.ConfigItems);
  1897. AlarmConditionEditViewModel alarmConditionViewModel = new AlarmConditionEditViewModel($"Parameter\\AlarmCondition", combination.AlarmCondition, SelectedRecipeStep.AlarmConditionTable.Value);
  1898. alarmConditionViewModel.IsEnableEdit = false;
  1899. alarmConditionViewModel.RecipeType = CurrentRecipe.RecipeChamberType;
  1900. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(alarmConditionViewModel, null, "Alarm Action"))
  1901. {
  1902. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmConditionTable.SetValue(alarmConditionViewModel.ReturnString);
  1903. }
  1904. //RecipeAlarmActionViewModel recipeAlarmActionViewModel = new RecipeAlarmActionViewModel
  1905. //{
  1906. // CurrentRecipe = CurrentRecipe,
  1907. // CurrentStepName = SelectedRecipeStep.Name,
  1908. // TableIndex = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmTableIndex,
  1909. // AlarmActions = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmActionSets
  1910. //};
  1911. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeAlarmActionViewModel, null, "Alarm Action"))
  1912. //{
  1913. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmTableIndex = recipeAlarmActionViewModel.TableIndex;
  1914. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().AlarmActionSets = recipeAlarmActionViewModel.AlarmActions;
  1915. //}
  1916. break;
  1917. case "TempSetting":
  1918. if (recipeTempSetViewModel is null)
  1919. {
  1920. recipeTempSetViewModel = new RecipeTempSetViewModel
  1921. {
  1922. RecipeTemplate = RecipeTemplate
  1923. };
  1924. }
  1925. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().TemperatureSets != null)
  1926. {
  1927. var tempSets = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1928. recipeTempSetViewModel.TemperatureValues = tempSets.TemperatureSets;
  1929. //tempSets.TemperatureSets.ToList().ForEach(x => recipeTempSetViewModel.TemperatureValues.Add(x));
  1930. }
  1931. recipeTempSetViewModel.StepType = SelectedRecipeStep.Name;
  1932. recipeTempSetViewModel.RecipeType = RecipeType;
  1933. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTempSetViewModel, null, "Temp Detail"))
  1934. {
  1935. if (recipeTempSetViewModel.TemperatureValues != null && recipeTempSetViewModel.TemperatureValues.Count > 0 && recipeTempSetViewModel.IsSave)
  1936. {
  1937. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().TemperatureSets != null)
  1938. {
  1939. // var tempSets = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1940. // tempSets.TemperatureSets = recipeTempSetViewModel.TempSetDataList;
  1941. }
  1942. }
  1943. }
  1944. break;
  1945. case "GASSetting":
  1946. RecipeMFCSettingViewModel recipeMFCSettingViewModel = new RecipeMFCSettingViewModel();
  1947. //InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorRecipeOK", "");
  1948. recipeMFCSettingViewModel.MFCSets = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().MFCSets;
  1949. //recipeGASSettingViewModel.MFMSets = new MFMValue() { AlarmValue = tempMFMSets.AlarmValue, IsNotifying = tempMFMSets.IsNotifying, Name = tempMFMSets.Name, Value = tempMFMSets.Value };
  1950. recipeMFCSettingViewModel.RecipeType = RecipeType;
  1951. recipeMFCSettingViewModel.RecipeTemplate = RecipeTemplate;
  1952. if (!(bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeMFCSettingViewModel, null, "MFC Detail"))
  1953. {
  1954. //InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorPROCManualOK", "");
  1955. return;
  1956. }
  1957. //InvokeClient.Instance.Service.DoOperation($"PM1.SetSensorPROCManualOK", "");
  1958. if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().MFCSets != null)
  1959. {
  1960. if (recipeMFCSettingViewModel.MFCSets != null && recipeMFCSettingViewModel.MFCSets.Count > 0)
  1961. {
  1962. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().MFCSets = recipeMFCSettingViewModel.MFCSets;
  1963. UpdateMFCShow();
  1964. }
  1965. }
  1966. break;
  1967. case "PressureSetting":
  1968. RecipePressureSettingViewModel recipePressureSettingViewModel = new RecipePressureSettingViewModel();
  1969. var tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1970. // recipePressureSettingViewModel.PressureSonsorValue = tempStep.PressureSonserValue;
  1971. // recipePressureSettingViewModel.PressureValveAngleValue = tempStep.PressureValveAngle;
  1972. // recipePressureSettingViewModel.PressureSettingVG = tempStep.PressureSettingVG;
  1973. //if (!string.IsNullOrEmpty(tempStep.PressureAlarmTableNo))
  1974. //{
  1975. // if (tempStep.PressureAlarmTableNo.ToLower() == "none")
  1976. // recipePressureSettingViewModel.PressureAlarmWatchTable = "None";
  1977. // else
  1978. // recipePressureSettingViewModel.PressureAlarmWatchTable = tempStep.PressureAlarmTableNo;
  1979. //}
  1980. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipePressureSettingViewModel, null, "Recipe Pressure Setting"))
  1981. //{
  1982. // if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault() != null)
  1983. // {
  1984. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureSonserValue = recipePressureSettingViewModel.PressureSonsorValue;
  1985. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureValveAngle = recipePressureSettingViewModel.PressureValveAngleValue;
  1986. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureAlarmTableNo = recipePressureSettingViewModel.PressureAlarmWatchTable;
  1987. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PressureSettingVG = recipePressureSettingViewModel.PressureSettingVG;
  1988. // // SelectedRecipeStep.PressureSonserValue = $"{recipePressureSettingViewModel.PressureSonsorValue}";
  1989. // }
  1990. //}
  1991. break;
  1992. case "RFSetting":
  1993. //RecipeRFPressureSettingViewModel recipeRFPressureSettingViewModel = new RecipeRFPressureSettingViewModel();
  1994. //var tempRecipeStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  1995. //recipeRFPressureSettingViewModel.RFSwitch = tempRecipeStep.RFSwitch;
  1996. //recipeRFPressureSettingViewModel.RFSetPointValue = tempRecipeStep.RFSetpoint;
  1997. //recipeRFPressureSettingViewModel.C1SetPointValue = tempRecipeStep.C1Setpoint;
  1998. //recipeRFPressureSettingViewModel.C2SetPointValue = tempRecipeStep.C2Setpoint;
  1999. //recipeRFPressureSettingViewModel.ForwardPowerAlarmWatchSetPointValue = tempRecipeStep.ForwardPowerAlarmWatchTable;
  2000. //recipeRFPressureSettingViewModel.PrAlarmWatchSetPointValue = tempRecipeStep.PrAlarmWatchTable;
  2001. //recipeRFPressureSettingViewModel.PIAlarmWatchSetPointValue = tempRecipeStep.PIAlarmWatchTable;
  2002. //recipeRFPressureSettingViewModel.C1AlarmWatchSetPointValue = tempRecipeStep.C1AlarmWatchTable;
  2003. //recipeRFPressureSettingViewModel.C2AlarmWatchSetPointValue = tempRecipeStep.C2AlarmWatchTable;
  2004. //recipeRFPressureSettingViewModel.VppAlarmWatchSetPointValue = tempRecipeStep.VppAlarmWatchTable;
  2005. //recipeRFPressureSettingViewModel.VdcAlarmWatchSetPointValue = tempRecipeStep.VdcAlarmWatchTable;
  2006. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeRFPressureSettingViewModel, null, "Recipe RF Setting"))
  2007. //{
  2008. // if (CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault() != null)
  2009. // {
  2010. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RFSwitch = recipeRFPressureSettingViewModel.RFSwitch;
  2011. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RFSetpoint = recipeRFPressureSettingViewModel.RFSetPointValue;
  2012. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().C1Setpoint = recipeRFPressureSettingViewModel.C1SetPointValue;
  2013. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().C2Setpoint = recipeRFPressureSettingViewModel.C2SetPointValue;
  2014. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ForwardPowerAlarmWatchTable = recipeRFPressureSettingViewModel.ForwardPowerAlarmWatchSetPointValue;
  2015. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PrAlarmWatchTable = recipeRFPressureSettingViewModel.PrAlarmWatchSetPointValue;
  2016. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().PIAlarmWatchTable = recipeRFPressureSettingViewModel.PIAlarmWatchSetPointValue;
  2017. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().C1AlarmWatchTable = recipeRFPressureSettingViewModel.C1AlarmWatchSetPointValue;
  2018. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().C2AlarmWatchTable = recipeRFPressureSettingViewModel.C2AlarmWatchSetPointValue;
  2019. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().VppAlarmWatchTable = recipeRFPressureSettingViewModel.VppAlarmWatchSetPointValue;
  2020. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().VdcAlarmWatchTable = recipeRFPressureSettingViewModel.VdcAlarmWatchSetPointValue;
  2021. // // SelectedRecipeStep.RFSetting = $"{recipeRFPressureSettingViewModel.RFSetPointValue}";
  2022. // }
  2023. //}
  2024. break;
  2025. case "Loader":
  2026. RecipeLoaderCommandViewModel recipeLoaderCommandViewModel = new RecipeLoaderCommandViewModel();
  2027. tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2028. recipeLoaderCommandViewModel.SelectedCmd = tempStep.LoaderCommand.Value;
  2029. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeLoaderCommandViewModel, null, "Loader Command"))
  2030. {
  2031. if (tempStep.LoaderCommand.Value != recipeLoaderCommandViewModel.ReturnString)
  2032. {
  2033. ClearLoaderSetValue();
  2034. }
  2035. tempStep.LoaderCommand.SetValue(recipeLoaderCommandViewModel.ReturnString);
  2036. SelectedRecipeStep.LoaderCommand.SetValue(recipeLoaderCommandViewModel.ReturnString);
  2037. SetShowLoaderValuePanel(recipeLoaderCommandViewModel.ReturnString);
  2038. }
  2039. break;
  2040. case "Pressure":
  2041. RecipePressCommandViewModel recipePressCommandViewModel = new RecipePressCommandViewModel();
  2042. tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2043. recipePressCommandViewModel.SelectedCmd = tempStep.PressCommand.Value;
  2044. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipePressCommandViewModel, null, "Press Command"))
  2045. {
  2046. tempStep.PressCommand.SetValue(recipePressCommandViewModel.ReturnString);
  2047. SelectedRecipeStep.PressCommand.SetValue(recipePressCommandViewModel.ReturnString);
  2048. SetShowPressPanel(recipePressCommandViewModel.ReturnString);
  2049. }
  2050. break;
  2051. case "PressureWait":
  2052. RecipePressureWaitViewModel recipePressureWaitViewModel = new RecipePressureWaitViewModel();
  2053. tempStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2054. var destinationStep = (Step)CloneUtil.CloneObject(tempStep);
  2055. destinationStep.StepNo = tempStep.StepNo;
  2056. destinationStep.PressWaitUnit.SetValue((string)QueryDataClient.Instance.Service.GetConfig($"PM1.APC.PressureUnit"));
  2057. recipePressureWaitViewModel.SelectedStep = destinationStep;
  2058. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipePressureWaitViewModel, null, "Press WaitSet"))
  2059. {
  2060. tempStep.PressIsWait = recipePressureWaitViewModel.SelectedStep.PressIsWait;
  2061. tempStep.PressLowWait = recipePressureWaitViewModel.SelectedStep.PressLowWait;
  2062. tempStep.PressHighWait = recipePressureWaitViewModel.SelectedStep.PressHighWait;
  2063. tempStep.PressWaitUnit = recipePressureWaitViewModel.SelectedStep.PressWaitUnit;
  2064. }
  2065. break;
  2066. case "Pattern":
  2067. if (SelectedRecipeStep != null)
  2068. {
  2069. string toolType = (string)QueryDataClient.Instance.Service.GetConfig("System.SetUp.ToolType");
  2070. isEditMFC = true;
  2071. if (ConstantsCommon.ELK.Equals(toolType))
  2072. {
  2073. using (FurnaceUI.Views.Editors.ELK.RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new FurnaceUI.Views.Editors.ELK.RecipeGasPanelSettingViewModel())
  2074. {
  2075. recipeGasPanelSettingViewModel.CurrentRecipe = CurrentRecipe;
  2076. recipeGasPanelSettingViewModel.SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}";
  2077. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  2078. recipeGasPanelSettingViewModel.SelectedStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2079. bool rtn = (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Recipe Gas View");
  2080. if (rtn)
  2081. {
  2082. isEditMFC = false;
  2083. }
  2084. }
  2085. }
  2086. else if (ConstantsCommon.SIBCN.Equals(toolType))
  2087. {
  2088. using (FurnaceUI.Views.Editors.SiBCN.RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new FurnaceUI.Views.Editors.SiBCN.RecipeGasPanelSettingViewModel())
  2089. {
  2090. recipeGasPanelSettingViewModel.CurrentRecipe = CurrentRecipe;
  2091. recipeGasPanelSettingViewModel.SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}";
  2092. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  2093. recipeGasPanelSettingViewModel.SelectedStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2094. bool rtn = (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Valve");
  2095. if (rtn)
  2096. {
  2097. isEditMFC = false;
  2098. }
  2099. }
  2100. }
  2101. else if (ConstantsCommon.TiN.Equals(toolType))
  2102. {
  2103. using (FurnaceUI.Views.Editors.TiN.RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new FurnaceUI.Views.Editors.TiN.RecipeGasPanelSettingViewModel())
  2104. {
  2105. recipeGasPanelSettingViewModel.CurrentRecipe = CurrentRecipe;
  2106. recipeGasPanelSettingViewModel.SelectedStepName = $"{SelectedRecipeStep.StepNo}:{SelectedRecipeStep.Name}";
  2107. recipeGasPanelSettingViewModel.ChangedStepEvent += RecipeGasPanelSettingViewModel_ChangedStepEvent;
  2108. recipeGasPanelSettingViewModel.SelectedStep = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2109. bool rtn = (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Valve");
  2110. if (rtn)
  2111. {
  2112. isEditMFC = false;
  2113. }
  2114. }
  2115. }
  2116. else
  2117. {
  2118. RecipeGasPanelSettingViewModel recipeGasPanelSettingViewModel = new RecipeGasPanelSettingViewModel();
  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. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGasPanelSettingViewModel, null, "Valve"))
  2124. {
  2125. }
  2126. }
  2127. }
  2128. break;
  2129. case "BoatElevatorSetting":
  2130. //BoatElevatorSettingViewModel boatElevatorSettingViewModel = new BoatElevatorSettingViewModel();
  2131. //boatElevatorSettingViewModel.SelectedRecipeStep = SelectedRecipeStep;
  2132. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(boatElevatorSettingViewModel, null, "BoatElevator Setting"))
  2133. //{
  2134. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ZAxisPosition = boatElevatorSettingViewModel.SelectedRecipeStep.ZAxisPosition;
  2135. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().ZAxisSpeed = boatElevatorSettingViewModel.SelectedRecipeStep.ZAxisSpeed;
  2136. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RotatePosition = boatElevatorSettingViewModel.SelectedRecipeStep.RotatePosition;
  2137. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RotateSpeed = boatElevatorSettingViewModel.SelectedRecipeStep.RotateSpeed;
  2138. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RotateInterval = boatElevatorSettingViewModel.SelectedRecipeStep.RotateInterval;
  2139. // CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().RotateDirection = boatElevatorSettingViewModel.SelectedRecipeStep.RotateDirection;
  2140. //}
  2141. break;
  2142. case "AUX":
  2143. if (SelectedRecipeStep == null || SelectedRecipeStep.AUXSets.Count == 0)
  2144. { return; }
  2145. RecipeAUXSetViewModel recipeAUXSetViewModel = new RecipeAUXSetViewModel();
  2146. recipeAUXSetViewModel.AUXDataList = SelectedRecipeStep.AUXSets;
  2147. if (!(bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeAUXSetViewModel, null, "AUX Set"))
  2148. {
  2149. // SelectedRecipeStep.UndoAUXChanges();
  2150. }
  2151. break;
  2152. case "RecipeHeader":
  2153. RecipeHeaderViewModel recipeHeaderViewModel = new RecipeHeaderViewModel();
  2154. recipeHeaderViewModel.CombinationData = new Combination(CurrentRecipe.ConfigItems);
  2155. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeHeaderViewModel, null, "Recipe Header"))
  2156. {
  2157. recipeHeaderViewModel.CombinationData.SetValueToParam();
  2158. }
  2159. break;
  2160. case "Combination":
  2161. RecipeCombinationViewModel recipeCombinationViewModel = new RecipeCombinationViewModel();
  2162. recipeCombinationViewModel.CombinationData = new Combination(CurrentRecipe.ConfigItems);
  2163. recipeCombinationViewModel.CombinationData.ChangedValueEvent += CombinationData_ChangedValueEvent;
  2164. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeCombinationViewModel, null, "Combination"))
  2165. {
  2166. recipeCombinationViewModel.CombinationData.SetValueToParam();
  2167. }
  2168. break;
  2169. case "VPDataList":
  2170. RecipeVPItemSelectViewModel recipeVPItemSelectViewModel = new RecipeVPItemSelectViewModel();
  2171. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeVPItemSelectViewModel, null, "VP Item Select"))
  2172. {
  2173. }
  2174. break;
  2175. case "AbortRecipe":
  2176. Step currentStep = CurrentRecipe.Steps.FirstOrDefault(x => x.StepNo == SelectedRecipeStep.StepNo);
  2177. StringParam abortCombination = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "Combination.AbortRecipe") as StringParam;
  2178. if (string.IsNullOrEmpty(abortCombination.Value))
  2179. {
  2180. DialogBox.ShowError("Please select abort recipe first!");
  2181. }
  2182. var retRecipe = RecipeTableSelect.ShowDialog($"Furnace\\abort", abortCombination.Value, false);
  2183. if (!string.IsNullOrEmpty(retRecipe))
  2184. {
  2185. currentStep.AbortRecipeTableIndex = retRecipe;
  2186. SelectedRecipeStep.AbortRecipeTableIndex = retRecipe;
  2187. }
  2188. break;
  2189. case "SkipOrWait":
  2190. RecipeSkipWaitCommandViewModel recipeSkipWaitCommandViewModel = new RecipeSkipWaitCommandViewModel();
  2191. recipeSkipWaitCommandViewModel.SkipWait = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().SkipWait;
  2192. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeSkipWaitCommandViewModel, null, "Skip or wait command"))
  2193. {
  2194. CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().SkipWait = recipeSkipWaitCommandViewModel.RtnString;
  2195. SelectedRecipeStep.SkipWait = recipeSkipWaitCommandViewModel.RtnString;
  2196. }
  2197. break;
  2198. default:
  2199. break;
  2200. }
  2201. }
  2202. private void CombinationData_ChangedValueEvent(string type, string value)
  2203. {
  2204. string prefix = "";
  2205. switch (type)
  2206. {
  2207. case "SubRecipe":
  2208. break;
  2209. case "AlarmRecipe":
  2210. break;
  2211. case "AbortRecipePath":
  2212. break;
  2213. case "AlarmCondition":
  2214. break;
  2215. case "LeakCheck":
  2216. break;
  2217. case "PressAPCPID":
  2218. prefix = $"Parameter\\APCPID";
  2219. var pressAPCDictData = LoadData(prefix, value);
  2220. foreach (var item in CurrentRecipe.Steps)
  2221. {
  2222. if (item.PressPID.Value.Contains(","))
  2223. {
  2224. var pidList = item.PressPID.Value.Split(',');
  2225. if (pidList.Count() > 2)
  2226. {
  2227. pidList[0] = $"{prefix}\\{value}";
  2228. int pressAPCTempNo = 0;
  2229. int.TryParse(pidList[1], out pressAPCTempNo);
  2230. if (pressAPCDictData != null && pressAPCDictData.ContainsKey(pressAPCTempNo))
  2231. {
  2232. pidList[2] = pressAPCDictData[pressAPCTempNo];
  2233. }
  2234. item.PressPID.Value = string.Join(",", pidList);
  2235. }
  2236. }
  2237. }
  2238. break;
  2239. case "TempCorrection":
  2240. prefix = $"Parameter\\TempCorrection";
  2241. var tempCorDictData = LoadData(prefix, value);
  2242. foreach (var item in CurrentRecipe.Steps)
  2243. {
  2244. if (item.TemperatureCorrect.Value.Contains(","))
  2245. {
  2246. var pidList = item.TemperatureCorrect.Value.Split(',');
  2247. if (pidList.Count() > 2)
  2248. {
  2249. pidList[0] = $"{prefix}\\{value}";
  2250. int tempCorTempNo = 0;
  2251. int.TryParse(pidList[1], out tempCorTempNo);
  2252. if (tempCorDictData != null && tempCorDictData.ContainsKey(tempCorTempNo))
  2253. {
  2254. pidList[2] = tempCorDictData[tempCorTempNo];
  2255. }
  2256. item.TemperatureCorrect.Value = string.Join(",", pidList);
  2257. }
  2258. }
  2259. }
  2260. break;
  2261. case "TempPID":
  2262. prefix = $"Parameter\\TempPID";
  2263. var tempPIDDictData = LoadData(prefix, value);
  2264. foreach (var item in CurrentRecipe.Steps)
  2265. {
  2266. if (item.TemperaturePID.Value.Contains(","))
  2267. {
  2268. var pidList = item.TemperaturePID.Value.Split(',');
  2269. if (pidList.Count() > 2)
  2270. {
  2271. pidList[0] = $"{prefix}\\{value}";
  2272. int tempTempNo = 0;
  2273. int.TryParse(pidList[1], out tempTempNo);
  2274. if (tempPIDDictData != null && tempPIDDictData.ContainsKey(tempTempNo))
  2275. {
  2276. pidList[2] = tempPIDDictData[tempTempNo];
  2277. }
  2278. }
  2279. item.TemperaturePID.Value = string.Join(",", pidList);
  2280. }
  2281. }
  2282. break;
  2283. case "ProfileCondition":
  2284. break;
  2285. default:
  2286. break;
  2287. }
  2288. }
  2289. public TempPIDParameterData CurrentParameter { get; set; } = new TempPIDParameterData();
  2290. private readonly ParameterProvider _parameterProvider = new ParameterProvider();
  2291. private Dictionary<int, string> LoadData(string PrefixPath, string name)
  2292. {
  2293. var recipeContent = _parameterProvider.LoadParameter(PrefixPath, name);
  2294. if (string.IsNullOrEmpty(recipeContent))
  2295. {
  2296. System.Windows.MessageBox.Show($"{PrefixPath}\\{name} is empty, please confirm the file is valid.");
  2297. return null;
  2298. }
  2299. var parameter = new TempPIDParameterData();
  2300. parameter.PrefixPath = PrefixPath;
  2301. parameter.Name = name;
  2302. parameter.InitData(PrefixPath, name, recipeContent, "");
  2303. var dictData = new Dictionary<int, string>();
  2304. if (parameter != null && parameter.Steps.Count > 0)
  2305. {
  2306. foreach (var item in parameter.Steps)
  2307. {
  2308. dictData.Add(item.StepNo, item.Name);
  2309. }
  2310. }
  2311. return dictData;
  2312. }
  2313. public void LowPressWaitTextChanged(object sender, object item)
  2314. {
  2315. if (SelectedRecipeStep == null)
  2316. {
  2317. DialogBox.ShowWarning("The current step is empty!");
  2318. return;
  2319. }
  2320. SelectExistViewModel selectExistViewModel = new SelectExistViewModel();
  2321. selectExistViewModel.ProductZeroStr = SelectedRecipeStep.PressLowPressWait.Value;
  2322. var windowManager = IoC.Get<IWindowManager>();
  2323. var dialogReturn = (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(selectExistViewModel, null, "Select");
  2324. if ((bool)dialogReturn)
  2325. {
  2326. SelectedRecipeStep.PressLowPressWait.SetValue(selectExistViewModel.DialogResultString);
  2327. }
  2328. }
  2329. public void UpdateTotalTime()
  2330. {
  2331. if (CurrentRecipe != null && CurrentRecipe.ConfigItems != null)
  2332. {
  2333. var param = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "RecipeTime");
  2334. string outAlarmSet = "0";
  2335. if (param != null && param is StringParam)
  2336. {
  2337. List<double> timeList = new List<double>();
  2338. foreach (var item in CurrentRecipe.Steps)
  2339. {
  2340. var timeStr = item.Time;
  2341. if (timeStr != null)
  2342. {
  2343. double hhTime = 0;
  2344. double mmTime = 0;
  2345. double ssTime = 0;
  2346. var strs = timeStr.Split(':');
  2347. if (strs.Length < 3) continue;
  2348. double.TryParse(strs[0], out hhTime);
  2349. double.TryParse(strs[1], out mmTime);
  2350. double.TryParse(strs[2], out ssTime);
  2351. timeList.Add(hhTime * 3600 + mmTime * 60 + ssTime);
  2352. }
  2353. else
  2354. {
  2355. continue;
  2356. }
  2357. }
  2358. string sumValue = timeList.ToArray().Sum().ToString();
  2359. if (((StringParam)param).Value != sumValue)
  2360. {
  2361. ((StringParam)param).Value = sumValue;
  2362. //outAlarmSet = (timeList.ToArray().Sum() * 10).ToString();
  2363. }
  2364. }
  2365. var paramTimeOut = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "TimeOutAlarmSet");
  2366. if (paramTimeOut != null && param is DoubleParam)
  2367. {
  2368. if (outAlarmSet != "0")
  2369. {
  2370. ((DoubleParam)paramTimeOut).Value = outAlarmSet;
  2371. }
  2372. }
  2373. }
  2374. }
  2375. public void RecipeSave()
  2376. {
  2377. List<string> noNeedEndRecipeType = new List<string>() {
  2378. "reset",
  2379. "idle",
  2380. "abort",
  2381. "sub",
  2382. "alarm",
  2383. };
  2384. var SelectedStep = this.CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2385. //if (SelectedStep != null)
  2386. //{
  2387. // SelectedStep.LoaderValue = GetSaveLoaderValue(SelectedStep.LoaderCommand);
  2388. // SelectedStep.PressValue = GetSavePressValue(SelectedStep.PressCommand);
  2389. //}
  2390. RecipePermissionSelectViewModel dialog = new RecipePermissionSelectViewModel("Save recipe and permission", CurrentRecipe.RecipePermission, CurrentRecipe.Description);
  2391. WindowManager wm = new WindowManager();
  2392. bool? dialogReturn = wm.ShowDialog(dialog);
  2393. if (!dialogReturn.HasValue || !dialogReturn.Value)
  2394. return;
  2395. this.CurrentRecipe.ReviseTime = DateTime.Now;
  2396. CurrentRecipe.Description = dialog.RecipeComment;
  2397. InvokeClient.Instance.Service.DoOperation("SetRecipeEditHistory", this.CurrentRecipe.GetRecipeHistory());
  2398. List<string> names = new List<string>();
  2399. string filmFormula = string.Empty;
  2400. Step step = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault();
  2401. if (string.IsNullOrEmpty(CurrentRecipe.Name))
  2402. {
  2403. DialogBox.ShowWarning("Recipe name is empty,can not save!");
  2404. return;
  2405. }
  2406. bool bStandby = false, bEnd;
  2407. foreach (Step recipestep in CurrentRecipe.Steps)
  2408. {
  2409. if (recipestep.StepNo == 0)
  2410. bStandby = true;
  2411. //DialogBox.ShowWarning($"{recipestep.TemperatureControlMode}");
  2412. //DialogBox.ShowWarning($"{recipestep.TemperatureCorrect}");
  2413. //DialogBox.ShowWarning($"{recipestep.TemperaturePID}");
  2414. //if (string.IsNullOrEmpty(filmFormula))
  2415. // filmFormula = recipestep.FilmThickFormula;
  2416. //if (filmFormula != recipestep.FilmThickFormula)
  2417. //{
  2418. // DialogBox.ShowWarning($"The step film thicknesss formula of step number {recipestep.StepNo} is different,can not save!");
  2419. // return;
  2420. //}
  2421. if (string.IsNullOrEmpty(recipestep.Name) || string.IsNullOrEmpty(recipestep.Time))
  2422. {
  2423. if (recipestep.Name != "Standby")
  2424. {
  2425. DialogBox.ShowWarning($"The step name or time of step number {recipestep.StepNo} is empty,can not save!");
  2426. return;
  2427. }
  2428. }
  2429. if (names.Where(x => x == recipestep.Name).FirstOrDefault() != null)
  2430. {
  2431. DialogBox.ShowWarning("Step name cannot be duplicated!");
  2432. return;
  2433. }
  2434. names.Add(recipestep.Name);
  2435. bEnd = bStandby ? recipestep.StepNo == CurrentRecipe.Steps.Count - 1 : recipestep.StepNo == CurrentRecipe.Steps.Count;
  2436. //// "reset/Idle/abort/sub"类型的Recipe不需要End结尾
  2437. if (bEnd == true && noNeedEndRecipeType.Contains(CurrentRecipe.RecipeChamberType.ToLower()))
  2438. {
  2439. bEnd = false;
  2440. }
  2441. //是否是最后一步
  2442. if (bEnd)
  2443. {
  2444. if (!recipestep.Name.ToUpper().Contains("END"))
  2445. {
  2446. DialogBox.ShowWarning("The step command of last step must be 'END',please check!");
  2447. return;
  2448. }
  2449. }
  2450. }
  2451. // step.SetStepValues(SelectedRecipeStep);
  2452. this.CurrentRecipe.Revisor = BaseApp.Instance.UserContext.LoginName;
  2453. this.CurrentRecipe.ReviseTime = DateTime.Now;
  2454. this.CurrentRecipe.RecipeLevel = this.LevelDisplay;
  2455. this.CurrentRecipe.RecipePermission = dialog.RecipeComment;
  2456. UpdateTotalTime();
  2457. var result = this._recipeProvider.SaveRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name, CurrentRecipe.GetXmlString());
  2458. if (result)
  2459. {
  2460. ((Window)GetView()).DialogResult = true;
  2461. }
  2462. }
  2463. public List<ConfigNode> GetMfcItem()
  2464. {
  2465. this.SystemName = "System";
  2466. ConfigNodes = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  2467. var MfcItems = ConfigNodes.Where(x => x.Display == "Parameter").FirstOrDefault().SubNodes.Where(y => y.Name == "MFC").FirstOrDefault().SubNodes;
  2468. return MfcItems;
  2469. }
  2470. public void RecipeCancel()
  2471. {
  2472. if (DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM, " You confirm that you want to unsave the recipe and exit the interface?") == DialogButton.No)
  2473. return;
  2474. ((Window)GetView()).DialogResult = false;
  2475. }
  2476. public void PressPIDChick()
  2477. {
  2478. var windowManager = IoC.Get<IWindowManager>();
  2479. StringParam pressAPC = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "Combination.PressAPCPID") as StringParam;
  2480. if (pressAPC == null)
  2481. {
  2482. DialogBox.ShowDialog(DialogButton.Cancel, DialogType.INFO, "Please set the combination file first");
  2483. return;
  2484. }
  2485. APCPIDEditViewModel aPCPIDEditViewModel = new APCPIDEditViewModel();
  2486. aPCPIDEditViewModel.IsEditEnabled = false;
  2487. aPCPIDEditViewModel.CurrentRecipe = CurrentRecipe;
  2488. var rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(aPCPIDEditViewModel, null, "APC PID Table");
  2489. if ((bool)rtn && SelectedRecipeStep != null)
  2490. SelectedRecipeStep.PressPID.SetValue(aPCPIDEditViewModel.RetrunString);
  2491. }
  2492. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  2493. {
  2494. base.InvokeAfterUpdateProperty(data);
  2495. if (SelectedRecipeStep != null)
  2496. {
  2497. if (CurrentRecipe.RecipeChamberType == RecipeDataBase.ProcessType)
  2498. {
  2499. SelectIndex = SelectedRecipeStep.StepNo + 1;
  2500. }
  2501. else
  2502. {
  2503. SelectIndex = SelectedRecipeStep.StepNo;
  2504. }
  2505. }
  2506. if (CurrentRecipe.Steps != null && CurrentRecipe.Steps.Count > 0 && CheckValueChange(data))
  2507. {
  2508. // UpdateRecipeGASSetting(data);
  2509. //SelectStep(CurrentRecipe.Steps[EditRecipeStepNo]);
  2510. }
  2511. // UpdateGASSetting();
  2512. oldresult = data;
  2513. SetCmdIsEnabled();
  2514. }
  2515. Dictionary<string, object> oldresult;
  2516. private bool CheckValueChange(Dictionary<string, object> result)
  2517. {
  2518. Dictionary<string, object> temp = result;
  2519. if (oldresult == null)
  2520. {
  2521. oldresult = result;
  2522. return true;
  2523. }
  2524. else
  2525. {
  2526. List<string> strkeys = new List<string>();
  2527. foreach (var key in result.Keys)
  2528. {
  2529. if (_subscribedKeys.Contains(key) && oldresult.ContainsKey(key) && result.ContainsKey(key))
  2530. {
  2531. if (result[key].GetType() == typeof(AITValveData) && ((AITValveData)oldresult[key]).VirtualFeedback != ((AITValveData)result[key]).VirtualFeedback)
  2532. {
  2533. return true;
  2534. }
  2535. else if (result[key].GetType() == typeof(AITMfcData) && ((AITMfcData)oldresult[key]).VirtualSetPoint != ((AITMfcData)result[key]).VirtualSetPoint)
  2536. {
  2537. return true;
  2538. }
  2539. else if (result[key].GetType() == typeof(bool) && (bool)oldresult[key] != (bool)result[key])
  2540. {
  2541. return true;
  2542. }
  2543. }
  2544. }
  2545. }
  2546. return false;
  2547. }
  2548. public void SetValue(object sender)
  2549. {
  2550. string value = ((TextBox)sender).Text;
  2551. NumberKeyboard fullKeyboard = new NumberKeyboard("", value);
  2552. if ((bool)fullKeyboard.ShowDialog())
  2553. {
  2554. ((TextBox)sender).Text = fullKeyboard.ValueString;
  2555. }
  2556. }
  2557. public void SetValue(object sender, string isFullKeyboard = "")
  2558. {
  2559. string value = ((TextBox)sender).Text;
  2560. if (!string.IsNullOrEmpty(isFullKeyboard))
  2561. {
  2562. FullKeyboard fullKeyboard1 = new FullKeyboard("", value);
  2563. if ((bool)fullKeyboard1.ShowDialog())
  2564. {
  2565. ((TextBox)sender).Text = fullKeyboard1.ValueString;
  2566. }
  2567. }
  2568. else
  2569. {
  2570. NumberKeyboard fullKeyboard = new NumberKeyboard("", value);
  2571. if ((bool)fullKeyboard.ShowDialog())
  2572. {
  2573. ((TextBox)sender).Text = fullKeyboard.ValueString;
  2574. }
  2575. }
  2576. }
  2577. public void MFCTextChanged(string type, object sender, object item)
  2578. {
  2579. if (!string.IsNullOrEmpty(type) && item != null && sender != null)
  2580. {
  2581. //if (isEditMFC) return;
  2582. MFCData mFCData = (MFCData)item;
  2583. string value = ((TextBox)sender).Text;
  2584. switch (type)
  2585. {
  2586. case "Value":
  2587. double setValue = 0;
  2588. double.TryParse(value, out setValue);
  2589. double.TryParse(mFCData.ScaleValue, out double maxData);
  2590. if (setValue > maxData)
  2591. {
  2592. DialogBox.ShowWarning($"{mFCData.ControlName} Out of the setting range {0}~{maxData}!");
  2593. ((TextBoxEx)sender).ChangedColor = ((TextBoxEx)sender).NormalColor;
  2594. SetSetPointValue(mFCData.ControlName, $"0");
  2595. return;
  2596. }
  2597. else
  2598. {
  2599. BrushConverter brushConverter = new BrushConverter();
  2600. if (setValue > 0)
  2601. {
  2602. ((TextBoxEx)sender).ChangedColor = (Brush)brushConverter.ConvertFromString("Yellow");
  2603. }
  2604. InvokeClient.Instance.Service.DoOperation($"PM1.{mFCData.ControlName}.SetMfcVirtualValue", $"{value};{mFCData.Rampng.Value};{mFCData.AlarmValue}");
  2605. }
  2606. break;
  2607. case "Rampng":
  2608. InvokeClient.Instance.Service.DoOperation($"PM1.{mFCData.ControlName}.SetMfcVirtualValue", $"{mFCData.SetValue.Value};{value};{mFCData.AlarmValue}");
  2609. SetRampngValue(mFCData.DisplayName, value);
  2610. break;
  2611. default:
  2612. break;
  2613. }
  2614. }
  2615. }
  2616. private void SetSetPointValue(string name, string value)
  2617. {
  2618. if (double.TryParse(value, out double getValue))
  2619. {
  2620. var stepNo = 0;
  2621. if (!_isStandbyCheckedSelect)
  2622. stepNo = SelectedRecipeStep.StepNo;
  2623. var step = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault();
  2624. if (step != null)
  2625. {
  2626. var mfc = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().MFCSets.FirstOrDefault(x => x.ControlName == name);
  2627. if (mfc != null)
  2628. {
  2629. mfc.SetValue.SetValue(value);
  2630. }
  2631. }
  2632. }
  2633. }
  2634. public void PressTextChanged(string type, object sender, object item)
  2635. {
  2636. if (!string.IsNullOrEmpty(type) && item != null && sender != null)
  2637. {
  2638. Step step = (Step)item;
  2639. if (step.StepNo != OldStep.StepNo)
  2640. {
  2641. return;
  2642. }
  2643. //string value = ((TextBox)sender).Text;
  2644. //switch (type)
  2645. //{
  2646. // case "PressSet":
  2647. // step.PressSet.IsSaved = false;
  2648. // break;
  2649. // case "PressSlowVacSet":
  2650. // step.PressSlowVacSet.IsSaved = false;
  2651. // break;
  2652. // case "PressValveAngleSet":
  2653. // step.PressValveAngleSet.IsSaved = false;
  2654. // break;
  2655. // case "PressLowPressWait":
  2656. // step.PressLowPressWait.IsSaved = false;
  2657. // break;
  2658. // case "WaitPress":
  2659. // step.WaitPress.IsSaved = false;
  2660. // break;
  2661. // default:
  2662. // break;
  2663. //}
  2664. }
  2665. }
  2666. //public void PressValidated(string type, object sender, object item)
  2667. //{
  2668. // if (!string.IsNullOrEmpty(type) && item != null && sender != null)
  2669. // {
  2670. // Step step = (Step)item;
  2671. // if (step.StepNo != OldStep.StepNo)
  2672. // {
  2673. // return;
  2674. // }
  2675. // string value = ((TextBox)sender).Text;
  2676. // switch (type)
  2677. // {
  2678. // case "PressSet":
  2679. // step.PressSet.IsSaved = false;
  2680. // break;
  2681. // case "PressSlowVacSet":
  2682. // step.PressSlowVacSet.IsSaved = false;
  2683. // break;
  2684. // case "PressValveAngleSet":
  2685. // step.PressValveAngleSet.IsSaved = false;
  2686. // break;
  2687. // case "PressLowPressWait":
  2688. // step.PressLowPressWait.IsSaved = false;
  2689. // break;
  2690. // case "WaitPress":
  2691. // step.WaitPress.IsSaved = false;
  2692. // break;
  2693. // default:
  2694. // break;
  2695. // }
  2696. // }
  2697. //}
  2698. private void SetRampngValue(string name, string value)
  2699. {
  2700. if (double.TryParse(value, out double getValue))
  2701. {
  2702. var stepNo = 0;
  2703. if (!_isStandbyCheckedSelect)
  2704. stepNo = SelectedRecipeStep.StepNo;
  2705. var step = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault();
  2706. if (step != null)
  2707. {
  2708. var mfc = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().MFCSets.FirstOrDefault(x => x.ControlName == name);
  2709. if (mfc != null)
  2710. {
  2711. mfc.Rampng.SetValue(value);
  2712. }
  2713. }
  2714. }
  2715. }
  2716. private void UpdateMFCShow()
  2717. {
  2718. var mfcDict = CurrentRecipe.Steps.Where(x => x.StepNo == SelectedRecipeStep.StepNo).FirstOrDefault().MFCSets;
  2719. foreach (var item in mfcDict)
  2720. {
  2721. //var mfc = MFCDataList.FirstOrDefault(x => x.Name == item.Key.Replace(".Flow", ""));
  2722. //if (mfc != null)
  2723. //{
  2724. // mfc.IsCheck = item.Value.IsCheck;
  2725. //}
  2726. }
  2727. }
  2728. private void UpdateRecipeGASSetting(Dictionary<string, object> result)
  2729. {
  2730. var stepNo = 0;
  2731. if (!_isStandbyCheckedSelect)
  2732. stepNo = SelectedRecipeStep.StepNo;
  2733. var step = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault();
  2734. if (step != null)
  2735. {
  2736. var mfcSets = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().MFCSets;
  2737. var valveSets = CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().ValveSets;
  2738. foreach (var key in result.Keys)
  2739. {
  2740. //if (result[key].GetType() == typeof(AITValveData))
  2741. //{
  2742. // var valveData = (AITValveData)result[key];
  2743. // if (valveSets.ContainsKey(valveData.DeviceName))
  2744. // {
  2745. // valveSets[valveData.DeviceName] = valveData.VirtualFeedback ? "Open" : "Close";
  2746. // }
  2747. //}else
  2748. if (result[key].GetType() == typeof(AITMfcData))
  2749. {
  2750. var mfcData = (AITMfcData)result[key];
  2751. var name = $"{mfcData.DeviceName}.Flow";
  2752. var findMFC = mfcSets.FirstOrDefault(x => x.ControlName == name);
  2753. if (findMFC != null)
  2754. {
  2755. findMFC.SetValue.Value = mfcData.VirtualSetPoint.ToString();
  2756. findMFC.Rampng.Value = mfcData.VirtualRamping.ToString();
  2757. findMFC.AlarmValue = mfcData.VirtualAlarmWatchTable;
  2758. }
  2759. }
  2760. }
  2761. CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().MFCSets = mfcSets;
  2762. CurrentRecipe.Steps.Where(x => x.StepNo == stepNo).FirstOrDefault().ValveSets = valveSets;
  2763. }
  2764. }
  2765. private void UpdateGASSetting()
  2766. {
  2767. if (_isStandbyCheckedSelect)
  2768. return;
  2769. List<AITMfcData> mfcDatas = new List<AITMfcData>()
  2770. {
  2771. MFC1Data,
  2772. MFC2Data,
  2773. MFC3Data,
  2774. MFC4Data,
  2775. MFC5Data,
  2776. MFC6Data,
  2777. MFC7Data,
  2778. MFC8Data,
  2779. MFC9Data,
  2780. MFC10Data,
  2781. MFC11Data,
  2782. MFC12Data,
  2783. MFC13Data,
  2784. MFC14Data,
  2785. MFC15Data,
  2786. MFC16Data,
  2787. MFC17Data,
  2788. MFC31Data,
  2789. MFC32Data,
  2790. //MFC51Data,
  2791. };
  2792. for (int i = 0; i < mfcDatas.Count; i++)
  2793. {
  2794. if (SelectedRecipeStep != null)
  2795. {
  2796. if (mfcDatas[i] == null) continue;
  2797. var mfc = SelectedRecipeStep.MFCSets.FirstOrDefault(x => x.ControlName == mfcDatas[i].DeviceName);
  2798. mfc.SetValue.Value = mfcDatas[i].VirtualSetPoint.ToString();
  2799. mfc.Rampng.Value = mfcDatas[i].VirtualRamping.ToString();
  2800. }
  2801. }
  2802. }
  2803. public void SelecteTable()
  2804. {
  2805. CurrentRecipe.Tables.FirstOrDefault(x => x.Index == CurrentRecipe.TableIndex).TableData.Steps.Clear();
  2806. CurrentRecipe.Steps.ToList().ForEach(x =>
  2807. {
  2808. var tempStep = (Step)CloneUtil.CloneAllObject(x);
  2809. CurrentRecipe.Tables.FirstOrDefault(y => y.Index == CurrentRecipe.TableIndex).TableData.Steps.Add(tempStep);
  2810. });
  2811. CurrentRecipe.StepCloneChangedIndex();
  2812. int getIndex = RecipeTableSelect.ShowDialogGetTableIndex(CurrentRecipe, RecipeType);
  2813. //SelectStep(CurrentRecipe.Steps.FirstOrDefault());
  2814. if (getIndex != -1)
  2815. {
  2816. while (CurrentRecipe.Steps.Count > 0)
  2817. {
  2818. CurrentRecipe.Steps.RemoveAt(0);
  2819. }
  2820. CurrentRecipe.Tables.FirstOrDefault(x => x.Index == (getIndex + 1)).TableData.Steps.ToList().ForEach(x =>
  2821. {
  2822. Step tempStep = (Step)CloneUtil.CloneAllObject(x);
  2823. CurrentRecipe.SetDelegateEvent(tempStep);
  2824. CurrentRecipe.Steps.Add(tempStep);
  2825. });
  2826. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  2827. SelectStep(CurrentRecipe.Steps.FirstOrDefault());
  2828. }
  2829. }
  2830. private int currentPage = 1;
  2831. private int pageSize = 10;
  2832. private int totalPage = 0;
  2833. private ObservableCollection<Step> _newSteps = new ObservableCollection<Step>();
  2834. public ObservableCollection<Step> NewSteps
  2835. {
  2836. get
  2837. {
  2838. return _newSteps;
  2839. }
  2840. set
  2841. {
  2842. _newSteps = value;
  2843. NotifyOfPropertyChange(nameof(NewSteps));
  2844. }
  2845. }
  2846. public void PageLineTop()
  2847. {
  2848. if (currentPage <= 1)
  2849. {
  2850. return;
  2851. }
  2852. currentPage = currentPage - 1;
  2853. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  2854. IndexNoDefault = 9;
  2855. SelectStep(NewSteps[IndexNoDefault]);
  2856. RefreshUpdate();
  2857. }
  2858. public void PageTop()
  2859. {
  2860. if (IndexNoDefault == 0)
  2861. {
  2862. PageLineTop();
  2863. if (currentPage != 1)
  2864. {
  2865. IndexNoDefault = NewSteps.Count - 1;
  2866. }
  2867. return;
  2868. }
  2869. IndexNoDefault = IndexNoDefault - 1;
  2870. SelectStep(NewSteps[IndexNoDefault]);
  2871. RefreshUpdate();
  2872. }
  2873. public void PageDown()
  2874. {
  2875. if (IndexNoDefault == CurrentRecipe.Steps.Count || SelectedRecipeStep == CurrentRecipe.Steps.LastOrDefault())
  2876. {
  2877. return;
  2878. }
  2879. IndexNoDefault = IndexNoDefault + 1;
  2880. if ((IndexNoDefault % pageSize) == 0)
  2881. {
  2882. PageLineDown();
  2883. }
  2884. SelectStep(NewSteps[IndexNoDefault]);
  2885. RefreshUpdate();
  2886. }
  2887. public void PageLineDown()
  2888. {
  2889. if (currentPage >= GetTotalPage())
  2890. {
  2891. return;
  2892. }
  2893. currentPage = currentPage + 1;
  2894. NewSteps = new ObservableCollection<Step>(CurrentRecipe.Steps.Take(pageSize * currentPage).Skip(pageSize * (currentPage - 1)));
  2895. IndexNoDefault = 0;
  2896. SelectStep(NewSteps[IndexNoDefault]);
  2897. RefreshUpdate();
  2898. }
  2899. public int GetTotalPage()
  2900. {
  2901. var totalPage = CurrentRecipe.Steps.Count / pageSize;
  2902. if ((CurrentRecipe.Steps.Count % pageSize) > 0)
  2903. {
  2904. totalPage = totalPage + 1;
  2905. }
  2906. return totalPage;
  2907. }
  2908. public int GetcurrentPage()
  2909. {
  2910. var currentPage = IndexNoDefault / pageSize;
  2911. if ((IndexNoDefault % pageSize) > 0)
  2912. {
  2913. currentPage = currentPage + 1;
  2914. }
  2915. if (currentPage == 0) currentPage++;
  2916. return currentPage;
  2917. }
  2918. }
  2919. }