|
@@ -0,0 +1,385 @@
|
|
|
+using Aitex.Core.Common.DeviceData;
|
|
|
+using Aitex.Core.RT.Log;
|
|
|
+using Aitex.Core.RT.SCCore;
|
|
|
+using Aitex.Core.RT.Tolerance;
|
|
|
+using Aitex.Core.Util;
|
|
|
+using MECF.Framework.Common.Device.Bases;
|
|
|
+using MECF.Framework.Common.Equipment;
|
|
|
+using System;
|
|
|
+using System.Collections.Concurrent;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.ServiceModel.Channels;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using Venus_Core;
|
|
|
+
|
|
|
+namespace Venus_RT.Devices
|
|
|
+{
|
|
|
+ public class SMCShareChiller : ChillerBase
|
|
|
+ {
|
|
|
+ private SMCChillerDrive _driver;
|
|
|
+ private string _address;
|
|
|
+ private readonly DeviceTimer _timerQueryStatus = new DeviceTimer();
|
|
|
+ private const ushort CHK_ST_INTERVAL = 500;
|
|
|
+ bool[] Statusflag = new bool[32];
|
|
|
+ bool[] LastStatusflag = new bool[32];
|
|
|
+ bool[] Alarmflag = new bool[48];
|
|
|
+ bool[] LastAlarmflag = new bool[48];
|
|
|
+ string[] AlarmMsg = new string[48];
|
|
|
+ bool[] NeedToStop = new bool[48];
|
|
|
+ private ToleranceChecker _toleranceChecker = new ToleranceChecker();
|
|
|
+ private float _controlTcSetPoint;
|
|
|
+ private float _controlTcFeedback;
|
|
|
+ private readonly double _scSetPointLimitMax;
|
|
|
+ private readonly double _scSetPointLimitMin;
|
|
|
+ private SCConfigItem _scAlarmRange;
|
|
|
+ private SCConfigItem _scEnableAlarm;
|
|
|
+ private SCConfigItem _scAlarmTime;
|
|
|
+ private bool chillerIsOn;
|
|
|
+ JetChamber jetChamber;
|
|
|
+ private SMCMutiChillerMessage message;
|
|
|
+ public SMCChillerState StatusSMC{get; private set;}
|
|
|
+
|
|
|
+
|
|
|
+ public double SetPointLimitMax
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return _scSetPointLimitMax; ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public double SetPointLimitMin
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return _scSetPointLimitMin; ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Subscription(AITChillerProperty.IsRunning)]
|
|
|
+ public override bool IsRunning
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return chillerIsOn;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Subscription(AITChillerProperty.IsError)]
|
|
|
+ public override bool IsError
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return StatusSMC == SMCChillerState.ERROR || StatusSMC == SMCChillerState.Disconnected;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Subscription(AITChillerProperty.ControlTcSetPoint)]
|
|
|
+ public float ControlTcSetPoint
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return _controlTcSetPoint;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Subscription(AITChillerProperty.ControlTcFeedback)]
|
|
|
+ public float ControlTcFeedback
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return _controlTcFeedback;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Subscription(AITChillerProperty.CoolantInletTempFeedback)]
|
|
|
+ public override float CoolantInletTcFeedback
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (jetChamber == JetChamber.VenusSE)
|
|
|
+ {
|
|
|
+ return GetAiValue($"{Module}.AI_Coolant_Inlet_Temp");
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ [Subscription(AITChillerProperty.CoolantOutletTempFeedback)]
|
|
|
+ public override float CoolantOutletTcFeedback
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (jetChamber == JetChamber.VenusSE)
|
|
|
+ {
|
|
|
+ return GetAiValue($"{Module}.AI_Coolant_Outlet_Temp");
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public override AITChillerData DeviceData
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ AITChillerData deviceData = new AITChillerData
|
|
|
+ {
|
|
|
+ Module = Module,
|
|
|
+ DeviceName = Name,
|
|
|
+ DeviceModule = Module,
|
|
|
+ DeviceSchematicId = DeviceID,
|
|
|
+ DisplayName = Display,
|
|
|
+ IsError = false,
|
|
|
+ IsWarning = false,
|
|
|
+ IsPowerOn = IsRunning,
|
|
|
+ ScaleMax = SetPointLimitMax,
|
|
|
+ ScaleMin = SetPointLimitMin,
|
|
|
+ SetPoint = ControlTcSetPoint,
|
|
|
+ FeedBack = CoolantOutletTcFeedback,
|
|
|
+ CoolantInletFeedBack = CoolantInletTcFeedback,
|
|
|
+ CoolantOutletFeedBack = CoolantOutletTcFeedback,
|
|
|
+ Unit = "℃",
|
|
|
+ };
|
|
|
+
|
|
|
+ return deviceData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public SMCShareChiller(ModuleName mod, string name) : base(mod.ToString(), name, name, "")
|
|
|
+ {
|
|
|
+ _address = SC.GetStringValue($"{mod}.{Name}.Address");
|
|
|
+ _driver = ChillerFactory.QuoteDrive(SC.GetStringValue($"{mod}.{Name}.Port"), _address, $"{mod}.{Name}");
|
|
|
+ _scSetPointLimitMax = SC.GetValue<double>($"{mod}.{name}.SetPointLimitMax");
|
|
|
+ _scSetPointLimitMin = SC.GetValue<double>($"{mod}.{name}.SetPointLimitMin");
|
|
|
+ _scEnableAlarm = SC.GetConfigItem($"{mod}.{name}.EnableToleranceAlarm");
|
|
|
+ _scAlarmRange = SC.GetConfigItem($"{mod}.{name}.ToleranceAlarmRange");
|
|
|
+ _scAlarmTime = SC.GetConfigItem($"{mod}.{name}.ToleranceAlarmTime");
|
|
|
+ jetChamber = (JetChamber)SC.GetValue<int>($"{mod}.ChamberType");
|
|
|
+ message = new SMCMutiChillerMessage(_address);
|
|
|
+ _timerQueryStatus.Start(CHK_ST_INTERVAL);
|
|
|
+ SetAlarmMsg();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public override void Monitor()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (_timerQueryStatus.IsTimeout() && StatusSMC != SMCChillerState.ERROR)
|
|
|
+ {
|
|
|
+ _driver.SendCmd(message.GET_ALL);
|
|
|
+ _timerQueryStatus.Start(CHK_ST_INTERVAL);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_driver != null)
|
|
|
+ {
|
|
|
+ Statusflag = _driver.QueryData(_address).Statusflag;
|
|
|
+ Alarmflag = _driver.QueryData(_address).Alarmflag;
|
|
|
+ _controlTcFeedback = _driver.QueryData(_address).ControlTcFeedback;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (Statusflag[0])
|
|
|
+ {
|
|
|
+ StatusSMC = SMCChillerState.ON;
|
|
|
+ chillerIsOn = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ else
|
|
|
+ {
|
|
|
+ StatusSMC = SMCChillerState.OFF;
|
|
|
+ chillerIsOn = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < 48; i++)
|
|
|
+ {
|
|
|
+ if (Alarmflag[i])
|
|
|
+ StatusSMC = SMCChillerState.ERROR;
|
|
|
+ if (Alarmflag[i] && !LastAlarmflag[i])//取报警信号上升沿
|
|
|
+ {
|
|
|
+ //报警一次
|
|
|
+ if (NeedToStop[i])
|
|
|
+ LOG.Write(eEvent.ERR_DEVICE_CHILLER, Module, AlarmMsg[i]);
|
|
|
+ else
|
|
|
+ LOG.Write(eEvent.WARN_DEVICE_CHILLER, Module, AlarmMsg[i]);
|
|
|
+ }
|
|
|
+ LastAlarmflag[i] = Alarmflag[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (IsRunning && _scEnableAlarm != null && _scEnableAlarm.BoolValue)
|
|
|
+ {
|
|
|
+ var range = _scAlarmRange.IntValue;
|
|
|
+ var time = _scAlarmTime.IntValue;
|
|
|
+ _toleranceChecker.Monitor(_controlTcFeedback, _controlTcSetPoint - Math.Abs(range), _controlTcSetPoint + Math.Abs(range), time);
|
|
|
+
|
|
|
+ if (_toleranceChecker.Trig)
|
|
|
+ {
|
|
|
+ LOG.Write(eEvent.ERR_DEVICE_CHILLER, Module, Display + $" temperature out of tolerance in {time:0} seconds");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _toleranceChecker.RST = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LOG.Write(eEvent.ERR_DEVICE_CHILLER, Module, ex.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public override void Reset()
|
|
|
+ {
|
|
|
+ _toleranceChecker.RST = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void SetChillerTemp(float value, float offset)
|
|
|
+ {
|
|
|
+ int isettemp = Convert.ToInt16((value - offset) * 10);
|
|
|
+ _driver.SendCmd(message.SET_TEMP + isettemp.ToString("X4"));
|
|
|
+ _controlTcSetPoint = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void SetChillerOnOff(bool on)
|
|
|
+ {
|
|
|
+ _driver.SendCmd(on ? message.SET_ON : SMCChillerMessage.SET_OFF);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetAlarmMsg()
|
|
|
+ {
|
|
|
+ AlarmMsg[0] = "Low level in tank";
|
|
|
+ AlarmMsg[1] = "High circulating fluid discharge temp";
|
|
|
+ AlarmMsg[2] = "Circulating fluid discharge temp. rise";
|
|
|
+ AlarmMsg[3] = "Circulating fluid discharge temp.";
|
|
|
+ AlarmMsg[4] = "High circulating fluid return temp.";
|
|
|
+ AlarmMsg[5] = "High circulating fluid discharge pressure";
|
|
|
+ AlarmMsg[6] = "Abnormal pump operation";
|
|
|
+ AlarmMsg[7] = "Circulating fluid discharge pressure rise";
|
|
|
+ AlarmMsg[8] = "Circulating fluid discharge pressure drop";
|
|
|
+ AlarmMsg[9] = "High compressor intake temp.";
|
|
|
+ AlarmMsg[10] = "Low compressor intake temp.";
|
|
|
+ AlarmMsg[11] = "Low super heat temperature";
|
|
|
+ AlarmMsg[12] = "High compressor discharge pressure";
|
|
|
+ //AlarmMsg[13] Unused
|
|
|
+ AlarmMsg[14] = "Refrigerant circuit pressure (high pressure side) drop";
|
|
|
+ AlarmMsg[15] = "Refrigerant circuit pressure (low pressure side) rise";
|
|
|
+
|
|
|
+ AlarmMsg[16] = "Refrigerant circuit pressure (low pressure side) drop";
|
|
|
+ AlarmMsg[17] = "Compressor overload";
|
|
|
+ AlarmMsg[18] = "Communication error";
|
|
|
+ AlarmMsg[19] = "Memory error";
|
|
|
+ AlarmMsg[20] = "DC line fuse cut";
|
|
|
+ AlarmMsg[21] = "Circulating fluid discharge temp. sensor failure";
|
|
|
+ AlarmMsg[22] = "Circulating fluid return temp. sensor failure";
|
|
|
+ AlarmMsg[23] = "Compressor intake temp. sensor failure";
|
|
|
+ AlarmMsg[24] = "Circulating fluid discharge pressure sensor failure";
|
|
|
+ AlarmMsg[25] = "Compressor discharge pressure sensor failure";
|
|
|
+ AlarmMsg[26] = "Compressor intake pressure sensor failure";
|
|
|
+ AlarmMsg[27] = "Maintenance of pump";
|
|
|
+ AlarmMsg[28] = "Maintenance of fan motor";
|
|
|
+ AlarmMsg[29] = "Maintenance of compressor";
|
|
|
+ AlarmMsg[30] = "Contact input 1 signal detection alarm";
|
|
|
+ AlarmMsg[31] = "Contact input 2 signal detection alarm";
|
|
|
+
|
|
|
+ AlarmMsg[32] = "Water leakage";
|
|
|
+ AlarmMsg[33] = "Electric resistivity/conductivity level rise";
|
|
|
+ AlarmMsg[34] = "Electric resistivity/conductivity level drop";
|
|
|
+ AlarmMsg[35] = "Electric resistivity/conductivity sensor error";
|
|
|
+ //AlarmMsg[36] Unused
|
|
|
+
|
|
|
+ NeedToStop[0] = true;
|
|
|
+ NeedToStop[1] = true;
|
|
|
+ NeedToStop[4] = true;
|
|
|
+ NeedToStop[5] = true;
|
|
|
+ NeedToStop[6] = true;
|
|
|
+ NeedToStop[9] = true;
|
|
|
+ NeedToStop[10] = true;
|
|
|
+ NeedToStop[11] = true;
|
|
|
+ NeedToStop[12] = true;
|
|
|
+ NeedToStop[14] = true;
|
|
|
+ NeedToStop[15] = true;
|
|
|
+ NeedToStop[16] = true;
|
|
|
+ NeedToStop[17] = true;
|
|
|
+ NeedToStop[19] = true;
|
|
|
+ NeedToStop[20] = true;
|
|
|
+ NeedToStop[21] = true;
|
|
|
+ NeedToStop[22] = true;
|
|
|
+ NeedToStop[23] = true;
|
|
|
+ NeedToStop[24] = true;
|
|
|
+ NeedToStop[25] = true;
|
|
|
+ NeedToStop[26] = true;
|
|
|
+ NeedToStop[30] = true;
|
|
|
+ NeedToStop[31] = true;
|
|
|
+ NeedToStop[32] = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public class SMCMutiChillerMessage
|
|
|
+ {
|
|
|
+ public string Start = ":";
|
|
|
+ public string End = "\r\n";
|
|
|
+ public string SlaveAddress = "00";
|
|
|
+ public string Function_R_M = "03";
|
|
|
+ public string Function_W_S = "06";
|
|
|
+ public string Function_W_M = "10";
|
|
|
+ public string Function_RW_M = "17";
|
|
|
+ public string Data_Address_GetTemp = "0000";
|
|
|
+ public string Data_Address_GetPress = "0002";
|
|
|
+ public string Data_Address_GetElec = "0003";
|
|
|
+ public string Data_Address_Status1 = "0004";
|
|
|
+ public string Data_Address_Alarm1 = "0005";
|
|
|
+ public string Data_Address_Alarm2 = "0006";
|
|
|
+ public string Data_Address_Alarm3 = "0007";
|
|
|
+ public string Data_Address_Status2 = "0009";
|
|
|
+ public string Data_Address_SetTemp = "000B";
|
|
|
+ public string Data_Address_SetRun = "000C";
|
|
|
+
|
|
|
+ public string SET_ON => SlaveAddress + Function_W_S + Data_Address_SetRun + "0001";
|
|
|
+ public string SET_OFF => SlaveAddress + Function_W_S + Data_Address_SetRun + "0000";
|
|
|
+ public string SET_TEMP => SlaveAddress + Function_W_S + Data_Address_SetTemp;
|
|
|
+ public string GET_ALL => SlaveAddress + Function_R_M + Data_Address_GetTemp + "000B";
|
|
|
+
|
|
|
+ public SMCMutiChillerMessage(string SlaveAddress)
|
|
|
+ {
|
|
|
+ this.SlaveAddress = SlaveAddress;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ChillerFactory
|
|
|
+ {
|
|
|
+ private static Dictionary<string, SMCChillerDrive> port2share = new Dictionary<string, SMCChillerDrive>();
|
|
|
+
|
|
|
+ public static SMCChillerDrive QuoteDrive(string portname, string address, string chillertype)
|
|
|
+ {
|
|
|
+ if (port2share.ContainsKey(portname))
|
|
|
+ {
|
|
|
+ port2share[portname].AddAddress(address, chillertype);
|
|
|
+ return port2share[portname];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //不包含该参数
|
|
|
+ SMCChillerDrive sMCChillerDrive = new SMCChillerDrive(portname);
|
|
|
+ port2share.Add(portname, sMCChillerDrive);
|
|
|
+ sMCChillerDrive.AddAddress(address, chillertype);
|
|
|
+ return sMCChillerDrive;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|