//实时测温回调 private void GetThermInfoCallback(uint dwType, IntPtr lpBuffer, uint dwBufLen, IntPtr pUserData) { if (dwType == 2) //测温数据 { NET_DVR_THERMOMETRY_UPLOAD resObj = new NET_DVR_THERMOMETRY_UPLOAD(); byte[] pByte = new byte[1024]; int iSize = Marshal.SizeOf(resObj); Marshal.Copy(lpBuffer, pByte, 0, Marshal.SizeOf(resObj)); resObj = (NET_DVR_THERMOMETRY_UPLOAD)BytesToStruct(pByte, resObj.GetType()); sTempUpload tempObj = new sTempUpload(); tempObj.iHandle = (Int32)pUserData; tempObj.fTempHighest = resObj.struLinePolygonThermCfg.fMaxTemperature; m_deqCamTemp.Enqueue(tempObj); } }
/// <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 }