change - 添加云台控制

master
wenjy 3 months ago
parent eedd24b5d5
commit 6fbb912784

@ -59,7 +59,7 @@
<Ellipse Width="80" Height="80" Stroke="White" StrokeThickness="60" Fill="Transparent" /> <Ellipse Width="80" Height="80" Stroke="White" StrokeThickness="60" Fill="Transparent" />
<!--向上--> <!--向上-->
<Border Width="120" Height="40" Background="Transparent" CornerRadius="70,70,0,0" Margin="0,0,0,120" > <Border Width="120" Height="40" Background="Transparent" CornerRadius="70,70,0,0" Margin="0,0,0,120" MouseDown="btnUp_MouseDown" MouseUp="btnUp_MouseUp" >
<Path Stroke="#0050BF" StrokeThickness="1" Fill="#0050BF" VerticalAlignment="Center" HorizontalAlignment="Center"> <Path Stroke="#0050BF" StrokeThickness="1" Fill="#0050BF" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path.Data> <Path.Data>
<PathGeometry> <PathGeometry>
@ -72,7 +72,7 @@
</Path> </Path>
</Border> </Border>
<!--向下--> <!--向下-->
<Border Width="120" Height="40" Background="Transparent" CornerRadius="0,0,70,70" Margin="0,120,0,0"> <Border Width="120" Height="40" Background="Transparent" CornerRadius="0,0,70,70" Margin="0,120,0,0" MouseDown="btnDown_MouseDown" MouseUp="btnDown_MouseUp">
<Path Stroke="#0050BF" StrokeThickness="1" Fill="#0050BF" VerticalAlignment="Center" HorizontalAlignment="Center"> <Path Stroke="#0050BF" StrokeThickness="1" Fill="#0050BF" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path.Data> <Path.Data>
<PathGeometry> <PathGeometry>
@ -85,7 +85,7 @@
</Path> </Path>
</Border> </Border>
<!--向左--> <!--向左-->
<Border Width="40" Height="80" Background="Transparent" CornerRadius="35,0,0,35" Margin="0,0,120,0"> <Border Width="40" Height="80" Background="Transparent" CornerRadius="35,0,0,35" Margin="0,0,120,0" MouseDown="btnLeft_MouseDown" MouseUp="btnLeft_MouseUp">
<Path Stroke="#0050BF" StrokeThickness="1" Fill="#0050BF" VerticalAlignment="Center" HorizontalAlignment="Center"> <Path Stroke="#0050BF" StrokeThickness="1" Fill="#0050BF" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path.Data> <Path.Data>
<PathGeometry> <PathGeometry>
@ -98,7 +98,7 @@
</Path> </Path>
</Border> </Border>
<!--向右--> <!--向右-->
<Border Width="40" Height="80" Background="Transparent" CornerRadius="0,35,35,0" Margin="120,0,0,0"> <Border Width="40" Height="80" Background="Transparent" CornerRadius="0,35,35,0" Margin="120,0,0,0" MouseDown="btnRight_MouseDown" MouseUp="btnRight_MouseUp">
<Path Stroke="#0050BF" StrokeThickness="1" Fill="#0050BF" VerticalAlignment="Center" HorizontalAlignment="Center"> <Path Stroke="#0050BF" StrokeThickness="1" Fill="#0050BF" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path.Data> <Path.Data>
<PathGeometry> <PathGeometry>
@ -111,12 +111,12 @@
</Path> </Path>
</Border> </Border>
<!--停止--> <!--停止-->
<Border Width="80" Height="80" Background="Transparent" CornerRadius="60"> <Border Width="80" Height="80" Background="Transparent" CornerRadius="60" MouseLeftButtonDown="btn_auto_MouseLeftButtonDown">
<TextBlock Text="停止" FontSize="20" Foreground="Red" FontWeight="Black" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock x:Name="btnAuto" Text="Auto" FontSize="20" Foreground="Red" FontWeight="Black" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border> </Border>
</Grid> </Grid>
<Button Content="回 零" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Index}" FontWeight="Black" FontSize="16" Width="100" Height="30" Foreground="#0050BF" Background="#E5EDF8" BorderBrush="#0050BF" Margin="50,0,0,0"/> <Button Content="回 零" FontWeight="Black" FontSize="16" Width="100" Height="30" Foreground="#0050BF" Background="#E5EDF8" BorderBrush="#0050BF" Margin="50,0,0,0" Click="btn_ptz_set_Click"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Border> </Border>

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -32,7 +33,8 @@ namespace SlnMesnac.WPF.Page
private Int32 m_lRealHandle_2 = -1; private Int32 m_lRealHandle_2 = -1;
public CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo; public CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo;
public CHCNetSDK.NET_DVR_IPPARACFG_V40 m_struIpParaCfgV40; public CHCNetSDK.NET_DVR_IPPARACFG_V40 m_struIpParaCfgV40;
private Int32 m_lTree = 0; public CHCNetSDK.NET_DVR_PTZPOS m_struPtzCfg;
private bool bAuto = false;
private string DVRIPAddress = "192.168.1.64"; //设备IP地址或者域名 Device IP private string DVRIPAddress = "192.168.1.64"; //设备IP地址或者域名 Device IP
private Int16 DVRPortNumber = 8000; //设备服务端口号 Device Port private Int16 DVRPortNumber = 8000; //设备服务端口号 Device Port
@ -59,7 +61,7 @@ namespace SlnMesnac.WPF.Page
{ {
//保存SDK日志 To save the SDK log //保存SDK日志 To save the SDK log
CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true); CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
DebugInfo("热成像双光谱微型云台初始化成功 error!"); DebugInfo("热成像双光谱微型云台初始化成功!");
} }
Open_Device(); Open_Device();
@ -203,5 +205,104 @@ namespace SlnMesnac.WPF.Page
{ {
serilogHelper.Camera(str); serilogHelper.Camera(str);
} }
private void btnUp_MouseDown(object sender, MouseButtonEventArgs e)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.TILT_UP, 0, 4);
}
private void btnUp_MouseUp(object sender, MouseButtonEventArgs e)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.TILT_UP, 1, 4);
}
private void btnDown_MouseDown(object sender, MouseButtonEventArgs e)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.TILT_DOWN, 0, 4);
}
private void btnDown_MouseUp(object sender, MouseButtonEventArgs e)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.TILT_DOWN, 1, 4);
}
private void btnLeft_MouseDown(object sender, MouseButtonEventArgs e)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, (uint)CHCNetSDK.PAN_LEFT, 0, 4);
}
private void btnLeft_MouseUp(object sender, MouseButtonEventArgs e)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.PAN_LEFT, 1, 4);
}
private void btnRight_MouseDown(object sender, MouseButtonEventArgs e)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.PAN_RIGHT, 0, 4);
}
private void btnRight_MouseUp(object sender, MouseButtonEventArgs e)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.PAN_RIGHT, 1, 4);
}
private void btn_ptz_set_Click(object sender, RoutedEventArgs e)
{
if (bAuto)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.PAN_AUTO, 1, 4);
btnAuto.Text = "Auto";
bAuto = false;
}
float wPanPos, wTiltPos, wZoomPos;
var flag = 0;
m_struPtzCfg.wAction = 1;
m_struPtzCfg.wPanPos = (ushort)(Convert.ToUInt16("20", 16));
m_struPtzCfg.wTiltPos = (ushort)(Convert.ToUInt16("4", 16));
m_struPtzCfg.wZoomPos = (ushort)(Convert.ToUInt16("10", 16));
while (flag == 0)
{
Int32 nSize = Marshal.SizeOf(m_struPtzCfg);
IntPtr ptrPtzCfg = Marshal.AllocHGlobal(nSize);
Marshal.StructureToPtr(m_struPtzCfg, ptrPtzCfg, false);
if (!CHCNetSDK.NET_DVR_SetDVRConfig(m_lUserID, CHCNetSDK.NET_DVR_SET_PTZPOS, 1, ptrPtzCfg, (UInt32)nSize))
{
var str = "云台回零加载异常, error code= " + CHCNetSDK.NET_DVR_GetLastError();
//设置POS参数失败
DebugInfo(str);
return;
}
else
{
DebugInfo("云台回零加载成功!");
break;
}
Marshal.FreeHGlobal(ptrPtzCfg);
}
}
private void btn_auto_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (!bAuto)
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.PAN_AUTO, 0, 4);
btnAuto.Text = "Stop";
bAuto = true;
}
else
{
CHCNetSDK.NET_DVR_PTZControlWithSpeed(m_lRealHandle_1, CHCNetSDK.PAN_AUTO, 1, 4);
btnAuto.Text = "Auto";
bAuto = false;
}
}
} }
} }

Loading…
Cancel
Save