swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Swarm-Support] FActionCreateForEach ---- Any examples?


From: Mervin Chan
Subject: [Swarm-Support] FActionCreateForEach ---- Any examples?
Date: Wed, 13 Oct 2004 05:56:38 +0800

 

 

Hi,

 

This is a question regarding FActionForEach. With regard to an existing example in

 

http://www.ku.edu/~pauljohn/SwarmFaq/WorkingExampleCode/java/ActionForEachHomogeneous.txt

 

I want to achieve the same thing, using “FactionCreateForEach”

 

For reference, this is a code snippet I’ve written. This simulates a “Machine” agent getting a Product from a “Buffer” agent.

What the code do is that I pass an object (aBuffer) to my agent aMachine.getProduct().

 

 

Another problem, is that every Machine agent may have different “Buffer” agents passed into. eg aMachine.getProduct(aBuffer), aMachine2.getProduct(aBuffer2).

 

I am expanding my code to do multiple agents/Machines (saved in a list), hence the need to pass the same “action” to all the Machines stored in a list.

 

            FCall process()

            {

                        try

                        {

                                    Selector sel= new Selector (aMachine.getClass(),"getProduct",false);

                                    FArgumentsC creating = new FArgumentsCImpl (new FArgumentsImpl ());

                                    creating.createBegin (getZone ());

                                    creating.setSelector (sel);

                                    creating.addObject(aBuffer);

                                    return new FCallImpl (getZone(),aMachine,sel,(FArguments) creating.createEnd ());

                                    }catch (Exception e)    

                                    {

                                    System.err.println("Exception product " + e.getMessage ());

                                    System.exit(1);

                                    }

                        return null;

            }

 

My question is:  Is there any code examples to do the same thing in using FCall. I need to pass different parameters into every unique agent’s actions, hence the need to use FCall.   I am using JAVA.

 

I’ve RTFA the ref-book java, but I still have no clue. Thanks.

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]