[kepler-users] Iterating over Elements / Looping

Stefan Proell sproell at sba-research.org
Mon Apr 30 01:07:18 PDT 2012


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 
>
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DirectoryLister.kar
Type: audio/midi
Size: 11609 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20120430/0b429bb1/attachment.kar>


More information about the Kepler-users mailing list