Magentix2  2.1.1
jason.stdlib.ia_FICN_Participant Class Reference
Inheritance diagram for jason.stdlib.ia_FICN_Participant:
Collaboration diagram for jason.stdlib.ia_FICN_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_FICN_Participant ficnp

Detailed Description

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

Author:
Bexy Alfonso Espinosa

Definition at line 23 of file ia_FICN_Participant.java.


Member Function Documentation

void jason.stdlib.ia_FICN_Participant.checkArguments ( Term[]  args) throws JasonException

Definition at line 39 of file ia_FICN_Participant.java.

                                                                     {

                super.checkArguments(args);
                boolean result = false;

                if (((Term)args[args.length-1]).isAtom()){result=true;}

                result = (result && (((Term)args[0]).isString()) );

                if ((protocolSteep.compareTo(Protocol_Template.TASK_DONE_STEP)==0)||
                                (protocolSteep.compareTo(Protocol_Template.TASK_NOT_DONE_STEP)==0))
                {
                        result = (result && (((Term)args[1]).isString()) );
                }
                if (protocolSteep.compareTo(Protocol_Template.MAKE_PROPOSAL_STEP)==0)
                {
                        result = (result && (((Term)args[1]).isNumeric()||((Term)args[1]).isNumeric()) );
                }               
                if (!result)
                {
                        throw JasonException.createWrongArgument(this,"Parameters must be in correct format.");
                }
        }
Object jason.stdlib.ia_FICN_Participant.execute ( TransitionSystem  ts,
Unifier  un,
Term[]  args 
) throws Exception

Definition at line 64 of file ia_FICN_Participant.java.

                                                                                             {

                agName  = ts.getUserAgArch().getAgName();

                Term protSteep = args[0];

                agentConversationID = ((Term)args[args.length-1]).toString();

                protocolSteep = ((StringTerm)protSteep).getString();

                checkArguments(args);

                ts.getAg().getLogger().fine("CALLING INTERNAL ACTION WITH STEEP: '"+protocolSteep+"'"+" CID: "+agentConversationID); 

                //the first state in the conversation

                if (protocolSteep.compareTo(Protocol_Template.JOIN_STEP)==0){
                        //TODO: It is necessary to document that 80000 is the max time for the waiting states by default so 
                        //in the Jason code of the participant this data is eliminated. Update examples in document. This value 
                        //must be greater than the wait_for_proposals deadline.
                        int timeOut = 80000;

                        if (ficnp == null){
                                ficnp = new Jason_FICN_Participant(agName, ts);
                        }
                        if (args.length >2)
                        {                                       
                                timeOut = (int)((NumberTerm)args[1]).solve();
                        }

                        String myfactName = getFactoryName(agentConversationID,"FICN",false);
                        String inifactName = getFactoryName(agentConversationID,"FICN",true);
                        MessageFilter filter = new MessageFilter("performative = CFP AND protocol = fipa-iterated-contract-net AND factoryname = "+inifactName);

                        ConvCFactory tmpFactory = ficnp.newFactory(myfactName, filter,null,1, 
                                        ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent(),timeOut);

                        ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent().addFactoryAsParticipant(tmpFactory);
                        CFactories.put(agentConversationID, tmpFactory);
                }
                else
                        if (protocolSteep.compareTo(Protocol_Template.MAKE_PROPOSAL_STEP)==0){
                                if (conversationsList.get(agentConversationID) == null)
                                {       ConvCFactory tmpFactory = CFactories.get(agentConversationID);
                                {Conversation conv = tmpFactory.removeConversationByJasonID(agentConversationID);
                                conversationsList.put(agentConversationID, conv);}
                                CFactories.remove(agentConversationID);
                                }
                                Term proposal = args[1];

                                ((FICNConversation)conversationsList.get(agentConversationID)).kindOfAnswer = "propose";
                                ((FICNConversation)conversationsList.get(agentConversationID)).proposal = getTermAsString(proposal);

                                conversationsList.get(agentConversationID).release_semaphore();
                        }
                        else
                                if (protocolSteep.compareTo(Protocol_Template.REFUSE_STEP)==0){
                                        if (conversationsList.get(agentConversationID) == null)
                                        {       ConvCFactory tmpFactory = CFactories.get(agentConversationID);
                                        {Conversation conv = tmpFactory.removeConversationByJasonID(agentConversationID);
                                        conversationsList.put(agentConversationID, conv);}
                                        CFactories.remove(agentConversationID);
                                        }

                                        ((FICNConversation)conversationsList.get(agentConversationID)).kindOfAnswer = "refuse";
                                        conversationsList.get(agentConversationID).release_semaphore();

                                }
                                else
                                        if (protocolSteep.compareTo(Protocol_Template.NOT_UNDERSTOOD_STEP)==0){
                                                if (conversationsList.get(agentConversationID) == null)
                                                {       ConvCFactory tmpFactory = CFactories.get(agentConversationID);
                                                { Conversation conv = tmpFactory.removeConversationByJasonID(agentConversationID);
                                                conversationsList.put(agentConversationID, conv);}
                                                CFactories.remove(agentConversationID);
                                                }

                                                ((FICNConversation)conversationsList.get(agentConversationID)).kindOfAnswer = "notUnderstood";
                                                conversationsList.get(agentConversationID).release_semaphore();
                                        }
                                        else
                                                if (protocolSteep.compareTo(Protocol_Template.TASK_DONE_STEP)==0){

                                                        Term finalInfo = args[1];

                                                        ((FICNConversation)conversationsList.get(agentConversationID)).infoToSend = ((StringTerm)finalInfo).getString();
                                                        ((FICNConversation)conversationsList.get(agentConversationID)).taskDone = true;

                                                        conversationsList.get(agentConversationID).release_semaphore();

                                                }
                                                else
                                                        if (protocolSteep.compareTo(Protocol_Template.TASK_NOT_DONE_STEP)==0){

                                                                Term finalInfo = args[1];
                                                                ((FICNConversation)conversationsList.get(agentConversationID)).infoToSend = ((StringTerm)finalInfo).getString();
                                                                ((FICNConversation)conversationsList.get(agentConversationID)).taskDone = false;

                                                                conversationsList.get(agentConversationID).release_semaphore();

                                                        }

                // everything ok, so returns true
                return true;
        }

Definition at line 36 of file ia_FICN_Participant.java.

{ return 5; };

Definition at line 35 of file ia_FICN_Participant.java.

{ return 2; };

Member Data Documentation


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