Example #1
0
        public FatigueTestSetupViewModel()
        {
            _fatigueTest = new FatigueTest
            {
                TestTemplateId = (int)TestType.FatigueTest
            };

            NoConditionsDefined = true;
            CanSeeNext          = false;

            TestConditions = new ObservableCollection <FatigueTestCondition>();
            TestConditions.CollectionChanged += TestConditionsOnCollectionChanged;

            AddConditionCommand    = new RelayCommand(AddCondition);
            NextCommand            = new RelayCommand(GoToNextScreen);
            RemoveConditionCommand = new RelayCommand <FatigueTestCondition>(RemoveCondition);

            ShaftStiffness = 1;
        }
        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);
        }