change - 添加巡检模式录像保存

master
wenjy 3 months ago
parent 7c176833a5
commit f7630c12c4

@ -37,6 +37,21 @@ namespace SlnMesnac.Config
/// </summary>
public string logPath { get; set; }
/// <summary>
/// 可见光图像保存路径
/// </summary>
public string visibleRangePath { get; set; }
/// <summary>
/// 热成像图像保存路径
/// </summary>
public string infraredImagePath { get; set; }
/// <summary>
/// 录像保存路径
/// </summary>
public string videoFilePath { get; set; }
/// <summary>
/// Sql连接配置
/// </summary>

@ -566,7 +566,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<TextBlock Text="自动模式" FontSize="16" FontWeight="Black" Foreground="DimGray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="1" Background="Transparent" BorderBrush="#0050BF" BorderThickness="2" CornerRadius="5" Margin="0,5">
<Border x:Name="btn_automatic" Grid.Row="1" Background="Transparent" BorderBrush="#0050BF" BorderThickness="2" CornerRadius="5" Margin="0,5" MouseDown="btn_automatic_MouseDown" >
<TextBlock Text="巡检模式" FontSize="16" FontWeight="Black" Foreground="DimGray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Config;
using SlnMesnac.Model.dto;
using SlnMesnac.Serilog;
using SlnMesnac.WPF.ViewModel;
@ -31,6 +32,7 @@ namespace SlnMesnac.WPF.Page
{
private IndexControlViewModel indexControlViewModel = new IndexControlViewModel();
private SerilogHelper serilogHelper = null;
private AppConfig _appConfig = null;
private bool m_bInitSDK = false;
private Int32 m_lUserID = -1;
@ -53,6 +55,7 @@ namespace SlnMesnac.WPF.Page
InitializeComponent();
this.DataContext = indexControlViewModel;
serilogHelper = App.ServiceProvider.GetService<SerilogHelper>();
_appConfig = App.ServiceProvider.GetService<AppConfig>();
_callback = new CHCNetSDK.RemoteConfigCallback(GetThermInfoCallback);
Task.Run(() =>
@ -133,27 +136,37 @@ namespace SlnMesnac.WPF.Page
realTemperature.fTemperatureDiff = (float)Math.Round(ret.struLinePolygonThermCfg.fTemperatureDiff, 1);
indexControlViewModel.RefreshRealTemperature(realTemperature);
string sJpegPicFileName = $"F:\\桌面\\赛轮智慧热电项目\\日志信息\\picture\\{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
if(realTemperature.fMaxTemperature > 65)
{
int lChannel = 2;
CHCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new CHCNetSDK.NET_DVR_JPEGPARA();
lpJpegPara.wPicQuality = 0; //图像质量 Image quality
lpJpegPara.wPicSize = 0xff; //抓图分辨率 Picture size: 2- 4CIF0xff- Auto(使用当前码流分辨率)抓图分辨率需要设备支持更多取值请参考SDK文档
string sJpegPicFileName = $"{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
for (int i = 1; 1 < 3; i++){
CHCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new CHCNetSDK.NET_DVR_JPEGPARA();
lpJpegPara.wPicQuality = 0;
lpJpegPara.wPicSize = 0xff;
var path = string.Empty;
if (i == 1)
{
path = $"{_appConfig.visibleRangePath}\\{sJpegPicFileName}";
}
else
{
path = $"{_appConfig.infraredImagePath}\\{sJpegPicFileName}";
}
//JPEG抓图 Capture a JPEG picture
if (!CHCNetSDK.NET_DVR_CaptureJPEGPicture(m_lUserID, lChannel, ref lpJpegPara, sJpegPicFileName))
{
var str = "NET_DVR_CaptureJPEGPicture failed, error code= " + NET_DVR_GetLastError();
DebugInfo(str);
return;
}
else
{
var str = "Successful to capture the JPEG file and the saved file is " + sJpegPicFileName;
DebugInfo(str);
//JPEG抓图 Capture a JPEG picture
if (!CHCNetSDK.NET_DVR_CaptureJPEGPicture(m_lUserID, i, ref lpJpegPara, path))
{
var str = "高温报警,图像信息保存失败, error code= " + NET_DVR_GetLastError();
DebugInfo(str);
return;
}
else
{
var str = "高温报警,图像信息保存成功: " + path;
DebugInfo(str);
}
}
}
}
@ -375,5 +388,90 @@ namespace SlnMesnac.WPF.Page
bAuto = false;
}
}
private bool is_automatic = false;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_automatic_MouseDown(object sender, MouseButtonEventArgs e)
{
if (!is_automatic)
{
MessageBox.Show("巡检模式开启");
btn_automatic.Background = new SolidColorBrush(Colors.LightBlue);
is_automatic = true;
string fileName = $"{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.mp4";
Task.Run(() =>
{
var url = $"{_appConfig.videoFilePath}\\可见光\\{fileName}";
CHCNetSDK.NET_DVR_MakeKeyFrame(m_lUserID, 1);
if (!CHCNetSDK.NET_DVR_SaveRealData(m_lRealHandle_1, url))
{
var str = "可见光通道开启巡检录像失败, error code= " + NET_DVR_GetLastError();
DebugInfo(str);
return;
}
else
{
DebugInfo($"可见光通道开启巡检录像成功");
}
});
Task.Run(() =>
{
var url = $"{_appConfig.videoFilePath}\\热成像\\{fileName}";
CHCNetSDK.NET_DVR_MakeKeyFrame(m_lUserID, 2);
if (!CHCNetSDK.NET_DVR_SaveRealData(m_lRealHandle_2, url))
{
var str = "热成像通道开启巡检录像失败, error code= " + NET_DVR_GetLastError();
DebugInfo(str);
return;
}
else
{
DebugInfo($"热成像通道开启巡检录像成功");
}
});
}
else
{
//MessageBox.Show("巡检模式关闭");
btn_automatic.Background = new SolidColorBrush(Colors.Transparent);
is_automatic = false;
Task.Run(() =>
{
if (!CHCNetSDK.NET_DVR_StopSaveRealData(m_lRealHandle_1))
{
var str = "可见光通道关闭巡检录像失败, error code= " + NET_DVR_GetLastError();
DebugInfo(str);
return;
}
else
{
DebugInfo($"可见光通道关闭巡检录像成功");
}
});
Task.Run(() =>
{
if (!CHCNetSDK.NET_DVR_StopSaveRealData(m_lRealHandle_2))
{
var str = "热成像通道关闭巡检录像失败, error code= " + NET_DVR_GetLastError();
DebugInfo(str);
return;
}
else
{
DebugInfo($"热成像通道关闭巡检录像成功");
}
});
}
}
}
}

@ -9,6 +9,9 @@
"AllowedHosts": "*",
"AppConfig": {
"logPath": "F:\\桌面\\赛轮智慧热电项目\\日志信息",
"visibleRangePath": "F:\\桌面\\赛轮智慧热电项目\\日志信息\\可见光图像",
"infraredImagePath": "F:\\桌面\\赛轮智慧热电项目\\日志信息\\红外热成像",
"videoFilePath": "F:\\桌面\\赛轮智慧热电项目\\日志信息\\巡检录像",
"SqlConfig": [
{
"configId": "mes",

Loading…
Cancel
Save