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 |
Public Member Functions | |
Jason_FCN_Participant (String agName2, TransitionSystem ts2) | |
ConvCFactory | newFactory (String name, MessageFilter filter, ACLMessage template, int availableConversations, ConvJasonAgent myAgent, int timeout) |
Protected Member Functions | |
void | doBegin (CProcessor myProcessor, ACLMessage msg) |
String | doReceiveSolicit (ConvCProcessor myProcessor, ACLMessage msg) |
void | doSendProposal (ConvCProcessor myProcessor, ACLMessage messageToSend) |
void | doSendRefuse (CProcessor myProcessor, ACLMessage messageToSend) |
void | doSendNotUnderstood (CProcessor myProcessor, ACLMessage messageToSend) |
void | doReceiveAccept (CProcessor myProcessor, ACLMessage msg) |
void | doReceiveReject (CProcessor myProcessor, ACLMessage msg) |
String | doTask (ConvCProcessor myProcessor, ACLMessage solicitMessage) |
void | doSendFailure (CProcessor myProcessor, ACLMessage messageToSend) |
void | doSendInfo (ConvCProcessor myProcessor, ACLMessage messageToSend) |
void | doFinal (ConvCProcessor myProcessor, ACLMessage messageToSend) |
Protected Attributes | |
TransitionSystem | Ts |
This class represents a template for a Fipa Contract Net Protocol from the participant perspective for being used in the Conversations Factory from Jason agents.
Definition at line 38 of file Jason_FCN_Participant.java.
es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_Participant.Jason_FCN_Participant | ( | String | agName2, |
TransitionSystem | ts2 | ||
) |
Definition at line 42 of file Jason_FCN_Participant.java.
{ Ts = ts2; }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_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 51 of file Jason_FCN_Participant.java.
{
myProcessor.getInternalData().put("InitialMessage", msg);
}
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_Participant.doFinal | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the conversation ends
myProcessor | the CProcessor managing the conversation |
messageToSend | final message |
Definition at line 283 of file Jason_FCN_Participant.java.
{ FCNConversation conv = (FCNConversation)myProcessor.getConversation(); myProcessor.getMyAgent().removeFactory(conv.factoryName); messageToSend = myProcessor.getLastSentMessage(); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_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 179 of file Jason_FCN_Participant.java.
{ }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_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 194 of file Jason_FCN_Participant.java.
{ }
String es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_Participant.doReceiveSolicit | ( | ConvCProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the participant receives a call for proposals
myProcessor | the CProcessor managing the conversation |
msg | call for proposals message |
Definition at line 68 of file Jason_FCN_Participant.java.
{ // accept all the solicits String jasonConvID = msg.getHeaderValue("jasonID"); Conversation conv = myProcessor.getConversation(); String factName = conv.factoryName; //At this point the conversation associated to the CProcessor has no value //for the internal conversation ID so it is updated conv.jasonConvID = jasonConvID; conv.initiator = msg.getSender(); FCNConversation newConv = new FCNConversation(conv.jasonConvID, conv.internalConvID, "", conv.initiator,factName); ((ConvCFactory)myProcessor.getMyFactory()).UpdateConv(newConv, myProcessor); String result = ""; AgentID Sender = myProcessor.getLastReceivedMessage().getSender(); String newMsgContent = "callforproposal"+"("+Sender.name+","+msg.getContent()+","+conv.jasonConvID+")[source(self)]"; List<Literal> allpercep = new ArrayList<Literal>(); allpercep.add(Literal.parseLiteral(newMsgContent)); ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allpercep); newConv.aquire_semaphore(); if (newConv.kindOfAnswer =="propose"){ result = "SEND_PROPOSAL"; }else if (newConv.kindOfAnswer=="refuse"){ result = "SEND_REFUSE"; }else if (newConv.kindOfAnswer=="notUnderstood"){ result = "SEND_NOT_UNDERSTOOD"; } return result; }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_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 238 of file Jason_FCN_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()); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_Participant.doSendInfo | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the task succeeded
myProcessor | the CProcessor managing the conversation |
messageToSend | inform message |
Definition at line 261 of file Jason_FCN_Participant.java.
{ FCNConversation conv = (FCNConversation)myProcessor.getConversation(); messageToSend.setSender(myProcessor.getMyAgent().getAid()); messageToSend.setReceiver(myProcessor.getLastReceivedMessage().getSender()); messageToSend.setContent("I'm "+myProcessor.getMyAgent().getAid().name+": "+conv.infoToSend); messageToSend.setPerformative(ACLMessage.INFORM); messageToSend.setProtocol("fipa-contract-net"); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_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 157 of file Jason_FCN_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()); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_Participant.doSendProposal | ( | ConvCProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the participant sends a proposal
myProcessor | the CProcessor managing the conversation |
messageToSend | proposal message |
Definition at line 111 of file Jason_FCN_Participant.java.
{
FCNConversation conv = (FCNConversation)myProcessor.getConversation();
messageToSend.setSender(myProcessor.getMyAgent().getAid());
messageToSend.setReceiver(conv.initiator);
messageToSend.setContent(conv.proposal);
messageToSend.setPerformative(ACLMessage.PROPOSE);
messageToSend.setProtocol("fipa-contract-net");
}
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_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 134 of file Jason_FCN_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()); }
String es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_Participant.doTask | ( | ConvCProcessor | myProcessor, |
ACLMessage | solicitMessage | ||
) | [protected] |
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 |
Definition at line 210 of file Jason_FCN_Participant.java.
{ String result = ""; FCNConversation conv = (FCNConversation)myProcessor.getConversation(); List<Literal> allpercep = new ArrayList<Literal>(); allpercep.add(Literal.parseLiteral("timetodotask("+conv.initiator.name+","+conv.jasonConvID+")[source(self)]")); ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allpercep); conv.aquire_semaphore(); if (conv.taskDone){ result = "SEND_INFORM";} else { result = "SEND_FAILURE";} return result; }
ConvCFactory es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_Participant.newFactory | ( | String | name, |
MessageFilter | filter, | ||
ACLMessage | template, | ||
int | availableConversations, | ||
ConvJasonAgent | 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 307 of file Jason_FCN_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); } 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_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); 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(RECEIVE_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); // 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); processor.addTransition(SEND_INFO, FINAL); processor.addTransition(RECEIVE_REJECT, FINAL); processor.addTransition(SEND_NOT_UNDERSTOOD, FINAL); processor.addTransition(SEND_REFUSE, FINAL); return theFactory; }
TransitionSystem es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_FCN_Participant.Ts [protected] |
Definition at line 40 of file Jason_FCN_Participant.java.