给plc写充电状态

master
CZ 5 months ago
parent 1d4de9893d
commit 62f78c0079

@ -2,6 +2,8 @@ using Autofac;
using HslCommunication;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Utils;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using Repository.Station;
using Service.Execute.Model;
using Service.Plc.Msg;
@ -33,7 +35,7 @@ public class PlcMgr
PlcClient = AppInfo.Container.Resolve<PlcClient>();
}
Task.Run(() =>PlcClient.Connect());
Task.Run(() => PlcClient.Connect());
}
/// <summary>
@ -70,14 +72,12 @@ public class PlcMgr
{
if (PlcClient != null)
{
return PlcToHostData.ExhaustFanStatus.Value;
}
return 0;
}
/// <summary>
/// 是否远程模式
@ -254,6 +254,8 @@ public class PlcMgr
static bool heart = false;
private static BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
/// <summary>
/// 发送心跳
/// </summary>
@ -275,6 +277,16 @@ public class PlcMgr
writeHostToPlc.Points.Value = (ushort)DateTime.Now.Minute;
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 write02 = PlcClient.WriteValue(writeHostToPlc.ProtocolVersion2);
bool write03 = PlcClient.WriteValue(writeHostToPlc.ProtocolVersion3);
@ -285,6 +297,14 @@ public class PlcMgr
bool write4 = PlcClient.WriteValue(writeHostToPlc.Hour);
bool write5 = PlcClient.WriteValue(writeHostToPlc.Points);
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;
}
@ -375,4 +395,4 @@ public class PlcMgr
return bResult;
}
}
}
Loading…
Cancel
Save