From 62f78c0079cfba83942347436eb93843ef9c90b2 Mon Sep 17 00:00:00 2001 From: CZ Date: Wed, 19 Jun 2024 10:14:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99plc=E5=86=99=E5=85=85=E7=94=B5?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Plc/Client/PlcMgr.cs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Service/Plc/Client/PlcMgr.cs b/Service/Plc/Client/PlcMgr.cs index 024b232..98183a8 100644 --- a/Service/Plc/Client/PlcMgr.cs +++ b/Service/Plc/Client/PlcMgr.cs @@ -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(); } - Task.Run(() =>PlcClient.Connect()); + Task.Run(() => PlcClient.Connect()); } /// @@ -70,14 +72,12 @@ public class PlcMgr { if (PlcClient != null) { - return PlcToHostData.ExhaustFanStatus.Value; } return 0; } - - + /// /// 是否远程模式 @@ -254,6 +254,8 @@ public class PlcMgr static bool heart = false; + private static BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve(); + /// /// 发送心跳 /// @@ -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; } -} +} \ No newline at end of file