{"id":1071,"date":"2016-10-13T21:27:36","date_gmt":"2016-10-14T02:27:36","guid":{"rendered":"http:\/\/rpchurchill.com\/?p=1071"},"modified":"2016-10-16T23:46:32","modified_gmt":"2016-10-17T04:46:32","slug":"a-simple-discrete-event-simulation-part-25","status":"publish","type":"post","link":"https:\/\/rpchurchill.com\/wordpress\/posts\/2016\/10\/13\/a-simple-discrete-event-simulation-part-25\/","title":{"rendered":"A Simple Discrete-Event Simulation: Part 25"},"content":{"rendered":"<p>The solution is that there is no solution.  The simplest thing to do is to ensure that the values are updated by hand whenever they need to be drawn.  I&#8217;ve included a method called <code>assignDisplayValues<\/code> to the arrivals component.  It should be called just before the <code>drawBasicFunction<\/code>.  This feels wasteful and kludgy, but it seems like the most straightforward thing to do.  Other solutions (like burying values in arrays) impose overheads of their own, so I figure it would be best to just be honest about what&#8217;s happening.  In the long run this will be the most clear solution for the programmer.<\/p>\n<p>I&#8217;m surprised that I hadn&#8217;t really appreciated this aspect of JavaScript until now, but perhaps I shouldn&#8217;t be.  Every tool comes with a large number of features you simply won&#8217;t see until you do that first thing that forces you to.  In the meantime I understand why this limitation is part of the language, but I also understand why people probably find it to be annoying (a word I seem to be using a lot recently&#8230;).<\/p>\n<pre class=\"toolbar-overlay:false wrap:false height-set:true lang:default decode:true \">\r\n      \/\/could also create blank and then use this.dataGroup.define externally so initiation not internal like this\r\n      this.dataGroup = new displayGroup(this.componentName,10,10,100,\"#00FFFF\",\"#FF0000\",\"#FFFF00\");\r\n      this.dataGroup.addValue(this.componentID,\"comp. ID\",\"integer\");\r\n      this.dataGroup.addValue(this.startBlockTime,\"Start Time\",\"numdec\",5);\r\n      this.dataGroup.addValue(this.currentBlockTime,\"CurrentTime\",\"numdec\",5);\r\n      this.dataGroup.addValue(this.endBlockTime,\"End Time\",\"numdec\",5);\r\n      this.dataGroup.addValue(this.entitiesScheduled,\"# Entities\",\"integer\");\r\n      this.dataGroup.addValue(this.entitiesRemaining,\"# Remaining\",\"integer\");\r\n      this.dataGroup.addValue(this.currentEntityID,\"Entity ID\",\"integer\");\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.startBlockTime;\r\n        this.dataGroup.valueList[2].value = this.currentBlockTime;\r\n        this.dataGroup.valueList[3].value = this.endBlockTime;\r\n        this.dataGroup.valueList[4].value = this.entitiesScheduled;\r\n        this.dataGroup.valueList[5].value = this.entitiesRemaining;\r\n        this.dataGroup.valueList[6].value = this.currentEntityID;\r\n        this.dataGroup.valueList[7].value = this.activity;\r\n      };\r\n      ...\r\n      ...\r\n      \/\/set values before drawing\r\n      this.assignDisplayValues();\r\n      clearCanvas(\"#000000\");\r\n      this.dataGroup.drawBasic();\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The solution is that there is no solution. The simplest thing to do is to ensure that the values are updated by hand whenever they need to be drawn. I&#8217;ve included a method called assignDisplayValues to the arrivals component. It &hellip; <a href=\"https:\/\/rpchurchill.com\/wordpress\/posts\/2016\/10\/13\/a-simple-discrete-event-simulation-part-25\/\">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\/1071"}],"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=1071"}],"version-history":[{"count":1,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/posts\/1071\/revisions"}],"predecessor-version":[{"id":1072,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/posts\/1071\/revisions\/1072"}],"wp:attachment":[{"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rpchurchill.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}