|
|
@ -13,7 +13,7 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
public FireControlClient()
|
|
|
|
public FireControlClient()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ReadAction = BatchRead;
|
|
|
|
ReadAction = BatchRead;
|
|
|
|
Ip = "172.0.50.101";
|
|
|
|
Ip = "172.0.50.100";
|
|
|
|
Port = 502;
|
|
|
|
Port = 502;
|
|
|
|
Duration = 1000;
|
|
|
|
Duration = 1000;
|
|
|
|
AutoReConnect = true;
|
|
|
|
AutoReConnect = true;
|
|
|
@ -23,46 +23,129 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
|
|
|
|
|
|
|
private void BatchRead(ModbusTcpMaster master)
|
|
|
|
private void BatchRead(ModbusTcpMaster master)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var bytes02 = master.BatchReadHolderRegister(1, 17);//0x01
|
|
|
|
Log.Info("fire start read");
|
|
|
|
var bytes03 = master.BatchReadHolderRegister(1, 3);//0x03
|
|
|
|
var bytes02 = master.ReadCoil("0x0000", 17).Content;//0x01
|
|
|
|
var bytes04 = master.BatchReadHolderRegister(0x0100, 383);//0x03
|
|
|
|
var bytes03 = master.BatchReadHolderRegister(1, 3);//0x03 读1 3
|
|
|
|
var bytes05 = master.BatchReadHolderRegister(1, 115);//0x04
|
|
|
|
var bytes04 = master.BatchReadHolderRegister(0x0100, 383);//0x03 读256 383
|
|
|
|
var bytes06 = master.BatchReadHolderRegister(0x0800, 2048);//0x04
|
|
|
|
var bytes05 = master.BatchReadHolderRegister(1, 115);//0x04 可以
|
|
|
|
var bytes07 = master.BatchReadHolderRegister(0x1000, 32);//0x04
|
|
|
|
|
|
|
|
var bytes08 = master.BatchReadHolderRegister(0x0000, 134);//0x05
|
|
|
|
|
|
|
|
var bytes09 = master.BatchReadHolderRegister(0x0100, 64);//0x06
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<byte> bytes06=new List<byte>();//= master.BatchReadHolderRegister(0x0800, 2048);//0x04 可以
|
|
|
|
|
|
|
|
var bytesAdd1 = master.BatchReadHolderRegister(0x0800, 1000);//0x04 可以
|
|
|
|
|
|
|
|
var bytesAdd2 = master.BatchReadHolderRegister(3048, 1048);//0x04 可以
|
|
|
|
|
|
|
|
bytes06.AddRange(bytesAdd1);
|
|
|
|
|
|
|
|
bytes06.AddRange(bytesAdd2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bytes07 = master.BatchReadHolderRegister(0x1000, 32);//0x04 可以
|
|
|
|
|
|
|
|
var bytes08 = master.BatchReadHolderRegister(0x0000, 134);//0x05 写
|
|
|
|
|
|
|
|
var bytes09 = master.BatchReadHolderRegister(0x0100, 64);//0x06 写
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
if (bytes02 != null)
|
|
|
|
if (bytes02 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModbusDecoder.Decode<Subzone2>(bytes02, FireControlMgr.Subzone2, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
Log.Info("fire read bytes02 success");
|
|
|
|
|
|
|
|
//ModbusDecoder.Decode<Subzone2>(bytes02, FireControlMgr.Subzone2, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.GiveAnAlarm.Value = bytes02[0];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.NumberOfFailures.Value = bytes02[1];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.SoundSuppression.Value = bytes02[2];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.SelfInspection.Value = bytes02[3];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.MainPower.Value = bytes02[4];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.PowerSupplyBackup.Value = bytes02[5];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.BackupPowerUnderpowered.Value = bytes02[6];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.AutomaticMode.Value = bytes02[7];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.ManualMode.Value = bytes02[8];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.ManualStart.Value = bytes02[9];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.ManualScram.Value = bytes02[10];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.StartUpControl.Value = bytes02[11];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.Delay.Value = bytes02[12];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.PrimingSpray.Value = bytes02[13];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.Spray.Value = bytes02[14];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.AudibleVisualAlarmStatus.Value = bytes02[15];
|
|
|
|
|
|
|
|
FireControlMgr.Subzone2.DeflatedDoNotEnter.Value = bytes02[16];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fire read bytes02 erroe{e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
if (bytes03 != null)
|
|
|
|
if (bytes03 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModbusDecoder.Decode<Subzone3>(bytes03, FireControlMgr.Subzone3, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
ModbusDecoder.Decode<Subzone3>(bytes03, FireControlMgr.Subzone3, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fire read bytes03 erroe{e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
if (bytes04 != null)
|
|
|
|
if (bytes04 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModbusDecoder.Decode<Subzone4>(bytes04, FireControlMgr.Subzone4, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
ModbusDecoder.Decode<Subzone4>(bytes04, FireControlMgr.Subzone4, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fire read bytes04 erroe{e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
if (bytes05 != null)
|
|
|
|
if (bytes05 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModbusDecoder.Decode<Subzone5>(bytes05, FireControlMgr.Subzone5, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
ModbusDecoder.Decode<Subzone5>(bytes05, FireControlMgr.Subzone5, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fire read bytes05 erroe{e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
if (bytes06 != null)
|
|
|
|
if (bytes06 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModbusDecoder.Decode<Subzone6>(bytes06, FireControlMgr.Subzone6, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
ModbusDecoder.Decode<Subzone6>(bytes06.ToArray(), FireControlMgr.Subzone6, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fire read bytes06 erroe{e}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes07 != null)
|
|
|
|
if (bytes07 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModbusDecoder.Decode<Subzone7>(bytes07, FireControlMgr.Subzone7, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
ModbusDecoder.Decode<Subzone7>(bytes07, FireControlMgr.Subzone7, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fire read bytes07 erroe{e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
if (bytes08 != null)
|
|
|
|
if (bytes08 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModbusDecoder.Decode<Subzone8>(bytes08, FireControlMgr.Subzone8, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
ModbusDecoder.Decode<Subzone8>(bytes08, FireControlMgr.Subzone8, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fire read bytes08 erroe{e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
if (bytes09 != null)
|
|
|
|
if (bytes09 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModbusDecoder.Decode<Subzone9>(bytes09, FireControlMgr.Subzone9, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
ModbusDecoder.Decode<Subzone9>(bytes09, FireControlMgr.Subzone9, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fire read bytes02 erroe{e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|