예제 #1
0
 /// <summary>
 /// 异常告警
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void device_AlarmHandle(object sender, DvAlarmEventArgs e)
 {
     if (null == e || string.IsNullOrEmpty(e.DeviceID) || string.IsNullOrEmpty(e.TagAlarm))
     {
         return;
     }
     this.sendclientdata(e.DeviceID, "alarm", Encoding.GetEncoding("GB2312").GetBytes(e.TagInfo));
 }
예제 #2
0
        /// <summary>
        /// 触发告警发生或结束事件
        /// </summary>
        /// <param name="arg"></param>
        public virtual void RaiseAlarm(DvAlarmEventArgs arg)
        {
            EventHandler <DvAlarmEventArgs> handle = this.AlarmHandle;

            if (null == handle || null == arg)
            {
                return;
            }
            if (string.IsNullOrEmpty(arg.DeviceID) || string.IsNullOrEmpty(arg.TagInfo) || string.IsNullOrEmpty(arg.TagAlarm))
            {
                return;
            }
            handle(this, arg);
        }
예제 #3
0
        /// <summary>
        /// 火警联动
        /// </summary>
        /// <param name="sender">门禁设备</param>
        /// <param name="e">报警事件</param>
        void device_AlarmHandle(object sender, DvAlarmEventArgs e)
        {
            DeviceDoor door = sender as DeviceDoor;

            if (null == door || null == e || string.IsNullOrEmpty(e.TagAlarm))
            {
                return;
            }
            string fire = basefun.valtag(e.TagAlarm, "火警");

            if ("1" != fire)
            {
                return;
            }
            NameObjectList ps = new NameObjectList();

            ps["设备ID"] = door.DevID;
            DataTable    tab      = this.query.getTable("同组设备", ps);
            CommiManager commimgr = CommiManager.GlobalManager;

            for (int i = 0; i < tab.Rows.Count; i++)
            {
                DataRow dr     = tab.Rows[i];
                string  dvid   = Convert.ToString(dr["ID"]);
                string  dvtype = Convert.ToString(dr["通讯协议"]);
                if (string.IsNullOrEmpty(dvtype) || DBNull.Value == dr["站址"])
                {
                    return;
                }
                int         station = Convert.ToInt32(dr["站址"]);
                CommiTarget target  = this.getTarget(dr);
                if (null == target)
                {
                    return;
                }
                target.setProtocol(Protocol.PTLDoor);
                door = new DeviceDoor();
                door.SetDevice(commimgr, target, dvid, station);
                door.FireOpenDoor();
            }
        }
예제 #4
0
        /// <summary>
        /// 验证状态信息,对状态对比变化时生成事件记录
        /// </summary>
        /// <param name="item">巡检项</param>
        /// <param name="devid">控制器ID</param>
        /// <param name="taginfo">状态信息tag标记值</param>
        private void validateSate(string taginfo)
        {
            if (string.IsNullOrEmpty(taginfo))
            {
                return;
            }
            Dictionary <string, string[]> dictstate = new Dictionary <string, string[]>();

            string[] alarm = { "时间格式错", "读头故障", "权限校验错", "时段参数错", "收费参数错", "黑名单错" };
            dictstate.Add("内部状态", alarm);

            //检查前后状态改变;alarmmsg报警信息,isalarm当前是否报警改变
            NameObjectList psevent = new NameObjectList();

            psevent["消费机"] = this.devid;
            psevent["时间"]  = basefun.valtag(taginfo, "{当前时间}");
            alarm          = new string[] { "内部状态" };
            string msg = "";

            foreach (string state in alarm)
            {
                //对比状态生成事件
                psevent["事件"] = state;
                string tagorgi   = this.tagInfos[state];
                string tagnews   = "";
                bool   ischanged = false;
                foreach (string st in dictstate[state])
                {
                    string valorg = basefun.valtag(tagorgi, st);
                    if (string.IsNullOrEmpty(valorg))
                    {
                        valorg = "0";
                    }
                    string valnew = basefun.valtag(taginfo, st);
                    tagnews = basefun.setvaltag(tagnews, st, valnew);
                    if (valorg == valnew)
                    {
                        continue;
                    }
                    ischanged     = true;
                    psevent["内容"] = st;
                    msg           = basefun.setvaltag(msg, st, valnew);
                    if ("1" != valnew)
                    {
                        this.query.ExecuteNonQuery("结束消费机事件", psevent, psevent, psevent);
                    }
                    else
                    {
                        this.query.ExecuteNonQuery("发生消费机事件", psevent, psevent, psevent);
                    }
                }
                this.tagInfos[state] = tagnews;
                if (!ischanged)
                {
                    continue;
                }
                psevent["类别"] = state;
                psevent["内容"] = tagnews;
                this.query.ExecuteNonQuery("消费巡检状态", psevent, psevent, psevent);
            }//foreach (string state in alarm)
            if (string.IsNullOrEmpty(this.Alarm.tag))
            {
                this.Alarm.tag       = taginfo;
                this.Alarm.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(this.Signal.tag))
            {
                this.Signal.tag       = taginfo;
                this.Signal.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(msg))
            {
                return;
            }
            this.Alarm.dtReceive = DateTime.Now;
            this.Alarm.tag       = taginfo;
            DateTime         dt  = Convert.ToDateTime(basefun.valtag(taginfo, "{当前时间}"));
            DvAlarmEventArgs arg = new DvAlarmEventArgs(this.devid, this.station, dt, taginfo);

            arg.TagAlarm = msg;
            this.RaiseAlarm(arg);
        }
