Beispiel #1
0
 public OrderManager(IFleetManagerClient fleetManagerClient,
                     IDispatcherClient dispatcherClient, ICosmosDbClient <Order> cosmosdbClient)
 {
     this.fleetManagerClient = fleetManagerClient;
     this.dispatcherClient   = dispatcherClient;
     this.cosmosdbClient     = cosmosdbClient;
 }
Beispiel #2
0
        public void DisableVirtual()
        {
            IFleetManagerClient client = ClientFactory.CreateTcpFleetManagerClient(settings);

            var result = client.SetKingpinState(IPAddress.Parse("192.0.2.0"), VehicleControllerState.Disabled);

            Assert.AreEqual(0, result.ServiceCode);
        }
Beispiel #3
0
        public void Freeze()
        {
            IFleetManagerClient client = ClientFactory.CreateTcpFleetManagerClient(settings);

            var result = client.SetFrozenState(FrozenState.Frozen);

            Assert.AreEqual(0, result.ServiceCode);
        }
Beispiel #4
0
        public void DisableFleet()
        {
            IFleetManagerClient client = ClientFactory.CreateTcpFleetManagerClient(settings);

            var result = client.SetFleetState(VehicleControllerState.Disabled);

            Assert.AreEqual(0, result.ServiceCode);
        }
Beispiel #5
0
        public static Window CreateFleetClientTutorialWindow(IFleetManagerClient client)
        {
            uiVM.ViewModelLocator.UpdateFleetManagerClientViewModels(client);

            FleetManagerClientTutorialWindow window = new FleetManagerClientTutorialWindow();

            return(window);
        }
        private void HandleShowFleetManager()
        {
            IPAddress           ipAddress = GACore.UI.ViewModel.ViewModelLocator.IPAddressViewModel.IPAddress;
            IFleetManagerClient client    = Model.CreateFleetManagerClient(ipAddress);

            Service.DialogService.CreateFleetClientTutorialWindow(client)
            .ShowDialog();
        }
Beispiel #7
0
        public void RemoveAGV()
        {
            IPAddress           ipAddress = IPAddress.Parse("192.0.2.5");
            IFleetManagerClient client    = ClientFactory.CreateTcpFleetManagerClient(settings);

            var result = client.RemoveVehicle(ipAddress);

            Assert.AreEqual(0, result.ServiceCode);
        }
Beispiel #8
0
        public static bool CreateVirtualVehicleAtOrigin(this IFleetManagerClient fleetManager, IPAddress ipAddress)
        {
            PoseData pose = new PoseData()
            {
                X = 0, Y = 0, Heading = 0
            };

            return(fleetManager.CreateVirtualVehicle(ipAddress, pose));
        }
Beispiel #9
0
        public void CreateVirtual_NaNPose()
        {
            PoseDto pose = new PoseDto()
            {
                X       = double.NaN,
                Y       = double.NaN,
                Heading = double.NaN
            };

            IFleetManagerClient client = ClientFactory.CreateTcpFleetManagerClient(settings);
            IServiceCallResult  result = client.CreateVirtualVehicle("192.168.0.1", pose);

            Assert.AreEqual(0, result.ServiceCode);
        }
Beispiel #10
0
        public void SetPose(double x, double y, double heading)
        {
            IFleetManagerClient client  = ClientFactory.CreateTcpFleetManagerClient(settings);
            PoseDto             poseDto = new PoseDto()
            {
                X       = x,
                Y       = y,
                Heading = heading
            };

            var result = client.SetPose(IPAddress.Parse("192.0.2.5"), poseDto);

            Assert.AreEqual(0, result.ServiceCode);
        }
Beispiel #11
0
        public static bool CreateVirtualVehicle(this IFleetManagerClient fleetManager, IPAddress ipAddress, PoseData pose)
        {
            bool success;
            ServiceOperationResult result = fleetManager.TryCreateVirtualVehicle(ipAddress, pose, out success);

            if (result.IsSuccessfull)
            {
                return(success);
            }
            else
            {
                throw Tools.GetException(result);
            }
        }
