| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 | 
							- 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.Diagnostics;
 
- 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 = 1000;
 
-         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;
 
-                 }
 
-             }
 
-         }
 
-         public override float Temperature
 
-         {
 
-             get
 
-             {
 
-                 return ControlTcFeedback;
 
-             }
 
-         }
 
-         [Subscription(AITChillerProperty.CoolantOutletTempFeedback)]
 
-         public override float CoolantOutletTcFeedback
 
-         {
 
-             get
 
-             {
 
-                 switch (jetChamber)
 
-                 {
 
-                     case JetChamber.VenusSE:
 
-                         return GetAiValue($"{Module}.AI_Coolant_Outlet_Temp");
 
-                     case JetChamber.VenusDE:
 
-                         return GetAiValue($"{Module}.AI_ESC_Coolant_Outlet_Temp");
 
-                     default:
 
-                         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,
 
-                     Temperature = Convert.ToInt16(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(ChillerMsgType.Get,message.GET_ALL);
 
-                     _timerQueryStatus.Start(CHK_ST_INTERVAL);
 
-                 }
 
-                 if (_driver != null && _driver.QueryData(_address) != null)
 
-                 {
 
-                     //LOG.Write(eEvent.INFO_DEVICE_CHILLER,Module,$"Address:{_address},");
 
-                     Statusflag = _driver.QueryData(_address).Statusflag;
 
-                     Alarmflag = _driver.QueryData(_address).Alarmflag;
 
-                     _controlTcFeedback = _driver.QueryData(_address).ControlTcFeedback;
 
-                 }
 
-                 else
 
-                 {
 
-                     LOG.Write(eEvent.WARN_DEVICE_CHILLER,Module,$"Address:{_address},获取的设备为空或值为空");
 
-                     return;
 
-                 }
 
-                 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];
 
-                 }
 
-             }
 
-             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(ChillerMsgType.Set, message.SET_TEMP + isettemp.ToString("X4"));
 
-             _controlTcSetPoint = value;
 
-         }
 
-         public override void SetChillerOnOff(bool on)
 
-         {
 
-             _driver.SendCmd(ChillerMsgType.Set, on ? message.SET_ON : message.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 static 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;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |