|
@@ -0,0 +1,143 @@
|
|
|
+using Aitex.Core.Common.DeviceData;
|
|
|
+using Aitex.Core.RT.Device;
|
|
|
+using Aitex.Core.RT.IOCore;
|
|
|
+using Aitex.Core.RT.SCCore;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Xml;
|
|
|
+
|
|
|
+namespace Venus_RT.Devices.IODevices
|
|
|
+{
|
|
|
+
|
|
|
+ public class IoHongHuControl : BaseDevice, IDevice
|
|
|
+ {
|
|
|
+ private bool _lastValue;
|
|
|
+
|
|
|
+ private SCConfigItem _scWriteMode;
|
|
|
+ private SCConfigItem _scTargetMFC;
|
|
|
+ private SCConfigItem _scTargetPressure;
|
|
|
+ private readonly DOAccessor _FlowMode;
|
|
|
+ private readonly DOAccessor _PressureMode;
|
|
|
+ private readonly AOAccessor _MFCSetPoint;
|
|
|
+ private readonly AOAccessor _PressureSetPoint;
|
|
|
+
|
|
|
+
|
|
|
+ public IoHongHuControl(string module, XmlElement node, string ioModule = "")
|
|
|
+ {
|
|
|
+ base.Module = module;
|
|
|
+ base.Name = node.GetAttribute("id");
|
|
|
+ base.Display = node.GetAttribute("display");
|
|
|
+ base.DeviceID = node.GetAttribute("schematicId");
|
|
|
+
|
|
|
+ _scWriteMode = SC.GetConfigItem($"{Module}.{Name}.ControlWriteMode");
|
|
|
+ _scTargetMFC = SC.GetConfigItem($"{Module}.{Name}.TargetMFC");
|
|
|
+ _scTargetPressure = SC.GetConfigItem($"{Module}.{Name}.TargetPressure");
|
|
|
+
|
|
|
+
|
|
|
+ _FlowMode = ParseDoNode("doMFCFlow", node, ioModule);
|
|
|
+ _PressureMode = ParseDoNode("doPressureMode", node, ioModule);
|
|
|
+ _MFCSetPoint = ParseAoNode("aoMFCFlow", node, ioModule);
|
|
|
+ _PressureSetPoint = ParseAoNode("aoPressure", node, ioModule);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public bool Initialize()
|
|
|
+ {
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Monitor()
|
|
|
+ {
|
|
|
+
|
|
|
+ if (_scWriteMode.BoolValue)
|
|
|
+ {
|
|
|
+ if(_FlowMode != null && _FlowMode.Value !=true)
|
|
|
+ _FlowMode.SetValue(true,out string _);
|
|
|
+ if (_PressureMode != null && _PressureMode.Value != false)
|
|
|
+ _PressureMode.SetValue(false,out _);
|
|
|
+ if (_MFCSetPoint != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ byte[] flow;
|
|
|
+ flow = BitConverter.GetBytes(float.Parse(_scTargetMFC.Value.ToString()));
|
|
|
+ _MFCSetPoint.Buffer[_MFCSetPoint.Index] = BitConverter.ToInt16(flow, 0);
|
|
|
+ _MFCSetPoint.Buffer[_MFCSetPoint.Index + 1] = BitConverter.ToInt16(flow, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (_FlowMode != null && _FlowMode.Value != false)
|
|
|
+ _FlowMode.SetValue(false, out string _);
|
|
|
+ if (_PressureMode != null && _PressureMode.Value != true)
|
|
|
+ _PressureMode.SetValue(true, out string _);
|
|
|
+ if (_PressureSetPoint != null )
|
|
|
+ {
|
|
|
+ byte[] pressure;
|
|
|
+ pressure = BitConverter.GetBytes(float.Parse(_scTargetPressure.Value.ToString()));
|
|
|
+ _PressureSetPoint.Buffer[_PressureSetPoint.Index] = BitConverter.ToInt16(pressure, 0);
|
|
|
+ _PressureSetPoint.Buffer[_PressureSetPoint.Index + 1] = BitConverter.ToInt16(pressure, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ _lastValue = _scWriteMode.BoolValue;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Reset()
|
|
|
+ {
|
|
|
+ if (_FlowMode != null && _FlowMode.Value != true)
|
|
|
+ _FlowMode.SetValue(true, out string _);
|
|
|
+ if (_PressureMode != null && _PressureMode.Value != false)
|
|
|
+ _PressureMode.SetValue(false, out _);
|
|
|
+ if (_MFCSetPoint != null)
|
|
|
+ {
|
|
|
+ byte[] flow;
|
|
|
+ flow = BitConverter.GetBytes(float.Parse("0"));
|
|
|
+ _MFCSetPoint.Buffer[_MFCSetPoint.Index] = BitConverter.ToInt16(flow, 0);
|
|
|
+ _MFCSetPoint.Buffer[_MFCSetPoint.Index + 1] = BitConverter.ToInt16(flow, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Terminate()
|
|
|
+ {
|
|
|
+ if (_FlowMode != null && _FlowMode.Value != true)
|
|
|
+ _FlowMode.SetValue(true, out string _);
|
|
|
+ if (_PressureMode != null && _PressureMode.Value != false)
|
|
|
+ _PressureMode.SetValue(false, out _);
|
|
|
+ if (_MFCSetPoint != null)
|
|
|
+ {
|
|
|
+ byte[] flow;
|
|
|
+ flow = BitConverter.GetBytes(float.Parse("0"));
|
|
|
+ _MFCSetPoint.Buffer[_MFCSetPoint.Index] = BitConverter.ToInt16(flow, 0);
|
|
|
+ _MFCSetPoint.Buffer[_MFCSetPoint.Index + 1] = BitConverter.ToInt16(flow, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|