Beispiel #12
0
        public void TestVirtual(string ipV4String)
        {
            IFleetManagerClient client = ClientFactory.CreateTcpFleetManagerClient(settings);

            PoseDto poseDto = new PoseDto()
            {
                X       = 0,
                Y       = 0,
                Heading = 0
            };

            var result = client.CreateVirtualVehicle(IPAddress.Parse(ipV4String), poseDto);

            Assert.AreEqual(0, result.ServiceCode);
        }
Beispiel #13
0
        /// <summary>
        /// Attempts to create virtual vehicles in the fleet manager for every AGV template in the collection.
        /// </summary>
        /// <param name="fleetManagerClient">Fleet manager client to use</param>
        public void Populate(IFleetManagerClient fleetManagerClient)
        {
            if (fleetManagerClient == null)
            {
                throw new ArgumentNullException("fleetManagerClient");
            }

            lock (lockObject)
            {
                foreach (AGVTemplate agvTemplate in AGVTemplates.ToList())
                {
                    _ = fleetManagerClient.CreateVirtualVehicle(agvTemplate.GetIPV4Address(), agvTemplate.ToPoseDto());
                }
            }
        }
Beispiel #14
0
        private static void Main(string[] args)
        {
            Console.Title = @"Fleet Client Console";

            IFleetManagerClient client = null;

            Parser.Default.ParseArguments <ConfigureClientOptions>(args)
            .WithParsed <ConfigureClientOptions>(o =>
            {
                client = o.CreateTcpFleetManagerClient();
            }
                                                 )
            .WithNotParsed <ConfigureClientOptions>(o =>
            {
                Environment.Exit(-1);
            });

            while (true)
            {
                Console.Write("fc>");
                args = Console.ReadLine().Split();

                Parser.Default.ParseArguments
                <CreateVirtualVehicleOptions,
                 GetKingpinDescriptionOptions,
                 RemoveOptions,
                 FreezeOption,
                 UnfreezeOption,
                 SetFleetStateOption,
                 SetKingpinStateOption,
                 SetPoseOptions,
                 GetSemVerOptions
                >
                    (args)
                .MapResult(
                    (CreateVirtualVehicleOptions opts) => opts.ExecuteOption(client),
                    (GetKingpinDescriptionOptions opts) => opts.ExecuteOption(client),
                    (RemoveOptions opts) => opts.ExecuteOption(client),
                    (FreezeOption opts) => opts.ExecuteOption(client),
                    (UnfreezeOption opts) => opts.ExecuteOption(client),
                    (SetFleetStateOption opts) => opts.ExecuteOption(client),
                    (SetKingpinStateOption opts) => opts.ExecuteOption(client),
                    (SetPoseOptions opts) => opts.ExecuteOption(client),
                    (GetSemVerOptions opts) => opts.ExecuteOption(client),
                    errs => ServiceCallResultFactory.FromClientException(new Exception("Operation failed"))
                    );
            }
        }
Beispiel #15
0
        public void CreateVirtual()
        {
            PoseDto pose = new PoseDto()
            {
                X       = -3,
                Y       = -2,
                Heading = 0
            };

            IPAddress           ipAddress = IPAddress.Parse("192.0.2.5");
            IFleetManagerClient client    = ClientFactory.CreateTcpFleetManagerClient(settings);

            var result = client.CreateVirtualVehicle(ipAddress, pose);

            Assert.AreEqual(0, result.ServiceCode);
        }
