C3204
2026-01-19 0468353b5e2265935846b299afc38bb34ae23e24
LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs
@@ -1,6 +1,8 @@
using LB_VisionControl;
using 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)
        {
@@ -35,7 +40,7 @@
            this.camera = camera;
            this.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;
        }
    }
}