From 46431fb658701489f8d5de4475b02df728c51f36 Mon Sep 17 00:00:00 2001
From: chunxiaqiu <1057644574@qq.com>
Date: 星期三, 18 三月 2026 15:48:26 +0800
Subject: [PATCH] 新增:读码器功能模块,集成华睿读码器并初步实现读码功能

---
 LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs |  158 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 153 insertions(+), 5 deletions(-)

diff --git a/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs b/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs
index a30f452..ea8c66a 100644
--- a/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs
+++ b/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs
@@ -1,6 +1,8 @@
-锘縰sing LB_VisionControl;
+锘縰sing LB_SmartVisionCommon;
+using LB_VisionControl;
 using LB_VisionProcesses.Cameras;
 using System;
+using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -12,6 +14,7 @@
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Forms;
+using System.Windows.Media.Media3D;
 using static ZXing.QrCode.Internal.Mode;
 
 namespace LB_SmartVision.Forms.Pages.MotionControlPage
@@ -20,10 +23,12 @@
     {
         BaseCamera camera { get; set; }
         UserPictureBox onlinePictureBox { get; set; }
+        string communicatorsName { get; set; }
         public MotionControlForm()
         {
             InitializeComponent();
         }
+        string cameraSN = string.Empty;
 
         public MotionControlForm(BaseCamera camera)
         {
@@ -34,8 +39,8 @@
 
             this.camera = camera;
             this.Text = camera.SN;
-            textBox1.Text = camera.SN;
-
+            textBoxSN.Text = camera.SN;
+            cameraSN = camera.SN;
             onlinePictureBox = new UserPictureBox(uiGroupBoxImage);
             this.uiGroupBoxImage.Controls.Clear();
             this.uiGroupBoxImage.Controls.Add(onlinePictureBox);
@@ -43,8 +48,12 @@
 
             //鍔犺浇鍥炶皟鍑芥暟
             Subscribe();
+            foreach (var name in GlobalVar.dicCommunicators.Items.Keys)
+            {
+                cmbCom.Items.Add(name);
+            }
         }
-
+        ConcurrentDictionary<string, RecordMotionControlData> concurrentDictionary = new ConcurrentDictionary<string, RecordMotionControlData>();
         private void CameraForm_FormClosing(object sender, FormClosingEventArgs e)
         {
             if (camera == null)
@@ -53,7 +62,141 @@
             camera.StopGrabbing();
 
             camera.StartGrabbing();
-
+            if (GlobalVar.dicMotionControlData.Keys.Contains(GlobalVar.strProductName))
+            {
+                concurrentDictionary = GlobalVar.dicMotionControlData[GlobalVar.strProductName];
+                double xAxisDetectLocationValue, xAxisOriginalLocationValue, yAxisDetectLocationValue, yAxisOriginalLocationValue, zAxisDetectLocationValue, zAxisOriginalLocationValue, wAxisDetectLocationValue, wAxisOriginalLocationValue, pulseMotionSpeedValue, angularVelocityValue;
+                xAxisDetectLocationValue = double.Parse(this.textBoxXDetectLocation.Text);
+                xAxisOriginalLocationValue = double.Parse(this.textBoxXOriginalLocation.Text);
+                yAxisDetectLocationValue = double.Parse(this.textBoxYDetectLocation.Text);
+                yAxisOriginalLocationValue = double.Parse(this.textBoxYOriginalLocation.Text);
+                zAxisDetectLocationValue = double.Parse(this.textBoxZDetectLocation.Text);
+                zAxisOriginalLocationValue = double.Parse(this.textBoxZOriginalLocation.Text);
+                wAxisDetectLocationValue = double.Parse(this.textBoxWDetectLocation.Text);
+                wAxisOriginalLocationValue = double.Parse(this.textBoxWOriginalLocation.Text);
+                pulseMotionSpeedValue = double.Parse(this.textBoxPointSpeed.Text);
+                angularVelocityValue = double.Parse(this.textBoxPointSpeed.Text);
+                if (concurrentDictionary.Keys.Contains(cameraSN))
+                {
+                    RecordMotionControlData recordMotionControlData = new RecordMotionControlData
+                    {
+                        ProductName = GlobalVar.strProductName,
+                        CommunicatorsName = communicatorsName,
+                        CameraSN = cameraSN,
+                        XAxisAddress = this.textBoxXVarAddress.Text,
+                        XAxisDetectLocationValue = xAxisDetectLocationValue,
+                        XAxisOriginalLocationValue = xAxisOriginalLocationValue,
+                        YAxisAddress = this.textBoxYVarAddress.Text,
+                        YAxisDetectLocationValue = yAxisDetectLocationValue,
+                        YAxisOriginalLocationValue = yAxisOriginalLocationValue,
+                        ZAxisAddress = this.textBoxZVarAddress.Text,
+                        ZAxisDetectLocationValue = zAxisDetectLocationValue,
+                        ZAxisOriginalLocationValue = zAxisOriginalLocationValue,
+                        WAxisAddress = this.textBoxWVarAddress.Text,
+                        WAxisDetectLocationValue = wAxisDetectLocationValue,
+                        WAxisOriginalLocationValue = wAxisOriginalLocationValue,
+                        PulseMotionSpeedAddress = this.textBoxPulseMotionSpeedAddress.Text,
+                        PulseMotionSpeedValue = pulseMotionSpeedValue,
+                        AngularVelocityAddress = this.textBoxAngularVelocityAddress.Text,
+                        AngularVelocityValue = angularVelocityValue
+                    };
+                    concurrentDictionary.TryAdd(cameraSN, recordMotionControlData);
+                }
+                else
+                {
+                    RecordMotionControlData recordMotionControlData = new RecordMotionControlData
+                    {
+                        ProductName = GlobalVar.strProductName,
+                        CommunicatorsName = communicatorsName,
+                        CameraSN = cameraSN,
+                        XAxisAddress = this.textBoxXVarAddress.Text,
+                        XAxisDetectLocationValue = xAxisDetectLocationValue,
+                        XAxisOriginalLocationValue = xAxisOriginalLocationValue,
+                        YAxisAddress = this.textBoxYVarAddress.Text,
+                        YAxisDetectLocationValue = yAxisDetectLocationValue,
+                        YAxisOriginalLocationValue = yAxisOriginalLocationValue,
+                        ZAxisAddress = this.textBoxZVarAddress.Text,
+                        ZAxisDetectLocationValue = zAxisDetectLocationValue,
+                        ZAxisOriginalLocationValue = zAxisOriginalLocationValue,
+                        WAxisAddress = this.textBoxWVarAddress.Text,
+                        WAxisDetectLocationValue = wAxisDetectLocationValue,
+                        WAxisOriginalLocationValue = wAxisOriginalLocationValue,
+                        PulseMotionSpeedAddress = this.textBoxPulseMotionSpeedAddress.Text,
+                        PulseMotionSpeedValue = pulseMotionSpeedValue,
+                        AngularVelocityAddress = this.textBoxAngularVelocityAddress.Text,
+                        AngularVelocityValue = angularVelocityValue
+                    };
+                    concurrentDictionary.TryAdd(cameraSN, recordMotionControlData);
+                }
+            }
+            else
+            {
+                double xAxisDetectLocationValue, xAxisOriginalLocationValue, yAxisDetectLocationValue, yAxisOriginalLocationValue, zAxisDetectLocationValue, zAxisOriginalLocationValue, wAxisDetectLocationValue, wAxisOriginalLocationValue, pulseMotionSpeedValue, angularVelocityValue;
+                xAxisDetectLocationValue = double.Parse(this.textBoxXDetectLocation.Text);
+                xAxisOriginalLocationValue = double.Parse(this.textBoxXOriginalLocation.Text);
+                yAxisDetectLocationValue = double.Parse(this.textBoxYDetectLocation.Text);
+                yAxisOriginalLocationValue = double.Parse(this.textBoxYOriginalLocation.Text);
+                zAxisDetectLocationValue = double.Parse(this.textBoxZDetectLocation.Text);
+                zAxisOriginalLocationValue = double.Parse(this.textBoxZOriginalLocation.Text);
+                wAxisDetectLocationValue = double.Parse(this.textBoxWDetectLocation.Text);
+                wAxisOriginalLocationValue = double.Parse(this.textBoxWOriginalLocation.Text);
+                pulseMotionSpeedValue = double.Parse(this.textBoxPointSpeed.Text);
+                angularVelocityValue = double.Parse(this.textBoxPointSpeed.Text);
+                if (concurrentDictionary.Keys.Contains(cameraSN))
+                {
+                    RecordMotionControlData recordMotionControlData = new RecordMotionControlData
+                    {
+                        ProductName = GlobalVar.strProductName,
+                        CommunicatorsName = communicatorsName,
+                        CameraSN = cameraSN,
+                        XAxisAddress = this.textBoxXVarAddress.Text,
+                        XAxisDetectLocationValue = xAxisDetectLocationValue,
+                        XAxisOriginalLocationValue = xAxisOriginalLocationValue,
+                        YAxisAddress = this.textBoxYVarAddress.Text,
+                        YAxisDetectLocationValue = yAxisDetectLocationValue,
+                        YAxisOriginalLocationValue = yAxisOriginalLocationValue,
+                        ZAxisAddress = this.textBoxZVarAddress.Text,
+                        ZAxisDetectLocationValue = zAxisDetectLocationValue,
+                        ZAxisOriginalLocationValue = zAxisOriginalLocationValue,
+                        WAxisAddress = this.textBoxWVarAddress.Text,
+                        WAxisDetectLocationValue = wAxisDetectLocationValue,
+                        WAxisOriginalLocationValue = wAxisOriginalLocationValue,
+                        PulseMotionSpeedAddress = this.textBoxPulseMotionSpeedAddress.Text,
+                        PulseMotionSpeedValue = pulseMotionSpeedValue,
+                        AngularVelocityAddress = this.textBoxAngularVelocityAddress.Text,
+                        AngularVelocityValue = angularVelocityValue
+                    };
+                    concurrentDictionary.TryAdd(cameraSN, recordMotionControlData);
+                }
+                else
+                {
+                    RecordMotionControlData recordMotionControlData = new RecordMotionControlData
+                    {
+                        ProductName = GlobalVar.strProductName,
+                        CommunicatorsName = communicatorsName,
+                        CameraSN = cameraSN,
+                        XAxisAddress = this.textBoxXVarAddress.Text,
+                        XAxisDetectLocationValue = xAxisDetectLocationValue,
+                        XAxisOriginalLocationValue = xAxisOriginalLocationValue,
+                        YAxisAddress = this.textBoxYVarAddress.Text,
+                        YAxisDetectLocationValue = yAxisDetectLocationValue,
+                        YAxisOriginalLocationValue = yAxisOriginalLocationValue,
+                        ZAxisAddress = this.textBoxZVarAddress.Text,
+                        ZAxisDetectLocationValue = zAxisDetectLocationValue,
+                        ZAxisOriginalLocationValue = zAxisOriginalLocationValue,
+                        WAxisAddress = this.textBoxWVarAddress.Text,
+                        WAxisDetectLocationValue = wAxisDetectLocationValue,
+                        WAxisOriginalLocationValue = wAxisOriginalLocationValue,
+                        PulseMotionSpeedAddress = this.textBoxPulseMotionSpeedAddress.Text,
+                        PulseMotionSpeedValue = pulseMotionSpeedValue,
+                        AngularVelocityAddress = this.textBoxAngularVelocityAddress.Text,
+                        AngularVelocityValue = angularVelocityValue
+                    };
+                    concurrentDictionary.TryAdd(cameraSN, recordMotionControlData);
+                }
+            }
+            GlobalVar.dicMotionControlData.TryAdd(GlobalVar.strProductName, concurrentDictionary);
+            ConfigManager<ConcurrentDictionary<string, ConcurrentDictionary<string, RecordMotionControlData>>>.SaveConfig<ConcurrentDictionary<string, ConcurrentDictionary<string, RecordMotionControlData>>>(GlobalVar.dicMotionControlData, GlobalVar.allMotionControlDataPath);
             Unsubscribe();
         }
 
@@ -370,5 +513,10 @@
         {
 
         }
+
+        private void cmbCom_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            communicatorsName = cmbCom.Text;
+        }
     }
 }

--
Gitblit v1.9.3