예제 #5
0
 /// <summary>
 /// �����澯����������¼�
 /// </summary>
 /// <param name="arg"></param>
 public virtual void RaiseAlarm(DvAlarmEventArgs arg)
 {
     EventHandler<DvAlarmEventArgs> handle = this.AlarmHandle;
     if (null == handle || null == arg)
         return;
     if (string.IsNullOrEmpty(arg.DeviceID) || string.IsNullOrEmpty(arg.TagInfo) || string.IsNullOrEmpty(arg.TagAlarm))
         return;
     handle(this, arg);
 }
예제 #6
0
        /// <summary>
        /// 验证状态信息,对状态对比变化时生成事件记录
        /// </summary>
        /// <param name="item">巡检项</param>
        /// <param name="devid">控制器ID</param>
        /// <param name="taginfo">状态信息tag标记值</param>
        private string validateSate(string taginfo)
        {
            if (string.IsNullOrEmpty(taginfo))
            {
                return(taginfo);
            }
            Dictionary <string, string[]> dictstate = new Dictionary <string, string[]>();

            string[] alarm = { "4号门报警", "3号门报警", "2号门报警", "1号门报警" };
            dictstate.Add("报警", alarm);
            alarm = new string[] { "火警", "无效刷卡", "联动报警", "非法闯入", "超时", "胁迫" };
            dictstate.Add("警报", alarm);
            alarm = new string[] { "芯片故障", "系统故障4", "时钟故障", "系统故障2", "系统故障1" };
            dictstate.Add("故障", alarm);
            alarm = new string[] { "按钮4状态", "按钮3状态", "按钮2状态", "按钮1状态" };
            dictstate.Add("按钮", alarm);
            alarm = new string[] { "门磁4状态", "门磁3状态", "门磁2状态", "门磁1状态" };
            dictstate.Add("门磁", alarm);
            alarm = new string[] { "继4状态", "继3状态", "继2状态", "继1状态" };
            dictstate.Add("继电器", alarm);
            //火警报警,WG板子使用火警事件记录来反映的
            string strstate = this.getStateDoorCard(basefun.valtag(taginfo, "{刷卡卡号}"),
                                                    basefun.valtag(taginfo, "状态编号"), basefun.valtag(taginfo, "读卡器"));

            if ("火警报警" == strstate)
            {
                taginfo = basefun.setvaltag(taginfo, "火警", "1");
                foreach (string k in dictstate["报警"])
                {
                    taginfo = basefun.setvaltag(taginfo, k, "1");
                }
            }
            //检查前后状态改变;alarmmsg报警信息,isalarm当前是否报警改变
            string         msg = "", alarmmsg = "", msgsigal = "";
            bool           isalarm = false;
            NameObjectList psevent = new NameObjectList();

            psevent["控制器"] = this.devid;
            DateTime dt = DateTime.MinValue;

            try
            {
                psevent["时间"] = dt = Convert.ToDateTime(basefun.valtag(taginfo, "{当前时间}"));
            }
            catch { dt = DateTime.MinValue; }
            if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
            {
                NameValueCollection datainfo = new NameValueCollection();
                datainfo["操作"] = "巡检状态";
                ServiceTool.LogMessage(taginfo, datainfo, EventLogEntryType.FailureAudit);
                if (null == dtobj)
                {
                    return(taginfo);
                }
                try { dt = Convert.ToDateTime(dtobj); }
                catch { return(taginfo); }
                if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
                {
                    return(taginfo);
                }
                psevent["时间"] = dtobj;
            }
            else
            {
                dtobj = psevent["时间"];
            }
            alarm = new string[] { "警报", "报警", "故障", "按钮", "门磁", "继电器" };
            foreach (string state in alarm)
            {
                //对比状态生成事件
                psevent["事件"] = state;
                string tagorgi   = this.tagInfos[state];
                string tagnews   = "";
                bool   ischanged = false;
                int    inum      = 5;
                foreach (string st in dictstate[state])
                {
                    inum--;
                    string valorg = basefun.valtag(tagorgi, st);
                    if (string.IsNullOrEmpty(valorg))
                    {
                        valorg = "0";
                    }
                    string valnew = basefun.valtag(taginfo, st);
                    tagnews = basefun.setvaltag(tagnews, st, valnew);
                    if ("警报" == state && "1" == valnew)
                    {
                        if (string.IsNullOrEmpty(alarmmsg))
                        {
                            alarmmsg = st;
                        }
                        else
                        {
                            alarmmsg += "," + st;
                        }
                    }
                    if (valorg == valnew && ("报警" != state || !isalarm))
                    {
                        continue;
                    }
                    ischanged = true;
                    if ("警报" == state)
                    {
                        continue;
                    }
                    //处理事件
                    if ("报警" == state || "故障" == state)
                    {
                        if ("报警" == state)
                        {
                            psevent["编号"] = inum.ToString();
                            psevent["内容"] = st + "(" + alarmmsg + ")";
                        }
                        else
                        {
                            psevent.Remove("编号");
                            psevent["内容"] = st;
                        }
                        msg = basefun.setvaltag(msg, st, valnew);
                        try
                        {
                            Monitor.Enter(objquery);
                            if ("1" == valnew)
                            {
                                this.query.ExecuteNonQuery("发生道闸事件", psevent, psevent, psevent);
                            }
                            else
                            {
                                this.query.ExecuteNonQuery("结束道闸事件", psevent, psevent, psevent);
                            }
                        }
                        finally
                        {
                            Monitor.PulseAll(objquery);
                            Monitor.Exit(objquery);
                        }
                    }
                    else
                    {
                        psevent["编号"] = inum.ToString();
                        psevent["内容"] = st + "变位 " + valnew;
                        msgsigal      = basefun.setvaltag(msgsigal, st, valnew);
                        try
                        {
                            Monitor.Enter(objquery);
                            this.query.ExecuteNonQuery("道闸变位事件", psevent, psevent, psevent);
                        }
                        finally
                        {
                            Monitor.PulseAll(objquery);
                            Monitor.Exit(objquery);
                        }
                    }
                }//foreach (string st in dictstate[state])
                this.tagInfos[state] = tagnews;
                if (!ischanged)
                {
                    continue;
                }
                psevent["类别"] = state;
                psevent["内容"] = tagnews;
                try
                {
                    Monitor.Enter(objquery);
                    this.query.ExecuteNonQuery("道闸巡检状态", psevent, psevent, psevent);
                }
                finally
                {
                    Monitor.PulseAll(objquery);
                    Monitor.Exit(objquery);
                }
                //报警内容变化时,先结束原警报事件
                if ("警报" == state)
                {
                    isalarm = !string.IsNullOrEmpty(alarmmsg);
                    if (!isalarm)
                    {
                        foreach (string a in dictstate[state])
                        {
                            msg = basefun.setvaltag(msg, a, "0");
                        }
                    }
                    psevent.Remove("编号");
                    try
                    {
                        Monitor.Enter(objquery);
                        this.query.ExecuteNonQuery("结束道闸事件", psevent, psevent, psevent);
                    }
                    finally
                    {
                        Monitor.PulseAll(objquery);
                        Monitor.Exit(objquery);
                    }
                }
            }//foreach (string state in alarm)
            if (string.IsNullOrEmpty(this.Alarm.tag))
            {
                this.Alarm.tag       = taginfo;
                this.Alarm.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(this.Signal.tag))
            {
                this.Signal.tag       = taginfo;
                this.Signal.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(msg) && string.IsNullOrEmpty(msgsigal))
            {
                return(taginfo);
            }
            if (!string.IsNullOrEmpty(msg))
            {
                alarm = alarmmsg.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string a in alarm)
                {
                    msg = basefun.setvaltag(msg, a, "1");
                }
                this.Alarm.dtReceive = DateTime.Now;
                this.Alarm.tag       = taginfo;
                this.Signal.tag      = taginfo;
                DvAlarmEventArgs arg = new DvAlarmEventArgs(this.devid, this.station, dt, taginfo);
                arg.TagAlarm = msg;
                this.RaiseAlarm(arg);
            }
            if (!string.IsNullOrEmpty(msgsigal))
            {
                this.Signal.dtReceive = DateTime.Now;
                this.Signal.tag       = taginfo;
                this.Alarm.tag        = taginfo;
                DvSignalEventArgs arg = new DvSignalEventArgs(this.devid, this.station, dt, taginfo);
                arg.TagSignal = msgsigal;
                this.RaiseSignal(arg);
            }
            return(taginfo);
        }
 /// <summary>
 /// 异常告警
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void device_AlarmHandle(object sender, DvAlarmEventArgs e)
 {
     if (null == e || string.IsNullOrEmpty(e.DeviceID) || string.IsNullOrEmpty(e.TagAlarm))
         return;
     this.sendclientdata(e.DeviceID, "alarm", Encoding.GetEncoding("GB2312").GetBytes(e.TagInfo));
 }
