Add IsFull() and ResetPosition() to User

Also set Token setter to public
This commit is contained in:
2021-01-25 21:08:09 +01:00
parent eb3401f4a4
commit e42974886d

View File

@@ -8,7 +8,7 @@ namespace Akari.Provider.WaveshareUART.Users
{ {
public string Name { get; private set; } public string Name { get; private set; }
public string Token { get; private set; } public string Token { get; set; }
public ushort Start { get; private set; } public ushort Start { get; private set; }
public ushort Position { get; private set; } public ushort Position { get; private set; }
@@ -33,7 +33,7 @@ namespace Akari.Provider.WaveshareUART.Users
public bool IncrementPosition() public bool IncrementPosition()
{ {
if (Position - Start < UsersManager.RangeLength) if (Count < UsersManager.RangeLength)
{ {
Position++; Position++;
@@ -43,8 +43,15 @@ namespace Akari.Provider.WaveshareUART.Users
return false; return false;
} }
public bool IsFull() => Count >= UsersManager.RangeLength;
public bool IsInRange(int position) => position >= Start && position < Position; public bool IsInRange(int position) => position >= Start && position < Position;
public void ResetPosition()
{
Position = Start;
}
public override string ToString() => Name; public override string ToString() => Name;
} }
} }