Beispiel #1
0
        private int stackPtr; //Pointer to next address to write to

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new z processor
        /// </summary>
        /// <param name="buf">memory buffer</param>
        /// <param name="ui">interface with the rest of the world</param>
        protected ZProcessor(MemoryBuffer buf, IUserInterface ui)
        {
            //Validate params
            if (buf == null)
            {
                throw new ArgumentNullException("buf");
            }
            else if (ui == null)
            {
                throw new ArgumentNullException("ui");
            }

            //Cache global vars offset
            globalVarsOffset = buf.GetUShort(0xC) - 0x10;

            //Globals vars must be higher than the header (security)
            if (globalVarsOffset + 0x10 < 64)
            {
                throw new ZMachineException("global variables table must not reside in the header");
            }

            //Set dynamic limit
            buf.DynamicLimit = Math.Min((int) buf.GetUShort(0xE), 64);

            //Store memory buffer and ui
            memBuf = buf;
            zUi = ui;

            //Create encoder and object tree
            zEncoder = new ZTextEncoder(buf);
            objectTree = new ZObjectTree(buf);
        }
        public void Display(IUserInterface userInterface, IServiceResult serviceResult)
        {
            if (userInterface == null)
            {
                throw new ArgumentNullException("userInterface");
            }

            if (serviceResult == null)
            {
                return;
            }

            if (serviceResult.Status == ServiceResultType.NoResult)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(serviceResult.Message))
            {
                return;
            }

            if (serviceResult.InnerResult != null)
            {
                this.Display(userInterface, serviceResult.InnerResult);
            }

            string resultTypeLabel = Resources.ServiceResultVisualizer.ResourceManager.GetString("ServiceResultType" + serviceResult.Status);
            userInterface.WriteLine(resultTypeLabel + ": " + serviceResult.Message);

            if (!string.IsNullOrWhiteSpace(serviceResult.ResultArtefact))
            {
                userInterface.WriteLine(Resources.ServiceResultVisualizer.ReturnValue + ": " + serviceResult.ResultArtefact);
            }
        }
        public SelfUpdateService(IUserInterface userInterface, ApplicationInformation applicationInformation, IPackageRepositoryBrowser packageRepositoryBrowser, IFilesystemAccessor filesystemAccessor)
        {
            if (userInterface == null)
            {
                throw new ArgumentNullException("userInterface");
            }

            if (applicationInformation == null)
            {
                throw new ArgumentNullException("applicationInformation");
            }

            if (packageRepositoryBrowser == null)
            {
                throw new ArgumentNullException("packageRepositoryBrowser");
            }

            if (filesystemAccessor == null)
            {
                throw new ArgumentNullException("filesystemAccessor");
            }

            this.userInterface = userInterface;
            this.applicationInformation = applicationInformation;
            this.packageRepositoryBrowser = packageRepositoryBrowser;
            this.filesystemAccessor = filesystemAccessor;
        }
Beispiel #4
0
 private Engine(CommandExecuter executor, IUserInterface userIo)
 {
     this.executor = executor;
     this.userIO = userIo;
     //// DI: Added IUserInterface and ConsoleIo types
     //// and made the constructor take an user interface usin DI
 }
Beispiel #5
0
 public Engine(PlayerType playerType, IUserInterface inputInterface)
 {
     this.PlayerType = playerType;
     this.rnd = new Random();
     this.inputInterface = inputInterface;
     this.AllObjects = new List<WorldObject>();
 }
