ke_junjie
2025-06-04 84620534eb627e95811b971a4b552b6a177829bf
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
using iWareSda.Common;
 
using System;
using System.Collections.Generic;
using System.Threading;
 
namespace iWareSda
{
    public class HuscoLineEntity : IDevice
    {
        public HuscoLineEntity()
        {
            this.View = new HuscoLineView();
        }
 
        #region OPC相关
 
        /// <summary>
        /// 线体 写的DB块
        /// </summary>
        public HuscoLineDBForWrite DBBlockForWrite { get; set; }
 
        /// <summary>
        /// 线体 读的DB块
        /// </summary>
        public HuscoLineDBForRead DBBlockForRead { get; set; }
 
        /// <summary>
        /// 读取PLC实例
        /// </summary>
        public PLCService plcService { get; set; }
 
        /// <summary>
        /// 视图对象
        /// </summary>
        public HuscoLineView View { get; set; }
 
 
        #endregion
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        public void InitData()
        {
            //IsConnected = false;
            //IsHeartBeat = false;
 
        }
        public HuscoLineEntity(string DeviceName, int deviceId, HuscoLineDBForWrite _dbBlockForWrite, HuscoLineDBForRead _dbBlockForRead, PLCService _plcService)
        {
            this.View = new HuscoLineView();
            this.View.DeviceName = DeviceName;
            this.View.DeviceId = deviceId;
            plcService = _plcService;
            DBBlockForWrite = _dbBlockForWrite;
            DBBlockForRead = _dbBlockForRead;
        }
 
 
        public void SetPropertyValueForRead()
        {
            var r_dbHeader = HuscoLine_CacheEntity.R_DBHeader;
            var r_dbBlock = this.DBBlockForRead;
            SdaHelper.SetPropertyValueForDB<HuscoLineDBForRead, HuscoLineView>(r_dbBlock, this.View, this.plcService, r_dbHeader, true);
        }
 
        public void SetPropertyValueForWrite()
        {
            var w_dbHeader = HuscoLine_CacheEntity.W_DBHeader;
            var w_dbBlock = this.DBBlockForWrite;
            SdaHelper.SetPropertyValueForDB<HuscoLineDBForWrite, HuscoLineView>(w_dbBlock, this.View, this.plcService, w_dbHeader, true);
        }
 
 
 
        #region 获取当前报警信息
 
 
 
        /// <summary>
        /// 获取当前报警信息
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.List<string> GetAlertDatas()
        {
            List<string> db_warningList = new List<string>();
            try
            {
                System.Collections.Generic.List<string> alertList = new System.Collections.Generic.List<string>();
 
                string _dbValue;
                var isHasAlert = false;
                IDictionary<string, string> srmAlertDict = new Dictionary<string, string>();
                //srmAlertDict = WareSdaStruct.lineAlertDict_1;
                foreach (var item in srmAlertDict)
                {
                    _dbValue = item.Key;
                    isHasAlert = Convert.ToBoolean(this.plcService.ReadValuePoint(HuscoLine_CacheEntity.R_DBHeader, item.Key, typeof(bool)));
                    if (isHasAlert)
                    {
                        db_warningList.Add(item.Value.Trim());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return db_warningList;
        }
 
 
        #endregion
 
 
        public bool IsHaveHeatBeat()
        {
            throw new NotImplementedException();
        }
    }
}