{"id":1090,"date":"2016-10-24T23:22:04","date_gmt":"2016-10-25T04:22:04","guid":{"rendered":"http:\/\/rpchurchill.com\/?p=1090"},"modified":"2017-02-03T14:31:43","modified_gmt":"2017-02-03T19:31:43","slug":"a-simple-discrete-event-simulation-part-30","status":"publish","type":"post","link":"https:\/\/rpchurchill.com\/wordpress\/posts\/2016\/10\/24\/a-simple-discrete-event-simulation-part-30\/","title":{"rendered":"A Simple Discrete-Event Simulation: Part 30"},"content":{"rendered":"<p>The Exit component is always available to accept any entities sent to it.  It doesn&#8217;t have to store any entities but only has to keep track of when they &#8220;arrive,&#8221; 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.<\/p>\n<p>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.<\/p>\n<p>(Click on the &#8220;Step&#8221; button to advance through the model, refresh the page to run it again.)<\/p>\n<p><iframe loading=\"lazy\" width=\"400px\" height=\"750px\" src=\"https:\/\/www.rpchurchill.com\/demo\/des\/discrete-event-sim_20161024.html\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>Here&#8217;s the code for the Exit component.<\/p>\n<pre class=\"toolbar-overlay:false wrap:false height-set:true lang:default decode:true \">\r\n    function ExitComponent(displayDelay) {\r\n      setOfEntities.push(this);\r\n      this.componentID = getNewID();\r\n      this.componentName = \"Exit\";\r\n      this.exitTime = \"\";\r\n      this.currentExitEntityID = \"\";\r\n      this.exitResidenceTime = \"\";\r\n      this.endExitDisplayTime = 0;\r\n      this.activity = \"\";\r\n      this.displayDelay = displayDelay;\r\n      this.openStatus = true;\r\n      this.previousComponent = null;\r\n\r\n      this.dataGroup = new DisplayGroup(this.componentName,175,196,80,\"#00FFFF\",\"#FF0000\",\"#FFFF00\");\r\n      this.dataGroup.addValue(this.componentID,\"comp. ID\",\"integer\");\r\n      this.dataGroup.addValue(this.exitTime,\"Exit Time\",\"numdec\",5);\r\n      this.dataGroup.addValue(this.currentExitEntityID,\"Exit ID\",\"integer\");\r\n      this.dataGroup.addValue(this.exitResidenceTime,\"Resdnce Tm\",\"numdec\",5);\r\n      this.dataGroup.addValue(this.activity,\"Activity\",\"text\");\r\n      \r\n      this.assignDisplayValues = function() {\r\n        this.dataGroup.valueList[0].value = this.componentID;\r\n        this.dataGroup.valueList[1].value = this.exitTime;\r\n        this.dataGroup.valueList[2].value = this.currentExitEntityID;\r\n        this.dataGroup.valueList[3].value = this.exitResidenceTime;\r\n        this.dataGroup.valueList[4].value = this.activity;\r\n      };\r\n      this.drawData = function() {\r\n        this.assignDisplayValues();\r\n        this.dataGroup.drawBasic();\r\n      };\r\n      this.clearExitDisplay = function() {\r\n        if (globalSimClock >= this.endExitDisplayTime) {\r\n          this.exitTime = \"\";\r\n          this.currentExitEntityID = \"\";\r\n          this.exitResidenceTime = \"\";\r\n          this.activity = \"\";\r\n        }\r\n        displayProgressText(\"Exit comp. \"+this.componentID+\" clears at time \"+globalSimClock.toFixed(6));\r\n      };\r\n      this.assignPreviousComponent = function(previous) {\r\n        this.previousComponent = previous;\r\n      };\r\n      this.isOpen = function() {\r\n        return this.openStatus;\r\n      };\r\n      this.pullFromPrevious = function() {\r\n        this.previousComponent.forwardEntity();\r\n      };\r\n      this.receiveEntity = function(entity) {\r\n        \/\/receive the entity\r\n        this.exitResidenceTime = globalSimClock - entity.getEntryTime();\r\n        \/\/display what was done\r\n        this.exitTime = globalSimClock;\r\n        this.currentExitEntityID = entity.entityID;\r\n        this.activity = \"entity exits\";\r\n        \/\/set timer to clear the display after a bit\r\n        this.endExitDisplayTime = globalSimClock+this.displayDelay;\r\n        feq.newItem(this.endExitDisplayTime,this,\"clearExitDisplay\");\r\n        displayProgressText(\"Exit comp. \"+this.componentID+\" receives entity: \"+this.currentExitEntityID+\" at time \"+globalSimClock.toFixed(6));\r\n      };\r\n      this.activate = function(nextState) {\r\n        if (nextState == \"clearExitDisplay\") {\r\n          this.clearExitDisplay();\r\n        } else {\r\n          errorUndefinedAdvanceState(this.entityID,this.nextState);\r\n        }      \r\n      };  \/\/this.activate\r\n    }  \/\/ExitComponent\r\n<\/pre>\n<p>Now we have a working representation of the basic components of the kind of systems I&#8217;ve often worked with.  There are a ton of things that could be done going forward, so we&#8217;ll work them in each day going forward.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Exit component is always available to accept any entities sent to it. It doesn&#8217;t have to store any entities but only has to keep track of when they &#8220;arrive,&#8221; which means they are leaving the model. The Exit component &hellip; <a href=\"https:\/\/rpchurchill.com\/wordpress\/posts\/2016\/10\/24\/a-simple-discrete-event-simulation-part-30\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60],"tags":[121,49],"_links":{"self":[{"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/posts\/1090"}],"collection":[{"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1090"}],"version-history":[{"count":2,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/posts\/1090\/revisions"}],"predecessor-version":[{"id":1432,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/posts\/1090\/revisions\/1432"}],"wp:attachment":[{"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}