You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

package IndoorNavigationWaypointTracing.MultiAgentSystem;
import IndoorNavigationWaypointTracing.Launch;
import agentBehaviourPrototype.ExecutionBehaviour;
import agentBehaviourPrototype.ReceiveDataFromAgentBehaviour;
import agentBehaviourPrototype.SendDataToAgentBehaviour;
import agentEntityPrototype.RobotAgent;
import edu.wpi.rail.jrosbridge.services.ServiceRequest;
import edu.wpi.rail.jrosbridge.services.std.Empty.Request;
import jade.core.AID;
public class PlanDispatchAgent extends RobotAgent
{
Request parseRequest = new Request();
//Request dispatchRequest = new Request();
ServiceRequest dispatchRequest = new ServiceRequest();
private AID PlannerAgent = new AID("PlannerAgent", false);
private AID MoveAgent = new AID("MoveAgent", false);
protected void setup() {
this.controller.addService(Launch.parseServiceName, Launch.parseServiceType);
this.controller.addService(Launch.dispatchServiceName, Launch.dispatchServiceType);
this.controller.getService(Launch.parseServiceName).callServiceAndWait(parseRequest);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
this.controller.getService(Launch.dispatchServiceName).callServiceAndWait(dispatchRequest);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//agent communication
this.behList.addElement(new SendDataToAgentBehaviour(this, controller, MoveAgent, Launch.actionDispatchDataKey));
this.behList.addElement(new SendDataToAgentBehaviour(this, controller, PlannerAgent, Launch.planFeedbackDataKey));
this.behList.addElement(new ReceiveDataFromAgentBehaviour(this, controller, PlannerAgent, Launch.planDispatchDataKey));
this.behList.addElement(new ReceiveDataFromAgentBehaviour(this, controller, MoveAgent, Launch.actionFeedbackDataKey));
addBehaviour(tbf.wrap(new ExecutionBehaviour(this, ds, this.behList)));
}
}