コード例 #1
0
        public override Result VisitResult(Result node)
        {
            if (!FilteringStrategy(node))
            {
                return(node);
            }

            string ruleId;

            if (node.RuleIndex > -1 && CurrentRun.Tool?.Driver?.Rules?.Count > node.RuleIndex)
            {
                ruleId = CurrentRun.Tool.Driver.Rules?[node.RuleIndex].Id;
            }
            else
            {
                // Remove the rule pattern index from the rule id. e.g. CSCAN0230/5
                int lastIndexOf = node.RuleId.LastIndexOf('/');
                ruleId = node.RuleId.Substring(0, lastIndexOf >= 0 ? lastIndexOf : node.RuleId.Length);
            }

            ArtifactLocation artifactLocation = node.Locations?[0]?.PhysicalLocation?.ArtifactLocation ?? s_emptyArtifactLocation;

            if (!_targetToRuleMap.TryGetValue(artifactLocation.Uri.ToString(), out Dictionary <string, SarifLog> ruleToSarifLogMap))
            {
                ruleToSarifLogMap = _targetToRuleMap[artifactLocation.Uri.ToString()] = new Dictionary <string, SarifLog>();
            }

            if (!ruleToSarifLogMap.TryGetValue(ruleId, out SarifLog sarifLog))
            {
                ruleToSarifLogMap[ruleId] = sarifLog = new SarifLog()
                {
                    Runs = new[]
                    {
                        new Run
                        {
                            Tool        = CurrentRun.Tool,
                            Invocations = CurrentRun.Invocations,
                            Results     = new List <Result>()
                        },
                    }
                };
                SplitSarifLogs.Add(sarifLog);
            }

            if (artifactLocation != null && artifactLocation.Index > -1)
            {
                int originalIndex = CurrentRun.GetFileIndex(artifactLocation);
                artifactLocation       = artifactLocation.DeepClone();
                artifactLocation.Index = sarifLog.Runs[0].GetFileIndex(artifactLocation);
                node.Locations[0].PhysicalLocation.ArtifactLocation = artifactLocation;
                sarifLog.Runs[0].Artifacts[artifactLocation.Index]  = CurrentRun.Artifacts[originalIndex];
            }

            sarifLog.Runs[0].Results.Add(node);

            return(node);
        }
コード例 #2
0
        protected override void PrepareSimulation()
        {
            base.PrepareSimulation();
            // Create global statistcis
            CurrentRun.initializeCurrentRun();
            _statistics = new Statistics();

            // inicializacia aut
            //
            //AgentDopravy.PrepareCars(SeedGenerator);
            SkladkaWStat = new WStat(this);
        }
コード例 #3
0
        public override Result VisitResult(Result node)
        {
            if (!FilteringStrategy(node))
            {
                return(node);
            }

            ArtifactLocation artifactLocation = node?.Locations[0]?.PhysicalLocation?.ArtifactLocation ?? s_emptyArtifactLocation;

            if (artifactLocation == null)
            {
                throw new InvalidOperationException("Result.Locations.PhysicalLocation.ArtifactLocation is null.");
            }

            if (!_targetMap.TryGetValue(artifactLocation.Uri.OriginalString, out SarifLog sarifLog))
            {
                sarifLog = _targetMap[artifactLocation.Uri.OriginalString] = new SarifLog()
                {
                    Runs = new[]
                    {
                        new Run
                        {
                            Tool        = CurrentRun.Tool,
                            Invocations = CurrentRun.Invocations,
                            Results     = new List <Result>()
                        },
                    }
                };
                SplitSarifLogs.Add(sarifLog);
            }

            if (artifactLocation != null && artifactLocation.Index > -1)
            {
                int originalIndex = CurrentRun.GetFileIndex(artifactLocation);
                artifactLocation       = artifactLocation.DeepClone();
                artifactLocation.Index = sarifLog.Runs[0].GetFileIndex(artifactLocation);
                node.Locations[0].PhysicalLocation.ArtifactLocation = artifactLocation;
                sarifLog.Runs[0].Artifacts[artifactLocation.Index]  = CurrentRun.Artifacts[originalIndex];
            }

            sarifLog.Runs[0].Results.Add(node);

            return(node);
        }
