예제 #1
0
        private void OnNewTrack(TrackTypes type)
        {
            TrackViewModel track = type switch
            {
                TrackTypes.Straight => TrackStraightViewModel.CreateNew(this),
                TrackTypes.Curved => TrackCurvedViewModel.CreateNew(this),
                TrackTypes.Crossing => TrackCrossingViewModel.CreateNew(this),
                TrackTypes.EndPiece => TrackEndPieceViewModel.CreateNew(this),
                TrackTypes.Flex => TrackFlexViewModel.CreateNew(this),

                TrackTypes.Turnout => TrackTurnoutViewModel.CreateNew(this),
                TrackTypes.CurvedTurnout => TrackCurvedTurnoutViewModel.CreateNew(this),
                TrackTypes.DoubleSlipSwitch => TrackDoubleSlipSwitchViewModel.CreateNew(this),
                TrackTypes.DoubleCrossover => TrackDoubleCrossoverViewModel.CreateNew(this),

                TrackTypes.Table => TrackTableViewModel.CreateNew(this),

                TrackTypes.Group => TrackGroupViewModel.CreateNew(this),
                _ => null
            };

            track.UpdateTrack();
            this.Tracks.Add(track);
            this.SelectedTrack = track;
        }
예제 #2
0
        private void InitBtns()
        {
            var colorStyle = new ControlDisableStyleController.ColorStyle(
                Color.DarkSlateGray,
                Color.FromArgb(224, 224, 224),
                Color.White,
                Color.LightGray);

            Button[] buttons =
            {
                viewNatsBtn,
                viewPacotsBtn,
                viewAusotsBtn,
                BtnNatsDn,
                BtnPacotsDn,
                BtnAusotsDn,
                downloadAllBtn,
                importBtn
            };

            buttons.ForEach(b =>
            {
                var styleController = new ControlDisableStyleController(b, colorStyle);
                styleController.Activate();
            });

            TrackTypes.ForEach(t =>
            {
                ViewBtn(t).Enabled     = false;
                DownloadBtn(t).Enabled = true;
            });

            downloadAllBtn.Enabled = true;
        }
예제 #3
0
파일: Track.cs 프로젝트: axtens/Axtension
        public void SetTrackType(string str)
        {
            if (!this.trackFlag)
            {
                return;
            }

            if (str.ToLower() == "unbuffered")
            {
                this.trackType = TrackTypes.UNBUFFERED;
            }
            else
            {
                if (str.ToLower() == "buffered")
                {
                    this.trackType = TrackTypes.BUFFERED;
                }
                else
                {
                    if (str.ToLower() == "withheld")
                    {
                        this.trackType = TrackTypes.WITHHELD;
                    }
                }
            }
        }
예제 #4
0
        public void Init(AirwayNetwork airwayNetwork, ToolStripStatusLabel statusLbl)
        {
            this.airwayNetwork = airwayNetwork;
            this.statusLbl     = statusLbl;

            RefreshListViewColumnWidth();
            InitImages();
            InitCBox();
            InitPicBoxes();
            InitBtns();

            // The event handlers are added after the form is created.
            // This way the events won't fire at form creation.
            TrackTypes.ForEach(t =>
            {
                DownloadBtn(t).Click  += (s, e) => DownloadAndEnableTracks(t);
                EnabledCBox(t).Enabled = false;
                EnabledCBox(t).SelectedIndexChanged += (s, e) => SetTrackEnabled(t);
                ViewBtn(t).Click += (s, e) => ViewTracks(t);
                DownloadBtn(t).EnabledChanged += RefreshDownloadAllBtnEnabled;
            });

            downloadAllBtn.Click              += (s, e) => DownloadAndEnableTracks();
            downloadAllBtn.EnabledChanged     += (s, e) => importBtn.Enabled = downloadAllBtn.Enabled;
            airwayNetwork.TrackMessageUpdated += (s, e) => RefreshViewTrackBtns();
            airwayNetwork.StatusChanged       += (s, e) => RefreshStatus(((TrackEventArg)e).TrackType);
            Closing += CloseForm;
            ScrollBarsUtil.OverrideScrollBar(panel1, this);
        }
