Package it.unito.di.artifact

Examples of it.unito.di.artifact.CAMessage


   
   

    @Override
    public void handleProposal(SocialEvent e) {
      CAMessage cfp = initiator.receive(ACLMessage.PROPOSE);
      Proposal prop = (Proposal)(cfp.getContents());
      if (!maximumReached) {         
        proposals.add(prop);
        logger.debug("Added Proposal, proposals size: "+proposals.size());
        if (proposals.size() >= maximumProposals) {
          maximumReached = true;
View Full Code Here


     
    }

    @Override
    public void handleDone(SocialEvent e) {
      CAMessage done = initiator.receive(ACLMessage.INFORM);
      t = (Task)(done.getContents());
      logger.debug("INTERACTION SUCCESSFUL, "+t.getResult());
     
    }
View Full Code Here

     
    }

    @Override
    public void handleFailure(SocialEvent e) {
      CAMessage failure = initiator.receive(ACLMessage.FAILURE);
      logger.debug("Received failure.");
      proposals.clear();
     
    }
View Full Code Here

  // ROLES OPERATIONS
 
  @OPERATION
  public void cfp(Task task, RoleId initiator) {
   
     CAMessage cfp = new CAMessage();
     RoleId dest = new RoleId(PARTICIPANT_ROLE, RoleId.GENERIC_ROLE);
    cfp.setContent(task);
    cfp.setRoleSender(initiator);
    cfp.setRoleReceiver(dest);
    cfp.setPerformative(ACLMessage.CFP);
    send(cfp);
   
    try {
      // createCommitment comporta la new di un commitment. Non ho garanzie se mi baso sui riferimenti al commitment
      // poiche siamo in un ambiente distribuito. Quindi ci vanno meccanismi di matching sullo stato sociale:
View Full Code Here

  }
 
  @OPERATION
  public void accept(Proposal proposal, RoleId initiator) {
   
    CAMessage accept = new CAMessage();
     RoleId dest = proposal.getRoleId();
     accept.setRoleSender(initiator);
     accept.setRoleReceiver(dest);
     accept.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
    send(accept);
   
    try {
      assertFact(new Fact("accept"));
      logger.trace("OPERATION PERFORMED: ACCEPT by "+initiator);
View Full Code Here

  }
 
  @OPERATION
  public void reject(Proposal proposal, RoleId initiator) {
   
    CAMessage reject = new CAMessage();
     RoleId dest = proposal.getRoleId();
     reject.setRoleSender(initiator);
     reject.setRoleReceiver(dest);
     reject.setPerformative(ACLMessage.REJECT_PROPOSAL);
    send(reject);
   
    try {
      releaseCommitment(new Commitment(proposal.getRoleId(), initiator, "accept", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("done"), new Fact("failure"))));
View Full Code Here

 
  @OPERATION
  public void propose(Proposal prop, RoleId participant, RoleId initiator) {
   
    prop.setRoleId(participant);
    CAMessage proposal = new CAMessage();
     proposal.setContent(prop);
     proposal.setRoleSender(participant);
     proposal.setRoleReceiver(initiator);
     proposal.setPerformative(ACLMessage.PROPOSE);
    send(proposal);
   
    try {
      createCommitment(new Commitment(participant, new RoleId(INITIATOR_ROLE, RoleId.GENERIC_ROLE), "accept", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("done"), new Fact("failure"))));
View Full Code Here

//        LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
  }
 
  @OPERATION
  public void done(Task task, RoleId participant, RoleId initiator) {
    CAMessage done = new CAMessage();
     done.setContent(task);
     done.setRoleSender(participant);
     done.setRoleReceiver(initiator);
     done.setPerformative(ACLMessage.INFORM);
    send(done);
   
    try {
      assertFact(new Fact("done", initiator, task));
      logger.trace("OPERATION PERFORMED: DONE by "+participant);
View Full Code Here

    }
  }
 
  @OPERATION
  public void failure(RoleId participant, RoleId initiator) {
    CAMessage failure = new CAMessage();
    failure.setRoleSender(participant);
    failure.setRoleReceiver(initiator);
    failure.setPerformative(ACLMessage.FAILURE);
    send(failure);
    try {
      assertFact(new Fact("failure"));
      logger.trace("OPERATION PERFORMED: FAILURE by "+participant);
    } catch (MissingOperandException e) {
View Full Code Here

    // listener dell'impegno C(i,p, propose, accept \/ reject)
    public void listenerCfp() {
      // qui sto ragionando, posso inserire logica sulla presenza di un commitment
      // do la possibilit� di ragionare sul commitment
      logger.debug("Started listener CFP");
      CAMessage cfp = participant.receive(ACLMessage.CFP);
   
      t = (Task)(cfp.getContents());
     
      // analisi del task e preparazione della proposal in base a qualche criterio
      p = createProposal(t);
      participant.propose(p, cfp.getRoleSender());
    }
View Full Code Here

TOP

Related Classes of it.unito.di.artifact.CAMessage

Copyright © 2018 www.massapicom. 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.