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_JAuc_Initiator | jauci |
This class represents the internal action to be used when adding a conversation to a Jason agent under the Japanese Auction Protocol as initiator
Definition at line 29 of file ia_JAuc_Initiator.java.
void jason.stdlib.ia_JAuc_Initiator.checkArguments | ( | Term[] | args | ) | throws JasonException |
Definition at line 42 of file ia_JAuc_Initiator.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.START_STEP)==0) { int cont = 0; for (Term t:args){ switch (cont){ case 1:result = (result&&t.isNumeric());//join timeout break; case 2:result = (result&&t.isNumeric());//timeout break; case 3:result = (result&&t.isNumeric());//initial bid break; case 4:result = (result&&t.isNumeric());//increment break; case 5:result = (result&&t.isNumeric());//max iterations break; case 6:result = (result&&t.isString());//initial msg break; case 7:result = (result&&t.isList());//participants break; //case 7:result = (result&&t.isLiteral());//request //break; } cont++; } } if (!result) { throw JasonException.createWrongArgument(this,"Parameters must be in correct format."); } }
Object jason.stdlib.ia_JAuc_Initiator.execute | ( | TransitionSystem | ts, |
Unifier | un, | ||
Term[] | args | ||
) | throws Exception |
Definition at line 88 of file ia_JAuc_Initiator.java.
{ protocolSteep = getTermAsString(args[0]); checkArguments(args); agentConversationID = getTermAsString(args[args.length-1]); if (((Term)args[args.length-1]).isString()){ agentConversationID = "\""+agentConversationID+"\""; } ConvJasonAgent myag = ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent(); agName = ts.getUserAgArch().getAgName(); ts.getAg().getLogger().fine("CALLING INTERNAL ACTION WITH STEEP: '"+protocolSteep+"'"+" CID: "+agentConversationID); //the first state in the conversation if (protocolSteep.compareTo(Protocol_Template.START_STEP)==0){ joinTimeOut = getTermAsInt(args[1]); timeOut = getTermAsInt(args[2]); double initialBid = getTermAsdouble(args[3]); double increment = getTermAsdouble(args[4]); int maxIterations = getTermAsInt(args[5]); String initialMsg = getTermAsString(args[6]); List<String> participants = getTermAsStringList(args[7]); List<AgentID> AIDparticipants = new ArrayList<AgentID>(); Iterator<String> it = participants.iterator(); while (it.hasNext()) AIDparticipants.add(new AgentID(it.next())); String request = getTermAsString(args[8]); int particnumber = participants.size(); //building message template ACLMessage msg = new ACLMessage(); msg.setProtocol("japanese-auction"); //int participantsNumber = participants.size(); msg.setContent(initialMsg); String factName = getFactoryName(agentConversationID,"JAUC",true); //if (jauci == null){ /* The agent creates the CFactory that creates processors that initiate the protocol conversations. */ jauci = new Jason_JAuc_Initiator( ts); String prevFactory = ""; if (Protocol_Factory!=null) prevFactory = Protocol_Factory.getName(); if (prevFactory.compareTo(factName)!=0) // if it is a new conversation a create a new one. This verification is not strictly //necessary because it supposed that this condition will be always truth. This must be improved but, //as the participants can not distinguish between conversation of the same factory also one factory per conversation //is created with the initiator factory name as a filter. This implies one factory per conversation in the initiator too { Protocol_Factory = jauci.newFactory(factName, null, msg, 1, ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent(),particnumber,timeOut, joinTimeOut ); ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent().addFactoryAsInitiator(Protocol_Factory); } //} /* finally the new conversation starts an asynchronous conversation.*/ myag.lock(); String ConvID = myag.newConvID(); JAucIniConversation conv = new JAucIniConversation(agentConversationID,ConvID, ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent().getAid(), AIDparticipants,initialMsg,initialBid, increment,maxIterations,factName); //the internal id is unknown yet ConvCProcessor processorTemplate = ((ConvCFactory)Protocol_Factory).cProcessorTemplate(); processorTemplate.setConversation(conv); msg.setConversationId(ConvID); if (myag.getName().compareTo("aut_agent20")==0) System.out.println("20"); ConvCProcessor convPprocessor = myag.newConversation(msg, processorTemplate, false, Protocol_Factory); convPprocessor.setConversation(conv); myag.unlock(); conv.request = request; conversationsList.put(agentConversationID, conv); //TODO: Hay que gestionar el elimar de aquĆ cdo se termine la conversacion } return true; }
Definition at line 39 of file ia_JAuc_Initiator.java.
{ return 10; };
Definition at line 38 of file ia_JAuc_Initiator.java.
{ return 10; };
Definition at line 36 of file ia_JAuc_Initiator.java.