Quantcast

Cleanup variable after pressing stop button

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

Cleanup variable after pressing stop button

cnietocoria
Hello everyone, 

As in the subject of this email says, I would like to cleanup the variables of the simulation when in the RS interface the user presses stop button. 

The thing is that I need to create a variable List type in the context class. The list contains the of folder's name which I use to load a number of Agents. Anyway, it works really good, add the agents and so on. However, if I decide to stop the simulation change somethings on the parameters and start again, the years List does not been cleaned. So it adds again the folder list, as you can imagine the years. The second time the year list is like [2005, 2006, 2005, 2006] and so on. 

I know that is repast we have the RunEnvironment class  that can controls the simulation. Although I was thinking if I can modify the clickListener on the stop button and add some code to clean the context variables could be better. 

What do you think? If I not wrong, can you suggest me where are the interface classes to modify? 

Or maybe you have a better solution to suggest me, I am open to suggestions. 

Thanks!! Cheers, 

Cesar

--
--------------------------------------------------------------
PhD. Student at University of Camerino
Cesar Augusto Nieto Coria
skype: cnietocoria


------------------------------------------------------------------------------

_______________________________________________
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: Cleanup variable after pressing stop button

Tatara, Eric R.
You can add a RunListener to the Repast Controller:

 RSApplication.getRSApplicationInstance().getController().getScheduleRunner().addRunListener(new MyListener());;
   
An example MyListener class would be for example:

class MyListener implements RunListener {

        @Override
        public void stopped() {
            System.out.println("Stopped");
           
        }

        @Override
        public void paused() {
            System.out.println("Paused");
           
        }

        @Override
        public void started() {
            System.out.println("Started");
           
        }

        @Override
        public void restarted() {
            System.out.println("Restarted");
           
        }
       
    }

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory

From: Cesar Nieto Coria [[hidden email]]
Sent: Thursday, August 04, 2016 7:10 AM
To: [hidden email]
Subject: [Repast-interest] Cleanup variable after pressing stop button

Hello everyone, 

As in the subject of this email says, I would like to cleanup the variables of the simulation when in the RS interface the user presses stop button. 

The thing is that I need to create a variable List type in the context class. The list contains the of folder's name which I use to load a number of Agents. Anyway, it works really good, add the agents and so on. However, if I decide to stop the simulation change somethings on the parameters and start again, the years List does not been cleaned. So it adds again the folder list, as you can imagine the years. The second time the year list is like [2005, 2006, 2005, 2006] and so on. 

I know that is repast we have the RunEnvironment class  that can controls the simulation. Although I was thinking if I can modify the clickListener on the stop button and add some code to clean the context variables could be better. 

What do you think? If I not wrong, can you suggest me where are the interface classes to modify? 

Or maybe you have a better solution to suggest me, I am open to suggestions. 

Thanks!! Cheers, 

Cesar

--
--------------------------------------------------------------
PhD. Student at University of Camerino
Cesar Augusto Nieto Coria
skype: cnietocoria


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...