plc msg调整。添加时间写入

master
CZ 6 months ago
parent 4d497b49d6
commit 7123ff8986

@ -21,15 +21,18 @@ public class PlcClient : ModbusTcpMaster
Duration = 2000;
AutoReConnect = true;
_binInfoRepository = binInfoRepository;
DataFormat = HslCommunication.Core.DataFormat.DCBA;
}
private void BatchRead(ModbusTcpMaster master)
{
PlcMgr.SendHear();
var bytes01 = master.BatchReadHolderRegister(1, 115);
if (bytes01 != null)
{
PlcMgr.DataValidityTime = DateTime.Now;
ModbusDecoder.Decode<HostToPlc>(bytes01, PlcMgr.HostToPlcData);
ModbusDecoder.Decode<HostToPlc>(bytes01, PlcMgr.HostToPlcData);
}
var bytes02 = master.BatchReadHolderRegister(201, 222);

@ -161,6 +161,29 @@ public class PlcMgr
return false;
}
public static bool SendHear()
{
if (PlcClient != null)
{
HostToPlc writeHostToPlc = new HostToPlc();
writeHostToPlc.Years.Value = (ushort)DateTime.Now.Year;
writeHostToPlc.Month.Value = (ushort)DateTime.Now.Month;
writeHostToPlc.Day.Value = (ushort)DateTime.Now.Day;
writeHostToPlc.Hour.Value = (ushort)DateTime.Now.Hour;
writeHostToPlc.Points.Value = (ushort)DateTime.Now.Minute;
writeHostToPlc.Seconds.Value = (ushort)DateTime.Now.Second;
bool write1 = PlcClient.WriteValue(writeHostToPlc.Years);
bool write2 = PlcClient.WriteValue(writeHostToPlc.Month);
bool write3 = PlcClient.WriteValue(writeHostToPlc.Day);
bool write4 = PlcClient.WriteValue(writeHostToPlc.Hour);
bool write5 = PlcClient.WriteValue(writeHostToPlc.Points);
bool write6 = PlcClient.WriteValue(writeHostToPlc.Seconds);
return write1 && write2&& write3 && write4&& write5 && write6;
}
return true;
}
/// <summary>
/// 查看拍照状态
/// </summary>

@ -71,7 +71,7 @@ namespace Service.Plc.Msg
/// 对时时钟:年
/// </summary>
public ModbusProperty<ushort> Years { get; set; } = new(40016);
public ModbusProperty<string> Standby3 { get; set; } = new(40017, length: 4); // 备用3
//public ModbusProperty<string> Standby3 { get; set; } = new(40017, length: 4); // 备用36
//public ModbusProperty<string> ChargingStatus { get; set; } = new(40021, length: 40); // 仓位充电状态
/// <summary>
/// 仓位充电状态
@ -340,7 +340,7 @@ namespace Service.Plc.Msg
/// 电池包锁止异常,暂停命令 0无命令1000暂停使能
/// </summary>
public ModbusProperty<ushort> StopCommand { get; set; } = new(40105);
public ModbusProperty<string> Standby4 { get; set; } = new(40106, length: 5); // 备用4
//public ModbusProperty<string> Standby4 { get; set; } = new(40106, length: 5); // 备用4
/// <summary>
/// 任务类型
/// <para>0.无任务</para>

@ -4,15 +4,10 @@ namespace Service.Plc.Msg
{
public class PlcFault
{
public ModbusProperty<ushort> ErrorCode01 { get; set; } = new(40701); // 错误码
public ModbusProperty<ushort> ErrorCode02 { get; set; } = new(40702); // 错误码
public ModbusProperty<ushort> ErrorCode03 { get; set; } = new(40703); // 错误码
public ModbusProperty<ushort> ErrorCode04 { get; set; } = new(40704); // 错误码
public ModbusProperty<ushort> ErrorCode05 { get; set; } = new(40705); // 错误码
public ModbusProperty<ushort> ErrorCode06 { get; set; } = new(40706); // 错误码
public ModbusProperty<ushort> ErrorCode07 { get; set; } = new(40707); // 错误码
public ModbusProperty<ushort> ErrorCode08 { get; set; } = new(40708); // 错误码
public ModbusProperty<ushort> ErrorCode09 { get; set; } = new(40709); // 错误码
public ModbusProperty<ushort> ErrorCode10 { get; set; } = new(40710); // 错误码
public ModbusProperty<int> ErrorCode01 { get; set; } = new(40701,length :2); // 错误码
public ModbusProperty<int> ErrorCode03 { get; set; } = new(40703,length :2); // 错误码
public ModbusProperty<int> ErrorCode05 { get; set; } = new(40705,length :2); // 错误码
public ModbusProperty<int> ErrorCode07 { get; set; } = new(40707,length :2); // 错误码
public ModbusProperty<int> ErrorCode09 { get; set; } = new(40709, length: 2); // 错误码
}
}

