| | |
| | | |
| | | string _precision = "f3"; |
| | | |
| | | |
| | | public override void Open() |
| | | { |
| | | InitialSetting(); |
| | |
| | | { |
| | | _precision = "f" + Config.Precision; |
| | | } |
| | | |
| | | IncomingCheckMethod = InitialMESWebServiceMethod(IncomingCheckMethodName, out IncomingCheckObj); |
| | | DataUploadMethod = InitialMESWebServiceMethod(DataUploadMethodName, out DataUploadObj); |
| | | } |
| | | |
| | | private void InitialMotionCardBaseAxisAlarm() |
| | |
| | | } |
| | | #endregion |
| | | |
| | | public string BarCode { get; set; } |
| | | |
| | | List<ProductionMeasurement> productionList = new List<ProductionMeasurement>(); |
| | | |
| | | [ProcessMethod("", "StartJob", "开始扫描", InvokeType.TestInvoke)] |
| | |
| | | throw new ProcessException(SafetyMsg, null, ExceptionLevel.Fatal); |
| | | } |
| | | |
| | | string hint = ""; |
| | | if (MachineState != MachineState.Ready) |
| | | throw new ProcessException("机台未就绪,请勿开始测量", null, ExceptionLevel.Fatal); |
| | | { |
| | | hint = "机台未就绪,请勿开始测量"; |
| | | OnCheckHintUpload?.Invoke(hint, true); |
| | | throw new ProcessException(hint, null, ExceptionLevel.Fatal); |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(BarCode)) |
| | | { |
| | | hint = "未输入产品条码,请勿开始测量"; |
| | | OnClearBarcode?.Invoke(); |
| | | throw new ProcessException("未输入产品条码,请勿开始测量"); |
| | | OnCheckHintUpload?.Invoke(hint, true); |
| | | throw new ProcessException(hint); |
| | | } |
| | | |
| | | MachineState = MachineState.Running; |
| | | |
| | | OnCheckHintUpload?.Invoke(hint, true); |
| | | OnMeasureStart?.Invoke(); |
| | | |
| | | //var measurements = Config.MeasurementUnitCollection.Where(u => u.IsEnabled).ToList().DeepSerializeClone(); |
| | |
| | | }); |
| | | |
| | | LogAsync(DateTime.Now, $"{pMeasure.Barcode}测量动作完成", ""); |
| | | |
| | | |
| | | GC.Collect(0, GCCollectionMode.Optimized); |
| | | |
| | | return new ProcessResponse(true); |
| | |
| | | { |
| | | if (m.KeyUnitCollection.Any(k => k.IsDone == false)) |
| | | { |
| | | m.Spec.ActualValue = -999; |
| | | //m.Spec.ActualValue = -999; |
| | | m.Spec.ActualValue = null; |
| | | } |
| | | else |
| | | { |
| | |
| | | if (!_halconToolDict.ContainsKey(toolKey)) |
| | | { |
| | | LogAsync(DateTime.Now, $"{m.GetDisplayText()}{m.Spec.Code}算法未初始化", ""); |
| | | m.Spec.ActualValue = -999; |
| | | //m.Spec.ActualValue = -999; |
| | | m.Spec.ActualValue = null; |
| | | } |
| | | else |
| | | { |
| | |
| | | if (array == null || array.Length == 0) |
| | | { |
| | | LogAsync(DateTime.Now, $"{m.GetDisplayText()}{m.Spec.Code}未能获取对应检测值", ""); |
| | | m.Spec.ActualValue = -999; |
| | | //m.Spec.ActualValue = -999; |
| | | m.Spec.ActualValue = null; |
| | | } |
| | | else |
| | | { |
| | |
| | | if (!_halconToolDict[toolKey].RunProcedure(out string error)) |
| | | { |
| | | LogAsync(DateTime.Now, $"{m.GetDisplayText()}{m.Spec.Code}算法异常,{error}", ""); |
| | | m.Spec.ActualValue = -999; |
| | | //m.Spec.ActualValue = -999; |
| | | m.Spec.ActualValue = null; |
| | | } |
| | | else |
| | | { |
| | |
| | | //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 || 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); |
| | | //输出图形基元到界面 |
| | |
| | | } |
| | | |
| | | pMeasure.EndTime = DateTime.Now; |
| | | bool pResult = pMeasure.Measurements.All(u => u.Spec.MeasureResult == true); |
| | | pMeasure.PResult = pResult ? "OK" : "NG"; |
| | | OnUpdateResult?.Invoke(DateTime.Now, pResult ? 1 : 0); |
| | | //bool pResult = pMeasure.Measurements.All(u => u.Spec.MeasureResult == true); |
| | | //pMeasure.PResult = pResult ? "OK" : "NG"; |
| | | //OnUpdateResult?.Invoke(DateTime.Now, pResult ? 1 : 0); |
| | | //OnUpdateCT?.Invoke((float)(pMeasure.EndTime.Value - pMeasure.StartTime.Value).TotalSeconds); |
| | | |
| | | int result = -1; |
| | | if (pMeasure.Measurements.Any(u => u.Spec.MeasureResult == null)) |
| | | { |
| | | pMeasure.PResult = "NA"; |
| | | } |
| | | else if (pMeasure.Measurements.Any(u => u.Spec.MeasureResult == false)) |
| | | { |
| | | pMeasure.PResult = "NG"; |
| | | result = 0; |
| | | } |
| | | else |
| | | { |
| | | pMeasure.PResult = "OK"; |
| | | result = 1; |
| | | } |
| | | OnUpdateResult?.Invoke(DateTime.Now, result); |
| | | OnUpdateCT?.Invoke((float)(pMeasure.EndTime.Value - pMeasure.StartTime.Value).TotalSeconds); |
| | | |
| | | LogAsync(DateTime.Now, $"{pMeasure.Barcode} 检测完成,结果 {pMeasure.PResult}", ""); |
| | |
| | | |
| | | var measurementUnitResultAndKeyUnitDataSet = GetMeasurementUnitResultAndKeyUnitData(pMeasure); |
| | | |
| | | //MES输出 todo |
| | | if (Config.IsEnableMESUpload) |
| | | if (pMeasure.PResult != "NA") |
| | | { |
| | | //MES输出 |
| | | MESCheckDataUpload(pMeasure); |
| | | } |
| | | |
| | | //Excel报表输出 (单个产品的excel导出) |
| | |
| | | if (slantMeasures.Count > 0) |
| | | { |
| | | int slantStartCol = slantSheet.Dimension.Columns; |
| | | |
| | | |
| | | var barcodeCell = slantSheet.Cells[1, slantStartCol + 1]; |
| | | barcodeCell.Value = exportData.ProductionMeasurementRecord.ProductionBarcode; |
| | | SetTitleCell(barcodeCell); |