123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935 |
- using Aitex.Common.Util;
- using Aitex.Core.Account;
- using Aitex.Core.RT.ConfigCenter;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.DataCollection;
- using Aitex.Core.RT.DBCore;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Fsm;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Core.WCF;
- using Aitex.Sorter.Common;
- using athosRT.Devices;
- using athosRT.FSM;
- using athosRT.Modules.LPs;
- using athosRT.Modules.Robot;
- using athosRT.tool;
- using Caliburn.Micro;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SCCore;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.Core.IoProviders;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TMs;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Configuration;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Security.Cryptography;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using athosRT.Devices.IODevices;
- using System.Xml;
- using System.Xml.Linq;
- using static MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase.RobotBaseDevice;
- using MECF.Framework.Common.IOCore;
- using Aitex.Core.RT.IOCore;
- using System.Net;
- using athosRT.Modules;
- using System.Windows.Threading;
- using Common.WcfService;
- using WcfServiceManager = Common.WcfServiceManager;
- using OperationManager = Common.OP.OperationManager;
- using Common.WcfService.Efem;
- using Aitex.Core.Common;
- using OP = Common.OP.OP;
- using MECF.Framework.Common.DataCenter;
- using DataManager = Common.DataCenter.DataManager;
- using DATA = Common.DataCenter.DATA;
- using QueryDataService = Common.DataCenter.QueryDataService;
- using athosRT.Modules.EFEMs;
- using static athosRT.Modules.EFEMs.EfemEntity;
- using athosRT.Devices.LP;
- using System.Text.RegularExpressions;
- using athosRT.Devices.FLP;
- using Aitex.Core.RT.Log;
- namespace athosRT
- {
- public class MainWindowViewModel : PropertyChangedBase
- {
- private TreeChildren _sc;
- public TreeChildren SCTree
- {
- get { return _sc; }
- set
- {
- _sc = value;
- NotifyOfPropertyChange(() => SCTree);
- }
- }
- private List<GridData> _gridDatas;
- public List<GridData> GridDatas { get { return _gridDatas; } set { _gridDatas = value; NotifyOfPropertyChange(() => GridDatas); } }
- public ICommand OnLoad { get; set; }
- public List<string> RTMsg { get; set; }
- private string _selectedMsg;
- public string SelectedMsg { get { return _selectedMsg; } set { _selectedMsg = value; NotifyOfPropertyChange(() => RTMsg); } }
- public DispatcherTimer _dp;
- public List<string> LPSET { get; set; }
- public List<string> LPGET { get; set; }
- public List<string> LPMOV { get; set; }
- private string _flipperstate;
- public string FlipperState { get { return _flipperstate; } set { _flipperstate = value; NotifyOfPropertyChange(() => FlipperState); } }
- private string lpsetcommand;
- private string lpgetcommand;
- private string lpmovcommand;
- private string setparam;
- public string LPSetCommand { get{ return lpsetcommand; } set{ lpsetcommand = value; NotifyOfPropertyChange(()=> LPSetCommand); } }
- public string LPGetCommand { get{ return lpgetcommand; } set{ lpgetcommand = value; NotifyOfPropertyChange(()=> LPGetCommand); } }
- public string LPMovCommand { get{ return lpmovcommand; } set{ lpmovcommand = value; NotifyOfPropertyChange(()=> LPMovCommand); } }
- public string SetParam { get { return setparam; } set { setparam = value;NotifyOfPropertyChange(()=> SetParam); } }
- private HirataLoadPort lp;
- public MainWindowViewModel()
- {
- Singleton<OperationManager>.Instance.Initialize();//框架下OP的初始化
- Singleton<DataManager>.Instance.Initialize();//框架下Data的初始化
-
- WcfServiceManager.Instance.Initialize(new Type[] {//框架下WCF的初始化
- typeof(SomebodyService),typeof(EfemService),typeof(QueryDataService)
- });
- Trace.WriteLine(ModuleName.LP1.ToString());
- OnLoad = new CommandBase(Load);
- LogObject.Info("RT", "--------------------------------------------------");
- SCTree = new TreeChildren();
- string xmlFileName = PathManager.GetCfgDir() + "Efem.sccfg";
- Singleton<SystemConfigManager>.Instance.Initialize(xmlFileName);
- GetSCTreeStatus();//厘清SC树的构造 并赋予变量SCTree
- GridDatas = new List<GridData>()
- {
- };
- RTMsg = getmsgitems();
- SelectedMsg = RTMsg.Count > 0 ? RTMsg[0].ToString() : "";
- //设备的初始化需要在构造中进行 否则页面无法正常运行
- InitCommonModules();
- GetIOCard();
- //Debug();
- }
- private void Debug()
- {
- LPSET = new List<string>()
- { "RSET", "RTRY", "STPP", "PASE",
- "ABOT", "RESM", "TYP1", "TYP2",
- "TYP3", "TYP4", "TYP5", "MAPP",
- "MAP1", "MAP2", "POSO", };
- LPGET = new List<string>()
- { "STAS","STA1","STA2","MDAT",
- "MAPR","VERN","MAPP","MAP1",
- "MAP2","POSO","POSD","MDAH",
- "MDAP","MDTC","MDHS","MDPS","LEST",};
- LPMOV = new List<string>()
- { "ORGN","ABGN","FPLD","FPML",
- "FDOC","FDLD","FDML","FCLD",
- "FCML","FPUL","FPMU","FVOF",
- "FVUL","FUDC","FUMD","MAPP",
- "RMAP","Z_MP",};
- LPSetCommand = LPSET[0];
- LPGetCommand = LPGET[0];
- LPMovCommand = LPMOV[0];
- SetParam = "";
- //lp = lp = new HirataLoadPort("LP3", "LP3", "LoadPort", (RobotBaseDevice)null);
- }
- public void SendSet()
- {
- string sendcommand = "SET:"+LPSetCommand;
- if (SetParam == "")
- {
- sendcommand += ";";
- }
- else
- {
- sendcommand += $"/{SetParam};";
- }
- lp.SendMessage(sendcommand);
- }
- public void SendGet()
- {
- string sendcommand = "GET:"+LPGetCommand+";";
- Trace.WriteLine(sendcommand);
- lp.SendMessage(sendcommand);
- }
- public void SendMov()
- {
- string sendcommand = "MOV:"+LPMovCommand+";";
- Trace.WriteLine(sendcommand);
- lp.SendMessage(sendcommand);
- }
- #region flipper 调试代码 不标准后续删除
- //public void FlipperHome() { Singleton<RouteManager1>.Instance._flipper.Check(1,out _); }
- //public void FlipperTurn() { Singleton<RouteManager1>.Instance._flipper.PostMsg(2); }
- //public void FlipperClamp() { Singleton<RouteManager1>.Instance._flipper.PostMsg(3, !Singleton<RouteManager1>.Instance._flipper.ClampOpen); }
- #endregion
- private void DataTimer_Tick(object sender, EventArgs e)
- {
- //RtState state;
- //if (Enum.TryParse(Singleton<RouteManager1>.Instance.GetFsmState, out state))
- //{
- // Trace.WriteLine("-------------------当前RT状态:" + (RtState)state + "-------------------");
- //}
- //Trace.WriteLine("-------------------当前RT Running:" + Singleton<RouteManager1>.Instance.IsRunning + "-------------------");
- //if (Enum.TryParse(Singleton<EfemEntity>.Instance.GetFsmState, out state))
- //{
- // Trace.WriteLine("-------------------当前EFEM状态:" + (ServerState)state + "-------------------");
- //}
- //Trace.WriteLine("-------------------当前Robot状态:" + DEVICE.GetDevice<RobotBaseDevice>("Robot").RobotState + "-------------------");
- ////if (_isPresent && _isPlaced && _isLoaded && IsReady() && _isMapped)
- //LoadPortBaseDevice lp1= DEVICE.GetDevice<LoadPortBaseDevice>("LP1");
- //Trace.WriteLine($"----当前LP1状态:Loaded:{lp1.IsLoaded} Ready:{lp1.IsReady()} Mapped:{lp1.IsMapped} DockState:{lp1.DockState}----");
- //LoadPortBaseDevice lp2 = DEVICE.GetDevice<LoadPortBaseDevice>("LP2");
- //Trace.WriteLine($"----当前LP2状态:Loaded:{lp2.IsLoaded} Ready:{lp2.IsReady()} Mapped:{lp2.IsMapped} DockState:{lp2.DockState}----");
- GetIOCard();
- //flipper状态
- FlipperState = Singleton<RouteManager1>.Instance.GetFlipper().State.ToString();
- }
- private void Load()
- {
- Singleton<RouteManager1>.Instance.Initialize();//RT控制初始化
- Singleton<EfemEntity>.Instance.SetEfemData();
- Singleton<EfemEntity>.Instance.Initialize();
- DATA.Subscribe($"DIItemList", () => DiItemList);//DI数据传递
- DATA.Subscribe($"DOItemList", () => DoItemList);//DO数据传递
- DATA.Subscribe("GetLogList",()=> LogObject.GetLogList());
- //====lp debug=====
- //lp = new HirataLoadPort("", "LP3", "LoadPort", (RobotBaseDevice)null);
- //lp.SendMessage("MOV:ORGN;");
- //=================
- _dp = new DispatcherTimer();
- _dp.Tick += new EventHandler(DataTimer_Tick);
- _dp.Interval = TimeSpan.FromSeconds(2);
- _dp.Start();
- }
- public void ChangeState()
- {
- RouteManager1.MSG willsend;
- if (Enum.TryParse(SelectedMsg, out willsend))
- {
- Trace.WriteLine("发送指令"+willsend);
- switch (willsend)
- {
- case RouteManager1.MSG.MapWafer:
- Singleton<RouteManager1>.Instance.CheckToPostMsg((RouteManager1.MSG)willsend,"LP1");
- break;
- case RouteManager1.MSG.Pick:
- Singleton<RouteManager1>.Instance.CheckToPostMsg((RouteManager1.MSG)willsend, "CoolingBuffer1", 0, 0);
- break;
- case RouteManager1.MSG.Place:
- Singleton<RouteManager1>.Instance.CheckToPostMsg((RouteManager1.MSG)willsend, "CoolingBuffer1", 0, 0);
- break;
- default:
- Singleton<RouteManager1>.Instance.CheckToPostMsg((RouteManager1.MSG)willsend);
- break;
- }
-
- }
- }
- private List<string> getmsgitems()
- {
- List<string> msgs = new List<string>();
- foreach (var i in Enum.GetValues(typeof(RouteManager1.MSG))) { msgs.Add(i.ToString()); }
- return msgs;
- }
- public void _comfirmChange(object item)
- {
- GridData SelectData = (GridData)item;
- //Trace.WriteLine("修改前的值是" + SelectData.CurrentValue);
- //告知sc修改SetItemValue
-
- switch (SelectData.Type)
- {
- case "Integer":
- if (int.TryParse(SelectData.Setpoint, out _))
- {
- SCConfigItem _item = SC.GetConfigItem(SelectData.Header + "." + SelectData.Name);
- SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
- SC.SetItemValueFromString(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
- _item = SC.GetConfigItem(SelectData.Header + "." + SelectData.Name);
- }
- break;
- case "Bool":
- if (bool.TryParse(SelectData.Setpoint, out _))
- {
- SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
- SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
- }
- break;
- default:
- SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
- SC.SetItemValue(SelectData.Header + "." + SelectData.Name, SelectData.Setpoint);
- break;
- }
- for (int i = 0; i < GridDatas.Count; i++)
- {
- if (SC.GetStringValue(SelectData.Header + "." + SelectData.Name) == SelectData.Setpoint && GridDatas[i].Header == SelectData.Header && GridDatas[i].Name == SelectData.Name)
- {
- GridDatas[i].CurrentValue = SelectData.Setpoint;
- }
- }
- }
- public void _showttems(object Items)
- {
- List<SCConfigItem> lst = (List<SCConfigItem>)Items;//获取所有配置项
- List<GridData> SelectDatas = new List<GridData>();
- foreach (var item in lst)
- {
- SelectDatas.Add(
- new GridData()
- {
- Header = item.Path,
- Description = item.Description,
- Unint = item.Unit,
- Min = item.Min,
- Max = item.Max,
- CurrentValue = SC.GetConfigItem(item.Path+"." + item.Name).Value.ToString(),
- Comfirm = new CommandBase(_comfirmChange),
- Setpoint = SC.GetConfigItem(item.Path + "." + item.Name).Value.ToString(),
- Name = item.Name,
- Type = item.Type,
- });
- }
- GridDatas = SelectDatas;
- }
- //设备文件解析和初始化的函数
- private void InitCommonModules()
- {
- Singleton<DeviceDefineManager>.Instance.Initialize(PathManager.GetCfgDir() + "DeviceDefine.xml");
- string xmlConfigFile = PathManager.GetCfgDir() + "IoProviderConfig.xml";
- int? nullable = Singleton<DeviceDefineManager>.Instance.GetValue<int>("IoCardQuantity");
- Dictionary<string, Dictionary<int, string>> ioMappingPathFile;
- if (nullable.HasValue)
- {
- switch (nullable.GetValueOrDefault())
- {
- case 1:
- ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
- {
- {
- "System.dio000",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
- }
- }
- },
- {
- "System.Super",
- new Dictionary<int, string>()
- {
- {
- 256,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\\\_diDefineSuper.xml"
- },
- {
- 512,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\\\_doDefineSuper.xml"
- },
- {
- 1001,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\\\_aiDefineSuper.xml"
- },
- {
- 2001,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\\\_aoDefineSuper.xml"
- }
- }
- }
- };
- goto label_10;
- case 2:
- ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
- {
- {
- "System.dio000",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
- }
- }
- },
- {
- "System.dio001",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
- }
- }
- }
- };
- goto label_10;
- case 3:
- ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
- {
- {
- "System.dio000",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
- }
- }
- },
- {
- "System.dio001",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
- }
- }
- },
- {
- "System.dio002",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
- }
- }
- }
- };
- goto label_10;
- case 4:
- ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
- {
- {
- "System.dio000",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
- }
- }
- },
- {
- "System.dio001",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
- }
- }
- },
- {
- "System.dio002",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
- }
- }
- },
- {
- "System.dio003",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard4.xml"
- }
- }
- }
- };
- goto label_10;
- case 5:
- ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
- {
- {
- "System.dio000",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
- }
- }
- },
- {
- "System.dio001",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
- }
- }
- },
- {
- "System.dio002",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
- }
- }
- },
- {
- "System.dio003",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard4.xml"
- }
- }
- },
- {
- "System.dio004",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard5.xml"
- }
- }
- }
- };
- goto label_10;
- case 6:
- ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
- {
- {
- "System.dio000",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
- }
- }
- },
- {
- "System.dio001",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
- }
- }
- },
- {
- "System.dio002",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
- }
- }
- },
- {
- "System.dio003",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard4.xml"
- }
- }
- },
- {
- "System.dio004",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard5.xml"
- }
- }
- },
- {
- "System.dio005",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard6.xml"
- }
- }
- }
- };
- goto label_10;
- case 7:
- ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
- {
- {
- "System.dio000",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCardNew.xml"
- }
- }
- },
- {
- "System.dio001",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard2.xml"
- }
- }
- },
- {
- "System.dio002",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard3.xml"
- }
- }
- },
- {
- "System.dio003",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard4.xml"
- }
- }
- },
- {
- "System.dio004",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard5.xml"
- }
- }
- },
- {
- "System.dio005",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard6.xml"
- }
- }
- },
- {
- "System.dio006",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineCard7.xml"
- }
- }
- }
- };
- goto label_10;
- }
- }
- ioMappingPathFile = new Dictionary<string, Dictionary<int, string>>()
- {
- {
- "System.dio000",
- new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefine.xml"
- }
- }
- }
- };
- label_10:
- if (Singleton<DeviceDefineManager>.Instance.GetValue<bool>("MotionAxisInstalled").GetValueOrDefault())
- ioMappingPathFile.Add("System.MotionAxis", new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineMotionAxis.xml"
- }
- });
- if (Singleton<DeviceDefineManager>.Instance.GetValue<bool>("PLCIoInstalled").GetValueOrDefault())
- ioMappingPathFile.Add("System.MainPlc", new Dictionary<int, string>()
- {
- {
- 0,
- PathManager.GetCfgDir() + SC.GetStringValue("System.DeviceType") + "\\_ioDefineMainPlc.xml"
- }
- });
- foreach (var keyValuePair in ioMappingPathFile)
- {
- //LOG.Write($"Key:{keyValuePair.Key} -- Value:{keyValuePair.Value}");
- }
- Singleton<Devices.IODevices.IoProviderManager>.Instance.Initialize(xmlConfigFile, ioMappingPathFile);
- Singleton<WaferManager>.Instance.Initialize();//框架下WaferManager的初始化
- Singleton<CarrierManager>.Instance.Initialize();
-
- Singleton<DeviceEntity>.Instance.Initialize();//设备初始化
- //Trace.WriteLine(PathManager.GetCfgDir() + "DeviceModel.xml");
- Singleton<DeviceManager>.Instance.Initialize(PathManager.GetCfgDir() + "DeviceModelNew.xml", "EFEM");
- }
- //验证设备状态的点击事件 不是很重要 后期移除
- public void GetSomeDevice()
- {
- //开一个服务用于数据的订阅
- //WaferInfo[] waferInfos = WaferManager.Instance.GetWafers(ModuleName.LP1);
- //Trace.WriteLine(waferInfos.Length);
- LoadPortBaseDevice LP = DEVICE.GetDevice<LoadPortBaseDevice>("LP2");
- if (LP == null)
- {
- Trace.WriteLine("暂无此设备");
- }
- else
- {
- Trace.WriteLine("LP设备获取完毕");
- }
- RobotBaseDevice Robot = DEVICE.GetDevice<RobotBaseDevice>("Robot");
- if (Robot == null)
- {
- Trace.WriteLine("暂无此设备");
- }
- else
- {
- Trace.WriteLine("Robot设备获取完毕");
- }
- LoadLockDevice LL1 = DEVICE.GetDevice<LoadLockDevice>("LL1");
- if (LL1 == null)
- {
- Trace.WriteLine("暂无此设备");
- }
- else
- {
- Trace.WriteLine("LL1设备获取完毕");
- }
- IoCoolingBuffer coolingBuffer1 = DEVICE.GetDevice<IoCoolingBuffer>("buffer");
- if (coolingBuffer1 == null)
- {
- Trace.WriteLine("暂无此设备");
- }
- else
- {
- Trace.WriteLine("coolingBuffer1设备获取完毕");
- }
- }
- public void StartCycle()
- {
- Singleton<RouteManager1>.Instance.PostMsg(RouteManager1.MSG.StartCycle);
- }
- /// <summary>
- /// 初始化一些数据 对获取的数据进行一个刷新
- /// </summary>
- private void GetIOCard()
- {
- DiItemList = new ObservableCollection<NotifiableIoItem>() { };
- DoItemList = new ObservableCollection<NotifiableIoItem>() { };
- AiItemList = new ObservableCollection<NotifiableIoItem>() { };
- AoItemList = new ObservableCollection<NotifiableIoItem>() { };
- //对IO数据进行获取
- List<DIAccessor> dilist = IO.GetDiList("System.dio000");
- foreach (DIAccessor diAccessor in dilist)
- DiItemList.Add(new NotifiableIoItem()
- {
- Name = diAccessor.Name,
- Index = diAccessor.Index,
- Description = diAccessor.Description,
- BoolValue = diAccessor.Value,
- Address = diAccessor.Addr
- });
- List<DOAccessor> dolist = IO.GetDoList("System.dio000");
- foreach (DOAccessor doAccessor in dolist)
- {
- DoItemList.Add(new NotifiableIoItem()
- {
- Name = doAccessor.Name,
- Index = doAccessor.Index,
- Description = doAccessor.Description,
- BoolValue = doAccessor.Value,
- Address = doAccessor.Addr
- });
- }
-
- //Trace.WriteLine(DiItemList.Count.ToString() + "" + DoItemList.Count.ToString());
- }
-
- //-------------涉及到IO数据的一些变量 要注意数据变化------------
- private ObservableCollection<NotifiableIoItem> _diItemList;
- private ObservableCollection<NotifiableIoItem> _doItemList;
- public ObservableCollection<NotifiableIoItem> DiItemList { get { return _diItemList; } set { _diItemList = value; NotifyOfPropertyChange(() => DiItemList); } }
- public ObservableCollection<NotifiableIoItem> DoItemList { get { return _doItemList; } set { _doItemList = value; NotifyOfPropertyChange(() => DoItemList); } }
- public ObservableCollection<NotifiableIoItem> AiItemList { get; set; }
- public ObservableCollection<NotifiableIoItem> AoItemList { get; set; }
- //构建sc树的逻辑
- public void GetSCTreeStatus()
- {
- List<SCConfigItem> SClist = SC.GetItemList();
- Dictionary<string, TreeChildren> scdic = new Dictionary<string, TreeChildren>();
- for (int i = 0; i < SClist.Count; i++)
- {
- TreeChildren tc1;//大类
- string headerName = SClist[i].Path.Split('.')[0];
- if (!scdic.ContainsKey(headerName))
- {
- //没有先new
- //Trace.WriteLine("添加"+ headerName);
- tc1 = new TreeChildren(headerName);
- tc1.ShowItems = new CommandBase(_showttems);
- scdic.Add(headerName, tc1);
- }
- else
- {
- //有了就加入
- scdic.TryGetValue(headerName, out tc1);
- }
- //----分割----
- if (SClist[i].Path.Contains("."))
- {
- //有点 加到子目录
- bool flag = false;
- TreeChildren tc2 = new TreeChildren();
- foreach (var itlist in tc1.Children)
- {
- if (itlist.Name == SClist[i].Path.Split('.')[1])
- {
- tc2 = itlist;
- flag = true;
- break;
- }
- }
- if (flag)
- {
- //说明有这个子类直接加到Items中
- tc2.Items.Add(SClist[i]);
- }
- else
- {
- //没有子类 新建一下
- tc2 = new TreeChildren(SClist[i].Path.Split('.')[1]);//小类
- tc2.Items.Add(SClist[i]);
- tc2.ShowItems = new CommandBase(_showttems);
- tc1.Children.Add(tc2);
- }
- }
- else
- {
- //无点 加到List
- tc1.Items.Add(SClist[i]);
- }
- }
- foreach (var item in scdic)
- {
- SCTree.Children.Add(item.Value);
- }
- }
- public class TreeChildren
- {
- public string Name { get; set; }
- public List<SCConfigItem> Items { get; set; } = new List<SCConfigItem>();
- public ObservableCollection<TreeChildren> Children { get; set; } = new ObservableCollection<TreeChildren>();
- public TreeChildren() { }
- public TreeChildren(string name)
- {
- Name = name;
- }
- public ICommand ShowItems { get; set; }
- }
- public class GridData : PropertyChangedBase
- {
- public string Header { get; set; }
- public string Description { get; set; }
- public string Name { get; set; }
- public string Type { get; set; }
- public string Unint { get; set; }
- public string Min { get; set; }
- public string Max { get; set; }
- private string _cv;
- private string _sp;
- public string CurrentValue { get { return _cv; } set { _cv = value; NotifyOfPropertyChange(() => CurrentValue); } }
- public string Setpoint { get { return _sp; } set { _sp = value; NotifyOfPropertyChange(() => Setpoint); } }
- public ICommand Comfirm { get; set; }
- }
-
- }
- }
|