Magentix2
2.1.1
|
Public Member Functions | |
int | getMinArgs () |
int | getMaxArgs () |
void | checkArguments (Term[] args) throws JasonException |
Object | execute (TransitionSystem ts, Unifier un, Term[] args) throws Exception |
Package Attributes | |
Jason_Fipa_RequestW_Participant | frp = null |
This class represents the internal action to be used when adding a conversation to a Jason agent under the Fipa Request When Protocol as participant
Definition at line 20 of file ia_fipa_requestw_Participant.java.
void jason.stdlib.ia_fipa_requestw_Participant.checkArguments | ( | Term[] | args | ) | throws JasonException |
Definition at line 36 of file ia_fipa_requestw_Participant.java.
{ super.checkArguments(args); boolean result = false; if (((Term)args[args.length-1]).isLiteral()){result=true;} result = (result && (((Term)args[0]).isString()) ); if (protocolSteep.compareTo(Protocol_Template.JOIN_STEP)==0) { result = (result && (((Term)args[1]).isNumeric()) ); } if ((protocolSteep.compareTo(Protocol_Template.INFORM_STEP)==0)|| (protocolSteep.compareTo(Protocol_Template.FAILURE_STEP)==0)) { result = (result && (((Term)args[1]).isLiteral()) ); } if (!result) { throw JasonException.createWrongArgument(this,"Parameters must be in correct format."); } }
Object jason.stdlib.ia_fipa_requestw_Participant.execute | ( | TransitionSystem | ts, |
Unifier | un, | ||
Term[] | args | ||
) | throws Exception |
Definition at line 65 of file ia_fipa_requestw_Participant.java.
{ protocolSteep = getTermAsString(args[0]); checkArguments(args); agName = ts.getUserAgArch().getAgName(); agentConversationID = getAtomAsString(args[args.length-1]); ts.getAg().getLogger().info("CALLING INTERNAL ACTION WITH STEEP: '"+protocolSteep+"'"+" CID: "+agentConversationID); if (protocolSteep.compareTo(Protocol_Template.JOIN_STEP)==0){ if (frp == null){ if (args.length >2) { timeOut = getTermAsInt(args[1]); } AgentID tmpid = ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent().getAid(); frp = new Jason_Fipa_RequestW_Participant(agName, ts, tmpid, timeOut); Protocol_Factory = frp.newFactory("Protocol_Factory", null,1, ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent()); // Finally the factory is setup to answer to incoming messages that // can start the participation of the agent in a new conversation ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent().addFactoryAsParticipant(Protocol_Factory); //This must be substituted by a Wait state int i = 0; while (i>10000){i++;} } } else if (protocolSteep.compareTo(Protocol_Template.AGREE_STEP)==0){ frp.RequestResult = Protocol_Template.AGREE_STEP; Conversation conv = Protocol_Factory.removeConversationByJasonID(agentConversationID); conversationsList.put(agentConversationID, conv); conv.release_semaphore(); } else if (protocolSteep.compareTo(Protocol_Template.REFUSE_STEP)==0){ frp.RequestResult = Protocol_Template.REFUSE_STEP; Conversation conv = Protocol_Factory.removeConversationByJasonID(agentConversationID); conversationsList.put(agentConversationID, conv); conversationsList.get(agentConversationID).release_semaphore(); } else if (protocolSteep.compareTo(Protocol_Template.NOT_UNDERSTOOD_STEP)==0){ frp.RequestResult = Protocol_Template.NOT_UNDERSTOOD_STEP; Conversation conv = Protocol_Factory.removeConversationByJasonID(agentConversationID); conversationsList.put(agentConversationID, conv); conversationsList.get(agentConversationID).release_semaphore(); } else if (protocolSteep.compareTo(Protocol_Template.INFORM_STEP)==0){ frp.TaskResult = getTermAsString(args[1]); frp.TaskDesition = Protocol_Template.INFORM_STEP; conversationsList.get(agentConversationID).release_semaphore(); } else if (protocolSteep.compareTo(Protocol_Template.FAILURE_STEP)==0){ frp.TaskDesition = Protocol_Template.FAILURE_STEP; conversationsList.get(agentConversationID).release_semaphore(); } return true; }
Definition at line 33 of file ia_fipa_requestw_Participant.java.
{ return 4; };
Definition at line 32 of file ia_fipa_requestw_Participant.java.
{ return 2; };
Definition at line 29 of file ia_fipa_requestw_Participant.java.