private void ConfirmTestInfo() { try { if (PassedValidation()) { // finish up initializing the TestSession BenchOperator currentOperator = new BenchOperator(ClockNumber); currentOperator.GetName(); MainWindow_VM.Instance.TestSession.BenchOperator = currentOperator; MainWindow_VM.Instance.TestSession.WorkId = WorkOrder; if (MainWindow_VM.Instance.TestSession.TestTemplate.Id == (int)TestType.TorsionTestToFailure) { MainWindow_VM.Instance.CurrentViewModel = MainWindow_VM.Instance.UnidirectionalToFailureTestVm; var vm = (UnidirectionalTorqueTest_VM)MainWindow_VM.Instance.CurrentViewModel; // starts up the test monitoring. vm.PrepareToTest(MainWindow_VM.Instance.TestSession); } else if (MainWindow_VM.Instance.TestSession.TestTemplate.Id == (int)TestType.SteeringShaftTest_4000_inlbs) { // if this is a brand new part number with no calibration information, this shaft will need to be calibrated. WorkOrderInfo woInfo = new WorkOrderInfo(WorkOrder); woInfo.Load(); if (HasBeenCalibrated(woInfo.PartNumber, woInfo.Revision)) { MainWindow_VM.Instance.CurrentViewModel = MainWindow_VM.Instance.SteeringShaftTestVm; var vm = (FullyReversedTorqueTest_VM)MainWindow_VM.Instance.CurrentViewModel; // starts up the test monitoring. vm.PrepareToTest(MainWindow_VM.Instance.TestSession); } else { MainWindow_VM.Instance.CalibrationVm.PartNumber = woInfo.PartNumber; MainWindow_VM.Instance.CalibrationVm.Revision = woInfo.Revision; MainWindow_VM.Instance.CurrentViewModel = MainWindow_VM.Instance.CalibrationVm; } } else { throw new Exception("Invalid test type, must select a valid test type to continue."); } } } catch (Exception ex) { _log.Error(ex.ToString()); ErrorMessage = ex.Message; } }
public bool CannotAcceptResults(TorqueTest test, string workId, out string result) { // look up part number and revision WorkOrderInfo partInWorkOrder = new WorkOrderInfo(workId); partInWorkOrder.Load(); // load a previous calibration _savedCalibration = new Calibration(partInWorkOrder.PartNumber, partInWorkOrder.Revision); _savedCalibration.Load(); if (_savedCalibration.NominalCwDeflection == null) { result = Messages.MissingCalibrationDataError(); return(false); } // now create a comparison calibration based off the test results Calibration comparison = new Calibration(partInWorkOrder.PartNumber, partInWorkOrder.Revision); comparison.CalculateCalibrationValues(test.CopyOfData, test.MaxTorque, test.MinTorque); // clockwise var expectedAngleCw = (decimal)_savedCalibration.NominalCwDeflection; var actualAngleCw = (decimal)comparison.NominalCwDeflection; var percentDiffCw = PercentDifference(expectedAngleCw, actualAngleCw); // counterclockwise var expectedAngleCcw = (decimal)_savedCalibration.NominalCcwDeflection; var actualAngleCcw = (decimal)comparison.NominalCcwDeflection; var percentDiffCcw = PercentDifference(expectedAngleCcw, actualAngleCcw); // compare the calibration results. if (percentDiffCw < ALLOWABLE_PCT_DIFF && percentDiffCcw < ALLOWABLE_PCT_DIFF) { result = Messages.TestPassedMessage(percentDiffCw, percentDiffCcw, ALLOWABLE_PCT_DIFF); return(false); // false means pass (CAN accept results) } result = Messages.TestFailureMessage(percentDiffCw, percentDiffCcw, ALLOWABLE_PCT_DIFF); return(true); // true means fail (Cannot Accept Results) }