Skip to content

Commit

Permalink
Creación de agentes desde el main #14 #12
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierBejMen committed Dec 13, 2017
1 parent f652644 commit 102213a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
11 changes: 5 additions & 6 deletions DBAP3/src/gugelcar/AgenteVehiculo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
public class AgenteVehiculo extends SingleAgent{

private final AgentID aid; //ID de este agente
private final AgentID agente_mapa_id; //ID del agente mapa
private final AgentID controlador_id; //ID del controador del servidor
private AgentID aid; //ID de este agente
private AgentID agente_mapa_id; //ID del agente mapa
private AgentID controlador_id; //ID del controador del servidor
//Puede ser que necesitemos los ID de los demás agentes vehiculos, el martes lo resolvemos


Expand All @@ -36,7 +36,7 @@ public class AgenteVehiculo extends SingleAgent{
private Posicion serverPos; //No tengo claro si tenemos distinción entre internalPos y serverPos, el martes lo resolvemos.

//Comunicacion
private final JSON jsonobj;
private JSON jsonobj;
private ACLMessage outbox = null;
private ACLMessage inbox = null;
/**
Expand All @@ -60,9 +60,8 @@ else if(this.fuelrate == 4)
* @brief Constructor
* @author Javier Bejar Mendez
*/
public AgenteVehiculo(AgentID aid, String cid, AgentID mapaid, AgentID controlid) throws Exception{
public AgenteVehiculo(AgentID aid, AgentID mapaid, AgentID controlid) throws Exception{
super(aid);
this.conversation_id = cid;
this.aid = aid;
this.agente_mapa_id = mapaid;
this.controlador_id = controlid;
Expand Down
52 changes: 39 additions & 13 deletions DBAP3/src/gugelcar/main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,46 @@ public class main {
* @author Emilien Giard
*/
public static void main(String[] args) {
//Poner datos correctos para la conexion!!!!!!!!!
String nombreServidor = "Cerastes";
AgentsConnection.connect("isg2.ugr.es",6000, nombreServidor, "Boyero", "Parra", false);

String controlador_name = "Cerastes";
String agente_mapa_name = "AgenteMapa";
String vehiculo1_name = "vehiculo1";
String vehiculo2_name = "vehiculo2";
String vehiculo3_name = "vehiculo3";
String vehiculo4_name = "vehiculo4";

String mapName = "map1";

AgentID controlador_id, agente_mapa_id, vehiculo1_id, vehiculo2_id, vehiculo3_id, vehiculo4_id;

try {
AgenteMapa mapa = new AgenteMapa(
new AgentID("agenteMapa"),
"map1",
new AgentID(nombreServidor),
new AgentID("vehiculo1"),
new AgentID("vehiculo2"),
new AgentID("vehiculo3"),
new AgentID("vehiculo4")
);
mapa.run();
//Conectarse al servidor
AgentsConnection.connect("isg2.ugr.es",6000, controlador, "Boyero", "Parra", false);

//Creacion de los IDs
controlador_id = new AgentID(controlador_name);
agente_mapa_id = new AgentID(agente_mapa_name);
vehiculo1_id = new AgentID(vehiculo1_name);
vehiculo2_id = new AgentID(vehiculo2_name);
vehiculo3_id = new AgentID(vehiculo3_name);
vehiculo4_id = new AgentID(vehiculo4_name);

//Creacion de los Agentes
AgenteMapa agente_mapa = new AgenteMapa(agente_mapa_id, mapName, controlador_id,
vehiculo1_id, vehiculo2_id, vehiculo3_id, vehiculo4_id);

AgenteVehiculo vehiculo1 = new AgenteVehiculo(vehiculo1_id, agente_mapa_id, controlador_id);
AgenteVehiculo vehiculo2 = new AgenteVehiculo(vehiculo2_id, agente_mapa_id, controlador_id);
AgenteVehiculo vehiculo3 = new AgenteVehiculo(vehiculo3_id, agente_mapa_id, controlador_id);
AgenteVehiculo vehiculo4 = new AgenteVehiculo(vehiculo4_id, agente_mapa_id, controlador_id);

//Ejecución de los Agentes
agente_mapa.run();
vehiculo1.run();
vehiculo2.run();
vehiculo3.run();
vehiculo4.run();

} catch (Exception ex) {
System.out.println("Error: "+ex.getMessage());
}
Expand Down

0 comments on commit 102213a

Please sign in to comment.