

#INCLUDE "Regbankdefs.inc"
#INCLUDE "hostio.inc"

PROC inputprocess(CHAN OF SP fs,ts,
                  []CHAN OF INPUT to.proc,
                  CHAN OF INT ABus,BBus,
                   CHAN OF ANY Ack)
  #USE "hostio.lib"
  #USE "string.lib"

  
  INT i,number,adata,bdata,time:  
  BOOL ok,any,more.results,result,more.data:
  TIMER clock:
  VAL INT Timeout IS 300:

  SEQ
    i:=0
    so.write.string.nl(fs,ts,"READING TEST DATA...")
    so.read.echo.any.int(fs,ts,number,result)
    so.write.string.nl(fs,ts,"")
    IF
      number = (-999)
        more.data:=FALSE
      TRUE
        more.data:=TRUE

    WHILE more.data
      SEQ  
        IF
          number=(-888)
            SEQ
              so.write.string.nl(fs,ts,"---------------- ")
              to.proc[i]!end.of.data
              i:=i+1
          TRUE
            to.proc[i]!data;number
        so.read.echo.any.int(fs,ts,number,result)
        so.write.string.nl(fs,ts,"")

        IF
          number = (-999)
            more.data:=FALSE
          TRUE
            more.data:=TRUE
            

    -- output results
    so.write.string.nl(fs,ts,"RESULTS....")
    more.results:=TRUE
    WHILE more.results
      SEQ
        clock?time
        ALT
          ABus?adata
            BBus?bdata
          clock?AFTER time PLUS Timeout
            more.results:=FALSE
        IF 
          more.results= TRUE        
            PAR
              Ack!any
              SEQ
                so.write.int(fs,ts,adata,0)
                so.write.nl(fs,ts)
                so.write.int(fs,ts,bdata,0)
                so.write.nl(fs,ts)
          TRUE
            SKIP
    so.exit(fs,ts,sps.success)

   

:
  
         
       
        
        
      
