Magentix2  2.1.1
jason.stdlib.ia_fipa_recruiting_Participant Class Reference
Inheritance diagram for jason.stdlib.ia_fipa_recruiting_Participant:
Collaboration diagram for jason.stdlib.ia_fipa_recruiting_Participant:

List of all members.

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

Detailed Description

This class represents the internal action to be used when adding a conversation to a Jason agent under the Fipa Recruiting Protocol as participant

Author:
Bexy Alfonso Espinosa

Definition at line 28 of file ia_fipa_recruiting_Participant.java.


Member Function Documentation

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;

        }

Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables