예제 #1
0
 private CompetitionRunTimings(RecordedTime startTime, RecordedTime?intermediateTime1, RecordedTime?intermediateTime2, RecordedTime?intermediateTime3,
                               RecordedTime?finishTime)
     : this(startTime)
 {
     IntermediateTime1 = intermediateTime1;
     IntermediateTime2 = intermediateTime2;
     IntermediateTime3 = intermediateTime3;
     FinishTime        = finishTime;
 }
 private CompetitionRunTimings([NotNull] RecordedTime startTime, [CanBeNull] RecordedTime intermediateTime1,
     [CanBeNull] RecordedTime intermediateTime2, [CanBeNull] RecordedTime intermediateTime3,
     [CanBeNull] RecordedTime finishTime)
     : this(startTime)
 {
     IntermediateTime1 = intermediateTime1;
     IntermediateTime2 = intermediateTime2;
     IntermediateTime3 = intermediateTime3;
     FinishTime = finishTime;
 }
예제 #3
0
 public virtual void Update(RecordedTime gameTime)
 {
     if (updateable)
     {
         foreach (Manager item in subManagers)
         {
             item.Update(gameTime);
         }
     }
 }
예제 #4
0
 public virtual void Draw(RecordedTime gameTime)
 {
     if (drawable)
     {
         foreach (Manager item in subManagers)
         {
             item.Draw(gameTime);
         }
     }
 }
        public CompetitionRunTimings UpdateFinishTimeFrom(TimeSpanWithAccuracy?finishTime)
        {
            RecordedTime startTime = CreateBestPossibleStartTime();

            CompetitionRunTimings timings = Timings ?? new CompetitionRunTimings(startTime);

            timings = timings.ChangeFinishTime(TryCreateRecordedTime(startTime, finishTime));

            return(timings);
        }
        private RecordedTime CreateBestPossibleStartTime()
        {
            // Note: In case we have no start time, we generate one here (with high precision). A low-precision elapsed
            // time is caused by either one or both times to be low precision. Although we cannot know the
            // precision of start time here, the nett effect when the precision of an elapsed time is recalculated will
            // be the same as long as we assume that the start time was high precision.
            RecordedTime startTime = Timings?.StartTime ?? new RecordedTime(TimeSpan.Zero, SystemContext.UtcNow());

            return(startTime);
        }
        public override void Draw(RecordedTime gameTime)
        {
            timeSinceLastUpdate += (float)gameTime.ElapsedTime.TotalSeconds;
            framecount++;
            if (timeSinceLastUpdate >= updateInterval)
            {
                game.System.Window.Title = "FPS: " + (framecount / timeSinceLastUpdate).ToString() +
                    "  ScreenSize: " + game.System.Window.WindowWidth + "x" +
                    game.System.Window.WindowHeight +
                   " -- RT: " + gameTime.ElapsedTime.TotalMilliseconds;

                timeSinceLastUpdate -= updateInterval;
                framecount = 0;
            }
        }
        public CompetitionRunTimings UpdateTimingsFrom(TimeSpanWithAccuracy?intermediateTime1, TimeSpanWithAccuracy?intermediateTime2,
                                                       TimeSpanWithAccuracy?intermediateTime3, TimeSpanWithAccuracy?finishTime)
        {
            RecordedTime startTime = CreateBestPossibleStartTime();

            CompetitionRunTimings timings = Timings ?? new CompetitionRunTimings(startTime);

            // @formatter:keep_existing_linebreaks true

            timings = timings
                      .ChangeIntermediateTime1(TryCreateRecordedTime(startTime, intermediateTime1))
                      .ChangeIntermediateTime2(TryCreateRecordedTime(startTime, intermediateTime2))
                      .ChangeIntermediateTime3(TryCreateRecordedTime(startTime, intermediateTime3))
                      .ChangeFinishTime(TryCreateRecordedTime(startTime, finishTime));

            // @formatter:keep_existing_linebreaks restore

            return(timings);
        }
        public override void Update(RecordedTime gameTime)
        {
            int nextStartX = 0, nextStartY = 0;
            if (!solved)
            {
                if(currentStartY < sizeY)
                {
                    Reset();
                    if (Start(currentStartX, currentStartY))
                    {
                        Search(currentStartX, currentStartY);
                        //   TryMoves();
                    }
                    if(!solved)
                        Reset();

                    if (currentStartX == sizeX - 1)
                    {
                        currentStartX = 0;
                        currentStartY++;
                    }
                    else
                        currentStartX++;
                    nextStartX = currentStartX + 1;
                    nextStartY = currentStartY;
                    if(nextStartX >= sizeX - 1)
                    {
                        nextStartX = 1;
                        nextStartY++;
                    }
                }
                if (solved && autosubmit)
                {
                    solutionURL = redoURL;
                    SubmitSolutionAndReload(gameTime.ElapsedTime);
                }
            }
            currentStartSprite.Position = new Vector3(nextStartX + .25f, nextStartY + .25f, 2f);
            if (solved)
                currentStartSprite.Position = new Vector3(undoData.StartLocation.x + .25f, undoData.StartLocation.y + .25f, 2f);
            base.Update(gameTime);
        }
        public override void Draw(RecordedTime gameTime)
        {
            graphics.Clear(Color.Black, 102.0f);

            if (boardDrawingToggled)
            {
                testGrid.Draw();
            }

            if(linesMade)
                undoData.DrawLines();

            currentStartSprite.Draw();
            base.Draw(gameTime);
        }
 public override void Update(RecordedTime gameTime)
 {
     base.Update(gameTime);
 }
        public void HandleGatePassed([CanBeNull] TimeSpan? sensorTime, GatePassage passageGate,
            [NotNull] WirelessNetworkAddress source)
        {
            string timeText = sensorTime != null ? "with time " + sensorTime : "without time";
            Log.Debug($"Entering HandleGatePassed for {passageGate} {timeText}.");

            // Devices without capability TimeSensor are considered low-precision, but hardware time is used.
            bool useSensorTime = synchronizationMonitor.IsDeviceSynchronized(source);
            TimeAccuracy? accuracy = DeviceHasTimeSensorCapability(source)
                ? (TimeAccuracy?) null
                : TimeAccuracy.LowPrecision;
            var passageTime = new RecordedTime(useSensorTime ? sensorTime : null, SystemContext.UtcNow(), accuracy);

            Log.Debug($"Evaluated sensor time: {passageTime}");

            switch (passageGate)
            {
                case GatePassage.PassStartFinish:
                    HandlePassStartOrFinishWhenSingleSensor(passageTime);
                    break;
                case GatePassage.PassStart:
                    HandlePassStart(passageTime);
                    break;
                case GatePassage.PassIntermediate1:
                    HandlePassIntermediate1(passageTime);
                    break;
                case GatePassage.PassIntermediate2:
                    HandlePassIntermediate2(passageTime);
                    break;
                case GatePassage.PassIntermediate3:
                    HandlePassIntermediate3(passageTime);
                    break;
                case GatePassage.PassFinish:
                    HandlePassFinish(passageTime);
                    break;
                default:
                    throw ExceptionFactory.CreateNotSupportedExceptionFor(passageGate);
            }
        }
        private static bool RecordedTimesElapsedEqual(RecordedTime firstRecordedTime, RecordedTime secondRecordedTime)
        {
            TimeSpanWithAccuracy elapsed = firstRecordedTime.ElapsedSince(secondRecordedTime);

            return(elapsed.TimeValue == TimeSpan.Zero);
        }
        public override void Update(RecordedTime gameTime)
        {
            this.gameTime = gameTime;
            if (!go)
                this.beginTime = gameTime.TotalTime;
            go = true;
            if (go)
            {
                int nextStartX = 0, nextStartY = 0;
                if (!solved)
                {
                    if (currentStartY < sizeY)
                    {
                        Reset();
                        if (Start(currentStartX, currentStartY))
                        {

                            Search(currentStartX, currentStartY);
                            //   TryMoves();
                        }
                        if (!solved)
                            Reset();

                        if (currentStartX == sizeX - 1)
                        {
                            currentStartX = 0;
                            currentStartY++;
                        }
                        else
                            currentStartX++;
                        nextStartX = currentStartX + 1;
                        nextStartY = currentStartY;
                        if (nextStartX >= sizeX - 1)
                        {
                            nextStartX = 1;
                            nextStartY++;
                        }
                    }
                    if (solved && autosubmit)
                    {
                       // solutionURL = redoURL;
                        SubmitSolutionAndReload(gameTime.ElapsedTime);
                    }
                }
                currentStartSprite.Position = new Vector3(nextStartX + .25f, nextStartY + .25f, 2f);
                if (solved)
                    currentStartSprite.Position = new Vector3(moveManager.StartLocation.x + .25f, moveManager.StartLocation.y + .25f, 2f);
            }
            base.Update(gameTime);
        }