コード例 #4
0
        public void UpdateUI()
        {
            if (CurrentRun != null && !CurrentRun.Active)
            {
                mRunLocations = mRunManager.GetLocationsForRun(CurrentRun.Id);

                if (mRunLocations.Count > 0)
                {
                    mStartedTextView.Text = CurrentRun.StartDate.ToLocalTime().ToString();

                    mLatitudeTextView.Text  = mRunLocations[0].Latitude.ToString();
                    mLongitudeTextView.Text = mRunLocations[0].Longitude.ToString();
                    mAltitudeTextView.Text  = mRunLocations[0].Altitude.ToString();

                    int durationSeconds = (int)Math.Ceiling((mRunLocations[mRunLocations.Count - 1].Time - CurrentRun.StartDate).TotalSeconds);
                    mDurationTextView.Text = Run.FormatDuration(durationSeconds);

//					var location = new LatLng(mRunLocations[mRunLocations.Count -1].Latitude, mRunLocations[mRunLocations.Count -1].Longitude);
//					var cu = CameraUpdateFactory.NewLatLngZoom (location, 20);
//					mGoogleMap.MoveCamera (cu);
                    DrawRunTrack(false);
                }
                else
                {
                    var     toast   = Toast.MakeText(Activity, Resource.String.empty_run_message, ToastLength.Long);
                    Display display = Activity.WindowManager.DefaultDisplay;
                    var     size    = new Android.Graphics.Point();
                    display.GetSize(size);
                    toast.SetGravity(GravityFlags.Top, 0, size.Y / 6);
                    toast.Show();
                }

                if (mRunManager.IsTrackingRun())
                {
                    mStartButton.Enabled    = false;
                    mStartButton.Visibility = ViewStates.Invisible;
                    mStopButton.Enabled     = false;
                    mStopButton.Visibility  = ViewStates.Invisible;
                }
                else
                {
                    mStartButton.Enabled = true;
                    mStopButton.Enabled  = false;
                }
            }
            else
            {
                bool started = mRunManager.IsTrackingRun();

                if (CurrentRun != null)
                {
                    mRunLocations         = mRunManager.GetLocationsForRun(CurrentRun.Id);
                    mStartedTextView.Text = CurrentRun.StartDate.ToLocalTime().ToString();
                }

                int durationSeconds = 0;
                if (CurrentRun != null && LastLocation != null)
                {
                    DateTime lastLocTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(LastLocation.Time);
                    durationSeconds         = CurrentRun.GetDurationSeconds(lastLocTime);
                    mLatitudeTextView.Text  = LastLocation.Latitude.ToString();
                    mLongitudeTextView.Text = LastLocation.Longitude.ToString();
                    mAltitudeTextView.Text  = LastLocation.Altitude.ToString();
                    mDurationTextView.Text  = Run.FormatDuration(durationSeconds);
                    CurrentRun.Duration     = durationSeconds;
                    mRunManager.UpdateItem <Run>(CurrentRun);

//					var location = new LatLng(LastLocation.Latitude, LastLocation.Longitude);
//					var cu = CameraUpdateFactory.NewLatLngZoom (location, 20);
//					mGoogleMap.MoveCamera (cu);
                    DrawRunTrack(true);
                }

                mStartButton.Enabled = !started;
                mStopButton.Enabled  = started;
            }
        }
コード例 #5
0
        public void Update()
        {
            // A run is over if the player is dead or the world changes (through a portal or the bottom of a world).
            var IsPayerDead   = LocalGameManager.Singleton.playerState == LocalGameManager.PlayerState.Dead;
            var isNextWorld   = CurrentRun != null && (CurrentRun.Seed != WorldManager.currentWorld.seed);
            var isPlayerReset = LocalGameManager.Singleton.playerState == LocalGameManager.PlayerState.Flying && Input.GetButtonDown("ResetPlayer");

            if (CurrentRun != null && (IsPayerDead || isNextWorld || isPlayerReset))
            {
                CurrentRun.TotalScore = LocalGameManager.Singleton.ScoreThisRun;

                if (IsPayerDead)
                {
                    CurrentRun.Ending = RunEnding.Death;
                }
                else if (isNextWorld)
                {
                    CurrentRun.Ending = RunEnding.NextWorld;
                }
                else
                {
                    CurrentRun.Ending = RunEnding.Reset;
                }

                // If the last run ended by traversing worlds, the player likely has points already, so we need to subtract those.
                if (LastRun != null && LastRun.Ending == RunEnding.NextWorld)
                {
                    CurrentRun.SecuredScore = LocalGameManager.Singleton.ScoreThisRun - LastRun.TotalScore;
                }
                else
                {
                    CurrentRun.SecuredScore = LocalGameManager.Singleton.ScoreThisRun;
                }

                foreach (int s in CurrentRun.ScorePerSecond)
                {
                    CurrentRun.AccumulatedScore += s;
                }

                if (CurrentRun.AccumulatedScore > 0)
                {
                    using (var writer = File.AppendText(SaveLocation))
                        writer.WriteLine(CurrentRun.ToCsvRow());
                }

                LastRun    = CurrentRun;
                CurrentRun = null;
            }

            // Calculate the increase in combo each frame, so no points are lost.
            ComboIncrease += Math.Max(0, LocalGameManager.Singleton.ScoreThisCombo - LastCombo);
            LastCombo      = LocalGameManager.Singleton.ScoreThisCombo;

            if (Time.time - LastSecond > 1)
            {
                if (LocalGameManager.Singleton.playerState == LocalGameManager.PlayerState.Flying)
                {
                    if (CurrentRun == null)
                    {
                        CurrentRun = new RunData
                        {
                            Seed = WorldManager.currentWorld.seed,
                            AlphanumericString = WorldManager.currentWorld.alphanumericSeed,
                            AccumulatedScore   = 0,
                            SecuredScore       = 0,
                            TotalScore         = 0,
                            ScorePerSecond     = new List <int>()
                        };

                        ComboIncrease = 0;
                    }

                    CurrentRun.ScorePerSecond.Add(ComboIncrease);

                    ComboIncrease = 0;
                }

                LastSecond = Time.time;
            }
        }