The Exit component is always available to accept any entities sent to it. It doesn’t have to store any entities but only has to keep track of when they “arrive,” which means they are leaving the model. The Exit component does calculate and report the residence time of the entity in the entire system, however.
I added reporting of residence time in the Queue component, which can vary, and the Process component, which is currently always a fixed value. I also modified the order of operations just a hair so the reporting operations go in the order that makes the most sense.
(Click on the “Step” button to advance through the model, refresh the page to run it again.)
Here’s the code for the Exit component.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
function ExitComponent(displayDelay) { setOfEntities.push(this); this.componentID = getNewID(); this.componentName = "Exit"; this.exitTime = ""; this.currentExitEntityID = ""; this.exitResidenceTime = ""; this.endExitDisplayTime = 0; this.activity = ""; this.displayDelay = displayDelay; this.openStatus = true; this.previousComponent = null; this.dataGroup = new DisplayGroup(this.componentName,175,196,80,"#00FFFF","#FF0000","#FFFF00"); this.dataGroup.addValue(this.componentID,"comp. ID","integer"); this.dataGroup.addValue(this.exitTime,"Exit Time","numdec",5); this.dataGroup.addValue(this.currentExitEntityID,"Exit ID","integer"); this.dataGroup.addValue(this.exitResidenceTime,"Resdnce Tm","numdec",5); this.dataGroup.addValue(this.activity,"Activity","text"); this.assignDisplayValues = function() { this.dataGroup.valueList[0].value = this.componentID; this.dataGroup.valueList[1].value = this.exitTime; this.dataGroup.valueList[2].value = this.currentExitEntityID; this.dataGroup.valueList[3].value = this.exitResidenceTime; this.dataGroup.valueList[4].value = this.activity; }; this.drawData = function() { this.assignDisplayValues(); this.dataGroup.drawBasic(); }; this.clearExitDisplay = function() { if (globalSimClock >= this.endExitDisplayTime) { this.exitTime = ""; this.currentExitEntityID = ""; this.exitResidenceTime = ""; this.activity = ""; } displayProgressText("Exit comp. "+this.componentID+" clears at time "+globalSimClock.toFixed(6)); }; this.assignPreviousComponent = function(previous) { this.previousComponent = previous; }; this.isOpen = function() { return this.openStatus; }; this.pullFromPrevious = function() { this.previousComponent.forwardEntity(); }; this.receiveEntity = function(entity) { //receive the entity this.exitResidenceTime = globalSimClock - entity.getEntryTime(); //display what was done this.exitTime = globalSimClock; this.currentExitEntityID = entity.entityID; this.activity = "entity exits"; //set timer to clear the display after a bit this.endExitDisplayTime = globalSimClock+this.displayDelay; feq.newItem(this.endExitDisplayTime,this,"clearExitDisplay"); displayProgressText("Exit comp. "+this.componentID+" receives entity: "+this.currentExitEntityID+" at time "+globalSimClock.toFixed(6)); }; this.activate = function(nextState) { if (nextState == "clearExitDisplay") { this.clearExitDisplay(); } else { errorUndefinedAdvanceState(this.entityID,this.nextState); } }; //this.activate } //ExitComponent |
Now we have a working representation of the basic components of the kind of systems I’ve often worked with. There are a ton of things that could be done going forward, so we’ll work them in each day going forward.