Esempio n. 1
0
 private void EnsurePitlaneStarted(RequiredModel model)
 {
     if (!model.InMenus && model.InPitlane && _previousModel?.InPitlane == false)
     {
         PitlaneStarted?.Invoke(this, model);
     }
 }
        public bool TryCollect(out RequiredModel collected)
        {
            collected = null;

            try
            {
                if (!Subscriber.IsSubscribed)
                {
                    Subscriber.Subscribe();
                }

                collected = Subscriber.Receive <RequiredModel>();
            }
            catch (Exception ex)
            {
                if (!(ex is SocketException))
                {
                    Logger.Fatal("Fatal error while collecting data from network.", ex);
                }
                else
                {
                    Logger.Warn($"Connecting to {PublisherIp}:{PublisherPort}...");
                }

                return(false);
            }

            return(true);
        }
Esempio n. 3
0
 private void EnsurePitlaneFinished(RequiredModel model)
 {
     if (!model.InMenus && !model.InPitlane && _previousModel?.InPitlane == true)
     {
         PitlaneFinished?.Invoke(this, model);
     }
 }
Esempio n. 4
0
 private void EnsureLapInvalidated(RequiredModel model)
 {
     if (!model.InMenus &&
         !model.LapIsValid && _previousModel?.LapIsValid == true)
     {
         LapInvalidated?.Invoke(this, model);
     }
 }
Esempio n. 5
0
 private void EnsureLapFinished(RequiredModel model)
 {
     if (!model.InMenus &&
         model.LapNumber > _previousModel?.LapNumber)
     {
         LapFinished?.Invoke(this, model);
     }
 }
Esempio n. 6
0
 private void EnsureSessionFinished(RequiredModel model)
 {
     if (model.Type == null &&
         _previousModel?.Type != null)
     {
         SessionFinished?.Invoke(this, model);
     }
 }
Esempio n. 7
0
 private void EnsureSectorChanged(RequiredModel model)
 {
     if (!model.InMenus && _previousModel != null &&
         model.SectorId != _previousModel.SectorId &&
         _previousModel.SectorId != -1)
     {
         SectorChanged?.Invoke(this, model);
     }
 }
        public override void OnLapStarted(object sender, RequiredModel lap)
        {
            base.OnLapStarted(sender, lap);

            if (LoadedMap == null)
            {
                MapManager.IsRecording = true;
                Logger.Info("Start recording map.");
            }
        }
        public override void OnUpdated(object sender, RequiredModel model)
        {
            base.OnUpdated(sender, model);

            DrawCurrentPosition(model);
            if (MapManager.IsRecording)
            {
                MapManager.Record(model.CarPosition);
            }
        }
        public void Return_null_if_every_property_is_ok()
        {
            var model = new RequiredModel {
                Summary = "text"
            };

            builder.BuildFromModel(model);

            builder.Invalid.Should().BeFalse();
            builder.Result.Should().BeNull();
        }
        public void Approve_required_properties()
        {
            var model = new RequiredModel {
                Summary = "text"
            };

            builder.BuildFromModel(model);

            builder.Invalid.Should().BeFalse();
            builder.Result.Should().BeNull();
        }
        public override void OnLapFinished(object sender, RequiredModel model)
        {
            base.OnLapFinished(sender, model);

            if (MapManager.IsRecording)
            {
                MapManager.Save(model.TrackName, model.LayoutName);
                Logger.Info("Map was created and saved.");
                LoadedMap = MapManager.LoadMap(model.TrackName, model.LayoutName);
            }
        }
        public void Check_required_string_properties(string value)
        {
            var model = new RequiredModel {
                Summary = value
            };

            builder.BuildFromModel(model);

            builder.Invalid.Should().BeTrue();
            builder.Result.Errors.Should().ContainEquivalentOf(new
            {
                Error = "required",
                Path  = new[] { "summary" }
            });
        }
Esempio n. 14
0
        public void Analyze(RequiredModel model)
        {
            if (model != null)
            {
                EnsureSessionFinished(model);
                EnsureSessionStarted(model);

                EnsureLapFinished(model);
                EnsureLapStarted(model);
                EnsureLapInvalidated(model);

                EnsureSectorChanged(model);
                EnsurePitlaneStarted(model);
                EnsurePitlaneFinished(model);

                _previousModel = model;
            }

            Updated?.Invoke(this, model);
        }
Esempio n. 15
0
 public virtual void OnPitlaneFinished(object sender, RequiredModel model)
 {
     Logger.Info("Pitlane finished.");
 }
Esempio n. 16
0
 public virtual void OnPitlaneStarted(object sender, RequiredModel model)
 {
     Logger.Info("Pitlane started.");
 }
Esempio n. 17
0
 public virtual void OnSectorChanged(object sender, RequiredModel model)
 {
     Logger.Info("Sector changed.");
 }
Esempio n. 18
0
 public virtual void OnLapInvalidated(object sender, RequiredModel model)
 {
     Logger.Info("Lap invalidated.");
 }
Esempio n. 19
0
 public virtual void OnLapFinished(object sender, RequiredModel model)
 {
     Logger.Info("Lap finished.");
 }
Esempio n. 20
0
 public virtual void OnLapStarted(object sender, RequiredModel model)
 {
     Logger.Info("Lap started.");
 }
Esempio n. 21
0
 public virtual void OnSessionFinished(object sender, RequiredModel model)
 {
     Logger.Info("Session finished.");
 }
Esempio n. 22
0
 public virtual void OnSessionStarted(object sender, RequiredModel model)
 {
     Logger.Info("Session started.");
 }
 public override void OnPitlaneFinished(object sender, RequiredModel model)
 {
     base.OnPitlaneFinished(sender, model);
     MapManager.Clear();
 }
Esempio n. 24
0
 public virtual void OnUpdated(object sender, RequiredModel model)
 {
 }
 public override void OnUpdated(object sender, RequiredModel model)
 {
     Publisher?.Publish(model);
 }
 public override void OnSessionStarted(object sender, RequiredModel model)
 {
     base.OnSessionStarted(sender, model);
     LoadedMap = MapManager.LoadMap(model.TrackName, model.LayoutName);
 }