예제 #8
0
        /// <summary>
        /// ��֤״̬��Ϣ,��״̬�Աȱ仯ʱ�����¼���¼
        /// </summary>
        /// <param name="item">Ѳ����</param>
        /// <param name="devid">������ID</param>
        /// <param name="taginfo">״̬��Ϣtag���ֵ</param>
        private void validateSate(string taginfo)
        {
            if (string.IsNullOrEmpty(taginfo))
                return;
            Dictionary<string, string[]> dictstate = new Dictionary<string, string[]>();
            string[] alarm ={ "ʱ���ʽ��", "��ͷ����", "Ȩ��У���", "ʱ�β�����", "�շѲ�����", "��������" };
            dictstate.Add("�ڲ�״̬", alarm);

            //���ǰ��״̬�ı䣻alarmmsg������Ϣ,isalarm��ǰ�Ƿ񱨾��ı�
            NameObjectList psevent = new NameObjectList();
            psevent["���ѻ�"] = this.devid;
            psevent["ʱ��"] = basefun.valtag(taginfo, "{��ǰʱ��}");
            alarm = new string[] { "�ڲ�״̬" };
            string msg = "";
            foreach (string state in alarm)
            {
                //�Ա�״̬�����¼�
                psevent["�¼�"] = state;
                string tagorgi = this.tagInfos[state];
                string tagnews = "";
                bool ischanged = false;
                foreach (string st in dictstate[state])
                {
                    string valorg = basefun.valtag(tagorgi, st);
                    if (string.IsNullOrEmpty(valorg))
                        valorg = "0";
                    string valnew = basefun.valtag(taginfo, st);
                    tagnews = basefun.setvaltag(tagnews, st, valnew);
                    if (valorg == valnew)
                        continue;
                    ischanged = true;
                    psevent["����"] = st;
                    msg = basefun.setvaltag(msg, st, valnew);
                    if ("1" != valnew)
                        this.query.ExecuteNonQuery("�������ѻ��¼�", psevent, psevent, psevent);
                    else
                        this.query.ExecuteNonQuery("�������ѻ��¼�", psevent, psevent, psevent);
                }
                this.tagInfos[state] = tagnews;
                if (!ischanged) continue;
                psevent["���"] = state;
                psevent["����"] = tagnews;
                this.query.ExecuteNonQuery("����Ѳ��״̬", psevent, psevent, psevent);
            }//foreach (string state in alarm)
            if (string.IsNullOrEmpty(this.Alarm.tag))
            {
                this.Alarm.tag = taginfo;
                this.Alarm.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(this.Signal.tag))
            {
                this.Signal.tag = taginfo;
                this.Signal.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(msg))
                return;
            this.Alarm.dtReceive = DateTime.Now;
            this.Alarm.tag = taginfo;
            DateTime dt = Convert.ToDateTime(basefun.valtag(taginfo, "{��ǰʱ��}"));
            DvAlarmEventArgs arg = new DvAlarmEventArgs(this.devid, this.station, dt, taginfo);
            arg.TagAlarm = msg;
            this.RaiseAlarm(arg);
        }
