| | |
| | | { |
| | | 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)) |
| | |
| | | _isdoing = true; |
| | | } |
| | | |
| | | MachineState = MachineState.Running; |
| | | MeasureState = MachineState = MachineState.Running; |
| | | |
| | | OnCheckHintUpload?.Invoke(hint, true); |
| | | OnMeasureStart?.Invoke(); |
| | |
| | | |
| | | return new ProcessResponse(); |
| | | } |
| | | |
| | | [ProcessMethod("KeyUnitGenerate", "GenerateKeyUnitByKeyNames", "生成单键配置", InvokeType.TestInvoke)] |
| | | public ProcessResponse GenerateKeyUnitByKeyNames(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | if (opConfig is KeyUnitGenerateConfig config) |
| | | { |
| | | int i = 1; |
| | | bool isStart = false; |
| | | bool isEnd = false; |
| | | foreach (string k in Config.KeyNameCollection) |
| | | { |
| | | if (k == config.StartKey) |
| | | { |
| | | isStart = true; |
| | | } |
| | | else if (k == config.EndKey) |
| | | { |
| | | isEnd = true; |
| | | } |
| | | |
| | | if (isStart) |
| | | { |
| | | KeyUnit unit = new KeyUnit(); |
| | | unit.Key = unit.AliasName = k; |
| | | unit.SnapshotPointId = config.SnapshotPointId; |
| | | unit.KeyAlgorithemId = config.KeyAlgorithemId; |
| | | unit.KeyResultId = config.KeyResultId; |
| | | unit.ImageSeq = i; |
| | | |
| | | Config.KeyUnitCollection.Add(unit); |
| | | i++; |
| | | } |
| | | |
| | | if (isEnd) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return new ProcessResponse(true); |
| | | } |
| | | #endregion |
| | | |
| | | #region 私有方法 |
| | |
| | | } |
| | | else |
| | | { |
| | | |
| | | _halconToolDict[toolKey].InputTupleDic["INPUT_Params"] = new HTuple(array); |
| | | if (!_halconToolDict[toolKey].RunProcedure(out string error)) |
| | | { |
| | |
| | | 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) |
| | | if (m.MeasureType.ToLower() == "alignment" || m.MeasureType.ToLower() == "slant") |
| | | { |
| | | 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); |
| | | //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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (m.Spec?.ActualValue != null) |
| | | { |
| | | LogAsync(DateTime.Now, $"{m.Name}检测结果{m.Spec.ActualValue.Value.ToString(_precision)}", ""); |
| | | } |
| | | |
| | | KeyIndicator indicator = new KeyIndicator(m.Id, m.DisplayLocation); |
| | |
| | | //if (MachineState == MachineState.Running) |
| | | // MachineState = MachineState.Ready; |
| | | |
| | | MeasureState = MachineState.Ready; |
| | | if (MachineState != MachineState.Alarm) |
| | | { |
| | | if (MachineState == MachineState.Pause) |
| | |
| | | var results = _halconToolDict[keyToolKey].GetResultTuple("OUTPUT_Results").DArr.ToList(); |
| | | if (results.Count == 0 || results.Any(u => u < 0)) |
| | | { |
| | | LogAsync(DateTime.Now, $"{k.AliasName}原始数据异常", ""); |
| | | LogAsync(DateTime.Now, $"{k.AliasName}原始数据{string.Join(",", results)}异常", ""); |
| | | } |
| | | else |
| | | { |
| | | //LogAsync(DateTime.Now, $"{k.AliasName}原始数据", $"{string.Join(" ", results)}"); |
| | | |
| | | results = results.Select(u => u - Config.PlanCompensation).ToList(); |
| | | |
| | | string resultStr = ""; |
| | | resultDict = k.KeyResultList.ToDictionary(u => u, u => |
| | | { |
| | | int index = k.KeyResultList.IndexOf(u); |
| | | return results[index]; |
| | | |
| | | if (index < results.Count && index >= 0) |
| | | { |
| | | double origin = results[index]; |
| | | |
| | | var compensation = k.KeyCompensationCollection.FirstOrDefault(c => c.KeyResult == u); |
| | | if (compensation != null) |
| | | { |
| | | origin = origin + compensation.Compensation; |
| | | } |
| | | |
| | | resultStr += $"{u} {origin};"; |
| | | |
| | | return origin; |
| | | } |
| | | else |
| | | { |
| | | return -999.0; |
| | | } |
| | | }); |
| | | |
| | | LogAsync(DateTime.Now, $"{k.AliasName}结果:{resultStr}", ""); |
| | | } |
| | | } |
| | | } |
| | | |
| | | keyBindList.ForEach(kb => |
| | | { |
| | | kb.KeyImages.Add(image.ConvertHObjectToHImage()); |
| | | kb.FillKeyValues(resultDict); |
| | | if (kb.KeyImages != null) |
| | | { |
| | | kb.KeyImages.Add(image.ConvertHObjectToHImage()); |
| | | kb.FillKeyValues(resultDict); |
| | | } |
| | | else |
| | | { |
| | | |
| | | } |
| | | }); |
| | | }); |
| | | |