| | |
| | | namespace WCS.Application; |
| | | |
| | | /// <summary> |
| | | /// PLC集线器 |
| | | /// 任务日志集线器 |
| | | /// </summary> |
| | | [MapHub("/hubs/Plc")] |
| | | 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连接状态 |
| | | /// </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> |
| | | /// 下发工位状态 |
| | |
| | | //} |
| | | |
| | | /// <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(); |
| | | 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 _sysConfigService.UpdateConfigValue("sys_Refresh", context.BoRefresh.Value); |
| | | } |
| | | await _plcHubContext.Clients.All.UpdateService(new PLCServiceModel() { BoRunningState = PLCTaskAction.boRunningState, BoRefresh = PLCTaskAction.boRefresh, BoOffline = PLCTaskAction.boOffline }); |
| | | } |
| | | } |
| | | public class PLCServiceModel |
| | | { |
| | | public bool? BoRunningState { get; set; } |
| | | |
| | | |
| | | public bool? BoOffline { get; set; } |
| | | |
| | | |
| | | public bool? BoRefresh { get; set; } |
| | | } |