领胜LDS 键盘AOI检测项目
1个文件已添加
6个文件已修改
198 ■■■■■ 已修改文件
src/Bro.Common.Device/DeviceBase/CameraBase.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/Model/LaserScanParam.cs 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/Bro.M071.Process.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Config.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Converters.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Process.cs 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Process_OfflineTest.cs 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Device/DeviceBase/CameraBase.cs
@@ -785,7 +785,7 @@
        [Category("图片保存")]
        [Description("是否保存原始图片")]
        [DisplayName("保存原始图片")]
        public bool IsSaveOriginImage { get; set; } = true;
        public bool IsSaveOriginImage { get; set; } = false;
        [Category("图片保存")]
        [Description("图片保存格式")]
src/Bro.Common.Model/Model/LaserScanParam.cs
@@ -1,4 +1,5 @@
using System;
using Bro.Common.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,7 +7,7 @@
namespace Bro.Common.Model
{
    public class LaserScanParam
    public class LaserScanParam : IComplexDisplay
    {
        public int Resolution_X { get; set; }
        public int Resolution_Y { get; set; }
@@ -17,5 +18,15 @@
        public int Offset_Z { get; set; }
        public int Angle_Z { get; set; }
        public override string ToString()
        {
            return GetDisplayText();
        }
        public string GetDisplayText()
        {
            return $"Resolution:{Resolution_X},{Resolution_Y},{Resolution_Z}; Offset:{Offset_X},{Offset_Y},{Offset_Z}; Angel_Z:{Angle_Z}";
        }
    }
}
src/Bro.M071.Process/Bro.M071.Process.csproj
@@ -123,6 +123,7 @@
    <Compile Include="M071Process.cs" />
    <Compile Include="M071Process_MES.cs" />
    <Compile Include="M071Process_MotionCard.cs" />
    <Compile Include="M071Process_OfflineTest.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="UI\KeyIndicator.cs" />
    <Compile Include="UI\M071Node.cs" />
src/Bro.M071.Process/M071Config.cs
@@ -42,6 +42,11 @@
        public List<KeyResult> KeyResultCollection { get; set; } = new List<KeyResult>();
        #endregion
        [Category("离线测试模式")]
        [Description("true:设备离线模式  false:设备连线模式")]
        [DisplayName("离线模式")]
        public bool IsOfflineMode { get; set; } = false;
        [Category("显示配置")]
        [Description("运行背景图片路径")]
        [Editor(typeof(FileDialogEditor), typeof(UITypeEditor))]
src/Bro.M071.Process/M071Converters.cs
@@ -1,4 +1,5 @@
using Autofac;
using Bro.Common.Base;
using Bro.Common.Helper;
using Bro.Common.Interface;
using Bro.Common.Model;
@@ -51,7 +52,13 @@
                {
                    config.SnapshotPointCollection.Where(u => u.IsEnabled).ToList().ForEach(s =>
                      {
                          table[s.Id] = s.Name;
                          if (s.CameraOp?.OpConfig is CameraOprerationConfigBase cameraOpConfig)
                          {
                              if (!string.IsNullOrWhiteSpace(cameraOpConfig?.AlgorithemPath))
                              {
                                  table[s.Id] = s.Name;
                              }
                          }
                      });
                }
            }
src/Bro.M071.Process/M071Process.cs
@@ -58,25 +58,31 @@
        {
            InitialSetting();
            base.Open();
            if (!Config.IsOfflineMode)
            {
                base.Open();
            InitialMotionCardBaseAxisAlarm();
                InitialMotionCardBaseAxisAlarm();
            SwitchBeep(false);
            SwitchLightGreen(false);
            SwitchLightRed(false);
            SwitchLightYellow(false);
                SwitchBeep(false);
                SwitchLightGreen(false);
                SwitchLightRed(false);
                SwitchLightYellow(false);
            Reset(null, null, null);
            FullReset(null);
                Reset(null, null, null);
                FullReset(null);
            }
            if (Config.Precision > 0)
            {
                _precision = "f" + Config.Precision;
            }
            IncomingCheckMethod = InitialMESWebServiceMethod(IncomingCheckMethodName, out IncomingCheckObj);
            DataUploadMethod = InitialMESWebServiceMethod(DataUploadMethodName, out DataUploadObj);
            if (Config.IsEnableMESUpload)
            {
                IncomingCheckMethod = InitialMESWebServiceMethod(IncomingCheckMethodName, out IncomingCheckObj);
                DataUploadMethod = InitialMESWebServiceMethod(DataUploadMethodName, out DataUploadObj);
            }
            var allowedShiftStr = ConfigurationManager.AppSettings["DataShift"];
            if (!double.TryParse(allowedShiftStr, out _allowedShift))
@@ -1438,8 +1444,15 @@
                            keyBindList.ForEach(kb =>
                            {
                                kb.KeyImages.Add(image.ConvertHObjectToHImage());
                                kb.FillKeyValues(resultDict);
                                if (kb.KeyImages != null)
                                {
                                    kb.KeyImages.Add(image.ConvertHObjectToHImage());
                                    kb.FillKeyValues(resultDict);
                                }
                                else
                                {
                                }
                            });
                        });
src/Bro.M071.Process/M071Process_OfflineTest.cs
New file
@@ -0,0 +1,129 @@
using Autofac;
using Bro.Common.Base;
using Bro.Common.Helper;
using Bro.Common.Interface;
using Bro.Common.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bro.M071.Process
{
    public partial class M071Process
    {
        [ProcessMethod("OfflineTest", "OfflineTest", "离线测试", InvokeType.TestInvoke)]
        public ProcessResponse OfflineTest(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
        {
            if (opConfig is OfflineTestOpConfig config)
            {
                if (config.SnapshotConfigs.Count > 0)
                {
                    OnMeasureStart?.Invoke();
                    List<MeasurementUnit> measurements = new List<MeasurementUnit>();
                    Config.MeasurementUnitCollection.Where(u => u.IsEnabled).ToList().ForEach(u =>
                    {
                        var m = u.Copy();
                        m.InitialKeyUnitMeasureChanged();
                        measurements.Add(m);
                    });
                    var pMeasure = new ProductionMeasurement()
                    {
                        Barcode = $"OfflineTest_{DateTime.Now.ToString("HHmmss")}",
                        Measurements = measurements,
                        StartTime = DateTime.Now,
                    };
                    lock (productionLock)
                    {
                        var existedProduction = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode);
                        if (existedProduction != null)
                        {
                            productionList.Remove(existedProduction);
                            existedProduction.Dispose();
                            existedProduction = null;
                        }
                        productionList.Add(pMeasure);
                    }
                    pMeasure.InitialMeasurementsPropertyChanged();
                    pMeasure.PropertyChanged += MeasureProduction_PropertyChanged;
                    config.SnapshotConfigs.ForEach(s =>
                    {
                        ImageSet set = new ImageSet();
                        set.HImage = new HalconDotNet.HImage(s.OfflineImageFilePath);
                        set.ImageData = JsonConvert.SerializeObject(config.ScanParam);
                        var snapshotConfig = Config.SnapshotPointCollection.FirstOrDefault(u => u.Id == s.SnapshotPointId);
                        RunImageHandle(snapshotConfig.CameraOp.OpConfig, set, snapshotConfig.Id, snapshotConfig.Name, pMeasure.Measurements);
                    });
                }
            }
            return new ProcessResponse(true);
        }
    }
    [Device("OfflineTest", "离线测试操作配置", EnumHelper.DeviceAttributeType.OperationConfig)]
    public class OfflineTestOpConfig : OperationConfigBase
    {
        [Category("取像设置")]
        [Description("取像设置")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<OfflineSnapshotPoint>), typeof(UITypeEditor))]
        public List<OfflineSnapshotPoint> SnapshotConfigs { get; set; } = new List<OfflineSnapshotPoint>();
        //[Category("离线图像目录")]
        //[Description("离线图片文件目录,目前只支持一级文件目录,该目录包含且仅包含一次完整测试需要的图片")]
        //[Editor(typeof(FoldDialogEditor),typeof(UITypeEditor))]
        //public string OfflineImageFolder { get; set; }
        [Category("扫描图像参数")]
        [Description("扫描图像参数")]
        [TypeConverter(typeof(ExpandableObjectConverter))]
        public LaserScanParam ScanParam { get; set; } = new LaserScanParam();
    }
    public class OfflineSnapshotPoint : IComplexDisplay
    {
        [Category("取像点位及配置")]
        [TypeConverter(typeof(SnapshotPointConverter))]
        public string SnapshotPointId { get; set; }
        [Category("离线图像文件")]
        [Editor(typeof(FileDialogEditor), typeof(UITypeEditor))]
        public string OfflineImageFilePath { get; set; }
        public string GetDisplayText()
        {
            string snapshotPointName = "";
            using (var scope = GlobalVar.Container.BeginLifetimeScope())
            {
                var config = scope.Resolve<IProcessConfig>() as M071Config;
                if (config != null)
                {
                    snapshotPointName = config.SnapshotPointCollection.FirstOrDefault(u => u.Id == SnapshotPointId)?.Name;
                }
            }
            if (string.IsNullOrWhiteSpace(snapshotPointName))
            {
                snapshotPointName = "未指定";
            }
            return snapshotPointName;
        }
    }
}