-- CommunicationControl.mesa  (last edited by: BLyon on: January 16, 1981  3:01 PM)
-- Function: The control module for Pilot's Communication configuration.

DIRECTORY
  CommunicationInternal USING [
    ChecksumsImpl, EchoServerImpl, PacketExchangeImpl, PilotCommUtil, RouterImpl,
    RoutingTableImpl, SocketImpl, NetworkStreamMgr, PacketStreamMgr],
  CommunicationPrograms USING [],
  DriverDefs USING [CommPackageGo, CommPackageOff, Boss],
  Echo USING [CreateServer, DeleteServer],
  OISCP USING [OiscpPackageReady],
  Router USING [OisRouterOff, OisRouterOn],
  SocketInternal USING [SocketOn],
  StatsOps USING [StatsHot];

CommunicationControl: MONITOR
  IMPORTS
    CommunicationInternal, DriverDefs, Echo, OISCP, Router, SocketInternal,
    StatsOps
  EXPORTS OISCP, CommunicationPrograms =
  BEGIN

  -- monitor data
  useCount: CARDINAL;

  StartupCommunication: PROCEDURE =
    -- module initialization:
    BEGIN
    useCount ← 0;
    START StatsOps.StatsHot;
    START CommunicationInternal.PilotCommUtil;
    -- AdjustSystemBufferParms[];
    START DriverDefs.Boss;
    START CommunicationInternal.ChecksumsImpl;
    START CommunicationInternal.RouterImpl;
    START CommunicationInternal.RoutingTableImpl;
    START CommunicationInternal.SocketImpl;
    START CommunicationInternal.PacketExchangeImpl;
    START CommunicationInternal.EchoServerImpl;
    OiscpPackageMake[];
    START CommunicationInternal.PacketStreamMgr;
    START CommunicationInternal.NetworkStreamMgr;
    END;

  InitializeCommunication: PUBLIC PROCEDURE =
    -- module initialization:
    BEGIN
    -- the start trap takes care of everything

    END;


  -- The procedure that a normal client calls to start things either before or
  -- after the MakeImage.

  OiscpPackageMake: PUBLIC ENTRY PROCEDURE =
    BEGIN
    IF (useCount ← useCount + 1) > 1 THEN RETURN;
    OISCP.OiscpPackageReady[];
    DriverDefs.CommPackageGo[];
    Router.OisRouterOn[];
    SocketInternal.SocketOn[];
    Echo.CreateServer[];
    END;

  -- The procedure that a normal client calls to stop things

  OiscpPackageDestroy: PUBLIC ENTRY PROCEDURE =
    BEGIN
    IF (useCount = 0) THEN RETURN;
    IF (useCount ← useCount - 1) > 0 THEN RETURN;
    Echo.DeleteServer[];
    Router.OisRouterOff[];
    DriverDefs.CommPackageOff[];
    END;

  -- main line code

  StartupCommunication[];

  END.  -- CommunicationControl module
LOG
Time: January 20, 1980  11:01 AM	By: Dalal	Action: changed initialization order.
Time: February 5, 1980  8:31 PM	By: Dalal	Action: started of SimpleHeapImpl.
Time: February 5, 1980  9:16 PM	By: Dalal	Action: added Echo Server.
Time: August 18, 1978  11:37 AM	By: Knutsen	Action: Module now STARTed by  InitializeCommunication[].
Time: May 6, 1980  6:35 PM	By: BLyon	Action: Temp removed CommunicationPrograms from EXPORTS; added  mainline  code so that Communications can be build/started seperately from TestPilotKernel ..  tajo.  
Time: August 11, 1980  3:39 PM	By: BLyon	Action: made it so that communication can start on a start trap (added running: BOOLEAN). 
Time: August 20, 1980  10:38 AM	By: BLyon	Action: added START ChecksumsImpl 
Time: October 22, 1980  3:56 PM	By: BLyon	Action: IF (useCount=0) THEN RETURN in OiscpPackageDestroy.