Beispiel #6
0
 public Store(IUserInterface userInterface)
 {
     this.userInterface = userInterface;
     this.myChashRegisterModule = new CashRegister(1.95583m, 1.53m);
     this.myStorageModule = new Storage();
     this.myStorageModule.LoadDB();
 }
		public void LoadViewStateConfiguration(IViewStateConfiguration viewStateConfiguration, IUserInterface userInterface)
		{
			this.ViewStateConfiguration = viewStateConfiguration;
			viewStates = viewStateConfiguration.ViewStateList;
			this._UI = userInterface;
			this.DefaultViewState = viewStateConfiguration.DefaultViewState;
		}
        private static void HandlePlayerControls(IUserInterface keyboard, Engine engine)
        {
            keyboard.OnUpPressed += (sender, eventInfo) =>
            {
                engine.MoveCruiserUp();
            };

            keyboard.OnDownPressed += (sender, eventInfo) =>
            {
                engine.MoveCruiserDown();
            };

            keyboard.OnLeftPressed += (sender, eventInfo) =>
            {
                engine.MoveCruiserLeft();
            };

            keyboard.OnRightPressed += (sender, eventInfo) =>
            {
                engine.MoveCruiserRight();
            };

            keyboard.OnActionPressed += (sender, eventInfo) =>
            {
                engine.CruiserShoot();
            };
        }
        private static void ProcessKeyboardEvents(IUserInterface keyboard, ConsoleEngine engine)
        {
            keyboard.OnUpPressed += (sender, eventInfo) =>
            {
                engine.MovementManager.MovePlayerUp();
            };

            keyboard.OnDownPressed += (sender, eventInfo) =>
            {
                engine.MovementManager.MovePlayerDown();
            };

            keyboard.OnLeftPressed += (sender, eventInfo) =>
            {
                engine.MovementManager.MovePlayerLeft();
            };

            keyboard.OnUpLeftPressed += (sender, eventInfo) =>
            {
                engine.MovementManager.MovePlayerUpLeft();
            };

            keyboard.OnRightPressed += (sender, eventInfo) =>
            {
                engine.MovementManager.MovePlayerRight();
            };

            keyboard.OnUpRightPressed += (sender, eventInfo) =>
            {
                engine.MovementManager.MovePlayerUpRight();
            };
        }
        public VersionCheckerViewModel(VersionChecker versionChecker, FileDownloader fileDownloader,
            IUserInterface userInterface, IVersionCheckerConfig config, IVersionCheckerUserInterface versionCheckerUserInterface)
        {
            if (versionChecker == null) throw new ArgumentNullException("versionChecker");
            if (fileDownloader == null) throw new ArgumentNullException("fileDownloader");
            if (userInterface == null) throw new ArgumentNullException("userInterface");
            if (config == null) throw new ArgumentNullException("config");
            if (versionCheckerUserInterface == null) throw new ArgumentNullException("versionCheckerUserInterface");

            this.versionChecker = versionChecker;
            this.fileDownloader = fileDownloader;
            this.userInterface = userInterface;
            this.config = config;
            this.versionCheckerUserInterface = versionCheckerUserInterface;

            CheckAgainCommand = new RelayCommand(p => true, CheckAgainClicked);
            DownloadCommand = new RelayCommand(p => true, DownloadClicked);
            OpenDownloadedFileCommand = new RelayCommand(p => true, OpenDownloadedFileClicked);
            CheckAtStartupCommand = new RelayCommand(p => true, CheckAtStartupChanged);
            CloseCommand = new RelayCommand(p => true, CloseClicked);

            ChangeStateToEmpty();

            versionChecker.CheckStarting += HandleVersionCheckStarting;
            versionChecker.CheckCompleted += HandleCheckCompleted;

            this.fileDownloader.DownloadFileStarting += HandleDownloadFileStarting;
            this.fileDownloader.DownloadProgressChanged += HandleDownloadProgressChanged;
            this.fileDownloader.DownloadFileCompleted += HandleDownloadFileCompleted;

            config.CheckAtStartUpChanged += HandleOptionsCheckAtStartupChanged;

            CheckAtStartupEnabled = true;
            CheckAtStartupValue = config.CheckAtStartUp;
        }
Beispiel #11
0
        public Program(ApplicationInformation applicationInformation, IUserInterface userInterface, IActionLogger logger, ICommandLineArgumentInterpreter commandLineArgumentInterpreter, IHelpCommand helpCommand)
        {
            if (applicationInformation == null)
            {
                throw new ArgumentNullException("applicationInformation");
            }

            if (userInterface == null)
            {
                throw new ArgumentNullException("userInterface");
            }

            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            if (commandLineArgumentInterpreter == null)
            {
                throw new ArgumentNullException("commandLineArgumentInterpreter");
            }

            if (helpCommand == null)
            {
                throw new ArgumentNullException("helpCommand");
            }

            this.applicationInformation = applicationInformation;
            this.userInterface = userInterface;
            this.logger = logger;
            this.commandLineArgumentInterpreter = commandLineArgumentInterpreter;
            this.helpCommand = helpCommand;
        }
Beispiel #12
0
        private static void HandlePlayerTwoControls(IUserInterface keyboard, Engine engine)
        {
            keyboard.OnUpPressedPlayerTwo += (sender, eventInfo) =>
            {
                Console.SetCursorPosition(startRow, startCol);
                Console.WriteLine("Player2, make a move please!");
                engine.MovePlayerTwoUp();
            };

            keyboard.OnDownPressedPlayerTwo += (sender, eventInfo) =>
            {
                Console.SetCursorPosition(startRow, startCol);
                Console.WriteLine("Player2, make a move please!");
                engine.MovePlayerTwoDown();
            };

            keyboard.OnLeftPressedPlayerTwo += (sender, eventInfo) =>
            {
                Console.SetCursorPosition(startRow, startCol);
                Console.WriteLine("Player2, make a move please!");
                engine.MovePlayerTwoLeft();
            };

            keyboard.OnRightPressedPlayerTwo += (sender, eventInfo) =>
            {
                Console.SetCursorPosition(startRow, startCol);
                Console.WriteLine("Player2, make a move please!");
                engine.MovePlayerTwoRight();
            };
        }
