mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 03:56:29 +02:00
Initial version.
This commit is contained in:
parent
193aaa1a56
commit
b72c67a53e
228 changed files with 25924 additions and 0 deletions
65
TINKLib/Services/BluetoothLock/LocksServiceOutOfReach.cs
Normal file
65
TINKLib/Services/BluetoothLock/LocksServiceOutOfReach.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Bike.BluetoothLock;
|
||||
using TINK.Services.BluetoothLock.Tdo;
|
||||
using System;
|
||||
|
||||
namespace TINK.Services.BluetoothLock
|
||||
{
|
||||
/// <summary>
|
||||
/// Facke locks service implementation which simulates locks which are out of reach.
|
||||
/// </summary>
|
||||
public class LocksServiceOutOfReach : ILocksServiceFake
|
||||
{
|
||||
private IEnumerable<LockInfoTdo> LocksInfo { get; set; } = new List<LockInfoTdo>();
|
||||
|
||||
/// <summary> Holds timeout values for series of connecting attemps to a lock or multiple locks. </summary>
|
||||
public ITimeOutProvider TimeOut { get; set; }
|
||||
|
||||
/// <summary> Connects to lock.</summary>
|
||||
/// <param name="authInfo"> Info required to connect to lock.</param>
|
||||
/// <param name="connectTimeout">Timeout for connect operation.</param>
|
||||
public async Task<LockInfoTdo> ConnectAsync(LockInfoAuthTdo authInfo, TimeSpan connectTimeout)
|
||||
{
|
||||
return await Task.FromResult(new LockInfoTdo.Builder { Id = authInfo.Id, Guid = authInfo.Guid, State = null }.Build());
|
||||
}
|
||||
|
||||
/// <summary> No info availalbe because no lock is in reach.</summary>
|
||||
/// <param name="connectTimeout">Timeout for connect operation of a single lock.</param>
|
||||
/// <returns>Empty collection.</returns>
|
||||
public async Task<IEnumerable<LockInfoTdo>> GetLocksStateAsync(IEnumerable<LockInfoAuthTdo> locksInfo, TimeSpan connectTimeout) => await Task.FromResult(LocksInfo);
|
||||
|
||||
|
||||
/// <summary> No changes required because lock state is unknown.</summary>
|
||||
public void UpdateSimulation(BikeCollection bikes)
|
||||
{
|
||||
var locksInfo = new List<LockInfoTdo>();
|
||||
|
||||
// Add and process locks info object
|
||||
foreach (var bikeInfo in bikes.OfType<BikeInfo>())
|
||||
{
|
||||
locksInfo.Add(new LockInfoTdo.Builder { Id = bikeInfo.LockInfo.Id, State = null }.Build());
|
||||
}
|
||||
|
||||
LocksInfo = locksInfo;
|
||||
}
|
||||
|
||||
/// <summary>Gets a lock by bike Id.</summary>
|
||||
/// <param name="bikeId"></param>
|
||||
/// <returns>Lock object</returns>
|
||||
public ILockService this[int bikeId]
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Disconnects lock.</summary>
|
||||
/// <param name="bikeId"> Id of lock to disconnect.</param>
|
||||
/// <param name="bikeGuid"> Guid of lock to disconnect.</param>
|
||||
public async Task<LockingState> DisconnectAsync(int bikeId, Guid bikeGuid) => await Task.FromResult(LockingState.Disconnected);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue