Magentix2  2.1.1
es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant Class Reference

List of all members.

Classes

class  BEGIN_Method
class  DO_TASK_Method
class  FINAL_Method
class  RECEIVE_ACCEPT_Method
class  RECEIVE_REJECT_Method
class  RECEIVE_SOLICIT_Method
class  SEND_FAILURE_Method
class  SEND_INFO_Method
class  SEND_NOT_UNDERSTOOD_Method
class  SEND_PROPOSAL_Method
class  SEND_REFUSE_Method
class  TIMEOUT_Method

Public Member Functions

CFactory newFactory (String name, MessageFilter filter, ACLMessage template, int availableConversations, CAgent myAgent, int timeout)

Protected Member Functions

void doBegin (CProcessor myProcessor, ACLMessage msg)
abstract String doReceiveSolicit (CProcessor myProcessor, ACLMessage msg)
abstract void doSendProposal (CProcessor myProcessor, ACLMessage messageToSend)
void doSendRefuse (CProcessor myProcessor, ACLMessage messageToSend)
void doSendNotUnderstood (CProcessor myProcessor, ACLMessage messageToSend)
void doTimeout (CProcessor myProcessor, ACLMessage msg)
void doReceiveAccept (CProcessor myProcessor, ACLMessage msg)
void doReceiveReject (CProcessor myProcessor, ACLMessage msg)
abstract String doTask (CProcessor myProcessor, ACLMessage solicitMessage)
void doSendFailure (CProcessor myProcessor, ACLMessage messageToSend)
abstract void doSendInfo (CProcessor myProcessor, ACLMessage messageToSend)
void doFinal (CProcessor myProcessor, ACLMessage messageToSend)

Detailed Description

Template for CFactories that manage fipa contract net participant conversation. The user has to create his/her own class extending from this one. And implement the abstract methods. Other methods can be overriden in order to modify the default behaviour

Author:
ricard
Javier Jorge Cano - jjorge@dsic.upv.es

Definition at line 30 of file FIPA_CONTRACTNET_Participant.java.


Member Function Documentation

Method executed at the beginning of the conversation

Parameters:
myProcessorthe CProcessor managing the conversation
msgfirst message assigned to this conversation

Definition at line 39 of file FIPA_CONTRACTNET_Participant.java.

                                                                       {
                myProcessor.getInternalData().put("InitialMessage", msg);
        }

Method executed when the conversation ends

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendfinal message

Definition at line 270 of file FIPA_CONTRACTNET_Participant.java.

                                                                                 {
                messageToSend = myProcessor.getLastSentMessage();
        }

Method executed when the initiator accepts participant's proposal

Parameters:
myProcessorthe CProcessor managing the conversation
msgaccept message

Definition at line 168 of file FIPA_CONTRACTNET_Participant.java.

                                                                               {
        }

Method executed when the initiator rejects participant's proposal

Parameters:
myProcessorthe CProcessor managing the conversation
msgreject message

Definition at line 186 of file FIPA_CONTRACTNET_Participant.java.

                                                                               {
        }
abstract String es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doReceiveSolicit ( CProcessor  myProcessor,
ACLMessage  msg 
) [protected, pure virtual]

Method executed when the participant receives a call for proposals

Parameters:
myProcessorthe CProcessor managing the conversation
msgcall for proposals message
Returns:
next state of this conversation

Method executed when the task failed

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendfail message

Definition at line 225 of file FIPA_CONTRACTNET_Participant.java.

                                                  {
                ACLMessage aux = (ACLMessage) myProcessor.getInternalData().get(
                                "InitialMessage");
                messageToSend.copyFromAsTemplate(aux);
                messageToSend.setProtocol("fipa-contract-net");
                messageToSend.setPerformative(ACLMessage.FAILURE);
                messageToSend.setReceiver(myProcessor.getLastReceivedMessage()
                                .getSender());
                messageToSend.setSender(myProcessor.getMyAgent().getAid());
        }
abstract void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doSendInfo ( CProcessor  myProcessor,
ACLMessage  messageToSend 
) [protected, pure virtual]

Method executed when the task succeeded

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendinform message

Method executed when the participant sends a not-understood

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendnot-understood message

Definition at line 122 of file FIPA_CONTRACTNET_Participant.java.

                                                  {
                ACLMessage aux = (ACLMessage) myProcessor.getInternalData().get(
                                "InitialMessage");
                messageToSend.copyFromAsTemplate(aux);
                messageToSend.setProtocol("fipa-contract-net");
                messageToSend.setPerformative(ACLMessage.NOT_UNDERSTOOD);
                messageToSend.setReceiver(myProcessor.getLastReceivedMessage()
                                .getSender());
                messageToSend.setSender(myProcessor.getMyAgent().getAid());
        }
