RecipeProcessEditViewModel.cs 141 KB

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