From d2cef0150abe6d14cbfa60c8845795b91a1f5f97 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期六, 20 四月 2024 19:50:53 +0800 Subject: [PATCH] 添加入库触发条件,修改上料区任务逻辑 --- 代码管理/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 42 insertions(+), 5 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs" index bec587e..6da6b16 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs" @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using WIDESEA_Entity.DomainModels; @@ -65,15 +66,51 @@ /// <param name="client"></param> /// <param name="value"></param> /// <returns></returns> - public static object Write(dt_plcinfodetail detail, PLCClient client, object value) + public static object Read(DBItemGroup itemGroup, PLCClient client) { - try + //PLCClient client = PLCClient.Clients.Where(x => x.PLCName == itemGroup.name).FirstOrDefault(); + if (client == null) { - return (client.Write(detail.plcdetail_db + "." + detail.plcdetail_value, value)); + throw new Exception($"鏈壘鍒皗itemGroup.name}杩炴帴瀵硅薄"); } - catch (Exception ex) + else { - throw; + if (itemGroup.dataType == typeof(int).Name.ToLower())//4瀛楄妭,鏈夌鍙风被鍨� + { + return (client.Read<int>(itemGroup.dbAddress)); + } + else if (itemGroup.dataType == typeof(uint).Name.ToLower())//4瀛楄妭,鏃犵鍙风被鍨� + { + return (client.Read<uint>(itemGroup.dbAddress)); + } + else if (itemGroup.dataType == typeof(short).Name.ToLower())//2瀛楄妭,鏈夌鍙风被鍨�,鏈�甯哥敤 + { + return (client.Read<short>(itemGroup.dbAddress)); + } + else if (itemGroup.dataType == typeof(ushort).Name.ToLower())//2瀛楄妭,鏃犵鍙风被鍨� + { + return (client.Read<ushort>(itemGroup.dbAddress)); + } + else if (itemGroup.dataType == typeof(float).Name.ToLower())//娴偣鍨� + { + return (client.Read<float>(itemGroup.dbAddress)); + } + else if (itemGroup.dataType == typeof(bool).Name.ToLower()) + { + return (client.Read<bool>(itemGroup.dbAddress)); + } + else if (itemGroup.dataType == typeof(byte).Name.ToLower())//瀛楄妭 + { + return (client.Read<byte>(itemGroup.dbAddress)); + } + else if (itemGroup.dataType == typeof(string).Name.ToLower())//瀛楃涓� + { + return (client.Read<string>(itemGroup.dbAddress, itemGroup.dataLen.GetValueOrDefault())); + } + else + { + throw new Exception($"銆恵itemGroup.name}銆�,DB鍦板潃{itemGroup.dbAddress},鏈畾涔夋暟鎹被鍨媨itemGroup.dataType}"); + } } } } -- Gitblit v1.9.3