InsideTheTool - Inside the Simulation Tool It is important...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Inside the Simulation Tool It is important to know how a tool works in order to know how to use the tool. In this context it will give a deeper understanding of the concepts being learned. In the above section some details of the simulation tool was presented. This section presents what is inside of the tool. First the data structures in the simulation object will be presented then the modeling elements. The Event List The schedule_event function schedules events onto the event list. The event list is simply a list of events stored in chronological order. The function creates a new event structure, fills the event structure with the required data then inserts the event into the list using the time of occurrence as the ordering priority. void EventList::schedule_event( int type, int which_one, double time) { struct Event *evt; evt = new struct Event; if (evt == NULL) { cout << "error. Out of memory in Schedule_event\n"; ErrorOccured = TRUE; } else { evt->Type = type; evt->WhichOne = which_one; evt->Time = time; strcpy(evt->Key1,"NULL"); strcpy(evt->Key2,"NULL"); strcpy(evt->Key3,"NULL"); evt->SN = 0; Que.insert_pri(evt,time); } } The get_event function get the next event from the event list. Notice that the function updates the system's clock to the time of the new event. struct Event *EventList::get_event() { struct Event *evt; evt = (Event *)Que.deque_p();
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
if (evt->Time < TNOW) { cout << "error in event list. event's time < TNOW \n"; print_event(evt); ErrorOccured = TRUE; } else TNOW = evt->Time; return evt; } The Resources The resource data structure holds information about the resources that are currently available. It is implemented using an array. Each array component corresponds to a resource. For example array component number 5 stores the number of resource 5 are currently available. The maximum number of each resource and the name of the resource are also stored.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

InsideTheTool - Inside the Simulation Tool It is important...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online