예제 #9
0
        /// <summary>
        /// 验证状态信息,对状态对比变化时生成事件记录
        /// </summary>
        /// <param name="item">巡检项</param>
        /// <param name="devid">控制器ID</param>
        /// <param name="taginfo">状态信息tag标记值</param>
        private void validateSate(string taginfo)
        {
            if (string.IsNullOrEmpty(taginfo))
                return;
            Dictionary<string, string[]> dictstate = new Dictionary<string, string[]>();
            string[] alarm ={ "时间格式错", "读头故障", "权限校验错", "时段参数错", "收费参数错", "黑名单错" };
            dictstate.Add("内部状态", alarm);

            //检查前后状态改变;alarmmsg报警信息,isalarm当前是否报警改变
            NameObjectList psevent = new NameObjectList();
            psevent["消费机"] = this.devid;
            psevent["时间"] = basefun.valtag(taginfo, "{当前时间}");
            alarm = new string[] { "内部状态" };
            string msg = "";
            foreach (string state in alarm)
            {
                //对比状态生成事件
                psevent["事件"] = state;
                string tagorgi = this.tagInfos[state];
                string tagnews = "";
                bool ischanged = false;
                foreach (string st in dictstate[state])
                {
                    string valorg = basefun.valtag(tagorgi, st);
                    if (string.IsNullOrEmpty(valorg))
                        valorg = "0";
                    string valnew = basefun.valtag(taginfo, st);
                    tagnews = basefun.setvaltag(tagnews, st, valnew);
                    if (valorg == valnew)
                        continue;
                    ischanged = true;
                    psevent["内容"] = st;
                    msg = basefun.setvaltag(msg, st, valnew);
                    if ("1" != valnew)
                        this.query.ExecuteNonQuery("结束消费机事件", psevent, psevent, psevent);
                    else
                        this.query.ExecuteNonQuery("发生消费机事件", psevent, psevent, psevent);
                }
                this.tagInfos[state] = tagnews;
                if (!ischanged) continue;
                psevent["类别"] = state;
                psevent["内容"] = tagnews;
                this.query.ExecuteNonQuery("消费巡检状态", psevent, psevent, psevent);
            }//foreach (string state in alarm)
            if (string.IsNullOrEmpty(this.Alarm.tag))
            {
                this.Alarm.tag = taginfo;
                this.Alarm.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(this.Signal.tag))
            {
                this.Signal.tag = taginfo;
                this.Signal.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(msg))
                return;
            this.Alarm.dtReceive = DateTime.Now;
            this.Alarm.tag = taginfo;
            DateTime dt = Convert.ToDateTime(basefun.valtag(taginfo, "{当前时间}"));
            DvAlarmEventArgs arg = new DvAlarmEventArgs(this.devid, this.station, dt, taginfo);
            arg.TagAlarm = msg;
            this.RaiseAlarm(arg);
        }
