using Aitex.Core.RT.IOCore; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.IOCore; using MECF.Framework.Common.PLC; using MECF.Framework.RT.Core.IoProviders; using MECF.Framework.Simulator.Core.IoProviders; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FurnaceSimulator.Instances { public class SimulatorPlc1 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc1() { Module = ModuleName.System; } } public class SimulatorPlc2 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc2() { Module = ModuleName.System; Name = "Heater"; } } public class SimulatorPlc3 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc3() { Module = ModuleName.System; Name = "GasLine1"; } } public class SimulatorPlc4 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc4() { Module = ModuleName.System; Name = "GasLine2"; } } public class SimulatorPlc5 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc5() { Module = ModuleName.System; Name = "GasLine3"; } } public class SimulatorPlc6 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc6() { Module = ModuleName.System; Name = "GasLine4"; } } public class SimulatorPlc7 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc7() { Module = ModuleName.System; Name = "GasLine6"; } } public class SimulatorPlc8 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc8() { Module = ModuleName.System; Name = "GasLine7"; } } public class SimulatorPlc9 : SimulatorPlcService, IWcfPlcService { public SimulatorPlc9() { Module = ModuleName.System; Name = "GasLine8"; } } public class SimulatorPlcService : IWcfPlcService { public ModuleName Module { get; set; } public string Name { get; set; } = "PM1"; //diVariable="" doVariable="" aiVariable="" aoVariable="" public bool CheckIsConnected() { return true; } public bool Read(string variable, out object data, string type, int length, out string reason) { reason = string.Empty; data = null; return true; } public bool WriteArrayElement(string variable, int index, object value, out string reason) { reason = string.Empty; return true; } public bool[] ReadDi(int offset, int size, out string reason) { bool[] result = IoManager.Instance.GetDiBuffer($"{Module}.{Name}")[0]; reason = string.Empty; return result; } public float[] ReadAiFloat(int offset, int size, out string reason) { float[] result = IoManager.Instance.GetAiBufferFloat($"{Module}.{Name}")[0]; reason = string.Empty; return result; } public int[] ReadAiInt(int offset, int size, out string reason) { reason = string.Empty; return null; } public short[] ReadAiInt16(int offset, int size, out string reason) { short[] result = IoManager.Instance.GetAiBuffer($"{Module}.{Name}")[0]; reason = string.Empty; return result; } public bool WriteDo(int offset, bool[] buffer, out string reason) { reason = string.Empty; for (int i = 0; i < buffer.Length && i < IoManager.Instance.GetDoBuffer($"{Module}.{Name}")[0].Length; i++) { IoManager.Instance.GetDoBuffer($"{Module}.{Name}")[0][i] = buffer[i]; } return true; } public bool WriteAoFloat(int offset, float[] buffer, out string reason) { reason = string.Empty; for (int i = 0; i < buffer.Length && i < IoManager.Instance.GetAoBufferFloat($"{Module}.{Name}")[0].Length; i++) { IoManager.Instance.GetAoBufferFloat($"{Module}.{Name}")[0][i] = buffer[i]; } return true; } public bool WriteAoInt(int offset, int[] buffer, out string reason) { reason = string.Empty; return true; } public bool WriteAoInt16(int offset, short[] buffer, out string reason) { reason = string.Empty; for (int i = 0; i < buffer.Length && i < IoManager.Instance.GetAoBuffer($"{Module}.{Name}")[0].Length; i++) { IoManager.Instance.GetAoBuffer($"{Module}.{Name}")[0][i] = buffer[i]; } return true; } public int Heartbeat(int counter) { return counter; } } }