예제 #5
0
        public bool RemovePlaneFromWaiting(String id)
        {
            TreeNode <Plane> plane = WaitingPlanes.Find(new Plane(id));

            if (plane != null)
            {
                ArrivedPlanes.Add(plane.Data);
                plane.Data.SetPriority(0);
                WaitingPlanes.Delete(plane.Data);
                if (plane.Data.Track != null)
                {
                    plane.Data.Track.SetPlane(null);
                    plane.Data.Track = null;
                }
                else
                {
                    TrackType            typeToSearch = new TrackType(plane.Data.GetMinimalTrackLength());
                    TreeNode <TrackType> type         = TrackTypes.Find(typeToSearch);
                    type.Data.WaitingPlanes.Delete(plane.Data);
                    type.Data.WaitingPlanesForSearch.Delete(plane.Data);
                }
                TrackAllocations.Add("plane ID" + plane.Data.GetInternationalID() + " removed from waiting queue");
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
 void forceParameters()
 {
     switch( m_Prototype )
     {
     case GameTypes.LARGE_FULL_COLLISION:
         m_TrackType = TrackTypes.ANALOGUE_JUMPS1;
         m_CollisionType = CollisionTypes.FULL_COLLISION;
         m_JumpType = JumpTypes.DIGITAL;
         m_viewDistance = 1.0f;
         break;
     case GameTypes.SMALL_FRONT_COLLISION:
         m_TrackType = TrackTypes.EASY_JUMPS1;
         m_CollisionType = CollisionTypes.FRONT_COLLISION;
         m_JumpType = JumpTypes.FAST_DIGITAL;
         m_viewDistance = 2.0f;
         break;
     case GameTypes.JOYRIDE_STYLE:
         m_TrackType = TrackTypes.ANALOGUE_JUMPS1;
         m_CollisionType = CollisionTypes.FULL_COLLISION;
         m_JumpType = JumpTypes.HIGH_ANALOGUE;
         m_viewDistance = 1.0f;
         break;
     case GameTypes.USER_CUSTOM:
         break;
     }
 }
예제 #7
0
        private TrackType GenerateTrackType(double length)
        {
            TrackType trackType = new TrackType(length);

            TrackTypes.Add(trackType);
            TrackTypesLengthList.Add(length);
            return(trackType);
        }
예제 #8
0
 internal GCHandle AllocGCHandle(TrackTypes track = TrackTypes.Untrack)
 {
     gcHandle = GCHandle.Alloc(this);
     if (track != TrackTypes.Untrack && PythonEngine.ShutdownMode == ShutdownMode.Reload)
     {
         _managedObjs.Add(this, track);
     }
     return(gcHandle);
 }
예제 #9
0
 internal GCHandle AllocGCHandle(TrackTypes track = TrackTypes.Untrack)
 {
     gcHandle = GCHandle.Alloc(this);
     if (track != TrackTypes.Untrack)
     {
         _managedObjs.Add(this, track);
     }
     return(gcHandle);
 }
예제 #10
0
        public bool Show(Track track)
        {
            var show = track.Language == PreferredLanguage &&
                       TrackTypes.Contains(track.Type);
            var hide = (track.IsHidden && HideHiddenTracks) ||
                       (!track.Codec.IsMuxable && HideUnsupportedCodecs);

            return(show && !hide);
        }
예제 #11
0
        //========= CONSTRUCTORS =========
        #region Constructors

        /**<summary>Constructs the default track design.</summary>*/
        public TrackDesign()
        {
            this.TrackType              = TrackTypes.None;
            this.Unknown0x01            = 0;
            this.SpecialTrackFlags      = 0;
            this.OperatingMode          = OperatingModes.NormalMode;
            this.VehicleColorScheme     = 0;
            this.VehicleColorSpecifiers = new RemapColors[64];

            this.Unknown0x48 = 0;

            this.EntranceType              = EntranceTypes.Plain;
            this.AirTime                   = 0;
            this.DepartureControlFlags     = DepartureControlFlags.UseMaximumTime | DepartureControlFlags.FullLoad;
            this.NumberOfTrains            = 0;
            this.CarsPerTrain              = 0;
            this.MinimumWaitTime           = 10;
            this.MaximumWaitTime           = 60;
            this.PoweredSpeedLapsMaxPeople = 0;
            this.MaximumSpeed              = 0;
            this.AverageSpeed              = 0;
            this.RideLength                = 0;
            this.PositiveGForce            = 0;
            this.NegativeGForce            = 0;
            this.LateralGForce             = 0;
            this.NumberOfInversions        = 0;
            this.NumberOfDrops             = 0;
            this.HighestDrop               = 0;
            this.Excitement                = 0;
            this.Intensity                 = 0;
            this.Nausea = 0;

            this.Unknown0x5E = 0;
            this.Unknown0x5F = 0;

            this.TrackSpineColors   = new RemapColors[4];
            this.TrackRailColors    = new RemapColors[4];
            this.TrackSupportColors = new RemapColors[4];

            this.Unknown0x6C = 0;
            this.Unknown0x6D = 0;
            this.Unknown0x6E = 0;

            this.SixFlagsRide = 0;

            this.ObjectHeader = new ObjectDataHeader();

            this.RideMapWidth  = 0;
            this.RideMapHeight = 0;

            this.VehicleAdditionalColors = new RemapColors[32];
            this.CircuitsChainLiftSpeed  = 0;

            this.MazeTiles   = new List <MazeTile>();
            this.TrackPieces = new List <TrackPiece>();
        }
예제 #12
0
        public bool NotifyDeparture(String internationalID)
        {
            Plane            planeToSearch = new Plane(internationalID);
            TreeNode <Plane> planeFound    = WaitingPlanes.Find(planeToSearch);

            if (planeFound != null && planeFound.Data.Track != null)
            {
                planeFound.Data.SetDepartureTime(SystemTime);
                PlaneDepartures.Add("plane ID" + planeFound.Data.GetInternationalID() + " arrived from the track "
                                    + planeFound.Data.Track.GetName() + " " + planeFound.Data.GetDepartureTime().ToString());
                TrackType type = planeFound.Data.Track.GetLengthType();
                planeFound.Data.Track.DepartureHistory.Add(new PlaneShortInfo(planeFound.Data.GetInternationalID(),
                                                                              planeFound.Data.GetDepartureTime()));
                planeFound.Data.Track.SetPlane(null);
                planeFound.Data.Track = null;
                WaitingPlanes.Delete(planeFound.Data);


                foreach (Track track in type.Tracks)
                {
                    if (track.GetPlane() == null && type.WaitingPlanes.Root != null)
                    {
                        Plane plane = type.WaitingPlanes.DeleteMin();
                        plane.Track = track;
                        track.SetPlane(plane);
                        TrackAllocations.Add("plane ID" + plane.GetInternationalID() + " to the track " + track.GetName());
                        type.WaitingPlanesForSearch.Delete(plane);
                    }

                    if (waitingCount / TrackList.Count > 5)
                    {
                        int upperTypeIndex = TrackTypesLengthList.IndexOf(type.Length) + 1;
                        if (upperTypeIndex < TrackTypesLengthList.Count)
                        {
                            TrackType upperType = TrackTypes.Find(new TrackType(TrackTypesLengthList[upperTypeIndex])).Data;
                            foreach (Track tr in upperType.Tracks)
                            {
                                if (tr.GetPlane() == null)
                                {
                                    planeFound.Data.Track = tr;
                                    tr.SetPlane(planeFound.Data);
                                    TrackAllocations.Add("!!! plane ID" + planeFound.Data.GetInternationalID() + " to " + tr.GetName()
                                                         );
                                    break;
                                }
                            }
                        }
                    }
                }

                waitingCount--;
                return(true);
            }
            return(false);
        }
예제 #13
0
        public bool Show(Playlist playlist)
        {
            var show = playlist.Length >= MinDuration &&
                       playlist.ChapterCount >= MinChapterCount &&
                       TrackTypes.Contains(playlist.Type);
            var hide = (playlist.IsDuplicate && HideDuplicatePlaylists) ||
                       (playlist.HasDuplicateStreamClips && HideDuplicateStreamClips) ||
                       (playlist.HasLoops && HideLoops) ||
                       (playlist.HasHiddenFirstTracks && HideHiddenFirstTracks);

            return(show && !hide);
        }
예제 #14
0
        public Track(String[] Fields, Decimal furlongs)
        {
            //declares and assigns
            string tt;

            AllWeather = (Fields[24].ToLower() == "a");
            TrackTypes.TryGetValue(Fields[6], out tt);
            TrackType      = tt;
            TrackTypeShort = Fields[6];
            TrackName      = Fields[0];
            Furlongs       = Math.Round(((Convert.ToDecimal(Regex.Replace(Fields[5], "[^.0-9]", "")) * 3) / 5280) * 8, 2);
        }
예제 #15
0
        public bool ChangePlanePriority(String id, double priority)
        {
            TreeNode <Plane> plane = WaitingPlanes.Find(new Plane(id));

            if (plane != null)
            {
                TrackType            typeToSearch = new TrackType(plane.Data.GetMinimalTrackLength());
                TreeNode <TrackType> type         = TrackTypes.Find(typeToSearch);
                type.Data.WaitingPlanes.ChangePriority(plane.Data, priority);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #16
0
        private void SetMainFormTrackStatus(IEnumerable <Entry> records)
        {
            var loadedTypes = TrackTypes.Where(t => airwayNetwork.TracksLoaded(t)).ToList();
            var maxSeverity = loadedTypes.Select(t => MaxSeverity(records, t)).ToList();

            if (maxSeverity.All(s => s == Severity.Advisory) &&
                loadedTypes.Count == TrackTypes.Count)
            {
                statusLbl.Image = Properties.Resources.GreenLight;
                statusLbl.Text  = "Tracks: Ready";
            }
            else if (maxSeverity.All(s => s == Severity.Critical) || loadedTypes.Count == 0)
            {
                statusLbl.Image = Properties.Resources.RedLight;
                statusLbl.Text  = "Tracks: Not Available";
            }
            else
            {
                statusLbl.Image = Properties.Resources.YellowLight;
                statusLbl.Text  = "Tracks: Partly Ready";
            }
        }
예제 #17
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            var msg = TrackTypes
                      .Select(t => airwayNetwork.GetTrackMessage(t))
                      .Where(m => m != null)
                      .ToList();

            if (msg.Count == 0)
            {
                this.ShowWarning("No track has been downloaded or imported.");
                return;
            }

            var myDoc          = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = GetFileDialogFilter();
            saveFileDialog.InitialDirectory = myDoc;
            saveFileDialog.RestoreDirectory = true;

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                var file = saveFileDialog.FileName;

                try
                {
                    File.Delete(file);
                    TrackFiles.SaveToFile(msg, file);
                }
                catch (Exception ex)
                {
                    Log(ex);
                    this.ShowWarning("Failed to save file.");
                }
            }
        }
예제 #18
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"));
        }
예제 #19
0
        //=========== READING ============
        #region Reading

        /**<summary>Reads the track design.</summary>*/
        public void Read(BinaryReader reader)
        {
            this.TrackType          = (TrackTypes)reader.ReadByte();
            this.Unknown0x01        = reader.ReadByte();
            this.SpecialTrackFlags  = reader.ReadUInt32();
            this.OperatingMode      = (OperatingModes)reader.ReadByte();
            this.VehicleColorScheme = reader.ReadByte();
            for (int i = 0; i < this.VehicleColorSpecifiers.Length; i++)
            {
                this.VehicleColorSpecifiers[i] = (RemapColors)reader.ReadByte();
            }

            this.Padding0x48               = reader.ReadByte();
            this.EntranceType              = (EntranceTypes)reader.ReadByte();
            this.AirTime                   = reader.ReadByte();
            this.DepartureControlFlags     = (DepartureControlFlags)reader.ReadByte();
            this.NumberOfTrains            = reader.ReadByte();
            this.CarsPerTrain              = reader.ReadByte();
            this.MinimumWaitTime           = reader.ReadByte();
            this.MaximumWaitTime           = reader.ReadByte();
            this.PoweredSpeedLapsMaxPeople = reader.ReadByte();
            this.MaximumSpeed              = reader.ReadByte();
            this.AverageSpeed              = reader.ReadByte();
            this.RideLength                = reader.ReadUInt16();
            this.PositiveGForce            = reader.ReadByte();
            this.NegativeGForce            = reader.ReadByte();
            this.LateralGForce             = reader.ReadByte();
            this.NumberOfInversions        = reader.ReadByte();
            this.NumberOfDrops             = reader.ReadByte();
            this.HighestDrop               = reader.ReadByte();
            this.Excitement                = reader.ReadByte();
            this.Intensity                 = reader.ReadByte();
            this.Nausea     = reader.ReadByte();
            this.UpkeepCost = reader.ReadInt16();

            for (int i = 0; i < this.TrackSpineColors.Length; i++)
            {
                this.TrackSpineColors[i] = (RemapColors)reader.ReadByte();
            }
            for (int i = 0; i < this.TrackRailColors.Length; i++)
            {
                this.TrackRailColors[i] = (RemapColors)reader.ReadByte();
            }
            for (int i = 0; i < this.TrackSupportColors.Length; i++)
            {
                this.TrackSupportColors[i] = (RemapColors)reader.ReadByte();
            }

            this.Unknown0x6C = reader.ReadByte();
            this.Unknown0x6D = reader.ReadByte();
            this.Unknown0x6E = reader.ReadByte();

            this.SixFlagsRide = reader.ReadByte();

            this.ObjectHeader.Read(reader);

            this.RideMapWidth  = reader.ReadByte();
            this.RideMapHeight = reader.ReadByte();

            for (int i = 0; i < this.VehicleAdditionalColors.Length; i++)
            {
                this.VehicleAdditionalColors[i] = (RemapColors)reader.ReadByte();
            }

            this.CircuitsChainLiftSpeed = reader.ReadByte();

            // Read the track data

            if (this.TrackType == TrackTypes.HedgeMaze)
            {
                MazeTile mazeTile = new MazeTile();
                mazeTile.Read(reader);
                // Read the maze tiles until an empty one is read.
                while (!mazeTile.IsEnd)
                {
                    this.MazeTiles.Add(mazeTile);
                    mazeTile = new MazeTile();
                    mazeTile.Read(reader);
                }
            }
            else
            {
                byte b = reader.ReadByte();
                // Read the track pieces until byte 0xFF.
                while (b != 0xFF)
                {
                    reader.BaseStream.Position--;
                    TrackPiece trackPiece = new TrackPiece();
                    trackPiece.Read(reader);
                    this.TrackPieces.Add(trackPiece);

                    b = reader.ReadByte();
                }
            }

            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                reader.ReadByte();
            }
        }
