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); }
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()); }