Beispiel #13
0
 public Engine(IUserInterface userInterface, IAttackFactory attackFactory, IBlobFactory blobFactory, IBehaviorFactory behaviorFactory, IDatabase database)
 {
     this.userInterface = userInterface;
     this.attackFactory = attackFactory;
     this.blobFactory = blobFactory;
     this.behaviorFactory = behaviorFactory;
     this.database = database;
 }
Beispiel #14
0
    public Engine(IRenderer renderer, IUserInterface userInterface)
    {
        this.renderer = renderer;
        this.userInterface = userInterface;

        this.OnMoveEnd += this.ResetAnimationDelay;
        this.OnMoveEnd += this.CheckForClearedRows;
    }
Beispiel #15
0
 private MusicShopEngine()
 {
     this.musicShopFactory = new MusicShopFactory();
     this.articleFactory = new ArticleFactory();
     this.musicShops = new Dictionary<string, IMusicShop>();
     this.articles = new Dictionary<string, IArticle>();
     this.userInterface = new ConsoleInterface();
 }
Beispiel #16
0
        static void Main(string[] args)
        {
            UI = new ConsoleUserInterface();

            UI.Splash();

            Start();
        }
 private RestaurantManagerEngine()
 {
     this.restaurantFactory = new RestaurantFactory();
     this.recipeFactory = new RecipeFactory();
     this.restaurants = new Dictionary<string, IRestaurant>();
     this.recipes = new Dictionary<string, IRecipe>();
     this.userInterface = new ConsoleInterface();
 }
Beispiel #18
0
        private readonly IUserInterface userInterface; // the user control on the console via keyboard.

        #endregion Fields

        #region Constructors

        // constructor - creates an on object of the Engine type
        public Engine(IRenderer renderer, IUserInterface userInterface)
        {
            this.renderer = renderer;
            this.userInterface = userInterface;
            this.AllObjects = new List<WorldObject>();
            this.MovingObjects = new List<MovableObject>();
            this.StaticObjects = new List<StaticObject>();
        }
 public void SetView(IUserInterface userinterface)
 {
     foreach (IUser user in users)
     {
         user.SetView(userinterface);
     }
     invalidUser.SetView(userinterface);
 }
 public ConsoleEngine(IUserInterface userInterface, int sleepTime)
 {
     this.userInterface = userInterface;
     this.SleepTime = sleepTime;
     this.MovementManager = new MovementManager();
     CurrentLevel = OutsideLevel.AboveGround;
     Player = new Mario(new MatrixCoordinates(Console.WindowHeight - 7, 0), MarioImages.RightProfile);
 }
        public Manager(IUserInterface userInterface, Configuration configuration, IBrowserNavigator browserNavigator)
        {
            m_browserNavigator = browserNavigator;
            m_configuration = configuration;
            m_userInterface = userInterface;

            userInterface.OnButtonClick += ButtonClick;
        }
Beispiel #22
0
 public Engine(IRenderer renderer, IUserInterface userInterface)
 {
     this.renderer = renderer;
     this.userInterface = userInterface;
     this.allObjects = new List<GameObject>();
     this.movingObjects = new List<MovingObjects>();
     this.staticObjects = new List<GameObject>();
 }
Beispiel #23
0
 public Engine(IRenderer renderer, IUserInterface userInterface, int sleepMilSeconds)
 {
     this.sleepMilSeconds = sleepMilSeconds;
     this.renderer = renderer;
     this.userInterface = userInterface;
     this.allObjects = new List<GameObject>();
     this.staticObjects = new List<GameObject>();
 }
Beispiel #24
0
 public Controller(IData data, IUserInterface ui) {
     Data = data;
     UI = ui;
     UI.OnImportFloorPlan += Data.ImportFloorPlan;
     UI.OnNewFloorPlan += Data.CreateFloorPlan;
     UI.OnExportFloorPlan += Data.ExportFloorPlan;
     UI.OnUISimulationStart += Data.StartSimulation;
     UI.OnPrepareSimulation += Data.PrepareSimulation;
 }
Beispiel #25
0
 public Engine(IRenderer renderer, IUserInterface userInterface, int sleepTime = 500)
 {
     this.renderer = renderer;
     this.userInterface = userInterface;
     this.allObjects = new List<GameObject>();
     this.movingObjects = new List<MovingObject>();
     this.staticObjects = new List<GameObject>();
     this.sleepTime = sleepTime;
 }
