コード例 #1
0
ファイル: MainWindowViewModel.cs プロジェクト: Tiwalun/mabohe
        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;
        }
コード例 #2
0
ファイル: Mabohe.cs プロジェクト: Tiwalun/mabohe
 public Mabohe(SerialConn sc)
 {
     _sc = sc;
     _sc.ConnectionStateChanged += handleConnectionChange;
 }