예제 #20
0
 public void DownloadAndEnableTracks()
 {
     TrackTypes.ForEach(t => DownloadAndEnableTracks(t));
 }
예제 #21
0
 private void RefreshViewTrackBtns()
 {
     TrackTypes.ForEach(t => ViewBtn(t).Enabled = airwayNetwork.TracksLoaded(t));
 }
예제 #22
0
 private void InitPicBoxes()
 {
     TrackTypes.ForEach(t => PicBox(t).Image = null);
 }
예제 #23
0
 private void InitCBox()
 {
     TrackTypes.ForEach(t => EnabledCBox(t).SelectedIndex = 0);
 }
예제 #24
0
        public bool NotifyTrackRequirement(String internationalID, double priority)
        {
            Plane            planeToSearch = new Plane(internationalID);
            TreeNode <Plane> planeFound    = ArrivedPlanes.Find(planeToSearch);

            if (planeFound != null)
            {
                planeFound.Data.SetTrackRequirementTime(SystemTime);
                ArrivedPlanes.Delete(planeFound.Data);
                planeFound.Data.SetPriority(priority + (SystemTime.ToUniversalTime() - beginOfTimes).TotalSeconds * 1.0 / 10000000000);
                WaitingPlanes.Add(planeFound.Data);
                waitingCount++;

                TrackType            typeToSearch = new TrackType(planeFound.Data.GetMinimalTrackLength());
                TreeNode <TrackType> typeFound    = TrackTypes.Find(typeToSearch);
                if (typeFound == null)
                {
                    return(false);
                }
                else
                {
                    foreach (Track track in typeFound.Data.Tracks)
                    {
                        if (track.GetPlane() == null)
                        {
                            planeFound.Data.Track = track;
                            track.SetPlane(planeFound.Data);
                            TrackAllocations.Add("plane ID" + planeFound.Data.GetInternationalID() + " to " + track.GetName()
                                                 );
                            break;
                        }
                    }
                    if (planeFound.Data.Track == null && waitingCount / TrackList.Count > 5)
                    {
                        int upperTypeIndex = TrackTypesLengthList.IndexOf(typeFound.Data.Length) + 1;
                        if (upperTypeIndex < TrackTypesLengthList.Count)
                        {
                            TrackType upperType = TrackTypes.Find(new TrackType(TrackTypesLengthList[upperTypeIndex])).Data;
                            foreach (Track track in upperType.Tracks)
                            {
                                if (track.GetPlane() == null)
                                {
                                    planeFound.Data.Track = track;
                                    track.SetPlane(planeFound.Data);
                                    TrackAllocations.Add("!!! plane ID" + planeFound.Data.GetInternationalID() + " to " + track.GetName()
                                                         );
                                    break;
                                }
                            }
                        }
                    }
                    if (planeFound.Data.Track == null)
                    {
                        typeFound.Data.WaitingPlanes.Add(planeFound.Data);
                        typeFound.Data.WaitingPlanesForSearch.Add(planeFound.Data);
                    }
                }
                return(true);
            }
            return(false);
        }