@ -65,31 +65,31 @@ namespace Service.Plc.Msg
/// <summary>
/// 备用
/// </summary>
public ModbusProperty<string> value09 { get; set; } = new(40211, length: 30);
//public ModbusProperty<1> value09 { get; set; } = new(40211, length: 30);
#region 舱位状态 bit0:有料检测 Bit1有料检测开关故障
public ModbusProperty<byte> MaterialDetec01 { get; set; } = new(40241,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec02 { get; set; } = new(40242,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec03 { get; set; } = new(40243,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec04 { get; set; } = new(40244,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec05 { get; set; } = new(40245,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec06 { get; set; } = new(40246,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec07 { get; set; } = new(40247,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec08 { get; set; } = new(40248,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec09 { get; set; } = new(40249,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec10 { get; set; } = new(40250,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec11 { get; set; } = new(40251,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec12 { get; set; } = new(40252,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec13 { get; set; } = new(40253,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec14 { get; set; } = new(40254,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec15 { get; set; } = new(40255,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec16 { get; set; } = new(40256,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec17 { get; set; } = new(40257,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec18 { get; set; } = new(40258,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec19 { get; set; } = new(40259,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec20 { get; set; } = new(40260,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec01 { get; set; } = new(40241);
public ModbusProperty<byte> MaterialDetec02 { get; set; } = new(40242);
public ModbusProperty<byte> MaterialDetec03 { get; set; } = new(40243);
public ModbusProperty<byte> MaterialDetec04 { get; set; } = new(40244);
public ModbusProperty<byte> MaterialDetec05 { get; set; } = new(40245);
public ModbusProperty<byte> MaterialDetec06 { get; set; } = new(40246);
public ModbusProperty<byte> MaterialDetec07 { get; set; } = new(40247);
public ModbusProperty<byte> MaterialDetec08 { get; set; } = new(40248);
public ModbusProperty<byte> MaterialDetec09 { get; set; } = new(40249);
public ModbusProperty<byte> MaterialDetec10 { get; set; } = new(40250);
public ModbusProperty<byte> MaterialDetec11 { get; set; } = new(40251);
public ModbusProperty<byte> MaterialDetec12 { get; set; } = new(40252);
public ModbusProperty<byte> MaterialDetec13 { get; set; } = new(40253);
public ModbusProperty<byte> MaterialDetec14 { get; set; } = new(40254);
public ModbusProperty<byte> MaterialDetec15 { get; set; } = new(40255);
public ModbusProperty<byte> MaterialDetec16 { get; set; } = new(40256);
public ModbusProperty<byte> MaterialDetec17 { get; set; } = new(40257);
public ModbusProperty<byte> MaterialDetec18 { get; set; } = new(40258);
public ModbusProperty<byte> MaterialDetec19 { get; set; } = new(40259);
public ModbusProperty<byte> MaterialDetec20 { get; set; } = new(40260);
#endregion 舱位状态
@ -127,7 +127,7 @@ namespace Service.Plc.Msg
/// z轴扭矩百分比
/// </summary>
public ModbusProperty<short> PercentageTorqueZ { get; set; } = new(40308);
public ModbusProperty<string> value20 { get; set; } = new(40309, length: 92); // 备用
//public ModbusProperty<string> value20 { get; set; } = new(40309, length: 92); // 备用
/// <summary>
/// 入口雷达状态
/// 0未触发
@ -229,7 +229,7 @@ namespace Service.Plc.Msg
/// z偏差
/// </summary>
public ModbusProperty<short> DeviationZ { get; set; } = new(40413);
public ModbusProperty<string> value44 { get; set; } = new(40414, length: 7); // 备用
//public ModbusProperty<string> value44 { get; set; } = new(40414, length: 7); // 备用

Loading…
Cancel
Save