chengsc
2025-04-14 d2588d8d1305171e7716055b23a6b5706e9cc04b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Application.Hub;
using WCS.Application.Service.WcsDevice.Dto;
 
namespace WCS.Application;
public static class HubUtil
{
    private static readonly IHubContext<PlcHub, IPlcHub> _plcHubContext = App.GetService<IHubContext<PlcHub, IPlcHub>>();
    private static readonly IHubContext<PlcDeviceHub, IPlcDeviceHub> _plcDeviceHubContext = App.GetService<IHubContext<PlcDeviceHub, IPlcDeviceHub>>();
    private static readonly IHubContext<TaskLogHub, ITaskLogHub> _taskLogHubContext = App.GetService<IHubContext<TaskLogHub, ITaskLogHub>>();
    private static readonly IHubContext<CheckTaskHub, ICheckTaskHub> _checkTaskHubContext = App.GetService<IHubContext<CheckTaskHub, ICheckTaskHub>>();
 
    /// <summary>
    /// 下发PLC连接状态
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public static async Task PublicPlcConn(WcsPlc context)
    {
        if (PLCTaskAction.boRefresh)
            await _plcHubContext.Clients.All.PublicPlcConn(context);
    }
 
    /// <summary>
    /// 下发报警信息
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public static async Task PublicAlarm(List<WcsAlarmInfo> context)
    {
        if (PLCTaskAction.boRefresh)
            await _plcHubContext.Clients.All.PublicAlarm(context);
    }
 
    /// <summary>
    /// 修改服务状态
    /// </summary>
    /// <param name="context"></param>
    public static async Task UpdateService(PLCServiceModel context)
    {
        if (PLCTaskAction.boRefresh)
            await _plcHubContext.Clients.All.UpdateService(context);
    }
 
    /// <summary>
    /// 下发控制台位置信息
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public static async Task PublicPosition(PlcPositionInfo context)
    {
        if (PLCTaskAction.boRefresh)
            await _plcHubContext.Clients.All.PublicPosition(context);
    }
 
    /// <summary>
    /// 下发任务
    /// </summary>
    /// <returns></returns>
    public static async Task PublicTask(WcsTaskOutput context)
    {
        if (PLCTaskAction.boRefresh)
            await _taskLogHubContext.Clients.All.PublicTask(context);
    }
 
    /// <summary>
    /// 下发任务明细
    /// </summary>
    /// <returns></returns>
    public static async Task PublicTaskMonitor(WcsTaskMonitorOutput context)
    {
        if (PLCTaskAction.boRefresh)
            await _taskLogHubContext.Clients.All.PublicTaskMonitor(context);
    }
 
    /// <summary>
    /// 下发设备信息
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public static async Task PublicPlcDevice(WcsDeviceOutput context)
    {
        if (PLCTaskAction.boRefresh)
            await _plcDeviceHubContext.Clients.All.PublicPlcDevice(context);
    }
 
    /// <summary>
    /// 下发分拣任务信息
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public static async Task PublicCheckTask(WcsDeviceTaskOrderDto context)
    {
        if (PLCTaskAction.boRefresh)
            await _checkTaskHubContext.Clients.All.PublicCheckTask(context);
    }
}