Quantcast

Display Simulated Time in Parameters

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Display Simulated Time in Parameters

nathan.alexandre
Hello,
I'm working on a function to display the simulation time. So I thought to display the time in the parameters.
I used :
Parameters params = RunEnvironment.getInstance().getParameters();
                          params.setValue("theHour", timeToDisplay);

and to verify :

System.out.println(params.getString("theHour"));

and the good value is displayed.
But in the Repast window, it seems that I can't the updated value, and the default value is always displayed.

I really appreciate any help you can provide.
--
                                     Nathan AKY M1 Informatique
                                        Université de la Réunion

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Display Simulated Time in Parameters

srcnick
Rather than use the parameters, you can replace the “Tick: “ label in the GUI to show whatever you want. 

1. add the following line to your scenario.xml file in your projects .rs folder.

<model.plugin_jpf file="plugin_jpf.xml" />

2. Create a plugin_jpf.xml file in your projects .rs folder. The contents of that file should be:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE plugin PUBLIC "-//JPF//Java Plug-in Manifest 0.6" "http://jpf.sourceforge.net/plugin_0_6.dtd">
<plugin class="" id="YYYY" version="">

<attributes>
<attribute id="simphony" value="2.0.1" />
</attributes>

<requires>
<import exported="false" match="compatible" optional="false"
plugin-id="repast.simphony.gui" reverse-lookup="false" />
<import exported="false" match="compatible" optional="false" plugin-id="saf.core.ui" reverse-lookup="false"/>
</requires>

<runtime>
  <library id="icons" path="../icons/" type="resources"/>
<library id="bin" path="../bin/" type="code">
<export prefix="*" />
</library>
</runtime>


<extension plugin-id="repast.simphony.gui" point-id="tick.label.formatter" id="my.tick.formatter"> 
           <parameter id="class" value="XXXX"/> 
     </extension> 
</plugin>

Replace the YYYY in the id attribute with some id for your model (e.g. id=“my.model"), and the XXXX in value=“XXXX”, with the fully qualified name of a class that impelements TickCountFormatter. 

3. Implement the tick count formatter class. For example,

package my.package;

import repast.simphony.ui.plugin.TickCountFormatter;

public class MyTickFormatter implements TickCountFormatter {

  @Override
  public String format(double tick) {
    return "Tick / 2: " + tick / 2;
  }

  @Override
  public String getInitialValue() {
    return "Tick / 2 : 0";
  }
}

That will display “Tick / 2 : N” where N is the internal tick divided by 2

Nick




On Mar 13, 2017, at 10:08 AM, [hidden email] wrote:

Hello,
I'm working on a function to display the simulation time. So I thought to display the time in the parameters.
I used :
Parameters params = RunEnvironment.getInstance().getParameters();
                          params.setValue("theHour", timeToDisplay);

and to verify :

System.out.println(params.getString("theHour"));

and the good value is displayed.
But in the Repast window, it seems that I can't the updated value, and the default value is always displayed.

I really appreciate any help you can provide.
--
                                     Nathan AKY M1 Informatique
                                        Université de la Réunion
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...