|
|
|
@ -1,11 +1,14 @@
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SlnMesnac.Model.dto;
|
|
|
|
|
using SlnMesnac.Serilog;
|
|
|
|
|
using SlnMesnac.WPF.ViewModel;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Channels;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
@ -16,6 +19,7 @@ using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
using static SlnMesnac.WPF.CHCNetSDK;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.WPF.Page
|
|
|
|
|
{
|
|
|
|
@ -24,7 +28,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class IndexControl : UserControl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private IndexControlViewModel indexControlViewModel = new IndexControlViewModel();
|
|
|
|
|
private SerilogHelper serilogHelper = null;
|
|
|
|
|
|
|
|
|
|
private bool m_bInitSDK = false;
|
|
|
|
@ -35,6 +39,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
public CHCNetSDK.NET_DVR_IPPARACFG_V40 m_struIpParaCfgV40;
|
|
|
|
|
public CHCNetSDK.NET_DVR_PTZPOS m_struPtzCfg;
|
|
|
|
|
private bool bAuto = false;
|
|
|
|
|
private CHCNetSDK.RemoteConfigCallback _callback;
|
|
|
|
|
|
|
|
|
|
private string DVRIPAddress = "192.168.1.64"; //设备IP地址或者域名 Device IP
|
|
|
|
|
private Int16 DVRPortNumber = 8000; //设备服务端口号 Device Port
|
|
|
|
@ -44,8 +49,9 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
public IndexControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.DataContext = indexControlViewModel;
|
|
|
|
|
serilogHelper = App.ServiceProvider.GetService<SerilogHelper>();
|
|
|
|
|
_callback = new CHCNetSDK.RemoteConfigCallback(GetThermInfoCallback);
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
@ -71,6 +77,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Open_Device()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
m_lUserID = CHCNetSDK.NET_DVR_Login_V30(DVRIPAddress, DVRPortNumber, DVRUserName, DVRPassword, ref DeviceInfo);
|
|
|
|
|
|
|
|
|
@ -84,9 +92,46 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
//登录成功
|
|
|
|
|
DebugInfo("热成像双光谱微型云台打开成功!");
|
|
|
|
|
|
|
|
|
|
Start_Grab();
|
|
|
|
|
Start_Grab(); //打开实时预览
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// 加载实时温度数据
|
|
|
|
|
///
|
|
|
|
|
var size = Marshal.SizeOf(typeof(CHCNetSDK.NET_DVR_REALTIME_THERMOMETRY_COND));
|
|
|
|
|
CHCNetSDK.NET_DVR_REALTIME_THERMOMETRY_COND struThermCond = new CHCNetSDK.NET_DVR_REALTIME_THERMOMETRY_COND();
|
|
|
|
|
struThermCond.dwSize = (uint)size;
|
|
|
|
|
struThermCond.byRuleID = 0; //规则ID,0代表获取全部规则,具体规则ID从1开始
|
|
|
|
|
struThermCond.dwChan = 2;// dwChannel; //从1开始,0xffffffff代表获取全部通道
|
|
|
|
|
|
|
|
|
|
IntPtr pCond = Marshal.AllocCoTaskMem(size);
|
|
|
|
|
Marshal.StructureToPtr(struThermCond, pCond, false);
|
|
|
|
|
var ret = NET_DVR_StartRemoteConfig(m_lUserID, NET_DVR_GET_REALTIME_THERMOMETRY, pCond, size, _callback, IntPtr.Zero);
|
|
|
|
|
if (ret < 0)
|
|
|
|
|
{
|
|
|
|
|
DebugInfo("配置测温失败, 错误代码:" + NET_DVR_GetLastError()); //登录失败,输出错误号
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
DebugInfo($"热成像双光谱微型云台加载异常: {ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GetThermInfoCallback(uint dwType, IntPtr lpBuffer, uint dwBufLen, IntPtr pUserData)
|
|
|
|
|
{
|
|
|
|
|
var ret = Marshal.PtrToStructure<NET_DVR_THERMOMETRY_UPLOAD>(lpBuffer);
|
|
|
|
|
DebugInfo($"最高温度:{ret.struLinePolygonThermCfg.fMaxTemperature};最低温度:{ret.struLinePolygonThermCfg.fMinTemperature};平均温度:{ret.struLinePolygonThermCfg.fAverageTemperature};温差:{ret.struLinePolygonThermCfg.fTemperatureDiff}");
|
|
|
|
|
|
|
|
|
|
RealTemperatureInfo realTemperature = new RealTemperatureInfo();
|
|
|
|
|
realTemperature.fMaxTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMaxTemperature, 1);
|
|
|
|
|
realTemperature.fMinTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMinTemperature, 1);
|
|
|
|
|
realTemperature.fAverageTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fAverageTemperature, 1);
|
|
|
|
|
realTemperature.fTemperatureDiff = (float)Math.Round(ret.struLinePolygonThermCfg.fTemperatureDiff, 1);
|
|
|
|
|
indexControlViewModel.RefreshRealTemperature(realTemperature);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void RealHandle_1()
|
|
|
|
|
{
|
|
|
|
|