From c48b29f9997cd8985ab898c1979b8194e4119c76 Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期二, 13 一月 2026 08:49:16 +0800
Subject: [PATCH] 在UserManagementEditPage.cs界面为修改按钮添加了指令,实现用户信息的修改 在HistoricalDataEditPage.cs界面为导出按钮添加了指令,还未完成

---
 LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.cs          |  166 +++++++++++++++
 LB_SmartVision/VisionForm.cs                                                     |   48 ++++
 LB_VisionProcesses/Cameras/BaseCamera.cs                                         |    5 
 LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs                                 |  257 +++++++++++++++++++++----
 LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.cs          |   42 ++++
 LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.Designer.cs |    1 
 LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.Designer.cs |   81 ++++----
 7 files changed, 505 insertions(+), 95 deletions(-)

diff --git a/LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.Designer.cs b/LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.Designer.cs
index dffa1cc..4796997 100644
--- a/LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.Designer.cs
+++ b/LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.Designer.cs
@@ -46,8 +46,8 @@
             labelStartTime = new Label();
             dataGridViewHD = new DataGridView();
             tableLayoutPanel4 = new TableLayoutPanel();
-            hopeButton1 = new ReaLTaiizor.Controls.HopeButton();
-            hopeButton2 = new ReaLTaiizor.Controls.HopeButton();
+            btnHisDataFind = new ReaLTaiizor.Controls.HopeButton();
+            btnHisDataExport = new ReaLTaiizor.Controls.HopeButton();
             grpHisData.SuspendLayout();
             tableLayoutPanel1.SuspendLayout();
             tableLayoutPanel2.SuspendLayout();
@@ -285,8 +285,8 @@
             tableLayoutPanel4.ColumnCount = 2;
             tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
             tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
-            tableLayoutPanel4.Controls.Add(hopeButton1, 0, 0);
-            tableLayoutPanel4.Controls.Add(hopeButton2, 1, 0);
+            tableLayoutPanel4.Controls.Add(btnHisDataFind, 0, 0);
+            tableLayoutPanel4.Controls.Add(btnHisDataExport, 1, 0);
             tableLayoutPanel4.Location = new Point(657, 509);
             tableLayoutPanel4.Name = "tableLayoutPanel4";
             tableLayoutPanel4.RowCount = 1;
@@ -294,43 +294,44 @@
             tableLayoutPanel4.Size = new Size(200, 39);
             tableLayoutPanel4.TabIndex = 1;
             // 
-            // hopeButton1
+            // btnHisDataFind
             // 
-            hopeButton1.BorderColor = Color.FromArgb(220, 223, 230);
-            hopeButton1.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary;
-            hopeButton1.DangerColor = Color.FromArgb(245, 108, 108);
-            hopeButton1.DefaultColor = Color.FromArgb(255, 255, 255);
-            hopeButton1.Font = new Font("Segoe UI", 12F);
-            hopeButton1.HoverTextColor = Color.FromArgb(48, 49, 51);
-            hopeButton1.InfoColor = Color.FromArgb(144, 147, 153);
-            hopeButton1.Location = new Point(3, 3);
-            hopeButton1.Name = "hopeButton1";
-            hopeButton1.PrimaryColor = Color.FromArgb(64, 158, 255);
-            hopeButton1.Size = new Size(94, 33);
-            hopeButton1.SuccessColor = Color.FromArgb(103, 194, 58);
-            hopeButton1.TabIndex = 0;
-            hopeButton1.Text = "鏌ヨ";
-            hopeButton1.TextColor = Color.White;
-            hopeButton1.WarningColor = Color.FromArgb(230, 162, 60);
+            btnHisDataFind.BorderColor = Color.FromArgb(220, 223, 230);
+            btnHisDataFind.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary;
+            btnHisDataFind.DangerColor = Color.FromArgb(245, 108, 108);
+            btnHisDataFind.DefaultColor = Color.FromArgb(255, 255, 255);
+            btnHisDataFind.Font = new Font("Segoe UI", 12F);
+            btnHisDataFind.HoverTextColor = Color.FromArgb(48, 49, 51);
+            btnHisDataFind.InfoColor = Color.FromArgb(144, 147, 153);
+            btnHisDataFind.Location = new Point(3, 3);
+            btnHisDataFind.Name = "btnHisDataFind";
+            btnHisDataFind.PrimaryColor = Color.FromArgb(64, 158, 255);
+            btnHisDataFind.Size = new Size(94, 33);
+            btnHisDataFind.SuccessColor = Color.FromArgb(103, 194, 58);
+            btnHisDataFind.TabIndex = 0;
+            btnHisDataFind.Text = "鏌ヨ";
+            btnHisDataFind.TextColor = Color.White;
+            btnHisDataFind.WarningColor = Color.FromArgb(230, 162, 60);
             // 
-            // hopeButton2
+            // btnHisDataExport
             // 
