[kepler-users] Iterating over Elements / Looping

Christopher Brooks cxh at eecs.berkeley.edu
Thu Apr 26 07:54:51 PDT 2012


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DirectoryListing2.xml
Type: text/xml
Size: 4457 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20120426/67fb61c2/attachment.xml>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DirectoryListingSDFRateChange.xml
Type: text/xml
Size: 3505 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20120426/67fb61c2/attachment-0001.xml>


More information about the Kepler-users mailing list