Exemplo n.º 1
0
 public AirTrafficTower(FlightLog Log, Subject Subject, List <CollisionTracker> tracker, bool verbose = true)
 {
     ListOfTracks      = Subject;
     this.Log          = Log;
     this.verbose      = verbose;
     collisionTracker_ = tracker;
 }
Exemplo n.º 2
0
        internal static void Display()
        {
            ScrollDetailsPosition = GUILayout.BeginScrollView(ScrollDetailsPosition, RMStyle.ScrollStyle, GUILayout.Height(210), GUILayout.Width(680));
            Rect   rect    = new Rect();
            string label   = "";
            string toolTip = "";

            GUILayout.Label("Kerbal Flight History", RMStyle.LabelStyleBold);
            GUILayout.Label(WindowRoster.SelectedKerbal.Name + " - (" + WindowRoster.SelectedKerbal.Title + ")", RMStyle.LabelStyleBold, GUILayout.MaxWidth(300));

            if (!string.IsNullOrEmpty(RMAddon.saveMessage))
            {
                GUILayout.Label(RMAddon.saveMessage, RMStyle.ErrorLabelRedStyle);
            }

            // Begin Tab contents.
            FlightLog thisLog = WindowRoster.SelectedKerbal.Kerbal.flightLog;

            foreach (FlightLog.Entry thisEntry in thisLog.Entries)
            {
                GUILayout.Label(thisEntry.flight.ToString() + " - " + thisEntry.target + " - " + thisEntry.type);
            }

            //End Tab contents
            GUILayout.EndScrollView();

            WindowRoster.DisplayEditActionButtons(ref rect, ref label, ref toolTip);
        }
Exemplo n.º 3
0
        public async Task <OverallStats> SetStats(FlightLog flightLog)
        {
            long   ticks      = flightLog.FlightLogAnalyse.FlightTime.Ticks;
            double sec        = TimeSpan.FromTicks(ticks).TotalSeconds;
            float? kilometers = flightLog.FlightLogAnalyse.Kilometers;
            byte   flightno   = 1;

            OverallStats stats = await _db.Stats.Where(f => f.Id == 1).FirstOrDefaultAsync();

            if (stats == null)
            {
                _db.Stats.Add(new OverallStats()
                {
                    TimeInSeconds = sec, Kilometers = kilometers, FlightsNo = flightno
                });
            }
            else
            {
                stats.TimeInSeconds += sec;
                stats.Kilometers    += kilometers;
                stats.FlightsNo     += flightno;
            }

            return(stats);
        }
Exemplo n.º 4
0
        public async Task <FlightLog> DeleteFlight(int id)
        {
            FlightLog flight = await _db.FlightLogs.Include(f => f.FlightLogAnalyse).Include(f => f.User).Where(fa => fa.Id == id).FirstOrDefaultAsync();

            ApplicationUser Users = await _db.Pilots.Where(f => f.Id == flight.UserId).FirstOrDefaultAsync();

            OverallStats stats = await _db.Stats.FindAsync(1);

            if (flight != null)
            {
                Users.SumKilometers -= flight.FlightLogAnalyse.Kilometers;
                long   ticks = flight.FlightLogAnalyse.FlightTime.Ticks;
                double sec   = TimeSpan.FromTicks(ticks).TotalSeconds;
                Users.TimeInSec     -= sec;
                Users.FlightsNo     -= 1;
                stats.FlightsNo     -= 1;
                stats.Kilometers    -= flight.FlightLogAnalyse.Kilometers;
                stats.TimeInSeconds -= sec;
                if (flight.FlightLogAnalyse.Topflight == true)
                {
                    Users.TopScore -= flight.FlightLogAnalyse.Score;
                }

                _db.FlightLogs.Remove(flight);

                await _db.SaveChangesAsync();
            }
            return(flight);
        }
        private void OnKerbalStatusChange(ProtoCrewMember pcm, ProtoCrewMember.RosterStatus oldStatus, ProtoCrewMember.RosterStatus newStatus)
        {
            if (oldStatus == ProtoCrewMember.RosterStatus.Assigned && newStatus == ProtoCrewMember.RosterStatus.Available)
            {
                FlightLog tmpLog = new FlightLog();
                foreach (FlightLog.Entry entry in pcm.careerLog.Entries.Union(pcm.flightLog.Entries))
                {
                    tmpLog.AddEntry(entry);
                }

                float xp = KerbalRoster.CalculateExperience(pcm.careerLog);
                float xp2 = KerbalRoster.CalculateExperience(tmpLog);

                float amount = (xp2 - xp) * multiplier;

                if (currency == Currency.Funds)
                {
                    Funding.Instance.AddFunds(amount, TransactionReasons.Strategies);
                }
                else if (currency == Currency.Reputation)
                {
                    Reputation.Instance.AddReputation(amount, TransactionReasons.Strategies);
                }
                else if (currency == Currency.Science)
                {
                    ResearchAndDevelopment.Instance.AddScience(amount, TransactionReasons.Strategies);
                }

                CurrencyPopup.Instance.AddPopup(currency, amount, TransactionReasons.Strategies, Parent.Config.Title, false);
            }
        }
