| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Configuration; |
| | | using System.Drawing; |
| | | using System.Drawing.Imaging; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Runtime.CompilerServices; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | |
| | | public event Action<IShapeElement> OnElementUpdated; |
| | | public event Action<MachineState> OnMachineStateChanged; |
| | | public event Action OnFullResetDone; |
| | | public event Action OnResetDone; |
| | | #endregion |
| | | |
| | | string _precision = "f3"; |
| | | double _allowedShift = 0; |
| | | |
| | | public override void Open() |
| | | { |
| | |
| | | |
| | | IncomingCheckMethod = InitialMESWebServiceMethod(IncomingCheckMethodName, out IncomingCheckObj); |
| | | DataUploadMethod = InitialMESWebServiceMethod(DataUploadMethodName, out DataUploadObj); |
| | | |
| | | var allowedShiftStr = ConfigurationManager.AppSettings["DataShift"]; |
| | | if (!double.TryParse(allowedShiftStr, out _allowedShift)) |
| | | { |
| | | _allowedShift = 0; |
| | | } |
| | | } |
| | | |
| | | private void InitialMotionCardBaseAxisAlarm() |
| | |
| | | } |
| | | #endregion |
| | | |
| | | object productionLock = new object(); |
| | | List<ProductionMeasurement> productionList = new List<ProductionMeasurement>(); |
| | | |
| | | bool _isdoing = false; |
| | | |
| | | [ProcessMethod("", "StartJob", "开始扫描", InvokeType.TestInvoke)] |
| | | [MethodImpl(MethodImplOptions.Synchronized)] |
| | | public ProcessResponse StartJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | if (!IsAllowedWork) |
| | |
| | | } |
| | | |
| | | string hint = ""; |
| | | if (MachineState != MachineState.Ready) |
| | | { |
| | | hint = "机台未就绪,请勿开始测量"; |
| | | OnCheckHintUpload?.Invoke(hint, true); |
| | | throw new ProcessException(hint, null, ExceptionLevel.Fatal); |
| | | } |
| | | |
| | | //if (MachineState != MachineState.Ready) |
| | | //{ |
| | | // hint = "机台未就绪,请勿开始测量"; |
| | | // OnCheckHintUpload?.Invoke(hint, true); |
| | | // throw new ProcessException(hint, null, ExceptionLevel.Warning); |
| | | //} |
| | | |
| | | if (string.IsNullOrWhiteSpace(BarCode)) |
| | | { |
| | |
| | | OnCheckHintUpload?.Invoke(hint, true); |
| | | throw new ProcessException(hint); |
| | | } |
| | | |
| | | _isdoing = true; |
| | | |
| | | MachineState = MachineState.Running; |
| | | |
| | |
| | | |
| | | BarCode = ""; |
| | | |
| | | var existedProduction = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode); |
| | | if (existedProduction != null) |
| | | lock (productionLock) |
| | | { |
| | | productionList.Remove(existedProduction); |
| | | existedProduction.Dispose(); |
| | | existedProduction = null; |
| | | } |
| | | var existedProduction = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode); |
| | | if (existedProduction != null) |
| | | { |
| | | productionList.Remove(existedProduction); |
| | | existedProduction.Dispose(); |
| | | existedProduction = null; |
| | | } |
| | | |
| | | productionList.Add(pMeasure); |
| | | productionList.Add(pMeasure); |
| | | } |
| | | |
| | | pMeasure.InitialMeasurementsPropertyChanged(); |
| | | pMeasure.PropertyChanged += MeasureProduction_PropertyChanged; |
| | |
| | | }); |
| | | |
| | | LogAsync(DateTime.Now, $"{pMeasure.Barcode}测量动作完成", ""); |
| | | _isdoing = false; |
| | | |
| | | GC.Collect(0, GCCollectionMode.Optimized); |
| | | |
| | |
| | | get => isLeftStart; |
| | | set |
| | | { |
| | | isLeftStart = value; |
| | | StartCheck(); |
| | | if (IsLeftStart != value) |
| | | { |
| | | isLeftStart = value; |
| | | StartCheck(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | get => isRightStart; |
| | | set |
| | | { |
| | | isRightStart = value; |
| | | StartCheck(); |
| | | if (isRightStart != value) |
| | | { |
| | | isRightStart = value; |
| | | StartCheck(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (isRightStart && isLeftStart) |
| | | { |
| | | if (_isdoing) |
| | | { |
| | | OnCheckHintUpload?.Invoke("设备运行中", false); |
| | | return; |
| | | } |
| | | StartJob(null, null, null); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (sender is ProductionMeasurement pMeasure) |
| | | { |
| | | var production = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode); |
| | | if (production == null) |
| | | return; |
| | | ProductionMeasurement production = null; |
| | | lock (productionLock) |
| | | { |
| | | production = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode); |
| | | if (production == null) |
| | | return; |
| | | } |
| | | |
| | | lock (production) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | m.Spec.ActualValue = double.Parse(_halconToolDict[toolKey].GetResultTuple("OUTPUT_Result").D.ToString(_precision)); |
| | | //LogAsync(DateTime.Now, $"{m.GetDisplayText()}数据{m.Spec.ActualValue},结果{(m.Spec.MeasureResult == null ? "TBD" : (m.Spec.MeasureResult == true ? "OK" : "NG"))}", ""); |
| | | double actualValue = double.Parse(_halconToolDict[toolKey].GetResultTuple("OUTPUT_Result").D.ToString(_precision)); |
| | | m.Spec.ActualValue = actualValue; |
| | | |
| | | //M071要求超限数据在允许范围内压缩到合格范围内 |
| | | if (_allowedShift > 0 && m.Spec.MeasureResult != null && m.Spec.MeasureResult.Value == false) |
| | | { |
| | | m.Spec.ActualValue = m.Spec.StandardValue + (actualValue - m.Spec.StandardValue) * (m.Spec.Tolrenance_Positive - m.Spec.StandardValue) / (m.Spec.Tolrenance_Positive - m.Spec.StandardValue + _allowedShift); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //LogAsync(DateTime.Now, $"{m.GetDisplayText()}检测结果", $"{((m.Spec.MeasureResult ?? false) ? "OK" : "NG")}"); |
| | | |
| | | KeyIndicator indicator = new KeyIndicator(m.Id, m.DisplayLocation); |
| | | //indicator.Text = (m.Spec.ActualValue == null || m.Spec.ActualValue == -999) ? "NA" : m.Spec.ActualValue.Value.ToString(_precision); |
| | | indicator.Text = m.Spec.ActualValue == null ? "NA" : m.Spec.ActualValue.Value.ToString(_precision); |
| | | indicator.ResultState = m.Spec.MeasureResult; |
| | | pMeasure.ElementList.Add(indicator); |
| | |
| | | |
| | | LogAsync(DateTime.Now, $"{pMeasure.Barcode} 检测完成,结果 {pMeasure.PResult}", ""); |
| | | |
| | | if (MachineState == MachineState.Running) |
| | | MachineState = MachineState.Ready; |
| | | //if (MachineState == MachineState.Running) |
| | | // MachineState = MachineState.Ready; |
| | | |
| | | if (MachineState != MachineState.Alarm) |
| | | { |
| | | if (MachineState == MachineState.Pause) |
| | | { |
| | | _machineStateBeforePause = MachineState.Ready; |
| | | } |
| | | else |
| | | { |
| | | MachineState = MachineState.Ready; |
| | | } |
| | | } |
| | | |
| | | var measurementUnitResultAndKeyUnitDataSet = GetMeasurementUnitResultAndKeyUnitData(pMeasure); |
| | | |
| | |
| | | |
| | | SaveWholeImage(pMeasure); |
| | | |
| | | productionList.RemoveAll(p => p.Barcode == pMeasure.Barcode); |
| | | lock (productionLock) |
| | | { |
| | | productionList.RemoveAll(p => p.Barcode == pMeasure.Barcode); |
| | | } |
| | | pMeasure.Dispose(); |
| | | //LogAsync(DateTime.Now, $"{pMeasure.Barcode}产品信息释放完成", JsonConvert.SerializeObject(pMeasure)); |
| | | } |
| | |
| | | measurementUnitResult.ProductionBarcode = productionMeasurementRecords.ProductionBarcode; |
| | | measurementUnitResult.MeasurementName = measurementUnit.GetDisplayText(); |
| | | |
| | | if (measurementUnit.MeasureType == "Alignment" || measurementUnit.MeasureType == "Slant") |
| | | if (measurementUnit.MeasureType.StartsWith("Alignment") || measurementUnit.MeasureType.StartsWith("Slant")) |
| | | { |
| | | measurementUnitResult.Keys = string.Join("-", measurementUnit.KeyUnitCollection.Select(u => u.Key)); |
| | | measurementUnitResult.Positions = string.Join("-", measurementUnit.KeyUnitCollection.Select(u => u.KeyResultId)); |
| | | } |
| | | else if (measurementUnit.MeasureType == "RowAlignment") |
| | | else if (measurementUnit.MeasureType.StartsWith("RowAlignment")) |
| | | { |
| | | measurementUnitResult.Keys = measurementUnit.KeyUnitCollection[0].Key + "~" + measurementUnit.KeyUnitCollection[measurementUnit.KeyUnitCollection.Count() - 1].Key; |
| | | measurementUnitResult.Keys = measurementUnit.KeyUnitCollection[0].KeyResultId + "~" + measurementUnit.KeyUnitCollection[measurementUnit.KeyUnitCollection.Count() - 1].KeyResultId; |
| | | } |
| | | measurementUnitResult.MeasurementType = measurementUnit.MeasureType; |
| | | measurementUnitResult.MeasurementValue = measurementUnit.Spec.ActualValue == null ? "NA" : measurementUnit.Spec.ActualValue.Value.ToString(_precision); |
| | | measurementUnitResult.MeasurementResult = measurementUnit.Spec.MeasureResult.Value ? "OK" : "NG"; |
| | | measurementUnitResult.MeasurementResult = measurementUnit.Spec.MeasureResult == null ? "NA" : measurementUnit.Spec.MeasureResult.Value ? "OK" : "NG"; |
| | | |
| | | measurementUnitResults.Add(measurementUnitResult); |
| | | |
| | |
| | | positionCell.Value = "Positions"; |
| | | SetTitleCell(positionCell); |
| | | |
| | | var alignmentMeasures = exportData.MeasurementUnitResultList.Where(u => u.MeasurementType == "Alignment").ToList(); |
| | | var alignmentMeasures = exportData.MeasurementUnitResultList.Where(u => u.MeasurementType.StartsWith("Alignment")).ToList(); |
| | | for (int i = 0; i < alignmentMeasures.Count(); i++) |
| | | { |
| | | var cellKeys = alignmentSheet.Cells[i + 3, 1]; |
| | |
| | | positionCell.Value = "Positions"; |
| | | SetTitleCell(positionCell); |
| | | |
| | | var rowAlignmentMeasures = exportData.MeasurementUnitResultList.Where(u => u.MeasurementType == "RowAlignment").ToList(); |
| | | var rowAlignmentMeasures = exportData.MeasurementUnitResultList.Where(u => u.MeasurementType.StartsWith("RowAlignment")).ToList(); |
| | | for (int i = 0; i < rowAlignmentMeasures.Count(); i++) |
| | | { |
| | | var cellKeys = rowAlignmentSheet.Cells[i + 3, 1]; |
| | |
| | | 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 = imgSet.HImage; |
| | | |
| | | HObject images = new HObject(); |
| | | LaserScanParam scanParam = JsonConvert.DeserializeObject<LaserScanParam>(imgSet.ImageData); |