schangxiang@126.com
2025-08-25 aa383c30e4f1053e97c6a33ccf9a899fca26dd20
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
using iWareOpc.Opc.Service;
using iWareOpc.Properties;
using OpcAccess.Access.Entity;
using OpcAccess.Access.Service;
using System.Collections.Generic;
 
namespace iWareOpc.Cache.Entity
{
    public class CacheEntity
    {
 
        private static object dbNameGroupDictLock = new object();
 
        private static Dictionary<string, string> dbNameGroupDict = null;
 
        public static Dictionary<string, string> DbNameGroupDict
        {
            get 
            {
                if (dbNameGroupDict == null)
                {
                    lock(dbNameGroupDictLock)
                    {
                        if (dbNameGroupDict == null)
                        {
                            dbNameGroupDict = new Dictionary<string, string> 
                            {
 
                                 //stacker1
                                 {"S7:[S7_Connection_1]DB540,W2","OPC1"},// 1Srm编号
                                 {"S7:[S7_Connection_1]DB540,W34","OPC1"},// 2任务号
                                 {"S7:[S7_Connection_1]DB540,W6","OPC1"},// 3源列
                                 {"S7:[S7_Connection_1]DB540,W8","OPC1"},// 4源层
                                 {"S7:[S7_Connection_1]DB540,W10","OPC1"},//5源排
                                 {"S7:[S7_Connection_1]DB540,W12","OPC1"},// 6宿列
                                 {"S7:[S7_Connection_1]DB540,W14","OPC1"},// 7宿层
                                 {"S7:[S7_Connection_1]DB540,W16","OPC1"},// 8宿排
                                 {"S7:[S7_Connection_1]DB540,W18","OPC1"},// 9发送命令
                                 {"S7:[S7_Connection_1]DB540,W20","OPC1"},// 10紧急停止
                                 {"S7:[S7_Connection_1]DB540,W22","OPC1"},// 11解除告警
                                 {"S7:[S7_Connection_1]DB540,W30","OPC1"},// 12WCS通讯位
                                 {"S7:[S7_Connection_1]DB540,W32","OPC1"},// 13SRM 应答位
                                 {"S7:[S7_Connection_1]DB540,W0","OPC1"},// 14心跳
                                 {"S7:[S7_Connection_1]DB540,W4","OPC1"},// 15批次
                                 
 
                                 {"S7:[S7_Connection_1]DB541,W2","OPC1"},// 1Srm编号
                                 {"S7:[S7_Connection_1]DB541,W4","OPC1"},// 2模式
                                 {"S7:[S7_Connection_1]DB541,W6","OPC1"},// 3告警
                                 {"S7:[S7_Connection_1]DB541,W8","OPC1"},// 4载货工位是否有货
                                 {"S7:[S7_Connection_1]DB541,W10","OPC1"},// 5当前列
                                 {"S7:[S7_Connection_1]DB541,W12","OPC1"},// 6当前层
                                 {"S7:[S7_Connection_1]DB541,W14","OPC1"},// 7货叉位置
                                 {"S7:[S7_Connection_1]DB541,DINT16","OPC1"},// 8当前列坐标
                                 {"S7:[S7_Connection_1]DB541,DINT20","OPC1"},// 9当前层坐标
                                 {"S7:[S7_Connection_1]DB541,DINT24","OPC1"}, //10当前货叉坐标
                                 {"S7:[S7_Connection_1]DB541,W28","OPC1"},//11完成取货信号
                                 {"S7:[S7_Connection_1]DB541,W30","OPC1"},// 12完成放货信号
                                 {"S7:[S7_Connection_1]DB541,W32","OPC1"},// 13任务完成
                                 {"S7:[S7_Connection_1]DB541,W48","OPC1"},// 14当前任务号
                                 {"S7:[S7_Connection_1]DB541,W36","OPC1"},// 15当前任务执行状态
                                 {"S7:[S7_Connection_1]DB541,W38","OPC1"},// 16当前巷道号
                                 {"S7:[S7_Connection_1]DB541,W40","OPC1"},// 17告警代码
                                 {"S7:[S7_Connection_1]DB541,W0","OPC1"},// 18心跳
 
                            };
                        }
                    }
                }
 
                return CacheEntity.dbNameGroupDict; 
            }
            set { CacheEntity.dbNameGroupDict = value; }
        }
 
        private static object OpcAccessServiceLock = new object();
 
        /// <summary>
        /// 获取opc服务
        /// </summary>
        private static OpcAccessService opcAccessService = null;
 
        public static OpcAccessService OpcAccessService
        {
            get 
            {
                if (opcAccessService == null) 
                {
                    lock (OpcAccessServiceLock) 
                    {
                        if (opcAccessService == null)
                        {
                            var groups = new List<OpcGroupEntity>() 
                            {
                
                                new OpcGroupEntity { Name = "OPC1", Items = new List<OpcItemEntity> 
                                {
                                    //stacker1
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W2"},// 1Srm编号
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W34"},// 2任务号
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W6"},// 3源列
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W8"},// 4源层
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W10"},//5源排
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W12"},// 6宿列
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W14"},// 7宿层
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W16"},// 8宿排
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W18"},// 9发送命令
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W20"},// 10紧急停止
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W22"},// 11解除告警
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W30"},// 12WCS通讯位
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W32"},// 13SRM 应答位
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W0"},// 14心跳
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB540,W4"},// 15批次
 
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W2"},// 1Srm编号
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W4"},// 2模式
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W6"},// 3告警
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W8"},// 4载货工位是否有货
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W10"},// 5当前列
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W12"},// 6当前层
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W14"},// 7货叉位置
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,DINT16"},// 8当前列坐标
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,DINT20"},// 9当前层坐标
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,DINT24"}, //10当前货叉坐标
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W28"},//11完成取货信号
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W30"},// 12完成放货信号
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W32"},// 13任务完成
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W48"},// 14当前任务号
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W36"},// 15当前任务执行状态
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W38"},// 16当前巷道号
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W40"},// 17告警代码
                                    new OpcItemEntity {Db = "S7:[S7_Connection_1]DB541,W0"},// 18心跳
                                
                                }},
                            };
 
                            opcAccessService = OpcService.GetInstance().GetOpcAccessService("192.168.1.200", groups);//Resources.OpcIp
                        }
                    }
                }
 
                return CacheEntity.opcAccessService;
 
            }
            set { CacheEntity.opcAccessService = value; }
        }
    }
}