#!/usr/local/bin/tops -s /usr/local/tops/sys -u /opt/mytops/usr/
{  File topse  February 2008

   Copyright (C) 2008  Dale R. Williamson

   Real time data collection 
}
\-----------------------------------------------------------------------

\  Words.

   CATMSG push no catmsg

   "mget.v" source

   inline: START ( --- )
      host "diego" = 
      host "plunger" = or
      host "riggo" = or
      IF NIST_DELTA ELSE NIST_SYNC THEN

      soonest_task (f) IF COLLECT_START ELSE COLLECT_END THEN
   end

   pull catmsg

\-----------------------------------------------------------------------

\  SYSOUT must be defined for daemon output.  These lines define a
\  LOG file and set SYSOUT to LOG file:
   "HOME" env "topse.log" catpath "LOG" book
   LOG set_sysout \ SYSOUT will be LOG

\  Write the first lines to LOG file:
   "-" 72 cats nl dot nl
   "PID " getpid intstr + spaced date + dot nl

\  Run START on an ALARM that gives DSERVER time to start:
   2 (sec) "START" ALARM

\-----------------------------------------------------------------------

\  Start a daemon server, running forever.

\  This server is only for the purpose of connecting for maintenance
\  and debugging, through word remoteprompt().  Its listening port
\  number is message TOPSE_SERVER on msgcomm.
   "TOPSE_SERVER" msgGet drop \ remove old port number

   "*" def_port nextport (nPort)
   (nPort) dup intstr "TOPSE_SERVER" msgPut \ put new port number
   (nPort) DSERVER

\-----------------------------------------------------------------------

;  Appendix

   Debugged and tested, but not used:

   inline: COLLECTOR_PORT ( --- n) \ server port of collector
      [ "HOME" env "topse.log" catpath "LOG" book ]
      LOG asciiload (hT) dup        
      (hT hT) "DSERVER:" grepr 1 endmost reach 7 word
      IF number drop 
      ELSE -1
      THEN
   end

