using RobotNet10.FleetManager.Script; using RobotNet10.FleetManager.Services.RobotController; namespace RobotNet10.FleetManager.Services.Script; public class ScriptRobot(string robotId, string robotName, Guid modelId, Guid? mapId, IRobotController robotController) : IRobot { public string RobotId { get; } = robotId; public string Name { get; } = robotName; public Guid ModelId { get; } = modelId; public Guid? MapId { get; } = mapId; public RobotState State => new( robotController.IsReady, robotController.Data.State?.BatteryState.BatteryVoltage ?? 0, robotController.Data.State?.Loads ?? [], robotController.Data.State?.BatteryState.Charging ?? false, robotController.Data.Visualization?.AgvPosition.X ?? 0, robotController.Data.Visualization?.AgvPosition.Y ?? 0, robotController.Data.Visualization?.AgvPosition.Theta ?? 0); public Task AbortMovement() { throw new NotImplementedException(); } public async Task Execute(RobotNet.VDA5050.InstantAction.Action action, CancellationToken cancellationToken) { var result = await robotController.SendInstantActionAsync(action, cancellationToken); return new(result.IsSuccess, result.Message); } public async Task MoveToNode(string nodeName, CancellationToken cancellationToken) { var result = await robotController.MoveToNodeAsync(nodeName, null, cancellationToken); return new(result.IsSuccess, result.Message); } public async Task MoveToNode(string nodeName, double lastAngle, CancellationToken cancellationToken) { var result = await robotController.MoveToNodeAsync(nodeName, lastAngle, cancellationToken); return new(result.IsSuccess, result.Message); } public async Task MoveToStation(string stationName, StationAction action, CancellationToken cancellationToken) { var result = await robotController.MoveToStationAsync(stationName, action, cancellationToken); return new(result.IsSuccess, result.Message); } }