|
|
|
@ -18,6 +18,7 @@ using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Interop;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
@ -34,7 +35,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
private IndexControlViewModel indexControlViewModel = new IndexControlViewModel();
|
|
|
|
|
private SerilogHelper serilogHelper = null;
|
|
|
|
|
private AppConfig _appConfig = null;
|
|
|
|
|
private AutoTaskBusiness taskBusiness = null;
|
|
|
|
|
private AutoModeBusiness taskBusiness = null;
|
|
|
|
|
private InspModeBusiness inspModeBusiness = null;
|
|
|
|
|
|
|
|
|
|
private bool m_bInitSDK = false;
|
|
|
|
|
private Int32 m_lUserID = -1;
|
|
|
|
@ -58,11 +60,22 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
this.DataContext = indexControlViewModel;
|
|
|
|
|
serilogHelper = App.ServiceProvider.GetService<SerilogHelper>();
|
|
|
|
|
_appConfig = App.ServiceProvider.GetService<AppConfig>();
|
|
|
|
|
taskBusiness = App.ServiceProvider.GetService<AutoTaskBusiness>();
|
|
|
|
|
taskBusiness = App.ServiceProvider.GetService<AutoModeBusiness>();
|
|
|
|
|
inspModeBusiness = App.ServiceProvider.GetService<InspModeBusiness>();
|
|
|
|
|
_callback = new CHCNetSDK.RemoteConfigCallback(GetThermInfoCallback);
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Open_Device();
|
|
|
|
|
|
|
|
|
|
taskBusiness.CaptureAlarmPictureEvent += CapturePicture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Open_Device()
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
m_bInitSDK = CHCNetSDK.NET_DVR_Init();
|
|
|
|
|
if (m_bInitSDK == false)
|
|
|
|
@ -77,16 +90,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
DebugInfo("热成像双光谱微型云台初始化成功!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Open_Device();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Open_Device()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
m_lUserID = CHCNetSDK.NET_DVR_Login_V30(DVRIPAddress, DVRPortNumber, DVRUserName, DVRPassword, ref DeviceInfo);
|
|
|
|
|
|
|
|
|
|
if (m_lUserID < 0)
|
|
|
|
@ -99,7 +103,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
//登录成功
|
|
|
|
|
DebugInfo("热成像双光谱微型云台打开成功!");
|
|
|
|
|
|
|
|
|
|
Start_Grab(); //打开实时预览
|
|
|
|
|
//SceneryPreview();
|
|
|
|
|
//ThermalPreview();
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// 加载实时温度数据
|
|
|
|
@ -119,6 +124,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -126,23 +133,40 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 测温回调函数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dwType"></param>
|
|
|
|
|
/// <param name="lpBuffer"></param>
|
|
|
|
|
/// <param name="dwBufLen"></param>
|
|
|
|
|
/// <param name="pUserData"></param>
|
|
|
|
|
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}");
|
|
|
|
|
|
|
|
|
|
taskBusiness._realTemperatureInfo.fMaxTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMaxTemperature, 1);
|
|
|
|
|
taskBusiness._realTemperatureInfo.fMinTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMinTemperature, 1);
|
|
|
|
|
taskBusiness._realTemperatureInfo.fMinTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMinTemperature);
|
|
|
|
|
taskBusiness._realTemperatureInfo.fAverageTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fAverageTemperature, 1);
|
|
|
|
|
taskBusiness._realTemperatureInfo.fTemperatureDiff = (float)Math.Round(ret.struLinePolygonThermCfg.fTemperatureDiff, 1);
|
|
|
|
|
indexControlViewModel.RefreshRealTemperature(taskBusiness._realTemperatureInfo);
|
|
|
|
|
|
|
|
|
|
var real = new RealTemperatureInfo()
|
|
|
|
|
{
|
|
|
|
|
fMaxTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMaxTemperature, 1),
|
|
|
|
|
fMinTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMinTemperature, 1),
|
|
|
|
|
fAverageTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fAverageTemperature, 1),
|
|
|
|
|
fTemperatureDiff = (float)Math.Round(ret.struLinePolygonThermCfg.fTemperatureDiff, 1),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
indexControlViewModel.RefreshRealTemperature(real);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (taskBusiness._realTemperatureInfo.fMaxTemperature > 65)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 抓拍图像
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sJpegPicFileName"></param>
|
|
|
|
|
public void CapturePicture(string sJpegPicFileName)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i < 3; i++)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
@ -156,7 +180,6 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
path = $"{_appConfig.infraredImagePath}\\{sJpegPicFileName}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//JPEG抓图 Capture a JPEG picture
|
|
|
|
|
if (!CHCNetSDK.NET_DVR_CaptureJPEGPicture(m_lUserID, i, ref lpJpegPara, path))
|
|
|
|
|
{
|
|
|
|
|
var str = "高温报警,图像信息保存失败, error code= " + NET_DVR_GetLastError();
|
|
|
|
@ -170,12 +193,15 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void RealHandle_1()
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 可见光预览
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void SceneryPreview()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
CHCNetSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO();
|
|
|
|
|
lpPreviewInfo.hPlayWnd = RealPlayWnd.Handle;//预览窗口 live view window
|
|
|
|
@ -199,6 +225,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
//预览成功
|
|
|
|
|
DebugInfo("光景图像预览加载成功!");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -207,9 +235,14 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RealHandle_2()
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 热成像预览
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ThermalPreview()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
CHCNetSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO();
|
|
|
|
|
lpPreviewInfo.hPlayWnd = RealPlayWnd2.Handle;//预览窗口 live view window
|
|
|
|
@ -233,6 +266,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
//预览成功
|
|
|
|
|
DebugInfo("热成像预览加载成功!");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -241,40 +276,9 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭设备
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Close_Device()
|
|
|
|
|
{
|
|
|
|
|
if (!CHCNetSDK.NET_DVR_Logout(m_lUserID))
|
|
|
|
@ -286,11 +290,16 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
DebugInfo("NET_DVR_Logout succ!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日志记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str"></param>
|
|
|
|
|
private void DebugInfo(string str)
|
|
|
|
|
{
|
|
|
|
|
serilogHelper.Camera(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 云台控制
|
|
|
|
|
private void btnUp_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.TILT_UP, 0, 4);
|
|
|
|
@ -330,7 +339,13 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
{
|
|
|
|
|
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.PAN_RIGHT, 1, 4);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 云台回零点
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btn_ptz_set_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -390,22 +405,29 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool is_automatic = false;
|
|
|
|
|
private bool is_insp_model = false;
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// 巡检模式
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btn_automatic_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
private void btn_inspmode_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_automatic)
|
|
|
|
|
if (!is_insp_model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (is_auto_model)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("巡检模式开启");
|
|
|
|
|
MessageBox.Show("当前处于自动模式中,请先关闭自动模式,再开启巡检模式");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btn_automatic.Background = new SolidColorBrush(Colors.LightBlue);
|
|
|
|
|
is_automatic = true;
|
|
|
|
|
string fileName = $"{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.mp4";
|
|
|
|
|
is_insp_model = true;
|
|
|
|
|
string taskCode = DateTime.Now.ToString("yyyyMMddHHmmssffff");
|
|
|
|
|
string fileName = $"{taskCode}.mp4";
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
var url = $"{_appConfig.videoFilePath}\\可见光\\{fileName}";
|
|
|
|
@ -437,12 +459,14 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
DebugInfo($"热成像通道开启巡检录像成功");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
inspModeBusiness.Start(taskCode, fileName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//MessageBox.Show("巡检模式关闭");
|
|
|
|
|
btn_automatic.Background = new SolidColorBrush(Colors.Transparent);
|
|
|
|
|
is_automatic = false;
|
|
|
|
|
is_insp_model = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
@ -475,20 +499,74 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool is_autotask = false;
|
|
|
|
|
private void btn_autotask_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
private bool is_auto_model = false;
|
|
|
|
|
private void btn_automode_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!is_auto_model)
|
|
|
|
|
{
|
|
|
|
|
if (!is_autotask)
|
|
|
|
|
if (is_insp_model)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("当前处于巡检模式中,请先关闭巡检模式,再开启自动模式");
|
|
|
|
|
}
|
|
|
|
|
btn_autotask.Background = new SolidColorBrush(Colors.LightBlue);
|
|
|
|
|
is_autotask = true;
|
|
|
|
|
taskBusiness.AutoCheckHandle();
|
|
|
|
|
is_auto_model = true;
|
|
|
|
|
taskBusiness.Start();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btn_autotask.Background = new SolidColorBrush(Colors.Transparent);
|
|
|
|
|
is_autotask = false;
|
|
|
|
|
is_auto_model = false;
|
|
|
|
|
taskBusiness.Stop();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开启预览
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btn_start_preview_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (m_lRealHandle_1 > 0 || m_lRealHandle_2 > 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("实时预览已开启,请勿重复开启");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SceneryPreview();
|
|
|
|
|
ThermalPreview();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 停止预览
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btn_stop_preview_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
m_lRealHandle_2 = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|