Beispiel #16
0
        private static void Main(string[] args)
        {
            // Here we create an endpoint settings object that defines where the fleet manager service is currently running
            // For this demo we are assuming it is running on localhost, using the default TCP port of 41917.
            EndpointSettings endpointSettings = new EndpointSettings(IPAddress.Loopback, 41916, 41917);

            // Now we create a fleet manager client using the client factory;
            IFleetManagerClient fleetManagerClient = ClientFactory.CreateTcpFleetManagerClient(endpointSettings);

            Console.WriteLine("Press <any> key to create a virtual vehicle 192.168.0.1 at 0,0,0");
            Console.ReadKey(true);

            IPAddress          virtualVehicle = IPAddress.Parse("192.168.0.1");
            IServiceCallResult result         = fleetManagerClient.CreateVirtualVehicle(virtualVehicle, 0, 0, 0);

            if (!result.IsSuccessful())
            {
                Console.WriteLine($"Failed to create virtual vehicle serviceCode:{result.ServiceCode}");
            }

            // Now we can subscribe to new fleet updates
            Console.WriteLine("Press <any> key to subscribe to fleet updates");
            Console.ReadKey(true);

            Console.Clear();
            Console.CursorVisible = false;
            Console.WriteLine("Press <any> key to quit");

            fleetManagerClient.Connected         += FleetManagerClient_Connected;
            fleetManagerClient.Disconnected      += FleetManagerClient_Disconnected;
            fleetManagerClient.FleetStateUpdated += FleetManagerClient_FleetStateUpdated;

            Console.Title = (fleetManagerClient.IsConnected) ? "Connected" : "Disconnected";

            Console.ReadKey(true);

            fleetManagerClient.Connected         -= FleetManagerClient_Connected;
            fleetManagerClient.Disconnected      -= FleetManagerClient_Disconnected;
            fleetManagerClient.FleetStateUpdated -= FleetManagerClient_FleetStateUpdated;

            // The fleet manager client has its own thread which must be disposed.
            fleetManagerClient.Dispose();
        }
Beispiel #17
0
        /// <summary>
        /// Sets the pose of a vehicle.
        /// </summary>
        /// <param name="client">The fleet manager client to use.</param>
        /// <param name="ipAddress">IPv4 address of target vehicle.</param>
        /// <param name="x">X position in meters.</param>
        /// <param name="y">Y position in meters.</param>
        /// <param name="heading">Heading in radians.</param>
        /// <returns>Successful service call result on success.</returns>
        public static IServiceCallResult SetPose(this IFleetManagerClient client, IPAddress ipAddress, double x, double y, double heading)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (ipAddress == null)
            {
                throw new ArgumentNullException("ipAddress");
            }

            PoseDto poseDto = new PoseDto()
            {
                X       = x,
                Y       = y,
                Heading = heading
            };

            return(client.SetPose(ipAddress, poseDto));
        }
Beispiel #18
0
        /// <summary>
        /// Creates a new virtual vehicle.
        /// </summary>
        /// <param name="client">The fleet manager client to use.</param>
        /// <param name="ipV4string">IPv4 address of the vehicle to be created.</param>
        /// <param name="pose">The initialization pose.</param>
        /// <returns></returns>
        public static IServiceCallResult CreateVirtualVehicle(this IFleetManagerClient client, string ipV4string, PoseDto pose)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (string.IsNullOrEmpty(ipV4string))
            {
                throw new ArgumentOutOfRangeException("ipV4string");
            }

            if (pose == null)
            {
                throw new ArgumentNullException("pose");
            }

            IPAddress ipAddress = IPAddress.Parse(ipV4string);

            return(client.CreateVirtualVehicle(ipAddress, pose));
        }
