Beispiel #1
0
        /// <summary>
        /// 消息处理函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tmrDealMsg_Tick(object sender, EventArgs e)
        {
            #region [温度处理回调数据]
            if (m_deqCamTemp.Count > 0)
            {
                sTempUpload tempObj = m_deqCamTemp.Dequeue();
                for (int i = 0; i < m_lstLoginInfor.Count; i++)
                {
                    if (tempObj != null)
                    {
                        if (tempObj.iHandle == m_lstLoginInfor[i].iHandle)
                        {
                            if (OnRecvTempMsg != null)
                            {
                                string Json = "{"
                                              + "\"fValue\":" + "\"" + tempObj.fTempHighest.ToString("F2") + "\""
                                              + "}";
                                OnRecvTempMsg(m_lstLoginInfor[i].strIp, Json);
                            }
                            break;
                        }
                    }
                }
            }//温度处理
            #endregion

            #region [门禁处理数据]
            if (m_qDoorNoEntry.Count > 0)
            {
                sDoorNoEntry tempObj = m_qDoorNoEntry.Dequeue();
                for (int i = 0; i < m_lstLoginInfor.Count; i++)
                {
                    if (tempObj.iHandle == m_lstLoginInfor[i].iHandle)
                    {
                        if (OnRecvTempMsg != null)
                        {
                            string time = Insert0WithTime(tempObj.sAlarmTime.dwYear) + "-"
                                          + Insert0WithTime(tempObj.sAlarmTime.dwMonth) + "-"
                                          + Insert0WithTime(tempObj.sAlarmTime.dwDay) + " "
                                          + Insert0WithTime(tempObj.sAlarmTime.dwHour) + ":"
                                          + Insert0WithTime(tempObj.sAlarmTime.dwMinute) + ":"
                                          + Insert0WithTime(tempObj.sAlarmTime.dwSecond);
                            string CardNumber = System.Text.Encoding.Default.GetString(tempObj.bCardNumber).Replace("\0", "");
                            string MenJin     = "{"
                                                //+ "\"bCardNumber\":" + "\"" + BitConverter.ToString(tempObj.bCardNumber).Replace('-', ' ') + "\"" + ","
                                                + "\"bCardNumber\":" + "\"" + CardNumber + "\"" + ","
                                                + "\"bCardType\":" + "\"" + tempObj.bCardType + "\"" + ","
                                                + "\"sAlarmTime\":" + "\"" + time + "\"" + ","
                                                + "\"iMajor\":" + "\"" + Convert.ToString(tempObj.iMajor, 16) + "\"" + ","
                                                + "\"iMijor\":" + "\"" + Convert.ToString(tempObj.iMijor, 16) + "\"" + ","
                                                + "\"PicType\":" + "\"" + tempObj.byPicTransType + "\"" + ","
                                                + "\"Pic\":" + "\"" + tempObj.pPicData + "\"" + ","
                                                + "\"PicLen\":" + "\"" + tempObj.dwPicDataLen + "\""
                                                + "}";
                            OnRecvTempMsg(m_lstLoginInfor[i].strIp, MenJin);
                        }
                    }
                }
            }//门禁
            #endregion

            #region [动环数据处理]
            if (m_qSealHead.Count > 0)//动环
            {
                sSealHead tempObj = m_qSealHead.Dequeue();
                for (int i = 0; i < m_lstLoginInfor.Count; i++)
                {
                    if (tempObj.iHandle == m_lstLoginInfor[i].iHandle)
                    {
                        if (OnRecvTempMsg != null)
                        {
                            //MessageBox.Show("btype = 1 : value: " + tempObj.fValue);
                            string Name = System.Text.Encoding.Default.GetString(tempObj.bName).Replace("\0", "");
                            Name = System.Text.RegularExpressions.Regex.Replace(Name, @"[^0-9]+", "");
                            //计算模拟量
                            float  Temp  = ((((tempObj.fValue - 4) / 16) * 200) - 50);
                            string sTemp = Temp.ToString("f2");
                            string Json  = "{"
                                           + "\"fValue\":" + "\"" + sTemp + "\"" + ","
                                           + "\"byName\":" + "\"" + Name + "\"" + ","
                                           + "\"byAlarmType\":" + "\"" + tempObj.bAlarmType + "\"" + ","
                                           + "\"byType\":" + "\"" + tempObj.bType + "\"" + ","
                                           + "\"byAlarmMode\":" + "\"" + tempObj.bAlarmMode + "\""
                                           + "}";
                            OnRecvTempMsg(m_lstLoginInfor[i].strIp, Json);
                        }
                    }
                }
            }
            #endregion

            #region [开关量报警处理]
            if (m_qOnOffInfo.Count > 0)
            {
                sOnOffAlarm tempObj = m_qOnOffInfo.Dequeue();
                for (int i = 0; i < m_lstLoginInfor.Count; i++)
                {
                    if (tempObj.iHandle == m_lstLoginInfor[i].iHandle)
                    {
                        string time = Insert0WithTime(Convert.ToUInt32(tempObj.sAlarmTime.wYear)) + "-"
                                      + Insert0WithTime(Convert.ToUInt32(tempObj.sAlarmTime.byMonth)) + "-"
                                      + Insert0WithTime(Convert.ToUInt32(tempObj.sAlarmTime.byDay)) + " "
                                      + Insert0WithTime(Convert.ToUInt32(tempObj.sAlarmTime.byHour)) + ":"
                                      + Insert0WithTime(Convert.ToUInt32(tempObj.sAlarmTime.byMinute)) + ":"
                                      + Insert0WithTime(Convert.ToUInt32(tempObj.sAlarmTime.bySecond));
                        string name = System.Text.Encoding.Default.GetString(tempObj.byName).Replace("\0", "");
                        string Json = "{"
                                      + "\"tag\":" + "\"" + "OnOffAlarm" + "\"" + ","
                                      + "\"byName\":" + "\"" + name + "\"" + ","
                                      + "\"byAlarmType\":" + "\"" + tempObj.byAlarmType + "\"" + ","
                                      + "\"sAlarmTime\":" + "\"" + time + "\"" + ","
                                      + "\"iChannel\":" + "\"" + tempObj.iChannel + "\""
                                      + "}";
                        OnRecvTempMsg(m_lstLoginInfor[i].strIp, Json);
                    }
                }
            }//开关量报警
            #endregion

            #region [温度报警处理]
            if (m_qTempAlarm.Count > 0)//温度报警
            {
                sTempAlarm tempObj = m_qTempAlarm.Dequeue();
                for (int i = 0; i < m_lstLoginInfor.Count; i++)
                {
                    if (tempObj.iHandle == m_lstLoginInfor[i].iHandle)
                    {
                        string Json = "{"
                                      + "\"tag\":" + "\"" + "TempAlarm" + "\"" + ","
                                      + "\"uiChannel\":" + "\"" + tempObj.uiChannel + "\"" + ","
                                      + "\"byTempUnit\":" + "\"" + tempObj.byTempUnit + "\"" + ","
                                      + "\"byAlarmLevel\":" + "\"" + tempObj.byAlarmLevel + "\"" + ","
                                      + "\"byAlarmRule\":" + "\"" + tempObj.byAlarmRule + "\"" + ","
                                      + "\"byAlarmType\":" + "\"" + tempObj.byAlarmType + "\"" + ","
                                      + "\"fCurrTemp\":" + "\"" + tempObj.fCurrTemp + "\""
                                      + "}";
                        OnRecvTempMsg(m_lstLoginInfor[i].strIp, Json);
                    }
                }
            }
            #endregion

            #region [温差报警处理]
            if (m_qTempDiffAlarm.Count > 0)//温度报警
            {
                sTempDiffAlarm tempObj = m_qTempDiffAlarm.Dequeue();
                for (int i = 0; i < m_lstLoginInfor.Count; i++)
                {
                    if (tempObj.iHandle == m_lstLoginInfor[i].iHandle)
                    {
                        string Json = "{"
                                      + "\"tag\":" + "\"" + "TempDiffAlarm" + "\"" + ","
                                      + "\"uiChannel\":" + "\"" + tempObj.uiChannel + "\"" + ","
                                      + "\"byAlarmLevel\":" + "\"" + tempObj.byAlarmLevel + "\"" + ","
                                      + "\"byAlarmRule\":" + "\"" + tempObj.byAlarmRule + "\"" + ","
                                      + "\"byAlarmType\":" + "\"" + tempObj.byAlarmType + "\""
                                      + "}";
                        OnRecvTempMsg(m_lstLoginInfor[i].strIp, Json);
                    }
                }
            }
            #endregion

            #region [视频移动报警处理]
            if (m_qVideoMoveAlarm.Count > 0)//温度报警
            {
                sVideoMove tempObj = m_qVideoMoveAlarm.Dequeue();
                for (int i = 0; i < m_lstLoginInfor.Count; i++)
                {
                    if (tempObj.iHandle == m_lstLoginInfor[i].iHandle)
                    {
                        string sChannel = System.Text.Encoding.Default.GetString(tempObj.uiChannel).Replace("\0", "");
                        string Json     = "{"
                                          + "\"tag\":" + "\"" + "VideoMove" + "\"" + ","
                                          + "\"uiChannel\":" + "\"" + sChannel + "\"" + ","
                                          + "\"uiAlarmType\":" + "\"" + tempObj.uiAlarmType + "\""
                                          + "}";
                        OnRecvTempMsg(m_lstLoginInfor[i].strIp, Json);
                    }
                }
            }
            #endregion

            #region [热成像报警处理]
            if (m_qThermalImagery.Count > 0)//温度报警
            {
                sThermalImagery tempObj = m_qThermalImagery.Dequeue();
                for (int i = 0; i < m_lstLoginInfor.Count; i++)
                {
                    if (tempObj.iHandle == m_lstLoginInfor[i].iHandle)
                    {
                        string Ipv4 = new string(tempObj.chIpv4).Replace("\0", "");
                        string Json = "{"
                                      + "\"tag\":" + "\"" + "Thermal" + "\"" + ","
                                      + "\"sIp\":" + "\"" + Ipv4 + "\"" + ","
                                      + "\"byStrategyType\":" + "\"" + tempObj.byStrategyType + "\""
                                      + "\"byAlarmSubType\":" + "\"" + tempObj.byAlarmSubType + "\"" + ","
                                      + "\"iMaxTemp\":" + "\"" + tempObj.iMaxTemp + "\"" + ","
                                      + "}";
                        OnRecvTempMsg(m_lstLoginInfor[i].strIp, Json);
                    }
                }
            }
            #endregion
        }
