private void OnAddressChanged() { ApiVersion = _froniusModel.Connect(Address); if (ApiVersion != null) { // ok } else { //... } }
public MainViewModel(IFroniusModel froniusModel) { _froniusModel = froniusModel; ApiVersion = _froniusModel.Connect("fronius.fritz.box"); _address = _froniusModel.Address; ArchiveViewModel = new ArchiveViewModel(froniusModel); ArchiveViewModel.PropertyChanged += ArchiveViewModelPropertyChangedEventHandler; SmartMeterViewModel = new SmartMeterViewModel(froniusModel); SmartMeterViewModel.PropertyChanged += SmartMeterViewModelPropertyChangedEventHandler; InverterViewModel = new InverterViewModel(froniusModel); InverterViewModel.PropertyChanged += InverterViewModelPropertyChangedEventHandler; _timer = new DispatcherTimer(TimeSpan.FromSeconds(TIMER_SECONDS), DispatcherPriority.Normal, OnTimerElapsed, Dispatcher.CurrentDispatcher); PlotModel = new PlotModel(); InitPlotModel(); // trigger first update OnTimerElapsed(null, EventArgs.Empty); }