Example #1
0
        public void SimulatedTorqueCellCalculatesTorqueAndUpdatesTorqueValue()
        {
            List <object> objSamples = new List <object>();
            List <float>  samples    = new List <float>();

            for (int i = 0; i < 500; i++)
            {
                _torqueCell.RefreshTorque();
                System.Threading.Thread.Sleep(1);
                objSamples.Add(new { _torqueCell.Torque, _torqueCell.LastTime });
                samples.Add(_torqueCell.Torque);
            }

            Assert.AreEqual(objSamples.Count, 500);
            Assert.AreEqual(samples.Count, 500);
        }
        public void ElapsedTimeCountsDownForMultipleTestConditions()
        {
            // initialize the simulated test bench
            var engine     = new SimulatorEngine(new Stopwatch());
            var torqueCell = new SimulatedTorqueCell(engine);
            var servoDrive = new SimulatedServoDrive(engine);

            TestBench.Initialize(torqueCell, servoDrive);

            // create a fatigue test and add a condition.
            var fatigueTest = new FatigueTest();

            engine.CurrentCondition = SingleFatigueTestCondition();
            fatigueTest.TestConditions.Add(engine.CurrentCondition);
            fatigueTest.TestConditions.AddRange(MultipleFatigueTestConditions());

            // load the test.
            TestBench.Singleton.LoadTest(fatigueTest);
            TestBench.Singleton.BeginCurrentTest();

            TimeSpan start = new TimeSpan(0, 0, 0);

            for (int i = 0; i < 1000; i++)
            {
                if (i == 0)
                {
                    start = fatigueTest.EstimatedCompletionTime;
                }
                torqueCell.RefreshTorque();
                servoDrive.StoreParameter(ServoDriveEnums.RegisterAddress.TorqueValue, (int)torqueCell.Torque);
                servoDrive.RefreshPosition();
                System.Threading.Thread.Sleep(10);
            }
            TimeSpan finish = fatigueTest.EstimatedCompletionTime;

            Console.WriteLine($"The estimated completion for the duty cycle is {finish.Days}:{finish.Hours}:{finish.Minutes}:{finish.Seconds}");
            var totalSeconds = start.Subtract(finish).TotalSeconds;

            Assert.GreaterOrEqual(totalSeconds, 10);
        }