Beispiel #2
0
        //门禁数据回调函数
        private bool MsgCallback_V31(int lCommand, ref NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
        {
            switch (lCommand)
            {
            case 0x5002:    //门禁消息
                NET_DVR_ACS_ALARM_INFO strAlarmInfo = new NET_DVR_ACS_ALARM_INFO();
                byte[] pByte = new byte[1024];
                int    iSize = Marshal.SizeOf(strAlarmInfo);
                Marshal.Copy(pAlarmInfo, pByte, 0, Marshal.SizeOf(strAlarmInfo));
                strAlarmInfo = (NET_DVR_ACS_ALARM_INFO)BytesToStruct(pByte, strAlarmInfo.GetType());
                sDoorNoEntry sDoorAlarmInfo = new sDoorNoEntry();
                sDoorAlarmInfo.iHandle        = pAlarmer.lUserID;
                sDoorAlarmInfo.bCardNumber    = strAlarmInfo.struAcsEventInfo.byCardNo;
                sDoorAlarmInfo.bCardType      = strAlarmInfo.struAcsEventInfo.byCardType;
                sDoorAlarmInfo.sAlarmTime     = strAlarmInfo.struTime;
                sDoorAlarmInfo.iMajor         = strAlarmInfo.dwMajor;
                sDoorAlarmInfo.iMijor         = strAlarmInfo.dwMinor;
                sDoorAlarmInfo.pPicData       = strAlarmInfo.pPicData;
                sDoorAlarmInfo.dwPicDataLen   = strAlarmInfo.dwPicDataLen;
                sDoorAlarmInfo.byPicTransType = strAlarmInfo.byPicTransType;
                m_qDoorNoEntry.Enqueue(sDoorAlarmInfo);
                //MessageBox.Show("dwMajor : " + strAlarmInfo.dwMajor + "dwMinor : " + strAlarmInfo.dwMinor);
                break;

            case 0x1120:    //模拟量实时数据信息
                            //case 0x1121://模拟量报警信息
                NET_DVR_SENSOR_ALARM resObj = new NET_DVR_SENSOR_ALARM();
                pByte = new byte[1024];
                iSize = Marshal.SizeOf(resObj);
                Marshal.Copy(pAlarmInfo, pByte, 0, Marshal.SizeOf(resObj));
                resObj = (NET_DVR_SENSOR_ALARM)BytesToStruct(pByte, resObj.GetType());
                sSealHead sSealHeadInfo = new sSealHead();
                sSealHeadInfo.iHandle    = pAlarmer.lUserID;
                sSealHeadInfo.bName      = resObj.byName;
                sSealHeadInfo.bType      = resObj.byType;
                sSealHeadInfo.fValue     = resObj.fValue;
                sSealHeadInfo.fIVValue   = resObj.fOriginalValue;
                sSealHeadInfo.bAlarmType = resObj.byAlarmType;
                sSealHeadInfo.bAlarmMode = resObj.byAlarmMode;
                m_qSealHead.Enqueue(sSealHeadInfo);
                break;

            case 0x1122:    //开关量报警信息
                NET_DVR_SWITCH_ALARM OnOffAlarmObj = new NET_DVR_SWITCH_ALARM();
                pByte = new byte[1024];
                iSize = Marshal.SizeOf(OnOffAlarmObj);
                Marshal.Copy(pAlarmInfo, pByte, 0, Marshal.SizeOf(OnOffAlarmObj));
                OnOffAlarmObj = (NET_DVR_SWITCH_ALARM)BytesToStruct(pByte, OnOffAlarmObj.GetType());
                sOnOffAlarm sOnOffInfo = new sOnOffAlarm();
                sOnOffInfo.iHandle     = pAlarmer.lUserID;
                sOnOffInfo.byName      = OnOffAlarmObj.byName;
                sOnOffInfo.byAlarmType = OnOffAlarmObj.byAlarmType;
                sOnOffInfo.sAlarmTime  = OnOffAlarmObj.struOperateTime;
                sOnOffInfo.iChannel    = OnOffAlarmObj.wSwitchChannel;
                m_qOnOffInfo.Enqueue(sOnOffInfo);
                break;

            case 0x5212:    //温度报警
                NET_DVR_THERMOMETRY_ALARM TempAlarmObj = new NET_DVR_THERMOMETRY_ALARM();
                pByte = new byte[1024];
                iSize = Marshal.SizeOf(TempAlarmObj);
                Marshal.Copy(pAlarmInfo, pByte, 0, Marshal.SizeOf(TempAlarmObj));
                TempAlarmObj = (NET_DVR_THERMOMETRY_ALARM)BytesToStruct(pByte, TempAlarmObj.GetType());
                sTempAlarm TempAlarm = new sTempAlarm();
                TempAlarm.iHandle      = pAlarmer.lUserID;
                TempAlarm.uiChannel    = TempAlarmObj.dwChannel;
                TempAlarm.byTempUnit   = TempAlarmObj.byThermometryUnit;
                TempAlarm.byAlarmLevel = TempAlarmObj.byAlarmLevel;
                TempAlarm.byAlarmRule  = TempAlarmObj.byAlarmRule;
                TempAlarm.byAlarmType  = TempAlarmObj.byAlarmType;
                TempAlarm.fCurrTemp    = TempAlarmObj.fCurrTemperature;
                m_qTempAlarm.Enqueue(TempAlarm);
                break;

            case 0x5211:    //温差报警
                NET_DVR_THERMOMETRY_DIFF_ALARM TempDiffAlarmObj = new NET_DVR_THERMOMETRY_DIFF_ALARM();
                pByte = new byte[1024];
                Marshal.Copy(pAlarmInfo, pByte, 0, Marshal.SizeOf(TempDiffAlarmObj));
                TempDiffAlarmObj = (NET_DVR_THERMOMETRY_DIFF_ALARM)BytesToStruct(pByte, TempDiffAlarmObj.GetType());
                sTempDiffAlarm TempDiffAlarm = new sTempDiffAlarm();
                TempDiffAlarm.iHandle      = pAlarmer.lUserID;
                TempDiffAlarm.byAlarmLevel = TempDiffAlarmObj.byAlarmLevel;
                TempDiffAlarm.byAlarmRule  = TempDiffAlarmObj.byAlarmRule;
                TempDiffAlarm.byAlarmType  = TempDiffAlarmObj.byAlarmRule;
                m_qTempDiffAlarm.Enqueue(TempDiffAlarm);
                break;

            case 0x4007:    //视频移动报警
                NET_DVR_ALARMINFO_V30 VideoMoveAlarmObj = new NET_DVR_ALARMINFO_V30();
                pByte = new byte[1024];
                Marshal.Copy(pAlarmInfo, pByte, 0, Marshal.SizeOf(VideoMoveAlarmObj));
                VideoMoveAlarmObj = (NET_DVR_ALARMINFO_V30)BytesToStruct(pByte, VideoMoveAlarmObj.GetType());
                sVideoMove VideoMoveAlarm = new sVideoMove();
                VideoMoveAlarm.iHandle     = pAlarmer.lUserID;
                VideoMoveAlarm.uiAlarmType = VideoMoveAlarmObj.dwAlarmType;
                VideoMoveAlarm.uiChannel   = VideoMoveAlarmObj.byChannel;
                m_qVideoMoveAlarm.Enqueue(VideoMoveAlarm);
                break;

            case 0x4991:    //热成像报警
                NET_DVR_FIREDETECTION_ALARM ThermalImageryObj = new NET_DVR_FIREDETECTION_ALARM();
                pByte = new byte[1024];
                iSize = Marshal.SizeOf(ThermalImageryObj);
                Marshal.Copy(pAlarmInfo, pByte, 0, Marshal.SizeOf(ThermalImageryObj));
                ThermalImageryObj = (NET_DVR_FIREDETECTION_ALARM)BytesToStruct(pByte, ThermalImageryObj.GetType());
                sThermalImagery ThermalImagery = new sThermalImagery();
                ThermalImagery.iHandle        = pAlarmer.lUserID;
                ThermalImagery.iMaxTemp       = ThermalImageryObj.wFireMaxTemperature;
                ThermalImagery.byAlarmSubType = ThermalImageryObj.byAlarmSubType;
                ThermalImagery.byStrategyType = ThermalImageryObj.byStrategyType;
                ThermalImagery.chIpv4         = ThermalImageryObj.struDevInfo.struDevIP.sIpV4;
                m_qThermalImagery.Enqueue(ThermalImagery);
                break;

            default:
                break;
            }
            return(true);
        }