abstract void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doSendProposal ( CProcessor  myProcessor,
ACLMessage  messageToSend 
) [protected, pure virtual]

Method executed when the participant sends a proposal

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendproposal message

Method executed when the participant sends a refuse

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendrefuse message

Definition at line 96 of file FIPA_CONTRACTNET_Participant.java.

                                                                                      {
                ACLMessage aux = (ACLMessage) myProcessor.getInternalData().get(
                                "InitialMessage");
                messageToSend.copyFromAsTemplate(aux);
                messageToSend.setProtocol("fipa-contract-net");
                messageToSend.setPerformative(ACLMessage.REFUSE);
                messageToSend.setReceiver(myProcessor.getLastReceivedMessage()
                                .getSender());
                messageToSend.setSender(myProcessor.getMyAgent().getAid());
        }
abstract String es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doTask ( CProcessor  myProcessor,
ACLMessage  solicitMessage 
) [protected, pure virtual]

Perform the proposal's task

Parameters:
myProcessorthe CProcessor managing the conversation
solicitMessagethe first message assigned to this conversation containing the solicit of the initiator agent
Returns:
next conversation state

Method executed when the timeout is reached while the initiator was waiting for proposals

Parameters:
myProcessorthe CProcessor managing the conversation
msgtimeout message

Definition at line 150 of file FIPA_CONTRACTNET_Participant.java.

                                                                         {
        }
CFactory es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.newFactory ( String  name,
MessageFilter  filter,
ACLMessage  template,
int  availableConversations,
CAgent  myAgent,
int  timeout 
)

Creates a new contract-net participant CFactory

Parameters:
namefactory's name
filtermessage filter
templatefirst message to send
availableConversationsmaximum number of conversation this CFactory can manage simultaneously
myAgentagent owner of this CFactory
timeoutfor waiting after sending the proposal
Returns:
a new fipa contract net participant factory

