/// <summary> /// Call this method to save the last completed test to the database using a /// unique test id. /// </summary> /// <param name="testId"></param> /// <returns></returns> public string PersistTestData(string testId) { try { /* * The number has been validated, now we can use it. Don't worry about it being * null. If it is I want an exception to be thrown so there are clues to the user * as to why the test was not saved to the database. */ _testToSave.TestId = testId; // passsed verification, so save to db. var recordsSaved = TorqueTestDb.SaveToDatabase(_testToSave); if (recordsSaved > 0) { // add to completed tests, the view model will grab it next time it updates. CompletedTests.Add(_testToSave); // there is no longer a test that needs to be saved, so set to null. _testToSave = null; return(Messages.DatabaseSaveSuccessful()); } return(Messages.DatabaseSaveUnsuccessful()); } catch (Exception ex) { Debug.WriteLine(Messages.GeneralExceptionMessage(ex, "SaveTestToDatabase")); return(ex.Message); } }
public void ResumeFatigueTest(FatigueTest fatigueTest) { _currentTest = fatigueTest; _currentTest.Start(); OnTestStarted(_currentTest); // this starts the test running Singleton.TurnOn(); }
private void OnTestStarted(TorqueTest test) { // let the world know. var handler = TestStarted; if (handler != null) { TestStarted(this, new TorqueTestEventArgs(test)); } }
/// <summary> /// Loads a new test into the test bench. /// </summary> /// <param name="test">The torque test to run on this test bench.</param> public void LoadTest(TorqueTest test) { // no need to load a null test, setting the _currentTest to null // is handled elsewhere in this class. if (test != null) { if (_currentTest != null && _currentTest.InProcess) { throw new Exception("Cannot begin a new test before the current test has finished."); } CurrentTest = test; SetTestType(CurrentTest.TestTemplateId); } }
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) }
/// <summary> /// Gets a new instance of the test type associated with the template. /// </summary> /// <returns></returns> public TorqueTest TestInstance() { if (!_templateLoaded) { throw new Exception("Test template is not loaded. Must first call Load() method."); } TorqueTest t = null; switch (_id) { case (int)TestType.SteeringShaftTest_4000_inlbs: Load(); t = new FullyReversedTorqueTest(); t.TestTemplateId = Id; t.LoadTestParameters(this); break; case (int)TestType.TorsionTestToFailure: Load(); t = new UnidirectionalTorqueTest(); t.TestTemplateId = Id; t.LoadTestParameters(this); break; case (int)TestType.FatigueTest: Load(); t = new FatigueTest(); t.TestTemplateId = Id; t.LoadTestParameters(this); break; default: throw new Exception("Unsupported test type"); } return(t); }
public void AddTestToListToSave() { // need to save test Data, add this test to the log of tests // performed on this test bench, and then set current test equal // to null. lock (_objLock) { if (CurrentTest != null) { TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"); DateTimeOffset offsetCentralTime = TimeZoneInfo.ConvertTime(new DateTimeOffset( DateTime.UtcNow, new TimeSpan(0, 0, 0)), timeZoneInfo); CurrentTest.FinishTime = offsetCentralTime.TimeOfDay; if (!_currentTest.WasShutDownEarly) { CompletedTests.Add(_currentTest); CurrentTest.ShouldBeSaved = true; // so there is still a reference to the CurrentTest for the // OnTestCompleted() method to have access to. _testToSave = CurrentTest; } else { _testToSave = null; } CurrentTest = null; OnTestCompleted(); } _runModeDeterminate = false; } }
public TorqueTestEventArgs(TorqueTest completedTest) { Test = completedTest; }