public SensorHelper(ObservableCollection <SensorCollection> SensorCollection , ICacheService cacheService, ISensorServer sensorServer, bool _useCache = true, Rate sensorServerRate = Rate.Easy) { this.SensorCollection = SensorCollection; this.useCache = _useCache; this.sensorServerRate = sensorServerRate; this.sensorServer = sensorServer; this.cacheService = cacheService; dispatcherTimer = new DispatcherTimer(); //sensorServer = new SensorServer(sensorServerRate); sensorServer.StartServer(); //sensorServer.OnSensorStatusEvent += SensorServer_OnSensorStatusEvent; Observable.FromEvent <OnSensorStatus, SensorStatus>( h => sensorServer.OnSensorStatusEvent += SensorServer_OnSensorStatusEvent, h => sensorServer.OnSensorStatusEvent -= SensorServer_OnSensorStatusEvent) .Subscribe(p => System.Diagnostics.Trace.WriteLine($"Progress {p}")); dispatcherTimer.Interval = new TimeSpan(days: 0, hours: 0, minutes: 0, seconds: 1, milliseconds: 0); dispatcherTimer.Tick += dispatcherTimer_Tick; Observable.FromEvent <DispatcherTimer>( h => dispatcherTimer.Tick += dispatcherTimer_Tick, h => dispatcherTimer.Tick -= dispatcherTimer_Tick) .Subscribe(p => System.Diagnostics.Trace.WriteLine($"Progress {p}")); dispatcherTimer.Start(); }
public EventService() { // TODO: Use IoC Container! _sensorServer = new SensorServer(); _cacheService = new CacheService(); _events = new List <Event>(); BindingOperations.EnableCollectionSynchronization(_events, syncObject); }
public MainWindowViewModel(ICacheService cacheService, ISensorServer sensorServer) { SensorCollection = new ObservableCollection <SensorCollection>(); SelectSensorCommand = new DelegateCommand <object>(SelectSensorExecute); RemoveSensorCommand = new DelegateCommand <object>(RemoveSensorExecute); sensorHelper = new SensorHelper(SensorCollection, cacheService, sensorServer); sensorHelper.DeleteSensorEvent += SensorHelper_DeleteSensorEvent; }