Definition at line 298 of file FIPA_CONTRACTNET_Participant.java.

                                     {

                // Create factory

                if (filter == null) {
                        filter = new MessageFilter("performative = CFP"); // falta AND
                                                                                                                                // protocol
                                                                                                                                // =
                                                                                                                                // fipa-contract-net;
                }

                if (template == null) {
                        template = new ACLMessage(ACLMessage.PROPOSE);
                }
                CFactory theFactory = new CFactory(name, filter,
                                availableConversations, myAgent);

                // Processor template setup

                CProcessor processor = theFactory.cProcessorTemplate();

                // BEGIN State

                BeginState BEGIN = (BeginState) processor.getState("BEGIN");
                BEGIN.setMethod(new BEGIN_Method());

                // WAIT_FOR_SOLICIT State
                WaitState WAIT_FOR_SOLICIT = new WaitState("WAIT_FOR_SOLICIT", timeout);
                processor.registerState(WAIT_FOR_SOLICIT);
                processor.addTransition(BEGIN, WAIT_FOR_SOLICIT);

                // RECEIVE_SOLICIT State

                ReceiveState RECEIVE_SOLICIT = new ReceiveState("RECEIVE_SOLICIT");
                RECEIVE_SOLICIT.setMethod(new RECEIVE_SOLICIT_Method());
                filter = new MessageFilter("performative = CFP");
                RECEIVE_SOLICIT.setAcceptFilter(filter);
                processor.registerState(RECEIVE_SOLICIT);
                processor.addTransition(WAIT_FOR_SOLICIT, RECEIVE_SOLICIT);

                // SEND_PROPOSAL State

                SendState SEND_PROPOSAL = new SendState("SEND_PROPOSAL");

                SEND_PROPOSAL.setMethod(new SEND_PROPOSAL_Method());
                template.setProtocol("fipa-contract-net");
                template.setPerformative(ACLMessage.PROPOSE);
                SEND_PROPOSAL.setMessageTemplate(template);
                processor.registerState(SEND_PROPOSAL);
                processor.addTransition(RECEIVE_SOLICIT, SEND_PROPOSAL);

                // SEND_REFUSE State

                SendState SEND_REFUSE = new SendState("SEND_REFUSE");

                SEND_REFUSE.setMethod(new SEND_REFUSE_Method());
                template.setProtocol("fipa-contract-net");
                template.setPerformative(ACLMessage.REFUSE);
                SEND_REFUSE.setMessageTemplate(template);
                processor.registerState(SEND_REFUSE);
                // WAIT_FOR_SOLICIT -> SEND_REFUSE debería ser RECEIVE_SOLICIT ->
                // SEND_REFUSE?
                // processor.addTransition(WAIT_FOR_SOLICIT, SEND_REFUSE);
                processor.addTransition(RECEIVE_SOLICIT, SEND_REFUSE);
                // SEND_NOT_UNDERSTOOD State

                SendState SEND_NOT_UNDERSTOOD = new SendState("SEND_NOT_UNDERSTOOD");

                SEND_NOT_UNDERSTOOD.setMethod(new SEND_NOT_UNDERSTOOD_Method());
                template.setProtocol("fipa-contract-net");
                template.setPerformative(ACLMessage.NOT_UNDERSTOOD);
                SEND_NOT_UNDERSTOOD.setMessageTemplate(template);
                processor.registerState(SEND_NOT_UNDERSTOOD);
                processor.addTransition(WAIT_FOR_SOLICIT, SEND_NOT_UNDERSTOOD);

                // WAIT_FOR_ACCEPT State
                WaitState WAIT_FOR_ACCEPT = new WaitState("WAIT_FOR_ACCEPT", timeout);
                processor.registerState(WAIT_FOR_ACCEPT);
                processor.addTransition(SEND_PROPOSAL, WAIT_FOR_ACCEPT);

                // TIMEOUT State

                ReceiveState TIMEOUT = new ReceiveState("TIMEOUT");
                TIMEOUT.setMethod(new TIMEOUT_Method());
                filter = new MessageFilter(
                                "performative = INFORM AND purpose = waitMessage");
                TIMEOUT.setAcceptFilter(filter);
                processor.registerState(TIMEOUT);
                processor.addTransition(WAIT_FOR_ACCEPT, TIMEOUT);
                // AGREGAR?
                //processor.addTransition(WAIT_FOR_SOLICIT, TIMEOUT);

                // RECEIVE_ACCEPT State

                ReceiveState RECEIVE_ACCEPT = new ReceiveState("RECEIVE_ACCEPT");
                RECEIVE_ACCEPT.setMethod(new RECEIVE_ACCEPT_Method());
                filter = new MessageFilter("performative = ACCEPT-PROPOSAL");
                RECEIVE_ACCEPT.setAcceptFilter(filter);
                processor.registerState(RECEIVE_ACCEPT);
                processor.addTransition(WAIT_FOR_ACCEPT, RECEIVE_ACCEPT);

                // RECEIVE_REJECT State

                ReceiveState RECEIVE_REJECT = new ReceiveState("RECEIVE_REJECT");
                RECEIVE_REJECT.setMethod(new RECEIVE_REJECT_Method());
                filter = new MessageFilter("performative = REJECT-PROPOSAL");
                RECEIVE_REJECT.setAcceptFilter(filter);
                processor.registerState(RECEIVE_REJECT);
                processor.addTransition(WAIT_FOR_ACCEPT, RECEIVE_REJECT);

                // DO_TASK State

                ActionState DO_TASK = new ActionState("DO_TASK");
                DO_TASK.setMethod(new DO_TASK_Method());
                processor.registerState(DO_TASK);
                processor.addTransition(RECEIVE_ACCEPT, DO_TASK);

                // SEND_INFO State

                SendState SEND_INFO = new SendState("SEND_INFORM");

                SEND_INFO.setMethod(new SEND_INFO_Method());
                template.setProtocol("fipa-contract-net");
                template.setPerformative(ACLMessage.INFORM);
                SEND_INFO.setMessageTemplate(template);
                processor.registerState(SEND_INFO);
                processor.addTransition(DO_TASK, SEND_INFO);

                // SEND_INFO State

                SendState SEND_FAILURE = new SendState("SEND_FAILURE");

                SEND_FAILURE.setMethod(new SEND_FAILURE_Method());
                template.setProtocol("fipa-contract-net");
                template.setPerformative(ACLMessage.FAILURE);
                SEND_FAILURE.setMessageTemplate(template);
                processor.registerState(SEND_FAILURE);
                processor.addTransition(DO_TASK, SEND_FAILURE);

                // FINAL State

                FinalState FINAL = new FinalState("FINAL");

                FINAL.setMethod(new FINAL_Method());

                processor.registerState(FINAL);
                processor.addTransition(SEND_FAILURE, FINAL);
                // Added by Javier
                processor.addTransition(SEND_REFUSE, FINAL);
                processor.addTransition(SEND_INFO, FINAL);
                processor.addTransition(RECEIVE_REJECT, FINAL);
                processor.addTransition(SEND_NOT_UNDERSTOOD, FINAL);
                processor.addTransition(TIMEOUT, FINAL);

                return theFactory;
        }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables