예제 #1
0
 /// <summary>
 /// �����źű�λ�¼�
 /// </summary>
 /// <param name="arg"></param>
 public virtual void RaiseSignal(DvSignalEventArgs arg)
 {
     EventHandler<DvSignalEventArgs> handle = this.SignalHandle;
     if (null == handle || null == arg)
         return;
     if (string.IsNullOrEmpty(arg.DeviceID) || string.IsNullOrEmpty(arg.TagInfo) || string.IsNullOrEmpty(arg.TagSignal))
         return;
     handle(this, arg);
 }
 /// <summary>
 /// 信号变位
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void device_SignalHandle(object sender, DvSignalEventArgs e)
 {
     if (null == e || string.IsNullOrEmpty(e.DeviceID) || string.IsNullOrEmpty(e.TagSignal))
         return;
     this.sendclientdata(e.DeviceID, "signal", Encoding.GetEncoding("GB2312").GetBytes(e.TagInfo));
 }
예제 #3
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;
 }
예제 #4
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);
        }
예제 #5
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);
            }
        }