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相关 /// /// 线体 写的DB块 /// public HuscoLineDBForWrite DBBlockForWrite { get; set; } /// /// 线体 读的DB块 /// public HuscoLineDBForRead DBBlockForRead { get; set; } /// /// 读取PLC实例 /// public PLCService plcService { get; set; } /// /// 视图对象 /// public HuscoLineView View { get; set; } #endregion /// /// 初始化数据 /// 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(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(w_dbBlock, this.View, this.plcService, w_dbHeader, true); } #region 获取当前报警信息 /// /// 获取当前报警信息 /// /// public System.Collections.Generic.List GetAlertDatas() { List db_warningList = new List(); try { System.Collections.Generic.List alertList = new System.Collections.Generic.List(); string _dbValue; var isHasAlert = false; IDictionary srmAlertDict = new Dictionary(); //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(); } } }