--
--	simple.occ -- simple user-defined channels
--	Copyright (C) 2002 Fred Barnes <frmb2@ukc.ac.uk>
--
--	This program is free software; you can redistribute it and/or modify
--	it under the terms of the GNU General Public License as published by
--	the Free Software Foundation; either version 2 of the License, or
--	(at your option) any later version.
--
--	This program is distributed in the hope that it will be useful,
--	but WITHOUT ANY WARRANTY; without even the implied warranty of
--	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--	GNU General Public License for more details.
--
--	You should have received a copy of the GNU General Public License
--	along with this program; if not, write to the Free Software
--	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--


--{{{  includes, uses
#INCLUDE "udc.module"
#INCLUDE "course.module"
--}}}  

--{{{  PROC timed.outputs (VAL INT delay, CHAN INT out!)
PROC timed.outputs (VAL INT delay, CHAN INT out!)
  TIMER tim:
  INT t, v:
  SEQ
    v := MOSTPOS INT
    tim ? t
    t := (t PLUS delay)
    WHILE TRUE
      SEQ
        out ! v
        tim ? AFTER t
        t := (t PLUS delay)
        v := (v PLUS 1)
:
--}}}  

--{{{  PROC printed.inputs (CHAN INT in?, CHAN BYTE out!)
PROC printed.inputs (CHAN INT in?, CHAN BYTE out!)
  WHILE TRUE
    INT x:
    SEQ
      in ? x
      out.int (x, 0, out!)
      out ! '*n'
:
--}}}  

--{{{  PROC simple (CHAN BYTE kyb?, scr!, err!)
PROC simple (CHAN BYTE kyb?, scr!, err!)

  INT addr:
  SEQ
    udc.softchan.alloc (addr)

    PLACED CHAN INT c addr:
    PAR
      timed.outputs (500000, c!)
      printed.inputs (c?, scr!)
:
--}}}  

