Esempio n. 1
0
        public void AddNewPlane(String producerName, String type, String internationalID, double minimalTrackLength)
        {
            Plane plane = new Plane(producerName, type, internationalID, minimalTrackLength, SystemTime, 0);

            Planes.Add(plane);
            ArrivedPlanes.Add(plane);
            PlaneArrivals.Add("plane " + plane.GetInternationalID() + " arrived " + plane.GetArrivalTime());
        }
Esempio n. 2
0
        /*
         * Returns true if plane id is already in system database
         */
        public bool NotifyArrival(String internationalID)
        {
            Plane            planeToSearch = new Plane(internationalID);
            TreeNode <Plane> planeFound    = Planes.Find(planeToSearch);

            if (planeFound == null)
            {
                return(false);
            }
            else
            {
                planeFound.Data.SetArrivalTime(SystemTime);
                ArrivedPlanes.Add(planeFound.Data);
                PlaneArrivals.Add("plane " + planeFound.Data.GetInternationalID() + " arrived " + planeFound.Data.GetArrivalTime());
                return(true);
            }
        }
Esempio n. 3
0
        public void ReadFromFile()
        {
            SystemTime = DateTime.Parse(File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\SystemTime.txt"));


            String[] planes = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking" +
                                               "\\PlaneDepartureTrackingMSTest\\Planes.txt").Split('\n');
            int test = 0;

            for (int i = 0; i < planes.Length; i++)
            {
                String [] row = planes[i].Split(',');
                if (row.Length >= 6)
                {
                    test++;
                    Plane plane = new Plane(row[0], row[1], row[2],
                                            Double.Parse(row[3]),
                                            DateTime.Parse(row[4]),
                                            Double.Parse(row[6].Replace('.', ',')));
                    plane.SetTrackRequirementTime(DateTime.Parse(row[5]));
                    Planes.Add(plane);
                }
            }
            System.Windows.Forms.MessageBox.Show("" + test);


            String[] trackAllocations = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\TrackAllocations.txt").Split(',');
            for (int i = 0; i < trackAllocations.Length; i++)
            {
                String allocation = trackAllocations[i];
                TrackAllocations.Add(allocation);
            }

            ArrivedPlanes.SplayDisabled = true;
            String[] arrivedPlanes = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking" +
                                                      "\\PlaneDepartureTrackingMSTest\\ArrivedPlanes.txt").Split();
            foreach (String planeID in arrivedPlanes)
            {
                TreeNode <Plane> plane = Planes.Find(new Plane(planeID));
                if (plane != null)
                {
                    ArrivedPlanes.Add(plane.Data);
                }
            }
            ArrivedPlanes.SplayDisabled = false;

            String[] planeArrivals = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\PlaneArrivals.txt").Split(',');
            foreach (String arrival in planeArrivals)
            {
                PlaneArrivals.Add(arrival);
            }

            String[] planeDepartures = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\PlaneDepartures.txt").Split(',');
            foreach (String departure in planeDepartures)
            {
                PlaneDepartures.Add(departure);
            }

            String[] pairs = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking" +
                                              "\\PlaneDepartureTrackingMSTest\\TrackPlanes.txt").Split(',');
            foreach (String pair in pairs)
            {
                String[] splittedPair = pair.Split(':');
                if (splittedPair.Length == 2)
                {
                    String           trackName = splittedPair[0];
                    String           planeID   = splittedPair[1];
                    TreeNode <Plane> plane     = Planes.Find(new Plane(planeID));
                    TreeNode <Track> track     = Tracks.Find(new Track(trackName));
                    if (plane != null && track != null)
                    {
                        plane.Data.Track = track.Data;
                        track.Data.SetPlane(plane.Data);
                    }
                }
            }


            WaitingPlanes.SplayDisabled = true;
            String[] waitingPlanes = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking" +
                                                      "\\PlaneDepartureTrackingMSTest\\WaitingPlanes.txt").Split();
            foreach (String planeID in waitingPlanes)
            {
                TreeNode <Plane> plane = Planes.Find(new Plane(planeID));
                if (plane != null)
                {
                    WaitingPlanes.Add(plane.Data);
                }
            }
            WaitingPlanes.SplayDisabled = false;

            foreach (double length in TrackTypesLengthList)
            {
                TreeNode <TrackType> type = TrackTypes.Find(new TrackType(length));

                if (type != null)
                {
                    type.Data.WaitingPlanesForSearch.SplayDisabled = true;
                    String[] waitingPlanesForSearchTrack = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking" +
                                                                            "\\PlaneDepartureTrackingMSTest\\" +
                                                                            type.Data.Length
                                                                            + "WaitingPlanesForSearch.txt").Split();
                    foreach (String planeID in waitingPlanesForSearchTrack)
                    {
                        TreeNode <Plane> plane = Planes.Find(new Plane(planeID));
                        if (plane != null)
                        {
                            type.Data.WaitingPlanesForSearch.Add(plane.Data);
                        }
                    }
                    type.Data.WaitingPlanesForSearch.SplayDisabled = false;

                    String[] waitingPlanesTrack = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking" +
                                                                   "\\PlaneDepartureTrackingMSTest\\" +
                                                                   type.Data.Length
                                                                   + "WaitingPlanes.txt").Split();
                    foreach (String planeID in waitingPlanesTrack)
                    {
                        TreeNode <Plane> plane = Planes.Find(new Plane(planeID));
                        if (plane != null)
                        {
                            type.Data.WaitingPlanes.Add(plane.Data);
                        }
                    }
                    foreach (Track track in type.Data.Tracks)
                    {
                        String[] trackHistory = File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking" +
                                                                 "\\PlaneDepartureTrackingMSTest\\" +
                                                                 track.GetName() +
                                                                 "History.txt").Split('\n');

                        foreach (String entry in trackHistory)
                        {
                            String[] splittedEntry = entry.Split(',');
                            if (splittedEntry.Length == 2)
                            {
                                track.DepartureHistory.Add(new PlaneShortInfo(splittedEntry[0],
                                                                              DateTime.Parse(splittedEntry[1])));
                            }
                        }
                    }
                }
            }

            waitingCount = Int32.Parse(File.ReadAllText("D:\\.NET Projects\\PlaneDepartureTracking" +
                                                        "\\PlaneDepartureTrackingMSTest\\WaitingCount.txt"));
        }