# This configuration file is Python code.  You should not
# need to change it; but if you do, you need to know that
# in Python, the *indentation matters*.

# The following will normally be empty lists, like this:
#
#ignore_ADCPs = []
#ignore_other_sensors = []
#
# But if you want to run with only a subset of the ADCPs
# and/or ancillary sensors that are defined in this file,
# you can list the ones you want to ignore like this:
#
#ignore_ADCPs = ['wh300', 'os75']
#ignore_other_sensors = ['GPS']
#
# In this case, you are listing the 'instrument' field of each
# ADCP or sensor you wish to exclude.
#

ignore_ADCPs = []
ignore_other_sensors = []
use_publishers = True


# 2-letter abbreviation for logging file prefix and constructing dbase name;
# read by procsetup.py
shipabbrev = "tt"


ADCPs = [
        { 'instrument'  :  'os75',
          'setup'       :  'rdi_setup',      ## RENAME ?? rdi_setup.py
          'terminal'    :  'oswh_term',
          'defaultcmd'  :  'os75_default.cmd',
          'commands'    :  ('EA05810',),
          'datatypes'   :  ('os75bb', 'os75nb'),
          'wakeup_baud' :  9600
        },       # this comma should be there!
        ]


# Do not edit the next three lines:
common_opts = '-f %s -F -m 1 -H 2 ' % (shipabbrev,)
nb_opts =   '-lE -c -I'          # raw data, write a log file, log errors
oswh_opts = '-lE -c -O -I'       # -O for OS/WH data format
                                  # -c for checksum, -I to initiate pinging

sensors = [

        { 'instrument'  :  'os75',       # Passive logging of OS
          'device'      :  'ttyUSB7',
          'baud'        :   38400,       # Some errors at 115200.
          'format'      :  'binary',
          'subdir'      :  'os75',
          'ext'         :  'raw',
          'opt'         :  oswh_opts,
        }, # Note -I option for new ser_bin.

        { 'instrument'  :  'CNav',
          'device'      :  'ttyUSB6',   #ttyR1 for comtrol
          'baud'        :   4800,
          'format'      :  'ascii',
          'subdir'      :  'gps_cnav',  #primary position for processing
          'ext'         :  'gps',
          'strings'     :  ('$GPGGA',),
          'messages'    :  ('gps',),
          'opt'         :  '-c -Y2',     # $PYRTM
         },

        { 'instrument'  :  'POS/MVv4',
          'device'      :  'ttyUSB4',   #ttyR6 for comtrol
          'baud'        :   9600,
          'format'      :  'ascii',
          'subdir'      :  'posmv4',
          'ext'         :  'pmv',
          'strings'     :   ('$INGGA', '$PASHR', '$INHDT'),
          'messages'    :  ('gps', 'pmv', 'hdg'),
          'opt'         :  '-c -Y2',     # $PYRTM
         },

        { 'instrument'  :  'POS/MVv5',
          'device'      :  'ttyUSB5',   #ttyR6 for comtrol
          'baud'        :   9600,
          'format'      :  'ascii',
          'subdir'      :  'posmv5',
          'ext'         :  'pmv',
          'strings'     :   ('$INGGA', '$PASHR', '$INHDT'),
          'messages'    :  ('gps', 'pmv', 'hdg'),
          'opt'         :  '-c -Y2',     # $PYRTM
         },

        { 'instrument'  :  'Gyro1', # Sperry NAVIGAT 3000
          'device'      :  'ttyUSB1',   #ttyR5 for comtrol
          'baud'        :   4800,
          'format'      :  'ascii',
          'subdir'      :  'gyro1',
          'ext'         :  'hdg',
          'strings'     :  ('$HEHDT',),
          'messages'    :  ('hdg',),
          'opt'         :  '-Y2 -s3', ## 6Hz: take every 3rd message (-s3)
         },

        { 'instrument'  :  'Comparitor', # apparently a comparitor  "gyro2"
          'device'      :  'ttyUSB2',   #ttyR5 for comtrol
          'baud'        :   4800,
          'format'      :  'ascii',
          'subdir'      :  'comparitor',
          'ext'         :  'hdg',
          'strings'     :  ('$HEHDT',),
          'messages'    :  ('hdg',),
          'opt'         :  '-Y2 -s3', ## 6Hz: take every 3rd message (-s3)
         }
      ] 
                                          ##  no checksum on these


## enabling or disabling this occurs in uhdas_cfg.py
## speedlog: enabled in /home/adcp/config/uhdas_cfg.py
speedlog_config = {
    'instrument'        : 'os75',
    'serial_device'     : '',     # no serial out (else: '/dev/ttyUSB1',)
    'baud'              : 9600,
    'zmq_from_bin'      : "tcp://127.0.0.1:38010",  # port to read os75 indexing
    'pub_addr'          : "tcp://127.0.0.1:38020",  # port to publish speedlog #NO SPACES
    'eth_port'          : "eno1",   # for web_speedlog  <======    
#    'heading_offset'    : xx.x,  # uses h_align; better would be from EA_estimator.py
    'scale'             : 1.0,     # multiplies velocity measurement
    'bins'              : (1,3),   # zero-based; input to python slice()
    'navg'              : 5,       # pings to average
}


## this section describes...
publishers = [
               {
               'subdir'      :  'gps_cnav',
               'pub_addr'    :  'tcp://127.0.0.1:38000', # uses this port
               'sample_opts' :  '-c -Y2 -s60',     # $PYRTM
               },
             ]

#### DO NOT CHANGE the following ################

ADCPs = [A for A in ADCPs if A['instrument'] not in ignore_ADCPs]
sensors = [S for S in sensors if S['instrument'] not in ignore_ADCPs]
sensors = [S for S in sensors if S['instrument'] not in ignore_other_sensors]

from uhdas.uhdas import make_publishers

# append zmq_from_bin port to opts in appropriate ADCP sensor block
make_publishers.modify_sensors_for_speedlog(sensors, speedlog_config)

# substitute publishers into sensors for zmq publishing
if use_publishers==True:
    make_publishers.modify_sensors_and_publishers(sensors, publishers)