|
@@ -29,6 +29,11 @@ namespace Venus_RT.Devices
|
|
|
|
|
|
|
|
|
|
|
|
+ public enum ChillerMsgType
|
|
|
+ {
|
|
|
+ Get,
|
|
|
+ Set
|
|
|
+ }
|
|
|
public class SMCChillerDrive
|
|
|
{
|
|
|
|
|
@@ -42,6 +47,7 @@ namespace Venus_RT.Devices
|
|
|
|
|
|
private Dictionary<string,string> _address2Module;
|
|
|
private Dictionary<string, ChillerData> _addressQuery;
|
|
|
+ private Dictionary<string, Queue<string>> _addressCmdQueue;
|
|
|
private ModuleName Module;
|
|
|
|
|
|
|
|
@@ -67,6 +73,7 @@ namespace Venus_RT.Devices
|
|
|
_address2Module = new Dictionary<string, string>();
|
|
|
_addressQuery = new Dictionary<string, ChillerData>();
|
|
|
|
|
|
+
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
foreach (var data in blockingCollection.GetConsumingEnumerable())
|
|
@@ -178,6 +185,7 @@ namespace Venus_RT.Devices
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ _addressCmdQueue[header].Dequeue();
|
|
|
_addressQuery[header] = chillerdata;
|
|
|
}
|
|
|
break;
|
|
@@ -199,12 +207,31 @@ namespace Venus_RT.Devices
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void SendCmd(string str)
|
|
|
+ public void SendCmd(ChillerMsgType type,string str)
|
|
|
{
|
|
|
|
|
|
|
|
|
- LOG.Write(eEvent.INFO_DEVICE_CHILLER,ModuleName.System, "Send Cmd => :" + str + ModbusUtility.CalculateLrc(ModbusUtility.HexToBytes(str)).ToString("X2"));
|
|
|
- blockingCollection.Add(":" + str + ModbusUtility.CalculateLrc(ModbusUtility.HexToBytes(str)).ToString("X2") + "\r\n");
|
|
|
+
|
|
|
+ if (type == ChillerMsgType.Set)
|
|
|
+ {
|
|
|
+ blockingCollection.Add(":" + str + ModbusUtility.CalculateLrc(ModbusUtility.HexToBytes(str)).ToString("X2") + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (type == ChillerMsgType.Get)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ _addressCmdQueue[str.Substring(1, 2)].Enqueue(str);
|
|
|
+ if (_addressCmdQueue[str.Substring(1, 2)].Count > 2)
|
|
|
+ _addressCmdQueue[str.Substring(1, 2)].Dequeue();
|
|
|
+ else
|
|
|
+ blockingCollection.Add(":" + _addressCmdQueue[str.Substring(1, 2)].Peek() + ModbusUtility.CalculateLrc(ModbusUtility.HexToBytes(str)).ToString("X2") + "\r\n");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void AddAddress(string address, string chillertype)
|
|
@@ -212,6 +239,7 @@ namespace Venus_RT.Devices
|
|
|
|
|
|
_address2Module.Add(address,chillertype);
|
|
|
_addressQuery.Add(address, new ChillerData());
|
|
|
+ _addressCmdQueue.Add(address, new Queue<string>());
|
|
|
}
|
|
|
|
|
|
public ChillerData QueryData(string address)
|