| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | 
							- using System;
 
- using System.Threading;
 
- using MECF.Framework.Simulator.Core.Driver;
 
- using PunkHPX8_Simulator.Instances;
 
- using Aitex.Core.RT.SCCore;
 
- using MECF.Framework.Common.SCCore;
 
- using MECF.Framework.Common.DataCenter;
 
- using Aitex.Core.Util;
 
- using System.IO;
 
- namespace PunkHPX8_Simulator.Devices
 
- {
 
-     class AIRSYSChillerMock : SerialPortDeviceSimulator
 
-     {
 
-         public enum AIRSYSChillerStatus
 
-         {
 
-             Open,
 
-             Close,
 
-         }
 
-         public static AIRSYSChillerStatus _simPumpStatus;
 
-         private const string EOF = "\r";
 
-         private const char MSG_DELIMITER = ' ';
 
-         //private const string MOCKUP_PORT = "COM43";
 
-         private int _temperature = 0;
 
-         public AIRSYSChillerMock(string port) : base(port, -1, EOF, MSG_DELIMITER)
 
-         {
 
-             _simPumpStatus = AIRSYSChillerStatus.Close;
 
-         }
 
-         protected override void ProcessUnsplitMessage(string message)
 
-         {
 
-             if (string.IsNullOrEmpty(message))
 
-                 throw new ArgumentException("Hardware command message is invalid");
 
-             string sRes = string.Empty;
 
-             string[] separatingStrings = { EOF };
 
-             string[] msgs = message.Trim().Split(separatingStrings, System.StringSplitOptions.RemoveEmptyEntries);
 
-             foreach (var msg in msgs)
 
-             {
 
-                 if (msg.StartsWith("AA90"))
 
-                 {
 
-                     _simPumpStatus = AIRSYSChillerStatus.Open;
 
-                     sRes = "AA90\r";
 
-                     int temp = Convert.ToInt32(msg.Substring(9, 8), 16);
 
-                     SetTemp(temp);
 
-                 }
 
-                 else if(msg.StartsWith("AA91"))
 
-                 {
 
-                     _simPumpStatus = AIRSYSChillerStatus.Close;
 
-                     sRes = "AA91\r";
 
-                 }
 
-                 else if (msg.StartsWith("AA42"))
 
-                 {
 
-                     //QUERY STATUS
 
-                     _simPumpStatus = AIRSYSChillerStatus.Open;
 
-                     sRes = "AA4200DE\r";
 
-                 }
 
-                 else if (msg.StartsWith("AA10"))
 
-                 {
 
-                     //QUERY TEMPERATURE
 
-                     sRes = string.Format("AA10{0:X4}\r", _temperature);
 
-                 }
 
-                 else if (msg.StartsWith("AAB0"))
 
-                 {
 
-                     //Set Temperature
 
-                     _temperature = Int32.Parse(msg.Substring(4, 4), System.Globalization.NumberStyles.HexNumber);
 
-                     sRes = "AAB0\r";
 
-                 }
 
-             }
 
-             OnWriteMessage(sRes);
 
-         }
 
-         void SetTemp(int temp)
 
-         {
 
-             string module = PortName == "COM47" ? "PMA" : "PMB";
 
-             double _OffsetTemp = SystemConfig.Instance.GetValue<double>($"{module}.Chiller.ChillerTemperatureOffset");
 
-             SimulatorSystem.Instance.SetCoolantOutletTemp(module, temp / 10 + (int)_OffsetTemp);
 
-         }
 
-     }
 
- }
 
 
  |