|
|
|
@ -10,6 +10,7 @@ using SlnMesnac.Model.dto;
|
|
|
|
|
using SlnMesnac.Serilog;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
@ -54,6 +55,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
private AppConfig _appConfig;
|
|
|
|
|
|
|
|
|
|
private CHCNetSDK.RemoteConfigCallback _callback;
|
|
|
|
|
private CHCNetSDK.MSGCallBack_V31 m_falarmData_V31;
|
|
|
|
|
public CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo;
|
|
|
|
|
|
|
|
|
|
private bool m_bInitSDK = false;
|
|
|
|
@ -72,6 +74,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
{
|
|
|
|
|
_log = App.ServiceProvider.GetService<SerilogHelper>();
|
|
|
|
|
_callback = new CHCNetSDK.RemoteConfigCallback(GetThermInfoCallback);
|
|
|
|
|
m_falarmData_V31 = new CHCNetSDK.MSGCallBack_V31(MsgCallback_V31);
|
|
|
|
|
_appConfig = App.ServiceProvider.GetService<AppConfig>();
|
|
|
|
|
autoModeBusiness = App.ServiceProvider.GetService<AutoModeBusiness>();
|
|
|
|
|
inspModeBusiness = App.ServiceProvider.GetService<InspModeBusiness>();
|
|
|
|
@ -88,9 +91,10 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
inspModeBusiness.GimbaRotationControlEvent += GimbaRotationControl;
|
|
|
|
|
|
|
|
|
|
RefreshTrackMotorAddress();
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Error("巡检控制系统初始化失败",ex);
|
|
|
|
|
_log.Error("巡检控制系统初始化失败", ex);
|
|
|
|
|
MessageBox.Show($"巡检控制系统初始化失败:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -191,6 +195,38 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// 报警布防
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
//设置透传报警信息类型
|
|
|
|
|
CHCNetSDK.NET_DVR_LOCAL_GENERAL_CFG struLocalCfg = new CHCNetSDK.NET_DVR_LOCAL_GENERAL_CFG();
|
|
|
|
|
struLocalCfg.byAlarmJsonPictureSeparate = 1;//控制JSON透传报警数据和图片是否分离,0-不分离(COMM_VCA_ALARM返回),1-分离(分离后走COMM_ISAPI_ALARM回调返回)
|
|
|
|
|
|
|
|
|
|
Int32 nSize = Marshal.SizeOf(struLocalCfg);
|
|
|
|
|
IntPtr ptrLocalCfg = Marshal.AllocHGlobal(nSize);
|
|
|
|
|
Marshal.StructureToPtr(struLocalCfg, ptrLocalCfg, false);
|
|
|
|
|
|
|
|
|
|
if (!CHCNetSDK.NET_DVR_SetSDKLocalCfg(17, ptrLocalCfg)) //NET_DVR_LOCAL_CFG_TYPE_GENERAL
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("NET_DVR_SetSDKLocalCfg failed, error code= " + CHCNetSDK.NET_DVR_GetLastError());
|
|
|
|
|
}
|
|
|
|
|
Marshal.FreeHGlobal(ptrLocalCfg);
|
|
|
|
|
|
|
|
|
|
CHCNetSDK.NET_DVR_SETUPALARM_PARAM struAlarmParam = new CHCNetSDK.NET_DVR_SETUPALARM_PARAM();
|
|
|
|
|
struAlarmParam.dwSize = (uint)Marshal.SizeOf(struAlarmParam);
|
|
|
|
|
struAlarmParam.byLevel = 1; //0- 一级布防,1- 二级布防
|
|
|
|
|
struAlarmParam.byAlarmInfoType = 1;//智能交通设备有效,新报警信息类型
|
|
|
|
|
struAlarmParam.byFaceAlarmDetection = 1;//1-人脸侦测
|
|
|
|
|
|
|
|
|
|
var m_lAlarmHandle = CHCNetSDK.NET_DVR_SetupAlarmChan_V41(m_lUserID, ref struAlarmParam);
|
|
|
|
|
if (m_lAlarmHandle < 0)
|
|
|
|
|
{
|
|
|
|
|
_log.Info("布防失败,错误号::" + CHCNetSDK.NET_DVR_GetLastError());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var res = CHCNetSDK.NET_DVR_SetDVRMessageCallBack_V31(m_falarmData_V31, IntPtr.Zero);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -211,7 +247,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
public void GetThermInfoCallback(uint dwType, IntPtr lpBuffer, uint dwBufLen, IntPtr pUserData)
|
|
|
|
|
{
|
|
|
|
|
var ret = Marshal.PtrToStructure<CHCNetSDK.NET_DVR_THERMOMETRY_UPLOAD>(lpBuffer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.RealTemperature = new RealTemperatureInfo()
|
|
|
|
|
{
|
|
|
|
|
fMaxTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMaxTemperature, 1),
|
|
|
|
@ -531,7 +567,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GimbaRotationControl(string wPanPos,string wTiltPos,string wZoomPos)
|
|
|
|
|
public void GimbaRotationControl(string wPanPos, string wTiltPos, string wZoomPos)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -565,7 +601,8 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
//Marshal.FreeHGlobal(ptrPtzCfg);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Info($"云台旋转控制异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
@ -631,7 +668,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
|
|
|
|
|
public void Stop_PointMode()
|
|
|
|
|
{
|
|
|
|
|
fixedPointBusiness.EndFixedPoint(null,true);
|
|
|
|
|
fixedPointBusiness.EndFixedPoint(null, true);
|
|
|
|
|
|
|
|
|
|
autoModeBusiness.ClearPlcMode();
|
|
|
|
|
}
|
|
|
|
@ -652,7 +689,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double speed = autoModeBusiness.GetDeviceSpeed();
|
|
|
|
|
RealDeviceSpeed = Math.Round(speed,2);
|
|
|
|
|
RealDeviceSpeed = Math.Round(speed, 2);
|
|
|
|
|
string deviceStatus = autoModeBusiness.GetDeviceStatus();
|
|
|
|
|
RealDeviceStatus = deviceStatus;
|
|
|
|
|
Task.Delay(1000).Wait();
|
|
|
|
@ -660,5 +697,51 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool MsgCallback_V31(int lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
|
|
|
|
|
{
|
|
|
|
|
AlarmMessageHandle(lCommand, ref pAlarmer, pAlarmInfo, dwBufLen, pUser);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AlarmMessageHandle(int lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
|
|
|
|
|
{
|
|
|
|
|
switch (lCommand)
|
|
|
|
|
{
|
|
|
|
|
case CHCNetSDK.COMM_ISAPI_ALARM://ISAPI报警信息上传
|
|
|
|
|
ProcessCommAlarm_ISAPIAlarm(ref pAlarmer, pAlarmInfo, dwBufLen, pUser);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
string strIP = System.Text.Encoding.UTF8.GetString(pAlarmer.sDeviceIP).TrimEnd('\0');
|
|
|
|
|
|
|
|
|
|
string stringAlarm = "报警上传,信息类型:0x" + Convert.ToString(lCommand, 16);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(stringAlarm);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ProcessCommAlarm_ISAPIAlarm(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CHCNetSDK.NET_DVR_ALARM_ISAPI_INFO struISAPIAlarm = new CHCNetSDK.NET_DVR_ALARM_ISAPI_INFO();
|
|
|
|
|
uint dwSize = (uint)Marshal.SizeOf(struISAPIAlarm);
|
|
|
|
|
struISAPIAlarm = (CHCNetSDK.NET_DVR_ALARM_ISAPI_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_ALARM_ISAPI_INFO));
|
|
|
|
|
|
|
|
|
|
string stringAlarm = $"ISAPI报警信息,byDataType:{struISAPIAlarm.byDataType}";
|
|
|
|
|
|
|
|
|
|
_log.Info($"云台避障报警:{stringAlarm}");
|
|
|
|
|
|
|
|
|
|
autoModeBusiness.SendCameraAlarmToPlc();
|
|
|
|
|
}catch(Exception e)
|
|
|
|
|
{
|
|
|
|
|
_log.Info($"云台避障报警逻辑处理异常:{e.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|