| | |
| | | /// <returns></returns> |
| | | private bool SetAxisParam(MovingOption optionPara) |
| | | { |
| | | List<short> resultCode = new List<short>() { 0 }; |
| | | List<short> resultCode = new List<short>(); |
| | | GTSCardAPI.TTrapPrm trapprm = new GTSCardAPI.TTrapPrm(); |
| | | short axisIndex = short.Parse(optionPara.AxisIndexStr); |
| | | resultCode.Add(GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, axisIndex)); |
| | | |
| | | if (optionPara.VelocityPara.Acc != 0 || optionPara.VelocityPara.Dec != 0) |
| | | { |
| | | resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, axisIndex, out trapprm)); |
| | | trapprm.smoothTime = 1; |
| | | |
| | |
| | | } |
| | | |
| | | resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm)); |
| | | } |
| | | |
| | | if (optionPara.VelocityPara.Velocity != 0) |
| | | { |
| | |
| | | var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK); |
| | | if (!resultOK) |
| | | { |
| | | throw new ProcessException("轴" + optionPara.AxisIndex + "设置参数异常,错误码:" + string.Join(",", resultCode)); |
| | | //throw new ProcessException("轴" + optionPara.AxisIndex + "设置参数异常,错误码:" + string.Join(",", resultCode)); |
| | | LogAsync(DateTime.Now, $"轴{optionPara.AxisIndex}设置参数异常,错误码:{string.Join(",", resultCode)}", ""); |
| | | } |
| | | return resultOK; |
| | | return true; |
| | | } |
| | | |
| | | TaskFactory taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.LongRunning); |
| | |
| | | //imgSet.HImage.GenImage1("int4", (int)width, zoomHeight, zoomPtr); |
| | | imgSet.HImage.GenImage1(IIConfig.ByteNums == GocatorDataByteNums.Byte2 ? "uint2" : "int4", (int)width, zoomHeight, zoomPtr); |
| | | |
| | | imgSet.HImage_2 = imgSet.HImage.Clone(); |
| | | //imgSet.HImage_2 = imgSet.HImage.Clone(); |
| | | //imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); |
| | | //imgSet.HImage_2.GenImage1("int4", (int)width, zoomHeight, zoomPtr); |
| | | //imgSet.HImage_2.GenImage1(IIConfig.ByteNums == GocatorDataByteNums.Byte2 ? "uint2" : "int4", (int)width, zoomHeight, zoomPtr); |
| | | |
| | | imgSet.HImage_2 = new HImage(); |
| | | imgSet.HImage_2.GenImage1(IIConfig.ByteNums == GocatorDataByteNums.Byte2 ? "uint2" : "int4", (int)width, zoomHeight, zoomPtr); |
| | | |
| | | LaserScanParam para = new LaserScanParam() |
| | | { |
| | |
| | | { |
| | | if (opConfig.IsOpenConnection) |
| | | { |
| | | while (sensor.State != GoState.Ready) |
| | | { |
| | | Thread.Sleep(10); |
| | | } |
| | | |
| | | do |
| | | { |
| | | try |
| | | { |
| | | system.Start(); |
| | | if (sensor.State != GoState.Running) |
| | | { |
| | | Thread.Sleep(100); |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(DateTime.Now, $"开启异常:{ex.GetExceptionMessage()}", ""); |
| | | } |
| | | } while (true); |
| | | |
| | | LogAsync(DateTime.Now, $"传感器启动成功", ""); |
| | | } |
| | | |
| | | if (!opConfig.IsSnapshotAction) |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(DateTime.Now, $"{Name}获取图像异常", ex.GetExceptionMessage()); |
| | | return null; |
| | | imgSet.HImage = null; |
| | | dataSet = null; |
| | | //return imgSet; |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (!opConfig.IsOpenConnection) |
| | | { |
| | | while (sensor.State == GoState.Busy) |
| | | { |
| | | Thread.Sleep(100); |
| | | } |
| | | |
| | | do |
| | | { |
| | | try |
| | | { |
| | | system.Stop(); |
| | | |
| | | if (sensor.State != GoState.Ready) |
| | | { |
| | | Thread.Sleep(100); |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(DateTime.Now, $"关闭异常:{ex.GetExceptionMessage()}", ""); |
| | | } |
| | | } while (true); |
| | | |
| | | sensor.Flush(); |
| | | LogAsync(DateTime.Now, $"传感器关闭成功", ""); |
| | | } |
| | | } |
| | | |
| | | if (dataSet != null) |
| | | { |
| | | HandleGoData(dataSet, imgSet); |
| | | |
| | | dataSet.Dispose(); |
| | |
| | | if (imgSet.HImage == null) |
| | | { |
| | | LogAsync(DateTime.Now, $"{Name}未能获取HImage图像", ""); |
| | | } |
| | | } |
| | | |
| | | return imgSet; |
| | |
| | | { |
| | | base.Start(); |
| | | |
| | | //system.Start(); |
| | | |
| | | if (IIConfig.IsAsyncMode) |
| | | system.Start(); |
| | | } |
| | |
| | | Measurements?.ForEach(m => m?.Dispose()); |
| | | Measurements = null; |
| | | ElementList = null; |
| | | Barcode = null; |
| | | //Barcode = null; |
| | | GC.Collect(); |
| | | } |
| | | |
| | |
| | | } |
| | | #endregion |
| | | |
| | | object productionLock = new object(); |
| | | List<ProductionMeasurement> productionList = new List<ProductionMeasurement>(); |
| | | |
| | | [ProcessMethod("", "StartJob", "开始扫描", InvokeType.TestInvoke)] |
| | |
| | | } |
| | | |
| | | string hint = ""; |
| | | if (MachineState != MachineState.Ready) |
| | | { |
| | | hint = "机台未就绪,请勿开始测量"; |
| | | OnCheckHintUpload?.Invoke(hint, true); |
| | | throw new ProcessException(hint, null, ExceptionLevel.Warning); |
| | | } |
| | | //if (MachineState != MachineState.Ready) |
| | | //{ |
| | | // hint = "机台未就绪,请勿开始测量"; |
| | | // OnCheckHintUpload?.Invoke(hint, true); |
| | | // throw new ProcessException(hint, null, ExceptionLevel.Warning); |
| | | //} |
| | | |
| | | if (string.IsNullOrWhiteSpace(BarCode)) |
| | | { |
| | |
| | | |
| | | BarCode = ""; |
| | | |
| | | lock (productionLock) |
| | | { |
| | | var existedProduction = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode); |
| | | if (existedProduction != null) |
| | | { |
| | |
| | | } |
| | | |
| | | productionList.Add(pMeasure); |
| | | } |
| | | |
| | | pMeasure.InitialMeasurementsPropertyChanged(); |
| | | pMeasure.PropertyChanged += MeasureProduction_PropertyChanged; |
| | |
| | | { |
| | | if (sender is ProductionMeasurement pMeasure) |
| | | { |
| | | var production = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode); |
| | | ProductionMeasurement production = null; |
| | | lock (productionLock) |
| | | { |
| | | production = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode); |
| | | if (production == null) |
| | | return; |
| | | } |
| | | |
| | | lock (production) |
| | | { |
| | |
| | | |
| | | SaveWholeImage(pMeasure); |
| | | |
| | | lock (productionLock) |
| | | { |
| | | productionList.RemoveAll(p => p.Barcode == pMeasure.Barcode); |
| | | } |
| | | pMeasure.Dispose(); |
| | | //LogAsync(DateTime.Now, $"{pMeasure.Barcode}产品信息释放完成", JsonConvert.SerializeObject(pMeasure)); |
| | | } |
| | |
| | | var keys = Config.KeyUnitCollection.Where(u => u.IsEnabled && u.SnapshotPointId == snapshotId); |
| | | var keyBindCollection = measureList.SelectMany(u => u.KeyUnitCollection).Where(u => keys.Any(k => k.Key == u.Key)).ToList(); |
| | | |
| | | if (imgSet.HImage == null) |
| | | { |
| | | LogAsync(DateTime.Now, $"{snapshotName}未获取扫描图像", ""); |
| | | keyBindCollection.ForEach(k => k.FillKeyValues(null)); |
| | | return; |
| | | } |
| | | |
| | | string toolKey = (opConfig as CameraOprerationConfigBase).AlgorithemPath; |
| | | |
| | | HObject images = new HObject(); |
| | |
| | | if (machineState == value) |
| | | return; |
| | | |
| | | LogAsync(DateTime.Now, $"设备状态切换:{machineState.ToString()}->{value.ToString()}", ""); |
| | | machineState = value; |
| | | |
| | | Task.Run(() => |
| | |
| | | |
| | | RaisedAlarm(""); |
| | | |
| | | if (MachineState != MachineState.Pause) |
| | | { |
| | | //if (MachineState != MachineState.Pause) |
| | | //{ |
| | | MachineState = MachineState.Ready; |
| | | } |
| | | else |
| | | { |
| | | LogAsync(DateTime.Now, "设备暂停中,无法复位", ""); |
| | | return new ProcessResponse(true); |
| | | } |
| | | //} |
| | | //else |
| | | //{ |
| | | // LogAsync(DateTime.Now, "设备暂停中,无法复位", ""); |
| | | // return new ProcessResponse(true); |
| | | //} |
| | | |
| | | if (IsEmergencyStopped) |
| | | { |
| | |
| | | MachineState = MachineState.Resetting; |
| | | MotionCardDefaultRun("FullReset", ref opConfig, ref invokeDevice); |
| | | |
| | | lock (productionLock) |
| | | { |
| | | productionList.ForEach(u => u.Dispose()); |
| | | productionList.Clear(); |
| | | } |
| | | |
| | | OnFullResetDone?.Invoke(); |
| | | |