示例#1
0
        public static void FetchNode(string node)
        {
            Graph g = Database.Instance.Data.Graphs.FirstOrDefault().Value;

            Node destination = null;

            try
            {
                destination = g.getNode(node);
            }
            catch (NodeException e)
            {
                PrintError(e.Message);
                return;
            }

            try
            {
                if (!destination.IsPalletNode)
                {
                    PrintError("Node '" + destination.Name + "' is not a pallet node");
                    return;
                }

                Database.Instance.Data.AddJob(new PalletJob(Database.Instance.Data.GetNewJobIdentifier(), destination, PalletJobType.fetch));
                PrintSuccess("Job added");
            }
            catch (Exception e)
            {
                PrintError(e.Message);
            }
        }
示例#2
0
        public static void Unblock(String nodeOne, String nodeTwo)
        {
            Graph g = Database.Instance.Data.Graphs.FirstOrDefault().Value;

            try
            {
                Node n1 = g.getNode(nodeOne);
                Node n2 = g.getNode(nodeTwo);

                g.UnblockEdge(n1, n2);

                ConsoleHandler.AddMessage(MessageType.SUCCESS, "Unblocked edge |" + n1.Name + " " + n2.Name + "|");
            }
            catch (NodeException e)
            {
                ConsoleHandler.AddMessage(MessageType.ERROR, e.Message);
            }
        }
示例#3
0
        public static void DeliverNavigate(string type, string node)
        {
            Graph g = Database.Instance.Data.Graphs.FirstOrDefault().Value;

            Node destination = null;

            try
            {
                destination = g.getNode(node);
            }
            catch (NodeException e)
            {
                PrintError(e.Message);
                return;
            }

            if (type == COMMAND_DELIVER)
            {
                try
                {
                    if (!destination.IsPalletNode)
                    {
                        PrintError("Node '" + destination.Name + "' is not a pallet node");
                        return;
                    }

                    Database.Instance.Data.AddJob(new PalletJob(Database.Instance.Data.GetNewJobIdentifier(), destination, PalletJobType.deliver));
                    PrintSuccess("Job added");
                }
                catch (Exception e)
                {
                    PrintError(e.Message);
                }
            }
            else if (type == COMMAND_NAVIGATE)
            {
                try
                {
                    Database.Instance.Data.AddJob(new NavigateJob(Database.Instance.Data.GetNewJobIdentifier(), destination));
                    PrintSuccess("Job added");
                }
                catch (Exception e)
                {
                    PrintError(e.Message);
                }
            }
            else
            {
                PrintIncorrectUse();
                FetchNodeHelp();
            }
        }
示例#4
0
        public void TryFindNodeInGraphWithMultipleSameNode()
        {
            Graph g = new Graph();

            Node sameNodeOne = new Node("a");
            Node sameNodeTwo = new Node("A");

            g.AddNode(sameNodeOne);
            g.AddNode(sameNodeTwo);

            Node searchNode = g.getNode("a");
        }
示例#5
0
        public void TryFindNotExistingNodeInGraph()
        {
            Graph g = new Graph();

            Node searchNode = g.getNode("a");
        }
示例#6
0
        public void FindNodeInGraphByNameDifferentLettercaseTwo()
        {
            Graph g = new Graph();

            Node expected = new Node("A");

            g.AddNode(expected);

            Node actual = g.getNode("a");

            Assert.IsTrue(expected.Equals(actual));
        }
示例#7
0
        public void FindNodeInGraphByNameBothUppercase()
        {
            Graph g = new Graph();

            Node expected = new Node("A");

            g.AddNode(expected);

            Node actual = g.getNode("A");

            Assert.IsTrue(expected.Equals(actual));
        }
示例#8
0
        // Used to check if position information is required
        public static void UpdatePositionInformation()
        {
            Graph    g = Database.Instance.Data.Graphs.FirstOrDefault().Value;
            Forklift f = Database.Instance.Data.Forklifts.FirstOrDefault().Value;

            if (f.RearNode == null || f.FrontNode == null)
            {
                ConsoleHandler.AddMessage(MessageType.REGULAR, "Information about PALL-E position is required.");

                bool result;

                do
                {
                    Node rearNode  = null;
                    Node frontNode = null;

                    // The user must enter a faceing node
                    while (frontNode == null)
                    {
                        try
                        {
                            ConsoleHandler.AddMessage(MessageType.REGULAR, "Enter name of front node...");
                            String faceing = Console.ReadLine();
                            ConsoleHandler.ClearCommand();
                            frontNode = g.getNode(faceing);
                        }
                        catch (NodeException e)
                        {
                            ConsoleHandler.AddMessage(MessageType.ERROR, "Error when finding node: '" + e.Message + "'");
                        }
                    }

                    // The user must enter a last node
                    while (rearNode == null)
                    {
                        try
                        {
                            ConsoleHandler.AddMessage(MessageType.REGULAR, "Enter name of rear node...");
                            String last = Console.ReadLine();
                            ConsoleHandler.ClearCommand();
                            rearNode = g.getNode(last);
                        }
                        catch (NodeException e)
                        {
                            ConsoleHandler.AddMessage(MessageType.ERROR, "Error when finding node: '" + e.Message + "'");
                        }
                    }

                    // Update node information
                    result = f.UpdateNodes(frontNode, rearNode);

                    Commands.PrintSuccess("Position updated");
                    Commands.Position();
                }while (!result);
            }
            else
            {
                ConsoleHandler.AddMessage(MessageType.REGULAR, ConsoleHandler.DNS + " position information:");
                ConsoleHandler.AddMessage(MessageType.REGULAR, "Front-node: '" + f.FrontNode.Name + "'. Rear-node: '" + f.RearNode.Name + "'");
            }
        }
示例#9
0
        public static void Palletlist(string subcommand, string name, string location)
        {
            if (subcommand == SUBCOMMAND_ADD)
            {
                if (location == "forklift")
                {
                    Forklift f = Database.Instance.Data.Forklifts.FirstOrDefault().Value;

                    if (f.HasPallet)
                    {
                        PrintError("Forklift is already carrying pallet: '" + f.Payload.Name + "'");
                        return;
                    }

                    try
                    {
                        Pallet p = new Pallet(Database.Instance.Data.GetNewPalletIdentifier(), name.ToUpper(), null);
                        Database.Instance.Data.AddPallet(p);
                        f.Payload = p;

                        PrintSuccess("Pallet added.");
                    }
                    catch (PalletException e)
                    {
                        PrintError(e.Message);
                        return;
                    }
                }
                else
                {
                    Graph g = Database.Instance.Data.Graphs.FirstOrDefault().Value;

                    try
                    {
                        Node n = g.getNode(location);

                        if (!n.IsPalletNode)
                        {
                            PrintError("Node '" + n.Name + "' is not a pallet-node.");
                            return;
                        }

                        if (n.HasPallet)
                        {
                            PrintError("Node '" + n.Name + "' is already containing a pallet.");
                            return;
                        }

                        try
                        {
                            Pallet p = new Pallet(Database.Instance.Data.GetNewPalletIdentifier(), name.ToUpper(), n);
                            Database.Instance.Data.AddPallet(p);

                            PrintSuccess("Pallet added.");
                        }
                        catch (PalletException e)
                        {
                            PrintError(e.Message);
                            return;
                        }
                    }
                    catch (NodeException e)
                    {
                        PrintError(e.Message);
                        return;
                    }
                }
            }
            else
            {
                PrintIncorrectUse();
                PalletlistHelp();
            }
        }