Browse Source

[fix] 宇视预置点 NETDEV_PTZPreset_Other

master
fajiao 1 year ago
parent
commit
b48bd591dc
  1. 24
      EC.Util/CameraSDK/YuShi/YuShiOriSDK.cs
  2. 18
      EC.Util/CameraSDK/YuShi/YuShiSDK.cs
  3. 5
      JiLinApp/Pages/Main/MainWindow.xaml.cs

24
EC.Util/CameraSDK/YuShi/YuShiOriSDK.cs

@ -49,6 +49,7 @@ public static class YuShiOriSDK
public const int PtzSpeedMax = 9; public const int PtzSpeedMax = 9;
/* Common length */ /* Common length */
public const int NETDEV_LEN_32 = 32;
public const int NETDEV_LEN_64 = 64; public const int NETDEV_LEN_64 = 64;
public const int NETDEV_LEN_128 = 128; public const int NETDEV_LEN_128 = 128;
public const int NETDEV_LEN_132 = 132; public const int NETDEV_LEN_132 = 132;
@ -83,6 +84,8 @@ public static class YuShiOriSDK
public const int PRESET_SET = 0; /* Set preset */ public const int PRESET_SET = 0; /* Set preset */
public const int PRESET_CLE = 1; /* Clear preset */ public const int PRESET_CLE = 1; /* Clear preset */
public const int PRESET_GOTO = 2; /* Go to preset */ public const int PRESET_GOTO = 2; /* Go to preset */
/* Maximum number of presets */
public const int NETDEV_MAX_PRESET_NUM = 255;
public enum NETDEV_LIVE_STREAM_INDEX_E : int public enum NETDEV_LIVE_STREAM_INDEX_E : int
{ {
@ -188,6 +191,24 @@ public static class YuShiOriSDK
public byte[] szReserve; /* Reserved */ public byte[] szReserve; /* Reserved */
} }
[StructLayout(LayoutKind.Sequential)]
public struct NETDEV_PTZ_ALLPRESETS_S
{
public Int32 dwSize; /* Total number of presets */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NETDEV_MAX_PRESET_NUM)]
public NETDEV_PTZ_PRESET_S[] astPreset; /* Structure of preset information */
}
[StructLayout(LayoutKind.Sequential)]
public struct NETDEV_PTZ_PRESET_S
{
public Int32 dwPresetID; /* ID Preset ID */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NETDEV_LEN_32)]
public byte[] szPresetName; /** Preset name */
}
#endregion SDK Struct #endregion SDK Struct
#region Common Method #region Common Method
@ -227,5 +248,8 @@ public static class YuShiOriSDK
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] [DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int NETDEV_StopRealPlay(IntPtr lpRealHandle); public static extern int NETDEV_StopRealPlay(IntPtr lpRealHandle);
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 NETDEV_GetPTZPresetList(IntPtr lpUserID, Int32 dwChannelID, ref NETDEV_PTZ_ALLPRESETS_S lpOutBuffer);
#endregion Common Method #endregion Common Method
} }

18
EC.Util/CameraSDK/YuShi/YuShiSDK.cs

@ -1,4 +1,7 @@
namespace EC.Util.CameraSDK; using System.Runtime.InteropServices;
using static EC.Util.CameraSDK.YuShiOriSDK;
namespace EC.Util.CameraSDK;
public class YuShiSDK : ICameraSDK public class YuShiSDK : ICameraSDK
{ {
@ -30,7 +33,11 @@ public class YuShiSDK : ICameraSDK
YuShiOriSDK.NETDEV_SELOG_INFO_S logInfo = new(); YuShiOriSDK.NETDEV_SELOG_INFO_S logInfo = new();
LoginId = YuShiOriSDK.NETDEV_Login_V30(ref loginInfo, ref logInfo); LoginId = YuShiOriSDK.NETDEV_Login_V30(ref loginInfo, ref logInfo);
ret = ConnectSuccess(); ret = ConnectSuccess();
if(!ret) BuildException(); if (!ret) BuildException();
//别删 NETDEV_QueryVideoChlDetailList,否则 NETDEV_PTZPreset_Other 教做人
int pdwChlCount = 16;
IntPtr pstVideoChlList = Marshal.AllocHGlobal(pdwChlCount * Marshal.SizeOf(typeof(NETDEV_VIDEO_CHL_DETAIL_INFO_S)));
YuShiOriSDK.NETDEV_QueryVideoChlDetailList(LoginId, ref pdwChlCount, pstVideoChlList);
return ret; return ret;
} }
@ -94,8 +101,13 @@ public class YuShiSDK : ICameraSDK
public override bool PtzPreset(int cmd, int presetId) public override bool PtzPreset(int cmd, int presetId)
{ {
if (!ConnectSuccess()) return false; if (!ConnectSuccess()) return false;
int retNum = YuShiOriSDK.NETDEV_PTZPreset_Other(LoginId, Channel, cmd, Array.Empty<byte>(), presetId); NETDEV_PTZ_ALLPRESETS_S ptzPresets = new();
int retNum = YuShiOriSDK.NETDEV_GetPTZPresetList(LoginId, Channel, ref ptzPresets);
bool ret = retNum == YuShiOriSDK.TRUE; bool ret = retNum == YuShiOriSDK.TRUE;
Console.WriteLine($"NETDEV_GetPTZPresetList:{retNum}, handle:{LoginId}, ptzPresets.dwSize:{ptzPresets.dwSize}");
if (!ret) BuildException();
retNum = YuShiOriSDK.NETDEV_PTZPreset_Other(LoginId, Channel, cmd, new byte[32], presetId);
ret = retNum == YuShiOriSDK.TRUE;
if (!ret) BuildException(); if (!ret) BuildException();
return ret; return ret;
} }

5
JiLinApp/Pages/Main/MainWindow.xaml.cs

@ -39,9 +39,4 @@ public partial class MainWindow : Window
private static extern bool AttachConsole(int dwProcessId); private static extern bool AttachConsole(int dwProcessId);
#endregion #endregion
private void Button_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("test");
}
} }
Loading…
Cancel
Save