#!/usr/bin/env python
#
# As of 2004/09/21, this looks quite obsolete.  the only
# update has been changing the names of subdirectories
# adu2 and pcode to ashtech and gpsnav, respectively.
#
# It may still be useful as an illustration of how
# incremental rbinning is done.
#

import time
import incr_class
import os
import serasc2bin
import glob

yearbase = 2002
dir_asc_base = '/home/data/km0202/raw'
dir_bin_base = '/home/data/km0202/rbin'

subdir_messages =  {'ashtech': ('gps', 'adu'),
            'gyro': ('hdg',),
            'gpsnav': ('gps',),
            'posmv': ('gps', 'pmv')}


comment = '''
for subdir in subdir_messages.keys():
   A = serasc2bin.asc2bin(yearbase = yearbase, showbad = 1,
                           outfiledir = os.path.join(dir_bin_base, subdir),
                           )
   for msg in subdir_messages[subdir]:
      files = glob.glob(os.path.join(dir_asc_base, subdir, 'km*'))
      A.translate_files(files, message = msg)
''' # end comment



T = incr_class.Translate(dir_asc_base = dir_asc_base,
                         dir_bin_base = dir_bin_base,
                         yearbase = yearbase,
                         # gzip = 1, # Doesn't work; have two threads
                         redo = 0,      # reading the same file.
                         showbad = 1,
                         sleepseconds = 1,
                         maxsleeps = 5,
                         subdir_messages = subdir_messages)



T.start()
while T.running:
   try:
      time.sleep(1)
   except:  # Ctl-C
      T.stop()

