Package it.unito.di.artifact

Examples of it.unito.di.artifact.RoleMessage


  // ROLES OPERATIONS
 
  @OPERATION
  public void cfp(Task task, RoleId initiator) {
   
     RoleMessage cfp = new RoleMessage();
     RoleId dest = new RoleId(PARTICIPANT_ROLE, RoleId.GENERIC_ROLE);
    cfp.setContents(task);
    cfp.setRoleSender(initiator);
    cfp.setRoleReceiver(dest);
    cfp.setPerformative(ACLMessage.CFP);
    send(cfp);
    initiatorId = initiator;
    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) {
   
    RoleMessage accept = new RoleMessage();
     RoleId dest = proposal.getRoleId();
     accept.setRoleSender(initiator);
     accept.setRoleReceiver(dest);
     accept.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
    send(accept);
   
    try {
      assertFact(new Fact("accept"));
      //**** DEBUG: CAMBIO STATO DI VITA A COMMITMENT GIUSTO, SARA' IL SOCIAL STATE CHE DOVRA' GESTIRLO
View Full Code Here

  }
 
  @OPERATION
  public void reject(Proposal proposal, RoleId initiator) {
   
    RoleMessage reject = new RoleMessage();
     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

    if (!acceptingProposals) {
      logger.debug("No more proposals allowed.");
      return;
    }
    prop.setRoleId(participant);
    RoleMessage proposal = new RoleMessage();
     proposal.setContents(prop);
     proposal.setRoleSender(participant);
     proposal.setRoleReceiver(initiator);
     proposal.setPerformative(ACLMessage.PROPOSE);
    send(proposal);
   
    try {
      assertFact(new Fact("propose", participant, prop));
      createCommitment(new Commitment(participant, initiator, new Fact("accept"), new CompositeExpression(
View Full Code Here

  }
 
 
  @OPERATION
  public void refuse(RoleId participant, RoleId initiator) {
    RoleMessage refusal = new RoleMessage();
    refusal.setRoleSender(participant);
    refusal.setRoleReceiver(initiator);
    refusal.setPerformative(ACLMessage.REFUSE);
    send(refusal);
   
    try {
      releaseCommitment(new Commitment(initiator, participant, "propose", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
View Full Code Here

    }
  }
 
  @OPERATION
  public void done(Task task, RoleId participant, RoleId initiator) {
    RoleMessage done = new RoleMessage();
     done.setContents(task);
     done.setRoleSender(participant);
     done.setRoleReceiver(initiator);
     done.setPerformative(ACLMessage.INFORM);
    send(done);
   
    try {
      ArrayList<Commitment> arrComm = new ArrayList<Commitment>();
      for (Commitment com : interactionState.retrieveCommitmentsByDebtorRoleId(participant)) {
View Full Code Here

    }
  }
 
  @OPERATION
  public void failure(RoleId participant, RoleId initiator) {
    RoleMessage failure = new RoleMessage();
    failure.setRoleSender(participant);
    failure.setRoleReceiver(initiator);
    failure.setPerformative(ACLMessage.FAILURE);
    send(failure);
    try {
      ArrayList<Commitment> arrComm = new ArrayList<Commitment>();
      for (Commitment com : interactionState.retrieveCommitmentsByDebtorRoleId(participant)) {
        if (com.getConsequent().equals(new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure")))) {
View Full Code Here

  // ROLES OPERATIONS
 
  @OPERATION
  public void cfp(Task task, RoleId initiator) {
   
     RoleMessage cfp = new RoleMessage();
     RoleId dest = new RoleId(PARTICIPANT_ROLE, RoleId.GENERIC_ROLE);
    cfp.setContents(task);
    cfp.setRoleSender(initiator);
    cfp.setRoleReceiver(dest);
    cfp.setPerformative(ACLMessage.CFP);
    send(cfp);
    initiatorId = initiator;
    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

    public void handleEvent(SocialEvent e, Object... args) {
      logger.debug("Updating for Participant");
      if (e.getElementChanged().getElType() == SocialStateElementType.LOGICAL_EXPRESSION
          && e.getElementChanged().toString().contains("cfp")) {
        logger.debug("CFP event perceived.");
        RoleMessage cfp = participant.receive(ACLMessage.CFP);
        t = (Task) (cfp.getContents());
        logger.debug("Task message received");
        // analisi del task e preparazione della proposal in base a
        // qualche criterio
        p = createProposal(t);
        participant.propose(p, cfp.getRoleSender());
      }

      else if (e.getElementChanged().getElType() == SocialStateElementType.LOGICAL_EXPRESSION
          && e.getElementChanged().toString().contains("accept")) {
        RoleMessage accept = participant
            .receive(ACLMessage.ACCEPT_PROPOSAL);
        // eventuali valutazioni
        if (elaborateTask(t))
          participant.done(t, accept.getRoleSender());
        else
          participant.failure(accept.getRoleSender());
      }

      else if (e.getElementChanged().getElType() == SocialStateElementType.LOGICAL_EXPRESSION
          && e.getElementChanged().toString().contains("reject")) {
        RoleMessage reject = participant
            .receive(ACLMessage.REJECT_PROPOSAL);
        logger.debug("Proposal Rejected.");
      }
      logger.debug("Updating done for Participant");
    }
View Full Code Here

  }
 
  @OPERATION
  public void accept(Proposal proposal, RoleId initiator) {
   
    RoleMessage accept = new RoleMessage();
     RoleId dest = proposal.getRoleId();
     accept.setRoleSender(initiator);
     accept.setRoleReceiver(dest);
     accept.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
    send(accept);
   
    try {
      assertFact(new Fact("accept"));
      //**** DEBUG: CAMBIO STATO DI VITA A COMMITMENT GIUSTO, SARA' IL SOCIAL STATE CHE DOVRA' GESTIRLO
View Full Code Here

TOP

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

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.