| | |
| | | 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; |
| | |
| | | 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 |
| | |
| | | { |
| | | BaseCamera camera { get; set; } |
| | | UserPictureBox onlinePictureBox { get; set; } |
| | | string communicatorsName { get; set; } |
| | | public MotionControlForm() |
| | | { |
| | | InitializeComponent(); |
| | | } |
| | | string cameraSN = string.Empty; |
| | | |
| | | public MotionControlForm(BaseCamera camera) |
| | | { |
| | |
| | | |
| | | 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); |
| | |
| | | |
| | | //加载回调函数 |
| | | 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) |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | //LogInfo?.Invoke($"X位置已更新为: {xPosition}", LogInfoType.INFO); |
| | | } |
| | | } |
| | | |
| | | private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) |
| | | { |
| | | |
| | | } |
| | | |
| | | private void cmbCom_SelectedIndexChanged(object sender, EventArgs e) |
| | | { |
| | | communicatorsName = cmbCom.Text; |
| | | } |
| | | } |
| | | } |