using System; using System.Xml; using Aitex.Core.RT.Device; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.OperationCenter; namespace Aitex.Core.RT.Device.Unit { public class IoGasStick : BaseDevice, IDevice { private readonly IoValve _DownValve; private readonly MfcBase1 _mfc; // Properties // public double FlowSP { get => _mfc.SetPoint; //set => _mfc.SetPoint = value; } public bool IsOutOfRange => _mfc.IsOutOfTolerance; // Constructor // public IoGasStick(string module, XmlElement node, string ioModule = "") { base.Module = module; base.Name = node.GetAttribute("id"); base.Display = node.GetAttribute("display"); base.DeviceID = node.GetAttribute("schematicId"); _DownValve = ParseDeviceNode(Module, "downvalve", node); _mfc = ParseDeviceNode(Module, "mfc", node); } public bool Initialize() { OP.Subscribe($"{Module}.{_mfc.Name}", (out string reason, int time, object[] para) => { reason = ""; double sp = Convert.ToDouble((string)para[0]); Flow(sp); return true; }); return true; } public void Flow(double setpoint) { if (setpoint >= 0.01) { _DownValve.TurnValve(true, out _); //this.FlowSP = setpoint; } else { _DownValve.TurnValve(false, out _); } _mfc.Ramp(setpoint, 1000); } public void Monitor() { _DownValve.Monitor(); _mfc.Monitor(); } public void Terminate() { } public void Reset() { } public void Stop() { _DownValve.TurnValve(false, out _); _mfc.Ramp(0, 1000); } } }