Hi Stefan,
We talked about these sorts of model today. Edward's main comment was that we need to have better documentation about how to do control flow with actor-oriented models. Also, we talked about using IterateOverArray for the sorts of models, which is probably your best bet.

My brute force method would be to have write an actor that read a directory and produced a file or directory on the output each time the actor was fired. When all the files and/or directories had been written to the output, then prefire() would return false. An even more brute force method would be to have a separate output that would be written to when the directory had been completely read. This output could be connected to a Stop actor.

_Christopher

On 4/30/12 1:07 AM, Stefan Proell wrote:
Dear Christopher,
thanks for the hints.
I do not know the size of the array in advance and I also need to terminate the looping in a reliable way. There hopefully exists a more elegant solution to this problem, but I now decided to model the process in a way it stays dynamic regarding the array size and terminating after hitting a counter-limit. I attach the project file to this mail. What this simple example does is fetching a directory of files (MP3s) and storing it on my local hard drive for further processing (not implemented yet :-) ). I used a DDF director.

Kind regards,
Stefan


Am 2012-04-26 16:54, schrieb Christopher Brooks:
Stefan,
DirectoryListing produces an Array an output.
If you know the number of files in the directory in advance, then you can use ArrayToSequence and have a SDF Director. The reason you need to know the number of files is because you need to know the size of the array so that SDF can calculate a schedule. An alternative is to set the allowRateChanges in SDFDirector to true, see DirectorySDFRateChange.xml
One issue with this model is that it does not terminate naturally.

Or, you can use the PN Director and terminate the model with a test that looks for a file name that has already been seen.

An alternative is to put the DirectoryListing inside a Composite that has a SDF Director. I ran in to issue with terminating the model though. Attached is DirectoryListing2.xml.

I'm probably missing an easier way to do this though.

See also
https://kepler-project.org/users/faq#how-do-i-branch

_Christopher

On 4/26/12 7:29 AM, Tomasz Żok wrote:
Dear Stefan,

please take a look at this tutorial session:
http://scilla.man.poznan.pl:8080/confluence/x/oAFU

You can jump straight to sections dedicated to looping in Kepler, there are
several possible solutions presented.

Best regards,
Tomek

Dear Kepler Community, I am rathre new to Kepler and I have a question regarding looping. I searched the documentation and the mailing list archive, but could not find a proper answer. For a specific workflow, I need to fetch several files from a Web server and process these. For this purpose, I use the DirectoryListing - Actor. Fetching the URLs of the files works fine, but how would I iterate over all the URLs for further processing? I would like to use the "URL to File" actor, but how would I iterate over the elements/URLs I receive? Is there an elegant way, or do I have to assemble (rather complicated) loops just for going through all the elements? So far I would use the Actor ArrayElement, but then I have to feed an index variable to it, which I would have to iterate after each token. This seems to be a bit of an overhead to me. Thanks in advance, Kind regards, Stefan





--
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841                                (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670

_______________________________________________
Kepler-users mailing list
Kepler-users@kepler-project.org
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

Reply via email to