Magentix2  2.1.1
es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant Class Reference
Collaboration diagram for es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant:

List of all members.

Classes

class  AGREE_Method
class  BEGIN_Method
class  FAILURE_NO_MATCH_Method
class  FAILURE_PROXY_Method
class  FINAL_RECRUITING_PARTICIPANT_Method
class  INFORM_Method
class  LOCATE_AGENTS_Method
class  RECEIVE_PROXY_Method
class  REFUSE_Method
class  START_SUB_PROTOCOL_Method

Public Member Functions

 Jason_Fipa_Recruiting_Participant (TransitionSystem ts)
ConvCFactory newFactory (String name, MessageFilter filter, ACLMessage template, int availableConversations, ConvJasonAgent myAgent)

Protected Member Functions

void doBegin (CProcessor myProcessor, ACLMessage msg)
String doReceiveProxy (ConvCProcessor myProcessor, ACLMessage msg)
void doRefuse (ConvCProcessor myProcessor, ACLMessage messageToSend)
void doAgree (ConvCProcessor myProcessor, ACLMessage messageToSend)
ArrayList< AgentIDdoLocateAgents (ConvCProcessor myProcessor, ACLMessage proxyMessage)
void doFailureNoMatch (ConvCProcessor myProcessor, ACLMessage messageToSend)
boolean resultOfSubProtocol (CProcessor myProcessor, ACLMessage subProtocolMessageResult)
void doFailureProxy (ConvCProcessor myProcessor, ACLMessage messageToSend)
void doInform (ConvCProcessor myProcessor, ACLMessage messageToSend)
void doFinalRecruitingParticipant (ConvCProcessor myProcessor, ACLMessage messageToSend)

Protected Attributes

TransitionSystem Ts

Detailed Description

This class represents a template for a Fipa Recruiting Protocol from the participant perspective for being used in the Conversations Factory from Jason agents.

Author:
Bexy Alfonso Espinosa

Definition at line 38 of file Jason_Fipa_Recruiting_Participant.java.


Constructor & Destructor Documentation


Member Function Documentation

Sets the agree message to a proxy action

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendagree message

Definition at line 132 of file Jason_Fipa_Recruiting_Participant.java.

                                                                                           {
                        FRCConversation conv =  (FRCConversation) myProcessor.getConversation();
                        messageToSend.setReceiver(conv.initiator);
                }

Method executed at the beginning of the conversation

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

Definition at line 52 of file Jason_Fipa_Recruiting_Participant.java.

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

Method to execute when there is no agents to recruit

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendno match message

Definition at line 191 of file Jason_Fipa_Recruiting_Participant.java.

                                                                                                    {
                        FRCConversation conv =  (FRCConversation) myProcessor.getConversation();
                        conv.FinalResult="FAILURE NOT MATCH";
                        messageToSend.setReceiver(conv.initiator);
                }

Sets the failure message

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendfailure message

Definition at line 243 of file Jason_Fipa_Recruiting_Participant.java.

                                                                                                  {
                        FRCConversation conv =  (FRCConversation) myProcessor.getConversation();
                        conv.FinalResult="FAILURE PROXY";
                        messageToSend.setReceiver(conv.initiator);
                }

End of the conversation

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendfinal message

Definition at line 294 of file Jason_Fipa_Recruiting_Participant.java.

                                                                                                                  {
                        FRCConversation conv = (FRCConversation)myProcessor.getConversation();
                        messageToSend = myProcessor.getLastSentMessage();
                        List<Literal> allperc = new ArrayList<Literal>();
                        String percept = "conversationended("+myProcessor.getMyAgent().getName()+","+"\""+conv.FinalResult+"\""+","+conv.jasonConvID+")[source(self)]";
                        allperc.add(Literal.parseLiteral(percept));
                        ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allperc);
                        
                        myProcessor.getMyAgent().removeFactory(conv.factoryName);

                }

Sets the inform message

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendinform message

Definition at line 265 of file Jason_Fipa_Recruiting_Participant.java.

                                                                                            {
                        FRCConversation conv = (FRCConversation)myProcessor.getConversation();
                        List<Literal> allperc = new ArrayList<Literal>();
                        String percept = "infotosend("+myProcessor.getMyAgent().getName()+","+conv.jasonConvID+")[source(self)]";
                        allperc.add(Literal.parseLiteral(percept));
                        ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allperc);
                        
                        conv.aquire_semaphore();
                        
                        messageToSend.setContent(conv.InfoToSend);
                        messageToSend.setReceiver(conv.initiator);
                        conv.FinalResult="INFORM";
                }

