Beispiel #1
0
        private async Task <Order> DispatchOrderAssignmentAsync(OrderAssignment assignment)
        {
            var order = assignment.Order;
            var robot = assignment.Robot;

            var job = new Job()
            {
                RobotId       = robot.DeviceId,
                OrderId       = order.Id,
                StartPosition = order.StartPosition,
                EndPosition   = order.EndPosition
            };

            var success = await dispatcherClient.SendJobAsync(job);

            if (!success)
            {
                order.Status = OrderStatus.Failed;
                job.Status   = JobStatus.Failed;
            }
            else
            {
                order.Status = OrderStatus.InProgress;
                job.Status   = JobStatus.Queued;
            }

            order.Jobs.Add(job);
            return(order);
        }
Beispiel #2
0
        private async Task <Order> AssignOrderToRobotAsync(Order order, string robotId)
        {
            var robot = await fleetManagerClient.GetRobot(robotId);

            robot = robot?.Telemetry.Status == RobotStatus.Idle ? robot : null;

            var assignment = new OrderAssignment(order, robot);

            await HandleAssignmentOutcomeAsync(assignment);

            return(order);
        }
Beispiel #3
0
        private async Task <Order> HandleAssignmentOutcomeAsync(OrderAssignment assignment)
        {
            var order = assignment.Order;

            if (assignment.IsAssigned)
            {
                await DispatchOrderAssignmentAsync(assignment);
                await StoreOrderAsync(order);
            }
            else
            {
                await StoreOrderFailedAsync(assignment.Order);
            }

            return(order);
        }