hwh
2024-09-18 d5f506ef2f7a9e8feb73e62f57086b5458ffbcbd
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
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
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>>();
 
    /// <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);
    }
}