From 33e94b92f9dca911df21e0e4c7aad51d2b8a63e9 Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 22 Apr 2025 18:03:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A5=E8=BF=9B=E7=94=B5=E6=9C=BA=20?= =?UTF-8?q?=E6=8C=A1=E6=96=99=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DH.Commons/Base/CameraBase.cs | 15 +- DH.Commons/Base/VisualLocalization.cs | 3 + DH.Commons/Enums/Enum.cs | 11 +- DH.Devices.Camera/Do3ThinkCamera.cs | 30 +- DH.Devices.PLC/XinJEPLCTcpNet.cs | 393 ++++++++++-- DHSoftware/MainWindow.cs | 227 +++---- DHSoftware/Views/CameraControl.Designer.cs | 571 ++++++++++-------- DHSoftware/Views/CameraControl.cs | 6 +- DHSoftware/Views/CameraControl.resx | 4 +- DHSoftware/Views/FrmLog.cs | 10 +- DHSoftware/Views/SettingWindow.cs | 2 +- .../VisualLocalizationWindow.Designer.cs | 259 ++++++-- DHSoftware/Views/VisualLocalizationWindow.cs | 432 +++++++++---- 13 files changed, 1378 insertions(+), 585 deletions(-) diff --git a/DH.Commons/Base/CameraBase.cs b/DH.Commons/Base/CameraBase.cs index 12e5ab8..73cf709 100644 --- a/DH.Commons/Base/CameraBase.cs +++ b/DH.Commons/Base/CameraBase.cs @@ -49,6 +49,7 @@ namespace DH.Commons.Base private bool _isallPicEnabled = true;//默认全画幅 private bool _isContinueMode = false; private bool _isSavePicEnabled = false; + private bool _isZoomCamera = false; private string _imageSaveDirectory; private EnumCamType _CamType; private ImageFormat _imageFormat = ImageFormat.Jpeg; @@ -59,7 +60,7 @@ namespace DH.Commons.Base private string _computerIP = string.Empty; private bool _isDirectHardwareTrigger = false; private float _gain =6; - private float _rotateImage = 0; + private int _rotateImage = 0; private float _exposure = 200; private float _triggerDelay = 0; private decimal _roiX = 0; @@ -83,6 +84,16 @@ namespace DH.Commons.Base OnPropertyChanged(nameof(IsContinueMode)); } } + public bool IsZoomCamera + { + get => _isZoomCamera; + set + { + if (_isZoomCamera == value) return; + _isZoomCamera = value; + OnPropertyChanged(nameof(IsZoomCamera)); + } + } public virtual bool IsEnabled { @@ -245,7 +256,7 @@ namespace DH.Commons.Base [Category("图像旋转")] [DisplayName("默认旋转")] [Description("默认旋转,相机开启后默认不旋转")] - public virtual float RotateImage + public virtual int RotateImage { get => _rotateImage; set diff --git a/DH.Commons/Base/VisualLocalization.cs b/DH.Commons/Base/VisualLocalization.cs index a38ce7a..66c7694 100644 --- a/DH.Commons/Base/VisualLocalization.cs +++ b/DH.Commons/Base/VisualLocalization.cs @@ -16,6 +16,8 @@ namespace DH.Commons.Base public string Direction { get; set; } public string Speed { get; set; } + public string MSpeed { get; set; } + // 配置文件路径 private const string ConfigFile = "VisualConfigs.json"; private static readonly object _fileLock = new object(); @@ -38,6 +40,7 @@ namespace DH.Commons.Base existing.Threshold = Threshold; existing.Direction = Direction; existing.Speed = Speed; + existing.MSpeed = MSpeed; } else { diff --git a/DH.Commons/Enums/Enum.cs b/DH.Commons/Enums/Enum.cs index 6c16f39..7bfbc3f 100644 --- a/DH.Commons/Enums/Enum.cs +++ b/DH.Commons/Enums/Enum.cs @@ -115,7 +115,16 @@ namespace DH.Commons.Enums NG脉冲, 状态复位, 启用定位, - 定位完成脉冲值 + 定位完成脉冲值, + 相机步进原点, + 相机步进位置, + 相机步进速度, + 相机步进顺时针, + 相机步进逆时针, + 点动相机步进, + 点动挡杆步进, + 相机步进实时位置, + 挡料电机实时位置 diff --git a/DH.Devices.Camera/Do3ThinkCamera.cs b/DH.Devices.Camera/Do3ThinkCamera.cs index df225db..67aea35 100644 --- a/DH.Devices.Camera/Do3ThinkCamera.cs +++ b/DH.Devices.Camera/Do3ThinkCamera.cs @@ -350,14 +350,7 @@ namespace DH.Devices.Camera public int ImageCallbackFunc(uint handle, dvpStreamEvent _event, IntPtr pContext, ref dvpFrame refFrame, IntPtr pBuffer) { Mat cvImage = new Mat(); - if (this.CameraName.Equals("Cam1")) - { - Console.WriteLine(); - } - if (this.CameraName.Equals("Cam2")) - { - Console.WriteLine(); - } + try { @@ -387,11 +380,30 @@ namespace DH.Devices.Camera cvImage = Mat.FromPixelData(nHeight, nWidth, MatType.CV_8UC1, pBuffer); break; } + Mat smat = cvImage.Clone(); + Mat rotated = new Mat(); // 显式创建输出对象 + + switch (RotateImage) + { + case 90: + Cv2.Rotate(smat, rotated, RotateFlags.Rotate90Clockwise); + break; + case 180: + Cv2.Rotate(smat, rotated, RotateFlags.Rotate180); + break; + case 270: + Cv2.Rotate(smat, rotated, RotateFlags.Rotate90Counterclockwise); + break; + default: + rotated = smat.Clone(); // 无旋转时保持原图 + break; + } + var imageSet = new MatSet { - _mat = smat, + _mat = rotated, }; InitialImageSet(imageSet); diff --git a/DH.Devices.PLC/XinJEPLCTcpNet.cs b/DH.Devices.PLC/XinJEPLCTcpNet.cs index a39b290..dc8a46a 100644 --- a/DH.Devices.PLC/XinJEPLCTcpNet.cs +++ b/DH.Devices.PLC/XinJEPLCTcpNet.cs @@ -737,7 +737,55 @@ namespace DH.Devices.PLC // LogAsync(DateTime.Now, LogLevel.Information, $"关闭定位"); //写入流程启动点位配置 StartProcessAction(); - // LogAsync(DateTime.Now, LogLevel.Information, $"写入流程加载点位配置"); + PLCItem? pLCItem = ConfigModel.GlobalList? + .FirstOrDefault()? + .StartProcessList? + .Where(it => it.Name == "挡料电机回原点速度").FirstOrDefault(); + if (pLCItem == null) + { + throw new Exception( $"未找到挡料电机回原点速度地址,请检查该地址是否存在于点位表!"); + } + PLCItem? pLCItem1 = ConfigModel.GlobalList? + .FirstOrDefault()? + .StartProcessList? + .Where(it => it.Name == "挡料电机位置").FirstOrDefault(); + if (pLCItem1 == null) + { + throw new Exception($"未找到挡料电机位置地址,请检查该地址是否存在于点位表!"); + } + FeedingMotor(true, Convert.ToInt32(pLCItem.Value), Convert.ToInt32(pLCItem1.Value)); + + + PLCItem? pLCItemmontor = ConfigModel.GlobalList? + .FirstOrDefault()? + .StartProcessList? + .Where(it => it.Name == "相机步进速度").FirstOrDefault(); + if (pLCItemmontor == null) + { + throw new Exception($"未找到相机步进速度地址,请检查该地址是否存在于点位表!"); + } + PLCItem? pLCItemmontor1 = ConfigModel.GlobalList? + .FirstOrDefault()? + .StartProcessList? + .Where(it => it.Name == "相机步进位置").FirstOrDefault(); + if (pLCItemmontor1 == null) + { + throw new Exception($"未找到相机步进位置地址,请检查该地址是否存在于点位表!"); + } + + Motor(true, Convert.ToInt32(pLCItemmontor.Value), Convert.ToInt32(pLCItemmontor1.Value)); + // if (_PLCConfig?.Enable == true) + //挡料电机操作 + // _PLC.FeedingMotor(_PLCConfig.CunToZeroSpeed, _PLCConfig.CunPos, _PLCConfig.CunSpeed, _PLCConfig.CunDirection); + + //流程开启操作配置 + // ProcessInitialAction(); + // if (_PLC?Enabled == true) + //皮带 + // _PLC.Belt(true); + + + // LogAsync(DateTime.Now, LogLevel.Information, $"写入流程加载点位配置"); //计数清零 CountToZero(); LogAsync(DateTime.Now, LogLevel.Information, $"状态复位-关闭定位-写入流程加载点位配置-计数清零"); @@ -827,6 +875,7 @@ namespace DH.Devices.PLC if (pLCItem == null) return; WriteBool(pLCItem.Address, b); + } /// @@ -839,6 +888,7 @@ namespace DH.Devices.PLC if (pLCItem == null) return; WriteUInt16(pLCItem.Address, (ushort)speed); + } /// @@ -850,7 +900,6 @@ namespace DH.Devices.PLC if (DiskRunItem == null) return; WriteBool(DiskRunItem.Address, b); - Thread.Sleep(30); piecesCount = 0; } @@ -914,6 +963,59 @@ namespace DH.Devices.PLC return; WriteBool(pLCItem.Address, b); Thread.Sleep(30); + } + public void Motor(bool direction, int speed, int pos) + { + + + int timeout = 5000; + int elapsedTime = 0; + int checkInterval = 100; + MotorToZero(false); + // 检查是否不在原点,如果不在,则回原点 + + + MotorSpeed(speed); // 速度 + Thread.Sleep(300); + // 发送回原点指令 + MotorToZero(true); + Thread.Sleep(1000); // 给设备一些时间响应 + + + + // 等待回到原点 + while (!ReadMotorToZero()) + { + if (elapsedTime >= timeout) + { + break; + } + + Thread.Sleep(checkInterval); + elapsedTime += checkInterval; + } + // } + + // 无论是刚回到原点还是已经在原点,执行目标位置、速度和方向设置 + MotorSpeed(speed); + + + if (direction) + { + MotorClockwise(true); // 顺时针转动 + + } + else + { + MotorCounterclockwise(true); // 逆时针转动 + + } + Thread.Sleep(30); + MotorPos(pos); // 目标位置 + Thread.Sleep(2000); + + + } /// @@ -922,60 +1024,26 @@ namespace DH.Devices.PLC /// False: 逆时针 /// /// - public void FeedingMotor( bool direction) + public void FeedingMotor( bool direction,int speed,int pos) { - // 设置最大等待时间,假设为 3 秒 - int timeout = 3000; + int timeout = 5000; int elapsedTime = 0; - int checkInterval = 100; // 每次检查等待 100ms - - PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机回原点"); - if (pLCItem == null) - return; - PLCItem zerospeeditem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机回原点速度"); - if (zerospeeditem == null) - return; - - PLCItem CunSpeed = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机速度"); - if (CunSpeed == null) - return; - - PLCItem CunClockwiseItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机顺时针"); - if (CunClockwiseItem == null) - return; - - PLCItem CunCounterclockwiseItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机逆时针"); - if (CunCounterclockwiseItem == null) - return; - - PLCItem CunPosItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机位置"); - if (CunPosItem == null) - return; - - string CunToZero = pLCItem.Type + pLCItem.Address; - string CunToZeroSpeed = zerospeeditem.Type + zerospeeditem.Address; - string CunSpeedadress = CunSpeed.Type + CunSpeed.Address; - string CunClockwise = CunClockwiseItem.Type + CunClockwiseItem.Address; - string CunCounterclockwise = CunCounterclockwiseItem.Type + CunCounterclockwiseItem.Address; - string CunPos = CunPosItem.Type + CunPosItem.Address; - UInt16 zerospeed = UInt16.Parse(zerospeeditem.Value); - UInt16 cunSpeed = UInt16.Parse(CunSpeed.Value); - UInt16 u = UInt16.Parse(CunPosItem.Value); - // WriteBool(CountToZero, true); + int checkInterval = 100; + BarrierToZero(false); // 检查是否不在原点,如果不在,则回原点 - if (!ReadBool(CunToZero)) - { - WriteUInt16(CunToZeroSpeed, zerospeed); // 速度 - Thread.Sleep(30); + + + BarrierToZeroSpeed(speed); // 速度 + Thread.Sleep(300); // 发送回原点指令 - WriteBool(CunToZero, true); + BarrierToZero(true); Thread.Sleep(1000); // 给设备一些时间响应 // 等待回到原点 - while (!ReadBool(CunToZero)) + while (!ReadBarrierToZero()) { if (elapsedTime >= timeout) { @@ -985,33 +1053,32 @@ namespace DH.Devices.PLC Thread.Sleep(checkInterval); elapsedTime += checkInterval; } - } + // 无论是刚回到原点还是已经在原点,执行目标位置、速度和方向设置 + BarrierSpeed(speed); - - - WriteUInt16(CunSpeedadress,cunSpeed); - Thread.Sleep(2000); - string dir = string.Empty; + if (direction) { - WriteBool(CunClockwise, true); // 顺时针转动 - dir = "顺时针"; + BarrierClockwise(true); // 顺时针转动 + } else { - WriteBool(CunCounterclockwise, true); // 逆时针转动 - dir = "逆时针"; + BarrierCounterclockwise(true); // 逆时针转动 + } Thread.Sleep(30); - WriteUInt16(CunPos, u); // 目标位置 + BarrierPos(pos); // 目标位置 Thread.Sleep(2000); } + + /// /// 转盘清料 /// @@ -1052,16 +1119,226 @@ namespace DH.Devices.PLC } + /// + /// 读取定位脉冲 + /// + /// + public int ReadVisionPos() { PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "定位完成脉冲值"); if (pLCItem == null) return 0; int value = ReadInt32(pLCItem.Address); - Thread.Sleep(10); + Thread.Sleep(100); return Math.Abs(value); } + /// + /// 挡杆回原点 + /// + public void BarrierToZero(bool b) + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机回原点"); + if (pLCItem == null) + return; + WriteBool(pLCItem.Address, b); + } + /// + /// 变焦相机回原点 + /// + public void ZoomcameraToZero(bool b) + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "步进电机回原点"); + if (pLCItem == null) + return; + WriteBool(pLCItem.Address, b); + } + + /// + /// 读取 挡杆回原点状态 + /// + /// + /// + + public bool ReadBarrierToZero() + { + //PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机回原点"); + //if (pLCItem == null) + //{ + // throw new Exception("未找到挡料电机回原点点位"); + //} + //挡料电机传感器感应点 + return ReadBool("X11"); + } + + /// + /// 挡杆回原点速度 + /// + public void BarrierToZeroSpeed(int speed) + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机回原点速度"); + if (pLCItem == null) + return; + WriteUInt32(pLCItem.Address, (uint)speed); + } + + + /// + /// 挡杆位置 + /// + public void BarrierPos(int value) + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机位置"); + if (pLCItem == null) + return; + WriteUInt16(pLCItem.Address, (ushort)value); + } + + + /// + /// 挡杆速度 + /// + public void BarrierSpeed(int value) + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机速度"); + if (pLCItem == null) + return; + WriteUInt32(pLCItem.Address, (uint)value); + } + + + /// + /// 挡杆顺时针 + /// + public void BarrierClockwise(bool b) + { + PLCItem? DiskRunItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机顺时针"); + if (DiskRunItem == null) + return; + WriteBool(DiskRunItem.Address, b); + Thread.Sleep(30); + } + + /// + /// 挡杆逆时针 + /// + public void BarrierCounterclockwise(bool b) + { + PLCItem? DiskRunItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机逆时针"); + if (DiskRunItem == null) + return; + WriteBool(DiskRunItem.Address, b); + Thread.Sleep(30); + } + + + + /// + /// 相机步进电机回原点 + /// + /// + public void MotorToZero(bool b) + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "相机步进原点"); + if (pLCItem == null) + return; + WriteBool(pLCItem.Address, b); + } + + /// + /// 读取相机步进电机回原点状态 + /// + /// + /// + public bool ReadMotorToZero() + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "相机步进原点"); + if (pLCItem == null) + { + throw new Exception("未找到挡料电机回原点点位"); + } + return ReadBool(pLCItem.Address); + } + + + /// + /// 相机步进电机位置 + /// + /// + public void MotorPos(int value) + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "相机步进位置"); + if (pLCItem == null) + return; + WriteUInt16(pLCItem.Address, (ushort)value); + } + + + + + + public int ReadMotorRealPos() + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "相机步进实时位置"); + if (pLCItem == null) + { + throw new Exception("未找到相机步进实时位置"); + } + return ReadInt16(pLCItem.Address); + } + + + + /// + /// 相机步进电机速度 + /// + /// + public void MotorSpeed(int speed) + { + PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "相机步进速度"); + if (pLCItem == null) + return; + WriteInt32(pLCItem.Address, speed); + } + + + /// + /// 相机步进顺时针 + /// + public void MotorClockwise(bool b) + { + PLCItem? DiskRunItem = PLCItemList.FirstOrDefault(u => u.Name == "相机步进顺时针"); + if (DiskRunItem == null) + return; + WriteBool(DiskRunItem.Address, b); + Thread.Sleep(30); + } + + /// + /// 相机步进逆时针 + /// + public void MotorCounterclockwise(bool b) + { + PLCItem? DiskRunItem = PLCItemList.FirstOrDefault(u => u.Name == "相机步进逆时针"); + if (DiskRunItem == null) + return; + WriteBool(DiskRunItem.Address, b); + Thread.Sleep(30); + } + + /// + /// 相机步进点动 + /// + public void MotorTest(bool b) + { + PLCItem? DiskRunItem = PLCItemList.FirstOrDefault(u => u.Name == "点动相机步进"); + if (DiskRunItem == null) + return; + WriteBool(DiskRunItem.Address, b); + Thread.Sleep(30); + } + public void LogAsync(LogMsg msg) { msg.MsgSource = "PLC"; diff --git a/DHSoftware/MainWindow.cs b/DHSoftware/MainWindow.cs index ae6e3f9..d6c92f0 100644 --- a/DHSoftware/MainWindow.cs +++ b/DHSoftware/MainWindow.cs @@ -694,6 +694,14 @@ namespace DHSoftware cam.CameraName = cameraBase.CameraName; cam.CameraIP = cameraBase.CameraIP; cam.IsEnabled = cameraBase.IsEnabled; + cam.IsZoomCamera = cameraBase.IsZoomCamera; + cam.Exposure = cameraBase.Exposure; + cam.Gain = cameraBase.Gain; + cam.RotateImage = cameraBase.RotateImage; + cam.ROIX= cameraBase.ROIX; + cam.ROIH= cameraBase.ROIH; + cam.ROIW= cameraBase.ROIW; + cam.ROIY=cameraBase.ROIY; cam.ImageSaveDirectory = Path.Combine("D://Projects", cameraBase.CameraName); Cameras.Add(cam); if (cameraBase.IsEnabled) @@ -1215,120 +1223,127 @@ namespace DHSoftware private void StartProcess() { - BatchNO = textBoxBatchNO.Text; - textBoxBatchNO.ReadOnly = true; - btnCreateBatchNO.Enabled = false; - PrepareBatchNO();//生成批次号 - ProcessstartTime = DateTime.Now; - lblStartTime.Text = ProcessstartTime.ToString("yyyy-MM-dd HH:mm:ss"); - //计数清零 - PieceCount = 0; - - //CameraSummaries.Clear(); - - if (PLC?.Enable == true) + try { - PLC.OnNewPieces -= MainMotion_NewPieces; - PLC.OnNewPieces += MainMotion_NewPieces; - } - Cameras.ForEach(d => - { - if (d is CameraBase cam) + + BatchNO = textBoxBatchNO.Text; + textBoxBatchNO.ReadOnly = true; + btnCreateBatchNO.Enabled = false; + PrepareBatchNO();//生成批次号 + ProcessstartTime = DateTime.Now; + lblStartTime.Text = ProcessstartTime.ToString("yyyy-MM-dd HH:mm:ss"); + //计数清零 + PieceCount = 0; + + //CameraSummaries.Clear(); + + if (PLC?.Enable == true) { - cam.SnapshotCount = 0; + PLC.OnNewPieces -= MainMotion_NewPieces; + PLC.OnNewPieces += MainMotion_NewPieces; } - }); - //PrepareBatchNO(); - // isInPositionChecking = false; - //isFullTrayChecking = false; - //队列清空 - // var temp = new List(); - // temp.AddRange(XKRSPLCConfig.TriggerConfigCollection); - // temp.AddRange(XKRSPLCConfig.SnapshotTriggerConfigCollection); - - //temp.ForEach(t => - //{ - // var diskInfo = XKRSPLCConfig.DiskInfoList.FirstOrDefault(u => u.DiskName == t.DiskName); - // if (diskInfo != null) - // { - // t.AxisNum = diskInfo.DiskAxisNum; - // } - // else - // { - // t.AxisNum = -1; - // } - //}); - - //if (temp.Any(u => u.AxisNum < 0)) - //{ - // LogAsync(DateTime.Now, LogLevel.Error, "触发信号归属转盘未确认"); - // return new ProcessResponse(false); - //} - - // _diskInfoListInOrder = XKRSPLCConfig.DiskInfoList.OrderBy(u => u.DiskSequence).ToList(); - // var axisNumList = _diskInfoListInOrder.Select(u => u.DiskAxisNum).ToList(); - - /// PrepareMLEngine(); - - // if (_PLCConfig?.Enable == true) - //挡料电机操作 - // _PLC.FeedingMotor(_PLCConfig.CunToZeroSpeed, _PLCConfig.CunPos, _PLCConfig.CunSpeed, _PLCConfig.CunDirection); - - //流程开启操作配置 - // ProcessInitialAction(); - // if (_PLC?Enabled == true) - //皮带 - // _PLC.Belt(true); - - //DeviceCollection.ForEach(d => - //{ - // if (d is CameraBase c) - // { - // c.OnHImageOutput -= OnCameraHImageOutput; - // c.OnHImageOutput += OnCameraHImageOutput; - // c.SnapshotCount = 0; - // } - //}); - _productLists.Clear(); - - #region 虚拟相机 - - //mOfflineImageTimer = new System.Timers.Timer(); - - //mOfflineImageTimer.Elapsed += OnEmitSerialPortAsync; - //mOfflineImageTimer.Interval = 1000; - //mOfflineImageTimer.Start(); - - #endregion 虚拟相机 - - var settings = _visionEngine.DetectionConfigs.Where(u => u.IsEnabled && u.IsAddStation).ToList(); - if (settings != null) - { - settings = settings.Where(s => s.IsEnabled).ToList(); - ProductBaseCount = settings.Count; - - for (int i = 0; i < ProductBaseCount * ProductListMulti; i++) + Cameras.ForEach(d => { - ConcurrentDictionary products = new ConcurrentDictionary(); - _productLists.Add(products); + if (d is CameraBase cam) + { + cam.SnapshotCount = 0; + } + }); + + //PrepareBatchNO(); + // isInPositionChecking = false; + //isFullTrayChecking = false; + //队列清空 + // var temp = new List(); + // temp.AddRange(XKRSPLCConfig.TriggerConfigCollection); + // temp.AddRange(XKRSPLCConfig.SnapshotTriggerConfigCollection); + + //temp.ForEach(t => + //{ + // var diskInfo = XKRSPLCConfig.DiskInfoList.FirstOrDefault(u => u.DiskName == t.DiskName); + // if (diskInfo != null) + // { + // t.AxisNum = diskInfo.DiskAxisNum; + // } + // else + // { + // t.AxisNum = -1; + // } + //}); + + //if (temp.Any(u => u.AxisNum < 0)) + //{ + // LogAsync(DateTime.Now, LogLevel.Error, "触发信号归属转盘未确认"); + // return new ProcessResponse(false); + //} + + // _diskInfoListInOrder = XKRSPLCConfig.DiskInfoList.OrderBy(u => u.DiskSequence).ToList(); + // var axisNumList = _diskInfoListInOrder.Select(u => u.DiskAxisNum).ToList(); + + /// PrepareMLEngine(); + + // if (_PLCConfig?.Enable == true) + //挡料电机操作 + // _PLC.FeedingMotor(_PLCConfig.CunToZeroSpeed, _PLCConfig.CunPos, _PLCConfig.CunSpeed, _PLCConfig.CunDirection); + + //流程开启操作配置 + // ProcessInitialAction(); + // if (_PLC?Enabled == true) + //皮带 + // _PLC.Belt(true); + + //DeviceCollection.ForEach(d => + //{ + // if (d is CameraBase c) + // { + // c.OnHImageOutput -= OnCameraHImageOutput; + // c.OnHImageOutput += OnCameraHImageOutput; + // c.SnapshotCount = 0; + // } + //}); + _productLists.Clear(); + + #region 虚拟相机 + + //mOfflineImageTimer = new System.Timers.Timer(); + + //mOfflineImageTimer.Elapsed += OnEmitSerialPortAsync; + //mOfflineImageTimer.Interval = 1000; + //mOfflineImageTimer.Start(); + + #endregion 虚拟相机 + + var settings = _visionEngine.DetectionConfigs.Where(u => u.IsEnabled && u.IsAddStation).ToList(); + if (settings != null) + { + settings = settings.Where(s => s.IsEnabled).ToList(); + ProductBaseCount = settings.Count; + + for (int i = 0; i < ProductBaseCount * ProductListMulti; i++) + { + ConcurrentDictionary products = new ConcurrentDictionary(); + _productLists.Add(products); + } } + + // _MGSCameraList = DeviceCollection + //.OfType() // 直接筛选出 MGSCameraDriver 类型的元素 + //.Where(camera => camera.IConfig != null && camera.IConfig.IsEnabled) // 进一步筛选 IConfig 不为 null 且 IsEnabled 为 true + //.ToList(); + + // ProductBaseCount = _MGSCameraList.Count; + + + + //流程执行时PLC + PLC.StartProcess(); + InitialOEEStatistic(); + } + catch (Exception ex) + { } - - // _MGSCameraList = DeviceCollection - //.OfType() // 直接筛选出 MGSCameraDriver 类型的元素 - //.Where(camera => camera.IConfig != null && camera.IConfig.IsEnabled) // 进一步筛选 IConfig 不为 null 且 IsEnabled 为 true - //.ToList(); - - // ProductBaseCount = _MGSCameraList.Count; - - - - //流程执行时PLC - PLC.StartProcess(); - InitialOEEStatistic(); - } diff --git a/DHSoftware/Views/CameraControl.Designer.cs b/DHSoftware/Views/CameraControl.Designer.cs index 21cd9ef..4fecb57 100644 --- a/DHSoftware/Views/CameraControl.Designer.cs +++ b/DHSoftware/Views/CameraControl.Designer.cs @@ -28,188 +28,63 @@ /// private void InitializeComponent() { - swhEnable = new AntdUI.Switch(); + panel3 = new AntdUI.Panel(); + btnSizeAdd = new AntdUI.Button(); + button1 = new AntdUI.Button(); + button2 = new AntdUI.Button(); + button3 = new AntdUI.Button(); + panel4 = new AntdUI.Panel(); + panel2 = new AntdUI.Panel(); label18 = new AntdUI.Label(); + swhEnable = new AntdUI.Switch(); label1 = new AntdUI.Label(); label2 = new AntdUI.Label(); label3 = new AntdUI.Label(); iptExposure = new AntdUI.InputNumber(); iptGain = new AntdUI.InputNumber(); - iptRevolve = new AntdUI.InputNumber(); + iptRevolve = new AntdUI.Select(); label4 = new AntdUI.Label(); sltAcquisitionMode = new AntdUI.Select(); label5 = new AntdUI.Label(); sltTriggerMode = new AntdUI.Select(); label7 = new AntdUI.Label(); - iptROIW = new AntdUI.InputNumber(); - iptROIY = new AntdUI.InputNumber(); iptROIX = new AntdUI.InputNumber(); + iptROIY = new AntdUI.InputNumber(); + iptROIW = new AntdUI.InputNumber(); iptROIH = new AntdUI.InputNumber(); - pictureBox1 = new PictureBox(); - btnSizeAdd = new AntdUI.Button(); - button1 = new AntdUI.Button(); - button2 = new AntdUI.Button(); - button3 = new AntdUI.Button(); - sthPic = new AntdUI.Switch(); label6 = new AntdUI.Label(); + sthPic = new AntdUI.Switch(); label8 = new AntdUI.Label(); label9 = new AntdUI.Label(); label10 = new AntdUI.Label(); label11 = new AntdUI.Label(); - sthAllPic = new AntdUI.Switch(); label12 = new AntdUI.Label(); - sltCamType = new AntdUI.Select(); + sthAllPic = new AntdUI.Switch(); label13 = new AntdUI.Label(); + sltCamType = new AntdUI.Select(); + label14 = new AntdUI.Label(); + switch1 = new AntdUI.Switch(); + panel1 = new AntdUI.Panel(); + pictureBox1 = new PictureBox(); + panel3.SuspendLayout(); + panel4.SuspendLayout(); + panel2.SuspendLayout(); + panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); SuspendLayout(); // - // swhEnable + // panel3 // - swhEnable.CheckedText = "启用"; - swhEnable.Location = new Point(93, 13); - swhEnable.Name = "swhEnable"; - swhEnable.Size = new Size(94, 33); - swhEnable.TabIndex = 13; - swhEnable.UnCheckedText = "关闭"; - // - // label18 - // - label18.Location = new Point(28, 23); - label18.Name = "label18"; - label18.Size = new Size(59, 23); - label18.TabIndex = 12; - label18.Text = "状 态"; - // - // label1 - // - label1.Location = new Point(28, 140); - label1.Name = "label1"; - label1.Size = new Size(59, 36); - label1.TabIndex = 14; - label1.Text = "曝 光"; - // - // label2 - // - label2.Location = new Point(28, 183); - label2.Name = "label2"; - label2.Size = new Size(59, 36); - label2.TabIndex = 15; - label2.Text = "增 益"; - // - // label3 - // - label3.Location = new Point(28, 226); - label3.Name = "label3"; - label3.Size = new Size(59, 36); - label3.TabIndex = 16; - label3.Text = "旋转角度"; - // - // iptExposure - // - iptExposure.Location = new Point(93, 140); - iptExposure.Name = "iptExposure"; - iptExposure.Size = new Size(94, 36); - iptExposure.TabIndex = 17; - iptExposure.Tag = ""; - iptExposure.Text = "0"; - // - // iptGain - // - iptGain.Location = new Point(93, 183); - iptGain.Name = "iptGain"; - iptGain.Size = new Size(94, 36); - iptGain.TabIndex = 18; - iptGain.Text = "0"; - // - // iptRevolve - // - iptRevolve.Location = new Point(93, 226); - iptRevolve.Name = "iptRevolve"; - iptRevolve.Size = new Size(94, 36); - iptRevolve.TabIndex = 19; - iptRevolve.Text = "0"; - // - // label4 - // - label4.Location = new Point(28, 269); - label4.Name = "label4"; - label4.Size = new Size(59, 36); - label4.TabIndex = 20; - label4.Text = "采图模式"; - // - // sltAcquisitionMode - // - sltAcquisitionMode.List = true; - sltAcquisitionMode.Location = new Point(93, 269); - sltAcquisitionMode.Name = "sltAcquisitionMode"; - sltAcquisitionMode.Size = new Size(94, 36); - sltAcquisitionMode.TabIndex = 21; - // - // label5 - // - label5.Location = new Point(28, 314); - label5.Name = "label5"; - label5.Size = new Size(59, 36); - label5.TabIndex = 22; - label5.Text = "触发模式"; - // - // sltTriggerMode - // - sltTriggerMode.List = true; - sltTriggerMode.Location = new Point(93, 314); - sltTriggerMode.Name = "sltTriggerMode"; - sltTriggerMode.Size = new Size(94, 36); - sltTriggerMode.TabIndex = 26; - // - // label7 - // - label7.Location = new Point(19, 476); - label7.Name = "label7"; - label7.Size = new Size(29, 23); - label7.TabIndex = 28; - label7.Text = "ROI"; - // - // iptROIW - // - iptROIW.Location = new Point(93, 494); - iptROIW.Name = "iptROIW"; - iptROIW.Size = new Size(94, 37); - iptROIW.TabIndex = 31; - iptROIW.Text = "0"; - // - // iptROIY - // - iptROIY.Location = new Point(93, 451); - iptROIY.Name = "iptROIY"; - iptROIY.Size = new Size(94, 37); - iptROIY.TabIndex = 30; - iptROIY.Text = "0"; - // - // iptROIX - // - iptROIX.Location = new Point(93, 408); - iptROIX.Name = "iptROIX"; - iptROIX.Size = new Size(94, 37); - iptROIX.TabIndex = 29; - iptROIX.Tag = ""; - iptROIX.Text = "0"; - // - // iptROIH - // - iptROIH.Location = new Point(93, 537); - iptROIH.Name = "iptROIH"; - iptROIH.Size = new Size(94, 37); - iptROIH.TabIndex = 32; - iptROIH.Text = "0"; - // - // pictureBox1 - // - pictureBox1.BorderStyle = BorderStyle.FixedSingle; - pictureBox1.Location = new Point(219, 23); - pictureBox1.Name = "pictureBox1"; - pictureBox1.Size = new Size(659, 489); - pictureBox1.TabIndex = 33; - pictureBox1.TabStop = false; + panel3.Controls.Add(button3); + panel3.Controls.Add(button2); + panel3.Controls.Add(button1); + panel3.Controls.Add(btnSizeAdd); + panel3.Dock = DockStyle.Bottom; + panel3.Location = new Point(0, 552); + panel3.Name = "panel3"; + panel3.Size = new Size(691, 59); + panel3.TabIndex = 39; + panel3.Text = "panel3"; // // btnSizeAdd // @@ -218,10 +93,10 @@ btnSizeAdd.Ghost = true; btnSizeAdd.IconRatio = 0F; btnSizeAdd.IconSvg = ""; - btnSizeAdd.Location = new Point(282, 532); + btnSizeAdd.Location = new Point(75, 13); btnSizeAdd.Name = "btnSizeAdd"; btnSizeAdd.Size = new Size(80, 38); - btnSizeAdd.TabIndex = 34; + btnSizeAdd.TabIndex = 43; btnSizeAdd.Text = "连接相机"; // // button1 @@ -231,10 +106,10 @@ button1.Ghost = true; button1.IconRatio = 0F; button1.IconSvg = ""; - button1.Location = new Point(440, 532); + button1.Location = new Point(233, 13); button1.Name = "button1"; button1.Size = new Size(80, 38); - button1.TabIndex = 35; + button1.TabIndex = 44; button1.Text = "断开相机"; // // button2 @@ -244,10 +119,10 @@ button2.Ghost = true; button2.IconRatio = 0F; button2.IconSvg = ""; - button2.Location = new Point(595, 532); + button2.Location = new Point(388, 13); button2.Name = "button2"; button2.Size = new Size(80, 38); - button2.TabIndex = 36; + button2.TabIndex = 45; button2.Text = "单次触发"; // // button3 @@ -257,169 +132,375 @@ button3.Ghost = true; button3.IconRatio = 0F; button3.IconSvg = ""; - button3.Location = new Point(743, 532); + button3.Location = new Point(536, 13); button3.Name = "button3"; button3.Size = new Size(80, 38); - button3.TabIndex = 37; + button3.TabIndex = 46; button3.Text = "连续触发"; // + // panel4 + // + panel4.Controls.Add(pictureBox1); + panel4.Dock = DockStyle.Fill; + panel4.Location = new Point(0, 0); + panel4.Name = "panel4"; + panel4.Size = new Size(691, 552); + panel4.TabIndex = 40; + panel4.Text = "panel4"; + // + // panel2 + // + panel2.Controls.Add(panel4); + panel2.Controls.Add(panel3); + panel2.Dock = DockStyle.Fill; + panel2.Location = new Point(218, 0); + panel2.Name = "panel2"; + panel2.Size = new Size(691, 611); + panel2.TabIndex = 49; + panel2.Text = "panel2"; + // + // label18 + // + label18.Location = new Point(21, 19); + label18.Name = "label18"; + label18.Size = new Size(59, 23); + label18.TabIndex = 48; + label18.Text = "状 态"; + // + // swhEnable + // + swhEnable.CheckedText = "启用"; + swhEnable.Location = new Point(86, 9); + swhEnable.Name = "swhEnable"; + swhEnable.Size = new Size(94, 33); + swhEnable.TabIndex = 49; + swhEnable.UnCheckedText = "关闭"; + // + // label1 + // + label1.Location = new Point(21, 136); + label1.Name = "label1"; + label1.Size = new Size(59, 36); + label1.TabIndex = 50; + label1.Text = "曝 光"; + // + // label2 + // + label2.Location = new Point(21, 179); + label2.Name = "label2"; + label2.Size = new Size(59, 36); + label2.TabIndex = 51; + label2.Text = "增 益"; + // + // label3 + // + label3.Location = new Point(21, 222); + label3.Name = "label3"; + label3.Size = new Size(59, 36); + label3.TabIndex = 52; + label3.Text = "旋转角度"; + // + // iptExposure + // + iptExposure.Location = new Point(86, 136); + iptExposure.Name = "iptExposure"; + iptExposure.Size = new Size(94, 36); + iptExposure.TabIndex = 53; + iptExposure.Tag = ""; + iptExposure.Text = "0"; + // + // iptGain + // + iptGain.Location = new Point(86, 179); + iptGain.Name = "iptGain"; + iptGain.Size = new Size(94, 36); + iptGain.TabIndex = 54; + iptGain.Text = "0"; + // + // iptRevolve + // + iptRevolve.Items.AddRange(new object[] { "0", "90", "180", "270" }); + iptRevolve.List = true; + iptRevolve.Location = new Point(86, 222); + iptRevolve.Name = "iptRevolve"; + iptRevolve.Size = new Size(94, 36); + iptRevolve.TabIndex = 55; + // + // label4 + // + label4.Location = new Point(21, 265); + label4.Name = "label4"; + label4.Size = new Size(59, 36); + label4.TabIndex = 56; + label4.Text = "采图模式"; + // + // sltAcquisitionMode + // + sltAcquisitionMode.List = true; + sltAcquisitionMode.Location = new Point(86, 265); + sltAcquisitionMode.Name = "sltAcquisitionMode"; + sltAcquisitionMode.Size = new Size(94, 36); + sltAcquisitionMode.TabIndex = 57; + // + // label5 + // + label5.Location = new Point(21, 310); + label5.Name = "label5"; + label5.Size = new Size(59, 36); + label5.TabIndex = 58; + label5.Text = "触发模式"; + // + // sltTriggerMode + // + sltTriggerMode.List = true; + sltTriggerMode.Location = new Point(86, 310); + sltTriggerMode.Name = "sltTriggerMode"; + sltTriggerMode.Size = new Size(94, 36); + sltTriggerMode.TabIndex = 59; + // + // label7 + // + label7.Location = new Point(3, 498); + label7.Name = "label7"; + label7.Size = new Size(29, 23); + label7.TabIndex = 60; + label7.Text = "ROI"; + // + // iptROIX + // + iptROIX.Location = new Point(86, 430); + iptROIX.Name = "iptROIX"; + iptROIX.Size = new Size(94, 37); + iptROIX.TabIndex = 61; + iptROIX.Tag = ""; + iptROIX.Text = "0"; + // + // iptROIY + // + iptROIY.Location = new Point(86, 473); + iptROIY.Name = "iptROIY"; + iptROIY.Size = new Size(94, 37); + iptROIY.TabIndex = 62; + iptROIY.Text = "0"; + // + // iptROIW + // + iptROIW.Location = new Point(86, 516); + iptROIW.Name = "iptROIW"; + iptROIW.Size = new Size(94, 37); + iptROIW.TabIndex = 63; + iptROIW.Text = "0"; + // + // iptROIH + // + iptROIH.Location = new Point(86, 559); + iptROIH.Name = "iptROIH"; + iptROIH.Size = new Size(94, 37); + iptROIH.TabIndex = 64; + iptROIH.Text = "0"; + // + // label6 + // + label6.Location = new Point(21, 66); + label6.Name = "label6"; + label6.Size = new Size(59, 23); + label6.TabIndex = 65; + label6.Text = "相 机 图"; + // // sthPic // sthPic.CheckedText = "启用"; - sthPic.Location = new Point(93, 60); + sthPic.Location = new Point(86, 56); sthPic.Name = "sthPic"; sthPic.Size = new Size(94, 33); - sthPic.TabIndex = 39; + sthPic.TabIndex = 66; sthPic.UnCheckedText = "关闭"; // - // label6 - // - label6.Location = new Point(28, 70); - label6.Name = "label6"; - label6.Size = new Size(59, 23); - label6.TabIndex = 38; - label6.Text = "相 机 图"; - // // label8 // - label8.Location = new Point(58, 408); + label8.Location = new Point(36, 430); label8.Name = "label8"; label8.Size = new Size(29, 37); - label8.TabIndex = 40; + label8.TabIndex = 67; label8.Text = "X:"; // // label9 // - label9.Location = new Point(58, 451); + label9.Location = new Point(36, 473); label9.Name = "label9"; label9.Size = new Size(29, 37); - label9.TabIndex = 41; + label9.TabIndex = 68; label9.Text = "Y:"; // // label10 // - label10.Location = new Point(43, 494); + label10.Location = new Point(28, 516); label10.Name = "label10"; label10.Size = new Size(44, 37); - label10.TabIndex = 42; + label10.TabIndex = 69; label10.Text = "宽度:"; // // label11 // - label11.Location = new Point(43, 538); + label11.Location = new Point(28, 560); label11.Name = "label11"; label11.Size = new Size(44, 36); - label11.TabIndex = 43; + label11.TabIndex = 70; label11.Text = "高度:"; // + // label12 + // + label12.Location = new Point(21, 362); + label12.Name = "label12"; + label12.Size = new Size(59, 23); + label12.TabIndex = 71; + label12.Text = "全 画 幅"; + // // sthAllPic // sthAllPic.CheckedText = "启用"; - sthAllPic.Location = new Point(93, 356); + sthAllPic.Location = new Point(86, 352); sthAllPic.Name = "sthAllPic"; sthAllPic.Size = new Size(94, 33); - sthAllPic.TabIndex = 45; + sthAllPic.TabIndex = 72; sthAllPic.UnCheckedText = "关闭"; // - // label12 + // label13 // - label12.Location = new Point(28, 366); - label12.Name = "label12"; - label12.Size = new Size(59, 23); - label12.TabIndex = 44; - label12.Text = "全 画 幅"; + label13.Location = new Point(21, 95); + label13.Name = "label13"; + label13.Size = new Size(59, 36); + label13.TabIndex = 73; + label13.Text = "相机类型"; // // sltCamType // sltCamType.List = true; - sltCamType.Location = new Point(93, 97); + sltCamType.Location = new Point(86, 93); sltCamType.Name = "sltCamType"; sltCamType.Size = new Size(94, 36); - sltCamType.TabIndex = 47; + sltCamType.TabIndex = 74; // - // label13 + // label14 // - label13.Location = new Point(28, 99); - label13.Name = "label13"; - label13.Size = new Size(59, 36); - label13.TabIndex = 46; - label13.Text = "相机类型"; + label14.Location = new Point(21, 401); + label14.Name = "label14"; + label14.Size = new Size(59, 23); + label14.TabIndex = 75; + label14.Text = "变焦相机"; + // + // switch1 + // + switch1.CheckedText = "启用"; + switch1.Location = new Point(86, 391); + switch1.Name = "switch1"; + switch1.Size = new Size(94, 33); + switch1.TabIndex = 76; + switch1.UnCheckedText = "关闭"; + // + // panel1 + // + panel1.Controls.Add(switch1); + panel1.Controls.Add(label14); + panel1.Controls.Add(sltCamType); + panel1.Controls.Add(label13); + panel1.Controls.Add(sthAllPic); + panel1.Controls.Add(label12); + panel1.Controls.Add(label11); + panel1.Controls.Add(label10); + panel1.Controls.Add(label9); + panel1.Controls.Add(label8); + panel1.Controls.Add(sthPic); + panel1.Controls.Add(label6); + panel1.Controls.Add(iptROIH); + panel1.Controls.Add(iptROIW); + panel1.Controls.Add(iptROIY); + panel1.Controls.Add(iptROIX); + panel1.Controls.Add(label7); + panel1.Controls.Add(sltTriggerMode); + panel1.Controls.Add(label5); + panel1.Controls.Add(sltAcquisitionMode); + panel1.Controls.Add(label4); + panel1.Controls.Add(iptRevolve); + panel1.Controls.Add(iptGain); + panel1.Controls.Add(iptExposure); + panel1.Controls.Add(label3); + panel1.Controls.Add(label2); + panel1.Controls.Add(label1); + panel1.Controls.Add(swhEnable); + panel1.Controls.Add(label18); + panel1.Dock = DockStyle.Left; + panel1.Location = new Point(0, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(218, 611); + panel1.TabIndex = 48; + panel1.Text = "panel1"; + // + // pictureBox1 + // + pictureBox1.BorderStyle = BorderStyle.FixedSingle; + pictureBox1.Dock = DockStyle.Fill; + pictureBox1.Location = new Point(0, 0); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new Size(691, 552); + pictureBox1.TabIndex = 39; + pictureBox1.TabStop = false; // // CameraControl // AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleMode = AutoScaleMode.Font; - Controls.Add(sltCamType); - Controls.Add(label13); - Controls.Add(sthAllPic); - Controls.Add(label12); - Controls.Add(label11); - Controls.Add(label10); - Controls.Add(label9); - Controls.Add(label8); - Controls.Add(sthPic); - Controls.Add(label6); - Controls.Add(button3); - Controls.Add(button2); - Controls.Add(button1); - Controls.Add(btnSizeAdd); - Controls.Add(pictureBox1); - Controls.Add(iptROIH); - Controls.Add(iptROIW); - Controls.Add(iptROIY); - Controls.Add(iptROIX); - Controls.Add(label7); - Controls.Add(sltTriggerMode); - Controls.Add(label5); - Controls.Add(sltAcquisitionMode); - Controls.Add(label4); - Controls.Add(iptRevolve); - Controls.Add(iptGain); - Controls.Add(iptExposure); - Controls.Add(label3); - Controls.Add(label2); - Controls.Add(label1); - Controls.Add(swhEnable); - Controls.Add(label18); + Controls.Add(panel2); + Controls.Add(panel1); Name = "CameraControl"; - Size = new Size(909, 601); + Size = new Size(909, 611); + panel3.ResumeLayout(false); + panel4.ResumeLayout(false); + panel2.ResumeLayout(false); + panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); ResumeLayout(false); } #endregion - private AntdUI.Switch swhEnable; + private AntdUI.Panel panel3; + private AntdUI.Button button3; + private AntdUI.Button button2; + private AntdUI.Button button1; + private AntdUI.Button btnSizeAdd; + private AntdUI.Panel panel4; + private PictureBox pictureBox1; + private AntdUI.Panel panel2; private AntdUI.Label label18; + private AntdUI.Switch swhEnable; private AntdUI.Label label1; private AntdUI.Label label2; private AntdUI.Label label3; private AntdUI.InputNumber iptExposure; private AntdUI.InputNumber iptGain; - private AntdUI.InputNumber iptRevolve; + private AntdUI.Select iptRevolve; private AntdUI.Label label4; private AntdUI.Select sltAcquisitionMode; private AntdUI.Label label5; private AntdUI.Select sltTriggerMode; private AntdUI.Label label7; - private AntdUI.InputNumber iptROIW; - private AntdUI.InputNumber iptROIY; private AntdUI.InputNumber iptROIX; + private AntdUI.InputNumber iptROIY; + private AntdUI.InputNumber iptROIW; private AntdUI.InputNumber iptROIH; - private PictureBox pictureBox1; - private AntdUI.Button btnSizeAdd; - private AntdUI.Button button1; - private AntdUI.Button button2; - private AntdUI.Button button3; - private AntdUI.Switch sthPic; private AntdUI.Label label6; + private AntdUI.Switch sthPic; private AntdUI.Label label8; private AntdUI.Label label9; private AntdUI.Label label10; private AntdUI.Label label11; - private AntdUI.Switch sthAllPic; private AntdUI.Label label12; - private AntdUI.Select sltCamType; + private AntdUI.Switch sthAllPic; private AntdUI.Label label13; + private AntdUI.Select sltCamType; + private AntdUI.Label label14; + private AntdUI.Switch switch1; + private AntdUI.Panel panel1; } } diff --git a/DHSoftware/Views/CameraControl.cs b/DHSoftware/Views/CameraControl.cs index 0c99e1b..d348e97 100644 --- a/DHSoftware/Views/CameraControl.cs +++ b/DHSoftware/Views/CameraControl.cs @@ -84,7 +84,8 @@ namespace DHSoftware.Views // 启用状态绑定 swhEnable.DataBindings.Add(nameof(swhEnable.Checked), CameraBase, nameof(CameraBase.IsEnabled), true, DataSourceUpdateMode.OnPropertyChanged); - + switch1.DataBindings.Add(nameof(switch1.Checked), CameraBase, nameof(CameraBase.IsZoomCamera), + true, DataSourceUpdateMode.OnPropertyChanged); // 曝光时间绑定(假设iptExposure是NumericUpDown) iptExposure.DataBindings.Add(nameof(iptExposure.Value), CameraBase, nameof(CameraBase.Exposure), true, DataSourceUpdateMode.OnPropertyChanged, 0M, "N2"); @@ -94,7 +95,7 @@ namespace DHSoftware.Views true, DataSourceUpdateMode.OnPropertyChanged, 0M, "N2"); // 旋转角度绑定 - iptRevolve.DataBindings.Add(nameof(iptRevolve.Value), CameraBase, nameof(CameraBase.RotateImage), + iptRevolve.DataBindings.Add(nameof(iptRevolve.Text), CameraBase, nameof(CameraBase.RotateImage), true, DataSourceUpdateMode.OnPropertyChanged, 0M, "N2"); // ROI坐标绑定 @@ -118,6 +119,7 @@ namespace DHSoftware.Views private void InitData() { + iptRevolve.Text = Convert.ToInt32(CameraBase.RotateImage).ToString(); // 获取枚举字段名列表(原描述改为字段名) sltCamType.Items.Clear(); foreach (EnumCamType value in Enum.GetValues(typeof(EnumCamType))) diff --git a/DHSoftware/Views/CameraControl.resx b/DHSoftware/Views/CameraControl.resx index af32865..8b2ff64 100644 --- a/DHSoftware/Views/CameraControl.resx +++ b/DHSoftware/Views/CameraControl.resx @@ -1,7 +1,7 @@