protected virtual Task InitializeAsync() { SensusServiceHelper.Get().Logger.Log("Initializing...", LoggingLevel.Normal, GetType()); lock (_chartData) { _chartData.Clear(); } _mostRecentDatum = null; _mostRecentStoreTimestamp = DateTimeOffset.UtcNow; // mark storage delay from initialization of probe // track/limit the raw data rate _rawRateCalculator = new DataRateCalculator(DataRateSampleSize, MaxDataStoresPerSecond); // track the storage rate _storageRateCalculator = new DataRateCalculator(DataRateSampleSize); // track/limit the UI update rate _uiUpdateRateCalculator = new DataRateCalculator(DataRateSampleSize, 1); // hook into the AC charge event signal -- add handler to AC broadcast receiver SensusContext.Current.PowerConnectionChangeListener.PowerConnectionChanged += _powerConnectionChanged; return(Task.CompletedTask); }
protected ListeningProbe() { _maxDataStoresPerSecond = null; // no data rate limit by default _keepDeviceAwake = DefaultKeepDeviceAwake; _deviceAwake = false; _incomingDataRateCalculator = new DataRateCalculator(100); // store all data to start with. we'll compute a store/drop rate after data have arrived. _samplingModulus = 1; _samplingModulusMatchAction = SamplingModulusMatchAction.Store; }
/// <summary> /// Initializes this probe. Throws an exception if initialization fails. After successful completion the probe is considered to be /// running and a candidate for stopping at some future point. /// </summary> protected virtual void Initialize() { lock (_chartData) { _chartData.Clear(); } _mostRecentDatum = null; _mostRecentStoreTimestamp = DateTimeOffset.UtcNow; // mark storage delay from initialization of probe // data rate calculators _rawRateCalculator = new DataRateCalculator(DataRateSampleSize, MaxDataStoresPerSecond); // track/limit the raw data rate _storageRateCalculator = new DataRateCalculator(DataRateSampleSize); // track the storage rate _uiUpdateRateCalculator = new DataRateCalculator(DataRateSampleSize, 1); // track/limit the UI update rate }