Beispiel #19
0
        private static void HandleCreateVehicle(EndpointSettings endpointSettings)
        {
            // Now we create a fleet manager client using the client factory, and create a virtual vehicle at pose at the node defined as origin.
            //  see: https://github.com/GuidanceAutomation/FleetClients
            using (IFleetManagerClient fleetManagerClient = FleetClients.Core.ClientFactory.CreateTcpFleetManagerClient(endpointSettings))
            {
                IServiceCallResult result = fleetManagerClient.CreateVirtualVehicle(IPAddress.Parse("192.168.0.1"), 0, 0, 0);

                if (!result.IsSuccessful())
                {
                    Console.WriteLine($"Failed to create virtual vehicle serviceCode:{result.ServiceCode}");
                }

                IServiceCallResult enableResult = fleetManagerClient.SetKingpinState(IPAddress.Parse("192.168.0.1"), VehicleControllerState.Enabled);

                if (!enableResult.IsSuccessful())
                {
                    Console.WriteLine($"Failed to enable virtual vehicle serviceCode:{result.ServiceCode}");
                }
            }
        }
        /// <summary>
        /// This method queries for what the state of a given controller's ChargeError flag. This only accounts for that flag,
        /// and only on a KingpinVehicle-type vehicle
        /// </summary>
        /// <param name="vehicleIpAddress">The IPv4 address of the vehicle to query</param>
        /// <returns>If true, there is a charge error being reported</returns>
        public static bool GetChargeFaultFlagForKingpinVehicleAgent(this IFleetManagerClient client, IPAddress vehicleIpAddress)
        {
            // Check the vehicle type is correct
            var descResult = client.GetKingpinDescription(vehicleIpAddress);

            if (descResult.ServiceCode != 0)
            {
                throw new FormatException("Vehicle type of vehicle could not be verified");
            }
            else
            {
                int agvType = int.Parse(descResult.Value.Element("agvType").Attribute("Id").Value);
                if (agvType != 1)
                {
                    throw new FormatException("AgvType of queried vehicle is not compatible with this functionality");
                }
                // otherwise just continue
            }

            bool result = false;

            var currentFleetState = client.FleetState.KingpinStates.ToArray();             // Make a copy of the fleet state to prevent any modification problems

            var vehicle = currentFleetState.FirstOrDefault(e => e.IPAddress == vehicleIpAddress);

            if (vehicle != null)
            {
                byte dockingFaultByte = vehicle.StateCastExtendedData[3];

                if ((DockingFault)dockingFaultByte == DockingFault.ChargeError)
                {
                    result = true;
                }
            }

            return(result);
        }
Beispiel #21
0
        private static void Main(string[] args)
        {
            // Here we create an endpoint settings object that defines where the fleet manager service is currently running
            // For this demo we are assuming it is running on localhost, using the default TCP port of 41917.

            EndpointSettings endpointSettings = new EndpointSettings(IPAddress.Loopback, 41916, 41917);

            // Now we create a fleet manager client using the client factory;
            IFleetManagerClient fleetManagerClient = ClientFactory.CreateTcpFleetManagerClient(endpointSettings);

            Console.WriteLine("Press <any> key to create a virtual vehicle 192.168.0.1 at 0,0,0");
            Console.ReadKey(true);

            IPAddress          virtualVehicle = IPAddress.Parse("192.168.0.1");
            IServiceCallResult result         = fleetManagerClient.CreateVirtualVehicle(virtualVehicle, 0, 0, 0);

            if (!result.IsSuccessful())
            {
                Console.WriteLine($"Failed to create virtual vehicle serviceCode:{result.ServiceCode}");
            }

            // Now we can update the vehicles pose
            Console.WriteLine("Press <any> key to set the pose of the vehicle to 1,1,1.57");
            Console.ReadKey(true);

            result = fleetManagerClient.SetPose(virtualVehicle, 1, 1, 1.57);
            if (!result.IsSuccessful())
            {
                Console.WriteLine($"Failed to set pose serviceCode:{result.ServiceCode}");
            }

            Console.WriteLine("Press <any> key to quit");
            Console.ReadKey(true);

            // The fleet manager client has its own thread which must be disposed.
            fleetManagerClient.Dispose();
        }
Beispiel #22
0
 public FleetTemplateManager(IFleetManagerClient client)
 {
     FleetManagerClient = client ?? throw new ArgumentNullException("client");
 }
Beispiel #23
0
        public FleetTemplateManager CreateFleetTemplateManager(IPAddress ipAddress)
        {
            IFleetManagerClient client = CreateFleetManagerClient(ipAddress);

            return(new FleetTemplateManager(client));
        }