예제 #25
0
파일: Track.cs 프로젝트: axtens/Axtension
 public void SetTrackType(TrackTypes tt)
 {
     this.trackType = tt;
     return;
 }
예제 #26
0
        public void SaveToFile()
        {
            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\SystemTime.txt",
                              SystemTime.ToString());

            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\Planes.txt",
                              Planes.TraverseLevelOrder());

            StringBuilder trackAllocations = new StringBuilder();

            foreach (String allocation in TrackAllocations)
            {
                trackAllocations.Append(allocation + ",");
            }
            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\TrackAllocations.txt",
                              trackAllocations.ToString());

            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\ArrivedPlanes.txt",
                              ArrivedPlanes.TraverseIDsLevelOrder());

            StringBuilder planeArrivals = new StringBuilder();

            foreach (String arrival in PlaneArrivals)
            {
                planeArrivals.Append(arrival + ",");
            }
            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\PlaneArrivals.txt",
                              planeArrivals.ToString());

            StringBuilder planeDepartures = new StringBuilder();

            foreach (String departure in PlaneDepartures)
            {
                planeDepartures.Append(departure + ",");
            }
            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\PlaneDepartures.txt",
                              planeDepartures.ToString());

            StringBuilder trackString = new StringBuilder();

            foreach (Track track in TrackList)
            {
                if (track.GetPlane() != null)
                {
                    trackString.Append(track.GetName() + ":" + track.GetPlane().GetInternationalID() + ",");
                }
            }
            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\TrackPlanes.txt",
                              trackString.ToString());

            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\WaitingPlanes.txt",
                              WaitingPlanes.TraverseIDsLevelOrder());

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

                File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\" +
                                  type.Length
                                  + "WaitingPlanes.txt",
                                  type.WaitingPlanes.TraverseIDsLevelOrder());

                File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\" +
                                  type.Length
                                  + "WaitingPlanesForSearch.txt",
                                  type.WaitingPlanesForSearch.TraverseIDsLevelOrder());

                foreach (Track track in type.Tracks)
                {
                    StringBuilder history = new StringBuilder();
                    foreach (PlaneShortInfo info in track.DepartureHistory)
                    {
                        history.Append(info.ID + "," + info.DepartureTime + "\n");
                    }
                    File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\" +
                                      track.GetName() +
                                      "History.txt",
                                      history.ToString());
                }
            }

            File.WriteAllText("D:\\.NET Projects\\PlaneDepartureTracking\\PlaneDepartureTrackingMSTest\\WaitingCount.txt",
                              "" + waitingCount);
        }