给plc写充电状态

zw
CZ 5 months ago
parent 1d4de9893d
commit 62f78c0079

@ -2,6 +2,8 @@ using Autofac;
using HslCommunication; using HslCommunication;
using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Utils; using HybirdFrameworkCore.Utils;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using Repository.Station;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Plc.Msg; using Service.Plc.Msg;
@ -70,7 +72,6 @@ public class PlcMgr
{ {
if (PlcClient != null) if (PlcClient != null)
{ {
return PlcToHostData.ExhaustFanStatus.Value; return PlcToHostData.ExhaustFanStatus.Value;
} }
@ -78,7 +79,6 @@ public class PlcMgr
} }
/// <summary> /// <summary>
/// 是否远程模式 /// 是否远程模式
/// </summary> /// </summary>
@ -254,6 +254,8 @@ public class PlcMgr
static bool heart = false; static bool heart = false;
private static BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
/// <summary> /// <summary>
/// 发送心跳 /// 发送心跳
/// </summary> /// </summary>
@ -275,6 +277,16 @@ public class PlcMgr
writeHostToPlc.Points.Value = (ushort)DateTime.Now.Minute; writeHostToPlc.Points.Value = (ushort)DateTime.Now.Minute;
writeHostToPlc.Seconds.Value = (ushort)DateTime.Now.Second; writeHostToPlc.Seconds.Value = (ushort)DateTime.Now.Second;
var lstBinInfo = BinInfoRepository.Query();
writeHostToPlc.ChargingStatus02.Value = (short)(lstBinInfo[1].ChargeStatus == 1 ? 1010 : 1000);
writeHostToPlc.ChargingStatus03.Value = (short)(lstBinInfo[2].ChargeStatus == 1 ? 1010 : 1000);
writeHostToPlc.ChargingStatus04.Value = (short)(lstBinInfo[3].ChargeStatus == 1 ? 1010 : 1000);
writeHostToPlc.ChargingStatus05.Value = (short)(lstBinInfo[4].ChargeStatus == 1 ? 1010 : 1000);
writeHostToPlc.ChargingStatus06.Value = (short)(lstBinInfo[5].ChargeStatus == 1 ? 1010 : 1000);
writeHostToPlc.ChargingStatus07.Value = (short)(lstBinInfo[6].ChargeStatus == 1 ? 1010 : 1000);
writeHostToPlc.ChargingStatus08.Value = (short)(lstBinInfo[7].ChargeStatus == 1 ? 1010 : 1000);
bool write01 = PlcClient.WriteValue(writeHostToPlc.ProtocolVersion1); bool write01 = PlcClient.WriteValue(writeHostToPlc.ProtocolVersion1);
bool write02 = PlcClient.WriteValue(writeHostToPlc.ProtocolVersion2); bool write02 = PlcClient.WriteValue(writeHostToPlc.ProtocolVersion2);
bool write03 = PlcClient.WriteValue(writeHostToPlc.ProtocolVersion3); bool write03 = PlcClient.WriteValue(writeHostToPlc.ProtocolVersion3);
@ -285,6 +297,14 @@ public class PlcMgr
bool write4 = PlcClient.WriteValue(writeHostToPlc.Hour); bool write4 = PlcClient.WriteValue(writeHostToPlc.Hour);
bool write5 = PlcClient.WriteValue(writeHostToPlc.Points); bool write5 = PlcClient.WriteValue(writeHostToPlc.Points);
bool write6 = PlcClient.WriteValue(writeHostToPlc.Seconds); bool write6 = PlcClient.WriteValue(writeHostToPlc.Seconds);
bool writeCharge2 = PlcClient.WriteValue(writeHostToPlc.ChargingStatus02);
bool writeCharge3 = PlcClient.WriteValue(writeHostToPlc.ChargingStatus03);
bool writeCharge4 = PlcClient.WriteValue(writeHostToPlc.ChargingStatus04);
bool writeCharge5 = PlcClient.WriteValue(writeHostToPlc.ChargingStatus05);
bool writeCharge6 = PlcClient.WriteValue(writeHostToPlc.ChargingStatus06);
bool writeCharge7 = PlcClient.WriteValue(writeHostToPlc.ChargingStatus07);
bool writeCharge8 = PlcClient.WriteValue(writeHostToPlc.ChargingStatus08);
return write1 && write2 && write3 && write4 && write5 && write6; return write1 && write2 && write3 && write4 && write5 && write6;
} }

Loading…
Cancel
Save