#!/bin/csh
# Launch the MMC portal service. The portal has two IP interfaces;
# the "public address" is the IP address used by shore-based clients
# of the portal. The "private address" is the address used by the
# deployed at-sea platform (e.g. a PPP-RF interfaces). 
#
# This script accepts a "-start" option, which allows the user to
# specify a packet retrieval criterion based on sensor packet timestamp.
# The portal will only attempt to retrieve packets that have a timestamp
# which is later than the "-start" time.

if ($#argv < 3) then
  echo "usage: $0 [-since timestamp] publicPortalAddress privatePortalAddress mooringHost"
  echo "'-since' option specifies packet timestamp retrieval constraint."
  echo "Valid timestamp formats:"
  echo "   mm/dd/yyyy        Get packets timestamped later than mm/dd/yyyy"
  echo "   mm/dd/yyyyTh:m:s  Get packets timestamped later than mm/dd/yyyy, h:m:s"
  echo "   now               Get packets timestamped later than now"
  echo "   0                 Get all packets"
  echo "Specify all times in 24 hour LOCAL time"
  exit 1
endif

# By default, retrieve all packets from beginning of time.
set startTime = "0"

if ("$argv[1]" == "-since" || "$argv[1]" == "-start") then
  shift
  set startTime = $argv[1]:q
  shift
endif

set publicAddress = $argv[1]
set privateAddress = $argv[2]
set mooringAddress = $argv[3]

# Socket timeout in milliseconds
set socketTimeout = 60000

echo "Starting MMC portal service"
java -cp $SIAM_HOME/classes:.:$SIAM_HOME/jars/ssds_ISI.jar -Djava.security.policy=$SIAM_HOME/properties/policy -Djava.rmi.server.codebase=http://${publicAddress}:8085/ -Djava.rmi.server.hostname=$privateAddress -Dsun.rmi.transport.tcp.readTimeout=$socketTimeout moos.operations.portal.PortalServer -start $startTime:q $argv 