예제 #15
0
        private static RecordedTime?GetTimeElapsedSinceStart(IDelimitedValuesReaderRow row, string columnName, RecordedTime startTime)
        {
            string timeString = row.GetCell(columnName);
            TimeSpanWithAccuracy?timeWithAccuracy = TimeSpanWithAccuracy.FromString(timeString, Settings.Default.ImportExportCulture);

            return(timeWithAccuracy != null?startTime.Add(timeWithAccuracy.Value) : null);
        }
예제 #16
0
        public CompetitionRunTimings(RecordedTime startTime)
        {
            Guard.NotNull(startTime, nameof(startTime));

            StartTime = startTime;
        }
 private static RecordedTime?TryCreateRecordedTime(RecordedTime startTime, TimeSpanWithAccuracy?elapsed)
 {
     return(elapsed != null?startTime.Add(elapsed.Value) : null);
 }
        private static CompetitionRunResult GetRunResultFrom([NotNull] IDelimitedValuesReaderRow row,
            bool hasOptionalColumns, DateTime startTimeUtc)
        {
            Competitor competitor = GetCompetitorFrom(row);
            var runResult = new CompetitionRunResult(competitor);

            if (hasOptionalColumns)
            {
                var faultCount = row.GetCell<int?>(ImportExportColumns.FaultCount);
                var refusalCount = row.GetCell<int?>(ImportExportColumns.RefusalCount);
                var isEliminated = row.GetCell<bool?>(ImportExportColumns.IsEliminated);

                // Note: We cannot reconstruct whether start time was high precision, because it does not roundtrip
                // through import/export. However, we do not need to know. A low-precision elapsed time is caused by 
                // either one or both times to be low precision. So although we lost some information, the nett effect
                // when the precision of an elapsed time is recalculated will be the same as long as we assume that the start
                // time was high precision.
                var startTime = new RecordedTime(TimeSpan.Zero, startTimeUtc);

                RecordedTime intermediateTime1 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime1,
                    startTime);
                RecordedTime intermediateTime2 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime2,
                    startTime);
                RecordedTime intermediateTime3 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime3,
                    startTime);
                RecordedTime finishTime = GetTimeElapsedSinceStart(row, ImportExportColumns.FinishTime, startTime);

                if (intermediateTime1 == null && intermediateTime2 == null && intermediateTime3 == null &&
                    finishTime == null)
                {
                    startTime = null;
                }

                bool runCompleted = finishTime != null || (isEliminated != null && isEliminated.Value);
                if (runCompleted)
                {
                    if (faultCount != null)
                    {
                        runResult = runResult.ChangeFaultCount(faultCount.Value);
                    }
                    if (refusalCount != null)
                    {
                        runResult = runResult.ChangeRefusalCount(refusalCount.Value);
                    }
                    if (isEliminated != null)
                    {
                        runResult = runResult.ChangeIsEliminated(isEliminated.Value);
                    }

                    if (startTime != null)
                    {
                        runResult =
                            runResult.ChangeTimings(
                                new CompetitionRunTimings(startTime).ChangeIntermediateTime1(intermediateTime1)
                                    .ChangeIntermediateTime2(intermediateTime2)
                                    .ChangeIntermediateTime3(intermediateTime3)
                                    .ChangeFinishTime(finishTime));
                    }
                }
            }

            return runResult;
        }
        public override void Draw(RecordedTime gameTime)
        {
            graphics.Clear(FACE_System.Color.Black, 5.0f);

            currentStartSprite.Draw();

            if (linesMade)
                moveManager.DrawLines();

            if (boardDrawingToggled)
            {
                testGrid.Draw();
            }

            base.Draw(gameTime);
        }