Exemplo n.º 6
0
        public async Task Save(FlightLog flightLog)
        {
            // Add the new FlightLog
            await db.FlightLogs.AddAsync(flightLog);

            // Update Entity used in the FlightLog
            var entity = db.Entities.FindAsync(flightLog.EntityId).Result;

            entity.TotalFlightCycles++;
            entity.TotalFlightDurationInSeconds += flightLog.SecondsFlown;
            entity.CyclesSinceLastMaintenance++;
            entity.FlightSecondsSinceLastMaintenance += flightLog.SecondsFlown;

            db.Entities.Update(entity);

            // Update all components in the Entity
            var components = db.Components
                             .Where(x => x.EntityId == flightLog.EntityId)
                             .ToList();

            foreach (var component in components)
            {
                component.TotalFlightCycles++;
                component.TotalFlightDurationInSeconds += flightLog.SecondsFlown;
                component.CyclesSinceLastMaintenance++;
                component.FlightSecondsSinceLastMaintenance += flightLog.SecondsFlown;
            }
            db.Components.UpdateRange(components);

            // Save changes
            await db.SaveChangesAsync();
        }
Exemplo n.º 7
0
        public List <FlightLog> FindFlightLog(Guid?appUserId = null, DateTime?flightDateUtc = null)
        {
            var results = new List <FlightLog>();
            var cmd     = new SqlCommand("dbo.FlightLog_Find");

            cmd.CommandType = CommandType.StoredProcedure;
            if (appUserId != null)
            {
                cmd.Parameters.AddWithValue("@AppUserId", appUserId.Value);
            }
            if (flightDateUtc != null)
            {
                cmd.Parameters.AddWithValue("@FlightDateUtc", appUserId.Value);
            }
            DataTable table = db.Get(cmd);

            foreach (DataRow row in table.Rows)
            {
                var result = new FlightLog(row);
                result.AircraftManufacturer = row.Field <string>("Manufacturer");
                result.AircraftModel        = row.Field <string>("Model");
                results.Add(result);
            }
            return(results);
        }
Exemplo n.º 8
0
        public async Task <ActionResult <FlightLog> > Post([FromBody] InputModel Data)
        {
            string message = "started";
            string data    = Data.Payload;

            if (data != null)
            {
                var       returnDataObj = JsonConvert.DeserializeObject <FlightLog>(data);
                FlightLog log           = await _db.FlightLogs
                                          .Where(f => f.Pilot == returnDataObj.Pilot)
                                          .Where(f => f.Date == returnDataObj.Date)
                                          .Where(f => f.LoggerId == returnDataObj.LoggerId)
                                          .Where(f => f.NumFlight == returnDataObj.NumFlight)
                                          .FirstOrDefaultAsync();

                if (log == null)
                {
                    await _stats.SetStats(returnDataObj);

                    await _flightLog.GiveTopBool(returnDataObj);

                    await _db.FlightLogs.AddAsync(returnDataObj);

                    await _db.SaveChangesAsync();
                }
                else if (log != null)
                {
                    return(Conflict());
                }
            }

            return(Ok(message));
        }