Locate agents to recruit

Parameters:
myProcessorthe CProcessor managing the conversation
proxyMessageproxy message sent by the initiator
Returns:
next conversation state

Definition at line 155 of file Jason_Fipa_Recruiting_Participant.java.

                                                         {
                        FRCConversation conv =  (FRCConversation) myProcessor.getConversation();
                        List<Literal> allperc = new ArrayList<Literal>();
                        String percept = "timetolocateagents("+myProcessor.getMyAgent().getName()+","+ conv.Condition+","+conv.jasonConvID+")[source(self)]";
                        allperc.add(Literal.parseLiteral(percept));
                        ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allperc);

                        conv.aquire_semaphore();

                        int i = 0; ArrayList<AgentID> result = new ArrayList<AgentID>();
                        while (i<conv.TargetAgentsMaxNumber&&i<conv.TargetAgents.size()){
                                result.add(conv.TargetAgents.get(i));
                                i++;
                        }
                        return result;
                }

Method executed when the participant receive a message to proxy

Parameters:
myProcessorthe CProcessor managing the conversation
msgproxy message
Returns:
next conversation state

Definition at line 69 of file Jason_Fipa_Recruiting_Participant.java.

                                                                                            {
                        Conversation conv =  myProcessor.getConversation();
                        String factName = conv.factoryName;
                        FRCConversation newConv = new FRCConversation(conv.jasonConvID, conv.internalConvID, "" ,0,
                                        myProcessor.getMyAgent().getAid(),conv.initiator,factName);
                        ((ConvCFactory)myProcessor.getMyFactory()).UpdateConv(newConv, myProcessor);
                        StringTokenizer msgContent = new StringTokenizer(msg.getContent(),",");
                        String tmp =  msgContent.nextToken();
                        LiteralImpl tmpcond = new LiteralImpl(LiteralImpl.parseLiteral(tmp));
                        newConv.Condition = tmpcond;
                        newConv.TargetAgentsMaxNumber = Integer.parseInt(msgContent.nextToken());
                        newConv.timeOut = Integer.parseInt(msgContent.nextToken());
                        newConv.jasonConvID = msgContent.nextToken();
                        newConv.initiator = new AgentID(msg.getSender().name);
                        List<Literal> allperc = new ArrayList<Literal>();
                        String percept = "receiveproxy("+msg.getSender().name+","+tmpcond.toString()+","+(newConv.timeOut)+","+newConv.jasonConvID+")[source(self)]";
                        allperc.add(Literal.parseLiteral(percept));
                        ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allperc);
                        
                        newConv.aquire_semaphore();

                        String result;
                        if (newConv.ProxyAcceptance) {result = ACLMessage.getPerformative(ACLMessage.AGREE);}
                        else result = ACLMessage.getPerformative(ACLMessage.REFUSE);
                        return result;
                }

Sets the refuse message to a proxy action

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendrefuse message

Definition at line 109 of file Jason_Fipa_Recruiting_Participant.java.

                                                         {
                        FRCConversation conv =  (FRCConversation) myProcessor.getConversation();
                        conv.FinalResult="REFUSE";
                        messageToSend.setReceiver(conv.initiator);
                }

Creates a new participant fipa recruiting 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
Returns:
a new fipa recruiting participant factory

