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_Recruiting_Participant | frcp |
This class represents the internal action to be used when adding a conversation to a Jason agent under the Fipa Recruiting Protocol as participant
Definition at line 28 of file ia_fipa_recruiting_Participant.java.
void jason.stdlib.ia_fipa_recruiting_Participant.checkArguments | ( | Term[] | args | ) | throws JasonException |
Definition at line 44 of file ia_fipa_recruiting_Participant.java.
{ super.checkArguments(args); boolean result = false; if ( (((Term)args[args.length-1]).isAtom())|| (((Term)args[args.length-1]).isString())|| (((Term)args[args.length-1]).isLiteral())|| (((Term)args[args.length-1]).isNumeric())){result=true;} result = (result && (((Term)args[0]).isString()) ); if ( protocolSteep.compareTo(Protocol_Template.LOCATE_AGENTS_STEP)==0) { result = (result && (((Term)args[1]).isList()) ); } if ( protocolSteep.compareTo(Protocol_Template.INFORM_STEP)==0) { result = (result && (((Term)args[1]).isString()) ); } if (!result) { throw JasonException.createWrongArgument(this,"Parameters must be in correct format."); } }
Object jason.stdlib.ia_fipa_recruiting_Participant.execute | ( | TransitionSystem | ts, |
Unifier | un, | ||
Term[] | args | ||
) | throws Exception |
Definition at line 73 of file ia_fipa_recruiting_Participant.java.
{ agentConversationID = getTermAsString( args[args.length-1]); protocolSteep = getTermAsString(args[0]); if (ts.getSettings().verbose()>1) ts.getAg().getLogger().info("CALLING INTERNAL ACTION WITH STEEP: '"+protocolSteep+"'"+" CID: "+agentConversationID); checkArguments(args); agName = ts.getUserAgArch().getAgName(); if (protocolSteep.compareTo(Protocol_Template.JOIN_STEP)==0){ if (args.length >2) { timeOut = getTermAsInt(args[2]); } if (frcp == null){ frcp = new Jason_Fipa_Recruiting_Participant( ts); } ACLMessage msg = new ACLMessage(); msg.setProtocol("fipa-recruiting"); msg.setContent("Joining fipa-recruiting conversation "+agentConversationID); String myfactName = getFactoryName(agentConversationID,"FRC",false); String inifactName = getFactoryName(agentConversationID,"FRC",true); MessageFilter filter = new MessageFilter("protocol = fipa-recruiting AND factoryname = "+inifactName); ConvCFactory tmpFactory = frcp.newFactory(myfactName, filter,msg,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(tmpFactory); CFactories.put(agentConversationID, tmpFactory); } else if (protocolSteep.compareTo(Protocol_Template.AGREE_STEP)==0){ ConvCFactory tmpFactory = CFactories.get(agentConversationID); Conversation conv = tmpFactory.removeConversationByJasonID(agentConversationID); conversationsList.put(agentConversationID, conv); CFactories.remove(agentConversationID); ((FRCConversation)conversationsList.get(agentConversationID)).MsgProxyContent = (LiteralImpl)args[1]; ((FRCConversation)conversationsList.get(agentConversationID)).ProxyAcceptance = true; conversationsList.get(agentConversationID).release_semaphore(); } else if (protocolSteep.compareTo(Protocol_Template.REFUSE_STEP)==0){ ConvCFactory tmpFactory = CFactories.get(agentConversationID); Conversation conv = tmpFactory.removeConversationByJasonID(agentConversationID); conversationsList.put(agentConversationID, conv); CFactories.remove(agentConversationID); ((FRCConversation)conversationsList.get(agentConversationID)).MsgProxyContent = (LiteralImpl)args[1]; ((FRCConversation)conversationsList.get(agentConversationID)).ProxyAcceptance = false; conversationsList.get(agentConversationID).release_semaphore(); } else if (protocolSteep.compareTo(Protocol_Template.LOCATE_AGENTS_STEP)==0){ List<String> tagents = new ArrayList<String>(); tagents = getTermAsStringList(args[1]); for (String ag:tagents){ ((FRCConversation)conversationsList.get(agentConversationID)).TargetAgents.add(new AgentID(ag)); } conversationsList.get(agentConversationID).release_semaphore(); } else if (protocolSteep.compareTo(Protocol_Template.INFORM_STEP)==0){ //getTermAsString(args[2]): has the task done ((FRCConversation)conversationsList.get(agentConversationID)).InfoToSend = getTermAsString(args[1]); conversationsList.get(agentConversationID).release_semaphore(); } return true; }
Definition at line 41 of file ia_fipa_recruiting_Participant.java.
{ return 3; };
Definition at line 40 of file ia_fipa_recruiting_Participant.java.
{ return 2; };
Definition at line 38 of file ia_fipa_recruiting_Participant.java.