using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace MeterPlugInLibrary
{
    public class Scanning
    {
        /// <summary>
        /// 设置设备类型
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "SetDeviceType", CharSet = CharSet.Ansi)]
        public static extern int SetDeviceType(int iType);

        /// <summary>
        /// 打开扫码枪串口
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "OpenDevice", CharSet = CharSet.Ansi)]
        public static extern int OpenDevice(int iPort, string szComParam);

        /// <summary>
        /// 关闭扫码枪串口
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "CloseDevice", CharSet = CharSet.Ansi)]
        public static extern int CloseDevice();

        /// <summary>
        /// 获取扫码枪状态
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "GetStatus", CharSet = CharSet.Ansi)]
        public static extern int GetStatus();

        /// <summary>
        /// 复位
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "Reset", CharSet = CharSet.Ansi)]
        public static extern int Reset();

        /// <summary>
        /// 同步读条码信息
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "ReadData", CharSet = CharSet.Ansi)]
        public static extern int ReadData(ref byte szData, int iTimeout);

        /// <summary>
        /// 开始异步读数据
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "BeginReadASYN", CharSet = CharSet.Ansi)]
        public static extern int BeginReadASYN();

        //**************************************************************
        /// <summary>
        /// 停止异步读数据
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "CancelReadASYN", CharSet = CharSet.Ansi)]
        public static extern int CancelReadASYN();

        /// <summary>
        /// 读取条码数据异步
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "ReadDataASYN", CharSet = CharSet.Ansi)]
        public static extern int ReadDataASYN(ref byte szData);
        //**************************************************************

        /// <summary>
        /// 获取中文错误信息
        /// </summary>
        [DllImport("GeitBarCodeReader.dll", EntryPoint = "GetErrInfo", CharSet = CharSet.Ansi)]
        public static extern int GetErrInfo(ref string szErrorInfo);

    }
}
