2
schangxiang@126.com
2024-10-01 ffa9dc9c2d28c0b8d88b26d483ba9667e316db01
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using iWareCommon.Utils;
 
using iWareModel;
 
using System.Collections.Generic;
using System;
using System.Linq;
 
namespace iWareSda
{
    /// <summary>
    /// 输送线实体类
    /// </summary>
    public static class Line_CacheEntity
    {
        public static LogType curLogType = LogType.LineSdaService;
 
        #region 输送线
 
        /// <summary>
        /// 写入DB
        /// </summary>
        public static string W_DBHeader = "2390";
        /// <summary>
        /// 读取DB
        /// </summary>
        public static string R_DBHeader = "2390";
        private static LineDBForWrite _dbBlockForWrite = new LineDBForWrite()
        {
            //TODO:这里写配置的DB地址
 
            //写的DB块
            W_HeartBeat = "100",
 
            W_T1_Die = "102",
            W_T1_Stock = "104",
            W_T1_Finish = "106.0",
 
            W_T2_Die = "108",
            W_T2_Stock = "110",
            W_T2_Finish = "112.0",
 
 
            W_T3_Die = "114",
            W_T3_Stock = "116",
            W_T3_Finish = "118.0",
 
            W_T1_request_ok = "106.1",
            W_T2_request_ok = "112.1",
            W_T3_request_ok = "118.1"
        };
        private static LineDBForRead _dbBlockForRead = new LineDBForRead()
        {
            //TODO:这里写配置的DB地址
            //写的DB块
            R_HeartBeat = "0",
 
            R_T1_IN_and_OUT = "2",
            R_T1_Ready = "4.0",
            R_T1_Die = "6",
            R_T1_DieNo = "8",
            R_T1_LocationNo = "10",
 
            R_T2_IN_and_OUT = "12",
            R_T2_Ready = "14.0",
            R_T2_Die = "16",
            R_T2_DieNo = "18",
            R_T2_LocationNo = "20",
 
            R_T3_IN_and_OUT = "22",
            R_T3_Ready = "24.0",
            R_T3_Die = "26",
            R_T3_DieNo = "28",
            R_T3_LocationNo = "30",
 
            R_MANUAL_AUTO = "32",
            R_Alarm = "34.0"
        };
        private static HslCommunicationParam hslCommunicationParam = new HslCommunicationParam()
        {
            //cpu = WareSdaStruct.Line_SiemensPLCS,
            //ip = WareSdaStruct.Line_Address,
            //rack = WareSdaStruct.Line_Rack,
            //slot = WareSdaStruct.Line_Slot,
            //port = WareSdaStruct.Line_Port
        };
        private static SS7Param s7Param = new SS7Param()
        {
            //cpu = WareSdaStruct.Line_PLC_CpuType,
            //ip = WareSdaStruct.Line_Address,
            //rack = WareSdaStruct.Line_Rack,
            //slot = WareSdaStruct.Line_Slot,
        };
        private static PLCService PLCService = PLCFactory.GetOPCService(WareSdaStruct.System_PlcServiceTypeEnum, s7Param, hslCommunicationParam);
        private static LineEntity line1 = new LineEntity("Line1", (int)EDevice.一号堆垛机, _dbBlockForWrite, _dbBlockForRead, PLCService);
 
        #endregion
 
        private static List<LineEntity> _deviceObjList = null;
        private static object objLock = new object();
 
        /// <summary>
        /// 生成设备实体类
        /// </summary>
        public static List<LineEntity> DeviceObjs
        {
            get
            {
                if (_deviceObjList == null)
                {
                    lock (objLock)
                    {
                        if (_deviceObjList == null)
                        {
                            _deviceObjList = new List<LineEntity>();
                            _deviceObjList.Add(line1);
                        }
                    }
                }
                return Line_CacheEntity._deviceObjList;
            }
            set { Line_CacheEntity._deviceObjList = value; }
        }
 
        public static T GetDeviceObj<T>(int deviceId)
        {
            var device = Line_CacheEntity.DeviceObjs.FirstOrDefault(x => x.View.DeviceId == deviceId);
            return (T)(Object)device;
        }
    }
}