using RobotNet10.FleetManager.Services.TrafficControl.Models; namespace RobotNet10.FleetManager.Services.TrafficControl; /// /// Service for traffic control and conflict management between robots /// public interface ITrafficControlService { /// /// Plans a route from start node to goal node for a robot /// /// Robot ID /// Start node ID /// Goal node ID /// Cancellation token /// RobotRoute if successful, null otherwise Task PlanRouteAsync( string robotId, Guid startNodeId, Guid goalNodeId, CancellationToken cancellationToken = default); /// /// Plans a route with optional constraints (angle, startDirection, finalDirection) /// /// Robot ID /// Start node ID /// Goal node ID /// Optional goal angle in degrees /// Optional start direction constraint /// Optional final direction constraint /// Cancellation token /// RobotRoute if successful, null otherwise Task PlanRouteAsync( string robotId, Guid startNodeId, Guid goalNodeId, double? goalAngle, RobotNet10.GlobalPathPlanner.Model.Orientation? startDirection, RobotNet10.GlobalPathPlanner.Model.Orientation? finalDirection, CancellationToken cancellationToken = default); /// /// Plans a route from current position (x, y, theta) to goal node /// /// Robot ID /// Current X position /// Current Y position /// Current orientation in degrees /// Goal node ID /// Optional goal angle in degrees /// Optional start direction constraint /// Optional final direction constraint /// Cancellation token /// RobotRoute if successful, null otherwise Task PlanRouteFromPositionAsync( string robotId, double x, double y, double theta, Guid goalNodeId, double? goalAngle, RobotNet10.GlobalPathPlanner.Model.Orientation? startDirection, RobotNet10.GlobalPathPlanner.Model.Orientation? finalDirection, CancellationToken cancellationToken = default); /// /// Plan route from current position (x, y, theta) to goal node /// Task PlanRouteFromPositionACSTrafficAsync( string robotId, double x, double y, double theta, Guid goalNodeId, double? goalAngle, RobotNet10.GlobalPathPlanner.Model.Orientation? startDirection, RobotNet10.GlobalPathPlanner.Model.Orientation? finalDirection, CancellationToken cancellationToken = default); /// /// Detects all conflicts between active robots /// /// Cancellation token /// List of detected conflicts Task> DetectConflictsAsync(CancellationToken cancellationToken = default); /// /// Resolves a conflict /// /// Conflict to resolve /// Cancellation token /// True if resolved successfully Task ResolveConflictAsync(Conflict conflict, CancellationToken cancellationToken = default); /// /// Releases horizon segments into base when safe /// /// Robot ID /// Number of segments to release /// Cancellation token /// True if released successfully Task ReleaseHorizonSegmentAsync( string robotId, int segmentCount, CancellationToken cancellationToken = default); /// /// Updates robot route (typically for rerouting) /// /// Robot ID /// New route /// Cancellation token /// True if updated successfully Task UpdateRobotRouteAsync( string robotId, RobotRoute newRoute, CancellationToken cancellationToken = default); /// /// Gets all active routes for all robots /// /// Dictionary of robot ID to RobotRoute Task> GetAllActiveRoutesAsync(); /// /// Gets route for a specific robot /// /// Robot ID /// RobotRoute if exists, null otherwise Task GetRobotRouteAsync(string robotId); /// /// Sets priority for a robot /// /// Robot ID /// Priority information /// True if set successfully Task SetRobotPriorityAsync(string robotId, RobotPriority priority); /// /// Gets priority for a robot /// /// Robot ID /// RobotPriority (default if not set) Task GetRobotPriorityAsync(string robotId); /// /// Removes priority for a robot (resets to default) /// /// Robot ID /// True if removed successfully Task RemoveRobotPriorityAsync(string robotId); /// /// Evaluates conflicts for resolution optimization /// /// List of conflicts to evaluate /// Cancellation token /// Sorted list of conflicts by priority Task> EvaluateConflictsForResolutionAsync( List conflicts, CancellationToken cancellationToken = default); /// /// Sends OrderUpdate to robot with new segments /// /// Robot ID /// New segments to add to order /// Cancellation token /// True if sent successfully Task SendOrderUpdateAsync( string robotId, List newSegments, CancellationToken cancellationToken = default); /// /// Reserves edges for a robot's route segments /// /// Robot ID /// Order ID /// Route segments containing edges to reserve /// Cancellation token /// True if reserved successfully Task ReserveEdgesAsync( string robotId, string orderId, List segments, CancellationToken cancellationToken = default); /// /// Gets all reservations for a specific edge /// /// Edge ID /// Cancellation token /// List of edge reservations Task> GetEdgeReservationsAsync( Guid edgeId, CancellationToken cancellationToken = default); /// /// Checks if an edge is available during a time period /// /// Edge ID /// Start time /// End time /// Cancellation token /// True if available, false otherwise Task IsEdgeAvailableAsync( Guid edgeId, DateTime fromTime, DateTime toTime, CancellationToken cancellationToken = default); /// /// Releases all reservations for a robot's order /// /// Robot ID /// Order ID /// Cancellation token /// True if released successfully Task ReleaseReservationsAsync( string robotId, string orderId, CancellationToken cancellationToken = default); /// /// Checks and releases horizon segments for robots near end of Base /// /// Optional: specific robot ID, null for all robots /// Cancellation token Task CheckAndReleaseHorizonsAsync( string? robotId = null, CancellationToken cancellationToken = default); }