687 lines
17 KiB
C#
687 lines
17 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace JoyD.Windows.CS.Toprie
|
|
{
|
|
public class A8SDK
|
|
{
|
|
// 结构体定义
|
|
public struct AreaPos
|
|
{
|
|
public int enable;
|
|
public int x;
|
|
public int y;
|
|
public int width;
|
|
public int height;
|
|
}
|
|
|
|
public struct SpotPos
|
|
{
|
|
public int enable;
|
|
public int x;
|
|
public int y;
|
|
}
|
|
|
|
public struct LinePos
|
|
{
|
|
public int enable;
|
|
public int sta_x;
|
|
public int sta_y;
|
|
public int end_x;
|
|
public int end_y;
|
|
}
|
|
|
|
public struct ImagePos
|
|
{
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
|
public AreaPos[] area;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
|
public SpotPos[] spot;
|
|
public LinePos line;
|
|
}
|
|
|
|
public struct AreaTemp
|
|
{
|
|
public int enable;
|
|
public int max_temp;
|
|
public int max_temp_x;
|
|
public int max_temp_y;
|
|
public int min_temp;
|
|
public int min_temp_x;
|
|
public int min_temp_y;
|
|
public int ave_temp;
|
|
}
|
|
|
|
public struct SpotTemp
|
|
{
|
|
public int enable;
|
|
public int temp;
|
|
}
|
|
|
|
public struct LineTemp
|
|
{
|
|
public int enable;
|
|
public int max_temp;
|
|
public int max_temp_x;
|
|
public int max_temp_y;
|
|
public int min_temp;
|
|
public int min_temp_x;
|
|
public int min_temp_y;
|
|
public int ave_temp;
|
|
}
|
|
|
|
public struct GlobaTemp
|
|
{
|
|
public int max_temp;
|
|
public int max_temp_x;
|
|
public int max_temp_y;
|
|
public int min_temp;
|
|
public int min_temp_x;
|
|
public int min_temp_y;
|
|
}
|
|
|
|
public struct ImageTemp
|
|
{
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
|
public AreaTemp[] area;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
|
public SpotTemp[] spot;
|
|
public LineTemp line;
|
|
public GlobaTemp globa;
|
|
}
|
|
|
|
public struct EmailServer
|
|
{
|
|
public int enable;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] recv_addr;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] send_addr;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] send_pwd;
|
|
}
|
|
|
|
public struct TftpServer
|
|
{
|
|
public int enable;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] tftp_addr;
|
|
}
|
|
|
|
public struct NetworkEth
|
|
{
|
|
public int enable;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] static_ip;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] netmask;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] gateway;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] dns1;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
|
public char[] dns2;
|
|
}
|
|
|
|
public struct EnvirParam
|
|
{
|
|
public int method;
|
|
public int num;
|
|
public float emissivity;
|
|
public float airTemp;
|
|
public float targetTemp;
|
|
public float atmosTrans;
|
|
public float distance;
|
|
public float infraredTemp;
|
|
public float infraredRadia;
|
|
}
|
|
|
|
public struct AlarmParam
|
|
{
|
|
public int method;
|
|
public int num;
|
|
public int active;
|
|
public int condition;
|
|
public int captrue;
|
|
public int disableCalib;
|
|
public int email;
|
|
public int digital;
|
|
public int ftp;
|
|
public float threshold;
|
|
public float hysteresis;
|
|
public int thresholeTime;
|
|
}
|
|
|
|
public struct FocusParam
|
|
{
|
|
public int method;
|
|
public int x;
|
|
public int y;
|
|
public int width;
|
|
public int height;
|
|
}
|
|
|
|
public struct TimeParam
|
|
{
|
|
public int year;
|
|
public char month;
|
|
public char day;
|
|
public char hour;
|
|
public char minute;
|
|
public char second;
|
|
}
|
|
|
|
// 使用V8类实例来实现功能
|
|
private readonly string deviceIp;
|
|
private readonly V8 v8Instance;
|
|
|
|
public A8SDK(string ip)
|
|
{
|
|
deviceIp = ip;
|
|
v8Instance = new V8(ip);
|
|
}
|
|
|
|
~A8SDK()
|
|
{
|
|
// V8类的析构函数会自动处理资源释放
|
|
}
|
|
|
|
public static int SDK_initialize()
|
|
{
|
|
return V8.SDK_initialize();
|
|
}
|
|
|
|
public static int SDK_destroy()
|
|
{
|
|
return V8.SDK_destroy();
|
|
}
|
|
|
|
public static String SDK_serch_device(int list_len)
|
|
{
|
|
return V8.SDK_serch_device(list_len);
|
|
}
|
|
|
|
// 快门校正方法
|
|
public void Shutter_correction()
|
|
{
|
|
v8Instance.Shutter_correction();
|
|
}
|
|
|
|
// 快门次数属性
|
|
public int Shutter_times
|
|
{
|
|
get
|
|
{
|
|
return v8Instance.Shutter_times;
|
|
}
|
|
set
|
|
{
|
|
v8Instance.Shutter_times = value;
|
|
}
|
|
}
|
|
|
|
// 色板属性
|
|
public int Color_plate
|
|
{
|
|
get
|
|
{
|
|
return GetColorPlate();
|
|
}
|
|
set
|
|
{
|
|
SetColorPlate(value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前色彩模式
|
|
/// </summary>
|
|
/// <returns>当前色彩模式的值</returns>
|
|
public int GetColorPlate()
|
|
{
|
|
return v8Instance.GetColorPlate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置色彩模式
|
|
/// </summary>
|
|
/// <param name="value">要设置的色彩模式值</param>
|
|
/// <returns>设置是否成功</returns>
|
|
public bool SetColorPlate(int value)
|
|
{
|
|
return v8Instance.SetColorPlate(value);
|
|
}
|
|
|
|
// 镜像模式属性
|
|
public int Mirror_mode
|
|
{
|
|
get
|
|
{
|
|
return v8Instance.Mirror_mode;
|
|
}
|
|
set
|
|
{
|
|
v8Instance.Mirror_mode = value;
|
|
}
|
|
}
|
|
|
|
// 视频模式属性
|
|
public int Video_mode
|
|
{
|
|
get
|
|
{
|
|
return v8Instance.Video_mode;
|
|
}
|
|
set
|
|
{
|
|
v8Instance.Video_mode = value;
|
|
}
|
|
}
|
|
|
|
// 设置区域位置
|
|
public void Set_area_pos(int index, SharedStructures.AreaPos area_data)
|
|
{
|
|
v8Instance.Set_area_pos(index, area_data);
|
|
}
|
|
|
|
// 获取区域位置
|
|
public SharedStructures.AreaPos Get_area_pos(int index)
|
|
{
|
|
return v8Instance.Get_area_pos(index);
|
|
}
|
|
|
|
// 设置点位置
|
|
public void Set_spot_pos(int index, SharedStructures.SpotPos spot_data)
|
|
{
|
|
v8Instance.Set_spot_pos(index, spot_data);
|
|
}
|
|
|
|
// 获取点位置
|
|
public SharedStructures.SpotPos Get_spot_pos(int index)
|
|
{
|
|
return v8Instance.Get_spot_pos(index);
|
|
}
|
|
|
|
// 线位置属性
|
|
public SharedStructures.LinePos Line_pos
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Line_pos = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Line_pos;
|
|
}
|
|
}
|
|
|
|
// 所有位置属性
|
|
public SharedStructures.ImagePos All_pos
|
|
{
|
|
get
|
|
{
|
|
return v8Instance.All_pos;
|
|
}
|
|
}
|
|
|
|
// 温度范围属性
|
|
public int Temp_range
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Temp_range = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Temp_range;
|
|
}
|
|
}
|
|
|
|
// 视频ISP X偏移属性
|
|
public int Video_isp_x_offset
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Video_isp_x_offset = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Video_isp_x_offset;
|
|
}
|
|
}
|
|
|
|
// 视频ISP Y偏移属性
|
|
public int Video_isp_y_offset
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Video_isp_y_offset = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Video_isp_y_offset;
|
|
}
|
|
}
|
|
|
|
// 视频ISP X缩放属性
|
|
public int Video_isp_x_scale
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Video_isp_x_scale = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Video_isp_x_scale;
|
|
}
|
|
}
|
|
|
|
// 视频ISP Y缩放属性
|
|
public int Video_isp_y_scale
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Video_isp_y_scale = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Video_isp_y_scale;
|
|
}
|
|
}
|
|
|
|
// LED设置属性
|
|
public int Set_led
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Set_led = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Set_led;
|
|
}
|
|
}
|
|
|
|
// 邮件服务器属性
|
|
public SharedStructures.EmailServer Email_server
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Email_server = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Email_server;
|
|
}
|
|
}
|
|
|
|
// TFTP服务器属性
|
|
public SharedStructures.TftpServer Tftp_server
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Tftp_server = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Tftp_server;
|
|
}
|
|
}
|
|
|
|
// 网络以太网属性
|
|
public SharedStructures.NetworkEth Network_eth
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Network_eth = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Network_eth;
|
|
}
|
|
}
|
|
|
|
// 融合距离属性
|
|
public int Fusion_distance
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Fusion_distance = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Fusion_distance;
|
|
}
|
|
}
|
|
|
|
// 设置环境参数
|
|
public void Set_envir_param(SharedStructures.EnvirParam data)
|
|
{
|
|
v8Instance.Set_envir_param(data);
|
|
}
|
|
|
|
// 获取区域环境参数
|
|
public SharedStructures.EnvirParam Get_area_envir_param(int index)
|
|
{
|
|
return v8Instance.Get_area_envir_param(index);
|
|
}
|
|
|
|
// 获取点环境参数
|
|
public SharedStructures.EnvirParam Get_spot_envir_param(int index)
|
|
{
|
|
return v8Instance.Get_spot_envir_param(index);
|
|
}
|
|
|
|
// 获取线环境参数
|
|
public SharedStructures.EnvirParam Get_line_envir_param()
|
|
{
|
|
return v8Instance.Get_line_envir_param();
|
|
}
|
|
|
|
// 获取全局环境参数
|
|
public SharedStructures.EnvirParam Get_globa_envir_param()
|
|
{
|
|
return v8Instance.Get_globa_envir_param();
|
|
}
|
|
|
|
// 设置报警参数
|
|
public void Set_alarm_param(SharedStructures.AlarmParam data)
|
|
{
|
|
v8Instance.Set_alarm_param(data);
|
|
}
|
|
|
|
// 获取区域报警参数
|
|
public SharedStructures.AlarmParam Get_area_alarm_param(int index)
|
|
{
|
|
return v8Instance.Get_area_alarm_param(index);
|
|
}
|
|
|
|
// 获取点报警参数
|
|
public SharedStructures.AlarmParam Get_spot_alarm_param(int index)
|
|
{
|
|
return v8Instance.Get_spot_alarm_param(index);
|
|
}
|
|
|
|
// 获取全局报警参数
|
|
public SharedStructures.AlarmParam Get_globa_alarm_param()
|
|
{
|
|
return v8Instance.Get_globa_alarm_param();
|
|
}
|
|
|
|
// 获取线报警参数
|
|
public SharedStructures.AlarmParam Get_line_alarm_param()
|
|
{
|
|
return v8Instance.Get_line_alarm_param();
|
|
}
|
|
|
|
// 获取区域温度
|
|
public SharedStructures.AreaTemp Get_area_temp(int index)
|
|
{
|
|
return v8Instance.Get_area_temp(index);
|
|
}
|
|
|
|
// 获取点温度
|
|
public SharedStructures.SpotTemp Get_spot_temp(int index)
|
|
{
|
|
return v8Instance.Get_spot_temp(index);
|
|
}
|
|
|
|
// 获取线温度
|
|
public SharedStructures.LineTemp Get_line_temp()
|
|
{
|
|
return v8Instance.Get_line_temp();
|
|
}
|
|
|
|
// 获取全局温度
|
|
public SharedStructures.GlobaTemp Get_globa_temp()
|
|
{
|
|
return v8Instance.Get_globa_temp();
|
|
}
|
|
|
|
// 获取所有温度
|
|
public SharedStructures.ImageTemp Get_all_temp()
|
|
{
|
|
return v8Instance.Get_all_temp();
|
|
}
|
|
|
|
// 电源重启
|
|
public void Power_reboot()
|
|
{
|
|
v8Instance.Power_reboot();
|
|
}
|
|
|
|
// 参数恢复
|
|
public void Param_recover()
|
|
{
|
|
v8Instance.Param_recover();
|
|
}
|
|
|
|
// 更新
|
|
public void Update()
|
|
{
|
|
v8Instance.Update();
|
|
}
|
|
|
|
// 心跳检测
|
|
public int Heartbeat()
|
|
{
|
|
return v8Instance.Heartbeat();
|
|
}
|
|
|
|
// 设置串口
|
|
public void Set_uart(int nSpeed, int nBits, char nEvent, int nStop)
|
|
{
|
|
v8Instance.Set_uart(nSpeed, nBits, nEvent, nStop);
|
|
}
|
|
|
|
// 发送串口命令
|
|
public void Send_uart_command(byte[] cmd)
|
|
{
|
|
v8Instance.Send_uart_command(cmd);
|
|
}
|
|
|
|
// 自动对焦
|
|
public void Autofocus(SharedStructures.FocusParam data)
|
|
{
|
|
v8Instance.Autofocus(data);
|
|
}
|
|
|
|
// 设置设备名称
|
|
public void Set_device_name(string data)
|
|
{
|
|
v8Instance.Set_device_name(data);
|
|
}
|
|
|
|
// 获取设备名称
|
|
public string Get_device_name()
|
|
{
|
|
return v8Instance.Get_device_name();
|
|
}
|
|
|
|
// 获取检测数量
|
|
public byte[] Get_detect_number()
|
|
{
|
|
return v8Instance.Get_detect_number();
|
|
}
|
|
|
|
// 温度帧属性
|
|
public char Temp_frame
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Temp_frame = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Temp_frame;
|
|
}
|
|
}
|
|
|
|
// 报警属性
|
|
public char Alarm
|
|
{
|
|
set
|
|
{
|
|
v8Instance.Alarm = value;
|
|
}
|
|
get
|
|
{
|
|
return v8Instance.Alarm;
|
|
}
|
|
}
|
|
|
|
// 补偿温度属性
|
|
public float Comp_temp
|
|
{
|
|
get
|
|
{
|
|
return v8Instance.Comp_temp;
|
|
}
|
|
}
|
|
|
|
// 设置时间
|
|
public void Set_time(SharedStructures.TimeParam data)
|
|
{
|
|
v8Instance.Set_time(data);
|
|
}
|
|
|
|
// 获取视频模式
|
|
public int GetVideoMode()
|
|
{
|
|
return v8Instance.GetVideoMode();
|
|
}
|
|
|
|
// 设置视频模式
|
|
public void SetVideoMode(int mode)
|
|
{
|
|
v8Instance.SetVideoMode(mode);
|
|
}
|
|
|
|
// 获取图像数据
|
|
public byte[] GetImageData()
|
|
{
|
|
return v8Instance.GetImageData();
|
|
}
|
|
|
|
// 设备搜索
|
|
public static List<string> SearchDevices()
|
|
{
|
|
List<string> devices = new List<string>();
|
|
const int maxDevices = 10;
|
|
string searchResult = SDK_serch_device(maxDevices);
|
|
if (!string.IsNullOrEmpty(searchResult))
|
|
{
|
|
string[] deviceList = searchResult.Split(';');
|
|
foreach (string device in deviceList)
|
|
{
|
|
if (!string.IsNullOrEmpty(device))
|
|
{
|
|
devices.Add(device);
|
|
}
|
|
}
|
|
}
|
|
return devices;
|
|
}
|
|
}
|
|
} |