轮胎外观检测添加思谋语义分割模型检测工具
C3204
2026-04-01 4d6c9ad3c9714d5f8520c6f52c3ed6ecb75b76b8
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
using LB_VisionProcesses.BarcodeReaders;
using LB_VisionProcesses.BarcodeReaders.Huayray;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace LB_SmartVision.Forms.Pages.BarcodeReaderPage
{
    public partial class CreateBarcodeReaderForm : Form
    {
        public BarcodeReaderBase barcodeReader { get; set; }
        public bool bCreate = false;
 
        public CreateBarcodeReaderForm(BarcodeReaderBase reader = null)
        {
            InitializeComponent();
            // 禁止修改窗口大小
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            if (reader == null)
                this.barcodeReader = new HRBarcodeReader();
            else
                this.barcodeReader = reader;
 
            uiButtonCreate.Enabled = false;
        }
 
        private void uiButtonTest_Click(object sender, EventArgs e)
        {
            uiButtonCreate.Enabled = false;
 
            if (string.IsNullOrEmpty(uiComboBoxSN.Text))
                MessageBox.Show($"初始化读码器[{uiComboBoxSN.Text}]为空!", "异常");
 
            if (barcodeReader == null)
            {
                MessageBox.Show("请先选择读码器品牌!", "异常");
                return;
            }
 
            barcodeReader.Close();
            if (barcodeReader.Open(uiComboBoxSN.Text))
            {
                uiButtonCreate.Enabled = true;
                barcodeReader.Close();
            }
            else
                MessageBox.Show($"初始化读码器[{uiComboBoxSN.Text}]失败!", "异常");
        }
 
        private void uiButtonCreate_Click(object sender, EventArgs e)
        {
            if (barcodeReader.Open(uiComboBoxSN.Text))
            {
                barcodeReader.SN = uiComboBoxSN.Text;
                bCreate = true;
                this.Close();
            }
            else
                MessageBox.Show($"初始化读码器[{uiComboBoxSN.Text}]失败!", "异常");
        }
 
        private void uiButtonCancel_Click(object sender, EventArgs e)
        {
            if (barcodeReader != null)
                barcodeReader.Close();
            bCreate = false;
            this.Close();
        }
 
        private void uiComboBoxBrand_MouseClick(object sender, MouseEventArgs e)
        {
            uiComboBoxBrand.Items.Clear();
            foreach (BarcodeReaderBrand brand in Enum.GetValues(typeof(BarcodeReaderBrand)))
            {
                if (brand != BarcodeReaderBrand.Unsupported)
                    uiComboBoxBrand.Items.Add(brand.ToString());
            }
        }
 
        private void uiComboBoxBrand_SelectedIndexChanged(object sender, EventArgs e)
        {
            uiButtonCreate.Enabled = false;
            uiComboBoxSN.Text = string.Empty;
 
            if (barcodeReader != null)
                barcodeReader.Close();
 
            Enum.TryParse<BarcodeReaderBrand>(uiComboBoxBrand.Text, out BarcodeReaderBrand brand);
            switch (brand)
            {
                case BarcodeReaderBrand.Huayray:
                    barcodeReader = new HRBarcodeReader();
                    break;
                default:
                    return;
            }
        }
 
        private void uiComboBoxSN_MouseClick(object sender, MouseEventArgs e)
        {
            uiButtonCreate.Enabled = false;
            uiComboBoxSN.Text = string.Empty;
 
            uiComboBoxSN.Items.Clear();
            var list = barcodeReader.GetDeviceList();
 
            foreach (string sn in list)
                uiComboBoxSN.Items.Add(sn);
        }
    }
}