/// <summary> /// Ctor. /// </summary> /// <param name="simconnectService"></param> /// <param name="settingsService"></param> public MissionService(ISimConnectService simconnectService, ISettingsService settingsService) { _simconnectService = simconnectService; //_settingsService = settingsService; _simconnectService.ObjectIdArrived += SimconnectServiceObjectIdArrived; }
void AttachedViewRequestFsxConnect(object sender, System.EventArgs e) { _simconnectService = new SimConnectService(_attachedView.Handle, _attachedView.SimConnect); _missionService = new MissionService(_simconnectService, _settingsService); _simconnectService.RequestCheckMIssions += SimconnectServiceRequestCheckMIssions; _simconnectService.SimconnectConnected += SimconnectServiceSimconnectConnected; _simconnectService.SimconnectDisconnected += SimconnectServiceSimconnectDisconnected; _missionService.RequestTimerStart += MissionServiceRequestTimerStart; _missionService.RequestTimerStop += MissionServiceRequestTimerStop; try { _simconnectService.Connect(); _timer.Enabled = true; _timer.Start(); if (_simconnectService.ConnectionStatus == ConnectionStatus.Connected) { _attachedView.Minimize(); } } catch (Exception ex) { AddLogMessage(ex.Message); } }
/// <summary> /// Constructor /// </summary> /// <param name="messageProcessor">Message Processor Object</param> public PluginService(IHostApplicationLifetime hostApplicationLifetime, IMessageProcessor messageProcessor, ISimConnectService simConnectService, IReflectionService reflectionService) { _hostApplicationLifetime = hostApplicationLifetime ?? throw new ArgumentNullException(nameof(hostApplicationLifetime)); _messageProcessor = messageProcessor ?? throw new ArgumentNullException(nameof(messageProcessor)); _simConnectService = simConnectService ?? throw new ArgumentNullException(nameof(simConnectService)); _reflectionService = reflectionService ?? throw new ArgumentNullException(nameof(reflectionService)); }
/// <summary> /// Constructor /// </summary> /// <param name="messageProcessor">Message Processor Object</param> public PluginService(IHostApplicationLifetime hostApplicationLifetime, ILogger <PluginService> logger, ITouchPortalClientFactory clientFactory, ISimConnectService simConnectService, IReflectionService reflectionService) { _hostApplicationLifetime = hostApplicationLifetime ?? throw new ArgumentNullException(nameof(hostApplicationLifetime)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _simConnectService = simConnectService ?? throw new ArgumentNullException(nameof(simConnectService)); _reflectionService = reflectionService ?? throw new ArgumentNullException(nameof(reflectionService)); _client = clientFactory?.Create(this) ?? throw new ArgumentNullException(nameof(clientFactory)); }
public MainWindow( MainWindowViewModel viewModel, IHidService hidService, ISimConnectService simConnectService) { _hidService = hidService; _simConnectService = simConnectService; DataContext = viewModel; InitializeComponent(); }
public EncoderViewModel( ISimConnectService simConnectService, string name, Expression <Func <DaniDeviceState, short> > getValueExpression, int buttonIndex, SimEvents increaseEvent, SimEvents decreaseEvent) { if (!(getValueExpression?.Body is MemberExpression memberExpression)) { throw new ArgumentException("The argument must be a MemberExpression", nameof(getValueExpression)); } _simConnectService = simConnectService; _getValue = getValueExpression.Compile(); IncreaseEvent = increaseEvent; DecreaseEvent = decreaseEvent; InputName = memberExpression.Member.Name; ButtonIndex = buttonIndex; Name = name; }
public DeviceViewModel( ISimConnectService simConnectService, IUsbService usbService, IEventAggregator eventAggregator) { Encoders = new[] { new EncoderViewModel(simConnectService, "HDG", state => state.Analog6, 0, SimEvents.HEADING_BUG_INC, SimEvents.HEADING_BUG_DEC), new EncoderViewModel(simConnectService, "ALT", state => state.Analog7, 1, SimEvents.AP_ALT_VAR_INC, SimEvents.AP_ALT_VAR_DEC), new EncoderViewModel(simConnectService, "SPD", state => state.Analog8, 2, SimEvents.AP_SPD_VAR_INC, SimEvents.AP_SPD_VAR_DEC), new EncoderViewModel(simConnectService, "VSP", state => state.Analog9, 3, SimEvents.AP_VS_VAR_INC, SimEvents.AP_VS_VAR_DEC) }; Potentiometers = new[] { new PotentiometerViewModel(state => state.Analog1), new PotentiometerViewModel(state => state.Analog2), new PotentiometerViewModel(state => state.Analog3), new PotentiometerViewModel(state => state.Analog4), new PotentiometerViewModel(state => state.Analog5), }; Buttons = Enumerable.Range(4, 11).Select(i => new ButtonViewModel(i)).ToList(); BuiltInLeds = Enumerable.Range(0, 16).Select(i => new LedViewModel(false, i)).ToList(); GpioLeds = Enumerable.Range(0, 16).Select(i => new LedViewModel(true, i)).ToList(); var leds = BuiltInLeds.Union(GpioLeds).ToDictionary(kvp => kvp.Pin); var inputComponents = Encoders.Cast <IInputComponentViewModel>() .Union(Potentiometers) .Union(Buttons) .ToList(); eventAggregator.GetEvent <UsbStateWrittenEvent>().Subscribe(state => { leds[Pin.Gpio15].State = LedState.On; leds[Pin.Gpio14].State = state.IsSimConnectConnected.ToLedState(); leds[Pin.Gpio7].State = state.IsBrakeNonZero.ToLedState(); leds[Pin.Gpio8].State = state.IsFlapNonZero.ToLedState(); leds[Pin.Gpio9].State = state.IsAutopilotMasterEnabled.ToLedState(); leds[Pin.Gpio10].State = state.IsAutopilotHeadingEnabled.ToLedState(); leds[Pin.Gpio11].State = state.IsAutopilotAltitudeEnabled.ToLedState(); leds[Pin.Gpio12].State = state.IsAutopilotAirspeedEnabled.ToLedState(); leds[Pin.Gpio13].State = state.IsAutopilotVerticalSpeedEnabled.ToLedState(); leds[Pin.Gpio0].State = state.IsParkingBrakeEnabled.ToLedState(); leds[Pin.Gpio5].State = state.IsAutoThrottleEnabled.ToLedState(); leds[Pin.Gpio4].State = state.IsAutopilotYawDamperEnabled.ToLedState(); leds[Pin.BuiltIn8].State = state.IsLeftGearMoving ? LedState.Blink : state.IsLeftGearOut.ToLedState(); leds[Pin.BuiltIn9].State = state.IsCenterGearMoving ? LedState.Blink : state.IsCenterGearOut.ToLedState(); leds[Pin.BuiltIn10].State = state.IsRightGearMoving ? LedState.Blink : state.IsRightGearOut.ToLedState(); }); eventAggregator.GetEvent <HidStateReceivedEvent>().Subscribe(state => { foreach (var inputComponent in inputComponents) { inputComponent.Update(state); } }); _isDisconnected = !usbService.IsConnected; eventAggregator.GetEvent <UsbConnectionChangedEvent>().Subscribe(isConnected => { IsDisconnected = !isConnected; }); }