Repeat executing a function block

1 view
Skip to first unread message

Sher

unread,
Jul 6, 2009, 4:24:14 AM7/6/09
to FBDK
I would like to build a function block to keep reading data from a
file and every time it should send a CNF event to other function
blocks. Currently, I can only think of the way that use a while loop
to keep reading the file. Is there any way that can make it easily?

Thanks in advance for your kind help.

William Dai

unread,
Jul 7, 2009, 9:08:13 PM7/7/09
to fb...@googlegroups.com
Using E_CYCLE FB to trigger your FB, it has duty cycle time as a
parameter setup.
--
Best Regards,
William Dai

Jim Christensen

unread,
Jul 8, 2009, 4:39:00 PM7/8/09
to FBDK
As William indicates, you should fire the file-reading FB with an
event from a SIFB such as E_CYCLE or E_DELAY that provides a separate
thread of execution, since java.io.InputStream.read() is a thread-
blocking operation. But how you fire the block depends on what you
want to do. Do you want to read the file character-by-character or
byte-by-byte and send each character or byte on with a CNF ? Or line-
by-line, or even the entire contents of the file? That also determines
what subclass of java.io.InputStream or java.io.Reader you encapsulate
in the FB. Also, how do you plan to deal with end-of-file or other
exceptional conditions?
- Jim Christensen

On Jul 7, 9:08 pm, William Dai <william...@gmail.com> wrote:
> Using E_CYCLE FB to trigger your FB, it has duty cycle time as a
> parameter setup.
>
Reply all
Reply to author
Forward
0 new messages