Magentix2
2.1.1
|
Classes | |
class | BEGIN_Method |
class | FINAL_Method |
class | RECEIVE_BID_CALL_Method |
class | RECEIVE_END_CONFIRMATION_Method |
class | RECEIVE_NEW_CONV_DATA_Method |
class | RECEIVE_WINNER_CONFIRM_Method |
class | SEND_AGREE_Method |
class | TIMEOUT_Method |
Public Member Functions | |
Jason_JAuc_Participant (TransitionSystem ts) | |
ConvCFactory | newFactory (String name, MessageFilter filter, ACLMessage template, int availableConversations, ConvJasonAgent myAgent, int timeout) |
Protected Member Functions | |
void | doBegin (CProcessor myProcessor, ACLMessage msg) |
String | doReceiveNewConvData (ConvCProcessor myProcessor, ACLMessage msg) |
String | doReceiveBidceCall (ConvCProcessor myProcessor, ACLMessage msg) |
void | doSendAgree (ConvCProcessor myProcessor, ACLMessage messageToSend) |
void | doTimeout (ConvCProcessor myProcessor, ACLMessage msg) |
void | doReceiveWinnerConfirm (ConvCProcessor myProcessor, ACLMessage msg) |
void | doFinal (ConvCProcessor myProcessor, ACLMessage messageToSend) |
Protected Attributes | |
TransitionSystem | Ts |
This class represents a template for a Japanese Auction Protocol from the participant perspective for being used in the Conversations Factory from Jason agents.
Definition at line 35 of file Jason_JAuc_Participant.java.
es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant.Jason_JAuc_Participant | ( | TransitionSystem | ts | ) |
Definition at line 39 of file Jason_JAuc_Participant.java.
{ Ts = ts; }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_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_JAuc_Participant.java.
{
myProcessor.getInternalData().put("InitialMessage", msg);
}
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_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 202 of file Jason_JAuc_Participant.java.
{ JAucPartConversation conv = (JAucPartConversation)myProcessor.getConversation(); myProcessor.getMyAgent().removeFactory(conv.factoryName); messageToSend = myProcessor.getLastSentMessage(); }
String es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant.doReceiveBidceCall | ( | ConvCProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the participant receives a call for bid acceptance
myProcessor | the CProcessor managing the conversation |
msg | bid acceptance message |
Definition at line 98 of file Jason_JAuc_Participant.java.
{ JAucPartConversation conv; conv = (JAucPartConversation) myProcessor.getConversation(); conv.AuctionLevel = msg.getHeaderValue("auctionlevel"); String result = ""; AgentID Sender = myProcessor.getLastReceivedMessage().getSender(); String request = msg.getContent(); String bid = msg.getHeaderValue("bid"); String participants = msg.getHeaderValue("participants"); String newMsgContent = "callforbid"+"("+Sender.name+","+request+","+participants+","+bid+","+conv.jasonConvID+")[source(self)]"; List<Literal> allpercep = new ArrayList<Literal>(); allpercep.add(Literal.parseLiteral(newMsgContent)); ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allpercep); conv.aquire_semaphore(); if (conv.Accept){ //it must be setted result = "SEND_AGREE"; }else result = "FINAL"; return result; }
String es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant.doReceiveNewConvData | ( | ConvCProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the participant receives the new converstaion internal information
myProcessor | the CProcessor managing the conversation |
msg | bid acceptance message |
Definition at line 67 of file Jason_JAuc_Participant.java.
{ JAucPartConversation newConv; Conversation conv = myProcessor.getConversation(); if (conv.jasonConvID.compareTo("")==0){ String jasonConvID = msg.getHeaderValue("jasonID"); 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. The factory name is already setted conv.jasonConvID = jasonConvID; conv.initiator = msg.getSender(); newConv = new JAucPartConversation(conv.jasonConvID, conv.internalConvID, conv.initiator,"",factName); ((ConvCFactory)myProcessor.getMyFactory()).UpdateConv(newConv, myProcessor); }else{ newConv = (JAucPartConversation) myProcessor.getConversation(); } return "WAIT_FOR_BID_CALL"; }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant.doReceiveWinnerConfirm | ( | ConvCProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the initiator sends the winner confirmation
myProcessor | the CProcessor managing the conversation |
msg | accept message |
Definition at line 163 of file Jason_JAuc_Participant.java.
{ JAucPartConversation conv = (JAucPartConversation)myProcessor.getConversation(); AgentID Sender = myProcessor.getLastReceivedMessage().getSender(); String finalbid = msg.getContent(); String request = msg.getHeaderValue("request"); String newMsgContent = "winner"+"(\""+Sender.name+"\","+request+","+finalbid+","+conv.jasonConvID+")[source(self)]"; List<Literal> allpercep = new ArrayList<Literal>(); allpercep.add(Literal.parseLiteral(newMsgContent)); ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allpercep); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant.doSendAgree | ( | 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 131 of file Jason_JAuc_Participant.java.
{ JAucPartConversation conv = (JAucPartConversation)myProcessor.getConversation(); messageToSend.setSender(myProcessor.getMyAgent().getAid()); messageToSend.setReceiver(conv.initiator); messageToSend.setContent("agree"); messageToSend.setHeader("auctionlevel", conv.AuctionLevel); messageToSend.setPerformative(ACLMessage.ACCEPT_PROPOSAL); messageToSend.setProtocol("japanese-auction"); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant.doTimeout | ( | ConvCProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Definition at line 148 of file Jason_JAuc_Participant.java.
{ }
ConvCFactory es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_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 226 of file Jason_JAuc_Participant.java.
{ // Create factory if (filter == null) { filter = new MessageFilter("protocol = japanese-auction AND purpose = startdata"); } 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_NEW_CONV_DATA State WaitState WAIT_FOR_NEW_CONV_DATA = new WaitState("WAIT_FOR_NEW_CONV_DATA", 4000); processor.registerState(WAIT_FOR_NEW_CONV_DATA); processor.addTransition(BEGIN, WAIT_FOR_NEW_CONV_DATA); // RECEIVE_NEW_CONV_DATA State ReceiveState RECEIVE_NEW_CONV_DATA = new ReceiveState( "RECEIVE_NEW_CONV_DATA"); RECEIVE_NEW_CONV_DATA.setMethod(new RECEIVE_NEW_CONV_DATA_Method()); filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.INFORM)+" AND purpose = startdata"); RECEIVE_NEW_CONV_DATA.setAcceptFilter(filter); processor.registerState(RECEIVE_NEW_CONV_DATA); processor.addTransition(WAIT_FOR_NEW_CONV_DATA, RECEIVE_NEW_CONV_DATA); // WAIT_FOR_BID_CALL State WaitState WAIT_FOR_BID_CALL = new WaitState("WAIT_FOR_BID_CALL", timeout); processor.registerState(WAIT_FOR_BID_CALL); processor.addTransition(RECEIVE_NEW_CONV_DATA, WAIT_FOR_BID_CALL); // RECEIVE_BID_CALL State ReceiveState RECEIVE_BID_CALL = new ReceiveState( "RECEIVE_BID_CALL"); RECEIVE_BID_CALL.setMethod(new RECEIVE_BID_CALL_Method()); filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.PROPOSE)+" AND ( purpose = start OR purpose = bid )"); RECEIVE_BID_CALL.setAcceptFilter(filter); processor.registerState(RECEIVE_BID_CALL); processor.addTransition(WAIT_FOR_BID_CALL, RECEIVE_BID_CALL); // SEND_AGREE State SendState SEND_AGREE = new SendState("SEND_AGREE"); SEND_AGREE.setMethod(new SEND_AGREE_Method()); template.setProtocol("japanese-auction"); template.setPerformative(ACLMessage.ACCEPT_PROPOSAL); SEND_AGREE.setMessageTemplate(template); processor.registerState(SEND_AGREE); processor.addTransition(RECEIVE_BID_CALL, SEND_AGREE); // WAIT_FOR_BID_CALL2 State WaitState WAIT_FOR_BID_CALL2 = new WaitState("WAIT_FOR_BID_CALL2", timeout); processor.registerState(WAIT_FOR_BID_CALL2); processor.addTransition(SEND_AGREE, WAIT_FOR_BID_CALL2); processor.addTransition(WAIT_FOR_BID_CALL2,RECEIVE_BID_CALL); // TIMEOUT State ReceiveState TIMEOUT = new ReceiveState("TIMEOUT"); TIMEOUT.setMethod(new TIMEOUT_Method()); filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.INFORM)+" AND purpose = waitMessage"); TIMEOUT.setAcceptFilter(filter); processor.registerState(TIMEOUT); processor.addTransition(WAIT_FOR_NEW_CONV_DATA, TIMEOUT); processor.addTransition(WAIT_FOR_BID_CALL, TIMEOUT); processor.addTransition(WAIT_FOR_BID_CALL2, TIMEOUT); // RECEIVE_WINNER_CONFIRMATION State ReceiveState RECEIVE_WINNER_CONFIRM = new ReceiveState( "RECEIVE_WINNER_CONFIRM"); RECEIVE_WINNER_CONFIRM.setMethod(new RECEIVE_WINNER_CONFIRM_Method()); filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.INFORM)+" AND purpose = winner"); RECEIVE_WINNER_CONFIRM.setAcceptFilter(filter); processor.registerState(RECEIVE_WINNER_CONFIRM); processor.addTransition(WAIT_FOR_BID_CALL2, RECEIVE_WINNER_CONFIRM); // RECEIVE_END_CONFIRMATION State ReceiveState RECEIVE_END_CONFIRMATION = new ReceiveState( "RECEIVE_END_CONFIRMATION"); RECEIVE_END_CONFIRMATION.setMethod(new RECEIVE_END_CONFIRMATION_Method()); filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.INFORM)+" AND purpose = end"); RECEIVE_END_CONFIRMATION.setAcceptFilter(filter); processor.registerState(RECEIVE_END_CONFIRMATION); processor.addTransition(WAIT_FOR_BID_CALL2, RECEIVE_END_CONFIRMATION); // FINAL State FinalState FINAL = new FinalState("FINAL"); FINAL.setMethod(new FINAL_Method()); processor.registerState(FINAL); processor.addTransition(RECEIVE_WINNER_CONFIRM, FINAL); processor.addTransition(RECEIVE_BID_CALL, FINAL); processor.addTransition(TIMEOUT, FINAL); processor.addTransition(RECEIVE_END_CONFIRMATION, FINAL); return theFactory; }
TransitionSystem es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant.Ts [protected] |
Definition at line 37 of file Jason_JAuc_Participant.java.