From 3d1df57ccc06c0c84813fac71f19ee5a4187b3da Mon Sep 17 00:00:00 2001 From: hwh <332078369@qq.com> Date: 星期五, 23 八月 2024 17:02:48 +0800 Subject: [PATCH] 1 --- Admin.NET/WCS.Application/PLC/PLCService.cs | 51 +++++++++++++++++++++++++++++++++------------------ 1 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Admin.NET/WCS.Application/PLC/PLCService.cs b/Admin.NET/WCS.Application/PLC/PLCService.cs index b9af4a9..ea2a5ea 100644 --- a/Admin.NET/WCS.Application/PLC/PLCService.cs +++ b/Admin.NET/WCS.Application/PLC/PLCService.cs @@ -12,32 +12,47 @@ switch (mod.Type) { case PLCTypeEnum.StackingMachine: - if (mod.Value == 820) + //鍐欐娴嬭瘯璇籹tring + var (res, val) = mod.PLCUtil.GetPlcDBValue(PLCDataTypeEnum.String, "DB100", "64"); + Console.WriteLine("DB100.64----" + val); + //娴嬭瘯鎵归噺璇诲彇 + Dictionary<string, PLCDataTypeEnum> listaddress = new Dictionary<string, PLCDataTypeEnum>(); + foreach (var modStation in mod.listStation) { - //娴嬭瘯鍐欏叆830 - var result = mod.PLCUtil.SetPlcDBValue(mod.PosType.Value, mod.DbNumber, mod.PlcPos, "830"); - //鍐欏叆鏄惁鎴愬姛 - if (result.IsSucceed) + listaddress.Add(modStation.PlcPos, modStation.PosType.Value); + } + var result = mod.PLCUtil.GetPlcBatchDBValue(listaddress); + if (result.Value.Count > 0) + { + foreach (var value in result.Value) + { + Console.WriteLine("鍦板潃" + value.Key + "----鍊�" + value, value); + } + } + if (!result.IsSucceed) + { + foreach (var err in result.ErrList) + { + Console.WriteLine(err); + } + if (result.Value.Count > 0)//鏈夐敊璇殑涔熸湁鎴愬姛鐨� { } } + if (mod.Value == 820) + { + //娴嬭瘯鍐欏叆830 + //var result = mod.PLCUtil.SetPlcDBValue(mod.PosType.Value, mod.DbNumber, mod.PlcPos, "830"); + ////鍐欏叆鏄惁鎴愬姛 + //if (result.IsSucceed) + //{ + + //} + } else if (mod.Value == 840) { - //娴嬭瘯鎵归噺璇诲彇 - Dictionary<string, PLCDataTypeEnum> listaddress = new Dictionary<string, PLCDataTypeEnum>(); - foreach (var modStation in mod.listStation) - { - listaddress.Add(modStation.PlcPos, modStation.PosType.Value); - } - var result = mod.PLCUtil.GetPlcBatchDBValue(listaddress); - if (!result.IsSucceed) - { - if (result.Value.Count > 0)//鏈夐敊璇殑涔熸湁鎴愬姛鐨� - { - } - } } else if (mod.Value == 860) { -- Gitblit v1.8.0