first commit
This commit is contained in:
@@ -169,6 +169,48 @@ public class CommandService
|
||||
return PostAsync($"/api/asrs/workflow/{op}", null, ct, "ASRS");
|
||||
}
|
||||
|
||||
// ── ASRS qua OPC UA (gateway) ─────────────────────────────────────────
|
||||
public Task AsrsOpcHomeAsync(CancellationToken ct = default)
|
||||
=> PostAsrsOpcAsync("Home", null, "/api/asrs/opc/home", null, ct);
|
||||
|
||||
public Task AsrsOpcRetrieveAsync(int column, int shelf, int conveyor, CancellationToken ct = default)
|
||||
=> PostAsrsOpcAsync("Retrieve", $"{column}.{shelf} → BT{conveyor}", "/api/asrs/opc/retrieve",
|
||||
new { Column = column, Shelf = shelf, Conveyor = conveyor }, ct);
|
||||
|
||||
public Task AsrsOpcStoreAsync(int column, int shelf, int conveyor, CancellationToken ct = default)
|
||||
=> PostAsrsOpcAsync("Store", $"BT{conveyor} → {column}.{shelf}", "/api/asrs/opc/store",
|
||||
new { Column = column, Shelf = shelf, Conveyor = conveyor }, ct);
|
||||
|
||||
public Task AsrsOpcStoreAnyAsync(int conveyor, CancellationToken ct = default)
|
||||
=> PostAsrsOpcAsync("StoreAny", $"BT{conveyor}", "/api/asrs/opc/store-any",
|
||||
new { Conveyor = conveyor }, ct);
|
||||
|
||||
public Task AsrsOpcMoveAsync(int fromColumn, int fromShelf, int toColumn, int toShelf, CancellationToken ct = default)
|
||||
=> PostAsrsOpcAsync("Move", $"{fromColumn}.{fromShelf} → {toColumn}.{toShelf}", "/api/asrs/opc/move",
|
||||
new { FromColumn = fromColumn, FromShelf = fromShelf, ToColumn = toColumn, ToShelf = toShelf }, ct);
|
||||
|
||||
private async Task PostAsrsOpcAsync(string command, string? @params, string url, object? body, CancellationToken ct)
|
||||
{
|
||||
_log.LogAsrsOpcCommand(command, @params);
|
||||
try
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, url);
|
||||
if (body != null)
|
||||
request.Content = JsonContent.Create(body);
|
||||
var resp = await _http.SendAsync(request, ct);
|
||||
if (resp.IsSuccessStatusCode) return;
|
||||
|
||||
string? error = null;
|
||||
try { error = (await resp.Content.ReadFromJsonAsync<ApiErrorBody>(cancellationToken: ct))?.Error; }
|
||||
catch { }
|
||||
_log.LogAsrsOpcRejected(command, error ?? $"HTTP {(int)resp.StatusCode}");
|
||||
}
|
||||
catch (OperationCanceledException) { throw; }
|
||||
catch (Exception ex) { _log.LogAsrsOpcRejected(command, ex.Message); }
|
||||
}
|
||||
|
||||
private sealed record ApiErrorBody(string? Error);
|
||||
|
||||
// ── Workflow ──────────────────────────────────────────────────────────
|
||||
public Task WorkflowX1AAsync(int times, int ng, CancellationToken ct = default)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user