NucuCar.Domain: Modify ITelemeter interface to add new method: IsTelemetryEnabled.
This commit is contained in:
parent
bc245cb5f6
commit
943aafdf40
7 changed files with 28 additions and 2 deletions
|
@ -9,7 +9,6 @@ namespace NucuCar.Domain.Sensors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class GenericSensor
|
public abstract class GenericSensor
|
||||||
{
|
{
|
||||||
protected bool TelemetryEnabled;
|
|
||||||
protected ILogger Logger;
|
protected ILogger Logger;
|
||||||
protected SensorStateEnum CurrentState;
|
protected SensorStateEnum CurrentState;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,9 @@ namespace NucuCar.Domain.Sensors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class GenericTelemeterSensor : GenericSensor, ITelemeter
|
public abstract class GenericTelemeterSensor : GenericSensor, ITelemeter
|
||||||
{
|
{
|
||||||
|
protected bool TelemetryEnabled;
|
||||||
public abstract string GetIdentifier();
|
public abstract string GetIdentifier();
|
||||||
public abstract Dictionary<string, object> GetTelemetryData();
|
public abstract Dictionary<string, object> GetTelemetryData();
|
||||||
|
public abstract bool IsTelemetryEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,8 +16,18 @@ namespace NucuCar.Domain.Telemetry
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function should return a dictionary containing the telemetry data.
|
/// This function should return a dictionary containing the telemetry data.
|
||||||
|
/// When implementing this function you should return null if the telemetry is disabled.
|
||||||
|
/// See: <see cref="IsTelemetryEnabled"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The telemetry data. It should be JSON serializable.</returns>
|
/// <returns>The telemetry data. It should be JSON serializable.</returns>
|
||||||
Dictionary<string, object> GetTelemetryData();
|
Dictionary<string, object> GetTelemetryData();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This function should return whether the sensor has telemetry enabled or not.
|
||||||
|
/// A value of true indicates that the sensor has enabled telemetry, and a value of false indicates
|
||||||
|
/// that telemetry is not enabled.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A boolean indicating if the sensor has enabled telemetry.</returns>
|
||||||
|
bool IsTelemetryEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,7 +60,7 @@ namespace NucuCar.Domain.Telemetry
|
||||||
/// <returns>Returns true if the telemeter has registered successfully and false otherwise.</returns>
|
/// <returns>Returns true if the telemeter has registered successfully and false otherwise.</returns>
|
||||||
public bool RegisterTelemeter(ITelemeter t)
|
public bool RegisterTelemeter(ITelemeter t)
|
||||||
{
|
{
|
||||||
if (RegisteredTelemeters.Contains(t)) return false;
|
if (RegisteredTelemeters.Contains(t) || !t.IsTelemetryEnabled()) return false;
|
||||||
Logger?.LogDebug($"Registering telemeter {t.GetIdentifier()}");
|
Logger?.LogDebug($"Registering telemeter {t.GetIdentifier()}");
|
||||||
RegisteredTelemeters.Add(t);
|
RegisteredTelemeters.Add(t);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -149,6 +149,11 @@ namespace NucuCar.Sensors.Environment
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool IsTelemetryEnabled()
|
||||||
|
{
|
||||||
|
return TelemetryEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public Bme680Sensor Object { get; }
|
public Bme680Sensor Object { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -98,6 +98,11 @@ namespace NucuCar.Sensors.Health
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool IsTelemetryEnabled()
|
||||||
|
{
|
||||||
|
return TelemetryEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public CpuTempSensor Object { get; }
|
public CpuTempSensor Object { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -41,6 +41,11 @@ namespace NucuCar.TestClient.Telemetry
|
||||||
{
|
{
|
||||||
return _dummyTelemeterData;
|
return _dummyTelemeterData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsTelemetryEnabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task RunAzurePublisherTelemetryTest(AzureTelemetryPublishOptions opts)
|
public static async Task RunAzurePublisherTelemetryTest(AzureTelemetryPublishOptions opts)
|
||||||
|
|
Loading…
Reference in a new issue