领胜LDS 键盘AOI检测项目
patrick.xu
2021-02-20 78289c64a16dd02cc9fec595bf758a9e30a30926
src/Bro.M071.Process/M071Process.cs
@@ -199,9 +199,9 @@
        List<ProductionMeasurement> productionList = new List<ProductionMeasurement>();
        bool _isdoing = false;
        object _doingLock = new object();
        [ProcessMethod("", "StartJob", "开始扫描", InvokeType.TestInvoke)]
        [MethodImpl(MethodImplOptions.Synchronized)]
        public ProcessResponse StartJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
        {
            if (!IsAllowedWork)
@@ -226,7 +226,16 @@
                throw new ProcessException(hint);
            }
            _isdoing = true;
            lock (_doingLock)
            {
                if (_isdoing)
                {
                    LogAsync(DateTime.Now, "设备正在运行中", "");
                    return new ProcessResponse(true);
                }
                _isdoing = true;
            }
            MachineState = MachineState.Running;
@@ -272,7 +281,9 @@
            pMeasure.InitialMeasurementsPropertyChanged();
            pMeasure.PropertyChanged += MeasureProduction_PropertyChanged;
            Config.SnapshotPointCollection.Where(u => u.IsEnabled).ToList().ForEach(s =>
            try
            {
                Config.SnapshotPointCollection.Where(u => u.IsEnabled).ToList().ForEach(s =>
                  {
                      _pausedHandle.Wait();
@@ -321,26 +332,42 @@
                      RunImageHandle(s.CameraOp.OpConfig, set, s.Id, s.Name, pMeasure.Measurements);
                  });
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                LogAsync(DateTime.Now, $"{pMeasure.Barcode}测量动作完成", "");
                _isdoing = false;
            LogAsync(DateTime.Now, $"{pMeasure.Barcode}测量动作完成", "");
            _isdoing = false;
            GC.Collect(0, GCCollectionMode.Optimized);
                GC.Collect(0, GCCollectionMode.Optimized);
            }
            return new ProcessResponse(true);
        }
        #region 双手启动
        object _leftStartLock = new object();
        object _rightStartLock = new object();
        bool isLeftStart = false;
        bool IsLeftStart
        {
            get => isLeftStart;
            set
            {
                if (IsLeftStart != value)
                if (isLeftStart != value)
                {
                    isLeftStart = value;
                    StartCheck();
                    lock (_leftStartLock)
                    {
                        if (IsLeftStart != value)
                        {
                            isLeftStart = value;
                            StartCheck();
                        }
                    }
                }
            }
        }
@@ -353,14 +380,21 @@
            {
                if (isRightStart != value)
                {
                    isRightStart = value;
                    StartCheck();
                    lock (_rightStartLock)
                    {
                        if (isRightStart != value)
                        {
                            isRightStart = value;
                            StartCheck();
                        }
                    }
                }
            }
        }
        private void StartCheck()
        {
            if (isRightStart && isLeftStart)
            {
                if (_isdoing)