MainWindowViewModel.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. using Aitex.Common.Util;
  2. using Aitex.Core.Account;
  3. using Aitex.Core.RT.ConfigCenter;
  4. using Aitex.Core.RT.DataCenter;
  5. using Aitex.Core.RT.DataCollection;
  6. using Aitex.Core.RT.DBCore;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.Device.Unit;
  9. using Aitex.Core.RT.Fsm;
  10. using Aitex.Core.RT.OperationCenter;
  11. using Aitex.Core.RT.Routine;
  12. using Aitex.Core.RT.SCCore;
  13. using Aitex.Core.Util;
  14. using Aitex.Core.WCF;
  15. using Aitex.Sorter.Common;
  16. using athosRT.Devices;
  17. using athosRT.FSM;
  18. using athosRT.Modules.LPs;
  19. using athosRT.Modules.Robot;
  20. using athosRT.tool;
  21. using Caliburn.Micro;
  22. using MECF.Framework.Common.Equipment;
  23. using MECF.Framework.Common.SCCore;
  24. using MECF.Framework.Common.SubstrateTrackings;
  25. using MECF.Framework.RT.Core.IoProviders;
  26. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  27. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
  28. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  29. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  30. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TMs;
  31. using System;
  32. using System.Collections.Generic;
  33. using System.Collections.ObjectModel;
  34. using System.Configuration;
  35. using System.Diagnostics;
  36. using System.IO;
  37. using System.Linq;
  38. using System.Reflection;
  39. using System.Security.Cryptography;
  40. using System.Text;
  41. using System.Threading;
  42. using System.Threading.Tasks;
  43. using System.Windows;
  44. using System.Windows.Controls;
  45. using System.Windows.Input;
  46. using athosRT.Devices.IODevices;
  47. using System.Xml;
  48. using System.Xml.Linq;
  49. using static MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase.RobotBaseDevice;
  50. using MECF.Framework.Common.IOCore;
  51. using Aitex.Core.RT.IOCore;
  52. using System.Net;
  53. using athosRT.Modules;
  54. using System.Windows.Threading;
  55. using Common.WcfService;
  56. using WcfServiceManager = Common.WcfServiceManager;
  57. using OperationManager = Common.OP.OperationManager;
  58. using Common.WcfService.Efem;
  59. using Aitex.Core.Common;
  60. using OP = Common.OP.OP;
  61. using MECF.Framework.Common.DataCenter;
  62. using DataManager = Common.DataCenter.DataManager;
  63. using DATA = Common.DataCenter.DATA;
  64. using QueryDataService = Common.DataCenter.QueryDataService;
  65. using athosRT.Modules.EFEMs;
  66. using static athosRT.Modules.EFEMs.EfemEntity;
  67. using athosRT.Devices.LP;
  68. using System.Text.RegularExpressions;
  69. using athosRT.Devices.FLP;
  70. using Aitex.Core.RT.Log;
  71. namespace athosRT
  72. {
  73. public class MainWindowViewModel : PropertyChangedBase
  74. {
  75. private TreeChildren _sc;
  76. public TreeChildren SCTree
  77. {
  78. get { return _sc; }
  79. set
  80. {
  81. _sc = value;
  82. NotifyOfPropertyChange(() => SCTree);
  83. }
  84. }
  85. private List<GridData> _gridDatas;
  86. public List<GridData> GridDatas { get { return _gridDatas; } set { _gridDatas = value; NotifyOfPropertyChange(() => GridDatas); } }
  87. public ICommand OnLoad { get; set; }
  88. public List<string> RTMsg { get; set; }
  89. private string _selectedMsg;
  90. public string SelectedMsg { get { return _selectedMsg; } set { _selectedMsg = value; NotifyOfPropertyChange(() => RTMsg); } }
  91. public DispatcherTimer _dp;
  92. public List<string> LPSET { get; set; }
  93. public List<string> LPGET { get; set; }
  94. public List<string> LPMOV { get; set; }
  95. private string _flipperstate;
  96. public string FlipperState { get { return _flipperstate; } set { _flipperstate = value; NotifyOfPropertyChange(() => FlipperState); } }
  97. private string lpsetcommand;
  98. private string lpgetcommand;
  99. private string lpmovcommand;
  100. private string setparam;
  101. public string LPSetCommand { get{ return lpsetcommand; } set{ lpsetcommand = value; NotifyOfPropertyChange(()=> LPSetCommand); } }
  102. public string LPGetCommand { get{ return lpgetcommand; } set{ lpgetcommand = value; NotifyOfPropertyChange(()=> LPGetCommand); } }
  103. public string LPMovCommand { get{ return lpmovcommand; } set{ lpmovcommand = value; NotifyOfPropertyChange(()=> LPMovCommand); } }
  104. public string SetParam { get { return setparam; } set { setparam = value;NotifyOfPropertyChange(()=> SetParam); } }
  105. private HirataLoadPort lp;
  106. public MainWindowViewModel()
  107. {
  108. Singleton<OperationManager>.Instance.Initialize();//框架下OP的初始化
  109. Singleton<DataManager>.Instance.Initialize();//框架下Data的初始化
  110. WcfServiceManager.Instance.Initialize(new Type[] {//框架下WCF的初始化
  111. typeof(SomebodyService),typeof(EfemService),typeof(QueryDataService)
  112. });
  113. Trace.WriteLine(ModuleName.LP1.ToString());
  114. OnLoad = new CommandBase(Load);
  115. LogObject.Info("RT", "--------------------------------------------------");
  116. SCTree = new TreeChildren();
  117. string xmlFileName = PathManager.GetCfgDir() + "Efem.sccfg";
  118. Singleton<SystemConfigManager>.Instance.Initialize(xmlFileName);
  119. GetSCTreeStatus();//厘清SC树的构造 并赋予变量SCTree
  120. GridDatas = new List<GridData>()
  121. {
  122. };
  123. RTMsg = getmsgitems();
  124. SelectedMsg = RTMsg.Count > 0 ? RTMsg[0].ToString() : "";
  125. //设备的初始化需要在构造中进行 否则页面无法正常运行
  126. InitCommonModules();
  127. GetIOCard();
  128. //Debug();
  129. }
  130. private void Debug()
  131. {
  132. LPSET = new List<string>()
  133. { "RSET", "RTRY", "STPP", "PASE",
  134. "ABOT", "RESM", "TYP1", "TYP2",
  135. "TYP3", "TYP4", "TYP5", "MAPP",
  136. "MAP1", "MAP2", "POSO", };
  137. LPGET = new List<string>()
  138. { "STAS","STA1","STA2","MDAT",
  139. "MAPR","VERN","MAPP","MAP1",
  140. "MAP2","POSO","POSD","MDAH",
  141. "MDAP","MDTC","MDHS","MDPS","LEST",};
  142. LPMOV = new List<string>()
  143. { "ORGN","ABGN","FPLD","FPML",
  144. "FDOC","FDLD","FDML","FCLD",
  145. "FCML","FPUL","FPMU","FVOF",
  146. "FVUL","FUDC","FUMD","MAPP",
  147. "RMAP","Z_MP",};
  148. LPSetCommand = LPSET[0];
  149. LPGetCommand = LPGET[0];
  150. LPMovCommand = LPMOV[0];
  151. SetParam = "";
  152. //lp = lp = new HirataLoadPort("LP3", "LP3", "LoadPort", (RobotBaseDevice)null);
  153. }
  154. public void SendSet()
  155. {
  156. string sendcommand = "SET:"+LPSetCommand;
  157. if (SetParam == "")
  158. {
  159. sendcommand += ";";
  160. }
  161. else
  162. {
  163. sendcommand += $"/{SetParam};";
  164. }
  165. lp.SendMessage(sendcommand);
  166. }
  167. public void SendGet()
  168. {
  169. string sendcommand = "GET:"+LPGetCommand+";";
  170. Trace.WriteLine(sendcommand);
  171. lp.SendMessage(sendcommand);
  172. }
  173. public void SendMov()
  174. {
  175. string sendcommand = "MOV:"+LPMovCommand+";";
  176. Trace.WriteLine(sendcommand);
  177. lp.SendMessage(sendcommand);
  178. }
  179. #region flipper 调试代码 不标准后续删除
  180. //public void FlipperHome() { Singleton<RouteManager1>.Instance._flipper.Check(1,out _); }
  181. //public void FlipperTurn() { Singleton<RouteManager1>.Instance._flipper.PostMsg(2); }
  182. //public void FlipperClamp() { Singleton<RouteManager1>.Instance._flipper.PostMsg(3, !Singleton<RouteManager1>.Instance._flipper.ClampOpen); }
  183. #endregion
  184. private void DataTimer_Tick(object sender, EventArgs e)
  185. {
  186. //RtState state;
  187. //if (Enum.TryParse(Singleton<RouteManager1>.Instance.GetFsmState, out state))
  188. //{
  189. // Trace.WriteLine("-------------------当前RT状态:" + (RtState)state + "-------------------");
  190. //}
  191. //Trace.WriteLine("-------------------当前RT Running:" + Singleton<RouteManager1>.Instance.IsRunning + "-------------------");
  192. //if (Enum.TryParse(Singleton<EfemEntity>.Instance.GetFsmState, out state))
  193. //{
  194. // Trace.WriteLine("-------------------当前EFEM状态:" + (ServerState)state + "-------------------");
  195. //}
  196. //Trace.WriteLine("-------------------当前Robot状态:" + DEVICE.GetDevice<RobotBaseDevice>("Robot").RobotState + "-------------------");
  197. ////if (_isPresent && _isPlaced && _isLoaded && IsReady() && _isMapped)
  198. //LoadPortBaseDevice lp1= DEVICE.GetDevice<LoadPortBaseDevice>("LP1");
  199. //Trace.WriteLine($"----当前LP1状态:Loaded:{lp1.IsLoaded} Ready:{lp1.IsReady()} Mapped:{lp1.IsMapped} DockState:{lp1.DockState}----");
  200. //LoadPortBaseDevice lp2 = DEVICE.GetDevice<LoadPortBaseDevice>("LP2");
  201. //Trace.WriteLine($"----当前LP2状态:Loaded:{lp2.IsLoaded} Ready:{lp2.IsReady()} Mapped:{lp2.IsMapped} DockState:{lp2.DockState}----");
  202. GetIOCard();
  203. //flipper状态
  204. FlipperState = Singleton<RouteManager1>.Instance.GetFlipper().State.ToString();
  205. }
  206. private void Load()
  207. {
  208. Singleton<RouteManager1>.Instance.Initialize();//RT控制初始化
  209. Singleton<EfemEntity>.Instance.SetEfemData();
  210. Singleton<EfemEntity>.Instance.Initialize();
  211. DATA.Subscribe($"DIItemList", () => DiItemList);//DI数据传递
  212. DATA.Subscribe($"DOItemList", () => DoItemList);//DO数据传递
  213. DATA.Subscribe("GetLogList",()=> LogObject.GetLogList());
  214. //====lp debug=====
  215. //lp = new HirataLoadPort("", "LP3", "LoadPort", (RobotBaseDevice)null);
  216. //lp.SendMessage("MOV:ORGN;");
  217. //=================
  218. _dp = new DispatcherTimer();
  219. _dp.Tick += new EventHandler(DataTimer_Tick);
  220. _dp.Interval = TimeSpan.FromSeconds(2);
  221. _dp.Start();
  222. }
  223. public void ChangeState()
  224. {
  225. RouteManager1.MSG willsend;
  226. if (Enum.TryParse(SelectedMsg, out willsend))
  227. {
  228. Trace.WriteLine("发送指令"+willsend);
  229. switch (willsend)
  230. {
  231. case RouteManager1.MSG.MapWafer:
  232. Singleton<RouteManager1>.Instance.CheckToPostMsg((RouteManager1.MSG)willsend,"LP1");
  233. break;
  234. case RouteManager1.MSG.Pick:
  235. Singleton<RouteManager1>.Instance.CheckToPostMsg((RouteManager1.MSG)willsend, "CoolingBuffer1", 0, 0);
  236. break;
  237. case RouteManager1.MSG.Place:
  238. Singleton<RouteManager1>.Instance.CheckToPostMsg((RouteManager1.MSG)willsend, "CoolingBuffer1", 0, 0);
  239. break;
  240. default:
  241. Singleton<RouteManager1>.Instance.CheckToPostMsg((RouteManager1.MSG)willsend);
  242. break;
  243. }
  244. }
  245. }
  246. private List<string> getmsgitems()
  247. {
  248. List<string> msgs = new List<string>();
  249. foreach (var i in Enum.GetValues(typeof(RouteManager1.MSG))) { msgs.Add(i.ToString()); }
  250. return msgs;
  251. }
  252. public void _comfirmChange(object item)
  253. {
  254. GridData SelectData = (GridData)item;
  255. //Trace.WriteLine("修改前的值是" + SelectData.CurrentValue);
  256. //告知sc修改SetItemValue
  257. switch (SelectData.Type)
  258. {
  259. case "Integer":
  260. if (int.TryParse(SelectData.Setpoint, out _))
  261. {
  262. SCConfigItem _item = SC.GetConfigItem(SelectData.Header + "." + SelectData.Name);
  263. SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
  264. SC.SetItemValueFromString(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
  265. _item = SC.GetConfigItem(SelectData.Header + "." + SelectData.Name);
  266. }
  267. break;
  268. case "Bool":
  269. if (bool.TryParse(SelectData.Setpoint, out _))
  270. {
  271. SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
  272. SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
  273. }
  274. break;
  275. default:
  276. SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
  277. SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
  278. break;
  279. }
  280. for (int i = 0; i < GridDatas.Count; i++)
  281. {
  282. if (SC.GetStringValue(SelectData.Header + "." + SelectData.Name) == SelectData.Setpoint && GridDatas[i].Header == SelectData.Header && GridDatas[i].Name == SelectData.Name)
  283. {
  284. GridDatas[i].CurrentValue = SelectData.Setpoint;
  285. }
  286. }
  287. }
  288. public void _showttems(object Items)
  289. {
  290. List<SCConfigItem> lst = (List<SCConfigItem>)Items;//获取所有配置项
  291. List<GridData> SelectDatas = new List<GridData>();
  292. foreach (var item in lst)
  293. {
  294. SelectDatas.Add(
  295. new GridData()
  296. {
  297. Header = item.Path,
  298. Description = item.Description,
  299. Unint = item.Unit,
  300. Min = item.Min,
  301. Max = item.Max,
  302. CurrentValue = SC.GetConfigItem(item.Path+"." + item.Name).Value.ToString(),
  303. Comfirm = new CommandBase(_comfirmChange),
  304. Setpoint = SC.GetConfigItem(item.Path + "." + item.Name).Value.ToString(),
  305. Name = item.Name,
  306. Type = item.Type,
  307. });
  308. }
  309. GridDatas = SelectDatas;
  310. }
  311. //设备文件解析和初始化的函数
  312. private void InitCommonModules()
  313. {
  314. Singleton<DeviceDefineManager>.Instance.Initialize(PathManager.GetCfgDir() + "DeviceDefine.xml");
  315. string xmlConfigFile = PathManager.GetCfgDir() + "IoProviderConfig.xml";
  316. int? nullable = Singleton<DeviceDefineManager>.Instance.GetValue<int>("IoCardQuantity");
  317. Dictionary<string, Dictionary<int, string>> ioMappingPathFile;
  318. if (nullable.HasValue)
  319. {
  320. switch (nullable.GetValueOrDefault())
  321. {
  322. case 1:
  323. ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
  324. {
  325. {
  326. "System.dio000",
  327. new Dictionary<int, string>()
  328. {
  329. {
  330. 0,
  331. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
  332. }
  333. }
  334. },
  335. {
  336. "System.Super",
  337. new Dictionary<int, string>()
  338. {
  339. {
  340. 256,
  341. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\\\_diDefineSuper.xml"
  342. },
  343. {
  344. 512,
  345. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\\\_doDefineSuper.xml"
  346. },
  347. {
  348. 1001,
  349. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\\\_aiDefineSuper.xml"
  350. },
  351. {
  352. 2001,
  353. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\\\_aoDefineSuper.xml"
  354. }
  355. }
  356. }
  357. };
  358. goto label_10;
  359. case 2:
  360. ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
  361. {
  362. {
  363. "System.dio000",
  364. new Dictionary<int, string>()
  365. {
  366. {
  367. 0,
  368. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
  369. }
  370. }
  371. },
  372. {
  373. "System.dio001",
  374. new Dictionary<int, string>()
  375. {
  376. {
  377. 0,
  378. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
  379. }
  380. }
  381. }
  382. };
  383. goto label_10;
  384. case 3:
  385. ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
  386. {
  387. {
  388. "System.dio000",
  389. new Dictionary<int, string>()
  390. {
  391. {
  392. 0,
  393. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
  394. }
  395. }
  396. },
  397. {
  398. "System.dio001",
  399. new Dictionary<int, string>()
  400. {
  401. {
  402. 0,
  403. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
  404. }
  405. }
  406. },
  407. {
  408. "System.dio002",
  409. new Dictionary<int, string>()
  410. {
  411. {
  412. 0,
  413. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
  414. }
  415. }
  416. }
  417. };
  418. goto label_10;
  419. case 4:
  420. ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
  421. {
  422. {
  423. "System.dio000",
  424. new Dictionary<int, string>()
  425. {
  426. {
  427. 0,
  428. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
  429. }
  430. }
  431. },
  432. {
  433. "System.dio001",
  434. new Dictionary<int, string>()
  435. {
  436. {
  437. 0,
  438. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
  439. }
  440. }
  441. },
  442. {
  443. "System.dio002",
  444. new Dictionary<int, string>()
  445. {
  446. {
  447. 0,
  448. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
  449. }
  450. }
  451. },
  452. {
  453. "System.dio003",
  454. new Dictionary<int, string>()
  455. {
  456. {
  457. 0,
  458. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard4.xml"
  459. }
  460. }
  461. }
  462. };
  463. goto label_10;
  464. case 5:
  465. ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
  466. {
  467. {
  468. "System.dio000",
  469. new Dictionary<int, string>()
  470. {
  471. {
  472. 0,
  473. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
  474. }
  475. }
  476. },
  477. {
  478. "System.dio001",
  479. new Dictionary<int, string>()
  480. {
  481. {
  482. 0,
  483. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
  484. }
  485. }
  486. },
  487. {
  488. "System.dio002",
  489. new Dictionary<int, string>()
  490. {
  491. {
  492. 0,
  493. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
  494. }
  495. }
  496. },
  497. {
  498. "System.dio003",
  499. new Dictionary<int, string>()
  500. {
  501. {
  502. 0,
  503. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard4.xml"
  504. }
  505. }
  506. },
  507. {
  508. "System.dio004",
  509. new Dictionary<int, string>()
  510. {
  511. {
  512. 0,
  513. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard5.xml"
  514. }
  515. }
  516. }
  517. };
  518. goto label_10;
  519. case 6:
  520. ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
  521. {
  522. {
  523. "System.dio000",
  524. new Dictionary<int, string>()
  525. {
  526. {
  527. 0,
  528. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
  529. }
  530. }
  531. },
  532. {
  533. "System.dio001",
  534. new Dictionary<int, string>()
  535. {
  536. {
  537. 0,
  538. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
  539. }
  540. }
  541. },
  542. {
  543. "System.dio002",
  544. new Dictionary<int, string>()
  545. {
  546. {
  547. 0,
  548. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
  549. }
  550. }
  551. },
  552. {
  553. "System.dio003",
  554. new Dictionary<int, string>()
  555. {
  556. {
  557. 0,
  558. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard4.xml"
  559. }
  560. }
  561. },
  562. {
  563. "System.dio004",
  564. new Dictionary<int, string>()
  565. {
  566. {
  567. 0,
  568. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard5.xml"
  569. }
  570. }
  571. },
  572. {
  573. "System.dio005",
  574. new Dictionary<int, string>()
  575. {
  576. {
  577. 0,
  578. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard6.xml"
  579. }
  580. }
  581. }
  582. };
  583. goto label_10;
  584. case 7:
  585. ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
  586. {
  587. {
  588. "System.dio000",
  589. new Dictionary<int, string>()
  590. {
  591. {
  592. 0,
  593. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
  594. }
  595. }
  596. },
  597. {
  598. "System.dio001",
  599. new Dictionary<int, string>()
  600. {
  601. {
  602. 0,
  603. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
  604. }
  605. }
  606. },
  607. {
  608. "System.dio002",
  609. new Dictionary<int, string>()
  610. {
  611. {
  612. 0,
  613. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
  614. }
  615. }
  616. },
  617. {
  618. "System.dio003",
  619. new Dictionary<int, string>()
  620. {
  621. {
  622. 0,
  623. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard4.xml"
  624. }
  625. }
  626. },
  627. {
  628. "System.dio004",
  629. new Dictionary<int, string>()
  630. {
  631. {
  632. 0,
  633. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard5.xml"
  634. }
  635. }
  636. },
  637. {
  638. "System.dio005",
  639. new Dictionary<int, string>()
  640. {
  641. {
  642. 0,
  643. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard6.xml"
  644. }
  645. }
  646. },
  647. {
  648. "System.dio006",
  649. new Dictionary<int, string>()
  650. {
  651. {
  652. 0,
  653. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard7.xml"
  654. }
  655. }
  656. }
  657. };
  658. goto label_10;
  659. }
  660. }
  661. ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
  662. {
  663. {
  664. "System.dio000",
  665. new Dictionary<int, string>()
  666. {
  667. {
  668. 0,
  669. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefine.xml"
  670. }
  671. }
  672. }
  673. };
  674. label_10:
  675. if (Singleton<DeviceDefineManager>.Instance.GetValue<bool>("MotionAxisInstalled").GetValueOrDefault())
  676. ioMappingPathFile.Add("System.MotionAxis", new Dictionary<int, string>()
  677. {
  678. {
  679. 0,
  680. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineMotionAxis.xml"
  681. }
  682. });
  683. if (Singleton<DeviceDefineManager>.Instance.GetValue<bool>("PLCIoInstalled").GetValueOrDefault())
  684. ioMappingPathFile.Add("System.MainPlc", new Dictionary<int, string>()
  685. {
  686. {
  687. 0,
  688. PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineMainPlc.xml"
  689. }
  690. });
  691. foreach (var keyValuePair in ioMappingPathFile)
  692. {
  693. //LOG.Write($"Key:{keyValuePair.Key} -- Value:{keyValuePair.Value}");
  694. }
  695. Singleton<Devices.IODevices.IoProviderManager>.Instance.Initialize(xmlConfigFile, ioMappingPathFile);
  696. Singleton<WaferManager>.Instance.Initialize();//框架下WaferManager的初始化
  697. Singleton<CarrierManager>.Instance.Initialize();
  698. Singleton<DeviceEntity>.Instance.Initialize();//设备初始化
  699. //Trace.WriteLine(PathManager.GetCfgDir() + "DeviceModel.xml");
  700. Singleton<DeviceManager>.Instance.Initialize(PathManager.GetCfgDir() + "DeviceModelNew.xml", "EFEM");
  701. }
  702. //验证设备状态的点击事件 不是很重要 后期移除
  703. public void GetSomeDevice()
  704. {
  705. //开一个服务用于数据的订阅
  706. //WaferInfo[] waferInfos = WaferManager.Instance.GetWafers(ModuleName.LP1);
  707. //Trace.WriteLine(waferInfos.Length);
  708. LoadPortBaseDevice LP = DEVICE.GetDevice<LoadPortBaseDevice>("LP2");
  709. if (LP == null)
  710. {
  711. Trace.WriteLine("暂无此设备");
  712. }
  713. else
  714. {
  715. Trace.WriteLine("LP设备获取完毕");
  716. }
  717. RobotBaseDevice Robot = DEVICE.GetDevice<RobotBaseDevice>("Robot");
  718. if (Robot == null)
  719. {
  720. Trace.WriteLine("暂无此设备");
  721. }
  722. else
  723. {
  724. Trace.WriteLine("Robot设备获取完毕");
  725. }
  726. LoadLockDevice LL1 = DEVICE.GetDevice<LoadLockDevice>("LL1");
  727. if (LL1 == null)
  728. {
  729. Trace.WriteLine("暂无此设备");
  730. }
  731. else
  732. {
  733. Trace.WriteLine("LL1设备获取完毕");
  734. }
  735. IoCoolingBuffer coolingBuffer1 = DEVICE.GetDevice<IoCoolingBuffer>("buffer");
  736. if (coolingBuffer1 == null)
  737. {
  738. Trace.WriteLine("暂无此设备");
  739. }
  740. else
  741. {
  742. Trace.WriteLine("coolingBuffer1设备获取完毕");
  743. }
  744. }
  745. public void StartCycle()
  746. {
  747. Singleton<RouteManager1>.Instance.PostMsg(RouteManager1.MSG.StartCycle);
  748. }
  749. /// <summary>
  750. /// 初始化一些数据 对获取的数据进行一个刷新
  751. /// </summary>
  752. private void GetIOCard()
  753. {
  754. DiItemList = new ObservableCollection<NotifiableIoItem>() { };
  755. DoItemList = new ObservableCollection<NotifiableIoItem>() { };
  756. AiItemList = new ObservableCollection<NotifiableIoItem>() { };
  757. AoItemList = new ObservableCollection<NotifiableIoItem>() { };
  758. //对IO数据进行获取
  759. List<DIAccessor> dilist = IO.GetDiList("System.dio000");
  760. foreach (DIAccessor diAccessor in dilist)
  761. DiItemList.Add(new NotifiableIoItem()
  762. {
  763. Name = diAccessor.Name,
  764. Index = diAccessor.Index,
  765. Description = diAccessor.Description,
  766. BoolValue = diAccessor.Value,
  767. Address = diAccessor.Addr
  768. });
  769. List<DOAccessor> dolist = IO.GetDoList("System.dio000");
  770. foreach (DOAccessor doAccessor in dolist)
  771. {
  772. DoItemList.Add(new NotifiableIoItem()
  773. {
  774. Name = doAccessor.Name,
  775. Index = doAccessor.Index,
  776. Description = doAccessor.Description,
  777. BoolValue = doAccessor.Value,
  778. Address = doAccessor.Addr
  779. });
  780. }
  781. //Trace.WriteLine(DiItemList.Count.ToString() + "" + DoItemList.Count.ToString());
  782. }
  783. //-------------涉及到IO数据的一些变量 要注意数据变化------------
  784. private ObservableCollection<NotifiableIoItem> _diItemList;
  785. private ObservableCollection<NotifiableIoItem> _doItemList;
  786. public ObservableCollection<NotifiableIoItem> DiItemList { get { return _diItemList; } set { _diItemList = value; NotifyOfPropertyChange(() => DiItemList); } }
  787. public ObservableCollection<NotifiableIoItem> DoItemList { get { return _doItemList; } set { _doItemList = value; NotifyOfPropertyChange(() => DoItemList); } }
  788. public ObservableCollection<NotifiableIoItem> AiItemList { get; set; }
  789. public ObservableCollection<NotifiableIoItem> AoItemList { get; set; }
  790. //构建sc树的逻辑
  791. public void GetSCTreeStatus()
  792. {
  793. List<SCConfigItem> SClist = SC.GetItemList();
  794. Dictionary<string, TreeChildren> scdic = new Dictionary<string, TreeChildren>();
  795. for (int i = 0; i < SClist.Count; i++)
  796. {
  797. TreeChildren tc1;//大类
  798. string headerName = SClist[i].Path.Split('.')[0];
  799. if (!scdic.ContainsKey(headerName))
  800. {
  801. //没有先new
  802. //Trace.WriteLine("添加"+ headerName);
  803. tc1 = new TreeChildren(headerName);
  804. tc1.ShowItems = new CommandBase(_showttems);
  805. scdic.Add(headerName, tc1);
  806. }
  807. else
  808. {
  809. //有了就加入
  810. scdic.TryGetValue(headerName, out tc1);
  811. }
  812. //----分割----
  813. if (SClist[i].Path.Contains("."))
  814. {
  815. //有点 加到子目录
  816. bool flag = false;
  817. TreeChildren tc2 = new TreeChildren();
  818. foreach (var itlist in tc1.Children)
  819. {
  820. if (itlist.Name == SClist[i].Path.Split('.')[1])
  821. {
  822. tc2 = itlist;
  823. flag = true;
  824. break;
  825. }
  826. }
  827. if (flag)
  828. {
  829. //说明有这个子类直接加到Items中
  830. tc2.Items.Add(SClist[i]);
  831. }
  832. else
  833. {
  834. //没有子类 新建一下
  835. tc2 = new TreeChildren(SClist[i].Path.Split('.')[1]);//小类
  836. tc2.Items.Add(SClist[i]);
  837. tc2.ShowItems = new CommandBase(_showttems);
  838. tc1.Children.Add(tc2);
  839. }
  840. }
  841. else
  842. {
  843. //无点 加到List
  844. tc1.Items.Add(SClist[i]);
  845. }
  846. }
  847. foreach (var item in scdic)
  848. {
  849. SCTree.Children.Add(item.Value);
  850. }
  851. }
  852. public class TreeChildren
  853. {
  854. public string Name { get; set; }
  855. public List<SCConfigItem> Items { get; set; } = new List<SCConfigItem>();
  856. public ObservableCollection<TreeChildren> Children { get; set; } = new ObservableCollection<TreeChildren>();
  857. public TreeChildren() { }
  858. public TreeChildren(string name)
  859. {
  860. Name = name;
  861. }
  862. public ICommand ShowItems { get; set; }
  863. }
  864. public class GridData : PropertyChangedBase
  865. {
  866. public string Header { get; set; }
  867. public string Description { get; set; }
  868. public string Name { get; set; }
  869. public string Type { get; set; }
  870. public string Unint { get; set; }
  871. public string Min { get; set; }
  872. public string Max { get; set; }
  873. private string _cv;
  874. private string _sp;
  875. public string CurrentValue { get { return _cv; } set { _cv = value; NotifyOfPropertyChange(() => CurrentValue); } }
  876. public string Setpoint { get { return _sp; } set { _sp = value; NotifyOfPropertyChange(() => Setpoint); } }
  877. public ICommand Comfirm { get; set; }
  878. }
  879. }
  880. }