initial commit
This commit is contained in:
43
Lab505.Script/Sim/SimAsrs.cs
Normal file
43
Lab505.Script/Sim/SimAsrs.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Lab505.Script.Facades;
|
||||
|
||||
namespace Lab505.Script.Sim;
|
||||
|
||||
/// <summary>Per-user in-memory ASRS simulation. All operations complete after a fixed delay.</summary>
|
||||
public sealed class SimAsrs : IAsrsFacade
|
||||
{
|
||||
private const int OpDelayMs = 1200;
|
||||
|
||||
public bool IsBusy { get; private set; }
|
||||
public event Action? OnOperationStateChanged;
|
||||
|
||||
public bool IsLocked(string key) => false;
|
||||
|
||||
private async Task RunOp(CancellationToken token)
|
||||
{
|
||||
IsBusy = true;
|
||||
OnOperationStateChanged?.Invoke();
|
||||
try { await Task.Delay(OpDelayMs, token); }
|
||||
finally
|
||||
{
|
||||
IsBusy = false;
|
||||
OnOperationStateChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public Task SYSTEM_HOMING(CancellationToken token = default) => RunOp(token);
|
||||
public Task X1_S12(CancellationToken token = default) => RunOp(token);
|
||||
public Task X2_S12(CancellationToken token = default) => RunOp(token);
|
||||
public Task X3_S12(CancellationToken token = default) => RunOp(token);
|
||||
public Task X1_S34(CancellationToken token = default) => RunOp(token);
|
||||
public Task X2_S34(CancellationToken token = default) => RunOp(token);
|
||||
public Task X3_S34(CancellationToken token = default) => RunOp(token);
|
||||
public Task X1_R12(CancellationToken token = default) => RunOp(token);
|
||||
public Task X2_R12(CancellationToken token = default) => RunOp(token);
|
||||
public Task X3_R12(CancellationToken token = default) => RunOp(token);
|
||||
public Task X1_R43(CancellationToken token = default) => RunOp(token);
|
||||
public Task X2_R43(CancellationToken token = default) => RunOp(token);
|
||||
public Task X3_R43(CancellationToken token = default) => RunOp(token);
|
||||
|
||||
public Task<bool> WaitCoil(Func<bool?> selector, bool target, int timeoutMs = 10000) =>
|
||||
Task.FromResult(true);
|
||||
}
|
||||
Reference in New Issue
Block a user