|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SlnMesnac.Serilog;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
@ -20,9 +23,185 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class IndexControl : UserControl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private SerilogHelper serilogHelper = null;
|
|
|
|
|
|
|
|
|
|
private bool m_bInitSDK = false;
|
|
|
|
|
private Int32 m_lUserID = -1;
|
|
|
|
|
private Int32 m_lRealHandle_1 = -1;
|
|
|
|
|
private Int32 m_lRealHandle_2 = -1;
|
|
|
|
|
public CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo;
|
|
|
|
|
public CHCNetSDK.NET_DVR_IPPARACFG_V40 m_struIpParaCfgV40;
|
|
|
|
|
private Int32 m_lTree = 0;
|
|
|
|
|
|
|
|
|
|
private string DVRIPAddress = "192.168.1.64"; //设备IP地址或者域名 Device IP
|
|
|
|
|
private Int16 DVRPortNumber = 8000; //设备服务端口号 Device Port
|
|
|
|
|
private string DVRUserName = "admin"; //设备登录用户名 User name to login
|
|
|
|
|
private string DVRPassword = "haiwei@2024"; //设备登录密码 Password to login
|
|
|
|
|
|
|
|
|
|
public IndexControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
serilogHelper = App.ServiceProvider.GetService<SerilogHelper>();
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
m_bInitSDK = CHCNetSDK.NET_DVR_Init();
|
|
|
|
|
if (m_bInitSDK == false)
|
|
|
|
|
{
|
|
|
|
|
DebugInfo("热成像双光谱微型云台初始化失败 error!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//保存SDK日志 To save the SDK log
|
|
|
|
|
CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
|
|
|
|
|
DebugInfo("热成像双光谱微型云台初始化成功 error!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Open_Device();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Open_Device()
|
|
|
|
|
{
|
|
|
|
|
m_lUserID = CHCNetSDK.NET_DVR_Login_V30(DVRIPAddress, DVRPortNumber, DVRUserName, DVRPassword, ref DeviceInfo);
|
|
|
|
|
|
|
|
|
|
if (m_lUserID < 0)
|
|
|
|
|
{
|
|
|
|
|
string str = "热成像双光谱微型云台打开失败, error code= " + CHCNetSDK.NET_DVR_GetLastError(); ; //登录失败,输出错误号 Failed to login and output the error code
|
|
|
|
|
DebugInfo(str);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//登录成功
|
|
|
|
|
DebugInfo("热成像双光谱微型云台打开成功!");
|
|
|
|
|
|
|
|
|
|
Start_Grab();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RealHandle_1()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CHCNetSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO();
|
|
|
|
|
lpPreviewInfo.hPlayWnd = RealPlayWnd.Handle;//预览窗口 live view window
|
|
|
|
|
lpPreviewInfo.lChannel = 1;//预览的设备通道 the device channel number
|
|
|
|
|
lpPreviewInfo.dwStreamType = 0;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
|
|
|
|
|
lpPreviewInfo.dwLinkMode = 0;//连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
|
|
|
|
|
lpPreviewInfo.bBlocked = true; //0- 非阻塞取流,1- 阻塞取流
|
|
|
|
|
lpPreviewInfo.dwDisplayBufNum = 15; //播放库显示缓冲区最大帧数
|
|
|
|
|
|
|
|
|
|
IntPtr pUser = IntPtr.Zero;//用户数据 user data
|
|
|
|
|
|
|
|
|
|
m_lRealHandle_1 = CHCNetSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, null/*RealData*/, pUser);
|
|
|
|
|
|
|
|
|
|
if (m_lRealHandle_1 < 0)
|
|
|
|
|
{
|
|
|
|
|
var str = "光景图像预览加载失败, error code= " + CHCNetSDK.NET_DVR_GetLastError(); //预览失败,输出错误号 failed to start live view, and output the error code.
|
|
|
|
|
DebugInfo(str);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//预览成功
|
|
|
|
|
DebugInfo("光景图像预览加载成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
serilogHelper.Camera($"光景图像预览加载异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RealHandle_2()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CHCNetSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO();
|
|
|
|
|
lpPreviewInfo.hPlayWnd = RealPlayWnd2.Handle;//预览窗口 live view window
|
|
|
|
|
lpPreviewInfo.lChannel = 2;//预览的设备通道 the device channel number
|
|
|
|
|
lpPreviewInfo.dwStreamType = 0;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
|
|
|
|
|
lpPreviewInfo.dwLinkMode = 0;//连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
|
|
|
|
|
lpPreviewInfo.bBlocked = true; //0- 非阻塞取流,1- 阻塞取流
|
|
|
|
|
lpPreviewInfo.dwDisplayBufNum = 15; //播放库显示缓冲区最大帧数
|
|
|
|
|
|
|
|
|
|
IntPtr pUser = IntPtr.Zero;//用户数据 user data
|
|
|
|
|
|
|
|
|
|
m_lRealHandle_2 = CHCNetSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, null/*RealData*/, pUser);
|
|
|
|
|
|
|
|
|
|
if (m_lRealHandle_2 < 0)
|
|
|
|
|
{
|
|
|
|
|
var str = "热成像预览加载失败, error code= " + CHCNetSDK.NET_DVR_GetLastError(); //预览失败,输出错误号 failed to start live view, and output the error code.
|
|
|
|
|
DebugInfo(str);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//预览成功
|
|
|
|
|
DebugInfo("热成像预览加载成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
serilogHelper.Camera($"热成像图像预览加载异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Start_Grab()
|
|
|
|
|
{
|
|
|
|
|
RealHandle_1();
|
|
|
|
|
RealHandle_2();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Stop_Grab()
|
|
|
|
|
{
|
|
|
|
|
if (!CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle_1))
|
|
|
|
|
{
|
|
|
|
|
var str = "NET_DVR_StopRealPlay failed, error code= " + CHCNetSDK.NET_DVR_GetLastError(); ;
|
|
|
|
|
DebugInfo(str);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugInfo("NET_DVR_StopRealPlay succ!");
|
|
|
|
|
RealPlayWnd.Invalidate();//刷新窗口 refresh the window
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle_2))
|
|
|
|
|
{
|
|
|
|
|
var str = "NET_DVR_StopRealPlay failed, error code= " + CHCNetSDK.NET_DVR_GetLastError(); ;
|
|
|
|
|
DebugInfo(str);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugInfo("NET_DVR_StopRealPlay succ!");
|
|
|
|
|
RealPlayWnd2.Invalidate();//刷新窗口 refresh the window
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Close_Device()
|
|
|
|
|
{
|
|
|
|
|
if (!CHCNetSDK.NET_DVR_Logout(m_lUserID))
|
|
|
|
|
{
|
|
|
|
|
var str = "NET_DVR_Logout failed, error code= " + CHCNetSDK.NET_DVR_GetLastError(); ;
|
|
|
|
|
DebugInfo(str);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DebugInfo("NET_DVR_Logout succ!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DebugInfo(string str)
|
|
|
|
|
{
|
|
|
|
|
serilogHelper.Camera(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|