Exemplo n.º 9
0
        public void TestFlightLogExpectsInstanceAlike()
        {
            FileConfig cfg = Factory.GetFileConfig("a", "b");
            FlightLog  log = Factory.GetFlightLog(cfg);

            Assert.IsInstanceOf <FlightLog>(log);
        }
Exemplo n.º 10
0
        private void OnKerbalStatusChange(ProtoCrewMember pcm, ProtoCrewMember.RosterStatus oldStatus, ProtoCrewMember.RosterStatus newStatus)
        {
            if (oldStatus == ProtoCrewMember.RosterStatus.Assigned && newStatus == ProtoCrewMember.RosterStatus.Available)
            {
                FlightLog tmpLog = new FlightLog();
                foreach (FlightLog.Entry entry in pcm.careerLog.Entries.Union(pcm.flightLog.Entries))
                {
                    tmpLog.AddEntry(entry);
                }

                float xp  = KerbalRoster.CalculateExperience(pcm.careerLog);
                float xp2 = KerbalRoster.CalculateExperience(tmpLog);

                float amount = (xp2 - xp) * multiplier;

                if (currency == Currency.Funds)
                {
                    Funding.Instance.AddFunds(amount, TransactionReasons.Strategies);
                }
                else if (currency == Currency.Reputation)
                {
                    Reputation.Instance.AddReputation(amount, TransactionReasons.Strategies);
                }
                else if (currency == Currency.Science)
                {
                    ResearchAndDevelopment.Instance.AddScience(amount, TransactionReasons.Strategies);
                }

                CurrencyPopup.Instance.AddPopup(currency, amount, TransactionReasons.Strategies, Parent.Config.Title, false);
            }
        }
Exemplo n.º 11
0
        public void TestAirTrafficTowerExpectsInstanceAlike()
        {
            FileConfig cfg                  = Factory.GetFileConfig("a", "b");
            FlightLog  log                  = Factory.GetFlightLog(cfg);
            Subject    ObserverList         = Factory.GetSubject();
            List <CollisionTracker> tracker = new List <CollisionTracker>();

            Assert.IsInstanceOf <AirTrafficTower>(Factory.GetTower(log, ObserverList, tracker));
        }
        public void HorizontalFlightTest()
        {
            const string filepath  = "../../../../../Startup/HelicopterSim/bin/x86/Release/" + "flightpath.xml";
            FlightLog    flightLog = FlightLogXMLFile.Read(filepath);

            if (flightLog == null)
            {
                throw new Exception("Could not read flight log from file: " + filepath);
            }

            HorizontalFlightTest(flightLog.Plots);
        }
Exemplo n.º 13
0
        public MonitorSystem()
        {
            tracker = Factory.GetTracker();

            cfg = Factory.GetFileConfig("AirTrafficMonitorLog.txt", Environment.GetFolderPath(Environment.SpecialFolder.Desktop));

            Log = Factory.GetFlightLog(cfg);

            TrackList = Factory.GetSubject();

            TrafficMonitor = new AirTrafficTower(Log, TrackList, tracker, true);
        }
