private string getAlarmInfo(CHCNetSDK.NET_DVR_ALARMER pAlarmer, CHCNetSDK.NET_DVR_ALARMINFO_V30 struAlarmInfoV30) { string serialNumber = System.Text.Encoding.UTF8.GetString(pAlarmer.sSerialNumber).Replace("\0", ""); string channels = ""; for (int i = 0; i < struAlarmInfoV30.byChannel.Length; i++) { byte channelNumberByte = struAlarmInfoV30.byChannel[i]; int channelNumber = Convert.ToInt32(channelNumberByte); if (channelNumber > 0) { channels += String.Format("ch {0}({1}) ", (i + 1), channelNumber); } } string result = string.Format("channels: {0} IP: {1} S/N: {2} ", channels, pAlarmer.sDeviceIP, serialNumber); return result; }
// Alarm callback public void MsgCallback(int lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser) { MyDebugInfo AlarmInfo = new MyDebugInfo(DebugInfo); switch (lCommand) { case CHCNetSDK.COMM_ALARM: ProcessCommAlarm(ref pAlarmer, pAlarmInfo, dwBufLen, pUser); break; case CHCNetSDK.COMM_ALARM_V30: ProcessCommAlarm_V30(ref pAlarmer, pAlarmInfo, dwBufLen, pUser); break; case CHCNetSDK.COMM_ALARM_RULE: this.BeginInvoke(AlarmInfo, "COMM_ALARM_RULE"); break; case CHCNetSDK.COMM_TRADEINFO: this.BeginInvoke(AlarmInfo, "COMM_TRADEINFO"); break; case CHCNetSDK.COMM_IPCCFG: this.BeginInvoke(AlarmInfo, "COMM_IPCCFG"); break; case CHCNetSDK.COMM_IPCCFG_V31: this.BeginInvoke(AlarmInfo, "COMM_IPCCFG_V31"); break; default: break; } }
public void ProcessCommAlarm(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser) { MyDebugInfo AlarmInfo = new MyDebugInfo(DebugInfo); CHCNetSDK.NET_DVR_ALARMINFO struAlarmInfo = new CHCNetSDK.NET_DVR_ALARMINFO(); struAlarmInfo = (CHCNetSDK.NET_DVR_ALARMINFO)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_ALARMINFO)); string str; switch (struAlarmInfo.dwAlarmType) { case 0: this.BeginInvoke(AlarmInfo, "sensor alarm"); break; case 1: this.BeginInvoke(AlarmInfo, "hard disk full"); break; case 2: this.BeginInvoke(AlarmInfo, "video lost"); break; case 3: str = ""; str += pAlarmer.sDeviceIP; str += " motion detection"; this.BeginInvoke(AlarmInfo, str); m_bJpegCapture = true; break; case 4: this.BeginInvoke(AlarmInfo, "hard disk unformatted"); break; case 5: this.BeginInvoke(AlarmInfo, "hard disk error"); break; case 6: this.BeginInvoke(AlarmInfo, "tampering detection"); break; case 7: this.BeginInvoke(AlarmInfo, "unmatched video output standard"); break; case 8: this.BeginInvoke(AlarmInfo, "illegal operation"); break; default: this.BeginInvoke(AlarmInfo, "Unknow alarm"); break; } }
private void ProcessCommAlarm_V30(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser) { MyDebugInfo alarmInfo = new MyDebugInfo(DebugInfo); CHCNetSDK.NET_DVR_ALARMINFO_V30 struAlarmInfoV30 = new CHCNetSDK.NET_DVR_ALARMINFO_V30(); struAlarmInfoV30 = (CHCNetSDK.NET_DVR_ALARMINFO_V30)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_ALARMINFO_V30)); string str; switch (struAlarmInfoV30.dwAlarmType) { case 0: this.BeginInvoke(alarmInfo, "sensor alarm"); break; case 1: this.BeginInvoke(alarmInfo, "hard disk full"); break; case 2: str = "video lost on "; str += getAlarmInfo(pAlarmer, struAlarmInfoV30); this.BeginInvoke(alarmInfo, str); playSound(alarmInfo, @"intel_alarm.wav"); break; case 3: str = "motion detection on "; str += getAlarmInfo(pAlarmer, struAlarmInfoV30); this.BeginInvoke(alarmInfo, str); playSound(alarmInfo, @"motion.wav"); break; case 4: this.BeginInvoke(alarmInfo, "hard disk unformatted"); break; case 5: this.BeginInvoke(alarmInfo, "hard disk error"); break; case 6: str = "tampering detection on "; str += getAlarmInfo(pAlarmer, struAlarmInfoV30); this.BeginInvoke(alarmInfo, str); playSound(alarmInfo, @"intel_alarm.wav"); break; case 7: this.BeginInvoke(alarmInfo, "unmatched video output standard"); break; case 8: this.BeginInvoke(alarmInfo, "illegal operation"); break; case 9: this.BeginInvoke(alarmInfo, "video signal abnormal"); break; case 10: this.BeginInvoke(alarmInfo, "record abnormal"); break; default: this.BeginInvoke(alarmInfo, "Unknow alarm"); break; } }