LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlEditPage.Designer.cs
@@ -33,7 +33,7 @@ { uiButton1 = new HopeButton(); uiButton2 = new LostButton(); uiFlowLayoutPanel1 = new FlowLayoutPanel(); uiMCLayoutPanel1 = new FlowLayoutPanel(); tableLayoutPanel1 = new TableLayoutPanel(); tableLayoutPanel2 = new TableLayoutPanel(); tableLayoutPanel1.SuspendLayout(); @@ -61,6 +61,7 @@ uiButton1.Text = "å¢å "; uiButton1.TextColor = Color.White; uiButton1.WarningColor = Color.FromArgb(230, 162, 60); uiButton1.Click += uiButton1_Click; // // uiButton2 // @@ -78,27 +79,27 @@ uiButton2.TabIndex = 12; uiButton2.Text = "æ¸ é¤"; // // uiFlowLayoutPanel1 // uiMCLayoutPanel1 // uiFlowLayoutPanel1.BackColor = Color.FromArgb(32, 41, 50); uiFlowLayoutPanel1.Dock = DockStyle.Fill; uiFlowLayoutPanel1.Font = new Font("å®ä½", 12F); uiFlowLayoutPanel1.ForeColor = SystemColors.Control; uiFlowLayoutPanel1.Location = new Point(4, 5); uiFlowLayoutPanel1.Margin = new Padding(4, 5, 4, 5); uiFlowLayoutPanel1.MinimumSize = new Size(1, 1); uiFlowLayoutPanel1.Name = "uiFlowLayoutPanel1"; uiFlowLayoutPanel1.Padding = new Padding(2); uiFlowLayoutPanel1.Size = new Size(599, 293); uiFlowLayoutPanel1.TabIndex = 10; uiFlowLayoutPanel1.Text = "`"; uiMCLayoutPanel1.BackColor = Color.FromArgb(32, 41, 50); uiMCLayoutPanel1.Dock = DockStyle.Fill; uiMCLayoutPanel1.Font = new Font("å®ä½", 12F); uiMCLayoutPanel1.ForeColor = SystemColors.Control; uiMCLayoutPanel1.Location = new Point(4, 5); uiMCLayoutPanel1.Margin = new Padding(4, 5, 4, 5); uiMCLayoutPanel1.MinimumSize = new Size(1, 1); uiMCLayoutPanel1.Name = "uiMCLayoutPanel1"; uiMCLayoutPanel1.Padding = new Padding(2); uiMCLayoutPanel1.Size = new Size(599, 293); uiMCLayoutPanel1.TabIndex = 10; uiMCLayoutPanel1.Text = "`"; // // tableLayoutPanel1 // tableLayoutPanel1.ColumnCount = 1; tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F)); tableLayoutPanel1.Controls.Add(uiFlowLayoutPanel1, 0, 0); tableLayoutPanel1.Controls.Add(uiMCLayoutPanel1, 0, 0); tableLayoutPanel1.Controls.Add(tableLayoutPanel2, 0, 1); tableLayoutPanel1.Dock = DockStyle.Fill; tableLayoutPanel1.Location = new Point(0, 0); @@ -130,8 +131,6 @@ // // MotionControlEditPage // AutoScaleDimensions = new SizeF(96F, 96F); AutoScaleMode = AutoScaleMode.Dpi; BackColor = Color.FromArgb(32, 41, 50); Controls.Add(tableLayoutPanel1); ForeColor = SystemColors.Control; @@ -147,7 +146,7 @@ private ReaLTaiizor.Controls.HopeButton uiButton1; private ReaLTaiizor.Controls.LostButton uiButton2; private FlowLayoutPanel uiFlowLayoutPanel1; private FlowLayoutPanel uiMCLayoutPanel1; private TableLayoutPanel tableLayoutPanel1; private TableLayoutPanel tableLayoutPanel2; } LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlEditPage.cs
@@ -1,4 +1,7 @@ using LB_VisionControl; using LB_SmartVision.Forms.Pages.CameraPage; using LB_SmartVision.Forms.Pages.MotionControlPage; using LB_VisionControl; using LB_VisionProcesses.Cameras; using OpenCvSharp.Flann; using System; using System.Collections.Concurrent; @@ -11,7 +14,6 @@ { public Action<string, LogInfoType> LogInfo; public MotionControlEditPage() { InitializeComponent(); @@ -22,9 +24,156 @@ private void MESEditPage_Paint(object sender, PaintEventArgs e) { uiFlowLayoutPanel1.Controls.Clear(); uiMCLayoutPanel1.Controls.Clear(); if (GlobalVar.dicCameras.Count <= 0) return; foreach (var item in GlobalVar.dicCameras) { string CameraSN = item.Key; string CameraBrand = item.Value.Brand.ToString(); if (string.IsNullOrEmpty(CameraSN) || string.IsNullOrEmpty(CameraBrand)) return; UserItem flow = new UserItem(new string[] { "è¿å¨æ§å¶", "å·æ°", "ç§»é¤" }); flow.Name = CameraSN; flow.Text = $"[{CameraBrand}]"; if (item.Value.isGrabbing) flow.state = State.Pass; else flow.state |= State.Error; LoadFlowEvent(flow); uiMCLayoutPanel1.Controls.Add(flow); } } private void uiButton1_Click(object sender, System.EventArgs e) { CreateCameraForm createCameraForm = new CreateCameraForm(); createCameraForm.ShowDialog(); if (createCameraForm.bCreate) { BaseCamera camera = createCameraForm.camera; if (GlobalVar.dicCameras.ContainsKey(camera.SN)) { MessageBox.Show($"ç¸æº[{camera.SN}]å·²åå¨!", "å¼å¸¸"); return; } string CameraSN = camera.SN;//"127.0.0.1" string CameraBrand = camera.Brand.ToString();//"1111" if (string.IsNullOrEmpty(CameraSN) || string.IsNullOrEmpty(CameraBrand)) return; GlobalVar.dicCameras.TryAdd(CameraSN, camera); LogInfo?.Invoke(string.Format("æ·»å ç¸æº[{0}][{1}]æå", CameraBrand, CameraSN), LogInfoType.PASS); } this.Invalidate(); } private void uiButton2_Click(object sender, System.EventArgs e) { //æ¸ é¤ç¨Clearæ¹æ³ uiMCLayoutPanel1.Controls.Clear(); foreach (var camera in GlobalVar.dicCameras.Values) { camera.CloseDevice(); } GlobalVar.dicCameras.Clear(); } private void LoadFlowEvent(UserItem flow) { //æé®1为æµè¯ flow.MenuItem1ClickedEvent += MCEvent; //æé®2ä¸ºå·æ° flow.MenuItem2ClickedEvent += ReconnectEvent; //æé®3ä¸ºç§»é¤ flow.MenuItem3ClickedEvent += DeleteEvent; } private void RemoveFlowEvent(UserItem flow) { //æé®1为æµè¯ flow.MenuItem1ClickedEvent -= MCEvent; //æé®2ä¸ºå·æ° flow.MenuItem2ClickedEvent -= ReconnectEvent; //æé®3ä¸ºç§»é¤ flow.MenuItem3ClickedEvent -= DeleteEvent; } // è¿å¨æ§å¶ private void MCEvent(string Name, string Text) { for (int i = 0; i < uiMCLayoutPanel1.Controls.Count; i++) { UserItem flow = (UserItem)uiMCLayoutPanel1.Controls[i]; string name = flow.Name; if (name != Name) continue; if (GlobalVar.dicCameras.ContainsKey(name)) { MotionControlPage.MotionControlForm cameraForm = new MotionControlPage.MotionControlForm(GlobalVar.dicCameras[name]); cameraForm.Show(); } } } // ç§»é¤ç¸æº private void DeleteEvent(string Name, string Text) { for (int i = 0; i < uiMCLayoutPanel1.Controls.Count; i++) { UserItem flow = (UserItem)uiMCLayoutPanel1.Controls[i]; string name = flow.Name; if (name != Name) continue; RemoveFlowEvent(flow); uiMCLayoutPanel1.Controls.Remove(uiMCLayoutPanel1.Controls[i]); if (GlobalVar.dicCameras.TryRemove(name, out BaseCamera BaseCamera)) { BaseCamera.Dispose(); LogInfo?.Invoke(string.Format("ç§»é¤ç¸æº[{0}]", name), LogInfoType.INFO); } else LogInfo?.Invoke(string.Format("ç§»é¤ç¸æº[{0}]失败", name), LogInfoType.ERROR); } } // éè¿ç¸æº private void ReconnectEvent(string Name, string Text) { for (int i = 0; i < uiMCLayoutPanel1.Controls.Count; i++) { UserItem flow = (UserItem)uiMCLayoutPanel1.Controls[i]; string name = flow.Name; if (name != Name) continue; GlobalVar.dicCameras[name].CloseDevice(); Thread.Sleep(50); GlobalVar.dicCameras[name].InitDevice(name, this.Handle); if (GlobalVar.dicCameras[name].isGrabbing) { flow.state = State.Pass; LogInfo?.Invoke(string.Format("éè¿ç¸æº[{0}]æå", name), LogInfoType.PASS); } else { flow.state = State.Error; LogInfo?.Invoke(string.Format("éè¿ç¸æº[{0}]失败", name), LogInfoType.ERROR); } flow.Refresh(); } } } } LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.Designer.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,782 @@ namespace LB_SmartVision.Forms.Pages.MotionControlPage { partial class MotionControlForm { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MotionControlForm)); uiGroupBoxMotionControl = new GroupBox(); tableLayoutPanel3 = new TableLayoutPanel(); tableLayoutPanel6 = new TableLayoutPanel(); uiButtonCloseSoftGrab = new Button(); uiButtonHardGrabWithPLC = new Button(); tableLayoutPanel5 = new TableLayoutPanel(); uiButtonGrabOnce = new Button(); tableLayoutPanel4 = new TableLayoutPanel(); labelPointSpeed = new Label(); textBoxAngleNow = new TextBox(); labelAngleNow = new Label(); textBoxPositionNow = new TextBox(); labelPositionNow = new Label(); textBoxAngSpeed = new TextBox(); labelAngSpeed = new Label(); textBoxPointSpeed = new TextBox(); tableLayoutPanel2 = new TableLayoutPanel(); uiButtonIncreasePitchAngle = new Button(); groupBoxPitchAnglePosition = new GroupBox(); textBoxPitchAnglePosition = new TextBox(); uiButtonDecreasePitchAngle = new Button(); groupBoxZPosition = new GroupBox(); textBoxZPosition = new TextBox(); groupBoxYPosition = new GroupBox(); textBoxYPosition = new TextBox(); uiButtonIncreaseZ = new Button(); uiButtonDecreaseZ = new Button(); uiButtonIncreaseY = new Button(); uiButtonDecreaseY = new Button(); uiButtonIncreaseX = new Button(); uiButtonDecreaseX = new Button(); groupBoxXPosition = new GroupBox(); textBoxXPosition = new TextBox(); tableLayoutPanel1 = new TableLayoutPanel(); textBox1 = new TextBox(); uiMarkLabelSN = new Label(); tableLayoutPanel7 = new TableLayoutPanel(); textBox2 = new TextBox(); uiMarkLabelName = new Label(); uiGroupBoxImage = new GroupBox(); uiSplitContainer1 = new SplitContainer(); themeForm1 = new ReaLTaiizor.Forms.ThemeForm(); controlBox1 = new ReaLTaiizor.Controls.ControlBox(); uiGroupBoxMotionControl.SuspendLayout(); tableLayoutPanel3.SuspendLayout(); tableLayoutPanel6.SuspendLayout(); tableLayoutPanel5.SuspendLayout(); tableLayoutPanel4.SuspendLayout(); tableLayoutPanel2.SuspendLayout(); groupBoxPitchAnglePosition.SuspendLayout(); groupBoxZPosition.SuspendLayout(); groupBoxYPosition.SuspendLayout(); groupBoxXPosition.SuspendLayout(); tableLayoutPanel1.SuspendLayout(); tableLayoutPanel7.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)uiSplitContainer1).BeginInit(); uiSplitContainer1.Panel1.SuspendLayout(); uiSplitContainer1.Panel2.SuspendLayout(); uiSplitContainer1.SuspendLayout(); themeForm1.SuspendLayout(); SuspendLayout(); // // uiGroupBoxMotionControl // uiGroupBoxMotionControl.Controls.Add(tableLayoutPanel3); uiGroupBoxMotionControl.Font = new Font("å®ä½", 12F); uiGroupBoxMotionControl.ForeColor = SystemColors.Control; uiGroupBoxMotionControl.Location = new Point(0, 0); uiGroupBoxMotionControl.Margin = new Padding(4, 5, 4, 5); uiGroupBoxMotionControl.MinimumSize = new Size(1, 1); uiGroupBoxMotionControl.Name = "uiGroupBoxMotionControl"; uiGroupBoxMotionControl.Padding = new Padding(0, 32, 0, 0); uiGroupBoxMotionControl.Size = new Size(374, 624); uiGroupBoxMotionControl.TabIndex = 18; uiGroupBoxMotionControl.TabStop = false; uiGroupBoxMotionControl.Text = "è¿å¨æ§å¶åæ°"; // // tableLayoutPanel3 // tableLayoutPanel3.ColumnCount = 1; tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); tableLayoutPanel3.Controls.Add(tableLayoutPanel6, 0, 3); tableLayoutPanel3.Controls.Add(tableLayoutPanel5, 0, 2); tableLayoutPanel3.Controls.Add(tableLayoutPanel4, 0, 5); tableLayoutPanel3.Controls.Add(tableLayoutPanel2, 0, 4); tableLayoutPanel3.Controls.Add(tableLayoutPanel1, 0, 0); tableLayoutPanel3.Controls.Add(tableLayoutPanel7, 0, 1); tableLayoutPanel3.Location = new Point(0, 55); tableLayoutPanel3.Name = "tableLayoutPanel3"; tableLayoutPanel3.RowCount = 6; tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); tableLayoutPanel3.Size = new Size(374, 560); tableLayoutPanel3.TabIndex = 0; tableLayoutPanel3.Paint += tableLayoutPanel3_Paint; // // tableLayoutPanel6 // tableLayoutPanel6.ColumnCount = 2; tableLayoutPanel6.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableLayoutPanel6.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableLayoutPanel6.Controls.Add(uiButtonCloseSoftGrab, 1, 0); tableLayoutPanel6.Controls.Add(uiButtonHardGrabWithPLC, 0, 0); tableLayoutPanel6.Dock = DockStyle.Fill; tableLayoutPanel6.Location = new Point(3, 138); tableLayoutPanel6.Name = "tableLayoutPanel6"; tableLayoutPanel6.RowCount = 1; tableLayoutPanel6.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); tableLayoutPanel6.Size = new Size(368, 39); tableLayoutPanel6.TabIndex = 6; // // uiButtonCloseSoftGrab // uiButtonCloseSoftGrab.Anchor = AnchorStyles.None; uiButtonCloseSoftGrab.BackColor = Color.Black; uiButtonCloseSoftGrab.Location = new Point(225, 5); uiButtonCloseSoftGrab.Name = "uiButtonCloseSoftGrab"; uiButtonCloseSoftGrab.Size = new Size(102, 29); uiButtonCloseSoftGrab.TabIndex = 2; uiButtonCloseSoftGrab.Text = "æåéé"; uiButtonCloseSoftGrab.UseVisualStyleBackColor = false; // // uiButtonHardGrabWithPLC // uiButtonHardGrabWithPLC.Anchor = AnchorStyles.None; uiButtonHardGrabWithPLC.BackColor = Color.Black; uiButtonHardGrabWithPLC.Location = new Point(41, 5); uiButtonHardGrabWithPLC.Name = "uiButtonHardGrabWithPLC"; uiButtonHardGrabWithPLC.Size = new Size(102, 29); uiButtonHardGrabWithPLC.TabIndex = 1; uiButtonHardGrabWithPLC.Text = "模æéé"; uiButtonHardGrabWithPLC.UseVisualStyleBackColor = false; uiButtonHardGrabWithPLC.Click += uiButtonHardGrabWithPLC_Click; // // tableLayoutPanel5 // tableLayoutPanel5.ColumnCount = 1; tableLayoutPanel5.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableLayoutPanel5.Controls.Add(uiButtonGrabOnce, 0, 0); tableLayoutPanel5.Dock = DockStyle.Fill; tableLayoutPanel5.Location = new Point(3, 93); tableLayoutPanel5.Name = "tableLayoutPanel5"; tableLayoutPanel5.RowCount = 1; tableLayoutPanel5.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); tableLayoutPanel5.Size = new Size(368, 39); tableLayoutPanel5.TabIndex = 5; // // uiButtonGrabOnce // uiButtonGrabOnce.BackColor = Color.Black; uiButtonGrabOnce.Dock = DockStyle.Fill; uiButtonGrabOnce.Location = new Point(3, 3); uiButtonGrabOnce.Name = "uiButtonGrabOnce"; uiButtonGrabOnce.Size = new Size(362, 33); uiButtonGrabOnce.TabIndex = 0; uiButtonGrabOnce.Text = "åå¼ éé"; uiButtonGrabOnce.UseVisualStyleBackColor = false; uiButtonGrabOnce.Click += uiButtonGrabOnce_Click; // // tableLayoutPanel4 // tableLayoutPanel4.ColumnCount = 2; tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 42.81768F)); tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 57.18232F)); tableLayoutPanel4.Controls.Add(labelPointSpeed, 0, 0); tableLayoutPanel4.Controls.Add(textBoxAngleNow, 1, 3); tableLayoutPanel4.Controls.Add(labelAngleNow, 0, 3); tableLayoutPanel4.Controls.Add(textBoxPositionNow, 1, 2); tableLayoutPanel4.Controls.Add(labelPositionNow, 0, 2); tableLayoutPanel4.Controls.Add(textBoxAngSpeed, 1, 1); tableLayoutPanel4.Controls.Add(labelAngSpeed, 0, 1); tableLayoutPanel4.Controls.Add(textBoxPointSpeed, 1, 0); tableLayoutPanel4.Dock = DockStyle.Fill; tableLayoutPanel4.Location = new Point(3, 373); tableLayoutPanel4.Name = "tableLayoutPanel4"; tableLayoutPanel4.RowCount = 4; tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel4.Size = new Size(368, 184); tableLayoutPanel4.TabIndex = 2; // // labelPointSpeed // labelPointSpeed.AutoSize = true; labelPointSpeed.Dock = DockStyle.Fill; labelPointSpeed.Location = new Point(3, 5); labelPointSpeed.Margin = new Padding(3, 5, 3, 5); labelPointSpeed.Name = "labelPointSpeed"; labelPointSpeed.Size = new Size(151, 35); labelPointSpeed.TabIndex = 18; labelPointSpeed.Text = "ç¹å¨é度(mm/s)"; labelPointSpeed.TextAlign = ContentAlignment.MiddleLeft; // // textBoxAngleNow // textBoxAngleNow.Anchor = AnchorStyles.Left | AnchorStyles.Right; textBoxAngleNow.Enabled = false; textBoxAngleNow.Location = new Point(160, 144); textBoxAngleNow.Name = "textBoxAngleNow"; textBoxAngleNow.Size = new Size(205, 30); textBoxAngleNow.TabIndex = 17; textBoxAngleNow.Text = "0"; textBoxAngleNow.TextChanged += textBoxAngleNow_TextChanged; // // labelAngleNow // labelAngleNow.AutoSize = true; labelAngleNow.Dock = DockStyle.Fill; labelAngleNow.Location = new Point(3, 140); labelAngleNow.Margin = new Padding(3, 5, 3, 5); labelAngleNow.Name = "labelAngleNow"; labelAngleNow.Size = new Size(151, 39); labelAngleNow.TabIndex = 16; labelAngleNow.Text = "å½åè§åº¦(°)"; labelAngleNow.TextAlign = ContentAlignment.MiddleLeft; // // textBoxPositionNow // textBoxPositionNow.Anchor = AnchorStyles.Left | AnchorStyles.Right; textBoxPositionNow.Enabled = false; textBoxPositionNow.Location = new Point(160, 97); textBoxPositionNow.Name = "textBoxPositionNow"; textBoxPositionNow.Size = new Size(205, 30); textBoxPositionNow.TabIndex = 15; textBoxPositionNow.Text = "(0,0,0)"; textBoxPositionNow.TextChanged += textBoxPositionNow_TextChanged; // // labelPositionNow // labelPositionNow.AutoSize = true; labelPositionNow.Dock = DockStyle.Fill; labelPositionNow.Location = new Point(3, 95); labelPositionNow.Margin = new Padding(3, 5, 3, 5); labelPositionNow.Name = "labelPositionNow"; labelPositionNow.Size = new Size(151, 35); labelPositionNow.TabIndex = 14; labelPositionNow.Text = "å½åç¹ä½(mm)"; labelPositionNow.TextAlign = ContentAlignment.MiddleLeft; // // textBoxAngSpeed // textBoxAngSpeed.Anchor = AnchorStyles.Left | AnchorStyles.Right; textBoxAngSpeed.Location = new Point(160, 52); textBoxAngSpeed.Name = "textBoxAngSpeed"; textBoxAngSpeed.Size = new Size(205, 30); textBoxAngSpeed.TabIndex = 13; textBoxAngSpeed.Text = "0"; textBoxAngSpeed.TextChanged += textBoxAngSpeed_TextChanged; textBoxAngSpeed.KeyDown += textBoxXPosition_KeyDown; textBoxAngSpeed.KeyPress += textBoxXPosition_KeyPress; // // labelAngSpeed // labelAngSpeed.AutoSize = true; labelAngSpeed.Dock = DockStyle.Fill; labelAngSpeed.Location = new Point(3, 50); labelAngSpeed.Margin = new Padding(3, 5, 3, 5); labelAngSpeed.Name = "labelAngSpeed"; labelAngSpeed.Size = new Size(151, 35); labelAngSpeed.TabIndex = 12; labelAngSpeed.Text = "è§é度(rad/s)"; labelAngSpeed.TextAlign = ContentAlignment.MiddleLeft; // // textBoxPointSpeed // textBoxPointSpeed.Anchor = AnchorStyles.Left | AnchorStyles.Right; textBoxPointSpeed.Location = new Point(160, 7); textBoxPointSpeed.Name = "textBoxPointSpeed"; textBoxPointSpeed.Size = new Size(205, 30); textBoxPointSpeed.TabIndex = 11; textBoxPointSpeed.Text = "0"; textBoxPointSpeed.TextChanged += textBoxPointSpeed_TextChanged; textBoxPointSpeed.KeyDown += textBoxXPosition_KeyDown; textBoxPointSpeed.KeyPress += textBoxXPosition_KeyPress; // // tableLayoutPanel2 // tableLayoutPanel2.ColumnCount = 3; tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 60F)); tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); tableLayoutPanel2.Controls.Add(uiButtonIncreasePitchAngle, 2, 3); tableLayoutPanel2.Controls.Add(groupBoxPitchAnglePosition, 1, 3); tableLayoutPanel2.Controls.Add(uiButtonDecreasePitchAngle, 0, 3); tableLayoutPanel2.Controls.Add(groupBoxZPosition, 1, 2); tableLayoutPanel2.Controls.Add(groupBoxYPosition, 1, 1); tableLayoutPanel2.Controls.Add(uiButtonIncreaseZ, 2, 2); tableLayoutPanel2.Controls.Add(uiButtonDecreaseZ, 0, 2); tableLayoutPanel2.Controls.Add(uiButtonIncreaseY, 2, 1); tableLayoutPanel2.Controls.Add(uiButtonDecreaseY, 0, 1); tableLayoutPanel2.Controls.Add(uiButtonIncreaseX, 2, 0); tableLayoutPanel2.Controls.Add(uiButtonDecreaseX, 0, 0); tableLayoutPanel2.Controls.Add(groupBoxXPosition, 1, 0); tableLayoutPanel2.Dock = DockStyle.Fill; tableLayoutPanel2.Location = new Point(3, 183); tableLayoutPanel2.Name = "tableLayoutPanel2"; tableLayoutPanel2.RowCount = 1; tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); tableLayoutPanel2.Size = new Size(368, 184); tableLayoutPanel2.TabIndex = 3; // // uiButtonIncreasePitchAngle // uiButtonIncreasePitchAngle.BackColor = Color.Black; uiButtonIncreasePitchAngle.Dock = DockStyle.Left; uiButtonIncreasePitchAngle.Location = new Point(298, 140); uiButtonIncreasePitchAngle.Margin = new Padding(5); uiButtonIncreasePitchAngle.Name = "uiButtonIncreasePitchAngle"; uiButtonIncreasePitchAngle.Size = new Size(32, 39); uiButtonIncreasePitchAngle.TabIndex = 27; uiButtonIncreasePitchAngle.Text = "+"; uiButtonIncreasePitchAngle.UseVisualStyleBackColor = false; uiButtonIncreasePitchAngle.Click += uiButtonIncreasePitchAngle_Click; // // groupBoxPitchAnglePosition // groupBoxPitchAnglePosition.Controls.Add(textBoxPitchAnglePosition); groupBoxPitchAnglePosition.Font = new Font("å®ä½", 8F); groupBoxPitchAnglePosition.ForeColor = Color.White; groupBoxPitchAnglePosition.Location = new Point(123, 138); groupBoxPitchAnglePosition.Margin = new Padding(50, 3, 3, 3); groupBoxPitchAnglePosition.Name = "groupBoxPitchAnglePosition"; groupBoxPitchAnglePosition.Size = new Size(115, 39); groupBoxPitchAnglePosition.TabIndex = 26; groupBoxPitchAnglePosition.TabStop = false; groupBoxPitchAnglePosition.Text = "俯仰è§(°)"; // // textBoxPitchAnglePosition // textBoxPitchAnglePosition.Dock = DockStyle.Bottom; textBoxPitchAnglePosition.Font = new Font("å®ä½", 10F); textBoxPitchAnglePosition.Location = new Point(3, 16); textBoxPitchAnglePosition.Multiline = true; textBoxPitchAnglePosition.Name = "textBoxPitchAnglePosition"; textBoxPitchAnglePosition.Size = new Size(109, 20); textBoxPitchAnglePosition.TabIndex = 13; textBoxPitchAnglePosition.Text = "1"; textBoxPitchAnglePosition.KeyDown += textBoxXPosition_KeyDown; textBoxPitchAnglePosition.KeyPress += textBoxXPosition_KeyPress; // // uiButtonDecreasePitchAngle // uiButtonDecreasePitchAngle.BackColor = Color.Black; uiButtonDecreasePitchAngle.Dock = DockStyle.Right; uiButtonDecreasePitchAngle.Location = new Point(37, 140); uiButtonDecreasePitchAngle.Margin = new Padding(5); uiButtonDecreasePitchAngle.Name = "uiButtonDecreasePitchAngle"; uiButtonDecreasePitchAngle.Size = new Size(31, 39); uiButtonDecreasePitchAngle.TabIndex = 25; uiButtonDecreasePitchAngle.Text = "-"; uiButtonDecreasePitchAngle.UseVisualStyleBackColor = false; uiButtonDecreasePitchAngle.Click += uiButtonDecreasePitchAngle_Click; // // groupBoxZPosition // groupBoxZPosition.Controls.Add(textBoxZPosition); groupBoxZPosition.Font = new Font("å®ä½", 8F); groupBoxZPosition.ForeColor = Color.White; groupBoxZPosition.Location = new Point(123, 93); groupBoxZPosition.Margin = new Padding(50, 3, 3, 3); groupBoxZPosition.Name = "groupBoxZPosition"; groupBoxZPosition.Size = new Size(115, 39); groupBoxZPosition.TabIndex = 24; groupBoxZPosition.TabStop = false; groupBoxZPosition.Text = "Z(mm)"; // // textBoxZPosition // textBoxZPosition.Dock = DockStyle.Bottom; textBoxZPosition.Font = new Font("å®ä½", 10F); textBoxZPosition.Location = new Point(3, 16); textBoxZPosition.Multiline = true; textBoxZPosition.Name = "textBoxZPosition"; textBoxZPosition.Size = new Size(109, 20); textBoxZPosition.TabIndex = 13; textBoxZPosition.Text = "1"; textBoxZPosition.KeyDown += textBoxXPosition_KeyDown; textBoxZPosition.KeyPress += textBoxXPosition_KeyPress; // // groupBoxYPosition // groupBoxYPosition.Controls.Add(textBoxYPosition); groupBoxYPosition.Font = new Font("å®ä½", 8F); groupBoxYPosition.ForeColor = Color.White; groupBoxYPosition.Location = new Point(123, 48); groupBoxYPosition.Margin = new Padding(50, 3, 3, 3); groupBoxYPosition.Name = "groupBoxYPosition"; groupBoxYPosition.Size = new Size(115, 39); groupBoxYPosition.TabIndex = 23; groupBoxYPosition.TabStop = false; groupBoxYPosition.Text = "Y(mm)"; // // textBoxYPosition // textBoxYPosition.Dock = DockStyle.Bottom; textBoxYPosition.Font = new Font("å®ä½", 10F); textBoxYPosition.Location = new Point(3, 16); textBoxYPosition.Multiline = true; textBoxYPosition.Name = "textBoxYPosition"; textBoxYPosition.Size = new Size(109, 20); textBoxYPosition.TabIndex = 13; textBoxYPosition.Text = "1"; textBoxYPosition.KeyDown += textBoxXPosition_KeyDown; textBoxYPosition.KeyPress += textBoxXPosition_KeyPress; // // uiButtonIncreaseZ // uiButtonIncreaseZ.BackColor = Color.Black; uiButtonIncreaseZ.Dock = DockStyle.Left; uiButtonIncreaseZ.Location = new Point(298, 95); uiButtonIncreaseZ.Margin = new Padding(5); uiButtonIncreaseZ.Name = "uiButtonIncreaseZ"; uiButtonIncreaseZ.Size = new Size(32, 35); uiButtonIncreaseZ.TabIndex = 19; uiButtonIncreaseZ.Text = "+"; uiButtonIncreaseZ.UseVisualStyleBackColor = false; uiButtonIncreaseZ.Click += uiButtonIncreaseZ_Click; // // uiButtonDecreaseZ // uiButtonDecreaseZ.BackColor = Color.Black; uiButtonDecreaseZ.Dock = DockStyle.Right; uiButtonDecreaseZ.Location = new Point(37, 95); uiButtonDecreaseZ.Margin = new Padding(5); uiButtonDecreaseZ.Name = "uiButtonDecreaseZ"; uiButtonDecreaseZ.Size = new Size(31, 35); uiButtonDecreaseZ.TabIndex = 17; uiButtonDecreaseZ.Text = "-"; uiButtonDecreaseZ.UseVisualStyleBackColor = false; uiButtonDecreaseZ.Click += uiButtonDecreaseZ_Click; // // uiButtonIncreaseY // uiButtonIncreaseY.BackColor = Color.Black; uiButtonIncreaseY.Dock = DockStyle.Left; uiButtonIncreaseY.Location = new Point(298, 50); uiButtonIncreaseY.Margin = new Padding(5); uiButtonIncreaseY.Name = "uiButtonIncreaseY"; uiButtonIncreaseY.Size = new Size(32, 35); uiButtonIncreaseY.TabIndex = 16; uiButtonIncreaseY.Text = "+"; uiButtonIncreaseY.UseVisualStyleBackColor = false; uiButtonIncreaseY.Click += uiButtonIncreaseY_Click; // // uiButtonDecreaseY // uiButtonDecreaseY.BackColor = Color.Black; uiButtonDecreaseY.Dock = DockStyle.Right; uiButtonDecreaseY.Location = new Point(37, 50); uiButtonDecreaseY.Margin = new Padding(5); uiButtonDecreaseY.Name = "uiButtonDecreaseY"; uiButtonDecreaseY.Size = new Size(31, 35); uiButtonDecreaseY.TabIndex = 14; uiButtonDecreaseY.Text = "-"; uiButtonDecreaseY.UseVisualStyleBackColor = false; uiButtonDecreaseY.Click += uiButtonDecreaseY_Click; // // uiButtonIncreaseX // uiButtonIncreaseX.BackColor = Color.Black; uiButtonIncreaseX.Dock = DockStyle.Left; uiButtonIncreaseX.Location = new Point(298, 5); uiButtonIncreaseX.Margin = new Padding(5); uiButtonIncreaseX.Name = "uiButtonIncreaseX"; uiButtonIncreaseX.Size = new Size(32, 35); uiButtonIncreaseX.TabIndex = 10; uiButtonIncreaseX.Text = "+"; uiButtonIncreaseX.UseVisualStyleBackColor = false; uiButtonIncreaseX.Click += uiButtonIncreaseX_Click; // // uiButtonDecreaseX // uiButtonDecreaseX.BackColor = Color.Black; uiButtonDecreaseX.Dock = DockStyle.Right; uiButtonDecreaseX.Location = new Point(37, 5); uiButtonDecreaseX.Margin = new Padding(5); uiButtonDecreaseX.Name = "uiButtonDecreaseX"; uiButtonDecreaseX.Size = new Size(31, 35); uiButtonDecreaseX.TabIndex = 8; uiButtonDecreaseX.Text = "-"; uiButtonDecreaseX.UseVisualStyleBackColor = false; uiButtonDecreaseX.Click += uiButtonDecreaseX_Click; // // groupBoxXPosition // groupBoxXPosition.Controls.Add(textBoxXPosition); groupBoxXPosition.Font = new Font("å®ä½", 8F); groupBoxXPosition.ForeColor = Color.White; groupBoxXPosition.Location = new Point(123, 3); groupBoxXPosition.Margin = new Padding(50, 3, 3, 3); groupBoxXPosition.Name = "groupBoxXPosition"; groupBoxXPosition.Size = new Size(115, 39); groupBoxXPosition.TabIndex = 21; groupBoxXPosition.TabStop = false; groupBoxXPosition.Text = "X(mm)"; // // textBoxXPosition // textBoxXPosition.Dock = DockStyle.Bottom; textBoxXPosition.Font = new Font("å®ä½", 10F); textBoxXPosition.Location = new Point(3, 16); textBoxXPosition.Multiline = true; textBoxXPosition.Name = "textBoxXPosition"; textBoxXPosition.Size = new Size(109, 20); textBoxXPosition.TabIndex = 12; textBoxXPosition.Text = "1"; textBoxXPosition.KeyDown += textBoxXPosition_KeyDown; textBoxXPosition.KeyPress += textBoxXPosition_KeyPress; // // tableLayoutPanel1 // tableLayoutPanel1.ColumnCount = 2; tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); tableLayoutPanel1.Controls.Add(textBox1, 1, 0); tableLayoutPanel1.Controls.Add(uiMarkLabelSN, 0, 0); tableLayoutPanel1.Dock = DockStyle.Fill; tableLayoutPanel1.Location = new Point(3, 3); tableLayoutPanel1.Name = "tableLayoutPanel1"; tableLayoutPanel1.RowCount = 1; tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); tableLayoutPanel1.Size = new Size(368, 39); tableLayoutPanel1.TabIndex = 4; // // textBox1 // textBox1.Anchor = AnchorStyles.Left | AnchorStyles.Right; textBox1.Enabled = false; textBox1.Location = new Point(78, 4); textBox1.Name = "textBox1"; textBox1.Size = new Size(287, 30); textBox1.TabIndex = 20; // // uiMarkLabelSN // uiMarkLabelSN.AutoSize = true; uiMarkLabelSN.Dock = DockStyle.Fill; uiMarkLabelSN.Location = new Point(3, 5); uiMarkLabelSN.Margin = new Padding(3, 5, 3, 5); uiMarkLabelSN.Name = "uiMarkLabelSN"; uiMarkLabelSN.Size = new Size(69, 29); uiMarkLabelSN.TabIndex = 19; uiMarkLabelSN.Text = "SN"; uiMarkLabelSN.TextAlign = ContentAlignment.MiddleLeft; // // tableLayoutPanel7 // tableLayoutPanel7.ColumnCount = 2; tableLayoutPanel7.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F)); tableLayoutPanel7.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); tableLayoutPanel7.Controls.Add(textBox2, 1, 0); tableLayoutPanel7.Controls.Add(uiMarkLabelName, 0, 0); tableLayoutPanel7.Dock = DockStyle.Fill; tableLayoutPanel7.Location = new Point(3, 48); tableLayoutPanel7.Name = "tableLayoutPanel7"; tableLayoutPanel7.RowCount = 1; tableLayoutPanel7.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); tableLayoutPanel7.Size = new Size(368, 39); tableLayoutPanel7.TabIndex = 7; // // textBox2 // textBox2.Anchor = AnchorStyles.Left | AnchorStyles.Right; textBox2.Enabled = false; textBox2.Location = new Point(78, 4); textBox2.Name = "textBox2"; textBox2.Size = new Size(287, 30); textBox2.TabIndex = 21; // // uiMarkLabelName // uiMarkLabelName.Anchor = AnchorStyles.None; uiMarkLabelName.Location = new Point(3, 5); uiMarkLabelName.Margin = new Padding(3, 5, 3, 5); uiMarkLabelName.Name = "uiMarkLabelName"; uiMarkLabelName.Size = new Size(69, 29); uiMarkLabelName.TabIndex = 20; uiMarkLabelName.Text = "åç§°"; uiMarkLabelName.TextAlign = ContentAlignment.MiddleLeft; uiMarkLabelName.Click += label1_Click; // // uiGroupBoxImage // uiGroupBoxImage.Dock = DockStyle.Fill; uiGroupBoxImage.Font = new Font("å®ä½", 12F); uiGroupBoxImage.ForeColor = SystemColors.Control; uiGroupBoxImage.Location = new Point(0, 0); uiGroupBoxImage.Margin = new Padding(4, 5, 4, 5); uiGroupBoxImage.MinimumSize = new Size(1, 1); uiGroupBoxImage.Name = "uiGroupBoxImage"; uiGroupBoxImage.Padding = new Padding(0, 32, 0, 0); uiGroupBoxImage.Size = new Size(495, 684); uiGroupBoxImage.TabIndex = 17; uiGroupBoxImage.TabStop = false; uiGroupBoxImage.Text = "宿¶éé"; // // uiSplitContainer1 // uiSplitContainer1.Dock = DockStyle.Fill; uiSplitContainer1.ForeColor = SystemColors.Control; uiSplitContainer1.Location = new Point(10, 70); uiSplitContainer1.MinimumSize = new Size(20, 20); uiSplitContainer1.Name = "uiSplitContainer1"; // // uiSplitContainer1.Panel1 // uiSplitContainer1.Panel1.Controls.Add(uiGroupBoxMotionControl); uiSplitContainer1.Panel1.Paint += uiSplitContainer1_Panel1_Paint; // // uiSplitContainer1.Panel2 // uiSplitContainer1.Panel2.Controls.Add(uiGroupBoxImage); uiSplitContainer1.Size = new Size(880, 684); uiSplitContainer1.SplitterDistance = 374; uiSplitContainer1.SplitterWidth = 11; uiSplitContainer1.TabIndex = 20; // // themeForm1 // themeForm1.BackColor = Color.FromArgb(32, 41, 50); themeForm1.Controls.Add(controlBox1); themeForm1.Controls.Add(uiSplitContainer1); themeForm1.Dock = DockStyle.Fill; themeForm1.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 0); themeForm1.Image = (Image)resources.GetObject("themeForm1.Image"); themeForm1.Location = new Point(0, 0); themeForm1.Name = "themeForm1"; themeForm1.Padding = new Padding(10, 70, 10, 9); themeForm1.RoundCorners = true; themeForm1.Sizable = true; themeForm1.Size = new Size(900, 763); themeForm1.SmartBounds = true; themeForm1.StartPosition = FormStartPosition.WindowsDefaultLocation; themeForm1.TabIndex = 21; themeForm1.Text = "è¿å¨æ§å¶è®¾ç½®"; // // controlBox1 // controlBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right; controlBox1.BackColor = Color.FromArgb(32, 34, 37); controlBox1.CloseHoverColor = Color.FromArgb(230, 17, 35); controlBox1.DefaultLocation = true; controlBox1.EnableHoverHighlight = true; controlBox1.EnableMaximizeButton = true; controlBox1.EnableMinimizeButton = true; controlBox1.ForeColor = Color.FromArgb(155, 155, 155); controlBox1.Location = new Point(800, 18); controlBox1.MaximizeHoverColor = Color.FromArgb(74, 74, 74); controlBox1.MinimizeHoverColor = Color.FromArgb(63, 63, 65); controlBox1.Name = "controlBox1"; controlBox1.Size = new Size(90, 25); controlBox1.TabIndex = 21; controlBox1.Text = "controlBox1"; // // MotionControlForm // AutoScaleDimensions = new SizeF(120F, 120F); AutoScaleMode = AutoScaleMode.Dpi; AutoSize = true; ClientSize = new Size(900, 763); Controls.Add(themeForm1); FormBorderStyle = FormBorderStyle.None; MinimumSize = new Size(261, 61); Name = "MotionControlForm"; Text = "è¿å¨æ§å¶è®¾ç½®"; TransparencyKey = Color.Fuchsia; uiGroupBoxMotionControl.ResumeLayout(false); tableLayoutPanel3.ResumeLayout(false); tableLayoutPanel6.ResumeLayout(false); tableLayoutPanel5.ResumeLayout(false); tableLayoutPanel4.ResumeLayout(false); tableLayoutPanel4.PerformLayout(); tableLayoutPanel2.ResumeLayout(false); groupBoxPitchAnglePosition.ResumeLayout(false); groupBoxPitchAnglePosition.PerformLayout(); groupBoxZPosition.ResumeLayout(false); groupBoxZPosition.PerformLayout(); groupBoxYPosition.ResumeLayout(false); groupBoxYPosition.PerformLayout(); groupBoxXPosition.ResumeLayout(false); groupBoxXPosition.PerformLayout(); tableLayoutPanel1.ResumeLayout(false); tableLayoutPanel1.PerformLayout(); tableLayoutPanel7.ResumeLayout(false); tableLayoutPanel7.PerformLayout(); uiSplitContainer1.Panel1.ResumeLayout(false); uiSplitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)uiSplitContainer1).EndInit(); uiSplitContainer1.ResumeLayout(false); themeForm1.ResumeLayout(false); ResumeLayout(false); } #endregion private GroupBox uiGroupBoxImage; private GroupBox uiGroupBoxMotionControl; private SplitContainer uiSplitContainer1; private TableLayoutPanel tableLayoutPanel7; private Label uiMarkLabel5; private TextBox uiTextBoxPitchAngle; private ReaLTaiizor.Forms.ThemeForm themeForm1; private ReaLTaiizor.Controls.ControlBox controlBox1; private TableLayoutPanel tableLayoutPanel3; private TableLayoutPanel tableLayoutPanel2; private Button uiButtonIncreasePitchAngle; private GroupBox groupBoxPitchAnglePosition; private TextBox textBoxPitchAnglePosition; private Button uiButtonDecreasePitchAngle; private GroupBox groupBoxZPosition; private TextBox textBoxZPosition; private GroupBox groupBoxYPosition; private TextBox textBoxYPosition; private Button uiButtonIncreaseZ; private Button uiButtonDecreaseZ; private Button uiButtonIncreaseY; private Button uiButtonDecreaseY; private Button uiButtonIncreaseX; private Button uiButtonDecreaseX; private GroupBox groupBoxXPosition; private TextBox textBoxXPosition; private TableLayoutPanel tableLayoutPanel4; private Label labelPointSpeed; private TextBox textBoxAngleNow; private Label labelAngleNow; private TextBox textBoxPositionNow; private Label labelPositionNow; private TextBox textBoxAngSpeed; private Label labelAngSpeed; private TextBox textBoxPointSpeed; private TableLayoutPanel tableLayoutPanel6; private Button uiButtonHardGrabWithPLC; private TableLayoutPanel tableLayoutPanel5; private Button uiButtonGrabOnce; private TableLayoutPanel tableLayoutPanel1; private TextBox textBox1; private Label uiMarkLabelSN; private Button uiButtonCloseSoftGrab; private Label uiMarkLabelName; private TextBox textBox2; } } LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,369 @@ using LB_VisionControl; using LB_VisionProcesses.Cameras; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; using System.Windows.Forms; using static ZXing.QrCode.Internal.Mode; namespace LB_SmartVision.Forms.Pages.MotionControlPage { public partial class MotionControlForm : Form { BaseCamera camera { get; set; } UserPictureBox onlinePictureBox { get; set; } public MotionControlForm() { InitializeComponent(); } public MotionControlForm(BaseCamera camera) { InitializeComponent(); if (camera == null) return; this.camera = camera; this.Text = camera.SN; textBox1.Text = camera.SN; onlinePictureBox = new UserPictureBox(uiGroupBoxImage); this.uiGroupBoxImage.Controls.Clear(); this.uiGroupBoxImage.Controls.Add(onlinePictureBox); onlinePictureBox.Dock = DockStyle.Fill; //å è½½åè°å½æ° Subscribe(); } private void CameraForm_FormClosing(object sender, FormClosingEventArgs e) { if (camera == null) return; camera.StopGrabbing(); camera.StartGrabbing(); Unsubscribe(); } public void Unsubscribe() { try { if (camera == null) return; //åæ¶åè°å½æ° camera.ImageGrabbed -= GetImageBllComplete; } catch (Exception ex) { // è®°å½éè¯¯ä¿¡æ¯ Debug.WriteLine($"é误: {ex.Message}"); } } public void Subscribe() { try { if (camera == null) return; //åæ¶åè°å½æ° camera.ImageGrabbed -= GetImageBllComplete; //å è½½åè°å½æ° camera.ImageGrabbed += GetImageBllComplete; } catch (Exception ex) { // è®°å½éè¯¯ä¿¡æ¯ Debug.WriteLine($"é误: {ex.Message}"); } } /// <summary> /// ç¸æºåè°è¿è¡ /// </summary> /// <param name="CCDName"></param> /// <param name="image"></param> private void GetImageBllComplete(object sender, CameraEventArgs e) { if (e.Bitmap == null) return; lock (e.Bitmap) { if (this.InvokeRequired) // æ£æ¥æ¯å¦éè¦å¨UI线ç¨ä¸è°ç¨ { this.Invoke(new Action(() => { onlinePictureBox.Image = e.Bitmap; })); // éå½è°ç¨èªèº«ï¼ä½è¿æ¬¡å¨UI线ç¨ä¸ } else { onlinePictureBox.Image = e.Bitmap; } } } private void uiButtonGrabOnce_Click(object sender, EventArgs e) { if (camera == null) return; Task.Factory.StartNew(() => { camera.SetTriggerMode(TriggerMode.On, TriggerSource.Software); DateTime startTime = DateTime.Now; // å½åæ¶é´ camera.GetImageWithSoftTrigger(out Bitmap bitmap); }); } private void uiButtonCloseSoftGrab_Click(object sender, EventArgs e) { if (camera == null) return; Task.Factory.StartNew(() => { camera.StopGrabbing(); camera.SetTriggerMode(TriggerMode.On, TriggerSource.Software); camera.StartGrabbing(); }); } private void uiButtonHardGrabWithPLC_Click(object sender, EventArgs e) { if (camera == null) return; Task.Factory.StartNew(() => { camera.SetTriggerMode(TriggerMode.On, TriggerSource.Line0); camera.StopGrabbing(); camera.StartWith_HardTriggerModel(); }); } private void uiButtonDecreaseX_Click(object sender, EventArgs e) { float xPosition = 0; xPosition = float.Parse(textBoxXPosition.Text); MovePosition(-xPosition, 0, 0, 0); PositionNow(); } private void uiButtonIncreaseX_Click(object sender, EventArgs e) { float xPosition = 0; xPosition = float.Parse(textBoxXPosition.Text); MovePosition(xPosition, 0, 0, 0); PositionNow(); } private void uiButtonDecreaseY_Click(object sender, EventArgs e) { float yPosition = 0; yPosition = float.Parse(textBoxYPosition.Text); MovePosition(0, -yPosition, 0, 0); PositionNow(); } private void uiButtonIncreaseY_Click(object sender, EventArgs e) { float yPosition = 0; yPosition = float.Parse(textBoxYPosition.Text); MovePosition(0, yPosition, 0, 0); PositionNow(); } private void uiButtonDecreaseZ_Click(object sender, EventArgs e) { float zPosition = 0; zPosition = float.Parse(textBoxZPosition.Text); MovePosition(0, 0, -zPosition, 0); PositionNow(); } private void uiButtonIncreaseZ_Click(object sender, EventArgs e) { float zPosition = 0; zPosition = float.Parse(textBoxZPosition.Text); MovePosition(0, 0, zPosition, 0); PositionNow(); } private void uiButtonDecreasePitchAngle_Click(object sender, EventArgs e) { float pitchanglePosition = 0; pitchanglePosition = float.Parse(textBoxPitchAnglePosition.Text); MovePosition(0, 0, 0, -pitchanglePosition); AngNow(); } private void uiButtonIncreasePitchAngle_Click(object sender, EventArgs e) { float pitchanglePosition = 0; pitchanglePosition = float.Parse(textBoxPitchAnglePosition.Text); MovePosition(0, 0, 0, pitchanglePosition); AngNow(); } public float XPositionDt; public float YPositionDt; public float ZPositionDt; public float AnglePositionDt; public void MovePosition(float fDeltaX, float fDeltaY, float fDeltaZ, float fDeltAngle) { XPositionDt += fDeltaX; YPositionDt += fDeltaY; ZPositionDt += fDeltaZ; AnglePositionDt += fDeltAngle; } private void textBoxPointSpeed_TextChanged(object sender, EventArgs e) { float pointspeed = 0; pointspeed = float.Parse(textBoxPointSpeed.Text); } private void textBoxAngSpeed_TextChanged(object sender, EventArgs e) { float angspeed = 0; angspeed = float.Parse(textBoxAngSpeed.Text); } private void textBoxPositionNow_TextChanged(object sender, EventArgs e) { textBoxPositionNow.Enabled = false; string x; string y; string z; x = Convert.ToString(Math.Round(XPositionDt, 3)); y = Convert.ToString(Math.Round(YPositionDt, 3)); z = Convert.ToString(Math.Round(ZPositionDt, 3)); textBoxPositionNow.Text = "(" + x + "," + y + "," + z + ")"; } private void textBoxAngleNow_TextChanged(object sender, EventArgs e) { textBoxAngleNow.Enabled = false; string ang; ang = Convert.ToString(Math.Round(AnglePositionDt, 3)); textBoxAngleNow.Text = ang; } private void PositionNow() { string x; string y; string z; x = Convert.ToString(Math.Round(XPositionDt, 3)); y = Convert.ToString(Math.Round(YPositionDt, 3)); z = Convert.ToString(Math.Round(ZPositionDt, 3)); textBoxPositionNow.Text = "(" + x + y + z + ")"; } private void AngNow() { string ang; ang = Convert.ToString(Math.Round(AnglePositionDt, 3)); textBoxAngleNow.Text = "(" + ang + ")"; } private void uiGroupBoxMotionControl_Enter(object sender, EventArgs e) { } private void label1_Click(object sender, EventArgs e) { } private void tableLayoutPanel3_Paint(object sender, PaintEventArgs e) { } private void uiSplitContainer1_Panel1_Paint(object sender, PaintEventArgs e) { } // 使ç¨KeyDownäºä»¶æ´éåå¤çåè½¦é® private void textBoxXPosition_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //// éªè¯è¾å ¥ //if (ValidateXPosition()) //{ // // æ§è¡ç¡®è®¤æä½ // ProcessXPosition(); //} // 黿¢ç³»ç»å£°é³å¹¶è®©ææ¬æ¡å¤±å»ç¦ç¹ e.SuppressKeyPress = true; e.Handled = true; this.ActiveControl = null; } } // 使ç¨KeyPresséªè¯å®æ¶è¾å ¥ private void textBoxXPosition_KeyPress(object sender, KeyPressEventArgs e) { // å 许å车é®ï¼è½ç¶KeyDownä¼å¤çå®ï¼ if (e.KeyChar == (char)Keys.Enter) return; // å è®¸éæ ¼é® if (e.KeyChar == (char)Keys.Back) return; // åªå 许æ°å if (!char.IsDigit(e.KeyChar)) { e.Handled = true; // 黿¢è¾å ¥ } } // éªè¯æ¹æ³ private bool ValidateXPosition() { if (string.IsNullOrWhiteSpace(textBoxXPosition.Text)) return false; return Regex.IsMatch(textBoxXPosition.Text, @"^\d+$"); } // å¤çç¡®è®¤çæ¹æ³ private void ProcessXPosition() { if (int.TryParse(textBoxXPosition.Text, out int xPosition)) { // æ§è¡é»è¾ //LogInfo?.Invoke($"Xä½ç½®å·²æ´æ°ä¸º: {xPosition}", LogInfoType.INFO); } } } } LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlForm.resx
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,144 @@ <?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <data name="themeForm1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO wgAADsIBFShKgAAAA+JJREFUWEftVkuIHGUQbt34iMEoq2S2q3p3yTJsuqpnJ+L6WBRdwaigohfFgEou BkVBUPCBCEG8BXNQ48GLeImCehIJxMsqhsSZruod46K4HtSIGjU+4iOr0c1I9fSsM3/PLNtCPO0H36m/ evz/X11VnreKVRTAHPOZumkY6lFwqURws3BwZ8ywTQnuiCP/+iTCzY1qaUPzdm/Atf3PaHre6XPsjyQM 2xLGV4XwIyX4QRj+UMK/lPFvJTyhBMeV8IgQvmRJuH4Ko+l5p9UjGBbCJ5RxTgj+VMZmXxKcSAjekHE/ NNs5DgaTKLinEQYVO4Trf1mkV81wixLUslPmA3bzF2XcKeP+hWY/u3n0fCXcrQwLyjAvjNsb1dI6N05P mFAIHlHG73sEypPgGwnhfpn0zzH7jzddcK4Q7kqfKNMI4a9K+MwBDgbdeF04MBWsFYYdQvhbLlBvfhKT f+vMtLfG7C0JJXxKGY67WnvCmPAFGRs7z42boul5AzHBfdK6TjdQtzPGk8oos5F/5Y7sfVvPhg+lp+1h 0yIsxARPmtaN78WEl8eEX+SNclxUhne0glUrNrN9zfMGlPAuZTzaQ99FYfwuDv3ruoLvq5bWaQSvZCfL GXUYLwrj240Qxtu2lkSN4FpdWfKZH9jb9RQ1Cq62f9sVOlxUxn3KQXnJ0PO8QxU/jBm1h74v7ZniEG9K Hdg/quzvXO709k0Y3u08ucGqWgheX862H4XgxbR47SqU8D1X0EXC2VmGizqDz0xPr0kYH9eO360gNe0b jWppozB+1kOQEb5MCLa0C64NoeGrhOGrvH6lhK81GiIvnggmrDLzgvTkvwvDA+5wsU4nhG/m9AUoBD/F HFzWN4H0XQn2vF8eXN8Z3FAPYasl59oUYjuB+sTImDB+nhfgYQ39STf4fmu1DHtz+oIUgiM1KkWtwcFw sOujVT3hrnaL7UQc+hcL5W+sKIXhw0OVjaW0iwnBc47gqIQ45QY32PKRzv8eTguRYM9SS5YouEEZjv37 EffbzbjBDdZyxZYQ12EB2qS0bWrJqRVazPDWkojwZbuZrsgZtDJ0iY1g12khEtTicMTvclwn2CKE32YJ 7G5PORfZ1HtMCH7MOV4BrQ3XCe92+4onk5Nn2PolDAvWXnuOzAwzo6Nnx4Q3SrojwqfKeMxWMpsXWVs+ 2WrfKRdbW1W6Hf0shM/33Y7my4PrleFZIfhAaWjU/e5ivlw+y3S2FySMtynjvcrwsFiLJv/RhPBB2ws1 hK2WcBLBFf1qawlplwvxaQlxe786OOU4PBWsjSO85mBlQ8n99r/BisSdAas4FfgHpdEUZpwUX7sAAAAA SUVORK5CYII= </value> </data> </root> LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.Designer.cs
@@ -46,10 +46,11 @@ // // toolStrip1 // toolStrip1.ImageScalingSize = new Size(20, 20); toolStrip1.Items.AddRange(new ToolStripItem[] { lblTitle, btnRun, btnCircleRun }); toolStrip1.Location = new Point(0, 0); toolStrip1.Name = "toolStrip1"; toolStrip1.Size = new Size(360, 25); toolStrip1.Size = new Size(450, 27); toolStrip1.TabIndex = 0; toolStrip1.Text = "toolStrip1"; // @@ -57,7 +58,7 @@ // lblTitle.ForeColor = SystemColors.ControlText; lblTitle.Name = "lblTitle"; lblTitle.Size = new Size(56, 22); lblTitle.Size = new Size(69, 24); lblTitle.Text = "æµç¨åç§°"; // // btnRun @@ -66,7 +67,7 @@ btnRun.Image = (Image)resources.GetObject("btnRun.Image"); btnRun.ImageTransparentColor = Color.Magenta; btnRun.Name = "btnRun"; btnRun.Size = new Size(76, 22); btnRun.Size = new Size(93, 24); btnRun.Text = "忬¡è¿è¡"; btnRun.ToolTipText = "忬¡è¿è¡"; btnRun.Click += btnRun_Click; @@ -77,7 +78,7 @@ btnCircleRun.Image = (Image)resources.GetObject("btnCircleRun.Image"); btnCircleRun.ImageTransparentColor = Color.Magenta; btnCircleRun.Name = "btnCircleRun"; btnCircleRun.Size = new Size(76, 22); btnCircleRun.Size = new Size(93, 24); btnCircleRun.Text = "è¿ç»è¿è¡"; btnCircleRun.ToolTipText = "è¿ç»"; btnCircleRun.Click += btnCircleRun_Click; @@ -87,7 +88,7 @@ panel1.Dock = DockStyle.Fill; panel1.Location = new Point(3, 3); panel1.Name = "panel1"; panel1.Size = new Size(354, 187); panel1.Size = new Size(444, 224); panel1.TabIndex = 1; // // tableLayoutPanel1 @@ -101,8 +102,8 @@ tableLayoutPanel1.Name = "tableLayoutPanel1"; tableLayoutPanel1.RowCount = 2; tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 22F)); tableLayoutPanel1.Size = new Size(360, 215); tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); tableLayoutPanel1.Size = new Size(450, 260); tableLayoutPanel1.TabIndex = 2; // // tableLayoutPanel2 @@ -113,11 +114,11 @@ tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.3333321F)); tableLayoutPanel2.Controls.Add(label1, 0, 0); tableLayoutPanel2.Dock = DockStyle.Fill; tableLayoutPanel2.Location = new Point(3, 196); tableLayoutPanel2.Location = new Point(3, 233); tableLayoutPanel2.Name = "tableLayoutPanel2"; tableLayoutPanel2.RowCount = 1; tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); tableLayoutPanel2.Size = new Size(354, 16); tableLayoutPanel2.Size = new Size(444, 24); tableLayoutPanel2.TabIndex = 2; // // label1 @@ -127,7 +128,7 @@ label1.ForeColor = SystemColors.Control; label1.Location = new Point(3, 0); label1.Name = "label1"; label1.Size = new Size(112, 16); label1.Size = new Size(141, 24); label1.TabIndex = 0; label1.Text = "æ»æ°ï¼0"; label1.DoubleClick += lblCount_DoubleClick; @@ -138,24 +139,25 @@ uiPanel1.Controls.Add(tableLayoutPanel1); uiPanel1.Dock = DockStyle.Fill; uiPanel1.Font = new Font("å®ä½", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); uiPanel1.Location = new Point(0, 25); uiPanel1.Margin = new Padding(4, 5, 4, 5); uiPanel1.Location = new Point(0, 27); uiPanel1.Margin = new Padding(5, 6, 5, 6); uiPanel1.MinimumSize = new Size(1, 1); uiPanel1.Name = "uiPanel1"; uiPanel1.Size = new Size(360, 215); uiPanel1.Size = new Size(450, 260); uiPanel1.TabIndex = 3; uiPanel1.Text = "uiPanel1"; uiPanel1.TextAlignment = ContentAlignment.MiddleCenter; // // ProcessControl // AutoScaleDimensions = new SizeF(96F, 96F); AutoScaleDimensions = new SizeF(120F, 120F); AutoScaleMode = AutoScaleMode.Dpi; BackColor = Color.FromArgb(32, 41, 50); Controls.Add(uiPanel1); Controls.Add(toolStrip1); Margin = new Padding(4, 4, 4, 4); Name = "ProcessControl"; Size = new Size(360, 240); Size = new Size(450, 287); Load += ProcessControl_Load; toolStrip1.ResumeLayout(false); toolStrip1.PerformLayout(); LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.resx
@@ -124,7 +124,7 @@ <data name="btnRun.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAmGSURBVHhe7Z3dcdw2FIVdQiLJk8dkd53JY9KB00HSQdJB YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAmGSURBVHhe7Z3dcdw2FIVdQiLJk8dkd53JY9KB00HSQdJB 8kZrFY/dgd2B3UHSQdyB04HUwaoDZy539YelqCUXwD0Avm/mjP0gkxSNQ55LApfPngEAAAAAAABAvXz7 45uvzl68fml6vrz4rf/z+/VP4c8BxOCbH958Z2PsdLX+xf608Rf+jDu9KZbrN6fL9eXpcv1lWN3mdPXq w+nq4ufw3wNMxcbR2eL838fGmYxRtsboNvsH+rjsFzPnh9sCOITdxXhvXD2UGcXxYmwOPVl2n/cP7FB1 @@ -171,7 +171,7 @@ <data name="btnCircleRun.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA5aSURBVHhe7Z3Rcdw4EoY3hFuPVPd4N0Nd7eNdBt4M7Ay8 YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAA5aSURBVHhe7Z3Rcdw4EoY3hFuPVPd4N0Nd7eNdBt4M7Ay8 Gdhv1FBS2RnYGUgZrDPYzeA2A00GMxncVYOkPGpwSBBsAA3w/6r+2lpZAkESTaAbDeCnn0Awrm4e3hrt ms+kzfbu69V2/0evza4+bnbN/8Z0/vvmb6iMrry+fH5dANTwj39//ltrBPuPvQHwRh5H9fGVAcFwQAqu /9X8xxhDdfu42TXPdkPVpTe7+r9U1+vd3QeqO78fABbx918+/5Ma18/b5neXIZF+1cfeYOje+P0CMAl9 LB_SmartVision/ProcessRun/ProcessContext.cs
@@ -329,28 +329,37 @@ IndexValueName = arrOutputs[2]; object o_InputImage = ((IProcess)dicContext[IndexProcessName]).OutputImage; if (o_InputImage is HImage ho_image && ho_image.IsInitialized()) InputImage = ho_image; else if (o_InputImage is Bitmap) if (o_InputImage != null && o_InputImage is HImage ho_image && ho_image.IsInitialized()) { InputImage = ho_image.Clone(); ho_image.Dispose(); } else if (o_InputImage != null && o_InputImage is Bitmap) { //å°Mat转æ¢ä¸ºHObject using (HImage ho_RecordImage = TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage)) { InputImage = ho_RecordImage.Clone(); if (ho_RecordImage != null) { InputImage = ho_RecordImage.Clone(); } } } else if (o_InputImage is Mat) else if (o_InputImage != null && o_InputImage is Mat) { //å°Mat转æ¢ä¸ºHObject using (HImage ho_RecordImage = TAlgorithm.Mat2HObject((Mat)o_InputImage)) { InputImage = ho_RecordImage.Clone(); if (ho_RecordImage != null) { InputImage = ho_RecordImage.Clone(); } } } if (InputImage != null && InputImage.IsInitialized()) { HOperatorSet.GetImageSize(InputImage, out ho_ImageWidth, out ho_ImageHeight); InputImage.GetImageSize(out ho_ImageWidth, out ho_ImageHeight); //å¾ç尺寸ååææ´æ°çªå£å°ºå¯¸[æé«é度] if ((ho_ImageWidth.Length > 0 && ho_ImageWidth.TupleInt() != hWindowControl.Size.Width) @@ -493,7 +502,38 @@ if (dicContext.TryGetValue(ProcessName, out IProcess obj) && obj is IProcess process) { process.InputImage = null; if (process.InputImage != null) { if (process.InputImage is HObject) { ((HObject)process.InputImage).Dispose(); } else if (process.InputImage is Mat) { ((Mat)process.InputImage).Dispose(); } else if (process.InputImage is Bitmap) { ((Bitmap)process.InputImage).Dispose(); } process.InputImage = null; } if (process.OutputImage != null) { if (process.OutputImage is HObject) { ((HObject)process.OutputImage).Dispose(); } else if (process.OutputImage is Mat) { ((Mat)process.OutputImage).Dispose(); } else if (process.OutputImage is Bitmap) { ((Bitmap)process.OutputImage).Dispose(); } process.OutputImage = null; } UpdateInputs(process); // ä¸åèç¹è·³è¿çæ¹å¼ä¸å LB_SmartVision/VisionForm.Designer.cs
@@ -65,7 +65,7 @@ theme_VisionForm.Padding = new Padding(10, 70, 10, 9); theme_VisionForm.RoundCorners = true; theme_VisionForm.Sizable = true; theme_VisionForm.Size = new Size(1440, 960); theme_VisionForm.Size = new Size(1440, 880); theme_VisionForm.SmartBounds = true; theme_VisionForm.StartPosition = FormStartPosition.WindowsDefaultLocation; theme_VisionForm.TabIndex = 0; @@ -86,8 +86,8 @@ // sc_VisionForm.Panel2 // sc_VisionForm.Panel2.Controls.Add(grb_Info); sc_VisionForm.Size = new Size(1420, 881); sc_VisionForm.SplitterDistance = 699; sc_VisionForm.Size = new Size(1420, 801); sc_VisionForm.SplitterDistance = 618; sc_VisionForm.TabIndex = 1; // // tlp_MainView @@ -104,7 +104,7 @@ tlp_MainView.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F)); tlp_MainView.RowStyles.Add(new RowStyle(SizeType.Absolute, 39F)); tlp_MainView.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); tlp_MainView.Size = new Size(1420, 699); tlp_MainView.Size = new Size(1420, 618); tlp_MainView.TabIndex = 1; tlp_MainView.TagString = null; // @@ -117,7 +117,7 @@ materialTabControl.MouseState = MaterialSkin.MouseState.HOVER; materialTabControl.Name = "materialTabControl"; materialTabControl.SelectedIndex = 0; materialTabControl.Size = new Size(1414, 594); materialTabControl.Size = new Size(1414, 513); materialTabControl.TabIndex = 0; // // tlp_VisionMainOperator @@ -237,7 +237,7 @@ grb_Info.MinimumSize = new Size(1, 1); grb_Info.Name = "grb_Info"; grb_Info.Padding = new Padding(0, 32, 0, 0); grb_Info.Size = new Size(1420, 178); grb_Info.Size = new Size(1420, 179); grb_Info.TabIndex = 1; grb_Info.Text = "æ¥å¿æ¾ç¤ºåºï¼"; grb_Info.TextAlignment = ContentAlignment.MiddleLeft; @@ -253,7 +253,7 @@ rich_Info.Name = "rich_Info"; rich_Info.Padding = new Padding(2); rich_Info.ShowText = false; rich_Info.Size = new Size(1420, 146); rich_Info.Size = new Size(1420, 147); rich_Info.TabIndex = 0; rich_Info.TextAlignment = ContentAlignment.MiddleLeft; // @@ -267,7 +267,7 @@ cb_VisionForm.EnableMaximizeButton = true; cb_VisionForm.EnableMinimizeButton = true; cb_VisionForm.ForeColor = Color.FromArgb(155, 155, 155); cb_VisionForm.Location = new Point(1340, 18); cb_VisionForm.Location = new Point(1360, 14); cb_VisionForm.MaximizeHoverColor = Color.FromArgb(74, 74, 74); cb_VisionForm.MinimizeHoverColor = Color.FromArgb(63, 63, 65); cb_VisionForm.Name = "cb_VisionForm"; @@ -279,7 +279,7 @@ // AutoScaleDimensions = new SizeF(96F, 96F); AutoScaleMode = AutoScaleMode.Dpi; ClientSize = new Size(1440, 960); ClientSize = new Size(1440, 880); Controls.Add(theme_VisionForm); FormBorderStyle = FormBorderStyle.None; Icon = (Icon)resources.GetObject("$this.Icon"); LB_VisionProcesses/Alogrithms/BaseAlgorithm/TAlgorithm.cs
@@ -131,37 +131,6 @@ image = bmp; return true; } else if (InputImage is HObject ho_image) { if (!ho_image.IsInitialized()) return false; if (Params.Fixture == null) Params.Fixture = new Fixture(); HObject hoDomainImage = null; switch (Params.ROI?.GetType().Name) { case "HRectangle2": HOperatorSet.GenRectangle2(out HObject hRectangle2, (HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column) , (HTuple)(Params.ROI.Phi + Params.Fixture.Phi), (HTuple)((HRectangle2)Params.ROI).SemiLength1, (HTuple)((HRectangle2)Params.ROI).SemiLength2); HOperatorSet.ReduceDomain(ho_image, hRectangle2, out hoDomainImage); break; case "HCircle": HOperatorSet.GenCircle(out HObject hCircle, (HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column) , (HTuple)((HCircle)Params.ROI).Radius); HOperatorSet.ReduceDomain(ho_image, hCircle, out hoDomainImage); break; case "ROI": default: image = ho_image.CopyObj(1, -1); return true; } image = hoDomainImage; return true; } else if (InputImage is Mat) { Mat src = ((Mat)InputImage); @@ -244,6 +213,77 @@ } } public virtual bool ReduceDomainImage(object InputImage, ref HImage image) { image = null; if (InputImage == null) { image = null; Msg = "è¾å ¥å¾ç为空"; Result = false; return false; } lock (InputImage) { try { if (InputImage is HImage ho_image) { if (!ho_image.IsInitialized()) return false; if (Params.Fixture == null) Params.Fixture = new Fixture(); HImage hoDomainImage = null; switch (Params.ROI?.GetType().Name) { case "HRectangle2": using (HRegion hRectangle2 = new HRegion()) { hRectangle2.GenRectangle2((HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column) , (HTuple)(Params.ROI.Phi + Params.Fixture.Phi), (HTuple)((HRectangle2)Params.ROI).SemiLength1, (HTuple)((HRectangle2)Params.ROI).SemiLength2); hoDomainImage = ho_image.ReduceDomain(hRectangle2); } break; case "HCircle": using (HRegion hCircle = new HRegion()) { hCircle.GenCircle((HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column) , (HTuple)((HCircle)Params.ROI).Radius); hoDomainImage = ho_image.ReduceDomain(hCircle); } break; case "ROI": default: image = ho_image.CopyObj(1, -1); return true; } image = hoDomainImage; return true; } else { image = null; Msg = $"è¾å ¥æ ¼å¼ä¸æ£ç¡®{InputImage.GetType()}"; Result = false; return false; } } catch (Exception ex) { image = null; Msg = $"è£åªåºå失败,åå æ¯:{ex.ToString()}"; Result = false; return false; } } } public override void Dispose() { if (InputImage != null) @@ -318,22 +358,22 @@ Result = true; bCompleted = false; Msg = string.Empty; if (InputImage != null) { if (InputImage is HObject) { ((HObject)InputImage).Dispose(); } else if (InputImage is Mat) { ((Mat)InputImage).Dispose(); } else if (InputImage is Bitmap) { ((Bitmap)InputImage).Dispose(); } InputImage = null; } //if (InputImage != null) //{ // if (InputImage is HObject) // { // ((HObject)InputImage).Dispose(); // } // else if (InputImage is Mat) // { // ((Mat)InputImage).Dispose(); // } // else if (InputImage is Bitmap) // { // ((Bitmap)InputImage).Dispose(); // } // InputImage = null; //} if (Record != null) { Record.Dispose(); @@ -487,12 +527,11 @@ HImage image = null; try { if (bmp == null || bmp.Width == 0 || bmp.Height == 0) if (bmp.Tag != null && bmp == null || bmp.Width == 0 || bmp.Height == 0) { image = null; return image; } lock (bmp) { image = new HImage(); LB_VisionProcesses/Alogrithms/Halcon/2D/HBlobTool/HBlobTool.cs
@@ -108,7 +108,7 @@ } #region è£åªåºå object DomainImage = null; HImage DomainImage = null; if (!ReduceDomainImage(InputImage, ref DomainImage)) { Msg = "è£åªåºå失败"; LB_VisionProcesses/Cameras/CameraConfig.cs
@@ -1,6 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using OpenCvSharp; using OpenCvSharp.Extensions; using System.Collections.Concurrent; using System.Diagnostics; using System.Text; @@ -190,7 +191,7 @@ Mat src = Cv2.ImRead(SN); if (src != null && !src.Empty()) OutputImage = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src); OutputImage = src.ToBitmap(); } } } LB_VisionProcesses/IProcess.cs
@@ -135,7 +135,7 @@ /// <summary> /// å 许è¿è¡æ¶é´ /// </summary> public double MaxTimeOut = 2000; public double MaxTimeOut = 200000000000; /// <summary> /// å·¥å ·åç§°