<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks.  This is fascinating stuff.  And the introduction of the timer guard has worked a treat!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>      WHILE TRUE<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>        SEQ<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>          tim ? t<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>          PRI ALT<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>            CatOut ? SIGNAL<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>              digital.write (ArmedLED, LOW)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>            CatIn ? SIGNAL<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>              digital.write (ArmedLED, HIGH)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>            tim ? AFTER t PLUS 200<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>              digital.write (SprayLED, HIGH)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>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.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>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.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>CatIn Level</span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>à</span><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>Loop process to output In = TRUE </span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>à</span><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>                ^    |                            |  <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>                Interrupts                            </span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>à</span><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>    ALT </span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>à</span><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>InOut channel<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>                |    v                            |<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>CatOut Level </span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>à</span><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'> Loop process to output In = FALSE </span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>à</span><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>So that is what I will try next.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Regards<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> jadudm@gmail.com [mailto:jadudm@gmail.com] <b>On Behalf Of </b>Matt Jadud<br><b>Sent:</b> 20 December 2012 17:46<br><b>To:</b> Carl Ritson<br><b>Cc:</b> james@barbet.co.uk; C.CC USERS<br><b>Subject:</b> Re: [C.CC USERS] Help needed with PRI ALT<o:p></o:p></span></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>Thank you, Carl. I missed that in a quick note last night. (James and I were working on getting his list membership sorted out.)<o:p></o:p></p><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>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:<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal><a href="http://www.jadud.com/dl/pdf/jadud-simpson-jacobsen-sigcse2008.pdf">http://www.jadud.com/dl/pdf/jadud-simpson-jacobsen-sigcse2008.pdf</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>and a slightly more complex one is in this paper:<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal><a href="http://www.jadud.com/dl/pdf/jacobsen-jadud-kilic-sampson-cpa2011.pdf">http://www.jadud.com/dl/pdf/jacobsen-jadud-kilic-sampson-cpa2011.pdf</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>If someone on the list could point me at a more &quot;legoland&quot; 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.&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>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.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Keep asking questions!<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Cheers,<o:p></o:p></p></div><div><p class=MsoNormal>Matt<o:p></o:p></p></div></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>On Thu, Dec 20, 2012 at 9:24 AM, Carl Ritson &lt;<a href="mailto:C.G.Ritson@kent.ac.uk" target="_blank">C.G.Ritson@kent.ac.uk</a>&gt; wrote:<o:p></o:p></p><p class=MsoNormal>Hi James,<br><br>Because your PRI ALT is in a tight loop with a SKIP guard the system<br>scheduler never gets a chance to run and no other processes can be run<br>and read/drive the pins. At least that is what it looks like is<br>happening to me.<br><br>You have three option:<br>1. Add a delay after digital.write (SprayLED, HIGH).<br>2. Add a RESCHEDULE() after digital.write (SprayLED, HIGH).<br>3. Use a timer guard to activate digital.write (SprayLED, HIGH) if<br>CatIn! and CatOut! do not signal within a set time period.<br><br>All of these will allow the scheduler to run the other processes.<br><br>Cheers,<br><br>Carl<br><br><br>2012/12/20 James Brown &lt;<a href="mailto:james.brown4994@gmail.com">james.brown4994@gmail.com</a>&gt;:<o:p></o:p></p><div><div><p class=MsoNormal>&gt; Can anyone help me with PRI ALT.<br>&gt;<br>&gt; I am a beginner and have been trying to figure out how to use occam to build<br>&gt; a simple cat deterrent.<br>&gt;<br>&gt; I have the following code. &nbsp;It is not representative of what I want it to do<br>&gt; eventually but rather to experiment with PRI ALT.<br>&gt;<br>&gt; I am expecting that a signal from CatOut or CatIn should drive ArmedLED low<br>&gt; or high. &nbsp;However it appears to ignore these signals. &nbsp;I appears always to<br>&gt; default to final TRUE &amp; SKIP condition. &nbsp;I am stuck and I don't know how to<br>&gt; debug it. &nbsp;Any ideas gratefully received.<br>&gt;<br>&gt; #INCLUDE &quot;plumbing.module&quot;<br>&gt;<br>&gt; VAL OutPin IS 2 :<br>&gt; VAL InPin IS 3 :<br>&gt; VAL ArmedLED IS 12 :<br>&gt; VAL SprayLED IS 13 :<br>&gt;<br>&gt; PROC blink.pin (CHAN SIGNAL out!)<br>&gt; &nbsp; WHILE TRUE<br>&gt; &nbsp; &nbsp; SEQ<br>&gt; &nbsp; &nbsp; &nbsp; delay (500)<br>&gt; &nbsp; &nbsp; &nbsp; out ! SIGNAL<br>&gt; :<br>&gt;<br>&gt; PROC monitor.pir ()<br>&gt; &nbsp; SEQ<br>&gt; &nbsp; &nbsp; digital.mode (InPin, INPUT)<br>&gt; &nbsp; &nbsp; digital.mode (OutPin, INPUT)<br>&gt; &nbsp; &nbsp; digital.mode (ArmedLED, OUTPUT)<br>&gt; &nbsp; &nbsp; digital.mode (SprayLED, OUTPUT)<br>&gt; &nbsp; &nbsp; digital.write (ArmedLED, LOW)<br>&gt; &nbsp; &nbsp; digital.write (SprayLED, LOW)<br>&gt; &nbsp; &nbsp; CHAN SIGNAL CatIn, CatOut:<br>&gt; &nbsp; &nbsp; PAR<br>&gt; &nbsp; &nbsp; &nbsp; blink.pin (CatOut!)<br>&gt; &nbsp; &nbsp; &nbsp; delay (300)<br>&gt; &nbsp; &nbsp; &nbsp; blink.pin (CatIn!)<br>&gt; &nbsp; &nbsp; &nbsp; WHILE TRUE<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; PRI ALT<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CatOut ? SIGNAL<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digital.write (ArmedLED, LOW)<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CatIn ? SIGNAL<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digital.write (ArmedLED, HIGH)<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TRUE &amp; SKIP<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digital.write (SprayLED, HIGH)<br>&gt; :<br>&gt;<br>&gt;<o:p></o:p></p></div></div><p class=MsoNormal>&gt; _______________________________________________<br>&gt; users mailing list<br>&gt; <a href="mailto:users@concurrency.cc">users@concurrency.cc</a><br>&gt; <a href="http://lists.concurrency.cc/mailman/listinfo/users" target="_blank">http://lists.concurrency.cc/mailman/listinfo/users</a><br>&gt;<br><br>_______________________________________________<br>users mailing list<br><a href="mailto:users@concurrency.cc">users@concurrency.cc</a><br><a href="http://lists.concurrency.cc/mailman/listinfo/users" target="_blank">http://lists.concurrency.cc/mailman/listinfo/users</a><o:p></o:p></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></div></body></html>