Beispiel #26
0
 public Engine(IUserInterface ui, IUserInputValidator validator, ICommandFactory commandFactory, IGameModel gameModel, IGameLogicProvider gameLogicProvider)
 {
     this.userInterface = ui;
     this.validator = validator;
     this.create = commandFactory;
     this.game = gameModel;
     this.gameLogicProvider = gameLogicProvider;
     this.highScoreChart = new string[2, 5];
 }
 public MinesweeperEngine(IUserInterface userInterface)
 {
     this.row = 0;
     this.col = 0;
     this.isWinining = false;
     this.userInterface = userInterface;
     this.topPlayers = new List<IPlayer>();
     this.InitializeBoard();
 }
Beispiel #28
0
 public Engine(IRenderer renderer, IUserInterface userInterface, int gameSpeed)
     : this(renderer, userInterface)
 {
     if (gameSpeed < 0)
     {
         throw new IndexOutOfRangeException("Game speed can not be negative");
     }
     this.gameSpeed = gameSpeed;
 }
Beispiel #29
0
 public GameEngine(IRenderer renderer, IUserInterface userInterface, int cellsCount)
 {
     this.renderer = renderer;
     this.userInterface = userInterface;
     this.allObjects = new List<GameObj>();
     this.movingObjects = new List<Zombie>();
     this.staticObjects = new List<GameObj>();
     this.cellsCount = cellsCount;
 }
Beispiel #30
0
        public FileDownloader(IUserInterface userInterface)
        {
            if (userInterface == null) throw new ArgumentNullException("userInterface");

            this.userInterface = userInterface;

            webClient = new WebClient();
            webClient.DownloadFileCompleted += HandleDownloadFileCompleted;
        }
        public Player CreateNewPlayer(IDieScoreCalculator dieScoreCalculator, IDieRoller dieRoller, IUserInterface userInterface, string playerName)
        {
            var gameState           = new PlayerGameState();
            var playerTurnProcessor = new PlayerTurnProcessor(dieScoreCalculator, dieRoller, userInterface, gameState);

            return(new Player(gameState, playerTurnProcessor, playerName));
        }
 public ServiceRemover(string[] servicesToRemove, IUserInterface ui)
 {
     this.servicesToRemove = servicesToRemove;
     this.ui         = ui;
     backupDirectory = new DirectoryInfo($"servicesBackup_{DateTime.Now:yyyy-MM-dd_hh-mm-ss}");
 }
Beispiel #33
0
 public ShootEnegine(IRenderer renderer, IUserInterface userInterface, int sleepTime) : base(renderer, userInterface, sleepTime)
 {
 }
 public LoginAuthorizeAttribute(IUserInterface IUserRepository)
 {
     lIUserRepository = IUserRepository;
 }
Beispiel #35
0
 public ProffesionFacultyMember(IUserInterface view)
 {
     mainMenuView = view;
 }
Beispiel #36
0
 public ShootEngine(IRenderer renderer, IUserInterface userInterface, int sleeping)
     : base(renderer, userInterface, sleeping)
 {
 }
Beispiel #37
0
 public void Setup(IUserInterface userInterface, ItemManager itemManager, PlayerStatus playerStatus)
 {
     this.userInterface = userInterface;
     this.itemManager   = itemManager;
     this.playerStatus  = playerStatus;
 }
