change - 添加实时温度采集

master
wenjy 3 months ago
parent 6fbb912784
commit 93bbdab177

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.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
{
/// <summary>
/// 最高温
/// </summary>
public float fMaxTemperature { get; set; }
/// <summary>
/// 最低温
/// </summary>
public float fMinTemperature { get; set; }//
/// <summary>
/// 平均温
/// </summary>
public float fAverageTemperature { get; set; }//
/// <summary>
/// 温差
/// </summary>
public float fTemperatureDiff { get; set; }//
}
}

@ -322,7 +322,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<TextBlock Text="平均温度 ℃" Foreground="Gray" FontSize="16" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
<Border Grid.Row="1" >
<TextBlock Text="28" Foreground="Black" FontSize="24" FontWeight="Black" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RealTemperature.fAverageTemperature}" Foreground="Black" FontSize="24" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
</Grid>
</Border>
@ -347,7 +347,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<TextBlock Text="最高温度 ℃" Foreground="Gray" FontSize="16" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
<Border Grid.Row="1" >
<TextBlock Text="39" Foreground="#ED4F31" FontSize="24" FontWeight="Black" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RealTemperature.fMaxTemperature}" Foreground="#ED4F31" FontSize="24" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
</Grid>
</Border>
@ -374,7 +374,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<TextBlock Text="最低温度 ℃" Foreground="Gray" FontSize="16" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
<Border Grid.Row="1" >
<TextBlock Text="28" Foreground="Black" FontSize="24" FontWeight="Black" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RealTemperature.fMinTemperature}" Foreground="Black" FontSize="24" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
</Grid>
</Border>

@ -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(() =>
{
@ -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; //规则ID0代表获取全部规则具体规则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<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()
{
try

@ -45,6 +45,7 @@
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="Lierda.WPFHelper" Version="1.0.3" />
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="NVelocity" Version="1.2.0" />

@ -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
* CLR4.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;
}
}
}
Loading…
Cancel
Save