-            hopeButton2.BorderColor = Color.FromArgb(220, 223, 230);
-            hopeButton2.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary;
-            hopeButton2.DangerColor = Color.FromArgb(245, 108, 108);
-            hopeButton2.DefaultColor = Color.FromArgb(255, 255, 255);
-            hopeButton2.Font = new Font("Segoe UI", 12F);
-            hopeButton2.HoverTextColor = Color.FromArgb(48, 49, 51);
-            hopeButton2.InfoColor = Color.FromArgb(144, 147, 153);
-            hopeButton2.Location = new Point(103, 3);
-            hopeButton2.Name = "hopeButton2";
-            hopeButton2.PrimaryColor = Color.FromArgb(64, 158, 255);
-            hopeButton2.Size = new Size(94, 33);
-            hopeButton2.SuccessColor = Color.FromArgb(103, 194, 58);
-            hopeButton2.TabIndex = 1;
-            hopeButton2.Text = "瀵煎嚭";
-            hopeButton2.TextColor = Color.White;
-            hopeButton2.WarningColor = Color.FromArgb(230, 162, 60);
+            btnHisDataExport.BorderColor = Color.FromArgb(220, 223, 230);
+            btnHisDataExport.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary;
+            btnHisDataExport.DangerColor = Color.FromArgb(245, 108, 108);
+            btnHisDataExport.DefaultColor = Color.FromArgb(255, 255, 255);
+            btnHisDataExport.Font = new Font("Segoe UI", 12F);
+            btnHisDataExport.HoverTextColor = Color.FromArgb(48, 49, 51);
+            btnHisDataExport.InfoColor = Color.FromArgb(144, 147, 153);
+            btnHisDataExport.Location = new Point(103, 3);
+            btnHisDataExport.Name = "btnHisDataExport";
+            btnHisDataExport.PrimaryColor = Color.FromArgb(64, 158, 255);
+            btnHisDataExport.Size = new Size(94, 33);
+            btnHisDataExport.SuccessColor = Color.FromArgb(103, 194, 58);
+            btnHisDataExport.TabIndex = 1;
+            btnHisDataExport.Text = "瀵煎嚭";
+            btnHisDataExport.TextColor = Color.White;
+            btnHisDataExport.WarningColor = Color.FromArgb(230, 162, 60);
+            btnHisDataExport.Click += btnHisDataExport_Click;
             // 
             // HistoricalDataEditPage
             // 
@@ -363,8 +364,8 @@
         private TableLayoutPanel tableLayoutPanel3;
         private DataGridView dataGridViewHD;
         private TableLayoutPanel tableLayoutPanel4;
-        private ReaLTaiizor.Controls.HopeButton hopeButton1;
-        private ReaLTaiizor.Controls.HopeButton hopeButton2;
+        private ReaLTaiizor.Controls.HopeButton btnHisDataFind;
+        private ReaLTaiizor.Controls.HopeButton btnHisDataExport;
         private TableLayoutPanel tableLayoutPanel5;
         private Label labelSearchBasis;
         private TableLayoutPanel tableLayoutPanelSN;
diff --git a/LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.cs b/LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.cs
index 1619fa2..28694cc 100644
--- a/LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.cs
+++ b/LB_SmartVision/Forms/Pages/HistoricalDataPage/HistoricalDataEditPage.cs
@@ -57,7 +57,7 @@
             }
 
             // 璁剧疆鍒楁爣棰�
-            dataGridViewHD.Columns[0].Name = "SN鍙�"; 
+            dataGridViewHD.Columns[0].Name = "SN鍙�";
             dataGridViewHD.Columns[1].Name = "鏃堕棿";
             dataGridViewHD.Columns[2].Name = "NG绫�";
             dataGridViewHD.Columns[3].Name = "缂洪櫡澶у皬";
@@ -151,5 +151,45 @@
         {
             dateTimePickerEnd.MinDate = dateTimePickerStart.Value;
         }
+
+        private void btnHisDataExport_Click(object sender, EventArgs e)
+        {
+
+        }
+
+        public void SaveToCSV(string filePath, int rowIndex)
+        {
+            // 浣跨敤 StreamWriter 鏉ュ啓鍏ユ枃浠�
+            using (StreamWriter writer = new StreamWriter(filePath))
+            {
+                DataGridViewRow row = dataGridViewHD.Rows[rowIndex];
+
+                int rowCount = 10;//10鏀逛负閲囬泦娆℃暟
+
+                writer.WriteLine("SN鍙�, 鏃堕棿, NG绫�, 缂洪櫡澶у皬");
+
+                // 閬嶅巻姣忎竴琛屾暟鎹�
+                for (int i = 0; i < rowCount; i++)
+                {
+                    int batchSize = 4;
+
+                    // 鍐欏叆杩欎竴鎵规鐨勬瘡涓�鍒楁暟鎹�
+                    for (int k = 0; k < batchSize; k++)
+                    {
+                        writer.Write($"{row.Cells[k].Value}");
+
+                        // 鍦ㄥ厓绱犱箣闂存坊鍔犻�楀彿锛岄櫎闈炶繖鏄渶鍚庝竴涓厓绱�
+                        if (k < batchSize - 1)
+                        {
+                            writer.Write(",");
+                        }
+                    }
+
+                    // 鍐欏叆瀹屼竴琛屽悗锛屾崲琛�
+                    writer.WriteLine();
+                    
+                }
+            }
+        }
     }
 }
diff --git a/LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.Designer.cs b/LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.Designer.cs
index 6996dcc..a1dcd6f 100644
--- a/LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.Designer.cs
+++ b/LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.Designer.cs
@@ -283,6 +283,7 @@
             btnEdit.Text = "淇敼";
             btnEdit.TextColor = Color.White;
             btnEdit.WarningColor = Color.FromArgb(230, 162, 60);
+            btnEdit.Click += btnEdit_Click;
             // 
             // btnFind
             // 
diff --git a/LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.cs b/LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.cs
index 10d745d..f017dce 100644
--- a/LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.cs
+++ b/LB_SmartVision/Forms/Pages/UserManagementPage/UserManagementEditPage.cs
@@ -31,10 +31,13 @@
             InitializeComboBox();
         }
 
+        /// <summary>
+        /// 琛ㄦ牸鍒濆鍖�
+        /// </summary>
         private void InitializeDataGridView()
         {
             // 璁剧疆DataGridView鍒楀
-            dataGridViewUM.ColumnCount = 5;
+            dataGridViewUM.ColumnCount = 4;
 
             int totalWidth = dataGridViewUM.ClientSize.Width;
             int columnCount = dataGridViewUM.ColumnCount;
@@ -54,10 +57,10 @@
 
             // 璁剧疆鍒楁爣棰�
             dataGridViewUM.Columns[0].Name = "鐢ㄦ埛鍚�";
-            dataGridViewUM.Columns[1].Name = "瀵嗙爜";
-            dataGridViewUM.Columns[2].Name = "濮撳悕";
-            dataGridViewUM.Columns[3].Name = "宸ュ彿";
-            dataGridViewUM.Columns[4].Name = "鏉冮檺";
+            //dataGridViewUM.Columns[1].Name = "瀵嗙爜";
+            dataGridViewUM.Columns[1].Name = "濮撳悕";
+            dataGridViewUM.Columns[2].Name = "宸ュ彿";
+            dataGridViewUM.Columns[3].Name = "鏉冮檺";
 
             dataGridViewUM.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
 
@@ -71,6 +74,9 @@
             dataGridViewUM.RowHeadersVisible = true;
         }
 
