C3032
2026-03-23 68a4b459eeb18effb8b3096add3d88c15629ab69
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
 
namespace LB_VisionProcesses.BarcodeReaders
{
    /// <summary>
    /// 读码器品牌枚举
    /// </summary>
    public enum BarcodeReaderBrand
    {
        Huayray,    // 华睿
        Unsupported
    }
 
    /// <summary>
    /// 条码详细信息
    /// </summary>
    public class BarcodeInfo
    {
        public string Text { get; set; }
        /// <summary>
        /// 条码的四个顶点坐标
        /// </summary>
        public Point[] Points { get; set; }
    }
 
    /// <summary>
    /// 读码结果参数类
    /// </summary>
    public class BarcodeEventArgs : EventArgs
    {
        /// <summary>
        /// 设备序列号
        /// </summary>
        public string SN { get; set; }
 
        /// <summary>
        /// 条码详细信息列表
        /// </summary>
        public List<BarcodeInfo> BarcodeInfos { get; set; } = new List<BarcodeInfo>();
 
        /// <summary>
        /// 仅获取条码文本列表 (保持兼容性)
        /// </summary>
        public List<string> Barcodes => BarcodeInfos.Select(x => x.Text).ToList();
 
        /// <summary>
        /// 关联图像 (可选)
        /// </summary>
        public Bitmap Image { get; set; }
 
        /// <summary>
        /// 是否读取成功
        /// </summary>
        public bool IsSuccess => BarcodeInfos.Count > 0;
 
        public BarcodeEventArgs(string sn, List<BarcodeInfo> barcodeInfos, Bitmap image = null)
        {
            SN = sn;
            BarcodeInfos = barcodeInfos;
            Image = image;
        }
    }
 
    /// <summary>
    /// 读码器抽象接口
    /// </summary>
    public interface IBarcodeReader : IDisposable
    {
        /// <summary>
        /// 读码结果回调事件
        /// </summary>
        event EventHandler<BarcodeEventArgs> BarcodeRead;
 
        /// <summary>
        /// 获取设备列表枚举
        /// </summary>
        /// <returns>SN列表</returns>
        List<string> GetDeviceList();
 
        /// <summary>
        /// 初始化并打开读码器
        /// </summary>
        /// <param name="sn">序列号</param>
        /// <returns>是否成功</returns>
        bool Open(string sn);
 
        /// <summary>
        /// 关闭读码器
        /// </summary>
        /// <returns>是否成功</returns>
        bool Close();
 
        /// <summary>
        /// 开始采集/监听
        /// </summary>
        /// <returns>是否成功</returns>
        bool StartGrabbing();
 
        /// <summary>
        /// 停止采集/监听
        /// </summary>
        /// <returns>是否成功</returns>
        bool StopGrabbing();
 
        /// <summary>
        /// 执行软触发一次
        /// </summary>
        /// <returns>是否成功</returns>
        bool SoftTrigger();
 
        /// <summary>
        /// 设置触发模式
        /// </summary>
        /// <param name="isSoftware">true为软触发, false为硬触发或自动监听</param>
        /// <returns>是否成功</returns>
        bool SetTriggerMode(bool isSoftware);
 
        /// <summary>
        /// 设备是否在线
        /// </summary>
        bool IsConnected { get; }
 
        /// <summary>
        /// 设备是否正在采集
        /// </summary>
        bool IsGrabbing { get; }
 
        /// <summary>
        /// 设备品牌
        /// </summary>
        BarcodeReaderBrand Brand { get; }
    }
}