예제 #10
0
        /// <summary>
        /// 验证状态信息,对状态对比变化时生成事件记录
        /// </summary>
        /// <param name="item">巡检项</param>
        /// <param name="devid">控制器ID</param>
        /// <param name="taginfo">状态信息tag标记值</param>
        private void validateSate(string taginfo)
        {
            if (string.IsNullOrEmpty(taginfo))
            {
                return;
            }
            Dictionary <string, string[]> dictstate = new Dictionary <string, string[]>();

            string[] alarm = { "4号门报警", "3号门报警", "2号门报警", "1号门报警" };
            dictstate.Add("报警", alarm);
            alarm = new string[] { "火警", "无效刷卡", "联动报警", "非法闯入", "超时", "胁迫" };
            dictstate.Add("警报", alarm);
            alarm = new string[] { "芯片故障", "系统故障4", "时钟故障", "系统故障2", "系统故障1" };
            dictstate.Add("故障", alarm);
            alarm = new string[] { "按钮4状态", "按钮3状态", "按钮2状态", "按钮1状态" };
            dictstate.Add("按钮", alarm);
            alarm = new string[] { "门磁4状态", "门磁3状态", "门磁2状态", "门磁1状态" };
            dictstate.Add("门磁", alarm);
            alarm = new string[] { "继4状态", "继3状态", "继2状态", "继1状态" };
            dictstate.Add("继电器", alarm);

            //检查前后状态改变;alarmmsg报警信息,isalarm当前是否报警改变
            string         msg = "", alarmmsg = "", msgsigal = "";
            bool           isalarm = false;
            NameObjectList psevent = new NameObjectList();

            psevent["控制器"] = this.devid;
            psevent["时间"]  = basefun.valtag(taginfo, "{当前时间}");
            alarm          = new string[] { "警报", "报警", "故障", "按钮", "门磁", "继电器" };
            foreach (string state in alarm)
            {
                //对比状态生成事件
                psevent["事件"] = state;
                string tagorgi   = this.tagInfos[state];
                string tagnews   = "";
                bool   ischanged = false;
                int    inum      = 5;
                foreach (string st in dictstate[state])
                {
                    inum--;
                    string valorg = basefun.valtag(tagorgi, st);
                    if (string.IsNullOrEmpty(valorg))
                    {
                        valorg = "0";
                    }
                    string valnew = basefun.valtag(taginfo, st);
                    tagnews = basefun.setvaltag(tagnews, st, valnew);
                    if ("警报" == state && "1" == valnew)
                    {
                        if (string.IsNullOrEmpty(alarmmsg))
                        {
                            alarmmsg = st;
                        }
                        else
                        {
                            alarmmsg += "," + st;
                        }
                    }
                    if (valorg == valnew && ("报警" != state || !isalarm))
                    {
                        continue;
                    }
                    ischanged = true;
                    if ("警报" == state)
                    {
                        continue;
                    }
                    //处理事件
                    if ("报警" == state || "故障" == state)
                    {
                        if ("报警" == state)
                        {
                            psevent["编号"] = inum.ToString();
                            psevent["内容"] = st + "(" + alarmmsg + ")";
                        }
                        else
                        {
                            psevent.Remove("编号");
                            psevent["内容"] = st;
                        }
                        msg = basefun.setvaltag(msg, st, valnew);
                        if ("1" == valnew)
                        {
                            this.query.ExecuteNonQuery("发生门禁事件", psevent, psevent, psevent);
                        }
                        else
                        {
                            this.query.ExecuteNonQuery("结束门禁事件", psevent, psevent, psevent);
                        }
                    }
                    else
                    {
                        psevent["编号"] = inum.ToString();
                        psevent["内容"] = st + "变位 " + valnew;
                        msgsigal      = basefun.setvaltag(msgsigal, st, valnew);
                        this.query.ExecuteNonQuery("门禁变位事件", psevent, psevent, psevent);
                    }
                }//foreach (string st in dictstate[state])
                this.tagInfos[state] = tagnews;
                if (!ischanged)
                {
                    continue;
                }
                psevent["类别"] = state;
                psevent["内容"] = tagnews;
                this.query.ExecuteNonQuery("门禁巡检状态", psevent, psevent, psevent);
                //报警内容变化时,先结束原警报事件
                if ("警报" == state)
                {
                    isalarm = !string.IsNullOrEmpty(alarmmsg);
                    if (!isalarm)
                    {
                        foreach (string a in dictstate[state])
                        {
                            msg = basefun.setvaltag(msg, a, "0");
                        }
                    }
                    psevent.Remove("编号");
                    this.query.ExecuteNonQuery("结束门禁事件", psevent, psevent, psevent);
                }
            }//foreach (string state in alarm)
            if (string.IsNullOrEmpty(this.Alarm.tag))
            {
                this.Alarm.tag       = taginfo;
                this.Alarm.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(this.Signal.tag))
            {
                this.Signal.tag       = taginfo;
                this.Signal.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(msg) && string.IsNullOrEmpty(msgsigal))
            {
                return;
            }
            DateTime dt = Convert.ToDateTime(basefun.valtag(taginfo, "{当前时间}"));

            if (!string.IsNullOrEmpty(msg))
            {
                alarm = alarmmsg.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string a in alarm)
                {
                    msg = basefun.setvaltag(msg, a, "1");
                }
                this.Alarm.dtReceive = DateTime.Now;
                this.Alarm.tag       = taginfo;
                DvAlarmEventArgs arg = new DvAlarmEventArgs(this.devid, this.station, dt, taginfo);
                arg.TagAlarm = msg;
                this.RaiseAlarm(arg);
            }
            if (!string.IsNullOrEmpty(msgsigal))
            {
                this.Signal.dtReceive = DateTime.Now;
                this.Signal.tag       = taginfo;
                DvSignalEventArgs arg = new DvSignalEventArgs(this.devid, this.station, dt, taginfo);
                arg.TagSignal = msgsigal;
                this.RaiseSignal(arg);
            }
        }
