|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Adding a behavior outside of the setup()Hi,
I read in the documentation that it is possible to use the .addBehavior() method outside of the agent's setup() method. I have a valid agent object, but when I try to add a behavior it just does nothing: no exceptions or errors, but also no result.
If I'm adding the behavior outside of an agent's setup() method, do I have to use another command to "pull the trigger" so to speak and actually make the behavior run?
Not only is behavior being added from outside the setup() method, but it is being added from another class.
So inside my TestBehavior.java file is:
import jade.core.behaviours.OneShotBehaviour;import java.sql.*;public class TestBehavior extends OneShotBehaviour{ public void action(){ System. out.println("Executing the test behavior in thread: " + Thread.currentThread().getId() );} }
And then snippets from the calling java class: private ThreadedBehaviourFactory tbf = new ThreadedBehaviourFactory();TestBehavior testb = new TestBehavior();System. out.println("the agent ID inside BrokerAgentTask: " + agent_obj.getAID().getName() );agent_obj.addBehaviour( tbf.wrap(testb) );
The agent_obj is my own agent class which extends Agent.
Thanks, Matt
_______________________________________________ jade-develop mailing list jade-develop@... https://avalon.cselt.it/mailman/listinfo/jade-develop UNSUBSCRIBE INSTRUCTIONS AT http://jade.tilab.com/community-mailinglist.htm |
|
|
RE: Adding a behavior outside of the setup()Hi, Of course your agent must
be alive. For instance if you do Agent a = new
MyAgentClass(); Behaviour b = new
MyBehaviourClass(); a.addBehaviour(b); Nothing will happen.
Agents must be alive to execute tasks i.e. they must be started by a container. Bye, Giovanni From:
jade-develop-bounces@...
[mailto:jade-develop-bounces@...] On Behalf Of Hutchinson, Matt Hi, I read in the documentation that it is possible to use the
.addBehavior() method outside of the agent's setup() method. I have a valid
agent object, but when I try to add a behavior it just does nothing: no
exceptions or errors, but also no result. If I'm adding the behavior outside of an agent's setup()
method, do I have to use another command to "pull the trigger" so to
speak and actually make the behavior run? Not only is behavior being added from outside the setup()
method, but it is being added from another class. So inside my TestBehavior.java file is: import jade.core.behaviours.OneShotBehaviour; import java.sql.*; public class TestBehavior extends
OneShotBehaviour { public void action() { System.out.println("Executing the test behavior
in thread: " + Thread.currentThread().getId()
); } } And
then snippets from the calling java class: private
ThreadedBehaviourFactory tbf
= new
ThreadedBehaviourFactory(); TestBehavior
testb = new
TestBehavior(); System.out.println("the agent ID inside
BrokerAgentTask: " + agent_obj.getAID().getName() ); agent_obj.addBehaviour(tbf.wrap(testb) ); The
agent_obj is my own agent class which extends Agent. Thanks, Matt _______________________________________________ jade-develop mailing list jade-develop@... https://avalon.cselt.it/mailman/listinfo/jade-develop UNSUBSCRIBE INSTRUCTIONS AT http://jade.tilab.com/community-mailinglist.htm |
| Free Forum Powered by Nabble | Forum Help |