| | |
| | | public class PlcHub : Hub<IPlcHub> |
| | | { |
| | | private readonly IHubContext<PlcHub, IPlcHub> _plcHubContext; |
| | | |
| | | public PlcHub(IHubContext<PlcHub, IPlcHub> plcHubContext) |
| | | private readonly SysConfigService _sysConfigService; |
| | | public PlcHub(IHubContext<PlcHub, IPlcHub> plcHubContext, SysConfigService sysConfigService) |
| | | { |
| | | _plcHubContext = plcHubContext; |
| | | _sysConfigService = sysConfigService; |
| | | } |
| | | /// <summary> |
| | | /// 下发PLC连接状态 |
| | |
| | | { |
| | | //运行状态 |
| | | if (context.BoRunningState.HasValue) |
| | | { |
| | | PLCTaskAction.boRunningState = context.BoRunningState.Value; |
| | | if (context.BoRunningState.Value) |
| | | PLCTaskAction.Init(); |
| | | else |
| | | PLCTaskAction.Stop(); |
| | | await _sysConfigService.UpdateConfigValue("sys_RunningState", context.BoRunningState.Value); |
| | | } |
| | | //脱机模式 |
| | | if (context.BoOffline.HasValue) |
| | | { |
| | | PLCTaskAction.boOffline = context.BoOffline.Value; |
| | | await _sysConfigService.UpdateConfigValue("sys_Offline", context.BoOffline.Value); |
| | | } |
| | | //自刷新 |
| | | if (context.BoRefresh.HasValue) |
| | | { |
| | | PLCTaskAction.boRefresh = context.BoRefresh.Value; |
| | | await _plcHubContext.Clients.All.UpdateService(context); |
| | | await _sysConfigService.UpdateConfigValue("sys_Refresh", context.BoRefresh.Value); |
| | | } |
| | | //演示模式 |
| | | if (context.BoDemo.HasValue) |
| | | { |
| | | PLCTaskAction.boDemo = context.BoDemo.Value; |
| | | await _sysConfigService.UpdateConfigValue("sys_demo", context.BoDemo.Value); |
| | | } |
| | | //滚筒反转 |
| | | if (context.BoDrumReversal.HasValue) |
| | | { |
| | | PLCTaskAction.boDrumReversal = context.BoDrumReversal.Value; |
| | | await _sysConfigService.UpdateConfigValue("sys_DrumReversal", context.BoDrumReversal.Value); |
| | | } |
| | | await _plcHubContext.Clients.All.UpdateService(new PLCServiceModel() { BoRunningState = PLCTaskAction.boRunningState, BoRefresh = PLCTaskAction.boRefresh, BoOffline = PLCTaskAction.boOffline, BoDemo = PLCTaskAction.boDemo}); |
| | | } |
| | | } |
| | | public class PLCServiceModel |
| | |
| | | |
| | | |
| | | public bool? BoRefresh { get; set; } |
| | | |
| | | public bool? BoDemo { get; set; } |
| | | |
| | | public bool? BoDrumReversal { get; set; } |
| | | } |