Beispiel #38
0
        public Horizon(Switch device, ContentManager contentManager)
        {
            ControlData = new BlitStruct <ApplicationControlProperty>(1);

            Device = device;

            State = new SystemStateMgr();

            ResourceLimit = new KResourceLimit(this);

            KernelInit.InitializeResourceLimit(ResourceLimit);

            MemoryRegions = KernelInit.GetMemoryRegions();

            LargeMemoryBlockAllocator = new KMemoryBlockAllocator(MemoryBlockAllocatorSize * 2);
            SmallMemoryBlockAllocator = new KMemoryBlockAllocator(MemoryBlockAllocatorSize);

            UserSlabHeapPages = new KSlabHeap(
                UserSlabHeapBase,
                UserSlabHeapItemSize,
                UserSlabHeapSize);

            CriticalSection = new KCriticalSection(this);

            Scheduler = new KScheduler(this);

            TimeManager = new KTimeManager();

            Synchronization = new KSynchronization(this);

            ContextIdManager = new KContextIdManager();

            _kipId     = InitialKipId;
            _processId = InitialProcessId;

            Scheduler.StartAutoPreemptionThread();

            KernelInitialized = true;

            ThreadCounter = new CountdownEvent(1);

            Processes = new SortedDictionary <long, KProcess>();

            AutoObjectNames = new ConcurrentDictionary <string, KAutoObject>();

            // Note: This is not really correct, but with HLE of services, the only memory
            // region used that is used is Application, so we can use the other ones for anything.
            KMemoryRegionManager region = MemoryRegions[(int)MemoryRegion.NvServices];

            ulong hidPa  = region.Address;
            ulong fontPa = region.Address + HidSize;
            ulong iirsPa = region.Address + HidSize + FontSize;
            ulong timePa = region.Address + HidSize + FontSize + IirsSize;

            HidBaseAddress = (long)(hidPa - DramMemoryMap.DramBase);

            KPageList hidPageList  = new KPageList();
            KPageList fontPageList = new KPageList();
            KPageList iirsPageList = new KPageList();
            KPageList timePageList = new KPageList();

            hidPageList.AddRange(hidPa, HidSize / KMemoryManager.PageSize);
            fontPageList.AddRange(fontPa, FontSize / KMemoryManager.PageSize);
            iirsPageList.AddRange(iirsPa, IirsSize / KMemoryManager.PageSize);
            timePageList.AddRange(timePa, TimeSize / KMemoryManager.PageSize);

            HidSharedMem  = new KSharedMemory(this, hidPageList, 0, 0, MemoryPermission.Read);
            FontSharedMem = new KSharedMemory(this, fontPageList, 0, 0, MemoryPermission.Read);
            IirsSharedMem = new KSharedMemory(this, iirsPageList, 0, 0, MemoryPermission.Read);

            KSharedMemory timeSharedMemory = new KSharedMemory(this, timePageList, 0, 0, MemoryPermission.Read);

            TimeServiceManager.Instance.Initialize(device, this, timeSharedMemory, (long)(timePa - DramMemoryMap.DramBase), TimeSize);

            AppletState = new AppletStateMgr(this);

            AppletState.SetFocus(true);

            Font = new SharedFontManager(device, (long)(fontPa - DramMemoryMap.DramBase));

            IUserInterface.InitializePort(this);

            VsyncEvent = new KEvent(this);

            ContentManager = contentManager;

            // TODO: use set:sys (and get external clock source id from settings)
            // TODO: use "time!standard_steady_clock_rtc_update_interval_minutes" and implement a worker thread to be accurate.
            UInt128 clockSourceId = new UInt128(Guid.NewGuid().ToByteArray());

            IRtcManager.GetExternalRtcValue(out ulong rtcValue);

            // We assume the rtc is system time.
            TimeSpanType systemTime = TimeSpanType.FromSeconds((long)rtcValue);

            // First init the standard steady clock
            TimeServiceManager.Instance.SetupStandardSteadyClock(null, clockSourceId, systemTime, TimeSpanType.Zero, TimeSpanType.Zero, false);
            TimeServiceManager.Instance.SetupStandardLocalSystemClock(null, new SystemClockContext(), systemTime.ToSeconds());

            if (NxSettings.Settings.TryGetValue("time!standard_network_clock_sufficient_accuracy_minutes", out object standardNetworkClockSufficientAccuracyMinutes))
            {
                TimeSpanType standardNetworkClockSufficientAccuracy = new TimeSpanType((int)standardNetworkClockSufficientAccuracyMinutes * 60000000000);

                TimeServiceManager.Instance.SetupStandardNetworkSystemClock(new SystemClockContext(), standardNetworkClockSufficientAccuracy);
            }

            TimeServiceManager.Instance.SetupStandardUserSystemClock(null, false, SteadyClockTimePoint.GetRandom());

            // FIXME: TimeZone shoud be init here but it's actually done in ContentManager

            TimeServiceManager.Instance.SetupEphemeralNetworkSystemClock();

            DatabaseImpl.Instance.InitializeDatabase(device);

            HostSyncpoint = new NvHostSyncpt(device);

            SurfaceFlinger = new SurfaceFlinger(device);
        }
Beispiel #39
0
 // CONSTRUCTEUR
 /// <summary>
 /// Creates an instance of the BreadthFirst class
 /// </summary>
 /// <param name="a_graph">Object that implements IGraph interface : the graph to resolve</param>
 /// <param name="a_gui">Reference to the application object instance that must implement the IUserInterface</param>
 public BreadthFirst(IGraph a_graph, IUserInterface a_gui) : base(a_graph, a_gui)
 {
 }
