diff --git a/SlnMesnac.Model/dto/RealTemperatureInfo.cs b/SlnMesnac.Model/dto/RealTemperatureInfo.cs
new file mode 100644
index 0000000..17da694
--- /dev/null
+++ b/SlnMesnac.Model/dto/RealTemperatureInfo.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:T14-GEN3-7895
+* 命名空间:SlnMesnac.Model.dto
+* 唯一标识:72de6948-1a7f-4f38-be57-6a095166f5db
+*
+* 创建者:WenJY
+* 电子邮箱:
+* 创建时间:2024-10-31 9:39:05
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.Model.dto
+{
+ public class RealTemperatureInfo
+ {
+
+ ///
+ /// 最高温
+ ///
+ public float fMaxTemperature { get; set; }
+
+ ///
+ /// 最低温
+ ///
+ public float fMinTemperature { get; set; }//
+
+ ///
+ /// 平均温
+ ///
+ public float fAverageTemperature { get; set; }//
+
+ ///
+ /// 温差
+ ///
+ public float fTemperatureDiff { get; set; }//
+ }
+}
diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml b/SlnMesnac.WPF/Page/IndexControl.xaml
index bf976f1..136c402 100644
--- a/SlnMesnac.WPF/Page/IndexControl.xaml
+++ b/SlnMesnac.WPF/Page/IndexControl.xaml
@@ -322,7 +322,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
-
+
@@ -347,7 +347,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
-
+
@@ -374,7 +374,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
-
+
diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml.cs b/SlnMesnac.WPF/Page/IndexControl.xaml.cs
index 3555db8..d59888f 100644
--- a/SlnMesnac.WPF/Page/IndexControl.xaml.cs
+++ b/SlnMesnac.WPF/Page/IndexControl.xaml.cs
@@ -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
///
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();
+ _callback = new CHCNetSDK.RemoteConfigCallback(GetThermInfoCallback);
Task.Run(() =>
{
@@ -72,22 +78,61 @@ namespace SlnMesnac.WPF.Page
private void Open_Device()
{
- m_lUserID = CHCNetSDK.NET_DVR_Login_V30(DVRIPAddress, DVRPortNumber, DVRUserName, DVRPassword, ref DeviceInfo);
-
- if (m_lUserID < 0)
+ try
{
- string str = "热成像双光谱微型云台打开失败, error code= " + CHCNetSDK.NET_DVR_GetLastError(); ; //登录失败,输出错误号 Failed to login and output the error code
- DebugInfo(str);
+ 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(); //打开实时预览
+
+ ///
+ /// 加载实时温度数据
+ ///
+ 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;
+ }
+ }
}
- else
+ catch (Exception ex)
{
- //登录成功
- DebugInfo("热成像双光谱微型云台打开成功!");
-
- Start_Grab();
+ DebugInfo($"热成像双光谱微型云台加载异常: {ex.Message}");
}
}
+ public void GetThermInfoCallback(uint dwType, IntPtr lpBuffer, uint dwBufLen, IntPtr pUserData)
+ {
+ var ret = Marshal.PtrToStructure(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()
{
try
diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
index 58a3750..ec29df7 100644
--- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj
+++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
@@ -45,6 +45,7 @@
+
diff --git a/SlnMesnac.WPF/ViewModel/IndexControlViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexControlViewModel.cs
new file mode 100644
index 0000000..e95559d
--- /dev/null
+++ b/SlnMesnac.WPF/ViewModel/IndexControlViewModel.cs
@@ -0,0 +1,47 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using SlnMesnac.Model.dto;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:T14-GEN3-7895
+* 命名空间:SlnMesnac.WPF.ViewModel
+* 唯一标识:018cae17-522c-47d7-be8b-558e6ddda75f
+*
+* 创建者:WenJY
+* 电子邮箱:
+* 创建时间:2024-10-31 9:40:56
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.WPF.ViewModel
+{
+ public class IndexControlViewModel : ObservableObject
+ {
+ public RealTemperatureInfo _realTemperature;
+ public RealTemperatureInfo RealTemperature
+ {
+ get => _realTemperature;
+ set => SetProperty(ref _realTemperature, value);
+ }
+
+ public void RefreshRealTemperature(RealTemperatureInfo realTemperature)
+ {
+ this.RealTemperature = realTemperature;
+ }
+ }
+}