Exemplo n.º 14
0
        private int getCrewTrainedLevel(ProtoCrewMember crew)
        {
            int       lastLog  = 0;
            FlightLog totalLog = crew.careerLog.CreateCopy();

            totalLog.MergeWith(crew.flightLog.CreateCopy());

            int deadFlight = -1;

            foreach (FlightLog.Entry entry in totalLog.Entries)
            {
                if (entry.flight <= deadFlight)
                {
                    continue;
                }
                if (entry.type == "Die")
                {
                    deadFlight = entry.flight;
                }
            }
            foreach (FlightLog.Entry entry in totalLog.Entries)
            {
                if (entry.flight <= deadFlight)
                {
                    continue;
                }
                if (lastLog < 1 && entry.type == "Training1")
                {
                    lastLog = 1;
                }
                if (lastLog < 2 && entry.type == "Training2")
                {
                    lastLog = 2;
                }
                if (lastLog < 3 && entry.type == "Training3")
                {
                    lastLog = 3;
                }
                if (lastLog < 4 && entry.type == "Training4")
                {
                    lastLog = 4;
                }
                if (lastLog < 5 && entry.type == "Training5")
                {
                    lastLog = 5;
                }
            }

            return(lastLog);
        }
        void generateCrew(string kerbalTrait, ProtoCrewMember.Gender gender)
        {
            ProtoCrewMember crew = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(ProtoCrewMember.KerbalType.Crew);

            while (crew.trait != kerbalTrait)
            {
                crew = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(ProtoCrewMember.KerbalType.Crew);
            }
            crew.ChangeName(crewName);
            crew.type            = ProtoCrewMember.KerbalType.Crew;
            crew.gender          = gender;
            crew.experienceLevel = 5;
            FlightLog flight = new FlightLog();

            flight.AddEntry("Land,Eeloo");
            flight.AddEntry("Land,Dres");
            flight.AddEntry("Land,Pol");
            flight.AddEntry("Land,Gilly");
            flight.AddEntry("Land,Tylo");
            flight.AddEntry("Land,Bop");
            flight.AddEntry("Land,Vall");
            flight.AddEntry("Land,Laythe");
            crew.careerLog.AddFlight();
            for (int i = flight.Entries.Count - 1; i >= 0; --i)
            {
                FlightLog.Entry entries = flight.Entries[i];
                crew.careerLog.AddEntry(entries);
            }
            for (int i = FlightGlobals.Vessels.Count - 1; i >= 0; --i)
            {
                Vessel vessel = FlightGlobals.Vessels[i];
                if (vessel.vesselName == "Kerbin Station")
                {
                    for (int j = vessel.Parts.Count - 1; j >= 0; --j)
                    {
                        Part part = vessel.Parts[j];
                        if (part.protoModuleCrew.Count < part.CrewCapacity)
                        {
                            part.AddCrewmember(crew);
                            part.Actions.part.SpawnIVA();
                            CameraManager.Instance.SetCameraMap();
                            CameraManager.Instance.SetCameraFlight();
                            break;
                        }
                    }
                    break;
                }
            }
        }
Exemplo n.º 16
0
        public void Setup()
        {
            // Make a fake Transponder Data Receiver
            _fakeTransponderReceiver = Substitute.For <ITransponderReceiver>();

            cfg = Factory.GetFileConfig($"UUT_GRP_13_TEST_2.txt", System.IO.Path.GetTempPath());

            Log = Factory.GetFlightLog(cfg);

            TrackList = Factory.GetSubject();



            _uut = new AirTrafficTower(Log, TrackList, tracker);
        }
Exemplo n.º 17
0
        private FlightLogViewModel CreateFlightLogViewModel(FlightLog flightLog)
        {
            var viewModel       = new FlightLogViewModel();
            var activeLocations = flightProgramsRepository.GetAllActiveProgramLocations();
            var activeAircraft  = flightProgramsRepository.GetAllActiveAircraftMds();

            if (flightLog != null)
            {
                Mapper.Map <FlightLog, FlightLogViewModel>(flightLog, viewModel);
                activeLocations = activeLocations.Union(new ProgramLocation[] { flightLog.Location });
            }
            viewModel.SetActiveLocations(activeLocations);
            viewModel.SetActiveAircraft(activeAircraft);
            viewModel.IsFlightLogManager = CurrentUser.Roles.FlightLogManager;
            return(viewModel);
        }
