[C.CC USERS] Occam-Pi programing question

Bryant Nelson bryant.p.nelson at gmail.com
Sun Oct 28 22:30:40 GMT 2012


Hey everybody,

Thanks for the help getting my flow control set up. Here is an update on
the project.
http://www.youtube.com/watch?v=LjQE70b3GY4

Bryant

On Mon, Sep 3, 2012 at 5:02 PM, Fred Barnes <F.R.M.Barnes at kent.ac.uk> wrote:

>
> Hi Bryant,
>
> > Here is what I got so far. The problem is, all the pumps turn on at the
> > same time, run for the proper amount of time, then wait for the maximum
> > wait time. For example, the pump on pin 12 is governing the off time.
> After
> > 4s all the pumps kick on, 13 is on for 1s, 12 for 2s and 11 for .7s, once
> > 12 is done it waits 4s then everything starts at the same time.
> >
> > Can somebody help me out?
> >
> >
> > #INCLUDE "plumbing.module"
> > PROC do (VAL INT pin, VAL INT timeOn, VAL INT timeOff)
> >   SEQ
> >     digital.mode (pin, OUTPUT)
> >     digital.write (pin, HIGH)
> >     delay(timeOn)
> >     digital.mode (pin, OUTPUT)
> >     digital.write(pin, LOW)
> >     delay(timeOff)
> > :
> >
> > PROC main ()
> >   WHILE TRUE
> >     PAR
> >       do(13, 1000, 2000)
> >       do(12, 2000, 4000)
> >       do(11, 700, 1500)
> > :
>
> If I understand correctly, you just need to move the logic around a bit.
> What happens with the PAR is that all the sub-processes do their own
> thing, but then wait for each other to finish (as per PAR semantics),
> at which point the WHILE loop flies around and everything starts all
> over again.
>
> It sounds like you want these things to be entirely independent, so
> (fairly simply) move the WHILE loop inside the process, e.g.:
>
> PROC do (VAL INT pin, timeOn, timeOff)
>   WHILE TRUE
>     SEQ
>       ... do stuff
> :
>
> PROC main ()
>   PAR
>     do(13, 1000, 2000)
>     do(12, 2000, 4000)
>     do(11, 700, 1500)
> :
>
>
> Alternatively, and equivalent to the above [but not your original code],
> you could just mangle PROC main() to swap the WHILE and PAR around:
>
> PROC main ()
>   PAR
>     WHILE TRUE
>       do(13, 1000, 2000)
>     WHILE TRUE
>       do(12, 2000, 4000)
>     WHILE TRUE
>       do(11, 700, 1500)
> :
>
>
> However, having the WHILE loop inside the 'do' process is cleaner and a
> little more obvious -- unless there are situations where you don't want
> this
> behaviour.
>
>
> Hope that helps,
>
> -- Fred
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.concurrency.cc/pipermail/users/attachments/20121028/79b7a39b/attachment.htm>


More information about the users mailing list