RecipeProcessEditViewModel.cs 140 KB

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