Exemplo n.º 1
0
        /// <summary>
        /// 写报警记录,包括异常清除写入
        /// </summary>
        /// <param name="type"></param>
        /// <param name="len"></param>
        /// <param name="temp"></param>
        /// <param name="GroupNo"></param>
        public void WriteErrWithCheck(int type, int len, String temp, decimal GroupNo)
        {
            String deviceNo = "" + len;
            string lastInfo = xml.ReadLastInfo(deviceNo);// fileOper.ReadLastInfo(deviceNo).Trim();
            string compStrs;
            string rese = string.Empty;
            //高低位反转
            //temp.Reverse().ToList().ForEach(s => { rese += s; });
            List <OperationChar> lst      = UnionBit.Union(lastInfo, temp, out compStrs);
            List <OperationChar> lstWhere = lst.Where(w => w.op != Oper.None).ToList();

            foreach (OperationChar item in lstWhere)
            {
                if (item.bit >= 0 && item.bit <= 7)
                {
                    String errMsg = item.val == "0" ? string.Format("消除{0}", getErrMsg(item.bit)) : getErrMsg(item.bit);
                    ErrListService.Add(deviceNo, GroupNo, 40, errMsg, item.val);
                    AlarmsInfo info = new AlarmsInfo {
                        DeviceNo = len, DeviceName = deviceNo, ErrInfo = errMsg
                    };
                    AlarmsHandler(info);
                    Downtime(info, errMsg, temp);
                }
            }
            //fileOper.Write(compStrs, deviceNo);
            xml.write(new AlarmsFileModel {
                DeviceNo = deviceNo, AlarmsValue = temp
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 写报警记录,包括异常清除写入
        /// </summary>
        /// <param name="type"></param>
        /// <param name="len"></param>
        /// <param name="temp"></param>
        /// <param name="GroupNo"></param>
        /// <param name="type">1皮带 2 烟柜 3 机械手</param>
        public void WriteErrWithCheck(string len, int GroupNo, String temp, int type)
        {
            String deviceNo = "" + len;
            string lastInfo = fileOper.ReadLastInfo(deviceNo).Trim();
            string compStrs;

            if (temp == null || temp == "")
            {
                return;
            }

            List <OperationChar> lst      = UnionBit.Union(lastInfo, temp, out compStrs);
            List <OperationChar> lstWhere = lst.Where(w => w.op != Oper.None).ToList();
            bool isneedWrite = false;

            foreach (OperationChar item in lstWhere)
            {
                isneedWrite = false;
                if (type == 1)
                {
                    if (item.bit == 13 || item.bit == 15 || (item.bit >= 1 && item.bit <= 6))//5 9 10 11 12 13 14
                    {
                        isneedWrite = true;
                    }
                }
                else if (type == 2)

                {
                    if ((item.bit >= 9 && item.bit <= 14))//9 10 11 12 13 14
                    {
                        isneedWrite = true;
                    }
                }
                else if (type == 3) // 6 7
                {
                    if ((item.bit >= 14 && item.bit <= 15))
                    {
                        isneedWrite = true;
                    }
                }
                if (isneedWrite)
                {
                    String errMsg = item.val == "0" ? string.Format("消除{0}", OnGetErr(item.bit, type)) : OnGetErr(item.bit, type);
                    ErrListService.Add(deviceNo, GroupNo, 10, errMsg, item.val);
                    DeviceStateInfoModel info = new DeviceStateInfoModel {
                        DeviceNo = len, DeviceName = deviceNo, ErrInfo = errMsg
                    };
                    if (AlarmsHandler != null)
                    {
                        AlarmsHandler(info);
                    }
                }
            }
            fileOper.write(new DeviceStateInfoModel
            {
                DeviceNo    = deviceNo,
                AlarmsValue = temp
            });
        }