|
|
|
@ -27,8 +27,9 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
WordSeq= EndingConst.WordSeq.CD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BatchRead(ModbusTcpMaster master)
|
|
|
|
|
private bool BatchRead(ModbusTcpMaster master)
|
|
|
|
|
{
|
|
|
|
|
bool connectResult = false;
|
|
|
|
|
//1电表
|
|
|
|
|
//2消防
|
|
|
|
|
//3温湿度
|
|
|
|
@ -39,9 +40,10 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
var readPowerValue = master.Read("x=3;39424", 2).Content;
|
|
|
|
|
if (readPowerValue != null)
|
|
|
|
|
{
|
|
|
|
|
connectResult = true;
|
|
|
|
|
Array.Reverse(readPowerValue);
|
|
|
|
|
//ModbusDecoder.Decode<PowerValue>(readPowerValue, FireControlMgr.PowerValue, EndingConst.ByteSeq.BA, EndingConst.WordSeq.DC);
|
|
|
|
|
FireControlMgr.PowerValue.FPowerValue.Value=BitConverter.ToSingle(readPowerValue, 0);
|
|
|
|
|
FireControlMgr.PowerValue.FPowerValue.Value=BitConverter.ToSingle(readPowerValue, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
@ -51,12 +53,13 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
var readTem = master.Read("s=3;x=3;0", 2).Content;
|
|
|
|
|
if (readTem!=null)
|
|
|
|
|
{
|
|
|
|
|
connectResult = true;
|
|
|
|
|
ModbusDecoder.Decode<TemperatureHumidity>(readTem, FireControlMgr.TemperatureHumidity, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
var bytes02 = master.ReadCoil("s=2;x=1;0", 17).Content;//0x01
|
|
|
|
|
|
|
|
|
|
var bytes02 = master.ReadCoil("s=2;x=1;0", 17).Content;//0x01
|
|
|
|
|
var bytes03 = master.Read("s=2;x=3;1", 3).Content;//0x03 读1 3
|
|
|
|
|
var bytes04 = master.Read("s=2;x=3;257", 383).Content;//0x03 读256 383
|
|
|
|
|
var bytes05 = master.Read("s=2;x=4;1", 115).Content;//0x04 可以
|
|
|
|
@ -67,18 +70,20 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
var bytesAdd2 = master.Read("s=2;x=4;3048", 1048).Content;//0x04 可以
|
|
|
|
|
if (bytesAdd1 != null && bytesAdd2 != null)
|
|
|
|
|
{
|
|
|
|
|
connectResult = true;
|
|
|
|
|
bytes06.AddRange(bytesAdd1);
|
|
|
|
|
bytes06.AddRange(bytesAdd2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bytes07 = master.Read("s=2;x=4;4096", 32).Content;//0x04 可以
|
|
|
|
|
var bytes08 = master.Read("s=2;x=5;0", 134).Content;//0x05 写
|
|
|
|
|
var bytes08 = master.Read("s=2;x=5;0", 134).Content;//0x05 写
|
|
|
|
|
var bytes09 = master.Read("s=2;x=6;256", 64).Content;//0x06 写
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes02 != null)
|
|
|
|
|
{
|
|
|
|
|
Log.Info("fire read bytes02 success");
|
|
|
|
|
connectResult = true;
|
|
|
|
|
FireControlMgr.Subzone2.GiveAnAlarm.Value = bytes02[0];
|
|
|
|
|
FireControlMgr.Subzone2.NumberOfFailures.Value = bytes02[1];
|
|
|
|
|
FireControlMgr.Subzone2.SoundSuppression.Value = bytes02[2];
|
|
|
|
@ -97,14 +102,16 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
FireControlMgr.Subzone2.AudibleVisualAlarmStatus.Value = bytes02[15];
|
|
|
|
|
FireControlMgr.Subzone2.DeflatedDoNotEnter.Value = bytes02[16];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes03 != null)
|
|
|
|
|
{
|
|
|
|
|
connectResult = true;
|
|
|
|
|
ModbusDecoder.Decode<Subzone3>(bytes03, FireControlMgr.Subzone3, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes04 != null)
|
|
|
|
|
{
|
|
|
|
|
connectResult = true;
|
|
|
|
|
ModbusDecoder.Decode<Subzone4>(bytes04, FireControlMgr.Subzone4, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
List<string> faultList = new List<string>()
|
|
|
|
|
{
|
|
|
|
@ -141,34 +148,38 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
};
|
|
|
|
|
SaveAlarmInfo(faultList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes05 != null)
|
|
|
|
|
{
|
|
|
|
|
connectResult = true;
|
|
|
|
|
ModbusDecoder.Decode<Subzone5>(bytes05, FireControlMgr.Subzone5, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes06 != null)
|
|
|
|
|
{
|
|
|
|
|
connectResult = true;
|
|
|
|
|
ModbusDecoder.Decode<Subzone6>(bytes06.ToArray(), FireControlMgr.Subzone6, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes07 != null)
|
|
|
|
|
{
|
|
|
|
|
connectResult = true;
|
|
|
|
|
ModbusDecoder.Decode<Subzone7>(bytes07, FireControlMgr.Subzone7, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*if (bytes08 != null)
|
|
|
|
|
{
|
|
|
|
|
ModbusDecoder.Decode<Subzone8>(bytes08, FireControlMgr.Subzone8, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes09 != null)
|
|
|
|
|
{
|
|
|
|
|
ModbusDecoder.Decode<Subzone9>(bytes09, FireControlMgr.Subzone9, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return connectResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveAlarmInfo(List<string> lstAlarm)
|
|
|
|
|
{
|
|
|
|
|
if (lstAlarm.Count > 0)
|
|
|
|
@ -193,7 +204,7 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
{
|
|
|
|
|
EquipAlarmDefine? alarmDefine =
|
|
|
|
|
EquipAlarmDefineRepository.QueryByClause(i=>i.EquipTypeCode==(int)EquipmentType.Fire&&i.ErrorCode==errorCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (alarmDefine != null)
|
|
|
|
|
{
|
|
|
|
|
EquipAlarmRecord record = new EquipAlarmRecord()
|
|
|
|
@ -207,7 +218,7 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
StartTime = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
EquipAlarmRecordRepository.Insert(record);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -267,4 +278,4 @@ public class FireControlClient: ModbusTcpMaster
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|