Magentix2  2.1.1
es.upv.dsic.gti_ia.cAgents.protocols.FIPA_REQUEST_Initiator Class Reference
Inheritance diagram for es.upv.dsic.gti_ia.cAgents.protocols.FIPA_REQUEST_Initiator:

List of all members.

Classes

class  AGREE_Method
class  BEGIN_Method
class  FAILURE_Method
class  FINAL_Method
class  INFORM_Method
class  NOT_UNDERSTOOD_Method
class  REFUSE_Method
class  REQUEST_Method
class  SECOND_WAIT_Method

Public Member Functions

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

Protected Member Functions

void doBegin (CProcessor myProcessor, ACLMessage msg)
void doRequest (CProcessor myProcessor, ACLMessage messageToSend)
void doNotUnderstood (CProcessor myProcessor, ACLMessage msg)
void doRefuse (CProcessor myProcessor, ACLMessage msg)
void doAgree (CProcessor myProcessor, ACLMessage msg)
void doSecondWait (CProcessor myProcessor, ACLMessage msg)
void doFailure (CProcessor myProcessor, ACLMessage msg)
abstract void doInform (CProcessor myProcessor, ACLMessage msg)
void doFinal (CProcessor myProcessor, ACLMessage messageToSend)

Detailed Description

Template for CFactories that manage fipa request initiator 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

Definition at line 27 of file FIPA_REQUEST_Initiator.java.


Member Function Documentation

Method to execute when the initiator receives an agree message

Parameters:
myProcessorthe CProcessor managing the conversation
msgagree message

Reimplemented in es.upv.dsic.gti_ia.organization.THOMASProxy.THOMASCAgentRequest.

Definition at line 102 of file FIPA_REQUEST_Initiator.java.

                                                                      {
        }

Method to execute at the beginning of the conversation

Parameters:
myProcessorthe CProcessor managing the conversation
msgfirst message to send

Definition at line 34 of file FIPA_REQUEST_Initiator.java.

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

Method to execute when the initiator receives a failure message

Parameters:
myProcessorthe CProcessor managing the conversation
msgfailure message

Reimplemented in es.upv.dsic.gti_ia.organization.THOMASProxy.THOMASCAgentRequest.

Definition at line 132 of file FIPA_REQUEST_Initiator.java.

                                                                        {
        }
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_REQUEST_Initiator.doFinal ( CProcessor  myProcessor,
ACLMessage  messageToSend 
) [protected]

Method to execute when the initiator ends the conversation

Parameters:
myProcessor
messageToSend

Definition at line 161 of file FIPA_REQUEST_Initiator.java.

                                                                                 {
                messageToSend = myProcessor.getLastSentMessage();
        }
abstract void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_REQUEST_Initiator.doInform ( CProcessor  myProcessor,
ACLMessage  msg 
) [protected, pure virtual]

Method to execute when the initiator receives an inform message

Parameters:
myProcessor
msg

Implemented in es.upv.dsic.gti_ia.organization.THOMASProxy.THOMASCAgentRequest.

Method to execute when the initiator receives a not-understood message

Parameters:
myProcessorthe CProcessor managing the conversation
msgnot-understood message

Reimplemented in es.upv.dsic.gti_ia.organization.THOMASProxy.THOMASCAgentRequest.

Definition at line 72 of file FIPA_REQUEST_Initiator.java.

                                                                              {
        }

Method to execute when the initiator receives a failure message

Parameters:
myProcessorthe CProcessor managing the conversation
msgfailure message

Reimplemented in es.upv.dsic.gti_ia.organization.THOMASProxy.THOMASCAgentRequest.

Definition at line 87 of file FIPA_REQUEST_Initiator.java.

                                                                       {
        }

Sets the request message

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendrequest message

Definition at line 50 of file FIPA_REQUEST_Initiator.java.

                                                  {
                /*ACLMessage aux = (ACLMessage) myProcessor.getInternalData().get(
                                "InitialMessage");
                messageToSend.copyFromAsTemplate(aux);
                messageToSend.setProtocol("fipa-request");
                messageToSend.setPerformative(ACLMessage.REQUEST);
                messageToSend.setSender(myProcessor.getMyAgent().getAid());*/
        }

Method to execute when the timeout is reached

Parameters:
myProcessorthe CProcessor managing the conversation
msgtimeout message

Definition at line 117 of file FIPA_REQUEST_Initiator.java.

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

Creates a new initiator fipa request cfactory

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

