Great to hear that things are coming along well for you, Oscar.

It sounds to me like remote clients are making changes to values in the interface, and you want them to be reflected in the engine (which is running on the server). Is that right? If the question is just about how to set a value in the simulation engine, the answer is this: call |world.observer.setGlobal(variableName, value)|, where |variableName| is the name of the variable tied to the widget (e.g. |"kick-line"|, |"goal-size"|, |"goal-pos"|, and |"show-level-curves?"| in your example image), and |value| is the new value that was sent from the client.

If you need something more than that, my guess here is that you’ll be needing to mess the UI stuff in a more sophisticated way, in which case you’ll probably want to know more about how the interface works. Put succinctly, the interface uses Ractive <http://www.ractivejs.org/> to perform databinding between variables in the simulation engine and the widgets in the interface.

More specifically, there are several files in our code that use Ractive, but the one that I think holds most/all of what you’re looking for is this one <https://github.com/NetLogo/Galapagos/blob/master/app/assets/javascripts/TortoiseJS/agent/widgets.coffee>, which contains most of the Ractive configuration, and many of the templates for the HTML elements. For example, this chunk of code <https://github.com/NetLogo/Galapagos/blob/master/app/assets/javascripts/TortoiseJS/agent/widgets.coffee#L86-L118> reads values from the engine and performs some validation on them before they’re displayed in the browser elements. Here <https://github.com/NetLogo/Galapagos/blob/master/app/assets/javascripts/TortoiseJS/agent/widgets.coffee#L131-L172>‘s where each type of widget gets some internal variables set. From this line <https://github.com/NetLogo/Galapagos/blob/master/app/assets/javascripts/TortoiseJS/agent/widgets.coffee#L193> down is the code that contains the HTML/Ractive templates for creating each of the UI elements. Also possibly of interest to you would also be the other Ractive files for the Info tab <https://github.com/NetLogo/Galapagos/blob/master/app/assets/javascripts/TortoiseJS/agent/info.coffee>, the Code tab <https://github.com/NetLogo/Galapagos/blob/master/app/assets/javascripts/TortoiseJS/agent/editor.coffee>, Output widgets <https://github.com/NetLogo/Galapagos/blob/master/app/assets/javascripts/TortoiseJS/agent/output.coffee>, and the Command Center <https://github.com/NetLogo/Galapagos/blob/master/app/assets/javascripts/TortoiseJS/agent/console.coffee>.

Hopefully this all makes it clear to you what you’ll need to change to fix the problem. Of course, if you need any more info about our code, be sure to let us know.

On 06/07/2015 02:22 AM, Oscar Martinez wrote:

Hi,

Just for context, I'm working on a project where I modify the standalone version of Tortoise, to add some extra code and make it work with NodeJS to have different instances of the simulation, working remotely. Thanks to help of this forum, I'm near of the end.

But, I would like to know how the controls modify the simulations. I did a trick, and the controls' values are updated remotely, but if some control changed remotely, it only changes the value of the input field, but it doesn't affect the simulation.

Note: Attached, what I understand for "controls".

Again, thanks for all.
--
You received this message because you are subscribed to the Google Groups "netlogo-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

​

--
You received this message because you are subscribed to the Google Groups 
"netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to