RecipeProcessEditViewModel.cs 140 KB

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