wangxinhui
2026-04-20 5d9c24c02c8685fd931e0ae93e54c811726af8c6
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
103
104
105
106
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_Tasks.ConveyorLineJob
{
    /// <summary>
    /// 北侧输送线系统
    /// </summary>
    public class ConveyorState_North
    {
        public string IPAddress { get; set; } = string.Empty;
        public bool IsEventSubscribed { get; set; }
    }
    /// <summary>
    /// 北侧输送线管理
    /// </summary>
    public static class ConveyorManager_North
    {
        private static readonly ConcurrentDictionary<string, Dictionary<string, CraneStacker>> _ipCranes = new();
 
        // 初始化输送线堆垛机(一个IP下)
        public static Dictionary<string, CraneStacker> GetOrCreateCraneList(string ip)
        {
            return _ipCranes.GetOrAdd(ip, _ => new Dictionary<string, CraneStacker>
            {
                { "CRAN32-01", new CraneStacker("CRAN32-01", "1#堆垛机") },
                { "CRAN32-02", new CraneStacker("CRAN32-02", "2#堆垛机") },
                { "CRAN32-03", new CraneStacker("CRAN32-03", "3#堆垛机") },
            });
        }
 
        // 获取某一台堆垛机
        public static CraneStacker? GetCrane(string ip, string craneCode)
        {
            if (_ipCranes.TryGetValue(ip, out var list) && list.TryGetValue(craneCode, out var crane))
                return crane;
            return null;
        }
    }
    /// <summary>
    /// 南侧输送线系统
    /// </summary>
    public class ConveyorState_South
    {
        public string IPAddress { get; set; } = string.Empty;
        public bool IsEventSubscribed { get; set; }
    }
    /// <summary>
    /// 南侧输送线系统管理
    /// </summary>
    public static class ConveyorManager_South
    {
        private static readonly ConcurrentDictionary<string, Dictionary<string, CraneStacker>> _ipCranes = new();
 
        // 初始化3台堆垛机(一个IP下)
        public static Dictionary<string, CraneStacker> GetOrCreateCraneList(string ip)
        {
            return _ipCranes.GetOrAdd(ip, _ => new Dictionary<string, CraneStacker>
            {
                { "CRAN30-01", new CraneStacker("CRAN30-01", "1#堆垛机") },
                { "CRAN30-02", new CraneStacker("CRAN30-02", "2#堆垛机") },
                { "CRAN30-03", new CraneStacker("CRAN30-03", "3#堆垛机") },
            });
        }
 
        // 获取某一台堆垛机
        public static CraneStacker? GetCrane(string ip, string craneCode)
        {
            if (_ipCranes.TryGetValue(ip, out var list) && list.TryGetValue(craneCode, out var crane))
                return crane;
            return null;
        }
    }
    /// <summary>
    /// 单台输送线独立状态
    /// </summary>
    public class CraneStacker
    {
        public string CraneCode { get; set; } = string.Empty;
        public string DisplayName { get; set; } = string.Empty;
 
        // 运行状态
        public int RunMode { get; set; } = 0;        // 1=自动 2=停止 3=手动/离线
        public int ErrorState { get; set; } = 0;      // 0=正常 1=故障
        public string CurrentPosition { get; set; } = string.Empty;
        public DateTime LastHeartbeat { get; set; } = DateTime.Now;
 
        // 当前任务
        public Dt_Task? CurrentTask { get; set; }
 
        // 独立序列号(每台堆垛机自己计数)
        public int SendSeq { get; set; } = 1;
        public object SeqLock { get; set; } = new object();
 
        public CraneStacker(string code, string name)
        {
            CraneCode = code;
            DisplayName = name;
        }
    }
}