Exemplo n.º 18
0
        private double getKerbalTrainingExp(ProtoCrewMember crew)
        {
            string lastExpStr = "0";

            FlightLog totalLog = crew.careerLog.CreateCopy();

            totalLog.MergeWith(crew.flightLog.CreateCopy());
            foreach (FlightLog.Entry entry in totalLog.Entries)
            {
                if (entry.type == "TrainingExp")
                {
                    lastExpStr = entry.target;
                }
            }

            return(double.Parse(lastExpStr));
        }
Exemplo n.º 19
0
        public Guid AddFlightLog(FlightLog model)
        {
            var cmd = new SqlCommand("dbo.FlightLog_Insert");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@AppUserId", model.UserId);
            cmd.Parameters.AddWithValue("@AircraftId", model.AircraftId);
            cmd.Parameters.AddWithValue("@FlightBeginUtc", model.FlightBeginUtc);
            cmd.Parameters.AddWithValue("@FlightEndUtc", model.FlightEndUtc);
            cmd.Parameters.AddWithValue("@HobbsBegin", model.HobbsBegin);
            cmd.Parameters.AddWithValue("@HobbsEnd", model.HobbsEnd);
            cmd.Parameters.AddWithValue("@HobbsHours", model.HobbsHours);
            cmd.Parameters.AddWithValue("@NightLandings", model.NightLandings);
            cmd.Parameters.AddWithValue("@CreatedByUserId", model.CreatedByUserId);
            object result = db.GetScalar(cmd);

            return((Guid)result);
        }
        public void Set(FlightLog flightLog)
        {
            Clear();

            PrepareCharts();

            foreach (var snapshot in flightLog.Plots)
            {
                AddPlot(snapshot);
            }

            foreach (Waypoint waypoint in flightLog.Waypoints)
            {
                _waypointMarkers.AddPoint(new ChartPoint("",
                                                         new Point(waypoint.Position.X, waypoint.Position.Z)));
            }

            RenderAndSetScale(flightLog.Plots.Last().Time);
        }
Exemplo n.º 21
0
        public static void GenerateCrew()
        {
            int i;

            crewToHire = new List <ProtoCrewMember>();
            for (i = crewToHire.Count; i <= 5;)
            {
                ProtoCrewMember crew = HighLogic.CurrentGame.CrewRoster.GetNewKerbal();
                crew.type            = ProtoCrewMember.KerbalType.Crew;
                crew.experienceLevel = Math.Abs(UnityEngine.Random.Range(0, 6));
                FlightLog flight = new FlightLog();
                if (crew.experienceLevel >= 1)
                {
                    flight.AddEntry("Orbit,Kerbin");
                }
                if (crew.experienceLevel >= 2)
                {
                    flight.AddEntry("Land,Duna");
                }
                if (crew.experienceLevel >= 3)
                {
                    flight.AddEntry("Land,Ike");
                }
                if (crew.experienceLevel >= 4)
                {
                    flight.AddEntry("Land,Pol");
                }
                if (crew.experienceLevel >= 5)
                {
                    flight.AddEntry("Land,Eeloo");
                    flight.AddEntry("Land,Dres");
                }
                crew.careerLog.AddFlight();
                foreach (FlightLog.Entry entries in flight.Entries)
                {
                    crew.careerLog.AddEntry(entries);
                }
                crewToHire.Add(crew);
                i = crewToHire.Count;
            }
            hireCrewWindow = true;
        }
