From c56d28d684cee010f291295dbe851bab64c1b6a6 Mon Sep 17 00:00:00 2001 From: hwh <332078369@qq.com> Date: 星期二, 03 九月 2024 09:52:22 +0800 Subject: [PATCH] 设备监控绑定plc数据 --- Admin.NET/WCS.Application/Hub/PlcHub.cs | 47 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Admin.NET/WCS.Application/Hub/PlcHub.cs b/Admin.NET/WCS.Application/Hub/PlcHub.cs index 31d652c..f85da61 100644 --- a/Admin.NET/WCS.Application/Hub/PlcHub.cs +++ b/Admin.NET/WCS.Application/Hub/PlcHub.cs @@ -4,7 +4,7 @@ namespace WCS.Application; /// <summary> -/// PLC闆嗙嚎鍣� +/// 浠诲姟鏃ュ織闆嗙嚎鍣� /// </summary> [MapHub("/hubs/Plc")] public class PlcHub : Hub<IPlcHub> @@ -20,10 +20,10 @@ /// </summary> /// <param name="context"></param> /// <returns></returns> - //public async Task PublicPlcConn(WcsPlc context) - //{ - // await _plcHubContext.Clients.All.PublicPlcConn(context); - //} + public async Task PublicPlcConn(WcsPlc context) + { + await _plcHubContext.Clients.All.PublicPlcConn(context); + } /// <summary> /// 涓嬪彂宸ヤ綅鐘舵�� @@ -36,12 +36,35 @@ //} /// <summary> - /// 涓嬪彂鎶ヨ淇℃伅 + /// 涓嬪彂鏈嶅姟鐘舵�� /// </summary> - /// <param name="context"></param> - /// <returns></returns> - //public async Task PublicAlarm(WcsAlarmInfoOutput context) - //{ - // await _plcHubContext.Clients.All.PublicAlarm(context); - //} + public async Task UpdateService(PLCServiceModel context) + { + //杩愯鐘舵�� + if (context.BoRunningState.HasValue) + { + PLCTaskAction.boRunningState = context.BoRunningState.Value; + if (context.BoRunningState.Value) + PLCTaskAction.Init(); + else + PLCTaskAction.Stop(); + } + //鑴辨満妯″紡 + if (context.BoOffline.HasValue) + PLCTaskAction.boOffline = context.BoOffline.Value; + //鑷埛鏂� + if (context.BoRefresh.HasValue) + PLCTaskAction.boRefresh = context.BoRefresh.Value; + await _plcHubContext.Clients.All.UpdateService(context); + } } +public class PLCServiceModel +{ + public bool? BoRunningState { get; set; } + + + public bool? BoOffline { get; set; } + + + public bool? BoRefresh { get; set; } +} \ No newline at end of file -- Gitblit v1.8.0