Magentix2
2.1.1
|
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) |
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
Definition at line 30 of file FIPA_CONTRACTNET_Participant.java.
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_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 39 of file FIPA_CONTRACTNET_Participant.java.
{
myProcessor.getInternalData().put("InitialMessage", msg);
}
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doFinal | ( | CProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the conversation ends
myProcessor | the CProcessor managing the conversation |
messageToSend | final message |
Definition at line 270 of file FIPA_CONTRACTNET_Participant.java.
{ messageToSend = myProcessor.getLastSentMessage(); }
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doReceiveAccept | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the initiator accepts participant's proposal
myProcessor | the CProcessor managing the conversation |
msg | accept message |
Definition at line 168 of file FIPA_CONTRACTNET_Participant.java.
{ }
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doReceiveReject | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the initiator rejects participant's proposal
myProcessor | the CProcessor managing the conversation |
msg | reject 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
myProcessor | the CProcessor managing the conversation |
msg | call for proposals message |
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doSendFailure | ( | CProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the task failed
myProcessor | the CProcessor managing the conversation |
messageToSend | fail 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
myProcessor | the CProcessor managing the conversation |
messageToSend | inform message |
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doSendNotUnderstood | ( | CProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the participant sends a not-understood
myProcessor | the CProcessor managing the conversation |
messageToSend | not-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
myProcessor | the CProcessor managing the conversation |
messageToSend | proposal message |
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doSendRefuse | ( | CProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the participant sends a refuse
myProcessor | the CProcessor managing the conversation |
messageToSend | refuse 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
myProcessor | the CProcessor managing the conversation |
solicitMessage | the first message assigned to this conversation containing the solicit of the initiator agent |
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Participant.doTimeout | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the timeout is reached while the initiator was waiting for proposals
myProcessor | the CProcessor managing the conversation |
msg | timeout 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
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 |
timeout | for waiting after sending the proposal |
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; }