-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #789 from predictive-technology-laboratory/powerCo…
…nnectProbe Add Power Connect Probe
- Loading branch information
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json; | ||
using Sensus.Context; | ||
using Syncfusion.SfChart.XForms; | ||
|
||
namespace Sensus.Probes.Device | ||
{ | ||
public class ListeningPowerConnectProbe : ListeningProbe | ||
{ | ||
private EventHandler<bool> _powerConnectionChanged; | ||
|
||
public ListeningPowerConnectProbe() | ||
{ | ||
_powerConnectionChanged = async (sender, connected) => | ||
{ | ||
await StoreDatumAsync(new PowerConnectDatum(DateTimeOffset.UtcNow,connected)); | ||
}; | ||
|
||
} | ||
|
||
public override string DisplayName | ||
{ | ||
get | ||
{ | ||
return "Power Connection"; | ||
} | ||
} | ||
public override Type DatumType | ||
{ | ||
get { return typeof(PowerConnectDatum); } | ||
} | ||
|
||
[JsonIgnore] | ||
protected override bool DefaultKeepDeviceAwake | ||
{ | ||
get | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
protected override Task StartListeningAsync() | ||
{ | ||
base.StartListeningAsync(); | ||
SensusContext.Current.PowerConnectionChangeListener.PowerConnectionChanged += _powerConnectionChanged; | ||
return Task.CompletedTask; | ||
} | ||
|
||
protected override Task StopListeningAsync() | ||
{ | ||
base.StopListeningAsync(); | ||
SensusContext.Current.PowerConnectionChangeListener.PowerConnectionChanged -= _powerConnectionChanged; | ||
return Task.CompletedTask; | ||
} | ||
|
||
|
||
protected override string DeviceAwakeWarning => throw new NotImplementedException(); | ||
|
||
protected override string DeviceAsleepWarning => throw new NotImplementedException(); | ||
|
||
protected override ChartDataPoint GetChartDataPointFromDatum(Datum datum) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override ChartAxis GetChartPrimaryAxis() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override RangeAxisBase GetChartSecondaryAxis() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override ChartSeries GetChartSeries() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Sensus.Probes.Device | ||
{ | ||
class PowerConnectDatum : Datum | ||
{ | ||
private bool _connection; | ||
|
||
|
||
public PowerConnectDatum(DateTimeOffset timestamp, bool connection) : base(timestamp) | ||
{ | ||
_connection = connection; | ||
} | ||
|
||
|
||
public override string DisplayDetail | ||
{ | ||
get | ||
{ | ||
return "(Power connect Data)"; | ||
} | ||
} | ||
|
||
public bool Connection { get => _connection; set => _connection = value; } | ||
|
||
public override object StringPlaceholderValue => throw new NotImplementedException(); | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
return base.Equals(obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return base.GetHashCode(); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return base.ToString() + Environment.NewLine + | ||
"Connected: " + _connection+ Environment.NewLine; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters