public MainWindowViewModel(SerialConn conn, MainWindow window) { this.window = window; sc = conn; mbh = new Mabohe(sc); setupPlot(); sc.ConnectionStateChanged += (Object sender, EventArgs e) => { NotifyPropertyChanged("connectionState"); if (sc.connectionState == SerialConn.ConnectionState.Connected) { _syncTimer.Start(); } else { _syncTimer.Stop(); } }; mbh.PropertyChanged += (Object sender, PropertyChangedEventArgs e) => { if (e.PropertyName == "PowerState") { NotifyPropertyChanged("powerState"); } }; //setup sync timer _syncTimer.Interval = TimeSpan.FromMilliseconds(SYNC_INTERVALL_MS); _syncTimer.Tick += handleSyncTick; _graphTimer.Interval = TimeSpan.FromMilliseconds(100); _graphTimer.Tick += (Object sender, EventArgs e) => { foreach (string property in _plotProperties) { SavePropertyToGraph(property); } tempModel.InvalidatePlot(true); }; _graphTimer.Start(); this.PropertyChanged += updateGraph; }
public Mabohe(SerialConn sc) { _sc = sc; _sc.ConnectionStateChanged += handleConnectionChange; }