Package it.unito.di.test

Source Code of it.unito.di.test.TestCNPProtocolThird

package it.unito.di.test;

import it.unito.di.artifact.examples.cnpFirst.InitiatorAgent;
import it.unito.di.artifact.examples.cnpFirst.ParticipantAgent;
import it.unito.di.logic.exception.MissingOperandException;
import it.unito.di.logic.exception.WrongOperandsNumberException;
import it.unito.di.logic.expression.CompositeExpression;
import it.unito.di.logic.expression.Fact;
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.core.Runtime;
import jade.wrapper.AgentController;
import jade.wrapper.ContainerController;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import cartago.CartagoException;
import cartago.CartagoService;

public class TestCNPProtocolThird {
 
  private static Logger logger = LogManager.getLogger(TestCNPProtocolThird.class);
 
  public static void main(String[] args)  {
    try {
      CartagoService.startNode();
      testAgents();
     
//      testExpressionTree();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
       
  }
 
  private static void testAgents() throws Exception {
   
    final Runtime rt = Runtime.instance();
    Profile p = new ProfileImpl();
    p.setParameter("gui", "false");
    ContainerController cc = rt.createMainContainer(p);
   
    java.lang.Runtime.getRuntime().addShutdownHook(new Thread()
    {
        @Override
        public void run()
        {
            rt.shutDown();
        }
    });
   
    AgentController initiator = cc.createNewAgent("Initiator",
        InitiatorAgent.class.getCanonicalName(), null);
    AgentController participant1 = cc.createNewAgent("Participant-1",
        ParticipantAgent.class.getCanonicalName(), null);
    AgentController participant2 = cc.createNewAgent("Participant-2",
        ParticipantAgent.class.getCanonicalName(), null);
    AgentController participant3 = cc.createNewAgent("Participant-3",
        ParticipantAgent.class.getCanonicalName(), null);
   
   
    participant1.start();
    participant2.start();
    participant3.start();
   
    initiator.start();
  }
 
  private static void testExpressionTree() throws MissingOperandException, WrongOperandsNumberException, CartagoException {
   
    CompositeExpression le1 =
        CompositeExpression.and(new Fact("pippo", new Fact("pippoInside")),
            CompositeExpression.or(new Fact("ripippo"),
              CompositeExpression.not(new Fact("ripippo")))
            );
   
    logger.info(le1.toString());   
    logger.error("pippo");
       
  }
 
 
}
TOP

Related Classes of it.unito.di.test.TestCNPProtocolThird

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.