RecipeProcessEditViewModel.cs 140 KB

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