Beispiel #40
0
        public SettingsForm(IAppConfig appConfig, IAfvManager audioForVatsim, IEventBroker eventBroker, IFsdManger networkManager, IUserInterface userInterface)
        {
            InitializeComponent();

            mConfig         = appConfig;
            mAfv            = audioForVatsim;
            mNetworkManager = networkManager;
            mUserInterface  = userInterface;
            mEventBroker    = eventBroker;
            mEventBroker.Register(this);

            mDirectInput        = new DirectInput();
            mPttDevicePollTimer = new Timer
            {
                Interval = 50
            };
            mPttDevicePollTimer.Tick += PttDevicePollTimer_Tick;

            cbUpdateChannel.BindEnumToCombobox(UpdateChannel.Stable);
            vhfEqualizer.BindEnumToCombobox(EqualizerPresets.VHFEmulation2);

            if (mConfig.InputVolumeDb > 18)
            {
                mConfig.InputVolumeDb = 18;
            }
            if (mConfig.InputVolumeDb < -18)
            {
                mConfig.InputVolumeDb = -18;
            }

            if (mConfig.Com1Volume > 1)
            {
                mConfig.Com1Volume = 1;
            }
            if (mConfig.Com1Volume < 0)
            {
                mConfig.Com1Volume = 0;
            }

            if (mConfig.Com2Volume > 1)
            {
                mConfig.Com2Volume = 1;
            }
            if (mConfig.Com2Volume < 0)
            {
                mConfig.Com2Volume = 0;
            }

            GetAudioDevices();
            LoadNetworkServers();
        }
Beispiel #41
0
 public Engine(IRenderer renderer, IUserInterface userInterface, int fieldSleepTime)
     : this(renderer, userInterface)
 {
     this.fieldSleepTime = fieldSleepTime;
 }
Beispiel #42
0
 public EngineShootPlayerRacket(IRenderer renderer, IUserInterface userInterface)
     : base(renderer, userInterface)
 {
 }
Beispiel #43
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Runs a model scenario.
        /// </summary>
        public void Run(string scenarioPath, IUserInterface ui)
        {
            this.ui = ui;

            siteVarRegistry.Clear();

            Scenario scenario = LoadScenario(scenarioPath);

            startTime      = scenario.StartTime;
            endTime        = scenario.EndTime;
            timeSinceStart = 0;
            currentTime    = startTime;
            InitializeRandomNumGenerator(scenario.RandomNumberSeed);

            LoadSpecies(scenario.Species);
            LoadEcoregions(scenario.Ecoregions);

            ui.WriteLine("Initializing landscape from ecoregions map \"{0}\" ...", scenario.EcoregionsMap);
            Ecoregions.Map ecoregionsMap = new Ecoregions.Map(scenario.EcoregionsMap,
                                                              ecoregions,
                                                              rasterFactory);
            // -- ProcessMetadata(ecoregionsMap.Metadata, scenario);
            cellLength = scenario.CellLength.Value;
            cellArea   = (float)((cellLength * cellLength) / 10000);
            ui.WriteLine("Cell length = {0} m, cell area = {1} ha", cellLength, cellArea);

            using (IInputGrid <bool> grid = ecoregionsMap.OpenAsInputGrid()) {
                ui.WriteLine("Map dimensions: {0} = {1:#,##0} cell{2}", grid.Dimensions,
                             grid.Count, (grid.Count == 1 ? "" : "s"));
                // landscape = new Landscape(grid);
                landscape = landscapeFactory.CreateLandscape(grid);
            }
            ui.WriteLine("Sites: {0:#,##0} active ({1:p1}), {2:#,##0} inactive ({3:p1})",
                         landscape.ActiveSiteCount, (landscape.Count > 0 ? ((double)landscape.ActiveSiteCount) / landscape.Count : 0),
                         landscape.InactiveSiteCount, (landscape.Count > 0 ? ((double)landscape.InactiveSiteCount) / landscape.Count : 0));

            ecoregionSiteVar = ecoregionsMap.CreateSiteVar(landscape);

            disturbAndOtherExtensions = new List <ExtensionMain>();

            try {
                ui.WriteLine("Loading {0} extension ...", scenario.Succession.Info.Name);
                succession = Loader.Load <SuccessionMain>(scenario.Succession.Info);
                succession.LoadParameters(scenario.Succession.InitFile, this);
                succession.Initialize();

                ExtensionMain[] disturbanceExtensions = LoadExtensions(scenario.Disturbances);
                InitExtensions(disturbanceExtensions);

                ExtensionMain[] otherExtensions = LoadExtensions(scenario.OtherExtensions);
                InitExtensions(otherExtensions);


                //  Perform 2nd phase of initialization for non-succession extensions.
                foreach (ExtensionMain extension in disturbanceExtensions)
                {
                    extension.InitializePhase2();
                }
                foreach (ExtensionMain extension in otherExtensions)
                {
                    extension.InitializePhase2();
                }

                //  Run output extensions for TimeSinceStart = 0 (time step 0)
                foreach (ExtensionMain extension in otherExtensions)
                {
                    if (extension.Type.IsMemberOf("output"))
                    {
                        Run(extension);
                    }
                }

                //******************// for Rob
                //  Main time loop  //
                //******************//

                for (currentTime++, timeSinceStart++;
                     currentTime <= endTime;
                     currentTime++, timeSinceStart++)
                {
                    bool isSuccTimestep = IsExtensionTimestep(succession);

                    List <ExtensionMain> distExtensionsToRun;
                    distExtensionsToRun = GetExtensionsToRun(disturbanceExtensions);
                    bool isDistTimestep = distExtensionsToRun.Count > 0;

                    List <ExtensionMain> otherExtensionsToRun;
                    otherExtensionsToRun = GetExtensionsToRun(otherExtensions);

                    if (!isSuccTimestep && !isDistTimestep &&
                        otherExtensionsToRun.Count == 0)
                    {
                        continue;
                    }

                    ui.WriteLine("Current time: {0}", currentTime);

                    if (isDistTimestep)
                    {
                        if (scenario.DisturbancesRandomOrder)
                        {
                            distExtensionsToRun = shuffle(distExtensionsToRun);
                        }
                        foreach (ExtensionMain distExtension in distExtensionsToRun)
                        {
                            Run(distExtension);
                        }
                    }

                    if (isSuccTimestep || isDistTimestep)
                    {
                        Run(succession);
                    }

                    foreach (ExtensionMain otherExtension in otherExtensionsToRun)
                    {
                        Run(otherExtension);
                    }
                }  // main time loop
            }
            finally {
                foreach (ExtensionMain extension in disturbAndOtherExtensions)
                {
                    extension.CleanUp();
                }
            }
            ui.WriteLine("Model run is complete.");
        }
 public CookController(ITimer timer, IDisplay display, IPowerTube powerTube, IUserInterface ui)
     : this(timer, display, powerTube)
 {
     UI = ui;
 }