Exemplo n.º 22
0
        public bool UpdateFlightLog(FlightLog model)
        {
            var cmd = new SqlCommand("dbo.FlightLog_Update");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@FlightLogId", model.Id);
            cmd.Parameters.AddWithValue("@AppUserId", model.UserId);
            cmd.Parameters.AddWithValue("@AircraftId", model.AircraftId);
            cmd.Parameters.AddWithValue("@FlightBeginUtc", model.FlightBeginUtc);
            cmd.Parameters.AddWithValue("@FlightEndUtc", model.FlightEndUtc);
            cmd.Parameters.AddWithValue("@HobbsBegin", model.HobbsBegin);
            cmd.Parameters.AddWithValue("@HobbsEnd", model.HobbsEnd);
            cmd.Parameters.AddWithValue("@HobbsHours", model.HobbsHours);
            cmd.Parameters.AddWithValue("@NightLandings", model.NightLandings);
            cmd.Parameters.AddWithValue("@CreatedByUserId", model.CreatedByUserId);
            int  rowsAffected = db.Execute(cmd);
            bool success      = rowsAffected == 1;

            return(success);
        }
        /// <summary>
        /// Assumes filepaths to the four ex1.xml ex2.xml ex3.xml and ex4.xml files are passed in.
        /// </summary>
        /// <param name="filepaths"></param>
        private void LogFlightLogComparison(StringCollection filepaths)
        {
//            if (!filepaths.Contains("ex1") || !filepaths.Contains("ex2") || !filepaths.Contains("ex3") ||
//                !filepaths.Contains("ex4")) return;

            _dataProvider.Clear();
            var colors = new Dictionary <string, Color>();

            colors["ex1"] = Colors.DarkRed;
            colors["ex2"] = Colors.Navy;
            colors["ex3"] = Colors.SkyBlue;
            colors["ex4"] = Colors.Orange;

            foreach (string filepath in filepaths)
            {
                FlightLog flightlog = FlightLogXMLFile.Read(filepath);
                string    filename  = Path.GetFileNameWithoutExtension(filepath);
                double    thickness = (filename == "ex1") ? 3 : 1.5;

                _dataProvider.AddToComparison(flightlog, colors[filename], filename, thickness);
            }
        }
Exemplo n.º 24
0
        private double getKerbalTrainingExp(ProtoCrewMember crew)
        {
            string lastExpStr = "0";

            FlightLog totalLog = crew.careerLog.CreateCopy();

            totalLog.MergeWith(crew.flightLog.CreateCopy());

            int deadFlight = -1;

            foreach (FlightLog.Entry entry in totalLog.Entries)
            {
                if (entry.flight <= deadFlight)
                {
                    continue;
                }
                if (entry.type == "Die")
                {
                    deadFlight = entry.flight;
                }
            }

            foreach (FlightLog.Entry entry in totalLog.Entries)
            {
                if (entry.type == "TrainingExp")
                {
                    if (entry.flight <= deadFlight)
                    {
                        removeKerbalTrainingExp(crew);
                    }
                    else
                    {
                        lastExpStr = entry.target;
                    }
                }
            }

            return(double.Parse(lastExpStr));
        }
Exemplo n.º 25
0
        public async Task <IActionResult> Post([FromBody] FlightLogViewModel flightLogViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var flightLog = new FlightLog
            {
                DepartmentId             = flightLogViewModel.DepartmentId,
                ApplicationUserIdPiloted = flightLogViewModel.ApplicationUserIdPiloted,
                ApplicationUserIdLogged  = flightLogViewModel.ApplicationUserIdLogged,
                EntityId                  = flightLogViewModel.EntityId,
                CountryId                 = flightLogViewModel.CountryId,
                DateTakeOff               = flightLogViewModel.DateTakeOff,
                AddressTakeOff            = flightLogViewModel.AddressTakeOff,
                LatitudeTakeOff           = flightLogViewModel.LatitudeTakeOff,
                LongitudeTakeOff          = flightLogViewModel.LongitudeTakeOff,
                SecondsFlown              = flightLogViewModel.SecondsFlown,
                AddressLanding            = flightLogViewModel.AddressLanding,
                LatitudeLanding           = flightLogViewModel.LatitudeLanding,
                LongitudeLanding          = flightLogViewModel.LongitudeLanding,
                Remarks                   = flightLogViewModel.Remarks,
                FlightLogTypeOfOperations = new List <FlightLogTypeOfOperation>()
            };

            foreach (var typeOfOperationViewModel in flightLogViewModel.TypeOfOperationViewModels)
            {
                flightLog.FlightLogTypeOfOperations.Add(new FlightLogTypeOfOperation {
                    TypeOfOperationId = typeOfOperationViewModel.TypeOfOperationId
                });
            }

            await repository.Save(flightLog);

            flightLogViewModel.FlightLogId = flightLog.FlightLogId;
            return(CreatedAtAction("Get", new { id = flightLog.FlightLogId }, flightLogViewModel));
        }
