RecipeProcessEditViewModel.cs 141 KB

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