Beispiel #45
0
 public Engine(IUserInterface userInterface)
 {
     this.userInterface = userInterface;
 }
Beispiel #46
0
 /// <summary>
 /// Create game instance using the given UI.
 /// </summary>
 /// <param name="ui">UI to use for game.</param>
 public Game(IUserInterface ui)
 {
     _ui = ui;
 }
Beispiel #47
0
 public LinkCommand(IUserInterface ui)
 {
     _ui = ui;
 }
 public LinkedListDeleteSpecificOperator(IUserInterface userInterface, IDataStructure <TDataType> dataStructure) : base(
         userInterface, dataStructure)
 {
 }
 internal UpdateQuantityCommand(IUserInterface userInterface, IInventoryContext context) : base(userInterface)
 {
     _context = context;
 }
 public SetTargetsCommand(ITransactionFactory transactionFactory, IExceptionHandler exceptionHandler, ExecutionContext executionContext, ICommandResultVisualizer commandResultVisualizer, IEntityFactory entityFactory, ITargetParser targetParser, IUserInterface userInterface) : base(transactionFactory, exceptionHandler, executionContext, commandResultVisualizer)
 {
     this.entityFactory = entityFactory;
     this.targetParser  = targetParser;
     this.userInterface = userInterface;
 }
 public LogController(IUserInterface ui, IUserInterface ui2)
 {
     _uis.Add(ui);
     _uis.Add(ui2);
 }
 public ErrorReportingDisabler(IUserInterface ui, ServiceRemover serviceRemover)
 {
     this.ui             = ui;
     this.serviceRemover = serviceRemover;
 }
Beispiel #53
0
 public void InitializeData()
 {
     this.engine        = new Engine(this.userInterface);
     this.executor      = new CommandExecutor(this.engine);
     this.userInterface = new ConsoleUserInterface();
 }
Beispiel #54
0
 public void SetView(IUserInterface userInterface)
 {
     mainMenuView = userInterface;
 }
