protected override void StartTest()
        {
            {
                if (CanStartTest())
                {
                    DisplayTempMessage("Test in process...", GOOD_MESSAGE_BRUSH, 0);

                    FullyReversedTorqueTest test = Session.TestTemplate.TestInstance() as FullyReversedTorqueTest;

                    test.Operator  = Session.BenchOperator;
                    test.WorkOrder = Session.WorkId;

                    TestBench.Singleton.LoadTest(test);
                    TestBench.Singleton.BeginCurrentTest();

                    ChartFactory.CreateFullyReversedChart(TorqueAngleChart,
                                                          (test as FullyReversedTorqueTest).MinTorque,
                                                          (test as FullyReversedTorqueTest).MaxTorque);

                    ClearTestData();

                    // reevalutate all commands can execute.
                    StartTestCommand.RaiseCanExecuteChanged();
                    ExitProgamCommand.RaiseCanExecuteChanged();
                    StopTestCommand.RaiseCanExecuteChanged();
                }
            }
        }
示例#2
0
        private void Singleton_TestCompleted(object sender, TorqueTestEventArgs e)
        {
            try
            {
                FullyReversedTorqueTest completedTest = e.Test as FullyReversedTorqueTest;

                // normalize the data to the min and max torque, so it's easy to compare to actual
                // test results.
                CurrentCalibration.CalculateCalibrationValues(completedTest.CopyOfData,
                                                              completedTest.MaxTorque, completedTest.MinTorque);

                // update UI
                CwValue  = CurrentCalibration.NominalCwDeflection;
                CcwValue = CurrentCalibration.NominalCcwDeflection;

                CurrentCalibration.CalibratedByClockId = MainWindow_VM.Instance.TestSession.BenchOperator.ClockId;
                int recordsAffected = CurrentCalibration.Save();

                // so the calibration is enabled again.
                _calibrationCanBegin = true;
                RunCalibrationCommand.RaiseCanExecuteChanged();
                Message = "Calibration completed. Going to test panel shortly.";

                DispatcherTimer t = new DispatcherTimer();
                t.Interval = new TimeSpan(0, 0, 0, 5);
                t.Tick    += T_Tick;
                t.Start();
            }
            catch (Exception ex)
            {
                ExceptionHandler.WriteToEventLog(ex);
            }
        }
示例#3
0
        /// <summary>
        ///     For a given testId, this method will get you a TorqueTest from
        ///     the Twister database.
        /// </summary>
        /// <param name="testId">
        ///     The TestId for the test performed.
        /// </param>
        /// <returns>
        ///     A TorqueTest with properties populated from the database.  If
        ///     the record is not found in the database, return null.
        /// </returns>
        private static TorqueTest GetTestById(string testId)
        {
            SqlConnection           conn         = null;
            FullyReversedTorqueTest existingTest = null;
            var sel = "up_GetTestById";

            try
            {
                conn = TwisterConnection();

                SqlCommand cmd = CreateCommand(conn, sel);
                cmd.Parameters.AddWithValue("@testId", testId);

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        existingTest                = new FullyReversedTorqueTest();
                        existingTest.TestId         = dr["TestId"] as string;
                        existingTest.TestTemplateId = (int)dr["TestTemplateId"];

                        // get the employee than ran the test, the class loads the rest.
                        BenchOperator employee = new BenchOperator(dr["EmployeeNumber"] as string);

                        existingTest.WorkOrder = dr["WorkId"] as string;

                        if (dr["TestDate"] == DBNull.Value)
                        {
                            existingTest.StartDate = null;
                        }
                        else
                        {
                            existingTest.StartDate = (DateTime)dr["TestDate"];
                        }

                        if (dr["StartTime"] != DBNull.Value)
                        {
                            existingTest.StartTime = (TimeSpan)dr["StartTime"];
                        }
                        if (dr["FinishTime"] != DBNull.Value)
                        {
                            existingTest.FinishTime = (TimeSpan)dr["FinishTime"];
                        }
                    }
                }
                cmd.Dispose();

                return(existingTest);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CloseConnection(conn);
            }
        }