62 lines
3.0 KiB
C#
62 lines
3.0 KiB
C#
namespace Lab505.Script;
|
|
|
|
/// <summary>
|
|
/// Unified condition checker exposed to user scripts.
|
|
/// Type 1 — instant: State.Assert(s => s.ImrReady, "msg")
|
|
/// Type 2 — async wait: await State.WaitUntil(s => s.ImrReadyAtC1)
|
|
/// await State.Require(s => s.C1HasGoods, "msg")
|
|
/// </summary>
|
|
public interface ICondition
|
|
{
|
|
// ── IMR ──────────────────────────────────────────────────────────────
|
|
bool ImrOnline { get; }
|
|
bool ImrReady { get; }
|
|
bool ImrBusy { get; }
|
|
bool ImrAtC1 { get; }
|
|
bool ImrAtABB { get; }
|
|
bool ImrReadyAtC1 { get; }
|
|
bool ImrReadyAtABB { get; }
|
|
|
|
// ── AMR ──────────────────────────────────────────────────────────────
|
|
bool AmrOnline { get; }
|
|
bool AmrReady { get; }
|
|
bool AmrBusy { get; }
|
|
bool AmrAtCap1 { get; }
|
|
bool AmrAtCap2 { get; }
|
|
bool AmrReadyAtCap1 { get; }
|
|
bool AmrReadyAtCap2 { get; }
|
|
|
|
// ── C1 ───────────────────────────────────────────────────────────────
|
|
bool C1Online { get; }
|
|
bool C1HasGoods { get; }
|
|
bool C1NotGoods { get; }
|
|
bool C1Ready { get; }
|
|
bool C1Idle { get; }
|
|
bool C1InOn { get; }
|
|
bool C1OutOn { get; }
|
|
bool C1IMRinOn { get; }
|
|
bool C1IMRoutOn { get; }
|
|
|
|
// ── C2 ───────────────────────────────────────────────────────────────
|
|
bool C2Online { get; }
|
|
bool C2HasGoods { get; }
|
|
bool C2Ready { get; }
|
|
bool C2Idle { get; }
|
|
bool C2InOn { get; }
|
|
bool C2OutOn { get; }
|
|
|
|
// ── Dobot ────────────────────────────────────────────────────────────
|
|
bool DobotOnline { get; }
|
|
|
|
// ── Condition methods ─────────────────────────────────────────────────
|
|
|
|
/// <summary>Instant check — throws InvalidOperationException if false. Use before sending a command.</summary>
|
|
void Assert(Func<ICondition, bool> condition, string errorMessage);
|
|
|
|
/// <summary>Event-driven wait. Returns false on timeout, throws on cancellation.</summary>
|
|
Task<bool> WaitUntil(Func<ICondition, bool> condition, int timeoutMs = 1_200_000, CancellationToken ct = default);
|
|
|
|
/// <summary>Event-driven wait. Throws TimeoutException if condition not met in time.</summary>
|
|
Task Require(Func<ICondition, bool> condition, string errorMessage, int timeoutMs = 1_200_000, CancellationToken ct = default);
|
|
}
|