using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Runtime.InteropServices;
|
using static IDViewer_2D.IDViewerDefines;
|
|
namespace IDViewer_2D
|
{
|
class IDViewerSDK
|
{
|
public class Node
|
{
|
public IDViewerDefines.IDDeviceInfo data;
|
public Node next;
|
}
|
|
public struct LinkedList
|
{
|
public Node head;
|
[MarshalAs(UnmanagedType.SysInt)]
|
public int size;
|
}
|
/****************************************
|
IDImage
|
//*****************************************/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Init", CharSet = CharSet.Ansi)]
|
public static extern long IDImage_Init(ref IntPtr imagePtr);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Destroy", CharSet = CharSet.Ansi)]
|
public static extern void IDImage_Destroy(ref IntPtr imagePtr);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Width", CharSet = CharSet.Ansi)]
|
public static extern long IDImage_Width(IntPtr imageHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Height", CharSet = CharSet.Ansi)]
|
public static extern long IDImage_Height(IntPtr imageHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Step", CharSet = CharSet.Ansi)]
|
public static extern long IDImage_Step(IntPtr imageHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_BitDepth", CharSet = CharSet.Auto)]
|
public static extern long IDImage_BitDepth(IntPtr imageHandle,ref IntPtr imageType);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Channels", CharSet = CharSet.Ansi)]
|
public static extern long IDImage_Channels(IntPtr imageHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_ImageData", CharSet = CharSet.Ansi)]
|
public static extern IntPtr IDImage_ImageData(IntPtr imageHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_SaveImage", CharSet = CharSet.Ansi)]
|
public static extern long IDImage_SaveImage(IntPtr imageHandle, string filePath, int compression);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_SaveImageW", CharSet = CharSet.Unicode)]
|
public static extern long IDImage_SaveImageW(IntPtr imageHandle, string filePath, int compression);
|
|
|
/****************************************
|
IDDevice
|
*****************************************/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Open", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_Open(IntPtr deviceHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsOpen", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_IsOpen(IntPtr deviceHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_StartRunning", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_StartRunning(IntPtr deviceHandle,int isCallBack); //isCallBack>0 注册回调,等于0 不注册回调
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_StartDebugging", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_StartDebugging(IntPtr deviceHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsRunning", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_IsRunning(IntPtr deviceHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsConnected", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_IsConnected(IntPtr deviceHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Stop", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_Stop(IntPtr deviceHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Close", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_Close(IntPtr deviceHandle);
|
|
/****************************************
|
DeviceInfo
|
*****************************************/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetDeviceInfo", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_GetDeviceInfo(IntPtr deviceHandle, ref IDDeviceInfo DeviceInfoHandel);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetHardWareParams", CharSet = CharSet.Ansi)]
|
public static extern IDViewerDefines.IDDeviceHarewareParams IDDevice_GetHardWareParams(IntPtr deviceHandle);
|
|
//此接口需要VS2019以上版本,C#7.0更新支持引入了新的语法ref return和ref locals,允许函数的返回值也可以被声明为引用
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetSolutionList", CharSet = CharSet.Ansi)]
|
public static extern ref StringList IDDevice_GetSolutionList(IntPtr deviceHandle, int timeout = 2000);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetRunningSolution", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_SetRunningSolution(IntPtr deviceHandle,byte[] solutionName, int timeout = 2000);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetRunningSolution", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_GetRunningSolution(IntPtr deviceHandle, byte[] solutionName, int timeout = 2000);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DeleteSolution", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_DeleteSolution(IntPtr deviceHandle, string solutionName, int timeout = 2000);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Release", CharSet = CharSet.Ansi)]
|
public static extern void IDDevice_Release(IntPtr deviceHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_FreeSolutionList", CharSet = CharSet.Ansi)]
|
public static extern void IDDevice_FreeSolutionList(StringList solutionList);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetIlluminanatbrightnessLength", CharSet = CharSet.Ansi)]
|
public static extern long IDDevice_GetIlluminanatbrightnessLength(IntPtr deviceHandle);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetIlluminanatbrightness", CharSet = CharSet.Ansi)]
|
public static extern IDNodeParam IDDevice_GetIlluminanatbrightness(IntPtr deviceHandle, uint index);
|
|
//回调函数
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_ResultNotify_")]
|
public static extern void IDCallback_ResultNotify_(IntPtr deviceHandle, IntPtr resCallback);
|
|
//[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeInfo")]
|
//public extern static IntPtr IDCallback_GetIDDecodeInfo(IntPtr decodeInfoHandel); //IDCallback_GetIDDecodeInfo
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeInfo_A")]
|
public extern static long IDCallback_GetIDDecodeInfo_A(IntPtr decodeInfoHandel,ref IDDecodeInfo info); //IDCallback_GetIDDecodeInfo
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeROIInfo", CharSet = CharSet.Ansi)]
|
public static extern IDDecodeROIInfo IDCallback_GetIDDecodeROIInfo(IntPtr decodeInfoHandel, uint index);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeResult", CharSet = CharSet.Ansi)]
|
public static extern IDDecodeResult IDCallback_GetIDDecodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, uint index);
|
|
/*
|
*decodeROIInfoIndex 第几个ROI
|
*decodeResultIndex 先忽略,
|
*index ROI内的第几个成功解码结果
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDMCodeResult", CharSet = CharSet.Ansi)]
|
public static extern long IDCallback_GetIDDMCodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
|
uint decodeResultIndex, uint index, ref IDDMCodeResult IDDMCodeResultData);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetID_QR_CODE_Result", CharSet = CharSet.Ansi)]
|
public static extern long IDCallback_GetID_QR_CODE_Result(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
|
uint decodeResultIndex, uint index, ref IDQRCodeResult ID_QR_CODE_RESULTData);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDPDF417CodeResult", CharSet = CharSet.Ansi)]
|
public static extern long IDCallback_GetIDPDF417CodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
|
uint decodeResultIndex, uint index, ref IDPDF417CodeResult IDPDF417CodeResultData);
|
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDBarCodeResult", CharSet = CharSet.Ansi)]
|
public static extern long IDCallback_GetIDBarCodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
|
uint decodeResultIndex, uint index, ref IDBarCodeResult IDBarCodeResultData);
|
/**
|
* @brief IDVIEWER_Init 使用SDK其他功能前需要先调用该初始化方法
|
* @return 错误码
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_Init_", CharSet = CharSet.Ansi)]
|
public extern static long IDVIEWER_Init_();
|
|
/**
|
* @brief IDVIEWER_DiscoveryDevices 扫描设备列表
|
* @param deviceList 返回获取的设备列表
|
* @param discoveryTime 扫描周期,默认200(单位毫秒)
|
* @return 错误码
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_DiscoveryDevices_", CharSet = CharSet.Ansi)]
|
public extern static IntPtr IDVIEWER_DiscoveryDevices_(uint discoveryTime = 200);
|
|
/**
|
* @brief IDVIEWER_GetDevicesLength_ 设备列表长度
|
* @param deviceList 返回获取的设备列表长度
|
*
|
* @return 长度
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_GetDevicesLength_", CharSet = CharSet.Ansi)]
|
public extern static long IDVIEWER_GetDevicesLength_(IntPtr DevicesList);
|
|
/**
|
* @brief IDVIEWER_SelectIDDeviceInfo_ 获取某个序号的设备
|
* @param DevicesList 当前设备列表指针
|
* @param index 设备列表的序号
|
|
* @return 设备信息
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_SelectIDDeviceInfo_", CharSet = CharSet.Ansi)]
|
public extern static long IDVIEWER_SelectIDDeviceInfo_(IntPtr DevicesList, ref IDDeviceInfo IDDeviceInfoHandel, uint index);
|
|
/**
|
* @brief IDVIEWER_SetIP 设置IP 设置IP后需要重新扫描
|
* @param deviceInfo 当前设备信息
|
* @param iPv4 新的IP地址
|
* @param mask 新的MASK地址
|
* @param gateway 新的网关地址
|
* @param isStatic 是否设置静态IP(false为临时IP)
|
* @return 错误码
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_SetIP_", CharSet = CharSet.Ansi)]
|
public static extern long IDVIEWER_SetIP_(ref IDViewerDefines.IDDeviceInfo deviceInfo, string iPv4, string mask, string gateway, bool isStatic);
|
|
|
/**
|
* @brief IDVIEWER_CreateDevice IDVIEWER_CreateDeviceBySN 更加SN创建设备
|
* @param cameraSN 当前设备SN
|
* @param device 创建的设备指针
|
* @return 错误码
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_CreateDeviceBySN_", CharSet = CharSet.Ansi)]
|
public static extern long IDVIEWER_CreateDeviceBySN_(string cameraSN, ref IntPtr deviceHandle);
|
|
/**
|
* @brief IDVIEWER_CreateDevice IDVIEWER_CreateDeviceByIP 更加SN创建设备
|
* @param cameraIP 当前设备IP
|
* @param device 创建的设备指针
|
* @return 错误码
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_CreateDeviceByIP_", CharSet = CharSet.Ansi)]
|
public static extern long IDVIEWER_CreateDeviceByIP_(string cameraIP, ref IntPtr deviceHandle);
|
/**
|
* @brief IDVIEWER_UnInit 使用完SDK后调用释放资源
|
* @return 错误码
|
*/
|
[DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_UnInit_", CharSet = CharSet.Ansi)]
|
public static extern long IDVIEWER_UnInit_(IntPtr deviceList);
|
}
|
}
|