예제 #11
0
 /// <summary>
 /// 验证状态信息,对状态对比变化时生成事件记录
 /// </summary>
 /// <param name="item">巡检项</param>
 /// <param name="devid">控制器ID</param>
 /// <param name="taginfo">状态信息tag标记值</param>
 private string validateSate(string taginfo)
 {
     if (string.IsNullOrEmpty(taginfo))
         return taginfo;
     Dictionary<string, string[]> dictstate = new Dictionary<string, string[]>();
     string[] alarm ={ "4号门报警", "3号门报警", "2号门报警", "1号门报警" };
     dictstate.Add("报警", alarm);
     alarm = new string[] { "火警", "无效刷卡", "联动报警", "非法闯入", "超时", "胁迫" };
     dictstate.Add("警报", alarm);
     alarm = new string[] { "芯片故障", "系统故障4", "时钟故障", "系统故障2", "系统故障1" };
     dictstate.Add("故障", alarm);
     alarm = new string[] { "按钮4状态", "按钮3状态", "按钮2状态", "按钮1状态" };
     dictstate.Add("按钮", alarm);
     alarm = new string[] { "门磁4状态", "门磁3状态", "门磁2状态", "门磁1状态" };
     dictstate.Add("门磁", alarm);
     alarm = new string[] { "继4状态", "继3状态", "继2状态", "继1状态" };
     dictstate.Add("继电器", alarm);
     //火警报警,WG板子使用火警事件记录来反映的
     string strstate = this.getStateDoorCard(basefun.valtag(taginfo, "{刷卡卡号}"),
                             basefun.valtag(taginfo, "状态编号"), basefun.valtag(taginfo, "读卡器"));
     if ("火警报警" == strstate)
     {
         taginfo = basefun.setvaltag(taginfo, "火警", "1");
         foreach(string k in dictstate["报警"])
             taginfo = basefun.setvaltag(taginfo, k, "1");
     }
     //检查前后状态改变;alarmmsg报警信息,isalarm当前是否报警改变
     string msg = "", alarmmsg = "", msgsigal = "";
     bool isalarm = false;
     NameObjectList psevent = new NameObjectList();
     psevent["控制器"] = this.devid;
     DateTime dt = DateTime.MinValue;
     try
     {
         psevent["时间"] = dt = Convert.ToDateTime(basefun.valtag(taginfo, "{当前时间}"));
     }
     catch { dt = DateTime.MinValue; }
     if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
     {
         NameValueCollection datainfo = new NameValueCollection();
         datainfo["操作"] = "巡检状态";
         ServiceTool.LogMessage(taginfo, datainfo, EventLogEntryType.FailureAudit);
         if (null == dtobj) return taginfo;
         try { dt = Convert.ToDateTime(dtobj); }
         catch { return taginfo; }
         if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
             return taginfo;
         psevent["时间"] = dtobj;
     }
     else
         dtobj = psevent["时间"];
     alarm = new string[] { "警报", "报警", "故障", "按钮", "门磁", "继电器" };
     foreach (string state in alarm)
     {
         //对比状态生成事件
         psevent["事件"] = state;
         string tagorgi = this.tagInfos[state];
         string tagnews = "";
         bool ischanged = false;
         int inum = 5;
         foreach (string st in dictstate[state])
         {
             inum--;
             string valorg = basefun.valtag(tagorgi, st);
             if (string.IsNullOrEmpty(valorg))
                 valorg = "0";
             string valnew = basefun.valtag(taginfo, st);
             tagnews = basefun.setvaltag(tagnews, st, valnew);
             if ("警报" == state && "1" == valnew)
             {
                 if (string.IsNullOrEmpty(alarmmsg))
                     alarmmsg = st;
                 else
                     alarmmsg += "," + st;
             }
             if (valorg == valnew && ("报警" != state || !isalarm))
                 continue;
             ischanged = true;
             if ("警报" == state) continue;
             //处理事件
             if ("报警" == state || "故障" == state)
             {
                 if ("报警" == state)
                 {
                     psevent["编号"] = inum.ToString();
                     psevent["内容"] = st + "(" + alarmmsg + ")";
                 }
                 else
                 {
                     psevent.Remove("编号");
                     psevent["内容"] = st;
                 }
                 msg = basefun.setvaltag(msg, st, valnew);
                 try
                 {
                     Monitor.Enter(objquery);
                     if ("1" == valnew)
                         this.query.ExecuteNonQuery("发生道闸事件", psevent, psevent, psevent);
                     else
                         this.query.ExecuteNonQuery("结束道闸事件", psevent, psevent, psevent);
                 }
                 finally
                 {
                     Monitor.PulseAll(objquery);
                     Monitor.Exit(objquery);
                 }
             }
             else
             {
                 psevent["编号"] = inum.ToString();
                 psevent["内容"] = st + "变位 " + valnew;
                 msgsigal = basefun.setvaltag(msgsigal, st, valnew);
                 try
                 {
                     Monitor.Enter(objquery);
                     this.query.ExecuteNonQuery("道闸变位事件", psevent, psevent, psevent);
                 }
                 finally
                 {
                     Monitor.PulseAll(objquery);
                     Monitor.Exit(objquery);
                 }
             }
         }//foreach (string st in dictstate[state])
         this.tagInfos[state] = tagnews;
         if (!ischanged) continue;
         psevent["类别"] = state;
         psevent["内容"] = tagnews;
         try
         {
             Monitor.Enter(objquery);
             this.query.ExecuteNonQuery("道闸巡检状态", psevent, psevent, psevent);
         }
         finally
         {
             Monitor.PulseAll(objquery);
             Monitor.Exit(objquery);
         }
         //报警内容变化时,先结束原警报事件
         if ("警报" == state)
         {
             isalarm = !string.IsNullOrEmpty(alarmmsg);
             if (!isalarm)
             {
                 foreach (string a in dictstate[state])
                     msg = basefun.setvaltag(msg, a, "0");
             }
             psevent.Remove("编号");
             try
             {
                 Monitor.Enter(objquery);
                 this.query.ExecuteNonQuery("结束道闸事件", psevent, psevent, psevent);
             }
             finally
             {
                 Monitor.PulseAll(objquery);
                 Monitor.Exit(objquery);
             }
         }
     }//foreach (string state in alarm)
     if (string.IsNullOrEmpty(this.Alarm.tag))
     {
         this.Alarm.tag = taginfo;
         this.Alarm.dtReceive = DateTime.Now;
     }
     if (string.IsNullOrEmpty(this.Signal.tag))
     {
         this.Signal.tag = taginfo;
         this.Signal.dtReceive = DateTime.Now;
     }
     if (string.IsNullOrEmpty(msg) && string.IsNullOrEmpty(msgsigal))
         return taginfo;
     if (!string.IsNullOrEmpty(msg))
     {
         alarm = alarmmsg.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
         foreach (string a in alarm)
             msg = basefun.setvaltag(msg, a, "1");
         this.Alarm.dtReceive = DateTime.Now;
         this.Alarm.tag = taginfo;
         this.Signal.tag = taginfo;
         DvAlarmEventArgs arg = new DvAlarmEventArgs(this.devid, this.station, dt, taginfo);
         arg.TagAlarm = msg;
         this.RaiseAlarm(arg);
     }
     if (!string.IsNullOrEmpty(msgsigal))
     {
         this.Signal.dtReceive = DateTime.Now;
         this.Signal.tag = taginfo;
         this.Alarm.tag = taginfo;
         DvSignalEventArgs arg = new DvSignalEventArgs(this.devid, this.station, dt, taginfo);
         arg.TagSignal = msgsigal;
         this.RaiseSignal(arg);
     }
     return taginfo;
 }