예제 #20
0
        private static CompetitionRunResult GetRunResultFrom(IDelimitedValuesReaderRow row, bool hasOptionalColumns, DateTime startTimeUtc)
        {
            Competitor competitor = GetCompetitorFrom(row);
            var        runResult  = new CompetitionRunResult(competitor);

            if (hasOptionalColumns)
            {
                int? faultCount   = row.GetCell <int?>(ImportExportColumns.FaultCount);
                int? refusalCount = row.GetCell <int?>(ImportExportColumns.RefusalCount);
                bool?isEliminated = row.GetCell <bool?>(ImportExportColumns.IsEliminated);

                // Note: We cannot reconstruct whether start time was high precision, because it does not roundtrip
                // through import/export. However, we do not need to know. A low-precision elapsed time is caused by
                // either one or both times to be low precision. So although we lost some information, the nett effect
                // when the precision of an elapsed time is recalculated will be the same as long as we assume that the start
                // time was high precision.
                var startTime = new RecordedTime(TimeSpan.Zero, startTimeUtc);

                RecordedTime?intermediateTime1 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime1, startTime);
                RecordedTime?intermediateTime2 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime2, startTime);
                RecordedTime?intermediateTime3 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime3, startTime);
                RecordedTime?finishTime        = GetTimeElapsedSinceStart(row, ImportExportColumns.FinishTime, startTime);

                if (intermediateTime1 == null && intermediateTime2 == null && intermediateTime3 == null && finishTime == null)
                {
                    startTime = null;
                }

                bool runCompleted = finishTime != null || (isEliminated != null && isEliminated.Value);

                if (runCompleted)
                {
                    if (faultCount != null)
                    {
                        runResult = runResult.ChangeFaultCount(faultCount.Value);
                    }

                    if (refusalCount != null)
                    {
                        runResult = runResult.ChangeRefusalCount(refusalCount.Value);
                    }

                    if (isEliminated != null)
                    {
                        runResult = runResult.ChangeIsEliminated(isEliminated.Value);
                    }

                    if (startTime != null)
                    {
                        // @formatter:keep_existing_linebreaks true

                        runResult = runResult
                                    .ChangeTimings(new CompetitionRunTimings(startTime)
                                                   .ChangeIntermediateTime1(intermediateTime1)
                                                   .ChangeIntermediateTime2(intermediateTime2)
                                                   .ChangeIntermediateTime3(intermediateTime3)
                                                   .ChangeFinishTime(finishTime));

                        // @formatter:keep_existing_linebreaks restore
                    }
                }
            }

            return(runResult);
        }