Exemple #1
0
        public Program(
			IInput input,
			IOutput output,
			IMessageBoard messageBoard,
			IDispatcher dispatcher,
			ISimulator simulator)
        {
            this.input = input;
            this.output = output;
            this.dispatcher = dispatcher;
            this.simulator = simulator;

            messageBoard.Receive<QuitCommand>(OnQuit);
        }
Exemple #2
0
        public Simulator(IOutput output, IMessageBoard messageBoard)
        {
            this.output = output;

            messageBoard.Receive<InitCommand>(OnInit);
            messageBoard.Receive<CreateCommand>(OnCreate);
            messageBoard.Receive<DestroyCommand>(OnDestroy);
            messageBoard.Receive<RequestCommand>(OnRequest);
            messageBoard.Receive<ReleaseCommand>(OnRelease);
            messageBoard.Receive<TimeoutCommand>(OnTimeout);
            messageBoard.Receive<RequestIOCommand>(OnRequestIO);
            messageBoard.Receive<CompleteIOCommand>(OnCompleteIO);
            messageBoard.Receive<ShowProcessCommand>(OnShowProcess);
            messageBoard.Receive<ShowResourceCommand>(OnShowResource);
            messageBoard.Receive<DebugCommand>(OnDebug);

            // Create simulation state.
            readyQueue = new Node<Process>[3];
            resources = new Dictionary<string, Resource>();
            processes = new Dictionary<string, Process>();

            // Initialize simulation to default state.
            messageBoard.Send(new InitCommand());
        }