+        /// <summary>
+        /// 鏉冮檺涓嬫媺妗嗗垵濮嬪寲
+        /// </summary>
         private void InitializeComboBox()
         {
             // 娣诲姞鏉冮檺閫夐」
@@ -90,7 +96,7 @@
             textBoxPassword.Clear();
             textBoxName.Clear();
             textBoxEmployeeID.Clear();
-            comboBoxPermission.SelectedIndex = 1;
+            comboBoxPermission.SelectedIndex = 0;
             textBoxUsername.Focus(); // 灏嗙劍鐐硅缃洖鐢ㄦ埛鍚嶈緭鍏ユ
         }
         private void btnAdd_Click(object sender, EventArgs e)
@@ -110,7 +116,7 @@
             string[] row = new string[]
             {
                 textBoxUsername.Text,
-                textBoxPassword.Text, // 瀹為檯搴旂敤涓瘑鐮佸簲璇ュ姞瀵�
+                //textBoxPassword.Text, // 瀹為檯搴旂敤涓瘑鐮佸簲璇ュ姞瀵�
                 textBoxName.Text,
                 textBoxEmployeeID.Text,
                 comboBoxPermission.SelectedItem.ToString()
@@ -150,7 +156,153 @@
                     MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
+        private int editingRowIndex = -1;
+        private bool isEditingMode = false;
+        private string originalButtonText = "淇敼";
+        private void btnEdit_Click(object sender, EventArgs e)
+        {
+            // 鍗曞厓鏍煎彲缂栬緫
+            //dataGridViewUM.ReadOnly = false;
+            // 绗竴娆$偣鍑伙細杩涘叆淇敼妯″紡
+            if (!isEditingMode)
+            {
+                // 妫�鏌ユ槸鍚﹂�夋嫨浜嗚
+                if (dataGridViewUM.SelectedRows.Count == 0)
+                {
+                    MessageBox.Show("璇峰厛閫夋嫨瑕佷慨鏀圭殑琛岋紒", "鎻愮ず",
+                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    return;
+                }
 
+                // 鑾峰彇閫変腑鐨勮绱㈠紩
+                editingRowIndex = dataGridViewUM.SelectedRows[0].Index;
 
+                // 灏嗛�変腑琛岀殑鏁版嵁濉厖鍒癟extBox涓�
+                FillFormWithRowData(editingRowIndex);
+
+                // 鏇存敼鎸夐挳鏂囨湰
+                btnEdit.Text = "瀹屾垚";
+
+                // 杩涘叆缂栬緫妯″紡
+                isEditingMode = true;
+
+                // 绂佺敤娣诲姞鎸夐挳锛堝彲閫夛級
+                btnAdd.Enabled = false;
+
+                // 璁剧疆鐒︾偣鍒扮敤鎴峰悕杈撳叆妗�
+                textBoxUsername.Focus();
+
+                // 楂樹寒鏄剧ず姝e湪缂栬緫鐨勮锛堝彲閫夛級
+                dataGridViewUM.Rows[editingRowIndex].DefaultCellStyle.BackColor = Color.LightYellow;
+            }
+            // 绗簩娆$偣鍑伙細淇濆瓨淇敼
+            else
+            {
+                // 楠岃瘉杈撳叆
+                if (string.IsNullOrWhiteSpace(textBoxUsername.Text) ||
+                    string.IsNullOrWhiteSpace(textBoxName.Text) ||
+                    string.IsNullOrWhiteSpace(textBoxEmployeeID.Text))
+                {
+                    MessageBox.Show("璇峰~鍐欐墍鏈夊繀濉瓧娈碉紒", "鎻愮ず",
+                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    return;
+                }
+
+                // 鏇存柊DataGridView涓殑琛屾暟鎹�
+                UpdateRowData(editingRowIndex);
+
+                // 鎭㈠鎸夐挳鏂囨湰
+                btnEdit.Text = originalButtonText;
+
+                // 閫�鍑虹紪杈戞ā寮�
+                isEditingMode = false;
+                editingRowIndex = -1;
+
+                // 鍚敤娣诲姞鎸夐挳锛堝彲閫夛級
+                btnAdd.Enabled = true;
+
+                // 鎭㈠琛岄鑹诧紙鍙�夛級
+                dataGridViewUM.DefaultCellStyle.BackColor = Color.White;
+
+                // 娓呯┖杈撳叆妗�
+                ClearInputFields();
+
+                MessageBox.Show("淇敼瀹屾垚锛�", "鎻愮ず",
+                    MessageBoxButtons.OK, MessageBoxIcon.Information);
+            }
+        }
+
+        private void FillFormWithRowData(int rowIndex)
+        {
+            if (rowIndex >= 0 && rowIndex < dataGridViewUM.Rows.Count)
+            {
+                DataGridViewRow row = dataGridViewUM.Rows[rowIndex];
+
+                // 濉厖鐢ㄦ埛鍚�
+                if (row.Cells[0].Value != null)
+                    textBoxUsername.Text = row.Cells[0].Value.ToString();
+                else
+                    textBoxUsername.Text = "";
+
+                // 濉厖濮撳悕
+                if (row.Cells[1].Value != null)
+                    textBoxName.Text = row.Cells[1].Value.ToString();
+                else
+                    textBoxName.Text = "";
+
+                // 濉厖宸ュ彿
+                if (row.Cells[2].Value != null)
+                    textBoxEmployeeID.Text = row.Cells[2].Value.ToString();
+                else
+                    textBoxEmployeeID.Text = "";
+
+                // 濉厖鏉冮檺
+                if (row.Cells[3].Value != null)
+                {
+                    string permission = row.Cells[3].Value.ToString();
+                    int index = comboBoxPermission.FindString(permission);
+                    if (index >= 0)
+                        comboBoxPermission.SelectedIndex = index;
+                    else
+                        comboBoxPermission.SelectedIndex = 0;
+                }
+                else
+                {
+                    comboBoxPermission.SelectedIndex = 0;
+                }
+
+                // 瀵嗙爜妗嗘竻绌猴紙閫氬父涓嶄細鏄剧ず瀵嗙爜锛�
+                textBoxPassword.Clear();
+                // 濡傛灉闇�瑕佷慨鏀瑰瘑鐮侊紝鍙互娣诲姞娉ㄩ噴鎴栧崰浣嶇
+                //textBoxPassword.PlaceholderText = "濡傞渶淇敼瀵嗙爜璇峰~鍐�";
+            }
+        }
+
+        private void UpdateRowData(int rowIndex)
+        {
+            if (rowIndex >= 0 && rowIndex < dataGridViewUM.Rows.Count)
+            {
+                DataGridViewRow row = dataGridViewUM.Rows[rowIndex];
+
+                // 鏇存柊鐢ㄦ埛鍚�
+                row.Cells[0].Value = textBoxUsername.Text;
+
+                // 濡傛灉瀵嗙爜涓嶄负绌猴紝鍒欐洿鏂板瘑鐮侊紙瀹為檯搴旂敤涓簲鍔犲瘑锛�
+                if (!string.IsNullOrWhiteSpace(textBoxPassword.Text))
+                {
+                    // 杩欓噷鍙互娣诲姞瀵嗙爜鍔犲瘑閫昏緫
+                    // row.Cells[1].Value = EncryptPassword(textBoxPassword.Text);
+                }
+
+                // 鏇存柊濮撳悕
+                row.Cells[1].Value = textBoxName.Text;
+
+                // 鏇存柊宸ュ彿
+                row.Cells[2].Value = textBoxEmployeeID.Text;
+
+                // 鏇存柊鏉冮檺
+                row.Cells[3].Value = comboBoxPermission.SelectedItem.ToString();
+            }
+        }
     }
 }
diff --git a/LB_SmartVision/VisionForm.cs b/LB_SmartVision/VisionForm.cs
index 0655293..a8fdfcf 100644
--- a/LB_SmartVision/VisionForm.cs
+++ b/LB_SmartVision/VisionForm.cs
@@ -66,6 +66,7 @@
             Assembly_LB_VisionProcessesDll = Assembly.Load(Assembly_LB_VisionProcessesBytes);
 
             GlobalVar.dicCommunicators.DictionaryChanged += CommunicatorsChanged;
+            GlobalVar.dicCameras.DictionaryChanged += CamerasChanged;
             GlobalVar.dicProcesses.DictionaryChanged += ProcessRunBllChanged;
 
             //鏈�寮�濮嬪氨娓呯┖鎵�鏈塗ab椤�
@@ -239,7 +240,30 @@
 
         private void CommunicatorsChanged(object? sender, DictionaryChangedEventArgs<string, BaseCommunicator> e)
         {
-
+            try
+            {
+                switch (e.ChangeType)
+                {
+                    case DictionaryChangeType.Added:
+                        e.NewValue.TriggerRunMessageReceived += TriggerRunMessageReceived;
+                        LogInfo($"閫氳鍙{e.NewValue.CommunicatorName}]鍔犺浇瑙﹀彂閫氳", LogInfoType.INFO);
+                        e.NewValue.CommunicatorName = e.NewKey;
+                        break;
+                    case DictionaryChangeType.Renamed:
+                        string OldCommunicatorName = e.OldKey;
+                        string NewCommunicatorName = e.NewKey;
+                        LogInfo(string.Format("閲嶅懡鍚嶉�氳鍙e悕[{0}]淇敼涓篬{1}]", OldCommunicatorName, NewCommunicatorName), LogInfoType.INFO);
+                        e.NewValue.CommunicatorName = NewCommunicatorName;
+                        break;
+                    case DictionaryChangeType.Removed:
+                        if (e.OldValue != null && e.OldValue is BaseCommunicator)
+                            e.OldValue.Disconnect();
+                        e.OldValue.TriggerRunMessageReceived -= TriggerRunMessageReceived;
+                        LogInfo($"閫氳鍙{e.OldValue.CommunicatorName}]绉婚櫎瑙﹀彂閫氳", LogInfoType.INFO);
+                        break;
+                }
+            }
+            catch { }
         }
 
         private void LogInfo(string strLog, LogInfoType infoType)
@@ -526,6 +550,28 @@
             }
         }
 
