mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 13:57:28 +02:00
Version 3.0.362
This commit is contained in:
parent
cba4da9357
commit
4ff3307997
128 changed files with 3954 additions and 3193 deletions
|
@ -1,6 +1,6 @@
|
|||
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
|
||||
{
|
||||
public interface IBikeInfoMutable : BikeInfoNS.BC.IBikeInfoMutable
|
||||
public interface IBikeInfoMutable : BC.IBikeInfoMutable
|
||||
{
|
||||
ILockInfoMutable LockInfo { get; }
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using TINK.Services.Geolocation;
|
||||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
|
||||
{
|
||||
|
@ -20,6 +21,14 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
|
|||
|
||||
byte[] Seed { get; }
|
||||
|
||||
/// <summary> Timestamp of the last locking state change.</summary>
|
||||
DateTime? LastLockingStateChange { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current location of the bike, null if location is unknown.
|
||||
/// </summary>
|
||||
IGeolocation Location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the version info of the locks.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using TINK.Services.Geolocation;
|
||||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
|
||||
{
|
||||
|
@ -7,16 +8,24 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
|
|||
/// <summary> Lock info object. </summary>
|
||||
private LockInfo LockInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Delegate to create time stamp.
|
||||
/// </summary>
|
||||
private Func<DateTime> _nowDelegate;
|
||||
|
||||
/// <summary> Constructs a bluetooth lock info object. </summary>
|
||||
/// <param name="id">Id of lock must always been known when constructing an lock info object.</param>
|
||||
/// <param name="nowDelegate">Delegate to create time stamp if null DateTime.Now is used.</param>
|
||||
public LockInfoMutable(
|
||||
int id,
|
||||
Guid guid,
|
||||
byte[] userKey,
|
||||
byte[] adminKey,
|
||||
byte[] seed,
|
||||
LockingState state)
|
||||
LockingState state,
|
||||
Func<DateTime> nowDelegate = null)
|
||||
{
|
||||
_nowDelegate = nowDelegate ?? (() => DateTime.Now);
|
||||
LockInfo = new LockInfo.Builder() { Id = id, Guid = guid, UserKey = userKey, AdminKey = adminKey, Seed = seed, State = state }.Build();
|
||||
}
|
||||
|
||||
|
@ -35,12 +44,34 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
|
|||
|
||||
public byte[] AdminKey => LockInfo.AdminKey;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the locking state.
|
||||
/// </summary>
|
||||
public LockingState State
|
||||
{
|
||||
get => LockInfo.State;
|
||||
set => LockInfo = new LockInfo.Builder(LockInfo) { State = value }.Build();
|
||||
set
|
||||
{
|
||||
if (LockInfo.State == value)
|
||||
{
|
||||
// State does not change, nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
Location = null; // Invalidate location.
|
||||
LastLockingStateChange = _nowDelegate(); // Get time stamp when state change happened.
|
||||
LockInfo = new LockInfo.Builder(LockInfo) { State = value }.Build();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the timestamp of the last locking state change.</summary>
|
||||
public DateTime? LastLockingStateChange { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current location of the bike, null if location is unknown.
|
||||
/// </summary>
|
||||
public IGeolocation Location { get; set; }
|
||||
|
||||
/// <summary> Holds the percentage of lock battery.</summary>
|
||||
public double BatteryPercentage { get; set; } = double.NaN;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue