OverviewViewModel.cs 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Runtime.InteropServices;
  7. using System.Timers;
  8. using System.Windows;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Xml;
  12. using Aitex.Core.Common.DeviceData;
  13. using Aitex.Core.MES;
  14. using Aitex.Core.MES.JC;
  15. using Aitex.Core.MES.YZQZ;
  16. using Aitex.Core.Observer;
  17. using Aitex.Core.RT.SCCore;
  18. using Aitex.Core.UI.Control;
  19. using Aitex.Core.UI.Dialog;
  20. using Aitex.Core.UI.MVVM;
  21. using Aitex.Core.Util;
  22. using Aitex.Core.Utilities;
  23. using Aitex.Platform;
  24. using Aitex.Triton160.Common;
  25. using Aitex.Triton160.UI;
  26. using Aitex.Triton160.UI.Properties;
  27. using Aitex.Triton160.UI.ViewModel;
  28. using Aitex.Triton160.UI.Views;
  29. using Aitex.Triton160.UI.Views.Hz;
  30. using Aitex.Triton160.UI.Wcf;
  31. namespace Triton160.UI.ViewModel
  32. {
  33. class OverviewViewModel : UIViewModelBase
  34. {
  35. [DllImport("User32.dll")]
  36. public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
  37. #region Command
  38. public ICommand DeviceOperationCommand
  39. {
  40. get;
  41. private set;
  42. }
  43. public ICommand RecipeSelectCommand
  44. {
  45. get;
  46. private set;
  47. }
  48. public ICommand RecipeRunCommand
  49. {
  50. get;
  51. private set;
  52. }
  53. public ICommand RecipeSkipToNextCommand
  54. {
  55. get;
  56. private set;
  57. }
  58. public ICommand RecipeAbortCommand
  59. {
  60. get;
  61. private set;
  62. }
  63. public ICommand RecipeBarcodeInputChangedCommand
  64. {
  65. get;
  66. set;
  67. }
  68. public ICommand LotBarcodeInputChangedCommand
  69. {
  70. get;
  71. set;
  72. }
  73. public ICommand OperatorInputChangedCommand
  74. {
  75. get;
  76. private set;
  77. }
  78. public ICommand GetRecipeByMESCommand
  79. {
  80. get;
  81. private set;
  82. }
  83. #endregion
  84. #region Valves
  85. [Subscription(TritonDevice.ValveMfc1, SystemDeviceModule)]
  86. public AITValveData GP1Valve
  87. {
  88. get;
  89. set;
  90. }
  91. [Subscription(TritonDevice.ValveMfc2, SystemDeviceModule)]
  92. public AITValveData GP2Valve
  93. {
  94. get;
  95. set;
  96. }
  97. [Subscription(TritonDevice.ValveMfc3, SystemDeviceModule)]
  98. public AITValveData GP3Valve
  99. {
  100. get;
  101. set;
  102. }
  103. [Subscription(TritonDevice.ValveMfc4, SystemDeviceModule)]
  104. public AITValveData GP4Valve
  105. {
  106. get;
  107. set;
  108. }
  109. [Subscription(TritonDevice.ValveMfc5, SystemDeviceModule)]
  110. public AITValveData GP5Valve
  111. {
  112. get;
  113. set;
  114. }
  115. [Subscription(TritonDevice.ValveProcessGasFinal, SystemDeviceModule)]
  116. public AITValveData GasFinalValve
  117. {
  118. get;
  119. set;
  120. }
  121. [Subscription(TritonDevice.ValveChamberPurge, SystemDeviceModule)]
  122. public AITValveData ChamberPurgeValve
  123. {
  124. get;
  125. set;
  126. }
  127. [Subscription(TritonDevice.ValveChamberVent, SystemDeviceModule)]
  128. public AITValveData VentValve
  129. {
  130. get;
  131. set;
  132. }
  133. [Subscription(TritonDevice.ValveChamberPumping, SystemDeviceModule)]
  134. public AITValveData ChamberPumpingOpenValve
  135. {
  136. get;
  137. set;
  138. }
  139. [Subscription(TritonDevice.ValveChamberPumpingClose, SystemDeviceModule)]
  140. public AITValveData ChamberPumpingCloseValve
  141. {
  142. get;
  143. set;
  144. }
  145. #endregion Valves
  146. #region MFCs
  147. private AITMfcData _mfc1;
  148. [Subscription(TritonDevice.MfcGas1, SystemDeviceModule)]
  149. public AITMfcData GP1Mfc
  150. {
  151. get
  152. {
  153. return _mfc1;
  154. }
  155. set
  156. {
  157. _mfc1 = value;
  158. if (IsAutoMode)
  159. {
  160. Mfc1SetPoint = _mfc1.SetPoint.ToString("F1");
  161. InvokePropertyChanged("Mfc1SetPoint");
  162. }
  163. }
  164. }
  165. private AITMfcData _mfc2;
  166. [Subscription(TritonDevice.MfcGas2, SystemDeviceModule)]
  167. public AITMfcData GP2Mfc
  168. {
  169. get
  170. {
  171. return _mfc2;
  172. }
  173. set
  174. {
  175. _mfc2 = value;
  176. if (IsAutoMode)
  177. {
  178. Mfc2SetPoint = _mfc2.SetPoint.ToString("F1");
  179. InvokePropertyChanged("Mfc2SetPoint");
  180. }
  181. }
  182. }
  183. private AITMfcData _mfc3;
  184. [Subscription(TritonDevice.MfcGas3, SystemDeviceModule)]
  185. public AITMfcData GP3Mfc
  186. {
  187. get
  188. {
  189. return _mfc3;
  190. }
  191. set
  192. {
  193. _mfc3 = value;
  194. if (IsAutoMode)
  195. {
  196. Mfc3SetPoint = _mfc3.SetPoint.ToString("F1");
  197. InvokePropertyChanged("Mfc3SetPoint");
  198. }
  199. }
  200. }
  201. private AITMfcData _mfc4;
  202. [Subscription(TritonDevice.MfcGas4, SystemDeviceModule)]
  203. public AITMfcData GP4Mfc
  204. {
  205. get
  206. {
  207. return _mfc4;
  208. }
  209. set
  210. {
  211. _mfc4 = value;
  212. if (IsAutoMode)
  213. {
  214. Mfc4SetPoint = _mfc4.SetPoint.ToString("F1");
  215. InvokePropertyChanged("Mfc4SetPoint");
  216. }
  217. }
  218. }
  219. private AITMfcData _mfc5;
  220. [Subscription(TritonDevice.MfcGas5, SystemDeviceModule)]
  221. public AITMfcData GP5Mfc
  222. {
  223. get
  224. {
  225. return _mfc5;
  226. }
  227. set
  228. {
  229. _mfc5 = value;
  230. if (IsAutoMode)
  231. {
  232. Mfc5SetPoint = _mfc5.SetPoint.ToString("F1");
  233. InvokePropertyChanged("Mfc5SetPoint");
  234. }
  235. }
  236. }
  237. #endregion MFCs
  238. #region Pressure Meter
  239. [Subscription(TritonDevice.PressureMeterChamber, SystemDeviceModule)]
  240. public AITPressureMeterData ChamberPressure
  241. {
  242. get;
  243. set;
  244. }
  245. #endregion Pressure Meter
  246. #region Rf
  247. private AITRfData _rf;
  248. [Subscription(TritonDevice.Rf, SystemDeviceModule)]
  249. public AITRfData Rf
  250. {
  251. get
  252. {
  253. return _rf;
  254. }
  255. set
  256. {
  257. _rf = value;
  258. if (IsAutoMode)
  259. {
  260. RfPowerSetPoint = _rf.PowerSetPoint.ToString("F0");
  261. InvokePropertyChanged("RfPowerSetPoint");
  262. RfDutySetPoint = _rf.DutySetPoint.ToString("F0");
  263. InvokePropertyChanged("RfDutySetPoint");
  264. RfFrequencySetPoint = _rf.FrequencySetPoint.ToString("F0");
  265. InvokePropertyChanged("RfFrequencySetPoint");
  266. RfMatchProcessModeSetPoint = _rf.TritonMatchProcessModeDisplay;
  267. InvokePropertyChanged("RfMatchProcessModeSetPoint");
  268. RfMatchPositionC1SetPoint = _rf.MatchPositionC1SetPoint.ToString("F0");
  269. InvokePropertyChanged("RfMatchPositionC1SetPoint");
  270. RfMatchPositionC2SetPoint = _rf.MatchPositionC2SetPoint.ToString("F0");
  271. InvokePropertyChanged("RfMatchPositionC2SetPoint");
  272. RfModeSetPoint = (_rf.WorkMode == (int)RfMode.ContinuousWaveMode) ? "Continuous" : "Pulsing";
  273. InvokePropertyChanged("RfModeSetPoint");
  274. }
  275. }
  276. }
  277. #endregion Rf
  278. #region Pump
  279. [Subscription(TritonDevice.MainPump, SystemDeviceModule)]
  280. public AITPumpData Pump
  281. {
  282. get;
  283. set;
  284. }
  285. private AITBoostPumpData _boost;
  286. [Subscription(TritonDevice.BoostPump, SystemDeviceModule)]
  287. public AITBoostPumpData BoostPump
  288. {
  289. get
  290. {
  291. return _boost;
  292. }
  293. set
  294. {
  295. _boost = value;
  296. if (IsAutoMode)
  297. {
  298. BoostPumpPressureSetPoint = _boost.PressureSetPoint.ToString("F0");
  299. InvokePropertyChanged("BoostPumpPressureSetPoint");
  300. }
  301. }
  302. }
  303. private AITThrottleValveData _tv;
  304. [Subscription(TritonDevice.ThrottleValve, SystemDeviceModule)]
  305. public AITThrottleValveData Tv
  306. {
  307. get
  308. {
  309. return _tv;
  310. }
  311. set
  312. {
  313. _tv = value;
  314. if (IsAutoMode)
  315. {
  316. ThrottleValveModeSetPoint = _tv.TextMode;
  317. InvokePropertyChanged("ThrottleValveModeSetPoint");
  318. ThrottleValvePositionSetPoint = _tv.PositionSetPoint.ToString("F0");
  319. InvokePropertyChanged("ThrottleValvePositionSetPoint");
  320. ThrottleValvePressureSetPoint = _tv.PressureSetPoint.ToString("F0");
  321. InvokePropertyChanged("ThrottleValvePressureSetPoint");
  322. }
  323. }
  324. }
  325. public double TvHeight
  326. {
  327. get;
  328. set;
  329. }
  330. public Visibility TvVisible
  331. {
  332. get;
  333. set;
  334. }
  335. #endregion Pump
  336. #region Sensor
  337. [Subscription(TritonDevice.SensorBackPanelDoor, SystemDeviceModule)]
  338. public AITSensorData SensorBackPanelDoor
  339. {
  340. get;
  341. set;
  342. }
  343. [Subscription(TritonDevice.SensorChamberDoor, SystemDeviceModule)]
  344. public AITSensorData SensorChamberDoor
  345. {
  346. get;
  347. set;
  348. }
  349. [Subscription(TritonDevice.SensorPumpDoor, SystemDeviceModule)]
  350. public AITSensorData SensorPumpDoor
  351. {
  352. get;
  353. set;
  354. }
  355. public Visibility IsHaveSensorPumpDoor
  356. {
  357. get
  358. {
  359. if (SensorPumpDoor == null)
  360. {
  361. return Visibility.Collapsed;
  362. }
  363. else
  364. {
  365. return Visibility.Visible;
  366. }
  367. }
  368. }
  369. #endregion Sensor
  370. #region state data
  371. [Subscription(StateData.ProcessStatus, SystemStateModule)]
  372. public string ProcessStatus
  373. {
  374. get;
  375. set;
  376. }
  377. [Subscription(StateData.RecipeStepTimeElapsed, SystemStateModule)]
  378. public string RecipeStepTimeElapsed
  379. {
  380. get;
  381. set;
  382. }
  383. [Subscription(StateData.RecipeStepTimeSetPoint, SystemStateModule)]
  384. public string RecipeStepTimeSetPoint
  385. {
  386. get;
  387. set;
  388. }
  389. private string _recipeStepRfTimeSetPoint;
  390. [Subscription(StateData.RecipeStepRfTimeSetPoint, SystemStateModule)]
  391. public string RecipeStepRfTimeSetPoint
  392. {
  393. get
  394. {
  395. return _recipeStepRfTimeSetPoint;
  396. }
  397. set
  398. {
  399. _recipeStepRfTimeSetPoint = value;
  400. if (IsAutoMode)
  401. {
  402. RfTimeSetPoint = _recipeStepRfTimeSetPoint;
  403. InvokePropertyChanged("RfTimeSetPoint");
  404. }
  405. }
  406. }
  407. private bool _isAutoMode;
  408. private R_TRIG _trigChangeToAuto = new R_TRIG();
  409. [Subscription(StateData.IsAutoMode, SystemStateModule)]
  410. public bool IsAutoMode
  411. {
  412. get
  413. {
  414. return _isAutoMode;
  415. }
  416. set
  417. {
  418. _isAutoMode = value;
  419. _IsEnableLotScan= IsAutoMode && !IsProcessing;
  420. _trigChangeToAuto.CLK = _isAutoMode;
  421. if (_trigChangeToAuto.Q)
  422. {
  423. ThrottleValveModeSetPoint = "";
  424. InvokePropertyChanged("ThrottleValveModeSetPoint");
  425. ThrottleValvePositionSetPoint = "";
  426. InvokePropertyChanged("ThrottleValvePositionSetPoint");
  427. ThrottleValvePressureSetPoint = "";
  428. InvokePropertyChanged("ThrottleValvePressureSetPoint");
  429. BoostPumpPressureSetPoint = "";
  430. InvokePropertyChanged("BoostPumpPressureSetPoint");
  431. RfTimeSetPoint = "";
  432. InvokePropertyChanged("RfTimeSetPoint");
  433. RfModeSetPoint = "";
  434. InvokePropertyChanged("RfModeSetPoint");
  435. RfPowerSetPoint = "";
  436. InvokePropertyChanged("RfPowerSetPoint");
  437. RfFrequencySetPoint = "";
  438. InvokePropertyChanged("RfFrequencySetPoint");
  439. RfDutySetPoint = "";
  440. InvokePropertyChanged("RfDutySetPoint");
  441. RfMatchProcessModeSetPoint = "";
  442. InvokePropertyChanged("RfMatchProcessModeSetPoint");
  443. RfMatchPositionC1SetPoint = "";
  444. InvokePropertyChanged("RfMatchPositionC1SetPoint");
  445. RfMatchPositionC2SetPoint = "";
  446. InvokePropertyChanged("RfMatchPositionC2SetPoint");
  447. Mfc1SetPoint = "";
  448. InvokePropertyChanged("Mfc1SetPoint");
  449. Mfc2SetPoint = "";
  450. InvokePropertyChanged("Mfc2SetPoint");
  451. Mfc3SetPoint = "";
  452. InvokePropertyChanged("Mfc3SetPoint");
  453. Mfc4SetPoint = "";
  454. InvokePropertyChanged("Mfc4SetPoint");
  455. Mfc5SetPoint = "";
  456. InvokePropertyChanged("Mfc5SetPoint");
  457. Vapor1SetPoint = "";
  458. InvokePropertyChanged("Vapor1SetPoint");
  459. Vapor2SetPoint = "";
  460. InvokePropertyChanged("Vapor2SetPoint");
  461. ElectrodeTempSetPoint = "";
  462. InvokePropertyChanged("ElectrodeTempSetPoint");
  463. }
  464. }
  465. }
  466. public bool IsManualMode
  467. {
  468. get
  469. {
  470. return !IsAutoMode;
  471. }
  472. }
  473. public bool IsMatchPositionInputEnabled
  474. {
  475. get
  476. {
  477. if (Rf != null && RfMatchProcessModeSetPoint != "Preset")
  478. return false;
  479. return IsManualMode;
  480. }
  481. }
  482. [Subscription(StateData.RecipeStepNo, SystemStateModule)]
  483. public int RecipeStepNo
  484. {
  485. get;
  486. set;
  487. }
  488. [Subscription(StateData.RecipeProcessTime, SystemStateModule)]
  489. public string RecipeProcessTime
  490. {
  491. get;
  492. set;
  493. }
  494. [Subscription(StateData.PumpTime, SystemStateModule)]
  495. public string PumpTime
  496. {
  497. get;
  498. set;
  499. }
  500. [Subscription(StateData.PMState, SystemStateModule)]
  501. public int PMStatus
  502. {
  503. get;
  504. set;
  505. }
  506. [Subscription(StateData.IsPumpingOkForProcess, SystemStateModule)]
  507. public bool IsPumpingOkForProcess
  508. {
  509. get;
  510. set;
  511. }
  512. [Subscription(StateData.IsGasFlowingOkForProcess, SystemStateModule)]
  513. public bool IsGasFlowingOkForProcess
  514. {
  515. get;
  516. set;
  517. }
  518. [Subscription(StateData.LotName, SystemStateModule)]
  519. public string LotName
  520. {
  521. get;
  522. set;
  523. }
  524. [Subscription("System.ControlStatus")]
  525. public string HostControlStatus
  526. {
  527. get;
  528. set;
  529. }
  530. [Subscription("System.CommunicationStatus")]
  531. public string HostCommunicationStatus
  532. {
  533. get;
  534. set;
  535. }
  536. public FACommunicationState FACommunicationState
  537. {
  538. get
  539. {
  540. return string.IsNullOrEmpty(HostCommunicationStatus) ? FACommunicationState.Disabled
  541. : (FACommunicationState)Enum.Parse(typeof(FACommunicationState), HostCommunicationStatus);
  542. }
  543. }
  544. public FAControlState FAControlState
  545. {
  546. get
  547. {
  548. return string.IsNullOrEmpty(HostControlStatus) ? FAControlState.Unknown
  549. : (FAControlState)Enum.Parse(typeof(FAControlState), HostControlStatus);
  550. }
  551. }
  552. [Subscription(StateData.RecipeName, SystemStateModule)]
  553. public string CurrentRecipeName
  554. {
  555. get;
  556. set;
  557. }
  558. [Subscription(StateData.TotalCycle, SystemStateModule)]
  559. public int TotalCycle
  560. {
  561. get;
  562. set;
  563. }
  564. #endregion state data
  565. #region Display
  566. public string TvText
  567. {
  568. get
  569. {
  570. if (Tv == null || !SCLocal.PressureControlConfig.EnableThrottleValve)
  571. return "";
  572. return string.Format("{0}%", Tv.PositionFeedback.ToString("F0"));
  573. }
  574. }
  575. public string TvTextBackground
  576. {
  577. get
  578. {
  579. if (Tv == null || !SCLocal.PressureControlConfig.EnableThrottleValve)
  580. return "Transparent";
  581. if (Tv.State != 1)
  582. return "Red";
  583. return "Green";
  584. }
  585. }
  586. #endregion Display
  587. #region logic display
  588. public Visibility VisibleLoadUnload
  589. {
  590. get { return SCLocal.System.EnableFa ? Visibility.Visible : Visibility.Hidden; }
  591. }
  592. public bool IsEnableLoad
  593. {
  594. get
  595. {
  596. return IsAutoMode && (PMState)PMStatus == PMState.Idle;
  597. }
  598. }
  599. public bool IsEnableUnload
  600. {
  601. get
  602. {
  603. return IsAutoMode && (PMState)PMStatus == PMState.Idle;
  604. }
  605. }
  606. public bool IsEnableRecipeScan
  607. {
  608. get
  609. {
  610. return IsAutoMode && !IsProcessing;
  611. }
  612. }
  613. private bool _IsEnableLotScan;
  614. public bool IsEnableLotScan
  615. {
  616. get
  617. {
  618. //_IsEnableLotScan= IsAutoMode && !IsProcessing;
  619. return _IsEnableLotScan;
  620. }
  621. set {
  622. _IsEnableLotScan = value;
  623. InvokePropertyChanged("IsEnableLotScan");
  624. }
  625. }
  626. public bool IsEnableSelectRecipe
  627. {
  628. get
  629. {
  630. return IsAutoMode
  631. && !IsProcessing
  632. && !(SCLocal.System.EnableFa && FACommunicationState == FACommunicationState.EnabledCommunicating && FAControlState == FAControlState.OnlineRemote)
  633. && (!SCLocal.BarcodeConfig.EnableBarcode || SCLocal.BarcodeConfig.EnableSelectRecipeInAutoRun);
  634. }
  635. }
  636. public bool IsEnableStartRecipe
  637. {
  638. get
  639. {
  640. return IsAutoMode
  641. && !(SCLocal.System.EnableFa && FACommunicationState == FACommunicationState.EnabledCommunicating && FAControlState == FAControlState.OnlineRemote)
  642. && !string.IsNullOrEmpty(SelectedRecipeName)
  643. && !IsProcessing;
  644. }
  645. }
  646. public bool IsEnableNextStep
  647. {
  648. get
  649. {
  650. return IsAutoMode && IsProcessing;
  651. }
  652. }
  653. public bool IsEnableStopRecipe
  654. {
  655. get
  656. {
  657. return IsAutoMode && IsProcessing;
  658. }
  659. }
  660. public bool IsBarcodeEnabled
  661. {
  662. get;
  663. set;
  664. }
  665. public bool IsRfPowerOn
  666. {
  667. get
  668. {
  669. return Rf != null && Rf.IsRfOn;
  670. }
  671. }
  672. public bool SensorValue
  673. {
  674. get
  675. {
  676. return false;
  677. }
  678. }
  679. public bool IsManualButtonEnabled
  680. {
  681. get
  682. {
  683. return IsAutoMode;
  684. }
  685. }
  686. public bool IsAutoButtonEnabled
  687. {
  688. get
  689. {
  690. return !IsAutoMode;
  691. }
  692. }
  693. public bool IsPumping
  694. {
  695. get
  696. {
  697. return (PMState)PMStatus == PMState.Pumping;
  698. }
  699. }
  700. public string RecipeStepNoDisplay
  701. {
  702. get
  703. {
  704. return (PMState)PMStatus == PMState.Processing ? RecipeStepNo.ToString() : "--";
  705. }
  706. }
  707. private string _pumpButtonBackground = "CadetBlue";
  708. public string PumpButtonBackground
  709. {
  710. get
  711. {
  712. if (IsPumping)
  713. {
  714. _pumpButtonBackground = _pumpButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7";
  715. return _pumpButtonBackground;
  716. }
  717. if (IsPumpingOkForProcess)
  718. return "#00C900";
  719. return "CadetBlue";
  720. }
  721. }
  722. public bool IsGasFlowing
  723. {
  724. get
  725. {
  726. return (PMState)PMStatus == PMState.GasFlowing;
  727. }
  728. }
  729. private string _gasFlowButtonBackground = "CadetBlue";
  730. public string GasFlowButtonBackground
  731. {
  732. get
  733. {
  734. if (IsGasFlowing)
  735. {
  736. _gasFlowButtonBackground = _gasFlowButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7";
  737. return _gasFlowButtonBackground;
  738. }
  739. if (IsGasFlowingOkForProcess)
  740. return "#00C900";
  741. return "CadetBlue";
  742. }
  743. }
  744. public bool IsRfPowering
  745. {
  746. get
  747. {
  748. return (PMState)PMStatus == PMState.RfPowering;
  749. }
  750. }
  751. private string _rfPowerButtonBackground = "CadetBlue";
  752. public string RfPowerButtonBackground
  753. {
  754. get
  755. {
  756. if (IsRfPowering)
  757. {
  758. _rfPowerButtonBackground = _rfPowerButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7";
  759. return _rfPowerButtonBackground;
  760. }
  761. return "CadetBlue";
  762. }
  763. }
  764. public bool IsCyclePurging
  765. {
  766. get
  767. {
  768. return (PMState)PMStatus == PMState.CyclePurge;
  769. }
  770. }
  771. private string _cyclePurgeButtonBackground = "CadetBlue";
  772. public string CyclePurgeButtonBackground
  773. {
  774. get
  775. {
  776. if (IsCyclePurging)
  777. {
  778. _cyclePurgeButtonBackground = _cyclePurgeButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7";
  779. return _cyclePurgeButtonBackground;
  780. }
  781. return "CadetBlue";
  782. }
  783. }
  784. public bool IsVenting
  785. {
  786. get
  787. {
  788. return (PMState)PMStatus == PMState.Vent;
  789. }
  790. }
  791. private string _ventButtonBackground = "CadetBlue";
  792. public string VentButtonBackground
  793. {
  794. get
  795. {
  796. if (IsVenting)
  797. {
  798. _ventButtonBackground = _ventButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7";
  799. return _ventButtonBackground;
  800. }
  801. return "CadetBlue";
  802. }
  803. }
  804. public bool IsProcessing
  805. {
  806. get
  807. {
  808. return (PMState)PMStatus == PMState.PreProcess || (PMState)PMStatus == PMState.Processing || (PMState)PMStatus == PMState.PostProcess;
  809. }
  810. }
  811. public Visibility RfPowerOnChamberVisibility
  812. {
  813. get
  814. {
  815. return IsRfPowerOn ? Visibility.Visible : Visibility.Hidden;
  816. }
  817. }
  818. public Visibility BoostPumpVisibility
  819. {
  820. get;
  821. set;
  822. }
  823. public bool IsRfPowerOnEnabled
  824. {
  825. get
  826. {
  827. return !IsRfPowerOn;
  828. }
  829. }
  830. public bool IsRfPowerOffEnabled
  831. {
  832. get
  833. {
  834. return IsRfPowerOn;
  835. }
  836. }
  837. public SolidColorBrush ChamberDoorColor
  838. {
  839. get
  840. {
  841. return SensorChamberDoor != null && SensorChamberDoor.Value ? Brushes.Lime : Brushes.Gray;
  842. }
  843. }
  844. public SolidColorBrush PumpDoorColor
  845. {
  846. get
  847. {
  848. return SensorPumpDoor != null && SensorPumpDoor.Value ? Brushes.Lime : Brushes.Gray;
  849. }
  850. }
  851. public SolidColorBrush BackpanelDoorColor
  852. {
  853. get
  854. {
  855. return SensorBackPanelDoor != null && SensorBackPanelDoor.Value ? Brushes.Lime : Brushes.Gray;
  856. }
  857. }
  858. public string ChamberStatus
  859. {
  860. get
  861. {
  862. return string.Format("{0} : {1}", Application.Current.Resources["GlobalLableChamberStatus"], ((PMState)PMStatus));
  863. }
  864. }
  865. public Brush ChamberStatusBkColor
  866. {
  867. get
  868. {
  869. switch ((PMState)PMStatus)
  870. {
  871. case PMState.Error:
  872. return Brushes.Red;
  873. case PMState.Idle:
  874. return Brushes.Blue;
  875. default:
  876. return Brushes.LightGreen;
  877. }
  878. //return Brushes.Transparent;
  879. }
  880. }
  881. public Brush ChamberStatusForeColor
  882. {
  883. get
  884. {
  885. if (true)
  886. return Brushes.Black;
  887. //else if (false)
  888. // return Brushes.LightGreen;
  889. //return Brushes.Red;
  890. }
  891. }
  892. public double RfReflectPower
  893. {
  894. get;
  895. set;
  896. }
  897. public double RfForwardPower
  898. {
  899. get;
  900. set;
  901. }
  902. public object[] RfPowerOnCommandParameter
  903. {
  904. get
  905. {
  906. return new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPowerOnOff.ToString(), "true" };
  907. }
  908. }
  909. public object[] RfPowerOffCommandParameter
  910. {
  911. get
  912. {
  913. return new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPowerOnOff.ToString(), "false" };
  914. }
  915. }
  916. public double LotBarcodeHeight
  917. {
  918. get
  919. {
  920. return IsBarcodeEnabled ? 35 : 0;
  921. }
  922. }
  923. public double DataLogHeight
  924. {
  925. get
  926. {
  927. return IsBarcodeEnabled ? (SCLocal.System.EnableFa ? 35 : 0) : 35;
  928. }
  929. }
  930. public double RecipeBarcodeHeight
  931. {
  932. get
  933. {
  934. return IsBarcodeEnabled ? 35 : 0;
  935. }
  936. }
  937. //public string Barcode1
  938. //{
  939. // get
  940. // {
  941. // if (string.IsNullOrEmpty(LotBarcodeInputText))
  942. // return "";
  943. // var value = LotBarcodeInputText.Split('/');
  944. // if (value.Length > 0)
  945. // return value[0];
  946. // return "";
  947. // }
  948. //}
  949. //public string Barcode2
  950. //{
  951. // get
  952. // {
  953. // if (string.IsNullOrEmpty(LotBarcodeInputText))
  954. // return "";
  955. // var value = LotBarcodeInputText.Split('/');
  956. // if (value.Length > 1)
  957. // return value[1];
  958. // return "";
  959. // }
  960. //}
  961. //public string Barcode3
  962. //{
  963. // get
  964. // {
  965. // if (string.IsNullOrEmpty(LotBarcodeInputText))
  966. // return "";
  967. // var value = LotBarcodeInputText.Split('/');
  968. // if (value.Length > 2)
  969. // return value[2];
  970. // return "";
  971. // }
  972. //}
  973. //public string Barcode4
  974. //{
  975. // get
  976. // {
  977. // if (string.IsNullOrEmpty(LotBarcodeInputText))
  978. // return "";
  979. // var value = LotBarcodeInputText.Split('/');
  980. // if (value.Length > 3)
  981. // return value[3];
  982. // return "";
  983. // }
  984. //}
  985. //public string Barcode5
  986. //{
  987. // get
  988. // {
  989. // if (string.IsNullOrEmpty(LotBarcodeInputText))
  990. // return "";
  991. // var value = LotBarcodeInputText.Split('/');
  992. // if (value.Length > 4)
  993. // return value[4];
  994. // return "";
  995. // }
  996. //}
  997. //public string Barcode6
  998. //{
  999. // get
  1000. // {
  1001. // if (string.IsNullOrEmpty(LotBarcodeInputText))
  1002. // return "";
  1003. // var value = LotBarcodeInputText.Split('/');
  1004. // if (value.Length > 5)
  1005. // return value[5];
  1006. // return "";
  1007. // }
  1008. //}
  1009. public string OperatorInputText
  1010. {
  1011. get;
  1012. set;
  1013. }
  1014. private ObservableCollection<string> m_Barcodes = new ObservableCollection<string>();
  1015. //
  1016. public ObservableCollection<string> Barcodes
  1017. {
  1018. get
  1019. {
  1020. return m_Barcodes;
  1021. }
  1022. set
  1023. {
  1024. m_Barcodes = value;
  1025. }
  1026. }
  1027. public string RecipeBarcodeInputText
  1028. {
  1029. get;
  1030. set;
  1031. }
  1032. public int RecipeBarcodeLength
  1033. {
  1034. get;
  1035. set;
  1036. }
  1037. public string LotBarcodeInputText
  1038. {
  1039. get;
  1040. set;
  1041. }
  1042. public int LotBarcodeLength
  1043. {
  1044. get;
  1045. set;
  1046. }
  1047. public int LotBarcodeMaxCount
  1048. {
  1049. get;
  1050. set;
  1051. }
  1052. #endregion logic display
  1053. #region setpoint
  1054. [IgnorePropertyChange]
  1055. public string BasePressureSetPoint
  1056. {
  1057. get;
  1058. set;
  1059. }
  1060. [IgnorePropertyChange]
  1061. public string PumpLimitSetPoint
  1062. {
  1063. get;
  1064. set;
  1065. }
  1066. [IgnorePropertyChange]
  1067. public string ThrottleValveModeSetPoint
  1068. {
  1069. get;
  1070. set;
  1071. }
  1072. [IgnorePropertyChange]
  1073. public string ThrottleValvePositionSetPoint
  1074. {
  1075. get;
  1076. set;
  1077. }
  1078. [IgnorePropertyChange]
  1079. public string ThrottleValvePressureSetPoint
  1080. {
  1081. get;
  1082. set;
  1083. }
  1084. [IgnorePropertyChange]
  1085. public string BoostPumpPressureSetPoint
  1086. {
  1087. get;
  1088. set;
  1089. }
  1090. [IgnorePropertyChange]
  1091. public string RfTimeSetPoint
  1092. {
  1093. get;
  1094. set;
  1095. }
  1096. [IgnorePropertyChange]
  1097. public string RfMatchProcessModeSetPoint
  1098. {
  1099. get;
  1100. set;
  1101. }
  1102. private string _rfModeSetPoint;
  1103. [IgnorePropertyChange]
  1104. public string RfModeSetPoint
  1105. {
  1106. get
  1107. {
  1108. return _rfModeSetPoint;
  1109. }
  1110. set
  1111. {
  1112. _rfModeSetPoint = value;
  1113. }
  1114. }
  1115. [IgnorePropertyChange]
  1116. public string RfPowerSetPoint
  1117. {
  1118. get;
  1119. set;
  1120. }
  1121. [IgnorePropertyChange]
  1122. public string RfFrequencySetPoint
  1123. {
  1124. get;
  1125. set;
  1126. }
  1127. [IgnorePropertyChange]
  1128. public string RfDutySetPoint
  1129. {
  1130. get;
  1131. set;
  1132. }
  1133. [IgnorePropertyChange]
  1134. public string RfMatchPositionC1SetPoint
  1135. {
  1136. get;
  1137. set;
  1138. }
  1139. [IgnorePropertyChange]
  1140. public string RfMatchPositionC2SetPoint
  1141. {
  1142. get;
  1143. set;
  1144. }
  1145. [IgnorePropertyChange]
  1146. public string Mfc1SetPoint
  1147. {
  1148. get;
  1149. set;
  1150. }
  1151. [IgnorePropertyChange]
  1152. public string Mfc2SetPoint
  1153. {
  1154. get;
  1155. set;
  1156. }
  1157. [IgnorePropertyChange]
  1158. public string Mfc3SetPoint
  1159. {
  1160. get;
  1161. set;
  1162. }
  1163. [IgnorePropertyChange]
  1164. public string Mfc4SetPoint
  1165. {
  1166. get;
  1167. set;
  1168. }
  1169. [IgnorePropertyChange]
  1170. public string Mfc5SetPoint
  1171. {
  1172. get;
  1173. set;
  1174. }
  1175. [IgnorePropertyChange]
  1176. public string Vapor1SetPoint
  1177. {
  1178. get;
  1179. set;
  1180. }
  1181. [IgnorePropertyChange]
  1182. public string Vapor2SetPoint
  1183. {
  1184. get;
  1185. set;
  1186. }
  1187. [IgnorePropertyChange]
  1188. public string ElectrodeTempSetPoint
  1189. {
  1190. get;
  1191. set;
  1192. }
  1193. [IgnorePropertyChange]
  1194. //public string SelectedRecipeName { get; set; }
  1195. private string _rcpName;
  1196. //private DeviceTimer _timer = new DeviceTimer();
  1197. private Timer _timer = new Timer(10000);
  1198. public string SelectedRecipeName
  1199. {
  1200. get { return _rcpName; }
  1201. set
  1202. {
  1203. _rcpName = value;
  1204. InvokePropertyChanged("SelectedRecipeName");
  1205. if (!string.IsNullOrWhiteSpace(_rcpName))
  1206. {
  1207. _timer.Start();
  1208. }
  1209. }
  1210. }
  1211. public string SelectedOperation = "";
  1212. #endregion setpoint
  1213. #region recipe
  1214. //public string RecipeStatus
  1215. //{
  1216. // get
  1217. // {
  1218. // if ((PMState)PMStatus == PMState.PreProcess)
  1219. // return "Pumping down";
  1220. // if ((PMState)PMStatus == PMState.Processing)
  1221. // return "Running";
  1222. // if ((PMState)PMStatus == PMState.PostProcess)
  1223. // return "Cycle Purge";
  1224. // return "";
  1225. // }
  1226. //}
  1227. public string RecipeStatusBackground
  1228. {
  1229. get
  1230. {
  1231. return IsProcessing ? "Green" : "Blue";
  1232. }
  1233. }
  1234. #endregion recipe
  1235. #region config
  1236. public double GP1Height
  1237. {
  1238. get;
  1239. set;
  1240. }
  1241. public double GP2Height
  1242. {
  1243. get;
  1244. set;
  1245. }
  1246. public double GP3Height
  1247. {
  1248. get;
  1249. set;
  1250. }
  1251. public double GP4Height
  1252. {
  1253. get;
  1254. set;
  1255. }
  1256. public double GP5Height
  1257. {
  1258. get;
  1259. set;
  1260. }
  1261. public Visibility GP1Visible
  1262. {
  1263. get;
  1264. set;
  1265. }
  1266. public Visibility GP2Visible
  1267. {
  1268. get;
  1269. set;
  1270. }
  1271. public Visibility GP3Visible
  1272. {
  1273. get;
  1274. set;
  1275. }
  1276. public Visibility GP4Visible
  1277. {
  1278. get;
  1279. set;
  1280. }
  1281. public Visibility GP5Visible
  1282. {
  1283. get;
  1284. set;
  1285. }
  1286. public double RFPulsingHeight
  1287. {
  1288. get;
  1289. set;
  1290. }
  1291. public double BoostPumpHeight
  1292. {
  1293. get;
  1294. set;
  1295. }
  1296. public ObservableCollection<string> RFModeItems
  1297. {
  1298. get;
  1299. set;
  1300. }
  1301. public bool IsRFModeSelectable
  1302. {
  1303. get;
  1304. set;
  1305. }
  1306. public bool IsFullControlPermission
  1307. {
  1308. get;
  1309. set;
  1310. }
  1311. public bool EnableDeviceControl
  1312. {
  1313. get
  1314. {
  1315. return SCLocal.System.IsTestMode;
  1316. }
  1317. }
  1318. public bool EnableWaterFlowAlarm
  1319. {
  1320. get
  1321. {
  1322. return !bSetWaterFlowAlarm;
  1323. }
  1324. }
  1325. public bool DisenableWaterFlowAlarm
  1326. {
  1327. get
  1328. {
  1329. return !EnableWaterFlowAlarm;
  1330. }
  1331. }
  1332. #endregion config
  1333. private bool m_IsAuto;
  1334. public bool IsAuto
  1335. {
  1336. get { return m_IsAuto; }
  1337. set
  1338. {
  1339. m_IsAuto = value;
  1340. }
  1341. }
  1342. private bool m_enableManualSelectRecipe;
  1343. public bool EnableManualSelectRecipe
  1344. {
  1345. get { return m_enableManualSelectRecipe; }
  1346. set
  1347. {
  1348. m_enableManualSelectRecipe = value;
  1349. }
  1350. }
  1351. private bool bSetWaterFlowAlarm = false;
  1352. private List<string> _keys = new List<string>();
  1353. private R_TRIG _trigRecipeFinished = new R_TRIG();
  1354. private HzOverviewView _hzOverviewView;
  1355. FabAutoComm _fabAutoComm;
  1356. string[] barcodes;
  1357. string userID;
  1358. private Timer monitorEndTimer = new Timer(5000);
  1359. List<ResponseRecipe> LotsReceipeInfo;
  1360. public OverviewViewModel(HzOverviewView hzOverviewView)
  1361. : base("OverviewViewModel")
  1362. {
  1363. DeviceOperationCommand = new DelegateCommand<object>(DeviceOperation);
  1364. InvokeCommand = new DelegateCommand<object>(Invoke);
  1365. RecipeSelectCommand = new DelegateCommand<object>(SelectRecipe);
  1366. RecipeRunCommand = new DelegateCommand<object>(RunRecipe);
  1367. RecipeSkipToNextCommand = new DelegateCommand<object>(SkipRecipe);
  1368. RecipeAbortCommand = new DelegateCommand<object>(AbortRecipe);
  1369. RecipeBarcodeInputChangedCommand = new DelegateCommand<object>(RecipeBarcodeInputChanged);
  1370. LotBarcodeInputChangedCommand = new DelegateCommand<object>(LotBarcodeInputChanged);
  1371. OperatorInputChangedCommand = new DelegateCommand<object>(OperatorInputChanged);
  1372. GetRecipeByMESCommand = new DelegateCommand<object>(GetRecipeByMES);
  1373. BasePressureSetPoint = ((float)(double)Triton160UiSystem.Instance.WCF.Query.GetConfig(SCName.System_PumpBasePressure)).ToString();
  1374. PumpLimitSetPoint = ((float)(double)Triton160UiSystem.Instance.WCF.Query.GetConfig(SCName.System_PumpTimeLimit)).ToString();
  1375. bSetWaterFlowAlarm = false;
  1376. SCLocal.RetrieveAll();
  1377. AITThrottleValveData tv =
  1378. (AITThrottleValveData)Triton160UiSystem.Instance.WCF.Query.GetData("Device.System.ThrottleValve");
  1379. AITRfData rf = (AITRfData)Triton160UiSystem.Instance.WCF.Query.GetData("Device.System.Rf");
  1380. RFModeItems = new ObservableCollection<string>();
  1381. RFModeItems.Add("Continuous");
  1382. if (tv != null)
  1383. {
  1384. ThrottleValveModeSetPoint = tv.TextMode;
  1385. }
  1386. if (rf != null)
  1387. {
  1388. RfModeSetPoint = rf.TextWorkMode;
  1389. InvokePropertyChanged("RfModeSetPoint");
  1390. RfMatchProcessModeSetPoint = rf.TritonMatchProcessModeDisplay;
  1391. InvokePropertyChanged("RfMatchProcessModeSetPoint");
  1392. }
  1393. _hzOverviewView = hzOverviewView;
  1394. GlobalObserver.Instance.OnIsAutoRaiseCahnged += Instance_OnIsAutoRaiseCahnged;
  1395. monitorEndTimer.Elapsed += MonitorEndTimer_Elapsed;
  1396. monitorEndTimer.Enabled = false;
  1397. //switch (WcfClient.Instance.Query.GetConfig(SCName.System_Company))
  1398. //{
  1399. // case 0:
  1400. // _fabAutoComm = new JCFabAuto();
  1401. // var recipeName = _fabAutoComm.GetRecipeByLot();
  1402. // AutoGetRecipe(recipeName);
  1403. // break;
  1404. //}
  1405. var company = WcfClient.Instance.Query.GetConfig(SCName.System_Company);
  1406. _fabAutoComm = tnt.SelectFab((Fab)Enum.Parse(typeof(Fab), company.ToString()));
  1407. EnableManualSelectRecipe =(bool) WcfClient.Instance.Query.GetConfig(SCName.BarcodeConfig_EnableSelectRecipeInAutoRun);
  1408. }
  1409. private void MonitorEndTimer_Elapsed(object sender, ElapsedEventArgs e)
  1410. {
  1411. if (ProcessStatus == "recipe completed" || ProcessStatus == "工艺完成")
  1412. {
  1413. _fabAutoComm.CheckOut();
  1414. monitorEndTimer.Enabled = false;
  1415. }
  1416. }
  1417. private void Instance_OnIsAutoRaiseCahnged(bool isAuto)
  1418. {
  1419. IsAuto = isAuto;
  1420. }
  1421. //private void Timer_Elapsed(object sender, ElapsedEventArgs e)
  1422. //{
  1423. // _timer.Stop();
  1424. // MessageBox.Show("是否开始工艺?");
  1425. //}
  1426. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  1427. {
  1428. UpdateAllConfig();
  1429. GP1Visible = SCLocal.GasLineConfig.Gas1Enable ? Visibility.Visible : Visibility.Hidden;
  1430. GP1Height = SCLocal.GasLineConfig.Gas1Enable ? 26 : 0;
  1431. GP2Visible = SCLocal.GasLineConfig.Gas2Enable ? Visibility.Visible : Visibility.Hidden;
  1432. GP2Height = SCLocal.GasLineConfig.Gas2Enable ? 26 : 0;
  1433. GP3Visible = SCLocal.GasLineConfig.Gas3Enable ? Visibility.Visible : Visibility.Hidden;
  1434. GP3Height = SCLocal.GasLineConfig.Gas3Enable ? 26 : 0;
  1435. GP4Visible = SCLocal.GasLineConfig.Gas4Enable ? Visibility.Visible : Visibility.Hidden;
  1436. GP4Height = SCLocal.GasLineConfig.Gas4Enable ? 26 : 0;
  1437. GP5Visible = SCLocal.GasLineConfig.Gas5Enable ? Visibility.Visible : Visibility.Hidden;
  1438. GP5Height = SCLocal.GasLineConfig.Gas5Enable ? 26 : 0;
  1439. BoostPumpVisibility = SCLocal.PressureControlConfig.EnableBoosterPump ? Visibility.Visible : Visibility.Hidden;
  1440. BoostPumpHeight = (BoostPumpVisibility == Visibility.Visible) ? 26 : 0;
  1441. IsBarcodeEnabled = SCLocal.BarcodeConfig.EnableBarcode;
  1442. LotBarcodeLength = SCLocal.BarcodeConfig.MaxLotInputBarcodeLength;
  1443. LotBarcodeMaxCount = SCLocal.BarcodeConfig.MaxLotBarcodeCount;
  1444. RecipeBarcodeLength = SCLocal.BarcodeConfig.MaxRecipeInputBarcodeLength;
  1445. TvVisible = SCLocal.PressureControlConfig.EnableThrottleValve ? Visibility.Visible : Visibility.Hidden;
  1446. TvHeight = (SCLocal.PressureControlConfig.EnableThrottleValve) ? 26 : 0;
  1447. Application.Current.Dispatcher.Invoke(new Action(() =>
  1448. {
  1449. RFPulsingHeight = SCLocal.RfConfig.EnablePulsingFunction ? 26 : 0;
  1450. if (SCLocal.RfConfig.EnablePulsingFunction != RFModeItems.Contains("Pulsing"))
  1451. {
  1452. if (SCLocal.RfConfig.EnablePulsingFunction)
  1453. {
  1454. RFModeItems.Add("Pulsing");
  1455. }
  1456. else
  1457. {
  1458. RFModeItems.Remove("Pulsing");
  1459. }
  1460. }
  1461. if (!SCLocal.RfConfig.EnablePulsingFunction)
  1462. {
  1463. RfModeSetPoint = "Continuous";
  1464. InvokePropertyChanged("RfModeSetPoint");
  1465. }
  1466. if (SCLocal.System.EnableFa && FAControlState == FAControlState.OnlineRemote)
  1467. {
  1468. SelectedRecipeName = CurrentRecipeName;
  1469. InvokePropertyChanged("SelectedRecipeName");
  1470. }
  1471. }));
  1472. IsRFModeSelectable = SCLocal.RfConfig.EnablePulsingFunction && IsManualMode;
  1473. _trigRecipeFinished.CLK = !IsProcessing;
  1474. if (_trigRecipeFinished.Q)
  1475. {
  1476. SelectedRecipeName = "";
  1477. RecipeBarcodeInputText = "";
  1478. LotBarcodeInputText = "";
  1479. Application.Current.Dispatcher.Invoke(new Action(() =>
  1480. {
  1481. InvokePropertyChanged("SelectedRecipeName");
  1482. InvokePropertyChanged("RecipeBarcodeInputText");
  1483. InvokePropertyChanged("LotBarcodeInputText");
  1484. }));
  1485. }
  1486. }
  1487. //device, operation, parameters
  1488. void DeviceOperation(object param)
  1489. {
  1490. object[] op = (object[])param;
  1491. Debug.Assert(op.Length >= 2);
  1492. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), op);
  1493. }
  1494. void Invoke(object param)
  1495. {
  1496. string[] p = param.ToString().Split(',');
  1497. if (p.Length == 1)
  1498. {
  1499. if (p[0] == "Pump")
  1500. {
  1501. DoPump();
  1502. return;
  1503. }
  1504. if (p[0] == "GasFlow")
  1505. {
  1506. DoGasFlow();
  1507. return;
  1508. }
  1509. if (p[0] == "RfPower")
  1510. {
  1511. DoRfPower();
  1512. return;
  1513. }
  1514. if (p[0] == "CyclePurge")
  1515. {
  1516. DoCyclePurge();
  1517. return;
  1518. }
  1519. if (p[0] == "Vent")
  1520. {
  1521. DoVent();
  1522. return;
  1523. }
  1524. if (p[0] == "ResetWaterFlowAlarm")
  1525. {
  1526. DoResetWaterFlowAlarm();
  1527. bSetWaterFlowAlarm = true;
  1528. return;
  1529. }
  1530. if (p[0] == "SetWaterFlowAlarm")
  1531. {
  1532. DoSetWaterFlowAlarm();
  1533. bSetWaterFlowAlarm = false;
  1534. return;
  1535. }
  1536. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(p[0]);
  1537. }
  1538. }
  1539. private void DoGasFlow()
  1540. {
  1541. if (IsGasFlowing)
  1542. {
  1543. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString());
  1544. return;
  1545. }
  1546. if (IsGasFlowingOkForProcess)
  1547. {
  1548. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.StopGasFlow.ToString());
  1549. return;
  1550. }
  1551. if (Tv != null && SCLocal.PressureControlConfig.EnableThrottleValve && SCLocal.PressureControlConfig.IsIndependentControl)
  1552. {
  1553. PressureCtrlMode mode;
  1554. if (ThrottleValveModeSetPoint == "Pressure")
  1555. mode = PressureCtrlMode.TVPressureCtrl;
  1556. else if (ThrottleValveModeSetPoint == "Position")
  1557. mode = PressureCtrlMode.TVPositionCtrl;
  1558. else
  1559. {
  1560. MessageBox.Show(string.Format(Resources.OverviewViewModel_DoGasFlow_PressureControlMode0IsNotValidShouldSelectFirst,
  1561. ThrottleValveModeSetPoint));
  1562. return;
  1563. }
  1564. double pressure = Convert.ToDouble(string.IsNullOrEmpty(ThrottleValvePressureSetPoint) ? "0.0" : ThrottleValvePressureSetPoint);
  1565. double position = Convert.ToDouble(string.IsNullOrEmpty(ThrottleValvePositionSetPoint) ? "0.0" : ThrottleValvePositionSetPoint);
  1566. if (mode == PressureCtrlMode.TVPressureCtrl)
  1567. {
  1568. if (string.IsNullOrEmpty(ThrottleValvePressureSetPoint) || pressure < 0 || pressure > 756000)
  1569. {
  1570. MessageBox.Show(string.Format(Resources.OverviewViewModel_DoGasFlow_Pressure0IsNotValidShouldBeIn0And756000,
  1571. ThrottleValvePressureSetPoint));
  1572. return;
  1573. }
  1574. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(),
  1575. new object[]
  1576. {
  1577. TritonDevice.ThrottleValve.ToString(), AITThrottleValveOperation.SetMode.ToString(),
  1578. mode.ToString()
  1579. });
  1580. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(),
  1581. new object[]
  1582. {
  1583. TritonDevice.ThrottleValve.ToString(), AITThrottleValveOperation.SetPressure.ToString(),
  1584. pressure.ToString()
  1585. });
  1586. }
  1587. else if (mode == PressureCtrlMode.TVPositionCtrl)
  1588. {
  1589. if (string.IsNullOrEmpty(ThrottleValvePositionSetPoint) || position < 0 || position > 100)
  1590. {
  1591. MessageBox.Show(string.Format(Resources.OverviewViewModel_DoGasFlow_Position0IsNotValidShouldBeIn0And100,
  1592. ThrottleValvePositionSetPoint));
  1593. return;
  1594. }
  1595. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(),
  1596. new object[]
  1597. {
  1598. TritonDevice.ThrottleValve.ToString(), AITThrottleValveOperation.SetMode.ToString(),
  1599. mode.ToString()
  1600. });
  1601. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(),
  1602. new object[]
  1603. {
  1604. TritonDevice.ThrottleValve.ToString(), AITThrottleValveOperation.SetPosition.ToString(),
  1605. position.ToString()
  1606. });
  1607. }
  1608. }
  1609. object[] mfc = new[]
  1610. {
  1611. (object)Convert.ToDouble(string.IsNullOrEmpty(Mfc1SetPoint) ? "0.0" : Mfc1SetPoint),
  1612. Convert.ToDouble(string.IsNullOrEmpty(Mfc2SetPoint) ? "0.0" : Mfc2SetPoint),
  1613. Convert.ToDouble(string.IsNullOrEmpty(Mfc3SetPoint) ? "0.0" : Mfc3SetPoint),
  1614. Convert.ToDouble(string.IsNullOrEmpty(Mfc4SetPoint) ? "0.0" : Mfc4SetPoint),
  1615. Convert.ToDouble(string.IsNullOrEmpty(Mfc5SetPoint) ? "0.0" : Mfc5SetPoint),
  1616. Convert.ToDouble(string.IsNullOrEmpty(Vapor1SetPoint) ? "0.0" : Vapor1SetPoint),
  1617. };
  1618. if (!Array.Exists(mfc, x => (double)x > 0))
  1619. {
  1620. MessageBox.Show(string.Format(Resources.OverviewViewModel_DoGasFlow_SetFlowValueBeforeFlowingGas));
  1621. return;
  1622. }
  1623. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.GasFlow.ToString(), mfc);
  1624. }
  1625. #region rf power
  1626. private void DoRfPower()
  1627. {
  1628. if (IsRfPowering)
  1629. {
  1630. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString());
  1631. return;
  1632. }
  1633. List<string> errors = new List<string>();
  1634. double power = Convert.ToDouble(RfPowerSetPoint);
  1635. double frequency = Convert.ToDouble(RfFrequencySetPoint);
  1636. double duty = Convert.ToDouble(RfDutySetPoint);
  1637. double c1 = Convert.ToDouble(RfMatchPositionC1SetPoint);
  1638. double c2 = Convert.ToDouble(RfMatchPositionC2SetPoint);
  1639. //检查输入有效性
  1640. RfMode rfMode = RfMode.ContinuousWaveMode;
  1641. if (RfModeSetPoint == "Continuous")
  1642. rfMode = RfMode.ContinuousWaveMode;
  1643. else if (RfModeSetPoint == "Pulsing")
  1644. rfMode = RfMode.PulsingMode;
  1645. else
  1646. {
  1647. errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_RFControlMode0IsNotValidShouldSelectFirst, RfModeSetPoint));
  1648. }
  1649. RfMatchModeProcess processMode = RfMatchModeProcess.PresetMode;
  1650. if (RfMatchProcessModeSetPoint == "Preset")
  1651. processMode = RfMatchModeProcess.PresetMode;
  1652. else if (RfMatchProcessModeSetPoint == "Hold")
  1653. processMode = RfMatchModeProcess.HoldMode;
  1654. else
  1655. {
  1656. errors.Add(string.Format("RF match preset mode {0} is not valid", RfMatchProcessModeSetPoint));
  1657. }
  1658. double rfTime = Double.TryParse(RfTimeSetPoint, out rfTime) ? rfTime : 0.0;
  1659. if (string.IsNullOrEmpty(RfTimeSetPoint) || rfTime <= 0)
  1660. {
  1661. errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_RFPowerOnTime0NotValid, RfTimeSetPoint));
  1662. }
  1663. if (string.IsNullOrEmpty(RfPowerSetPoint) || power < 0 || power > Rf.ScalePower)
  1664. {
  1665. errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_Power0IsNotValidShouldBeIn0And1, RfPowerSetPoint, Rf.ScalePower));
  1666. }
  1667. if (rfMode == RfMode.PulsingMode)
  1668. {
  1669. if (string.IsNullOrEmpty(RfFrequencySetPoint) || frequency < 0 || frequency > 1000)
  1670. {
  1671. errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_Frequency0IsNotValidShouldBeIn0And1000, RfFrequencySetPoint));
  1672. }
  1673. if (string.IsNullOrEmpty(RfDutySetPoint) || duty < 0 || duty > 100)
  1674. {
  1675. errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_Duty0IsNotValidShouldBeIn0And100, RfDutySetPoint));
  1676. }
  1677. }
  1678. if (SCLocal.RfConfig.EnableC1C2Position && (processMode == RfMatchModeProcess.HoldMode))
  1679. {
  1680. if (string.IsNullOrEmpty(RfMatchPositionC1SetPoint) || c1 < 0 || c1 > 100)
  1681. {
  1682. errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_RFMatchPositionC1Value0IsNotValueShouldBeIn0100, RfMatchPositionC1SetPoint));
  1683. }
  1684. if (string.IsNullOrEmpty(RfMatchPositionC2SetPoint) || c2 < 0 || c2 > 100)
  1685. {
  1686. errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_RFMatchPositionC2Value0IsNotValueShouldBeIn0100, RfMatchPositionC2SetPoint));
  1687. }
  1688. }
  1689. if (errors.Count > 0)
  1690. {
  1691. MessageBox.Show(string.Join("\r\n", errors));
  1692. return;
  1693. }
  1694. //RF 操作
  1695. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMode.ToString(), rfMode.ToString() });
  1696. if (rfMode == RfMode.ContinuousWaveMode)
  1697. {
  1698. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetContinuousPower.ToString(), power.ToString() });
  1699. }
  1700. else if (rfMode == RfMode.PulsingMode)
  1701. {
  1702. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPulsingPower.ToString(), power.ToString(), frequency.ToString(), duty.ToString() });
  1703. }
  1704. if (processMode == RfMatchModeProcess.PresetMode)
  1705. {
  1706. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchProcessMode.ToString(), (int)RfMatchModeProcess.PresetMode });
  1707. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC1.ToString(), c1.ToString() });
  1708. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC2.ToString(), c2.ToString() });
  1709. }
  1710. else
  1711. {
  1712. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchProcessMode.ToString(), (int)RfMatchModeProcess.HoldMode });
  1713. }
  1714. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.RfPower.ToString(), rfTime);
  1715. }
  1716. #endregion rf power
  1717. #region cycle purge
  1718. private void DoCyclePurge()
  1719. {
  1720. if (IsCyclePurging)
  1721. {
  1722. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString());
  1723. return;
  1724. }
  1725. if (IsRfPowering)
  1726. {
  1727. MessageBox.Show(Resources.OverviewViewModel_DoCyclePurge_RFOnCanNotPurge);
  1728. return;
  1729. }
  1730. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Purge.ToString());
  1731. }
  1732. #endregion cycle purge
  1733. #region vent
  1734. private void DoVent()
  1735. {
  1736. if (IsVenting)
  1737. {
  1738. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString());
  1739. return;
  1740. }
  1741. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Vent.ToString());
  1742. }
  1743. #endregion vent
  1744. private void DoResetWaterFlowAlarm()
  1745. {
  1746. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.WaterFlowAlarm.ToString(), false);
  1747. }
  1748. private void DoSetWaterFlowAlarm()
  1749. {
  1750. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.WaterFlowAlarm.ToString(), true);
  1751. }
  1752. #region pump
  1753. private void DoPump()
  1754. {
  1755. if (IsPumping)
  1756. {
  1757. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString());
  1758. return;
  1759. }
  1760. if (IsPumpingOkForProcess)
  1761. {
  1762. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.StopPump.ToString());
  1763. return;
  1764. }
  1765. // 底压设置
  1766. double basePressure = string.IsNullOrEmpty(BasePressureSetPoint) ? 0 : Convert.ToDouble(BasePressureSetPoint);
  1767. if (basePressure <= 0.01 || basePressure >= 1000)
  1768. {
  1769. MessageBox.Show(string.Format(Resources.OverviewViewModel_DoPump_BasePressure0IsNotValidShouldBeIn0And1000, basePressure));
  1770. return;
  1771. }
  1772. // 抽气时间设置
  1773. double pumpLimit = string.IsNullOrEmpty(PumpLimitSetPoint) ? 0 : Convert.ToDouble(PumpLimitSetPoint);
  1774. if (pumpLimit <= 0.01 || pumpLimit >= 1200)
  1775. {
  1776. MessageBox.Show(string.Format(Resources.OverviewViewModel_DoPump_PumpLimitPressure0IsNotValidShouldBeIn0And1000, pumpLimit));
  1777. return;
  1778. }
  1779. //
  1780. if (BoostPump != null && SCLocal.PressureControlConfig.EnableBoosterPump && SCLocal.PressureControlConfig.IsIndependentControl)
  1781. {
  1782. double pressure = Convert.ToDouble(BoostPumpPressureSetPoint);
  1783. if (string.IsNullOrEmpty(BoostPumpPressureSetPoint) || pressure < 0 || pressure > 1000)
  1784. {
  1785. MessageBox.Show(string.Format(Resources.OverviewViewModel_DoPump_Pressure0IsNotValidShouldBeIn0And1000, BoostPumpPressureSetPoint));
  1786. return;
  1787. }
  1788. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(),
  1789. new object[] { TritonDevice.BoostPump.ToString(), AITBoostPumpOperation.SetPressure.ToString(), pressure.ToString() });
  1790. }
  1791. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), "System_PumpBasePressure", basePressure);
  1792. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), "System_PumpTimeLimit", pumpLimit);
  1793. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Pump.ToString());
  1794. }
  1795. #endregion pump
  1796. #region recipe
  1797. private void SelectRecipe(object param)
  1798. {
  1799. RecipeSelectDialog dialog = new RecipeSelectDialog(WcfClient.Instance.Recipe.GetXmlRecipeList(ModuleName.System, false))
  1800. {
  1801. Owner = Application.Current.MainWindow
  1802. };
  1803. var ret = dialog.ShowDialog();
  1804. if (ret.HasValue && ret.Value)
  1805. {
  1806. SelectedRecipeName = dialog.SelectedRecipe;
  1807. RecipeBarcodeInputText = "";
  1808. InvokePropertyChanged("RecipeBarcodeInputText");
  1809. InvokePropertyChanged("SelectedRecipeName");
  1810. }
  1811. }
  1812. private void RunRecipe(object param)
  1813. {
  1814. //if (string.IsNullOrEmpty(SelectedRecipeName))
  1815. //{
  1816. // return;
  1817. //}
  1818. //LotBarcodeInputText = LotBarcodeInputText ?? "";
  1819. //WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText);
  1820. if (IsAuto == true)
  1821. {
  1822. //WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText);
  1823. //monitorEndTimer.Enabled=true;
  1824. if (string.IsNullOrEmpty(SelectedRecipeName))
  1825. {
  1826. return;
  1827. }
  1828. if (_fabAutoComm.CheckIn() == true)
  1829. {
  1830. monitorEndTimer.Enabled = true;
  1831. WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText,SelectedOperation, string.IsNullOrEmpty(OperatorInputText)?"": OperatorInputText.TrimEnd('/'));
  1832. }
  1833. else
  1834. {
  1835. WPFMessageBox.ShowError("远程CheckIn失败");
  1836. }
  1837. //if (info != null)
  1838. //{
  1839. // if (info.Success == true)
  1840. // {
  1841. // checkInInformation = info;
  1842. // monitorEndTimer.Enabled = true;
  1843. // WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText);
  1844. // }
  1845. // else
  1846. // {
  1847. // MessageBox.Show("远程CheckOut失败");
  1848. // }
  1849. //}
  1850. //else
  1851. //{
  1852. // MessageBox.Show("远程CheckIn失败");
  1853. // return;
  1854. //}
  1855. }
  1856. else
  1857. {
  1858. WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText);
  1859. }
  1860. }
  1861. private void SkipRecipe(object param)
  1862. {
  1863. if (MessageBox.Show(Resources.OverviewViewModel_SkipRecipe_SkipToNextStep, "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  1864. {
  1865. WcfClient.Instance.InvokeService_DoOperation(TritonOperation.SkipCurrentStep.ToString());
  1866. }
  1867. }
  1868. private void AbortRecipe(object param)
  1869. {
  1870. if (MessageBox.Show(Resources.OverviewViewModel_AbortRecipe_DoYouWantToStopCurrentRecipeRunning, "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  1871. WcfClient.Instance.InvokeService_DoOperation(TritonOperation.AbortRecipe.ToString());
  1872. }
  1873. #endregion recipe
  1874. #region barcode
  1875. private void RecipeBarcodeInputChanged(object param)
  1876. {
  1877. string barcode = param as string;
  1878. if (string.IsNullOrEmpty(barcode))
  1879. {
  1880. SelectedRecipeName = "";
  1881. return;
  1882. }
  1883. SelectedRecipeName = WcfClient.Instance.Recipe.GetRecipeByBarcode(ModuleName.System, barcode);
  1884. InvokePropertyChanged("SelectedRecipeName");
  1885. }
  1886. private void LotBarcodeInputChanged(object param)
  1887. {
  1888. string barcode = param as string;
  1889. //if (string.IsNullOrEmpty(barcode))
  1890. //{
  1891. // SelectedRecipeName = "";
  1892. // //return;
  1893. //}
  1894. //if (string.IsNullOrEmpty(LotBarcodeInputText))
  1895. // return "";
  1896. // var value = LotBarcodeInputText.Split('/');
  1897. // if (value.Length > 3)
  1898. // return value[3];
  1899. // return "";
  1900. LotBarcodeInputText = barcode;
  1901. //InvokePropertyChanged("Barcode1");
  1902. //InvokePropertyChanged("Barcode2");
  1903. //InvokePropertyChanged("Barcode3");
  1904. //InvokePropertyChanged("Barcode4");
  1905. //InvokePropertyChanged("Barcode5");
  1906. //InvokePropertyChanged("Barcode6");
  1907. if (barcode.Length < 11)
  1908. {
  1909. return;
  1910. }
  1911. barcodes = barcode.Split('/');
  1912. if (barcodes.Length < 2)
  1913. {
  1914. return;
  1915. }
  1916. Barcodes.Clear();
  1917. for (int i = barcodes.Length - 1; i >= 0; i--)
  1918. {
  1919. if (barcodes[i] != "")
  1920. {
  1921. Barcodes.Add(barcodes[i]);
  1922. }
  1923. }
  1924. InvokePropertyChanged("Barcodes");
  1925. //if (Barcodes.GroupBy(j => j).Where(g => g.Count() > 0).Count() != Barcodes.Count)
  1926. //{
  1927. // WPFMessageBox.ShowError("重复扫码,请确认并重新扫码");
  1928. // Barcodes.Clear();
  1929. // InvokePropertyChanged("Barcodes");
  1930. // LotBarcodeInputText = "";
  1931. //}
  1932. }
  1933. private void OperatorInputChanged(object param)
  1934. {
  1935. string currentOperator = param as string;
  1936. OperatorInputText = currentOperator;
  1937. if (currentOperator.Contains('/'))
  1938. {
  1939. keybd_event((byte)(System.Windows.Forms.Keys.Tab), 0, 0, 0);
  1940. //FocusManager.SetFocusedElement(_hzOverviewView, _hzOverviewView.BarcodeTextBox);//UserName文本框获取光标
  1941. }
  1942. }
  1943. private void GetRecipeByMES(object obj)
  1944. {
  1945. try
  1946. {
  1947. if (IsAuto == true)
  1948. {
  1949. var lotList = new List<string>(Barcodes);
  1950. if (OperatorInputText == "")
  1951. {
  1952. return;
  1953. }
  1954. if (LotBarcodeInputText == "")
  1955. {
  1956. return;
  1957. }
  1958. if (!string.IsNullOrEmpty(OperatorInputText))
  1959. {
  1960. if (OperatorInputText.Substring(OperatorInputText.Length - 1, 1) == "/")
  1961. {
  1962. userID = OperatorInputText.Substring(0, OperatorInputText.Length - 1);
  1963. }
  1964. else
  1965. {
  1966. userID = OperatorInputText;
  1967. }
  1968. }
  1969. switch (WcfClient.Instance.Query.GetConfig(SCName.System_Company))
  1970. {
  1971. case 0:
  1972. //_fabAutoComm = new JCFabAuto();
  1973. var recipeName = _fabAutoComm.GetRecipeByLot(lotList);
  1974. if (!string.IsNullOrEmpty(recipeName))
  1975. AutoGetRecipe(recipeName);
  1976. break;
  1977. case 1:
  1978. ResponseResult receipeRes = _fabAutoComm.GetRecipeByMultipleLot(lotList, WcfClient.Instance.Query.GetConfig(SCName.System_YZQZMachineNumber).ToString(), WcfClient.Instance.Query.GetConfig(SCName.System_YZQZMachineType).ToString(), WcfClient.Instance.Query.GetConfig(SCName.System_YZQZWebapi).ToString());
  1979. AutoGetRecipeYZQZ(receipeRes);
  1980. break;
  1981. }
  1982. //var recipeName = _fabAutoComm.GetRecipeByLot(lotList);
  1983. //AutoGetRecipe(recipeName);
  1984. }
  1985. else
  1986. {
  1987. WPFMessageBox.ShowInformation("当前状态为手动过站");
  1988. }
  1989. }
  1990. catch (Exception ex)
  1991. {
  1992. WPFMessageBox.ShowInformation(ex.Message);
  1993. }
  1994. }
  1995. private void AutoGetRecipe(string recipeName)
  1996. {
  1997. var xmlReipes = WcfClient.Instance.Recipe.GetXmlRecipeList(ModuleName.System, false);
  1998. var recipesNames = GetRecipes(xmlReipes);
  1999. if (recipesNames.Count == 0)
  2000. {
  2001. //MessageBox.Show("请先创建Recipe");
  2002. WPFMessageBox.ShowError("请先创建Recipe");
  2003. return;
  2004. }
  2005. if (!recipesNames.Contains(recipeName))
  2006. {
  2007. WPFMessageBox.ShowError(recipeName + "不存在,请确认");
  2008. //MessageBox.Show(recipeName + "不存在,请确认");
  2009. return;
  2010. }
  2011. SelectedRecipeName = recipeName;
  2012. RecipeBarcodeInputText = "";
  2013. InvokePropertyChanged("RecipeBarcodeInputText");
  2014. InvokePropertyChanged("SelectedRecipeName");
  2015. }
  2016. private void AutoGetRecipeYZQZ(ResponseResult receipeRes)
  2017. {
  2018. if (receipeRes != null)
  2019. {
  2020. string recipeName;
  2021. if (receipeRes.Status == (int)ResultStatus.Success)
  2022. {
  2023. LotsReceipeInfo = receipeRes.Data;
  2024. if (LotsReceipeInfo != null && LotsReceipeInfo.Count > 0)
  2025. {
  2026. recipeName = LotsReceipeInfo[0].RecipeName;
  2027. SelectedOperation = LotsReceipeInfo[0].Operation;
  2028. }
  2029. else return;
  2030. var xmlReipes = WcfClient.Instance.Recipe.GetXmlRecipeList(ModuleName.System, false);
  2031. var recipesNames = GetRecipes(xmlReipes);
  2032. if (recipesNames.Count == 0)
  2033. {
  2034. //MessageBox.Show("请先创建Recipe");
  2035. WPFMessageBox.ShowError("请先创建Recipe");
  2036. return;
  2037. }
  2038. if (!recipesNames.Contains(recipeName))
  2039. {
  2040. WPFMessageBox.ShowError(recipeName + "不存在,请确认");
  2041. //MessageBox.Show(recipeName + "不存在,请确认");
  2042. return;
  2043. }
  2044. SelectedRecipeName = recipeName;
  2045. RecipeBarcodeInputText = "";
  2046. InvokePropertyChanged("RecipeBarcodeInputText");
  2047. InvokePropertyChanged("SelectedRecipeName");
  2048. }
  2049. else
  2050. {
  2051. MessageBox.Show("接口获取失败,error message:" + receipeRes.Status + "|" + receipeRes.Message);
  2052. }
  2053. }else MessageBox.Show("接口获取异常!");
  2054. }
  2055. private void AutoGetRecipeYZQZbySingleLot(KeyValuePair<ResultStatus, ResponseRecipe> receipeRes)
  2056. {
  2057. string recipeName;
  2058. if (receipeRes.Key == ResultStatus.Success)
  2059. {
  2060. if(LotsReceipeInfo!=null) LotsReceipeInfo.Clear();
  2061. else LotsReceipeInfo=new List<ResponseRecipe>();
  2062. if(receipeRes.Value!=null)
  2063. LotsReceipeInfo.Add(receipeRes.Value);
  2064. if (LotsReceipeInfo != null && LotsReceipeInfo.Count > 0)
  2065. {
  2066. recipeName = LotsReceipeInfo[0].RecipeName;
  2067. }
  2068. else return;
  2069. var xmlReipes = WcfClient.Instance.Recipe.GetXmlRecipeList(ModuleName.System, false);
  2070. var recipesNames = GetRecipes(xmlReipes);
  2071. if (recipesNames.Count == 0)
  2072. {
  2073. //MessageBox.Show("请先创建Recipe");
  2074. WPFMessageBox.ShowError("请先创建Recipe");
  2075. return;
  2076. }
  2077. if (!recipesNames.Contains(recipeName))
  2078. {
  2079. WPFMessageBox.ShowError(recipeName + "不存在,请确认");
  2080. //MessageBox.Show(recipeName + "不存在,请确认");
  2081. return;
  2082. }
  2083. }
  2084. else
  2085. {
  2086. MessageBox.Show("接口获取失败,error code:" + (int)receipeRes.Key);
  2087. }
  2088. }
  2089. /// <summary>
  2090. /// 读取xml里面所有的recipe名
  2091. /// </summary>
  2092. /// <returns></returns>
  2093. public static List<string> GetRecipes(string xml)
  2094. {
  2095. var list = new List<string>();
  2096. XmlDocument doc = new XmlDocument();
  2097. doc.LoadXml(xml);
  2098. XmlNode root = doc.FirstChild;
  2099. XmlNodeList nodeList = root.ChildNodes;
  2100. foreach (XmlNode node in nodeList)
  2101. {
  2102. list.Add(node.Attributes[0].InnerText);
  2103. }
  2104. return list;
  2105. }
  2106. #endregion barcode
  2107. }
  2108. }