Definition at line 321 of file Jason_Fipa_Recruiting_Participant.java.

                                                                            {
                
                // Create factory
                long timeout = 0;
                if (filter == null) {
                        filter = new MessageFilter("protocol = fipa-recruiting");
                }
                ConvCFactory theFactory = new ConvCFactory(name, filter,
                                availableConversations, myAgent);
                
                // Processor template setup

                ConvCProcessor processor = theFactory.cProcessorTemplate();
                
                // BEGIN State

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

                WaitState WAIT_FOR_PROXY_MESSAGE = new WaitState("WAIT_FOR_PROXY_MESSAGE", timeout);
                processor.registerState(WAIT_FOR_PROXY_MESSAGE);
                processor.addTransition(BEGIN, WAIT_FOR_PROXY_MESSAGE);
                
                // RECEIVE_PROXY State
                
                ReceiveState RECEIVE_PROXY = new ReceiveState("RECEIVE_PROXY");
                RECEIVE_PROXY.setMethod(new RECEIVE_PROXY_Method());
                filter = new MessageFilter("protocol = fipa-recruiting");
                RECEIVE_PROXY.setAcceptFilter(filter);
                processor.registerState(RECEIVE_PROXY);
                processor.addTransition(WAIT_FOR_PROXY_MESSAGE, RECEIVE_PROXY);
                
                // REFUSE State

                SendState REFUSE = new SendState("REFUSE");
                REFUSE.setMethod(new REFUSE_Method());
                template = new ACLMessage(ACLMessage.REFUSE);
                REFUSE.setMessageTemplate(template);
                processor.registerState(REFUSE);
                processor.addTransition(RECEIVE_PROXY, REFUSE);
                
                // AGREE State

                SendState AGREE = new SendState("AGREE");
                AGREE.setMethod(new AGREE_Method());
                template = new ACLMessage(ACLMessage.AGREE);
                AGREE.setMessageTemplate(template);
                processor.registerState(AGREE);
                processor.addTransition(RECEIVE_PROXY, AGREE);
                
                // LOCATE_AGENTS State
                
                ActionState LOCATE_AGENTS = new ActionState("LOCATE_AGENTS");
                LOCATE_AGENTS.setMethod(new LOCATE_AGENTS_Method());
                processor.registerState(LOCATE_AGENTS);
                processor.addTransition(AGREE, LOCATE_AGENTS);
                
                // FAILURE_NO_MATCH State

                SendState FAILURE_NO_MATCH = new SendState("FAILURE_NO_MATCH");
                FAILURE_NO_MATCH.setMethod(new FAILURE_NO_MATCH_Method());
                template = new ACLMessage(ACLMessage.FAILURE);
                FAILURE_NO_MATCH.setMessageTemplate(template);
                processor.registerState(FAILURE_NO_MATCH);
                processor.addTransition(LOCATE_AGENTS, FAILURE_NO_MATCH);
                
                // START_SUB_PROTOCOL State
                
                ActionState START_SUB_PROTOCOL = new ActionState("START_SUB_PROTOCOL");
                START_SUB_PROTOCOL.setMethod(new START_SUB_PROTOCOL_Method());
                processor.registerState(START_SUB_PROTOCOL);
                processor.addTransition(LOCATE_AGENTS, START_SUB_PROTOCOL);
                
                // INFORM State

                SendState INFORM = new SendState("INFORM");
                INFORM.setMethod(new INFORM_Method());
                template = new ACLMessage(ACLMessage.INFORM);
                INFORM.setMessageTemplate(template);
                processor.registerState(INFORM);
                processor.addTransition(START_SUB_PROTOCOL, INFORM);
                
                // FAILURE_PROXY State

                SendState FAILURE_PROXY = new SendState("FAILURE_PROXY");
                FAILURE_PROXY.setMethod(new FAILURE_PROXY_Method());
                template = new ACLMessage(ACLMessage.FAILURE);
                FAILURE_PROXY.setMessageTemplate(template);
                processor.registerState(FAILURE_PROXY);
                processor.addTransition(START_SUB_PROTOCOL, FAILURE_PROXY);
                
                // FINAL State

                FinalState FINAL_RECRUITING_PARTICIPANT = new FinalState("FINAL_RECRUITING_PARTICIPANT");

                FINAL_RECRUITING_PARTICIPANT.setMethod(new FINAL_RECRUITING_PARTICIPANT_Method());
                processor.registerState(FINAL_RECRUITING_PARTICIPANT);
                
                processor.addTransition(REFUSE, FINAL_RECRUITING_PARTICIPANT);
                processor.addTransition(FAILURE_PROXY, FINAL_RECRUITING_PARTICIPANT);
                processor.addTransition(FAILURE_NO_MATCH, FINAL_RECRUITING_PARTICIPANT);
                processor.addTransition(INFORM, FINAL_RECRUITING_PARTICIPANT);                          
                
                return theFactory;
        }

Returns the result of a proxy action

Parameters:
myProcessorthe CProcessor managing the conversation
subProtocolMessageResultresult of the subprotocol
Returns:
next conversation message

Definition at line 215 of file Jason_Fipa_Recruiting_Participant.java.

                                                                     {
                        // TODO Auto-generated method stub
                        return true;
                }                       

Member Data Documentation


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