mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 13:57:28 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -2,109 +2,109 @@
|
|||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
|
||||
{
|
||||
public class Battery : IBattery
|
||||
{
|
||||
private Battery() { }
|
||||
public class Battery : IBattery
|
||||
{
|
||||
private Battery() { }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
|
||||
/// </summary>
|
||||
public double CurrentChargePercent { get; private set; } = double.NaN;
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
|
||||
/// </summary>
|
||||
public double CurrentChargePercent { get; private set; } = double.NaN;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the current chargeing level of the battery in bars, null if unkonwn.
|
||||
/// </summary>
|
||||
public int? CurrentChargeBars { get; private set; } = null;
|
||||
/// <summary>
|
||||
/// Holds the current chargeing level of the battery in bars, null if unkonwn.
|
||||
/// </summary>
|
||||
public int? CurrentChargeBars { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the maximum chargeing level of the battery in bars, null if unkonwn.
|
||||
/// </summary>
|
||||
public int? MaxChargeBars { get; private set; } = null;
|
||||
/// <summary>
|
||||
/// Holds the maximum chargeing level of the battery in bars, null if unkonwn.
|
||||
/// </summary>
|
||||
public int? MaxChargeBars { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
public bool? IsBackendAccessible { get; private set; } = null;
|
||||
/// <summary>
|
||||
/// Holds whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
public bool? IsBackendAccessible { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds whether to display battery level or not.
|
||||
/// </summary>
|
||||
public bool? IsHidden { get; private set; } = null;
|
||||
/// <summary>
|
||||
/// Holds whether to display battery level or not.
|
||||
/// </summary>
|
||||
public bool? IsHidden { get; private set; } = null;
|
||||
|
||||
public class Builder
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the current chargeing level of the battery in bars.
|
||||
/// </summary>
|
||||
public int? CurrentChargeBars { get; set; } = null;
|
||||
public class Builder
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the current chargeing level of the battery in bars.
|
||||
/// </summary>
|
||||
public int? CurrentChargeBars { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the maximum chargeing level of the battery in bars.
|
||||
/// </summary>
|
||||
public int? MaxChargeBars { get; set; } = null;
|
||||
/// <summary>
|
||||
/// Holds the maximum chargeing level of the battery in bars.
|
||||
/// </summary>
|
||||
public int? MaxChargeBars { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in percent.
|
||||
/// </summary>
|
||||
public double CurrentChargePercent { get; set; } = double.NaN;
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in percent.
|
||||
/// </summary>
|
||||
public double CurrentChargePercent { get; set; } = double.NaN;
|
||||
|
||||
/// <summary>
|
||||
/// Holds whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
public bool? IsBackendAccessible { get; set; } = null;
|
||||
/// <summary>
|
||||
/// Holds whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
public bool? IsBackendAccessible { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds whether to display battery level or not.
|
||||
/// </summary>
|
||||
public bool? IsHidden { get; set; } = null;
|
||||
/// <summary>
|
||||
/// Holds whether to display battery level or not.
|
||||
/// </summary>
|
||||
public bool? IsHidden { get; set; } = null;
|
||||
|
||||
public Battery Build()
|
||||
{
|
||||
if (!double.IsNaN(CurrentChargePercent)
|
||||
&& (CurrentChargePercent < 0 || 100 < CurrentChargePercent))
|
||||
{
|
||||
// Invalid filling level detected
|
||||
CurrentChargePercent = double.NaN;
|
||||
}
|
||||
public Battery Build()
|
||||
{
|
||||
if (!double.IsNaN(CurrentChargePercent)
|
||||
&& (CurrentChargePercent < 0 || 100 < CurrentChargePercent))
|
||||
{
|
||||
// Invalid filling level detected
|
||||
CurrentChargePercent = double.NaN;
|
||||
}
|
||||
|
||||
if (CurrentChargeBars < 0)
|
||||
{
|
||||
// Current value of bars must never be smaller zero.
|
||||
CurrentChargeBars = null;
|
||||
}
|
||||
if (CurrentChargeBars < 0)
|
||||
{
|
||||
// Current value of bars must never be smaller zero.
|
||||
CurrentChargeBars = null;
|
||||
}
|
||||
|
||||
if (MaxChargeBars < 0)
|
||||
{
|
||||
// Max value of bars must never be smaller zero.
|
||||
MaxChargeBars = null;
|
||||
}
|
||||
if (MaxChargeBars < 0)
|
||||
{
|
||||
// Max value of bars must never be smaller zero.
|
||||
MaxChargeBars = null;
|
||||
}
|
||||
|
||||
if (CurrentChargeBars != null
|
||||
&& MaxChargeBars == null)
|
||||
{
|
||||
// If current charge bars is set, max charge must be set as well.
|
||||
Log.ForContext<Battery>().Error($"Current bars value can not be set to {CurrentChargeBars} if max bars is not se.");
|
||||
CurrentChargeBars = null;
|
||||
}
|
||||
if (CurrentChargeBars != null
|
||||
&& MaxChargeBars == null)
|
||||
{
|
||||
// If current charge bars is set, max charge must be set as well.
|
||||
Log.ForContext<Battery>().Error($"Current bars value can not be set to {CurrentChargeBars} if max bars is not se.");
|
||||
CurrentChargeBars = null;
|
||||
}
|
||||
|
||||
if (CurrentChargeBars != null
|
||||
&& MaxChargeBars != null
|
||||
&& CurrentChargeBars > MaxChargeBars)
|
||||
{
|
||||
// If current charge bars must never be larger than max charge bars.
|
||||
Log.ForContext<Battery>().Error($"Invalid current bars value {CurrentChargeBars} detected. Value must never be largen than max value bars {MaxChargeBars}.");
|
||||
CurrentChargeBars = null;
|
||||
}
|
||||
if (CurrentChargeBars != null
|
||||
&& MaxChargeBars != null
|
||||
&& CurrentChargeBars > MaxChargeBars)
|
||||
{
|
||||
// If current charge bars must never be larger than max charge bars.
|
||||
Log.ForContext<Battery>().Error($"Invalid current bars value {CurrentChargeBars} detected. Value must never be largen than max value bars {MaxChargeBars}.");
|
||||
CurrentChargeBars = null;
|
||||
}
|
||||
|
||||
return new Battery
|
||||
{
|
||||
CurrentChargeBars = CurrentChargeBars,
|
||||
MaxChargeBars = MaxChargeBars,
|
||||
CurrentChargePercent = CurrentChargePercent,
|
||||
IsBackendAccessible = IsBackendAccessible,
|
||||
IsHidden = IsHidden
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Battery
|
||||
{
|
||||
CurrentChargeBars = CurrentChargeBars,
|
||||
MaxChargeBars = MaxChargeBars,
|
||||
CurrentChargePercent = CurrentChargePercent,
|
||||
IsBackendAccessible = IsBackendAccessible,
|
||||
IsHidden = IsHidden
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
|
||||
{
|
||||
public interface IBattery
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
|
||||
/// </summary>
|
||||
double CurrentChargePercent { get; }
|
||||
public interface IBattery
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
|
||||
/// </summary>
|
||||
double CurrentChargePercent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the current chargeing level of the battery in bars. Must not be arger than MaxChargeBars, null if unkonwn.
|
||||
/// </summary>
|
||||
int? CurrentChargeBars { get; }
|
||||
/// <summary>
|
||||
/// Holds the current chargeing level of the battery in bars. Must not be arger than MaxChargeBars, null if unkonwn.
|
||||
/// </summary>
|
||||
int? CurrentChargeBars { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the maximum chargeing level of the battery in bars, null if unkonwn.
|
||||
/// </summary>
|
||||
int? MaxChargeBars { get; }
|
||||
/// <summary>
|
||||
/// Holds the maximum chargeing level of the battery in bars, null if unkonwn.
|
||||
/// </summary>
|
||||
int? MaxChargeBars { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
bool? IsBackendAccessible { get; }
|
||||
/// <summary>
|
||||
/// Holds whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
bool? IsBackendAccessible { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds whether to display battery level or not.
|
||||
/// </summary>
|
||||
bool? IsHidden { get; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Holds whether to display battery level or not.
|
||||
/// </summary>
|
||||
bool? IsHidden { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,60 +3,60 @@ using TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS;
|
|||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS
|
||||
{
|
||||
public enum DriveType
|
||||
{
|
||||
/// <summary>
|
||||
/// Bike without pedalling aid.
|
||||
/// </summary>
|
||||
SoleHumanPowered,
|
||||
public enum DriveType
|
||||
{
|
||||
/// <summary>
|
||||
/// Bike without pedalling aid.
|
||||
/// </summary>
|
||||
SoleHumanPowered,
|
||||
|
||||
/// <summary>
|
||||
/// pedal electric cycle: Pedalling is assisted by an electric engine.
|
||||
/// </summary>
|
||||
Pedelec
|
||||
}
|
||||
/// <summary>
|
||||
/// pedal electric cycle: Pedalling is assisted by an electric engine.
|
||||
/// </summary>
|
||||
Pedelec
|
||||
}
|
||||
|
||||
public class Drive
|
||||
{
|
||||
public Drive(
|
||||
IEngine engine = null,
|
||||
IBattery battery = null)
|
||||
{
|
||||
if (engine == null)
|
||||
{
|
||||
Engine = new Engine();
|
||||
Battery = new Battery.Builder().Build();
|
||||
Type = DriveType.SoleHumanPowered;
|
||||
return;
|
||||
}
|
||||
public class Drive
|
||||
{
|
||||
public Drive(
|
||||
IEngine engine = null,
|
||||
IBattery battery = null)
|
||||
{
|
||||
if (engine == null)
|
||||
{
|
||||
Engine = new Engine();
|
||||
Battery = new Battery.Builder().Build();
|
||||
Type = DriveType.SoleHumanPowered;
|
||||
return;
|
||||
}
|
||||
|
||||
Engine = engine;
|
||||
Battery = battery ?? new Battery.Builder().Build();
|
||||
Type = DriveType.Pedelec;
|
||||
}
|
||||
Engine = engine;
|
||||
Battery = battery ?? new Battery.Builder().Build();
|
||||
Type = DriveType.Pedelec;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the drive.
|
||||
/// </summary>
|
||||
public DriveType Type { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets the type of the drive.
|
||||
/// </summary>
|
||||
public DriveType Type { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Engine driving the bike.
|
||||
/// </summary>
|
||||
public IEngine Engine { get; private set; }
|
||||
/// <summary>
|
||||
/// Engine driving the bike.
|
||||
/// </summary>
|
||||
public IEngine Engine { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Battery powering the engine.
|
||||
/// </summary>
|
||||
public IBattery _Battery = new Battery.Builder().Build();
|
||||
/// <summary>
|
||||
/// Battery powering the engine.
|
||||
/// </summary>
|
||||
public IBattery _Battery = new Battery.Builder().Build();
|
||||
|
||||
/// <summary>
|
||||
/// Battery powering the engine.
|
||||
/// </summary>
|
||||
public IBattery Battery
|
||||
{
|
||||
get => _Battery;
|
||||
set => _Battery = value ?? new Battery.Builder().Build();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Battery powering the engine.
|
||||
/// </summary>
|
||||
public IBattery Battery
|
||||
{
|
||||
get => _Battery;
|
||||
set => _Battery = value ?? new Battery.Builder().Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS
|
||||
{
|
||||
public class Engine : IEngine
|
||||
{
|
||||
public Engine(string manufacturer = null)
|
||||
=> Manufacturer = !string.IsNullOrEmpty(manufacturer) ? manufacturer : null;
|
||||
public class Engine : IEngine
|
||||
{
|
||||
public Engine(string manufacturer = null)
|
||||
=> Manufacturer = !string.IsNullOrEmpty(manufacturer) ? manufacturer : null;
|
||||
|
||||
/// <summary>
|
||||
/// Manufacturer of the engine.
|
||||
/// </summary>
|
||||
public string Manufacturer { get; private set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Manufacturer of the engine.
|
||||
/// </summary>
|
||||
public string Manufacturer { get; private set; } = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS
|
||||
{
|
||||
public interface IEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Manufacturer of the engine.
|
||||
/// </summary>
|
||||
string Manufacturer { get; }
|
||||
}
|
||||
public interface IEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Manufacturer of the engine.
|
||||
/// </summary>
|
||||
string Manufacturer { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,21 +3,21 @@ using TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS;
|
|||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS
|
||||
{
|
||||
public interface IDrive
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type of the drive.
|
||||
/// </summary>
|
||||
DriveNS.DriveType Type { get; }
|
||||
public interface IDrive
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type of the drive.
|
||||
/// </summary>
|
||||
DriveNS.DriveType Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Engine driving the bike.
|
||||
/// </summary>
|
||||
IEngine Engine { get; }
|
||||
/// <summary>
|
||||
/// Engine driving the bike.
|
||||
/// </summary>
|
||||
IEngine Engine { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Battery powering the engine.
|
||||
/// </summary>
|
||||
IBattery Battery { get; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Battery powering the engine.
|
||||
/// </summary>
|
||||
IBattery Battery { get; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue