protected override void StartTest() { { if (CanStartTest()) { DisplayTempMessage("Test in process...", GOOD_MESSAGE_BRUSH, 0); UnidirectionalTorqueTest test = Session.TestTemplate.TestInstance() as UnidirectionalTorqueTest; test.Operator = Session.BenchOperator; test.WorkOrder = Session.WorkId; // used when creating the Unidirectional Chart to set the minimum or maximum y value. int maxTorque = test.MaxTorque; // set the test direction, based of what the user has chosen. if (IsClockwise) { test.Direction = TestDirection.Clockwise; } else if (IsCounterclockwise) { maxTorque = test.MinTorque; // CCW is negative test.Direction = TestDirection.Counterclockwise; } else { test.Direction = TestDirection.Unknown; throw new Exception("Unknown test direction, please change to Clockwise or Counterclockwise."); } TestBench.Singleton.LoadTest(test); TestBench.Singleton.BeginCurrentTest(); ChartFactory.CreateUnidirectionalChart(TorqueAngleChart, maxTorque); // clear all saved Sample objects from base class list. ClearTestData(); // reevalutate all commands can execute. StartTestCommand.RaiseCanExecuteChanged(); SaveDataCommand.RaiseCanExecuteChanged(); ExitProgamCommand.RaiseCanExecuteChanged(); StopTestCommand.RaiseCanExecuteChanged(); } } }
protected override void ScaleChartAxis(float currentTorque, float currentAngle) { // for calibration purposes if (TorqueAngleChart == null) { return; } UnidirectionalTorqueTest runningTest = TestBench.Singleton.CurrentTest as UnidirectionalTorqueTest; try { TorqueAngleChart.ChartAreas[0].RecalculateAxesScale(); } catch (Exception ex) { Debug.WriteLine( Messages.GeneralExceptionMessage(ex, "UnidirectionalTorqueTest_VM.ScaleChartAxis")); } }
internal static void SetTorqeTestParameters(SqlCommand cmd, TorqueTest torqueTest) { cmd.Parameters.Add(new SqlParameter { ParameterName = "@TestId", SqlDbType = SqlDbType.NVarChar, Value = torqueTest.TestId }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@TestTemplateId", SqlDbType = SqlDbType.Int, Value = torqueTest.TestTemplateId }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@EmployeeNumber", SqlDbType = SqlDbType.NVarChar, Value = torqueTest.Operator.ClockId }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@WorkId", SqlDbType = SqlDbType.NVarChar, Value = torqueTest.WorkOrder }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@TestDate", SqlDbType = SqlDbType.Date, Value = torqueTest.StartDate.Value.Date }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@StartTime", SqlDbType = SqlDbType.Time, Value = torqueTest.StartTime }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@FinishTime", SqlDbType = SqlDbType.Time, Value = torqueTest.FinishTime }); // now see if it's a unidirectional test, so the direction must be know. var direction = "BD"; // both directions is default, see TestDirections table. UnidirectionalTorqueTest test = torqueTest as UnidirectionalTorqueTest; if (test != null) { if (test.Direction == TestDirection.Clockwise) { direction = "CW"; } else if (test.Direction == TestDirection.Counterclockwise) { direction = "CCW"; } } // now add the parameter cmd.Parameters.Add(new SqlParameter { ParameterName = "@Direction", SqlDbType = SqlDbType.NVarChar, Precision = 5, Value = direction }); }