예제 #12
0
        /// <summary>
        /// ��֤״̬��Ϣ,��״̬�Աȱ仯ʱ�����¼���¼
        /// </summary>
        /// <param name="item">Ѳ����</param>
        /// <param name="devid">������ID</param>
        /// <param name="taginfo">״̬��Ϣtag���ֵ</param>
        private void validateSate(string taginfo)
        {
            if (string.IsNullOrEmpty(taginfo))
                return;
            Dictionary<string, string[]> dictstate = new Dictionary<string, string[]>();
            string[] alarm ={ "4���ű���", "3���ű���", "2���ű���", "1���ű���" };
            dictstate.Add("����", alarm);
            alarm = new string[] { "��", "��Чˢ��", "��������", "�Ƿ�����", "��ʱ", "в��" };
            dictstate.Add("����", alarm);
            alarm = new string[] { "оƬ����", "ϵͳ����4", "ʱ�ӹ���", "ϵͳ����2", "ϵͳ����1" };
            dictstate.Add("����", alarm);
            alarm = new string[] { "��ť4״̬", "��ť3״̬", "��ť2״̬", "��ť1״̬" };
            dictstate.Add("��ť", alarm);
            alarm = new string[] { "�Ŵ�4״̬", "�Ŵ�3״̬", "�Ŵ�2״̬", "�Ŵ�1״̬" };
            dictstate.Add("�Ŵ�", alarm);
            alarm = new string[] { "��4״̬", "��3״̬", "��2״̬", "��1״̬" };
            dictstate.Add("�̵���", alarm);

            //���ǰ��״̬�ı䣻alarmmsg������Ϣ,isalarm��ǰ�Ƿ񱨾��ı�
            string msg = "", alarmmsg = "", msgsigal = "";
            bool isalarm = false;
            NameObjectList psevent = new NameObjectList();
            psevent["������"] = this.devid;
            psevent["ʱ��"] = basefun.valtag(taginfo, "{��ǰʱ��}");
            alarm = new string[] { "����", "����", "����", "��ť", "�Ŵ�", "�̵���" };
            foreach (string state in alarm)
            {
                //�Ա�״̬�����¼�
                psevent["�¼�"] = state;
                string tagorgi = this.tagInfos[state];
                string tagnews = "";
                bool ischanged = false;
                int inum = 5;
                foreach (string st in dictstate[state])
                {
                    inum--;
                    string valorg = basefun.valtag(tagorgi, st);
                    if (string.IsNullOrEmpty(valorg))
                        valorg = "0";
                    string valnew = basefun.valtag(taginfo, st);
                    tagnews = basefun.setvaltag(tagnews, st, valnew);
                    if ("����" == state && "1" == valnew)
                    {
                        if (string.IsNullOrEmpty(alarmmsg))
                            alarmmsg = st;
                        else
                            alarmmsg += "," + st;
                    }
                    if (valorg == valnew && ("����" != state || !isalarm))
                        continue;
                    ischanged = true;
                    if ("����" == state) continue;
                    //�����¼�
                    if ("����" == state || "����" == state)
                    {
                        if ("����" == state)
                        {
                            psevent["���"] = inum.ToString();
                            psevent["����"] = st + "(" + alarmmsg + ")";
                        }
                        else
                        {
                            psevent.Remove("���");
                            psevent["����"] = st;
                        }
                        msg = basefun.setvaltag(msg, st, valnew);
                        if ("1" == valnew)
                            this.query.ExecuteNonQuery("�����Ž��¼�", psevent, psevent, psevent);
                        else
                            this.query.ExecuteNonQuery("�����Ž��¼�", psevent, psevent, psevent);
                    }
                    else
                    {
                        psevent["���"] = inum.ToString();
                        psevent["����"] = st + "��λ " + valnew;
                        msgsigal = basefun.setvaltag(msgsigal, st, valnew);
                        this.query.ExecuteNonQuery("�Ž���λ�¼�", psevent, psevent, psevent);
                    }
                }//foreach (string st in dictstate[state])
                this.tagInfos[state] = tagnews;
                if (!ischanged) continue;
                psevent["���"] = state;
                psevent["����"] = tagnews;
                this.query.ExecuteNonQuery("�Ž�Ѳ��״̬", psevent, psevent, psevent);
                //�������ݱ仯ʱ,�Ƚ���ԭ�����¼�
                if ("����" == state)
                {
                    isalarm = !string.IsNullOrEmpty(alarmmsg);
                    if (!isalarm)
                    {
                        foreach (string a in dictstate[state])
                            msg = basefun.setvaltag(msg, a, "0");
                    }
                    psevent.Remove("���");
                    this.query.ExecuteNonQuery("�����Ž��¼�", psevent, psevent, psevent);
                }
            }//foreach (string state in alarm)
            if (string.IsNullOrEmpty(this.Alarm.tag))
            {
                this.Alarm.tag = taginfo;
                this.Alarm.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(this.Signal.tag))
            {
                this.Signal.tag = taginfo;
                this.Signal.dtReceive = DateTime.Now;
            }
            if (string.IsNullOrEmpty(msg) && string.IsNullOrEmpty(msgsigal))
                return;
            DateTime dt = Convert.ToDateTime(basefun.valtag(taginfo, "{��ǰʱ��}"));
            if (!string.IsNullOrEmpty(msg))
            {
                alarm = alarmmsg.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string a in alarm)
                    msg = basefun.setvaltag(msg, a, "1");
                this.Alarm.dtReceive = DateTime.Now;
                this.Alarm.tag = taginfo;
                DvAlarmEventArgs arg = new DvAlarmEventArgs(this.devid, this.station, dt, taginfo);
                arg.TagAlarm = msg;
                this.RaiseAlarm(arg);
            }
            if (!string.IsNullOrEmpty(msgsigal))
            {
                this.Signal.dtReceive = DateTime.Now;
                this.Signal.tag = taginfo;
                DvSignalEventArgs arg = new DvSignalEventArgs(this.devid, this.station, dt, taginfo);
                arg.TagSignal = msgsigal;
                this.RaiseSignal(arg);
            }
        }
