RecipeProcessEditViewModel.cs 141 KB

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