using System; using System.IO; using Aitex.Core.RT.Device; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.SCCore; using MECF.Framework.Common.Equipment; using SorterRT.Modules; using Virgo_DRT.Devices; namespace Virgo_DRT.Instances { public class DeviceEntity : DeviceEntityT { public DeviceEntity() { } } public class DeviceManager : DeviceManagerBase { private readonly string device_model_file; public DeviceManager() { device_model_file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config\\", RtInstance.DeviceModelFileName); } public override bool Initialize() { if (SC.GetValue("System.PMAIsInstalled")) InitPM(ModuleName.PMA); if (SC.GetValue("System.PMBIsInstalled")) InitPM(ModuleName.PMB); OP.Subscribe("DeviceOperation", this.Invoke); return true; } private void InitPM(ModuleName mod) { Initialize(device_model_file, RtInstance.SystemName, mod, mod.ToString()); if (SC.GetValue($"{mod}.Rf.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.Rf.MFG") == (int)GeneratorMFG.AdTec) { AddCustomModuleDevice(new AdTecGenerator(mod)); } if (SC.GetValue($"{mod}.match.EnableMatch") && SC.GetValue($"{mod}.match.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.match.MFG") == (int)MatchMFG.AdTec) { AddCustomModuleDevice(new AdTecMatch(mod)); } if (SC.GetValue($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY) { AddCustomModuleDevice(new SkyPump(mod)); } else if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards) { AddCustomModuleDevice(new EdwardsPump(mod)); } } AddCustomDevice(new JetPM(mod)); } private bool Invoke(string arg1, object[] args) { string name = (string)args[0]; string func = (string)args[1]; object[] param = new object[args.Length - 2]; for (int i = 2; i < args.Length; i++) param[i - 2] = args[i].ToString(); DEVICE.Do(string.Format("{0}.{1}", name, func), 0, true, param); return true; } } }