1
czw
2025-05-15 9a5dcc53616c720c97492025faf1930e221b8aeb
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.Serialization;
using System.Collections.Concurrent;
using System.ServiceModel;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net;
using NLog;
using NLog.Config;
using NLog.Targets;
using GZ.DB.Map.OIDATABASE;
using GZ.DB.App.OIDATABASE;
using GZ.DB.Repository.OIDATABASE;
using GZ.DB.IRepository.OIDATABASE;
using GZ.DB.Entity.OIDATABASE;
namespace GZ.Projects.S7
{
    #region 设备通信
    /// <summary>
    /// 设备通信
    /// </summary>
    public class Device
    {
        public GZ.Device.PLC.PlcBase PLC1=null;
        public GZ.Device.PLC.PlcBase 西门子2=null;
        public GZ.Device.PLC.PlcBase 维希尔抓臂1=null;
        public GZ.Device.PLC.PlcBase 维希尔抓臂2=null;
        public GZ.Device.PLC.PlcBase 捷瞬输送1=null;
        public GZ.Device.PLC.PlcBase 捷瞬输送2=null;
        public GZ.Device.PLC.PlcBase 捷瞬抓臂1=null;
        public GZ.Device.PLC.PlcBase 捷瞬抓臂2=null;
        public GZ.Device.PLC.PlcBase wxwp=null;
        public GZ.Device.PLC.PlcBase wxrp=null;
        public GZ.Device.PLC.PlcBase warp=null;
        public GZ.Device.PLC.PlcBase ssx2xPlcRead=null;
        public GZ.Device.PLC.PlcBase ssx1xPlcRead=null;
        public GZ.Device.PLC.PlcBase ssx3xPlcRead=null;
        public GZ.Device.PLC.PlcBase PLC10=null;
        public Device()
        {
            PLC1 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "PLC1"),
                Conn.默认日志
            );
            西门子2 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "西门子2"),
                Conn.默认日志
            );
            维希尔抓臂1 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "维希尔抓臂1"),
                Conn.默认日志
            );
            维希尔抓臂2 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "维希尔抓臂2"),
                Conn.默认日志
            );
            捷瞬输送1 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "捷瞬输送1"),
                Conn.默认日志
            );
            捷瞬输送2 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "捷瞬输送2"),
                Conn.默认日志
            );
            捷瞬抓臂1 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "捷瞬抓臂1"),
                Conn.默认日志
            );
            捷瞬抓臂2 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "捷瞬抓臂2"),
                Conn.默认日志
            );
            wxwp = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "wxwp"),
                Conn.默认日志
            );
            wxrp = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "wxrp"),
                Conn.默认日志
            );
            warp = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "warp"),
                Conn.默认日志
            );
            ssx2xPlcRead = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "ssx2xPlcRead"),
                Conn.默认日志
            );
            ssx1xPlcRead = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "ssx1xPlcRead"),
                Conn.默认日志
            );
            ssx3xPlcRead = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "ssx3xPlcRead"),
                Conn.默认日志
            );
            PLC10 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
            (
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "PLC10"),
                Conn.默认日志
            );
            if(System.Configuration.ConfigurationManager.AppSettings["AutoRunPLC"]=="1")
            {
                if(PLC1!=null){PLC1.Run();}
                if(西门子2!=null){西门子2.Run();}
                if(维希尔抓臂1!=null){维希尔抓臂1.Run();}
                if(维希尔抓臂2!=null){维希尔抓臂2.Run();}
                if(捷瞬输送1!=null){捷瞬输送1.Run();}
                if(捷瞬输送2!=null){捷瞬输送2.Run();}
                if(捷瞬抓臂1!=null){捷瞬抓臂1.Run();}
                if(捷瞬抓臂2!=null){捷瞬抓臂2.Run();}
                if(wxwp!=null){wxwp.Run();}
                if(wxrp!=null){wxrp.Run();}
                if(warp!=null){warp.Run();}
                if(ssx2xPlcRead!=null){ssx2xPlcRead.Run();}
                if(ssx1xPlcRead!=null){ssx1xPlcRead.Run();}
                if(ssx3xPlcRead!=null){ssx3xPlcRead.Run();}
                if(PLC10!=null){PLC10.Run();}
            }
        }
    }
    #endregion
    
    #region 简单PLC
        
    /// <summary>
    /// PLC变量组
    /// </summary>
    public class EasyPLC
    {
        #region PLC1
        public _PLC1 PLC1 = new _PLC1();
        /// <summary>
        /// xxx
        /// </summary>        
        public class _PLC1
        {
            public _Group1 Group1 = new _Group1();
            /// <summary>
            /// 
            /// </summary>    
            public class _Group1
            {
                public string Param2 = "";
                public string Param3 = "";
 
                public bool Write()
                {
                    GZ.Modular.Redis.WriteGroupEntity group = new GZ.Modular.Redis.WriteGroupEntity();
                    group.groupName = "PLC1.Group1";
                    group.queueStatus = 1;
                    group.queueTime = DateTime.Now;
                    group.writeList = new List<GZ.Modular.Redis.ParamData>();
 
                    GZ.Modular.Redis.ParamData p_Param2 = new GZ.Modular.Redis.ParamData();
                    p_Param2.paramName = "PLC1.Param2";
                    p_Param2.paramValue = Param2;
                    group.writeList.Add(p_Param2);
 
                    GZ.Modular.Redis.ParamData p_Param3 = new GZ.Modular.Redis.ParamData();
                    p_Param3.paramName = "PLC1.Param3";
                    p_Param3.paramValue = Param3;
                    group.writeList.Add(p_Param3);
 
                    string lastKey = "";
                    string lastVal = "";
                    return Conn.默认Redis.SetQueue(group, "PLC1Queue", lastKey, lastVal);
                }
            }
            public _Group2 Group2 = new _Group2();
            /// <summary>
            /// 
            /// </summary>    
            public class _Group2
            {
                public string Param4 = "";
                public string Param5 = "";
 
                public bool Write()
                {
                    GZ.Modular.Redis.WriteGroupEntity group = new GZ.Modular.Redis.WriteGroupEntity();
                    group.groupName = "PLC1.Group2";
                    group.queueStatus = 1;
                    group.queueTime = DateTime.Now;
                    group.writeList = new List<GZ.Modular.Redis.ParamData>();
 
                    GZ.Modular.Redis.ParamData p_Param4 = new GZ.Modular.Redis.ParamData();
                    p_Param4.paramName = "PLC1.Param4";
                    p_Param4.paramValue = Param4;
                    group.writeList.Add(p_Param4);
 
                    GZ.Modular.Redis.ParamData p_Param5 = new GZ.Modular.Redis.ParamData();
                    p_Param5.paramName = "PLC1.Param5";
                    p_Param5.paramValue = Param5;
                    group.writeList.Add(p_Param5);
 
                    string lastKey = "";
                    string lastVal = "";
                    return Conn.默认Redis.SetQueue(group, "PLC1Queue", lastKey, lastVal);
                }
            }
        }
        #endregion
        
        #region 西门子2
        public _西门子2 西门子2 = new _西门子2();
        /// <summary>
        /// 
        /// </summary>        
        public class _西门子2
        {
        }
        #endregion
        
        #region 维希尔抓臂1
        public _维希尔抓臂1 维希尔抓臂1 = new _维希尔抓臂1();
        /// <summary>
        /// 
        /// </summary>        
        public class _维希尔抓臂1
        {
        }
        #endregion
        
        #region 维希尔抓臂2
        public _维希尔抓臂2 维希尔抓臂2 = new _维希尔抓臂2();
        /// <summary>
        /// 
        /// </summary>        
        public class _维希尔抓臂2
        {
        }
        #endregion
        
        #region 捷瞬输送1
        public _捷瞬输送1 捷瞬输送1 = new _捷瞬输送1();
        /// <summary>
        /// 
        /// </summary>        
        public class _捷瞬输送1
        {
        }
        #endregion
        
        #region 捷瞬输送2
        public _捷瞬输送2 捷瞬输送2 = new _捷瞬输送2();
        /// <summary>
        /// 
        /// </summary>        
        public class _捷瞬输送2
        {
        }
        #endregion
        
        #region 捷瞬抓臂1
        public _捷瞬抓臂1 捷瞬抓臂1 = new _捷瞬抓臂1();
        /// <summary>
        /// 
        /// </summary>        
        public class _捷瞬抓臂1
        {
        }
        #endregion
        
        #region 捷瞬抓臂2
        public _捷瞬抓臂2 捷瞬抓臂2 = new _捷瞬抓臂2();
        /// <summary>
        /// 
        /// </summary>        
        public class _捷瞬抓臂2
        {
        }
        #endregion
        
        #region wxwp
        public _wxwp wxwp = new _wxwp();
        /// <summary>
        /// wcs write plc
        /// </summary>        
        public class _wxwp
        {
        }
        #endregion
        
        #region wxrp
        public _wxrp wxrp = new _wxrp();
        /// <summary>
        /// wcs read plc
        /// </summary>        
        public class _wxrp
        {
        }
        #endregion
        
        #region warp
        public _warp warp = new _warp();
        /// <summary>
        /// wcs read turn agv
        /// </summary>        
        public class _warp
        {
        }
        #endregion
        
        #region ssx2xPlcRead
        public _ssx2xPlcRead ssx2xPlcRead = new _ssx2xPlcRead();
        /// <summary>
        /// 出烤箱区
        /// </summary>        
        public class _ssx2xPlcRead
        {
        }
        #endregion
        
        #region ssx1xPlcRead
        public _ssx1xPlcRead ssx1xPlcRead = new _ssx1xPlcRead();
        /// <summary>
        /// 进烤区
        /// </summary>        
        public class _ssx1xPlcRead
        {
        }
        #endregion
        
        #region ssx3xPlcRead
        public _ssx3xPlcRead ssx3xPlcRead = new _ssx3xPlcRead();
        /// <summary>
        /// 部件区
        /// </summary>        
        public class _ssx3xPlcRead
        {
        }
        #endregion
        
        #region PLC10
        public _PLC10 PLC10 = new _PLC10();
        /// <summary>
        /// 
        /// </summary>        
        public class _PLC10
        {
        }
        #endregion
        
    }
 
    #endregion
}