[C.CC USERS] Help needed with PRI ALT

James Brown james.brown4994 at gmail.com
Thu Dec 20 19:14:38 GMT 2012

Thanks.  This is fascinating stuff.  And the introduction of the timer guard
has worked a treat!




          tim ? t

          PRI ALT

            CatOut ? SIGNAL

              digital.write (ArmedLED, LOW)

            CatIn ? SIGNAL

              digital.write (ArmedLED, HIGH)

            tim ? AFTER t PLUS 200

              digital.write (SprayLED, HIGH)


I completely agree and part of the problem is that I am diving in rather
than systematically sitting down with the texts available and working
through the theory carefully.


In fact what I need to do is something like this, which if my thinking is
right will do the same thing without the need for the PRI ALT and delay.


CatIn LevelàLoop process to output In = TRUE à

                ^    |                            |  

                Interrupts                            à    ALT àInOut

                |    v                            |

CatOut Level à Loop process to output In = FALSE à



So that is what I will try next.




From: jadudm at gmail.com [mailto:jadudm at gmail.com] On Behalf Of Matt Jadud
Sent: 20 December 2012 17:46
To: Carl Ritson
Cc: james at barbet.co.uk; C.CC USERS
Subject: Re: [C.CC USERS] Help needed with PRI ALT


Thank you, Carl. I missed that in a quick note last night. (James and I were
working on getting his list membership sorted out.)


James, another useful thing you might consider is drawing a dataflow diagram
of your application, and thinking about how the data will flow from one
parallel process to another. Some simple ones are in this paper:




and a slightly more complex one is in this paper:




If someone on the list could point me at a more "legoland" resource, that
would be great. I know there must be some material that will help James in
thinking about how things flow from point A to point B in his app. 


It feels a bit like you're wrestling with two things: the language, and the
paradigm. I'm thinking that we might be able to help you tease those apart a
little bit.


Keep asking questions!





On Thu, Dec 20, 2012 at 9:24 AM, Carl Ritson <C.G.Ritson at kent.ac.uk> wrote:

Hi James,

Because your PRI ALT is in a tight loop with a SKIP guard the system
scheduler never gets a chance to run and no other processes can be run
and read/drive the pins. At least that is what it looks like is
happening to me.

You have three option:
1. Add a delay after digital.write (SprayLED, HIGH).
2. Add a RESCHEDULE() after digital.write (SprayLED, HIGH).
3. Use a timer guard to activate digital.write (SprayLED, HIGH) if
CatIn! and CatOut! do not signal within a set time period.

All of these will allow the scheduler to run the other processes.



2012/12/20 James Brown <james.brown4994 at gmail.com>:

> Can anyone help me with PRI ALT.
> I am a beginner and have been trying to figure out how to use occam to
> a simple cat deterrent.
> I have the following code.  It is not representative of what I want it to
> eventually but rather to experiment with PRI ALT.
> I am expecting that a signal from CatOut or CatIn should drive ArmedLED
> or high.  However it appears to ignore these signals.  I appears always to
> default to final TRUE & SKIP condition.  I am stuck and I don't know how
> debug it.  Any ideas gratefully received.
> #INCLUDE "plumbing.module"
> VAL OutPin IS 2 :
> VAL InPin IS 3 :
> VAL ArmedLED IS 12 :
> VAL SprayLED IS 13 :
> PROC blink.pin (CHAN SIGNAL out!)
>     SEQ
>       delay (500)
>       out ! SIGNAL
> :
> PROC monitor.pir ()
>   SEQ
>     digital.mode (InPin, INPUT)
>     digital.mode (OutPin, INPUT)
>     digital.mode (ArmedLED, OUTPUT)
>     digital.mode (SprayLED, OUTPUT)
>     digital.write (ArmedLED, LOW)
>     digital.write (SprayLED, LOW)
>     CHAN SIGNAL CatIn, CatOut:
>     PAR
>       blink.pin (CatOut!)
>       delay (300)
>       blink.pin (CatIn!)
>       WHILE TRUE
>         PRI ALT
>           CatOut ? SIGNAL
>             digital.write (ArmedLED, LOW)
>           CatIn ? SIGNAL
>             digital.write (ArmedLED, HIGH)
>           TRUE & SKIP
>             digital.write (SprayLED, HIGH)
> :

> _______________________________________________
> users mailing list
> users at concurrency.cc
> http://lists.concurrency.cc/mailman/listinfo/users

users mailing list
users at concurrency.cc


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.concurrency.cc/pipermail/users/attachments/20121220/eb99ea5b/attachment-0001.htm>

More information about the users mailing list