Пример #1
0
    public void Undo()
    {
        if (undoStack.Count == 0)
        {
            return;
        }
        var state = undoStack.Pop();

        redoStack.Push(stateProvider.GetState(this));
        stateProvider.SetState(state);
    }
        private void RecordHighTideMark(SyncItem syncItem)
        {
            var retry = 5;

            do
            {
                try
                {
                    var state = _stateProvider.GetState(_syncItem.StateKey);
                    state.DownloadHighTide = _syncItem.Published;
                    state.SaveState(_syncItem.StateKey);
                    retry = 0;
                }
                catch (System.IO.IOException)
                {
                    OnStatusUpdate(new StatusUpdateEventArgs(StatusUpdateLevel.Warning, string.Format(CultureInfo.InvariantCulture, "{0}, cannot write to state file, will retry", syncItem.EpisodeTitle), false, syncItem));
                    if (_syncItem.RetryWaitTimeInSeconds > 0)
                    {
                        Thread.Sleep(1000 * _syncItem.RetryWaitTimeInSeconds);
                    }
                    retry--;
                    if (retry == 0)
                    {
                        throw;
                    }
                }
            } while (retry > 0);
        }
Пример #3
0
        private List <ISyncItem> ApplyDownloadStrategy(string stateKey, IPodcastInfo podcastInfo, List <ISyncItem> episodesFound)
        {
            switch (podcastInfo.Feed.DownloadStrategy.Value)
            {
            case PodcastEpisodeDownloadStrategy.All:
                return(episodesFound);

            case PodcastEpisodeDownloadStrategy.HighTide:
                var state       = _stateProvider.GetState(stateKey);
                var newEpisodes =
                    (from episode in episodesFound
                     where episode.Published > state.DownloadHighTide
                     select episode);
                var filteredEpisodes = new List <ISyncItem>(1);
                filteredEpisodes.AddRange(newEpisodes);
                return(filteredEpisodes);

            case PodcastEpisodeDownloadStrategy.Latest:
                episodesFound.Sort((e1, e2) => e2.Published.CompareTo(e1.Published));
                var latestEpisodes = new List <ISyncItem>(1);
                latestEpisodes.AddRange(episodesFound.Take(1));
                return(latestEpisodes);

            default:
                throw new EnumOutOfRangeException();
            }
        }
        private void UpdateStateEstimators(SimulationStepResults simulationState, GameTime gameTime, JoystickOutput output,
                                           out PhysicalHeliState estimatedState,
                                           out PhysicalHeliState blindEstimatedState,
                                           out PhysicalHeliState observedState)
        {
            var dtMillis    = (long)gameTime.ElapsedGameTime.TotalMilliseconds;
            var totalMillis = (long)gameTime.TotalGameTime.TotalMilliseconds;

            //            TimeSpan totalSimulationTime = gameTime.TotalGameTime;

            // Update sensors prior to using the state provider,
            // because they are typically dependent on the state of the sensors.
            Sensors.Update(_simulationState, output);

            // Update states
            ((SensorEstimatedState)_estimatedStateProvider).CheatingTrueState = simulationState; // TODO Temp cheating
            _estimatedStateProvider.Update(simulationState, dtMillis, totalMillis, output);

            // TODO Separate physical and navigational states
            _estimatedStateProvider.GetState(out estimatedState, out observedState, out blindEstimatedState);
        }