Definition at line 181 of file FIPA_REQUEST_Initiator.java.

                                                                                  {

                // Create factory

                if (filter == null) {
                        filter = new MessageFilter("performative = REQUEST"); //falta AND protocol = fipa-request;
                }
                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());

                // REQUEST State

                SendState REQUEST = new SendState("REQUEST_REQUEST_INITIATOR");

                REQUEST.setMethod(new REQUEST_Method());
                //requestMessage = new ACLMessage(ACLMessage.REQUEST);
                //requestMessage.setProtocol("REQUEST");                
                REQUEST.setMessageTemplate(requestMessage);
                processor.registerState(REQUEST);
                processor.addTransition("BEGIN", "REQUEST_REQUEST_INITIATOR");

                // FIRST_WAIT State

                processor.registerState(new WaitState("FIRST_WAIT_REQUEST_INITIATOR", timeout));
                processor.addTransition("REQUEST_REQUEST_INITIATOR", "FIRST_WAIT_REQUEST_INITIATOR");
                
                // NOT_UNDERSTOOD State
                
                ReceiveState NOT_UNDERSTOOD = new ReceiveState("NOT_UNDERSTOOD_REQUEST_INITIATOR");
                NOT_UNDERSTOOD.setMethod(new NOT_UNDERSTOOD_Method());
                filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.NOT_UNDERSTOOD));
                NOT_UNDERSTOOD.setAcceptFilter(filter);
                processor.registerState(NOT_UNDERSTOOD);
                processor.addTransition("FIRST_WAIT_REQUEST_INITIATOR", "NOT_UNDERSTOOD_REQUEST_INITIATOR");
                
                // REFUSE State
                
                ReceiveState REFUSE = new ReceiveState("REFUSE_REQUEST_INITIATOR");
                REFUSE.setMethod(new REFUSE_Method());
                filter = new MessageFilter("performative = REFUSE");
                REFUSE.setAcceptFilter(filter);
                processor.registerState(REFUSE);
                processor.addTransition("FIRST_WAIT_REQUEST_INITIATOR", "REFUSE_REQUEST_INITIATOR");
                
                // AGREE State
                
                ReceiveState AGREE = new ReceiveState("AGREE_REQUEST_INITIATOR");
                AGREE.setMethod(new AGREE_Method());
                filter = new MessageFilter("performative = AGREE");
                AGREE.setAcceptFilter(filter);
                processor.registerState(AGREE);
                processor.addTransition("FIRST_WAIT_REQUEST_INITIATOR", "AGREE_REQUEST_INITIATOR");
                
                // SECOND_WAIT State

                processor.registerState(new WaitState("SECOND_WAIT_REQUEST_INITIATOR", timeout));
                processor.addTransition("AGREE_REQUEST_INITIATOR", "SECOND_WAIT_REQUEST_INITIATOR");
                
                // FAILURE State

                ReceiveState FAILURE = new ReceiveState("FAILURE_REQUEST_INITIATOR");
                FAILURE.setMethod(new FAILURE_Method());
                filter = new MessageFilter("performative = FAILURE");
                FAILURE.setAcceptFilter(filter);
                processor.registerState(FAILURE);
                processor.addTransition("SECOND_WAIT_REQUEST_INITIATOR", "FAILURE_REQUEST_INITIATOR");
                
                // INFORM State

                ReceiveState INFORM = new ReceiveState("INFORM_REQUEST_INITIATOR");
                INFORM.setMethod(new INFORM_Method());
                filter = new MessageFilter("performative = INFORM");
                INFORM.setAcceptFilter(filter);
                processor.registerState(INFORM);
                processor.addTransition("SECOND_WAIT_REQUEST_INITIATOR", "INFORM_REQUEST_INITIATOR");

                // FINAL State

                FinalState FINAL = new FinalState("FINAL_REQUEST_INITIATOR");

                FINAL.setMethod(new FINAL_Method());

                processor.registerState(FINAL);
                processor.addTransition("INFORM_REQUEST_INITIATOR", "FINAL_REQUEST_INITIATOR");
                processor.addTransition("FAILURE_REQUEST_INITIATOR", "FINAL_REQUEST_INITIATOR");
                processor.addTransition("NOT_UNDERSTOOD_REQUEST_INITIATOR", "FINAL_REQUEST_INITIATOR");
                processor.addTransition("REFUSE_REQUEST_INITIATOR", "FINAL_REQUEST_INITIATOR");
                return theFactory;
        }

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