[C.CC USERS] Help needed with PRI ALT

James Brown james.brown4994 at gmail.com
Thu Dec 20 10:01:59 GMT 2012


Can anyone help me with PRI ALT.

I am a beginner and have been trying to figure out how to use occam to build
a simple cat deterrent.

I have the following code.  It is not representative of what I want it to do
eventually but rather to experiment with PRI ALT.

I am expecting that a signal from CatOut or CatIn should drive ArmedLED low
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 to
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!)
  WHILE TRUE
    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)
:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.concurrency.cc/pipermail/users/attachments/20121220/23a2bf94/attachment.htm>


More information about the users mailing list