public override void Execute(Calender calender, ResourceManager resourceManager, Statistics statistics, RandomNumberGenerator rGen, EntityFactory entitiyFactory, EventFactory eventFactory) { // Set entities start time at call centre CurrentEntity.StartTime = EventTime; // Total of the two product queues if (resourceManager.IsSpaceInQueues) { // Set active entites call type CurrentEntity.CallType = rGen.GetCallType; // Calculate the next event time int nextEventTime = CurrentEntity.StartTime + rGen.DelayAtSwitch; // Setup next event for active entity switch complete event Event processingCompleteEvent = eventFactory.Spawn(EEventType.SWITCH_COMPLETE, nextEventTime, CurrentEntity); // Add to calender calender.Add(processingCompleteEvent); } else { // Entity hangs up at the switch Global.BusySignalCount++; } // Calculate next arrival time int nextArrivalTime = EventTime + rGen.TimeBetweenArrivals; // Create entity Entity nextEntity = entitiyFactory.CreateEntity(); // Setup next event for entity Event nextEvent = eventFactory.Spawn(EEventType.ARRIVAL, nextArrivalTime, nextEntity); // Add to the calender calender.Add(nextEvent); }
public Simulator(Statistics statistics) { this.statistics = statistics; calender = new Calender(); resourceManager = new ResourceManager(); rGen = new RandomNumberGenerator(); entityFactory = new EntityFactory(); eventFactory = new EventFactory(); // Set global clock //Global.Clock = Global.StartSimulationTime; // Add EndSim Event Event endSimulationEvent = eventFactory.Spawn(EEventType.END_SIMULATION, Global.EndSimulationTime, entityFactory.CreateEntity()); calender.Add(endSimulationEvent); // Create First Arrival Event Entity firstCaller = entityFactory.CreateEntity(); int nextArrivalTime = Global.Clock + rGen.TimeBetweenArrivals; Event firstArrivalEvent = eventFactory.Spawn(EEventType.ARRIVAL, nextArrivalTime, firstCaller); calender.Add(firstArrivalEvent); }
public abstract void Update(Calender calender, ResourceManager resourceMananger, Statistics statistics);
/// <summary> /// Update the information from the main simulation /// </summary> public override void Update(Calender calender, ResourceManager resourceMananger, Statistics statistics) { calenderData = calender.GetEventData(); otherQueueData = resourceMananger.GetQueueEntityData(ECallType.OTHER); carStereoQueueData = resourceMananger.GetQueueEntityData(ECallType.CAR_STEREO); }
/// <summary> /// Update status bar no information from the main simulation is used /// </summary> public override void Update(Calender calender, ResourceManager resourceMananger, Statistics statistics) { if (pBar.InvokeRequired) { // It's on a different thread, so use Invoke. SetCallBack d = new SetCallBack(UpdateProgress); mainForm.Invoke(d); } else { // It's on the same thread, no need for Invoke pBar.Value = Global.Clock; } }
/// <summary> /// Update the information from the main simulation /// </summary> public override void Update(Calender calender, ResourceManager resourceMananger, Statistics statistics) { gDisplay.Update(calender, resourceMananger, statistics); }
public override void Execute(Calender calender, ResourceManager resourceManager, Statistics statistics, RandomNumberGenerator rGen, EntityFactory entitiyFactory, EventFactory eventFactory) { }
// ResourceManager public override void Execute(Calender calender, ResourceManager resourceManager, Statistics statistics, RandomNumberGenerator rGen, EntityFactory entitiyFactory, EventFactory eventFactory) { // Check to see if rep is available Resource resource = resourceManager.NextAvailableResource(CurrentEntity.CallType); // if available rep if (resource != null) { // Resource is now busy resource.IsFree = false; // Entity is assigned a resource CurrentEntity.AssignResource = resource; // Set the time the enitity starts being processed CurrentEntity.StartProcessingTime = Global.Clock; // Compute its process time int nextEventTime = EventTime + rGen.NextEventTime(CurrentEntity.CallType); // Spawn Processing Complete Event Event nextEvent = eventFactory.Spawn(EEventType.PROCESSING_COMPLETE, nextEventTime, CurrentEntity); // Add to calender calender.Add(nextEvent); } else { // Set begin wait time CurrentEntity.BeginWait = EventTime; // Add entity to resource queue resourceManager.AddToQueue(CurrentEntity); } }
public override void Execute(Calender calender, ResourceManager resourceManager, Statistics statistics, RandomNumberGenerator rGen, EntityFactory entitiyFactory, EventFactory eventFactory) { // Set entities time they finish in the system CurrentEntity.EndTime = EventTime; // Update statistics of enitiy leaving system statistics.UpdateEntityStatistics(CurrentEntity); // (active entity Rep) is now free, look at queue Resource resource = CurrentEntity.AssignResource; // if Queue is empty if (resourceManager.IsQueueEmpty(resource.CallType)) { // Set busy flag to false resource.IsFree = true; } else { // Remove entity at head of queue Entity nextEntityInQueue = resourceManager.GetFirstInQueue(resource.CallType); // Set the time the enitity starts being processed nextEntityInQueue.StartProcessingTime = Global.Clock; // Resource is now busy resource.IsFree = false; // Assign the entity a resource nextEntityInQueue.AssignResource = resource; // Compute its process time int nextEventTime = EventTime + rGen.NextEventTime(resource.CallType); // Spawn next event Event nextEvent = eventFactory.Spawn(EEventType.PROCESSING_COMPLETE, nextEventTime, nextEntityInQueue); // Add to calender calender.Add(nextEvent); } }
/// <summary> /// Keeps the calender and resourcemanager lists up to date /// </summary> public void UpdateLists(Calender calender, ResourceManager resourceManager) { this.calender = calender; this.resourceManager = resourceManager; }
/// <summary> /// Keeps the simulation information current for Calender, Other and CarStereo Queue /// </summary> public void Update(Calender calender, ResourceManager resourceMananger, Statistics statistics) { // Clear the lists Arrival.Clear(); SwitchComplete.Clear(); QueueOther.Clear(); QueueCarStereo.Clear(); ResourceOther.Clear(); ResourceCarStereo.Clear(); // Update the lists updateDisplayDataList(resourceMananger.GetQueueEntityData(ECallType.OTHER)); updateDisplayDataList(resourceMananger.GetQueueEntityData(ECallType.CAR_STEREO)); updateDisplayDataList(calender.GetEventData()); }