예제 #13
0
 /// <summary>
 /// 火警联动
 /// </summary>
 /// <param name="sender">门禁设备</param>
 /// <param name="e">报警事件</param>
 void device_AlarmHandle(object sender, DvAlarmEventArgs e)
 {
     DeviceDoor door = sender as DeviceDoor;
     if (null == door || null == e || string.IsNullOrEmpty(e.TagAlarm))
         return;
     string fire = basefun.valtag(e.TagAlarm, "火警");
     if ("1" != fire) return;
     NameObjectList ps = new NameObjectList();
     ps["设备ID"] = door.DevID;
     DataTable tab = this.query.getTable("同组设备", ps);
     CommiManager commimgr = CommiManager.GlobalManager;
     for (int i = 0; i < tab.Rows.Count; i++)
     {
         DataRow dr = tab.Rows[i];
         string dvid = Convert.ToString(dr["ID"]);
         string dvtype = Convert.ToString(dr["通讯协议"]);
         if (string.IsNullOrEmpty(dvtype) || DBNull.Value == dr["站址"])
             return;
         int station = Convert.ToInt32(dr["站址"]);
         CommiTarget target = this.getTarget(dr);
         if (null == target) return;
         target.setProtocol(Protocol.PTLDoor); 
         door = new DeviceDoor();
         door.SetDevice(commimgr, target, dvid, station);
         door.FireOpenDoor();
     }
 }