From 19bf97fd8ec4f435e9111d72969c4ebf00d97991 Mon Sep 17 00:00:00 2001
From: C3032 <1057644574@qq.com>
Date: 星期五, 20 三月 2026 11:10:02 +0800
Subject: [PATCH] 读码器功能集成完成

---
 LB_VisionProcesses/BarcodeReaders/Huayray/HRBarcodeReader.cs |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/LB_VisionProcesses/BarcodeReaders/Huayray/HRBarcodeReader.cs b/LB_VisionProcesses/BarcodeReaders/Huayray/HRBarcodeReader.cs
index aa9be07..538de93 100644
--- a/LB_VisionProcesses/BarcodeReaders/Huayray/HRBarcodeReader.cs
+++ b/LB_VisionProcesses/BarcodeReaders/Huayray/HRBarcodeReader.cs
@@ -73,6 +73,7 @@
 
                 // 鍒涘缓鍙ユ焺
                 int nRet = _camera.eidCreateDevice_Net(sn, EidCamera.EidDeviceDataType.eidDeviceDataTypeSN);
+                if (nRet != EidCamera.eidErrorOK) return false;
                 if (nRet != EidCamera.eidErrorOK)
                 {
                     _camera = null;
@@ -124,11 +125,15 @@
 
         public override bool Close()
         {
+            if (!IsConnected) return true;
+
             try
             {
                 if (IsConnected)
                 {
                     StopGrabbing();
+                _camera.eidCloseDevice_Net();
+                _camera.eidReleaseHandle_Net();
                     _camera?.eidCloseDevice_Net();
                 }
                 // 鏃犺鏄惁杩炴帴锛岄兘灏濊瘯閲婃斁鍙ユ焺
@@ -144,6 +149,7 @@
                 _camera = null;
 
                 this.IsConnected = false;
+                this.SN = string.Empty;
                 this.IsGrabbing = false;
                 return true;
             }
@@ -210,6 +216,7 @@
         {
             try
             {
+                List<string> barcodes = new List<string>();
                 List<BarcodeInfo> barcodeInfos = new List<BarcodeInfo>();
                 // 瑙f瀽鏉$爜
                 for (int i = 0; i < frameInfo.codeNum; i++)
@@ -221,6 +228,7 @@
                     string data = Marshal.PtrToStringAnsi(codeInfo.data);
                     if (!string.IsNullOrEmpty(data))
                     {
+                        barcodes.Add(data);
                         BarcodeInfo info = new BarcodeInfo
                         {
                             Text = data,
@@ -236,10 +244,13 @@
                     }
                 }
 
+                // 杞崲鍥惧儚 (濡傛灉闇�瑕�)
                 // 杞崲鍥惧儚
                 Bitmap bitmap = null;
                 if (frameInfo.imageDataLen > 0 && frameInfo.imageData != IntPtr.Zero)
                 {
+                    // 杩欓噷绠�鍖栧鐞嗭紝濡傛灉鏄疛peg鍒欑洿鎺ヤ粠鍐呭瓨鍔犺浇锛屽鏋滄槸Raw鍒欓渶杞崲
+                    // 瀹為檯椤圭洰涓彲鏍规嵁 frameInfo.format 杩涜澶勭悊
                     if (frameInfo.isJpeg)
                     {
                         byte[] managedArray = new byte[frameInfo.imageDataLen];
@@ -252,6 +263,7 @@
                 }
 
                 // 瑙﹀彂浜嬩欢
+                OnBarcodeRead(new BarcodeEventArgs(this.SN, barcodes, bitmap));
                 OnBarcodeRead(new BarcodeEventArgs(this.SN, barcodeInfos, bitmap));
             }
             catch (Exception ex)

--
Gitblit v1.9.3