+        private void CamerasChanged(object sender, DictionaryChangedEventArgs<string, BaseCamera> e)
+        {
+            try
+            {
+                switch (e.ChangeType)
+                {
+                    case DictionaryChangeType.Added:
+                        e.NewValue.TriggerRunMessageReceived += TriggerRunMessageReceived;
+                        LogInfo($"鐩告満[{e.NewValue.SN}]鍔犺浇瑙﹀彂閫氳", LogInfoType.INFO);
+                        e.NewValue.SN = e.NewKey;
+                        break;
+                    case DictionaryChangeType.Removed:
+                        if (e.OldValue != null && e.OldValue is BaseCommunicator)
+                            e.OldValue.CloseDevice();
+                        e.OldValue.TriggerRunMessageReceived -= TriggerRunMessageReceived;
+                        LogInfo($"鐩告満[{e.OldValue.SN}]绉婚櫎瑙﹀彂閫氳", LogInfoType.INFO);
+                        break;
+                }
+            }
+            catch { }
+        }
+
         private void VisionForm_Load(object sender, EventArgs e)
         {
             XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
diff --git a/LB_VisionProcesses/Cameras/BaseCamera.cs b/LB_VisionProcesses/Cameras/BaseCamera.cs
index a5b371a..7be4f11 100644
--- a/LB_VisionProcesses/Cameras/BaseCamera.cs
+++ b/LB_VisionProcesses/Cameras/BaseCamera.cs
@@ -23,6 +23,11 @@
         /// 鐩告満鍚嶇О
         /// </summary>
         public string CameraName { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 鐩告満纭Е鍙戣幏鍙栧浘鍍忚Е鍙戝搴旂殑妫�娴嬫祦绋�
+        /// </summary>
+        public Action<string, string> TriggerRunMessageReceived;
         public CameraBrand Brand { get; set; } = CameraBrand.UNSUPPORTED;
 
         public bool isGrabbing = false;
diff --git a/LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs b/LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs
index 685b06d..2d4067b 100644
--- a/LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs
+++ b/LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs
@@ -1,4 +1,6 @@
-锘縰sing MVSDK_Net;
+锘縰sing HalconDotNet;
+using LB_SmartVisionCommon;
+using MVSDK_Net;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -26,6 +28,16 @@
         private Thread _callbackThread; // 鍥炶皟澶勭悊绾跨▼
         private List<IMVDefine.IMV_Frame> _frameList; // 鍥惧儚缂撳瓨鍒楄〃
         private readonly object _frameLock = new object(); // 甯х紦瀛橀攣
+        private IMVDefine.IMV_EPixelType type = IMVDefine.IMV_EPixelType.gvspPixelMono8;
+        private IMVDefine.IMV_PixelConvertParam stPixelConvertParam = new IMVDefine.IMV_PixelConvertParam();
+
+        HObject Hobj = new HObject();
+        IntPtr pTemp = IntPtr.Zero;
+        IntPtr pConvertDstBuffer = IntPtr.Zero;
+        int nConvertBufSize = 0;
+
+
+        private IMVDefine.IMV_FrameCallBack frameCallBack;
 
         // CopyMemory API澹版槑
         [System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "RtlMoveMemory")]
@@ -92,13 +104,15 @@
                 {
                     // 璁板綍鏃ュ織鎴栨姏鍑哄紓甯�
                     //throw new Exception($"鏋氫妇璁惧澶辫触锛岄敊璇爜锛歿result}");
-                    Debug.WriteLine("鏋氫妇璁惧澶辫触锛�");
+                    AsyncLogHelper.Error("鏋氫妇璁惧澶辫触锛�");
+                    System.Diagnostics.Debug.WriteLine("鏋氫妇璁惧澶辫触锛�");
                 }
             }
             catch (Exception ex)
             {
                 // 璁板綍閿欒鏃ュ織
                 System.Diagnostics.Debug.WriteLine($"鑾峰彇鐩告満鍒楄〃澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error($"鑾峰彇鐩告満鍒楄〃澶辫触锛歿ex.Message}");
                 throw;
             }
 
