Example #1
0
        public void Should_TurnOffRadio_AndResetBoard_WhenMenuRadioOnHold()
        {
            RadioEmulator.Init();

            Launcher.Launch(Launcher.LaunchMode.WPF);

            ManualResetEvent emulatorOnIsEnabledChangedWaitHandle = new ManualResetEvent(false);

            Launcher.Emulator.IsEnabledChanged += (s, e) => { emulatorOnIsEnabledChangedWaitHandle.Set(); };
            Radio.PressOnOffToggle();
            bool radioEnabledResult = emulatorOnIsEnabledChangedWaitHandle.Wait();


            ManualResetEvent emulatorOnIsPlayingChangedWaitHandle = new ManualResetEvent(false);

            Launcher.Emulator.PlayerIsPlayingChanged += (sender, isPlayingChangedValue) =>
            {
                if (!isPlayingChangedValue)
                {
                    emulatorOnIsPlayingChangedWaitHandle.Set();
                }
            };
            Manager.Instance.EnqueueMessage(
                new Message(DeviceAddress.OnBoardMonitor, DeviceAddress.LocalBroadcastAddress, 0x48, 0x34),
                new Message(DeviceAddress.OnBoardMonitor, DeviceAddress.LocalBroadcastAddress, 0x48, 0x74));
            bool radioDisabledResult = emulatorOnIsPlayingChangedWaitHandle.Wait();

            Assert.IsTrue(radioEnabledResult);
            Assert.IsTrue(radioDisabledResult);
            Assert.IsTrue(!Launcher.Emulator.IsEnabled);
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();

            _viewModel  = new ViewModel();
            DataContext = _viewModel;

            InstrumentClusterElectronicsEmulator.Init();
            NavigationModuleEmulator.Init();
            AuxilaryHeaterEmulator.Init();
            RadioEmulator.Init();
            DigitalDieselElectronicsEmulator.Init();
            FrontDisplayEmulator.Init();
            HeadlightVerticalAimControlEmulator.Init();
            IntegratedHeatingAndAirConditioningEmulator.Init();
            VolumioEmulator.Init(_viewModel);

            Launcher.Launch(Launcher.LaunchMode.WPF);

            //AuxilaryHeaterEmulator.FirstMessageAfterWakeup();

            InstrumentClusterElectronics.IgnitionStateChanged += (e) =>
            {
                if (e.PreviousIgnitionState == IgnitionState.Acc && e.CurrentIgnitionState == IgnitionState.Ign)
                {
                    InstrumentClusterElectronicsEmulator.StartAnnounce();
                }

                if (e.PreviousIgnitionState == IgnitionState.Ign && e.CurrentIgnitionState == IgnitionState.Acc)
                {
                    InstrumentClusterElectronicsEmulator.StopAnnounce();
                }
            };

            Bordmonitor.ReplyToScreenUpdates = true;
            Bordmonitor.TextReceived        += Bordmonitor_TextReceived;
            FrontDisplayEmulator.LedChanged += FrontDisplayEmulator_LedChanged;
            InstrumentClusterElectronicsEmulator.OBCTextChanged += InstrumentClusterElectronicsEmulator_OBCTextChanged;

            //BordmonitorMenu.Instance.CurrentScreen = HomeScreen.Instance;

            Manager.Instance.AddMessageReceiverForSourceDevice(DeviceAddress.Radio, m =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    if (m.Data.StartsWith(Radio.DataRadioOn))
                    {
                        EnableRadio();
                    }
                    if (m.Data.StartsWith(Radio.DataRadioOff))
                    {
                        DisableRadio();
                    }
                });
            });
#if !DebugOnRealDeviceOverFTDI
            //Launcher.emulator.IsEnabled = true;
#endif
        }