Magentix2
2.1.1
|
This class represents a template for a Fipa Recruiting Protocol from the participant perspective for being used in the Conversations Factory from Jason agents.
Definition at line 38 of file Jason_Fipa_Recruiting_Participant.java.
es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.Jason_Fipa_Recruiting_Participant | ( | TransitionSystem | ts | ) |
Definition at line 43 of file Jason_Fipa_Recruiting_Participant.java.
{ Ts = ts; }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doAgree | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Sets the agree message to a proxy action
myProcessor | the CProcessor managing the conversation |
messageToSend | agree message |
Definition at line 132 of file Jason_Fipa_Recruiting_Participant.java.
{ FRCConversation conv = (FRCConversation) myProcessor.getConversation(); messageToSend.setReceiver(conv.initiator); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doBegin | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed at the beginning of the conversation
myProcessor | the CProcessor managing the conversation |
msg | first message assigned to this conversation |
Definition at line 52 of file Jason_Fipa_Recruiting_Participant.java.
{
myProcessor.getInternalData().put("InitialMessage", msg);
}
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doFailureNoMatch | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method to execute when there is no agents to recruit
myProcessor | the CProcessor managing the conversation |
messageToSend | no 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);
}
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doFailureProxy | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Sets the failure message
myProcessor | the CProcessor managing the conversation |
messageToSend | failure 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);
}
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doFinalRecruitingParticipant | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
End of the conversation
myProcessor | the CProcessor managing the conversation |
messageToSend | final 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); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doInform | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Sets the inform message
myProcessor | the CProcessor managing the conversation |
messageToSend | inform 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"; }
ArrayList<AgentID> es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doLocateAgents | ( | ConvCProcessor | myProcessor, |
ACLMessage | proxyMessage | ||
) | [protected] |
Locate agents to recruit
myProcessor | the CProcessor managing the conversation |
proxyMessage | proxy message sent by the initiator |
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; }
String es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doReceiveProxy | ( | ConvCProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the participant receive a message to proxy
myProcessor | the CProcessor managing the conversation |
msg | proxy message |
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; }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.doRefuse | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Sets the refuse message to a proxy action
myProcessor | the CProcessor managing the conversation |
messageToSend | refuse message |
Definition at line 109 of file Jason_Fipa_Recruiting_Participant.java.
{
FRCConversation conv = (FRCConversation) myProcessor.getConversation();
conv.FinalResult="REFUSE";
messageToSend.setReceiver(conv.initiator);
}
ConvCFactory es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.newFactory | ( | String | name, |
MessageFilter | filter, | ||
ACLMessage | template, | ||
int | availableConversations, | ||
ConvJasonAgent | myAgent | ||
) |
Creates a new participant fipa recruiting CFactory
name | factory's name |
filter | message filter |
template | first message to send |
availableConversations | maximum number of conversation this CFactory can manage simultaneously |
myAgent | agent owner of this CFactory |
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; }
boolean es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.resultOfSubProtocol | ( | CProcessor | myProcessor, |
ACLMessage | subProtocolMessageResult | ||
) | [protected] |
Returns the result of a proxy action
myProcessor | the CProcessor managing the conversation |
subProtocolMessageResult | result of the subprotocol |
Definition at line 215 of file Jason_Fipa_Recruiting_Participant.java.
{ // TODO Auto-generated method stub return true; }
TransitionSystem es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_Fipa_Recruiting_Participant.Ts [protected] |
Definition at line 41 of file Jason_Fipa_Recruiting_Participant.java.