private void OnTimerChanged(TimerChangedMessage message)
        {
            if (message.TimerIsRunning)
            {
                TextColor = GreenYellowRedSelector.GetBrushForTimeRemaining(message.RemainingSecs);

                TimeString = TimeFormatter.FormatTimerDisplayString(message.CountUp
                    ? message.ElapsedSecs
                    : message.RemainingSecs);

                // if duration of talk is greater than 1hr we only start showing the sector
                // when remaining time is less than 1 hr (for sake of clarity)...
                InitOverallDurationSector(message.RemainingSecs);

                if (DurationSector != null)
                {
                    DateTime now          = DateTime.Now;
                    var      currentAngle = CalcAngleFromTime(now);
                    if (Math.Abs(currentAngle - DurationSector.CurrentAngle) > 0.15) // prevent gratuitous updates
                    {
                        var d = DurationSector.Clone();
                        d.CurrentAngle = currentAngle;
                        d.IsOvertime   = message.RemainingSecs < 0;
                        DurationSector = d;
                    }
                }
            }
        }
        private void OnTimerStarted(TimerStartMessage message)
        {
            TimeString = TimeFormatter.FormatTimerDisplayString(message.CountUp
                ? 0
                : message.TargetSeconds);

            IsRunning = true;
            InitOverallDurationSector(message.TargetSeconds);
        }
Exemplo n.º 3
0
        public void TestOperatorViewStartStop()
        {
            const int TalkIdStart = 500;
            const int NumTalks    = 3;

            Mock <IOptionsService> optionsService = new Mock <IOptionsService>();

            optionsService.Setup(o => o.Options).Returns(MockOptions.Create());

            Mock <ITalkTimerService>            timerService         = new Mock <ITalkTimerService>();
            Mock <IAdaptiveTimerService>        adaptiveTimerService = new Mock <IAdaptiveTimerService>();
            ITalkScheduleService                scheduleService      = new MockTalksScheduleService(TalkIdStart, NumTalks);
            Mock <IBellService>                 bellService          = new Mock <IBellService>();
            Mock <ICommandLineService>          commandLineService   = new Mock <ICommandLineService>();
            Mock <ILocalTimingDataStoreService> timingDataService    = new Mock <ILocalTimingDataStoreService>();
            Mock <ISnackbarService>             snackbarService      = new Mock <ISnackbarService>();

            var vm = new OperatorPageViewModel(
                timerService.Object,
                scheduleService,
                adaptiveTimerService.Object,
                optionsService.Object,
                commandLineService.Object,
                bellService.Object,
                timingDataService.Object,
                snackbarService.Object);

            Assert.IsFalse(vm.IsRunning);
            Assert.IsFalse(vm.IsManualMode);

            for (int n = 0; n < NumTalks; ++n)
            {
                int talkId = TalkIdStart + n;
                Assert.IsTrue(vm.TalkId == talkId);

                var talk = scheduleService.GetTalkScheduleItem(talkId);
                Assert.IsNotNull(talk);
                Assert.AreEqual(vm.CurrentTimerValueString, TimeFormatter.FormatTimerDisplayString(talk.GetPlannedDurationSeconds()));

                vm.StartCommand.Execute(null);
                Assert.IsTrue(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == TalkIdStart + n);

                vm.StopCommand.Execute(null);
                Assert.IsFalse(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == (n == NumTalks - 1 ? 0 : TalkIdStart + n + 1));
            }
        }
Exemplo n.º 4
0
 private void OnNavigate(NavigateMessage message)
 {
     if (message.TargetPageName.Equals(SettingsPageViewModel.PageName))
     {
         // when the settings page is displayed we ensure that the
         // display is split so that we can easily adjust the split
         // position...
         var model = (TimerOutputWindowViewModel)DataContext;
         model.TimeString = TimeFormatter.FormatTimerDisplayString(0);
         DisplaySplitScreen();
     }
     else if (message.OriginalPageName.Equals(SettingsPageViewModel.PageName))
     {
         // restore to full screen time of day...
         DisplayFullScreenTimeOfDay();
     }
 }
