runfdcmp



#!/bin/csh -f
#########################################################################
#
#  Filename runfdcmp
#
#  Purpose:	
#	This is a csh script for executing dcmpftst.860
#
#  To run:
#	First make the executable for dcmpftst.860
#	Next execute this script using the following command:
#		dcmpftst [options]
#	where [options] are:
#       -v: Enables verbose mode
#       -df <filename>: filename for decompressor register and
#               codepage binary file.
#       -cfn <filename>: filename for compressed data frame
#               to be decompressed.
#       -i: Reset and initialize system
#       -ofn <filename>: filename for  decompressed data output
#       -l: Set linear mode.
#       -h: Set half resolution mode
#
#  See also:
#	dcmpftst.c
#	dcmpftst.h
#	
#
#  Notes:
#	
#
#########################################################################
#########################################################################
#
# Revision history
#
#   2-6-96 LRE Created
#   LRE 2-22-96 Ready to run?
#
#########################################################################

date

# First we initialize the local variables

set board_exec = ./dcmpftst.860
set dcmpbin = ./des_data.dat
set cmp_frame = ./tst96.dat
# set cmp_frame = ./roitst.dat
set verbose_flag = ''
set half_res = ''
set options = ''
set init = 0
set out_file = ./decomp.out
set lin_flag = ''

############################################################################

# Next we test to see if the executable has been created.

if (! -e $board_exec) then
  echo "ERROR: Execution of this script requires that $board_exec exist."
  echo "       It can be created by executing make. Once created, rerun this"
  echo "       script."
  exit 1
endif

############################################################################

# test for any options

set i = 1
while ($i <= $#argv)
  switch ("$argv[$i]")
  case -df:
    @ i++
    if ($i > $#argv) then
      echo "ERROR: Missing filename for -df option"
      echo "Exiting runfdcmp script."
      exit 2
    endif

    if (! -e $argv[$i]) then
        echo "ERROR: $argv[$i] for option -df not found."
        echo "Exiting runfdcmp script."
        exit 3
    endif

    set dcmpbin = $argv[$i]
    breaksw

  case -cfn:
    @ i++
    if ($i > $#argv) then
      echo "ERROR: Missing filename for -cfn option"
      echo "Exiting runfdcmp script."
      exit 2
    endif

    if (! -e $argv[$i]) then
        echo "ERROR: $argv[$i] for option -dfn not found."
        echo "Exiting runfdcmp script."
        exit 3
    endif

    set cmp_frm = $argv[$i]
    breaksw

  case -ofn:
    @ i++
    if ($i > $#argv) then
      echo "ERROR: Missing filename for -ofn option"
      echo "Exiting runfdcmp script."
      exit 2
    endif

    set out_file = $argv[$i]
    breaksw


  case -v:
    set verbose_flag = -v
    set options = -v
    breaksw

  case -i:
    set init = -1 
    breaksw

  case -l:
    set lin_flag = -l 
    breaksw

  case -h:
    set half_res = -h 
    breaksw

  default:
    echo "ERROR: Illegal option supplied: $argv[$i]"
    echo "       Legal options: -df <filename>, -v, -i"
    exit 3
  endsw

  @ i++
end


############################################################################

# Initialize the system if -i option


if ($init) then

# reset ce's
    echo Resetting compute elements

    set i = 0
    while ($i <= 3)
        echo resetting caproc$i
        /usr/mercury/bin/sysmc $verbose_flag -f caproc$i reset

    set rc = $status
    if ($rc) then
        echo "ERROR: Unable to reset caproc$i"
        echo "Exiting runfdcmp"
        exit $rc
    endif

    @ i++

    end

# run configuration process

    echo Running configmc init.
    /usr/mercury/bin/configmc $verbose_flag -cf /usr/mercury/etc/mcv6roi.cfg init

    set rc = $status
    if ($rc) then
        echo "ERROR: configmc init failed"
        echo "Exiting runfdcmp"
        exit $rc
    endif

# run sysmc init process

    echo Running sysmc init
    /usr/mercury/bin/sysmc $verbose_flag -f caproc0 init caproc1 caproc2 caproc3

    set rc = $status
    if ($rc) then
        echo "ERROR: sysmc init failed"
        echo "Exiting runfdcmp"
        exit $rc
    endif

# load rio driver

    echo Loading rio driver
    /usr/mercury/bin/sysmc $verbose_flag -f caproc0 load /usr/mercury/lib/rio_driver.860

    set rc = $status
    if ($rc) then
        echo "ERROR: rio driver load failed"
        echo "Exiting runfdcmp"
        exit $rc
    endif

# endif init
endif


############################################################################


# Now we are ready to run

echo Running $board_exec on caproc0
runmc -ce 2 -h 0x40000 $verbose_flag $board_exec $dcmpbin $cmp_frame $out_file $options $lin_flag $half_res


set rc = $status
if ($rc) then
  echo $board_exec failed, returned status = $rc
  exit $rc
endif

echo $board_exec ran ok
date
exit 0