@@ -145,6 +159,7 @@
 
                 if (cameraIndex == -1)
                 {
+                    AsyncLogHelper.Error($"鏈壘鍒板簭鍒楀彿涓� {SN} 鐨勭浉鏈�");
                     throw new Exception($"鏈壘鍒板簭鍒楀彿涓� {SN} 鐨勭浉鏈�");
                 }
 
@@ -152,6 +167,7 @@
                 int result = _camera.IMV_CreateHandle(IMVDefine.IMV_ECreateHandleMode.modeByIndex, cameraIndex);
                 if (result != IMVDefine.IMV_OK)
                 {
+                    AsyncLogHelper.Error($"鍒涘缓璁惧鍙ユ焺澶辫触锛岄敊璇爜锛歿result}");
                     throw new Exception($"鍒涘缓璁惧鍙ユ焺澶辫触锛岄敊璇爜锛歿result}");
                 }
                 _handleCreated = true;
@@ -160,6 +176,7 @@
                 result = _camera.IMV_Open();
                 if (result != IMVDefine.IMV_OK)
                 {
+                    AsyncLogHelper.Error($"鎵撳紑鐩告満澶辫触锛岄敊璇爜锛歿result}");
                     throw new Exception($"鎵撳紑鐩告満澶辫触锛岄敊璇爜锛歿result}");
                 }
 
@@ -167,17 +184,121 @@
                 this.SN = SN;
                 isGrabbing = false;
 
-                // 璁剧疆缂撳瓨涓暟涓�8
-                _camera.IMV_SetBufferCount(8);
+                // 娉ㄥ唽鏁版嵁甯у洖璋冨嚱鏁�
+                // Register data frame callback function
+                frameCallBack = onGetFrame;
+                int res = _camera.IMV_AttachGrabbing(frameCallBack, IntPtr.Zero);
+                if (res != IMVDefine.IMV_OK)
+                {
+                    System.Diagnostics.Debug.WriteLine("Attach grabbing failed! ErrorCode:[{0}]", res);
+                    AsyncLogHelper.Error("Attach grabbing failed! ErrorCode:[{0}]" + res);
+                }
+                // 璁剧疆缂撳瓨涓暟涓�12
+                _camera.IMV_SetBufferCount(12);
 
                 return true;
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine($"鍒濆鍖栫浉鏈哄け璐ワ細{ex.Message}");
+                AsyncLogHelper.Error($"鍒濆鍖栫浉鏈哄け璐ワ細{ex.Message}");
                 return false;
             }
         }