Beispiel #24
0
 public static void UpdateFleetManagerClientViewModels(IFleetManagerClient client)
 {
     FleetManagerClientViewModel.Model = client;
     KingpinStatesViewModel.Model      = client;
 }
Beispiel #25
0
        private static void Main(string[] args)
        {
            // Here we create an endpoint settings object that defines where the fleet manager service is currently running
            // For this demo we are assuming it is running on localhost, using the default TCP port of 41917.
            EndpointSettings endpointSettings = new EndpointSettings(IPAddress.Loopback, 41916, 41917);

            IEnumerable <int> nodeIds = Enumerable.Empty <int>(); // Create an array to store node ids in

            NodeDto startNode = null;

            // Using the map manager client, get the ids of all nodes in the map
            using (IMapClient mapClient = SchedulingClients.Core.ClientFactory.CreateTcpMapClient(endpointSettings))
            {
                IServiceCallResult <NodeDto[]> nodeResults = mapClient.GetAllNodes();

                if (!nodeResults.IsSuccessful())
                {
                    Console.WriteLine($"Failed to get nodes, serviceCode:{nodeResults.ServiceCode}");
                }
                else
                {
                    nodeIds = nodeResults.Value.Select(e => e.Id);
                }

                startNode = nodeResults.Value.First();
            }

            // Now we create a fleet manager client using the client factory, and create a virtual vehicle at pose at the first node.
            //  see: https://github.com/GuidanceAutomation/FleetClients
            using (IFleetManagerClient fleetManagerClient = FleetClients.Core.ClientFactory.CreateTcpFleetManagerClient(endpointSettings))
            {
                IServiceCallResult result = fleetManagerClient.CreateVirtualVehicle(IPAddress.Parse("192.168.0.1"), startNode.Pose.X, startNode.Pose.Y, startNode.Pose.Heading);

                if (!result.IsSuccessful())
                {
                    Console.WriteLine($"Failed to create virtual vehicle serviceCode:{result.ServiceCode}");
                }
            }


            Random random       = new Random(); // Random number generator
            bool   continueFlag = true;

            while (continueFlag)
            {
                Console.WriteLine("Press <any> key to create a random GoTo job, 'q' to quit");

                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.Q:
                {
                    continueFlag = false;
                    break;
                }

                default:
                {
                    // Use the job builder client to create a new goto job.
                    using (IJobBuilderClient jobBuilder = SchedulingClients.Core.ClientFactory.CreateTcpJobBuilderClient(endpointSettings))
                    {
                        // Boiler plate code to pick a random node from the array of nodes.
                        int index  = random.Next(0, nodeIds.Count());
                        int nodeId = nodeIds.ElementAt(index);

                        Console.WriteLine($"Sending to node:{nodeId}");

                        IServiceCallResult <JobDto> createResult = jobBuilder.CreateJob();
                        if (!createResult.IsSuccessful())
                        {
                            Console.WriteLine($"Failed to create job, serviceCode:{createResult.ServiceCode}");
                        }

                        IServiceCallResult <int> gotoResult = jobBuilder.CreateGoToNodeTask(createResult.Value.RootOrderedListTaskId, nodeId);
                        if (!gotoResult.IsSuccessful())
                        {
                            Console.WriteLine($"Failed to create goto task, serviceCode:{gotoResult.ServiceCode}");
                        }

                        IServiceCallResult commitResult = jobBuilder.CommitJob(createResult.Value.JobId);
                        if (!commitResult.IsSuccessful())
                        {
                            Console.WriteLine($"Failed to commit job, serviceCode:{commitResult.ServiceCode}");
                        }
                    }

                    break;
                }
                }
            }
        }
Beispiel #26
0
 public void OneTimeSetup()
 {
     FleetManagerClient = ClientFactory.CreateTcpFleetManagerClient(new EndpointSettings(IPAddress.Loopback));
 }