From 0468353b5e2265935846b299afc38bb34ae23e24 Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期一, 19 一月 2026 16:49:49 +0800
Subject: [PATCH] 完善运动控制参数存储以及加载
---
LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 152 insertions(+), 4 deletions(-)
diff --git a/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs b/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs
index e48690f..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)
{
@@ -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;
+ }
}
}
--
Gitblit v1.9.3