Beispiel #55
0
        public Horizon(Switch device, ContentManager contentManager)
        {
            KernelContext = new KernelContext(device, device.Memory);

            Device = device;

            State = new SystemStateMgr();

            // Note: This is not really correct, but with HLE of services, the only memory
            // region used that is used is Application, so we can use the other ones for anything.
            KMemoryRegionManager region = KernelContext.MemoryRegions[(int)MemoryRegion.NvServices];

            ulong hidPa  = region.Address;
            ulong fontPa = region.Address + HidSize;
            ulong iirsPa = region.Address + HidSize + FontSize;
            ulong timePa = region.Address + HidSize + FontSize + IirsSize;

            HidBaseAddress = hidPa - DramMemoryMap.DramBase;

            KPageList hidPageList  = new KPageList();
            KPageList fontPageList = new KPageList();
            KPageList iirsPageList = new KPageList();
            KPageList timePageList = new KPageList();

            hidPageList.AddRange(hidPa, HidSize / KMemoryManager.PageSize);
            fontPageList.AddRange(fontPa, FontSize / KMemoryManager.PageSize);
            iirsPageList.AddRange(iirsPa, IirsSize / KMemoryManager.PageSize);
            timePageList.AddRange(timePa, TimeSize / KMemoryManager.PageSize);

            HidSharedMem  = new KSharedMemory(KernelContext, hidPageList, 0, 0, MemoryPermission.Read);
            FontSharedMem = new KSharedMemory(KernelContext, fontPageList, 0, 0, MemoryPermission.Read);
            IirsSharedMem = new KSharedMemory(KernelContext, iirsPageList, 0, 0, MemoryPermission.Read);

            KSharedMemory timeSharedMemory = new KSharedMemory(KernelContext, timePageList, 0, 0, MemoryPermission.Read);

            TimeServiceManager.Instance.Initialize(device, this, timeSharedMemory, timePa - DramMemoryMap.DramBase, TimeSize);

            AppletState = new AppletStateMgr(this);

            AppletState.SetFocus(true);

            Font = new SharedFontManager(device, fontPa - DramMemoryMap.DramBase);

            IUserInterface.InitializePort(this);

            VsyncEvent = new KEvent(KernelContext);

            DisplayResolutionChangeEvent = new KEvent(KernelContext);

            ContentManager = contentManager;

            // TODO: use set:sys (and get external clock source id from settings)
            // TODO: use "time!standard_steady_clock_rtc_update_interval_minutes" and implement a worker thread to be accurate.
            UInt128 clockSourceId = new UInt128(Guid.NewGuid().ToByteArray());

            IRtcManager.GetExternalRtcValue(out ulong rtcValue);

            // We assume the rtc is system time.
            TimeSpanType systemTime = TimeSpanType.FromSeconds((long)rtcValue);

            // Configure and setup internal offset
            TimeSpanType internalOffset = TimeSpanType.FromSeconds(ConfigurationState.Instance.System.SystemTimeOffset);

            TimeSpanType systemTimeOffset = new TimeSpanType(systemTime.NanoSeconds + internalOffset.NanoSeconds);

            if (systemTime.IsDaylightSavingTime() && !systemTimeOffset.IsDaylightSavingTime())
            {
                internalOffset = internalOffset.AddSeconds(3600L);
            }
            else if (!systemTime.IsDaylightSavingTime() && systemTimeOffset.IsDaylightSavingTime())
            {
                internalOffset = internalOffset.AddSeconds(-3600L);
            }

            internalOffset = new TimeSpanType(-internalOffset.NanoSeconds);

            // First init the standard steady clock
            TimeServiceManager.Instance.SetupStandardSteadyClock(null, clockSourceId, systemTime, internalOffset, TimeSpanType.Zero, false);
            TimeServiceManager.Instance.SetupStandardLocalSystemClock(null, new SystemClockContext(), systemTime.ToSeconds());

            if (NxSettings.Settings.TryGetValue("time!standard_network_clock_sufficient_accuracy_minutes", out object standardNetworkClockSufficientAccuracyMinutes))
            {
                TimeSpanType standardNetworkClockSufficientAccuracy = new TimeSpanType((int)standardNetworkClockSufficientAccuracyMinutes * 60000000000);

                // The network system clock needs a valid system clock, as such we setup this system clock using the local system clock.
                TimeServiceManager.Instance.StandardLocalSystemClock.GetClockContext(null, out SystemClockContext localSytemClockContext);
                TimeServiceManager.Instance.SetupStandardNetworkSystemClock(localSytemClockContext, standardNetworkClockSufficientAccuracy);
            }

            TimeServiceManager.Instance.SetupStandardUserSystemClock(null, false, SteadyClockTimePoint.GetRandom());

            // FIXME: TimeZone shoud be init here but it's actually done in ContentManager

            TimeServiceManager.Instance.SetupEphemeralNetworkSystemClock();

            DatabaseImpl.Instance.InitializeDatabase(device);

            HostSyncpoint = new NvHostSyncpt(device);

            SurfaceFlinger = new SurfaceFlinger(device);

            ConfigurationState.Instance.System.EnableDockedMode.Event += OnDockedModeChange;

            InitLibHacHorizon();
            InitializeAudioRenderer();
        }
 public TelemetryDisabler(IUserInterface ui) => this.ui = ui;
 public void AddUi(IUserInterface userInterface)
 {
     _uis.Add(userInterface);
 }
 public void AddLevel2Ui(IUserInterface userInterface)
 {
     _uisLevel2.Add(userInterface);
 }
Beispiel #59
0
 public Engine(IDatabase data, IUserInterface userInterface)
 {
     this.Database      = data;
     this.UserInterface = userInterface;
 }
Beispiel #60
0
 // Constructors
 public Engine(IRenderer renderer, IUserInterface userInterface)
     : this(renderer, userInterface, defaultSleepTime)
 {
 }