Exemplo n.º 26
0
        internal static void Display()
        {
            _scrollDetailsPosition = GUILayout.BeginScrollView(_scrollDetailsPosition, RMStyle.ScrollStyle, GUILayout.Height(210), GUILayout.Width(780));
            GUILayout.Label("Kerbal Flight History:  " + WindowRoster.SelectedKerbal.Name + " - (" + WindowRoster.SelectedKerbal.Trait + ")", RMStyle.LabelStyleBold, GUILayout.Width(500));

            if (!string.IsNullOrEmpty(RMAddon.SaveMessage))
            {
                GUILayout.Label(RMAddon.SaveMessage, RMStyle.ErrorLabelRedStyle);
            }

            // Begin Tab contents.
            FlightLog thisLog = WindowRoster.SelectedKerbal.Kerbal.flightLog;

            foreach (FlightLog.Entry thisEntry in thisLog.Entries)
            {
                GUILayout.Label(thisEntry.flight + " - " + thisEntry.target + " - " + thisEntry.type);
            }

            //End Tab contents
            GUILayout.EndScrollView();

            WindowRoster.DisplayActionButtonsEdit();
        }
Exemplo n.º 27
0
 public FlightLog AddFlightLog(FlightLog flightLog)
 {
     flightLog.MarkedUpdated();
     flightLog.Validate();
     return(Persist <FlightLog>(flightLog));
 }
Exemplo n.º 28
0
 /// <summary>
 ///     创建FlightLog。
 /// </summary>
 /// <returns>FlightLog</returns>
 public static FlightLog CreateFlightLog()
 {
     var flightLog = new FlightLog();
     flightLog.GenerateNewIdentity();
     return flightLog;
 }
Exemplo n.º 29
0
 public static AirTrafficTower GetTower(FlightLog log, Subject Subject, List <CollisionTracker> tracker)
 {
     return(new AirTrafficTower(log, Subject, tracker));
 }
Exemplo n.º 30
0
 public FlightTimeSummaryReport(FlightLog flightLog)
 {
     this.flightLog = flightLog;
 }
