public bool TestWithDigitalInput(EngineData.DI[] detections, out Dictionary <EngineData.DI, int> testResult) { var validation = true; var builder = new StringBuilder(); testResult = new Dictionary <EngineData.DI, int>(); var error = ""; foreach (var DI in detections) { var result = ReadDI(DI); if (!result) { validation = false; builder.Append(Enum.GetName(typeof(EngineData.DI), DI) + " = " + result + " Wanted = true" + Environment.NewLine); testResult.Add(DI, 1); DBResource?.Result_SaveResult(DBResource.JobID, result, true, "", "", ResultSubCategory.Mechanical_DimensionControl, ResultUnit.Bool, ""); } else { testResult.Add(DI, 0); DBResource?.Result_SaveResult(DBResource.JobID, result, false, "", "", ResultSubCategory.Mechanical_DimensionControl, ResultUnit.Bool, ""); } } error = builder.ToString(); NewInternalErrorText?.Invoke(CycleId, error); return(validation); }
public bool TestWithAnalogInput(EngineData.AI[] detections, out Dictionary <EngineData.AI, int> testResult, ResultUnit unit) { var validation = true; testResult = new Dictionary <EngineData.AI, int>(); var builder = new StringBuilder(); var error = ""; var index = 0; var adjustments = DBResource?.Calibration_GetLastAdjustments(WSID, 1); //Check Analog Inputs foreach (var AI in detections) { var adjustment = adjustments?.Find(a => a.Name == Enum.GetName(typeof(EngineData.AI), AI)); if (adjustment == null) { adjustment = new CalibrationAdjustment { OffSet = 0 }; } var realTimeValue = Math.Round(ReadAI(AI) - adjustment.OffSet, 2); var measure = DBResource?.MeasureLimits.Find(m => m.MeasureName == Enum.GetName(typeof(EngineData.AI), AI)); if (measure != null) { if (realTimeValue > measure.MinValue && realTimeValue < measure.MaxValue) { testResult.Add(AI, 0); DBResource?.Result_SaveResult(DBResource.JobID, realTimeValue, measure.MinValue, measure.MaxValue, "", "", ResultSubCategory.Mechanical_DimensionControl, unit, ""); } else { testResult.Add(AI, 1); validation = false; builder.Append(Enum.GetName(typeof(EngineData.AI), detections[index]) + " -> " + " [" + measure.MinValue + " < " + realTimeValue + " < " + measure.MaxValue + "]" + Environment.NewLine); DBResource?.Result_SaveResult(DBResource.JobID, realTimeValue, measure.MinValue, measure.MaxValue, "", "", ResultSubCategory.Mechanical_DimensionControl, ResultUnit.V, ""); } } index++; } error = builder.ToString(); NewInternalErrorText?.Invoke(CycleId, error); return(validation); }
public SystemConfiguration GetSystemConfiguration(string name) { var config = DBResource?.SystemConfigurations.Find(c => c.ConfigurationName == name); if (config != null) { return(config); } else { NewInternalErrorText?.Invoke(CycleId, "The System Configuration " + name + "Doesn't Exist!"); return(new SystemConfiguration()); } }
public MeasureLimit GetMeasureLimit(string name) { var limit = DBResource?.MeasureLimits.Find(m => m.MeasureName == name); if (limit != null) { return(limit); } else { NewInternalErrorText?.Invoke(CycleId, "The Measure Limit " + name + "Doesn't Exist!"); return(new MeasureLimit()); } }
public DeviceConst GetDeviceConsts(string name) { var constant = DBResource?.DeviceConsts.Find(m => m.ConstName == name); if (constant != null) { return(constant); } else { NewInternalErrorText?.Invoke(CycleId, "The Device Constant " + name + "Doesn't Exist!"); return(new DeviceConst()); } }
public bool RunCalibration(string traceNumber, EngineData.AI[] detections, int subWCid) { var validation = true; var builder = new StringBuilder(); var inputName = ""; var error = ""; GetCalibrationMeasurementList(traceNumber); // Check Analog Inputs foreach (var AI in detections) { inputName = Enum.GetName(typeof(EngineData.AI), AI); var calib = CalibrationMeasurementList.Find(p => p.Name == inputName); if (calib != null) { var min = calib.NominalValue - calib.Tolerance; var max = calib.NominalValue + calib.Tolerance; var result = ReadAI(AI); if (min < result && max > result) { SaveCalibrationResult(calib, traceNumber, WSID, (byte)subWCid, result, 0); } else { validation = false; SaveCalibrationResult(calib, traceNumber, WSID, (byte)subWCid, result, 1); builder.Append("Calibration:" + Environment.NewLine + Enum.GetName(typeof(EngineData.AI), AI) + " -> " + " [" + min + " < " + result + " < " + max + "]" + Environment.NewLine); } } } error = builder.ToString(); NewInternalErrorText?.Invoke(CycleId, error); return(validation); }