Class PollingProbe
Polling Probes are triggered at regular intervals. When triggered, the PollingProbe asks the device (and perhaps the user) for some type of information and stores the resulting information in the System.LocalDataStore.
Background Considerations
On Android, each PollingProbe is able to periodically wake up in the background, take a reading, and allow the system to go back to sleep. The Android operating system will occasionally delay the wake-up signal in order to batch wake-ups and thereby conserve energy; however, this delay is usually only 5-10 seconds. So, if you configure a PollingProbe to poll every 60 seconds, you may see actual polling delays of 65-70 seconds and maybe even more. This is by design within Android and cannot be changed.
Polling on iOS is generally less reliable than on Android. By design, iOS apps are restricted from performing processing in the background, with the following exceptions for PollingProbes:
Significant location change processing: If SignificantChangePoll is enabled, the PollingProbe will wake up each time the user's physical location changes significantly. This change is triggered by a change in cellular tower, which is roughly on the order of several kilometers.
Push notification processing: If you configure push notifications, the PollingProbe will be woken up at the desired time to take a reading. Note that the reliability of these timings is subject to push notification throttling imposed by the Apple Push Notification Service. The value of PollingSleepDurationMS should be set conservatively for all probes, for example no lower than 15-20 minutes. The push notification backend server will attempt to deliver push notifications slightly ahead of their scheduled times. If such a push notification arrives at the device before the scheduled time, then the local notification (if AlertUserWhenBackgrounded is enabled) will be cancelled.
Beyond these exceptions, all processing within Sensus for iOS must be halted when the user backgrounds the app. Sensus does its best to support PollingProbes on iOS by scheduling notifications to appear when polling operations (e.g., taking a GPS reading) should execute. This relies on the user to open the notification from the tray and bring Sensus to the foreground so that the polling operation can execute. Of course, the user might not see the notification or might choose not to open it. The polling operation will not be executed in such cases.
Inheritance
Inherited Members
Namespace: Sensus.Probes
Assembly: SensusAndroid.dll
Syntax
public abstract class PollingProbe : Probe, INotifyPropertyChanged, IPollingProbe, IProbe
Constructors
PollingProbe()
Declaration
protected PollingProbe()
Properties
AcPowerConnectPoll
Whether to poll on when the device is connected to AC Power.
Declaration
[OnOffUiProperty("Poll On AC Power Connection:", true, 7)]
public bool AcPowerConnectPoll { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
AcPowerConnectPollOverridesScheduledPolls
Has no effect if AcPowerConnectPoll is disabled. If AcPowerConnectPoll is enabled: (1) If this is on, polling will only occur on AC power connect. (2) If this is off, polling will occur based on PollingSleepDurationMS and on AC power connect.
Declaration
[OnOffUiProperty("AC Power Connection Poll Overrides Scheduled Polls:", true, 8)]
public bool AcPowerConnectPollOverridesScheduledPolls { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
AlertUserWhenBackgrounded
Available on iOS only. Whether or not to alert the user with a notification when polling should occur and the app is in the background. See the PollingProbe overview for information about background considerations. The notifications issued when this setting is enabled encourage the user to bring the app to the foreground so that data polling may occur. Depending on how many PollingProbes are enabled, these notifications can become excessive for the user.
Declaration
[OnOffUiProperty("(iOS) Alert User When Backgrounded:", true, 11)]
public bool AlertUserWhenBackgrounded { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
CollectionDescription
Declaration
public override string CollectionDescription { get; }
Property Value
Type | Description |
---|---|
System.String |
Overrides
DataRateSampleSize
Declaration
protected override long DataRateSampleSize { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
DefaultPollingSleepDurationMS
Declaration
public abstract int DefaultPollingSleepDurationMS { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
DelayToleranceAfterMS
Tolerance in milliseconds for running the PollingProbe after the scheduled time, if doing so will increase the number of batched actions and thereby decrease battery consumption.
Declaration
[EntryIntegerUiProperty("Delay Tolerance After (MS):", true, 13, true)]
public int DelayToleranceAfterMS { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The delay tolerance before. |
DelayToleranceBeforeMS
Tolerance in milliseconds for running the PollingProbe before the scheduled time, if doing so will increase the number of batched actions and thereby decrease battery consumption.
Declaration
[EntryIntegerUiProperty("Delay Tolerance Before (MS):", true, 12, true)]
public int DelayToleranceBeforeMS { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The delay tolerance before. |
MaxDataStoresPerSecond
Declaration
public override Nullable<double> MaxDataStoresPerSecond { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> |
Overrides
PollingSleepDurationMS
How long to sleep (become inactive) between successive polling operations.
Declaration
[EntryIntegerUiProperty("Sleep Duration (MS):", true, 5, true)]
public virtual int PollingSleepDurationMS { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The polling sleep duration in milliseconds. |
PollingTimeoutMinutes
How long the PollingProbe has to complete a single poll operation before being cancelled.
Declaration
[EntryIntegerUiProperty("Timeout (Mins.):", true, 6, true)]
public int PollingTimeoutMinutes { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The polling timeout minutes. |
PollTimes
Declaration
public List<DateTime> PollTimes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<System.DateTime> |
RawParticipation
Declaration
protected override double RawParticipation { get; }
Property Value
Type | Description |
---|---|
System.Double |
Overrides
SignificantChangePoll
Available on iOS only. Whether or not to poll when a significant change in location has occurred. See here for more information on significant changes.
Declaration
[OnOffUiProperty("(iOS) Poll On Significant Location Change:", true, 9)]
public bool SignificantChangePoll { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
SignificantChangePollOverridesScheduledPolls
Available on iOS only. Has no effect if significant-change polling is disabled. If significant-change polling is enabled: (1) If this is on, polling will only occur on significant changes. (2) If this is off, polling will occur based on PollingSleepDurationMS and on significant changes.
Declaration
[OnOffUiProperty("(iOS) Significant Change Poll Overrides Scheduled Polls:", true, 10)]
public bool SignificantChangePollOverridesScheduledPolls { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
PollAsync(CancellationToken)
Declaration
protected abstract Task<List<Datum>> PollAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.List<Datum>> |
ProtectedStartAsync()
Declaration
protected override Task ProtectedStartAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
ProtectedStopAsync()
Declaration
protected override Task ProtectedStopAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
ResetAsync()
Declaration
public override Task ResetAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
TestHealthAsync(List<AnalyticsTrackedEvent>)
Declaration
public override Task<HealthTestResult> TestHealthAsync(List<AnalyticsTrackedEvent> events)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<AnalyticsTrackedEvent> | events |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<HealthTestResult> |