Пример #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
            });
        }
Пример #2
0
        /// <summary>
        /// 写报警记录,包括异常清除写入
        /// </summary>
        public void WriteErrWithCheck(string val, string index, string lineNum)
        {
            String deviceNo = "" + index;
            string lastInfo = fileOper.ReadLastInfo(deviceNo).Trim();

            if (lastInfo == "")
            {
                lastInfo = "0";
            }
            if (lastInfo != val)
            {
                String errMsg = "";//取数据库取对应的错误信息
                if (val == "0")
                {
                    errMsg = "消除将来从数据库获取"; //取数据库取对应的错误信息
                }
                else
                {
                    errMsg = "消除将来从数据库获取another one";
                }
                ErrListService.Add(deviceNo, decimal.Parse(lineNum), 50, errMsg, val);
            }

            fileOper.write(new DeviceStateInfoModel
            {
                DeviceNo    = deviceNo,
                AlarmsValue = val
            });
        }
Пример #3
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
            });
        }
Пример #4
0
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="type"></param>
        /// <param name="len"></param>
        /// <param name="temp"></param>
        /// <param name="GroupNo"></param>
        public void WriteErrToDB(int type, int len, String temp, decimal GroupNo)
        {
            String deviceNo = "" + len;

            for (int i = 1; i <= temp.Length; i++)
            {
                if (temp.ElementAt(i - 1) == '1')
                {
                    String errMsg = getErrMsg(temp.Length - i);
                    ErrListService.Add(deviceNo, GroupNo, 10, errMsg, temp.ElementAt(i - 1).ToString());
                    AlarmsInfo info = new AlarmsInfo {
                        DeviceNo = len, DeviceName = deviceNo, ErrInfo = errMsg
                    };
                    AlarmsHandler(info);
                    Downtime(info, errMsg, temp);
                }
            }
        }