+
+        // 鏁版嵁甯у洖璋冨嚱鏁�
+        // Data frame callback function
+        private void onGetFrame(ref IMVDefine.IMV_Frame frame, IntPtr pUser)
+        {
+            if (frame.frameHandle == IntPtr.Zero)
+            {
+                AsyncLogHelper.Info(SN + "frame is NULL");
+                return;
+            }
+            try
+            {
+                Bitmap bitmap = ConvertFrameToBitmap(frame);
+
+                // 閲婃斁甯ф暟鎹�
+                // release frame
+                _camera.IMV_ReleaseFrame(ref frame);
+                CallBackImg = (Bitmap)bitmap.Clone();
+                if (CallBackImg == null)
+                {
+                    return;
+                }
+                if (GetTriggerMode(out TriggerMode mode, out TriggerSource source))
+                {
+                    if (mode == TriggerMode.On && source != TriggerSource.Software)
+                        TriggerRunMessageReceived?.Invoke(SN, source.ToString());  // 瑙﹀彂杩愯浜嬩欢
+                }
+                bitmap.Dispose();
+            }
+            catch { }
+            AsyncLogHelper.Info(SN + "Get frame blockId = {0}" + frame.frameInfo.blockId);
+        }
+
+        /// <summary>
+        /// 鍥惧儚鏄惁涓篗ono鏍煎紡
+        /// </summary>
+        /// <param name="enType"></param>
+        /// <returns></returns>
+        private bool IsMonoPixelFormat(IMVDefine.IMV_EPixelType enType)
+        {
+            switch (enType)
+            {
+                case IMVDefine.IMV_EPixelType.gvspPixelMono8:
+                case IMVDefine.IMV_EPixelType.gvspPixelMono10:
+                case IMVDefine.IMV_EPixelType.gvspPixelMono10Packed:
+                case IMVDefine.IMV_EPixelType.gvspPixelMono12:
+                case IMVDefine.IMV_EPixelType.gvspPixelMono12Packed:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        /// <summary>
+        /// 鍥惧儚鏄惁涓哄僵鑹�
+        /// </summary>
+        /// <param name="enType"></param>
+        /// <returns></returns>
+        private bool IsColorPixelFormat(IMVDefine.IMV_EPixelType enType)
+        {
+            switch (enType)
+            {
+                case IMVDefine.IMV_EPixelType.gvspPixelRGB8:
+                case IMVDefine.IMV_EPixelType.gvspPixelBGR8:
+                case IMVDefine.IMV_EPixelType.gvspPixelRGBA8:
+                case IMVDefine.IMV_EPixelType.gvspPixelBGRA8:
+                case IMVDefine.IMV_EPixelType.gvspPixelYUV422_8:
+                case IMVDefine.IMV_EPixelType.gvspPixelYUV422_8_UYVY:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGR8:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayRG8:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGB8:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayBG8:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGB10:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGB10Packed:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayBG10:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayBG10Packed:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayRG10:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayRG10Packed:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGR10:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGR10Packed:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGB12:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGB12Packed:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayBG12:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayBG12Packed:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayRG12:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayRG12Packed:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGR12:
+                case IMVDefine.IMV_EPixelType.gvspPixelBayGR12Packed:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
 
         /// <summary>
         /// 鍏抽棴鐩告満璁惧
@@ -203,6 +324,7 @@
                     if (result != IMVDefine.IMV_OK)
                     {
                         System.Diagnostics.Debug.WriteLine($"鍏抽棴鐩告満澶辫触锛岄敊璇爜锛歿result}");
+                        AsyncLogHelper.Info(SN + $"鍏抽棴鐩告満澶辫触锛岄敊璇爜锛歿result}");
                     }
                 }
 
@@ -233,6 +355,7 @@
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine($"鍏抽棴鐩告満澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Info(SN + $"鍏抽棴鐩告満澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -251,7 +374,8 @@
             {
                 if (_camera == null || !_camera.IMV_IsOpen())
                 {
-                    throw new Exception("鐩告満鏈墦寮�");
+                    AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+                    throw new Exception(SN + "鐩告満鏈墦寮�");
                 }
 
                 // 鍋滄鐜版湁閲囬泦
@@ -264,7 +388,8 @@
                 int result = _camera.IMV_StartGrabbing();
                 if (result != IMVDefine.IMV_OK)
                 {
-                    throw new Exception($"鍚姩閲囬泦澶辫触锛岄敊璇爜锛歿result}");
+                    AsyncLogHelper.Error(SN + $"鍚姩閲囬泦澶辫触锛岄敊璇爜锛歿result}");
+                    throw new Exception(SN + $"鍚姩閲囬泦澶辫触锛岄敊璇爜锛歿result}");
                 }
 
                 _isGrabbing = true;
@@ -280,7 +405,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鍚姩閲囬泦澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鍚姩閲囬泦澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"鍚姩閲囬泦澶辫触锛歿ex.Message}");
                 _isGrabbing = false;
                 isGrabbing = false;
                 return false;
@@ -310,7 +436,8 @@
                 int result = _camera.IMV_StopGrabbing();
                 if (result != IMVDefine.IMV_OK)
                 {
-                    System.Diagnostics.Debug.WriteLine($"鍋滄閲囬泦澶辫触锛岄敊璇爜锛歿result}");
+                    System.Diagnostics.Debug.WriteLine(SN + $"鍋滄閲囬泦澶辫触锛岄敊璇爜锛歿result}");
+                    AsyncLogHelper.Info(SN + $"鍋滄閲囬泦澶辫触锛岄敊璇爜锛歿result}");
                 }
 
                 _isGrabbing = false;
@@ -331,7 +458,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鍋滄閲囬泦澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鍋滄閲囬泦澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"鍋滄閲囬泦澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -346,7 +474,8 @@
             {
                 if (_camera == null || !_camera.IMV_IsOpen())
                 {
-                    throw new Exception("鐩告満鏈墦寮�");
+                    AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+                    throw new Exception(SN + "鐩告満鏈墦寮�");
                 }
 
                 int result = _camera.IMV_ExecuteCommandFeature("TriggerSoftware");
@@ -354,7 +483,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"杞Е鍙戝け璐ワ細{ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"杞Е鍙戝け璐ワ細{ex.Message}");
+                AsyncLogHelper.Error(SN + $"杞Е鍙戝け璐ワ細{ex.Message}");
                 return false;
             }
         }
@@ -375,7 +505,8 @@
             {
                 if (_camera == null || !_camera.IMV_IsOpen())
                 {
-                    throw new Exception("鐩告満鏈墦寮�");
+                    AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+                    throw new Exception(SN + "鐩告満鏈墦寮�");
                 }
 
                 // 璁剧疆瑙﹀彂妯″紡
@@ -383,7 +514,8 @@
                 int result = _camera.IMV_SetEnumFeatureSymbol("TriggerMode", triggerMode);
                 if (result != IMVDefine.IMV_OK)
                 {
-                    throw new Exception($"璁剧疆瑙﹀彂妯″紡澶辫触锛岄敊璇爜锛歿result}");
+                    AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂妯″紡澶辫触锛岄敊璇爜锛歿result}");
+                    throw new Exception(SN + $"璁剧疆瑙﹀彂妯″紡澶辫触锛岄敊璇爜锛歿result}");
                 }
 
                 // 璁剧疆瑙﹀彂婧�
@@ -393,7 +525,8 @@
                     result = _camera.IMV_SetEnumFeatureSymbol("TriggerSource", triggerSource);
                     if (result != IMVDefine.IMV_OK)
                     {
-                        throw new Exception($"璁剧疆瑙﹀彂婧愬け璐ワ紝閿欒鐮侊細{result}");
+                        AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂婧愬け璐ワ紝閿欒鐮侊細{result}");
+                        throw new Exception(SN + $"璁剧疆瑙﹀彂婧愬け璐ワ紝閿欒鐮侊細{result}");
                     }
                 }
 
@@ -401,7 +534,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"璁剧疆瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -421,7 +555,8 @@
             {
                 if (_camera == null || !_camera.IMV_IsOpen())
                 {
-                    throw new Exception("鐩告満鏈墦寮�");
+                    AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+                    throw new Exception(SN + "鐩告満鏈墦寮�");
                 }
 
                 // 鑾峰彇瑙﹀彂妯″紡
@@ -444,7 +579,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鑾峰彇瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"鑾峰彇瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -460,7 +596,8 @@
             {
                 if (_camera == null || !_camera.IMV_IsOpen())
                 {
-                    throw new Exception("鐩告満鏈墦寮�");
+                    AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+                    throw new Exception(SN + "鐩告満鏈墦寮�");
                 }
 
                 // 楠岃瘉鏇濆厜鏃堕棿鑼冨洿
@@ -468,32 +605,37 @@
                 int result = _camera.IMV_GetDoubleFeatureMin("ExposureTime", ref minExp);
                 if (result != IMVDefine.IMV_OK)
                 {
-                    throw new Exception($"鑾峰彇鏇濆厜鏃堕棿鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
+                    AsyncLogHelper.Error(SN + $"鑾峰彇鏇濆厜鏃堕棿鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
+                    throw new Exception(SN + $"鑾峰彇鏇濆厜鏃堕棿鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
                 }
 
                 result = _camera.IMV_GetDoubleFeatureMax("ExposureTime", ref maxExp);
                 if (result != IMVDefine.IMV_OK)
                 {
-                    throw new Exception($"鑾峰彇鏇濆厜鏃堕棿鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
+                    AsyncLogHelper.Error(SN + $"鑾峰彇鏇濆厜鏃堕棿鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
+                    throw new Exception(SN + $"鑾峰彇鏇濆厜鏃堕棿鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
                 }
 
                 if (value < minExp || value > maxExp)
                 {
-                    throw new Exception($"鏇濆厜鏃堕棿瓒呭嚭鑼冨洿锛屾湁鏁堣寖鍥达細{minExp} - {maxExp}");
+                    AsyncLogHelper.Error(SN + $"鏇濆厜鏃堕棿瓒呭嚭鑼冨洿锛屾湁鏁堣寖鍥达細{minExp} - {maxExp}");
+                    throw new Exception(SN + $"鏇濆厜鏃堕棿瓒呭嚭鑼冨洿锛屾湁鏁堣寖鍥达細{minExp} - {maxExp}");
                 }
 
                 // 璁剧疆鏇濆厜鏃堕棿
                 result = _camera.IMV_SetDoubleFeatureValue("ExposureTime", value);
                 if (result != IMVDefine.IMV_OK)
                 {
-                    throw new Exception($"璁剧疆鏇濆厜鏃堕棿澶辫触锛岄敊璇爜锛歿result}");
+                    AsyncLogHelper.Error(SN + $"璁剧疆鏇濆厜鏃堕棿澶辫触锛岄敊璇爜锛歿result}");
+                    throw new Exception(SN + $"璁剧疆鏇濆厜鏃堕棿澶辫触锛岄敊璇爜锛歿result}");
                 }
 
                 return true;
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"璁剧疆鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"璁剧疆鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -511,7 +653,8 @@
             {
                 if (_camera == null || !_camera.IMV_IsOpen())
                 {
-                    throw new Exception("鐩告満鏈墦寮�");
+                    AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+                    throw new Exception(SN + "鐩告満鏈墦寮�");
                 }
 
                 int result = _camera.IMV_GetDoubleFeatureValue("ExposureTime", ref value);
@@ -519,7 +662,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鑾峰彇鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"鑾峰彇鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -535,7 +679,8 @@
             {
                 if (_camera == null || !_camera.IMV_IsOpen())
                 {
-                    throw new Exception("鐩告満鏈墦寮�");
+                    AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+                    throw new Exception(SN + "鐩告満鏈墦寮�");
                 }
 
                 string gainFeature = _camera.IMV_FeatureIsValid("Gain") ? "Gain" : "GainRaw";
@@ -545,13 +690,15 @@
                 int result = _camera.IMV_GetDoubleFeatureMin(gainFeature, ref minGain);
                 if (result != IMVDefine.IMV_OK)
                 {
-                    throw new Exception($"鑾峰彇澧炵泭鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
+                    AsyncLogHelper.Error(SN + $"鑾峰彇澧炵泭鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
+                    throw new Exception(SN + $"鑾峰彇澧炵泭鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
                 }
 
                 result = _camera.IMV_GetDoubleFeatureMax(gainFeature, ref maxGain);
                 if (result != IMVDefine.IMV_OK)
                 {
-                    throw new Exception($"鑾峰彇澧炵泭鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
+                    AsyncLogHelper.Error(SN + $"鑾峰彇澧炵泭鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
+                    throw new Exception(SN + $"鑾峰彇澧炵泭鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
                 }
 
                 if (gain < minGain) gain = minGain;
@@ -561,14 +708,16 @@
                 result = _camera.IMV_SetDoubleFeatureValue(gainFeature, gain);
                 if (result != IMVDefine.IMV_OK)
                 {
-                    throw new Exception($"璁剧疆澧炵泭澶辫触锛岄敊璇爜锛歿result}");
+                    AsyncLogHelper.Error(SN + $"璁剧疆澧炵泭澶辫触锛岄敊璇爜锛歿result}");
+                    throw new Exception(SN + $"璁剧疆澧炵泭澶辫触锛岄敊璇爜锛歿result}");
                 }
 
                 return true;
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"璁剧疆澧炵泭澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆澧炵泭澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"璁剧疆澧炵泭澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -586,7 +735,8 @@
             {
                 if (_camera == null || !_camera.IMV_IsOpen())
                 {
-                    throw new Exception("鐩告満鏈墦寮�");
+                    AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+                    throw new Exception(SN + "鐩告満鏈墦寮�");
                 }
 
                 string gainFeature = _camera.IMV_FeatureIsValid("Gain") ? "Gain" : "GainRaw";
@@ -595,7 +745,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鑾峰彇澧炵泭澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇澧炵泭澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"鑾峰彇澧炵泭澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -619,7 +770,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"璁剧疆瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
+                AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
                 return false;
             }
         }
@@ -647,7 +799,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鑾峰彇瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
+                AsyncLogHelper.Error(SN + $"鑾峰彇瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
                 return false;
             }
         }
@@ -671,7 +824,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"璁剧疆瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -695,7 +849,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鑾峰彇瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"鑾峰彇瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -718,7 +873,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"璁剧疆瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -742,7 +898,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鑾峰彇瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"鑾峰彇瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
                 return false;
             }
         }
@@ -767,7 +924,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"璁剧疆淇″彿绾挎ā寮忓け璐ワ細{ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆淇″彿绾挎ā寮忓け璐ワ細{ex.Message}");
+                AsyncLogHelper.Error(SN + $"璁剧疆淇″彿绾挎ā寮忓け璐ワ細{ex.Message}");
                 return false;
             }
         }
@@ -791,7 +949,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"璁剧疆淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
+                AsyncLogHelper.Error(SN + $"璁剧疆淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
                 return false;
             }
         }
@@ -820,7 +979,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鑾峰彇淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
+                AsyncLogHelper.Error(SN + $"鑾峰彇淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
                 return false;
             }
         }
@@ -843,7 +1003,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鑷姩鐧藉钩琛″け璐ワ細{ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鑷姩鐧藉钩琛″け璐ワ細{ex.Message}");
+                AsyncLogHelper.Error(SN + $"鑷姩鐧藉钩琛″け璐ワ細{ex.Message}");
                 return false;
             }
         }
@@ -880,14 +1041,16 @@
                         if ((uint)result != 0x80000001 && result != -119 && result != -102) // 瓒呮椂閿欒浠g爜
                         {
                             // 闈炶秴鏃堕敊璇�
-                            System.Diagnostics.Debug.WriteLine($"鑾峰彇鍥惧儚甯уけ璐ワ紝閿欒鐮侊細{result}");
+                            System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇鍥惧儚甯уけ璐ワ紝閿欒鐮侊細{result}");
+                            AsyncLogHelper.Error(SN + $"鑾峰彇鍥惧儚甯уけ璐ワ紝閿欒鐮侊細{result}");
                             Thread.Sleep(10); // 鍑洪敊鏃剁◢浣滅瓑寰�
                         }
                     }
                 }
                 catch (Exception ex)
                 {
-                    System.Diagnostics.Debug.WriteLine($"閲囬泦绾跨▼寮傚父锛歿ex.Message}");
+                    System.Diagnostics.Debug.WriteLine(SN + $"閲囬泦绾跨▼寮傚父锛歿ex.Message}");
+                    AsyncLogHelper.Error(SN + $"閲囬泦绾跨▼寮傚父锛歿ex.Message}");
                     Thread.Sleep(10);
                 }
 
@@ -918,7 +1081,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"澶勭悊鍥惧儚甯уけ璐ワ細{ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"澶勭悊鍥惧儚甯уけ璐ワ細{ex.Message}");
+                AsyncLogHelper.Error(SN + $"澶勭悊鍥惧儚甯уけ璐ワ細{ex.Message}");
             }
             finally
             {
@@ -957,7 +1121,8 @@
             }
             catch (Exception ex)
             {
-                System.Diagnostics.Debug.WriteLine($"鍥惧儚鏍煎紡杞崲澶辫触锛歿ex.Message}");
+                System.Diagnostics.Debug.WriteLine(SN + $"鍥惧儚鏍煎紡杞崲澶辫触锛歿ex.Message}");
+                AsyncLogHelper.Error(SN + $"鍥惧儚鏍煎紡杞崲澶辫触锛歿ex.Message}");
                 return null;
             }
         }

--
Gitblit v1.9.3