Exemplo n.º 5
0
        public void TestOperatorViewStartStop()
        {
            const int TALK_ID_START = 500;
            const int NUM_TALKS     = 3;

            Mock <IOptionsService> optionsService = new Mock <IOptionsService>();

            optionsService.Setup(o => o.Options).Returns(MockOptions.Create());

            Mock <ITalkTimerService>     timerService         = new Mock <ITalkTimerService>();
            Mock <IAdaptiveTimerService> adaptiveTimerService = new Mock <IAdaptiveTimerService>();
            ITalkScheduleService         scheduleService      = new MockTalksScheduleService(TALK_ID_START, NUM_TALKS);

            OperatorPageViewModel vm = new OperatorPageViewModel(timerService.Object, scheduleService,
                                                                 adaptiveTimerService.Object, optionsService.Object);

            Assert.IsFalse(vm.IsRunning);
            Assert.IsFalse(vm.IsManualMode);

            for (int n = 0; n < NUM_TALKS; ++n)
            {
                int talkId = TALK_ID_START + n;
                Assert.IsTrue(vm.TalkId == talkId);

                var talk = scheduleService.GetTalkScheduleItem(talkId);
                Assert.IsNotNull(talk);
                Assert.AreEqual(vm.CurrentTimerValueString, TimeFormatter.FormatTimerDisplayString(talk.GetDurationSeconds()));

                vm.StartCommand.Execute(null);
                Assert.IsTrue(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == TALK_ID_START + n);

                vm.StopCommand.Execute(null);
                Assert.IsFalse(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == (n == NUM_TALKS - 1 ? 0 : TALK_ID_START + n + 1));
            }
        }
Exemplo n.º 6
0
        public void TestOperatorViewStartStop()
        {
            const int TalkIdStart = 500;
            const int NumTalks    = 3;

            var options = MockOptions.Create();

            options.GenerateTimingReports = false;
            options.MidWeekAdaptiveMode   = AdaptiveMode.TwoWay;
            options.MidWeekOrWeekend      = MidWeekOrWeekend.MidWeek;
            options.OperatingMode         = OperatingMode.Automatic;

            var optionsService = new Mock <IOptionsService>();

            optionsService.Setup(o => o.Options).Returns(options);
            optionsService.Setup(x => x.GetAdaptiveMode()).Returns(options.MidWeekAdaptiveMode);

            var timerService                     = new Mock <ITalkTimerService>();
            var adaptiveTimerService             = new Mock <IAdaptiveTimerService>();
            ITalkScheduleService scheduleService = new MockTalksScheduleService(TalkIdStart, NumTalks);
            var bellService        = new Mock <IBellService>();
            var commandLineService = new Mock <ICommandLineService>();
            var timingDataService  = new Mock <ILocalTimingDataStoreService>();
            var snackbarService    = new Mock <ISnackbarService>();
            var dateTimeService    = new MockDateTimeService();
            IQueryWeekendService queryWeekendService = new QueryWeekendService();

            dateTimeService.Set(new DateTime(2019, 11, 28) + TimeSpan.FromHours(19));

            var vm = new OperatorPageViewModel(
                timerService.Object,
                scheduleService,
                adaptiveTimerService.Object,
                optionsService.Object,
                commandLineService.Object,
                bellService.Object,
                timingDataService.Object,
                snackbarService.Object,
                dateTimeService,
                queryWeekendService);

            Assert.IsFalse(vm.IsRunning);
            Assert.IsFalse(vm.IsManualMode);

            for (var n = 0; n < NumTalks; ++n)
            {
                var talkId = TalkIdStart + n;
                Assert.IsTrue(vm.TalkId == talkId);

                var talk = scheduleService.GetTalkScheduleItem(talkId);
                Assert.IsNotNull(talk);
                Assert.AreEqual(vm.CurrentTimerValueString, TimeFormatter.FormatTimerDisplayString(talk.GetPlannedDurationSeconds()));

                vm.StartCommand.Execute(null);
                Assert.IsTrue(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == TalkIdStart + n);

                vm.StopCommand.Execute(null);
                Assert.IsFalse(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == (n == NumTalks - 1 ? 0 : TalkIdStart + n + 1));
            }
        }