A Simple Discrete-Event Simulation: Part 20

After defining things more clearly yesterday I offer this version of an arrivals component. Here’s how it’s supposed to work.

The component is created using an external call.

The graphic properties are initialized using a separate call to this.basicDefine. Most of the graphic characteristics are fixed; only the location and colors can be changed. Once we’re done debugging this capability would no longer be needed, but for now it demonstrates something of the separation between the model and what is displayed. The method to draw the component is this.basicDisplay, and it should be called whenever the status is updated.

this.blockIncrement is called using the discrete-event mechanism to generate the entities for that time span.

this.entityStatus is called when the generated entities wake up for the first time. The entities have to be able to refer back to the generator that created them in order to display the activation status in this way.

this.destroy is probably not needed, but is included for completeness and because good housekeeping is usually desirable.

this.activate is the standard discrete-event activity mechanism for timed activities.

All values needed to display the component’s status are declared as properties.

All of the initialization, display, and activity code is folded directly into the element’s object definition.

It has not been debugged and run yet so there are doubtless some errors and omissions. Remember that any updates to the display involve clearing the screen and cycling through all of the objects to get them to draw themselves. This being the case the call to draw things should not be evoked as shown here. Rather, a global redraw flag should be set which initiates that process if appropriate when events are pulled from the future events queue or current events queue.

This entry was posted in Simulation and tagged , . Bookmark the permalink.

Leave a Reply