Exemplo n.º 31
0
        public void FlightsDescentGraphic()
        {
            var chart = chartFlightsDescentGraphic.ChartAreas[0];

            chart.AxisX.IntervalType = DateTimeIntervalType.Number;

            chart.AxisX.LabelStyle.Format            = "";
            chart.AxisY.LabelStyle.Format            = "";
            chart.AxisY.LabelStyle.IsEndLabelVisible = true;

            chart.AxisX.Minimum  = 0;
            chart.AxisX.Maximum  = 60;
            chart.AxisX.Interval = 5;

            chart.AxisY.Minimum  = 0;
            chart.AxisY.Maximum  = 10000;
            chart.AxisY.Interval = 2000;

            chartFlightsDescentGraphic.Series.Clear();
            chartFlightsDescentGraphic.Series.Add("# chartFlightsDescentGraphic");
            chartFlightsDescentGraphic.Series["# chartFlightsDescentGraphic"].ChartType = SeriesChartType.FastLine;
            chartFlightsDescentGraphic.Series["# chartFlightsDescentGraphic"].Color     = Color.MediumBlue;
            chartFlightsDescentGraphic.Series[0].IsVisibleInLegend = false;

            int i    = 1;
            int min  = 0;
            int temp = 0;
            int diff = 0;

            foreach (FlightLog l in FlightLog.GetDescent(IDF))
            {
                if (l.Time.Minute != temp)
                {
                    if (temp != 0)
                    {
                        if (temp > l.Time.Minute)
                        {
                            diff = (l.Time.Minute - temp) + 60;
                        }
                        else
                        {
                            diff = l.Time.Minute - temp;
                        }
                    }
                    else
                    {
                        min = 1;
                    }

                    int total = min + diff;

                    if (total > l.Time.Minute)
                    {
                        temp = l.Time.Minute + 60;
                    }
                    else
                    {
                        temp = l.Time.Minute;
                    }

                    min = total;

                    chartFlightsDescentGraphic.Series["# chartFlightsDescentGraphic"].Points.AddXY(total, l.Alt);
                }
            }
        }
        public void TransferCareerLog(ProtoCrewMember to, ProtoCrewMember from)
        {
            // record current flightlog & reset, if applicable
            FlightLog current = null;
            if (to.flightLog.Entries.Count() > 0) {
                current = new FlightLog();
                foreach (FlightLog.Entry entry in to.flightLog.Entries)
                    current.Entries.Add(entry);
                to.flightLog = new FlightLog();
            }

            //transfer careerLog
            foreach (FlightLog flight in from.careerLog.GetFlights()) {
                foreach (FlightLog.Entry entry in flight.Entries)
                    to.flightLog.Entries.Add(entry);
                to.ArchiveFlightLog();
            }

            //rewrite flightLog, if applicable
            if (current != null)
                foreach (FlightLog.Entry entry in current.Entries)
                    to.flightLog.Entries.Add(entry);
        }
Exemplo n.º 33
0
 public void SetUp()
 {
     cfg = new FileConfig("testFixtureGrp13.txt", System.IO.Path.GetTempPath());
     log = new FlightLog(cfg);
 }
 public VesselHasVisited(CelestialBody destination, FlightLog.EntryType entryType, string title)
     : base(title)
 {
     if (title == null)
     {
         this.title = "Perform ";
         switch (entryType)
         {
             case FlightLog.EntryType.BoardVessel:
                 this.title = "Board a vessel on ";
                 break;
             case FlightLog.EntryType.Die:
                 this.title = "Die on ";
                 break;
             case FlightLog.EntryType.Escape:
                 this.title += "an escape from";
                 break;
             case FlightLog.EntryType.ExitVessel:
                 this.title = "Exit a vessel on ";
                 break;
             case FlightLog.EntryType.Flight:
                 this.title += "a flight on ";
                 break;
             case FlightLog.EntryType.Flyby:
                 this.title += "a flyby of ";
                 break;
             case FlightLog.EntryType.Land:
                 this.title += "a landing on ";
                 break;
             case FlightLog.EntryType.Launch:
                 this.title += "a launch from ";
                 break;
             case FlightLog.EntryType.Orbit:
                 this.title += "an orbit of ";
                 break;
             case FlightLog.EntryType.PlantFlag:
                 this.title = "Plant a flag on ";
                 break;
             case FlightLog.EntryType.Recover:
                 this.title += " a recovery on ";
                 break;
             case FlightLog.EntryType.Spawn:
                 this.title = "Spawn on ";
                 break;
             case FlightLog.EntryType.Suborbit:
                 this.title += "a sub-orbital trajectory of ";
                 break;
         }
         if (destination != null)
         {
             this.title += destination.theName;
         }
         else
         {
             this.title += "any body";
         }
     }
     else
     {
         this.title = title;
     }
     this.destination = destination;
     this.entryType = entryType;
 }
Exemplo n.º 35
0
 private void loadVesselLog()
 {
     if (vessel.loaded)
     {
         shipsLog = VesselTripLog.FromVessel(vessel).Log;
     }
     else
     {
         shipsLog = VesselTripLog.FromProtoVessel(vessel.protoVessel).Log;
     }
 }