/* ---------------------------------------------------------------------- */ 
/* S150Formats.h                                                          */ 
/* ---------------------------------------------------------------------- */ 
/*                                                                        */ 
/* (c) Copyright 2007  EdgeTech,                                          */ 
/*                                                                        */ 
/* This file contains proprietary information, and trade secrets of       */ 
/* EdgeTech, and may not be disclosed or reproduced without the prior     */ 
/* written consent of EdgeTech.                                           */ 
/*                                                                        */ 
/* EdgeTech is not responsible for the consequences of the use or misuse  */ 
/* of this software, even if they result from defects in it.              */ 
/*                                                                        */ 
/* ---------------------------------------------------------------------- */ 
/*                                                                        */ 
/* This file contains the EdgeTech headers for reading S-150 data from    */ 
/* the input serial data stream.                                          */ 
/* ---------------------------------------------------------------------- */ 

#pragma once


/* ---------------------------------------------------------------------- */ 
/* Interface board data packet format                                     */ 
/* ---------------------------------------------------------------------- */ 

typedef struct
{ /*  Offset   : Description                                              */ 
  /*   0 -   3 : Header ID string                                         */ 
  /* header string should always be $ADC                                  */ 
  unsigned char   headerID[4];

  /*   4 -   5 : Battery Voltage                                          */ 
  /* battery voltage = (50.0 * ((value & 0x0fff) / 4096.0)) + 0.35 volts  */ 
  unsigned short  batteryVoltage;

  /*   6 -   7 : Towfish Cable Voltage                                    */ 
  /* towfish cable voltage = 100.0 * ((value & 0x0fff) / 4096.0) volts    */ 
  unsigned short  towfishCableVoltage;

  /*   8 -   9 : Camera Depth                                             */ 
  /* camera depth = 2.5 * ((value & 0x0fff) / 4096.0)                     */ 
  unsigned short  cameraDepth;

  /*  10 -  11 : Cable Current                                            */ 
  /* cable current = 2.5 * ((value & 0x0fff) / 4096.0) Amperes            */ 
  unsigned short  cableCurrent;

  /*  12 -  14 : Reserved                                                 */ 
  /* not specified in received documentation                              */ 
  unsigned char   reserved[3];

  /*  15 -  15 : Checksum                                                 */ 
  /* checksum 8 bit XOR                                                   */ 
  unsigned char   checksum;

  /*  16 -  17 : Asterisks                                                */ 
  /* packet should always end with two asterisks **                       */ 
  unsigned char   asterisks[2];

}  InterfaceBoardDataType;


/* ---------------------------------------------------------------------- */ 
/* S-150 towfish data packet header format                                */ 
/* ---------------------------------------------------------------------- */ 

typedef struct
{ /*  Offset   : Description                                              */ 
  /*   0 -   5 : Header ID                                                */ 
  /* header string should always be TK2004                                */ 
  unsigned char   headerID[6];

  /*   6 -   7 : Block counter                                            */ 
  unsigned short  blockCounter;

  /*   8 -   9 : Altitude - first peak                                    */ 
  unsigned short  altitude;

  /*  10 -  11 : Altitude - second peak                                   */ 
  unsigned short  altitude2;

  /*  12 -  13 : Altitude Amps - debug info                               */ 
  unsigned short  altitudeAmps;

  /*  14 -  15 : Depth                                                    */ 
  unsigned short  depth;

  /*  16 -  17 : Water Temperature                                        */ 
  unsigned short  waterTemperature;

  /*  18 -  19 : Heading                                                  */ 
  unsigned short  heading;

  /*  20 -  21 : Pitch                                                    */ 
  unsigned short  pitch;

  /*  22 -  23 : Roll                                                     */ 
  unsigned short  roll;

  /*  24 -  24 : counter - debug info                                     */ 
  unsigned char   counterB;

  /*  25 -  25 : state - debug info                                       */ 
  unsigned char   statep2;

  /*  26 -  27 : temperature - debug info                                 */ 
  unsigned short  tempMot;

  /*  28 -  28 : nspi - debug info                                        */ 
  unsigned char   nspi;

  /*  29 -  29 : npc - debug info                                         */ 
  unsigned char   npc;

  /*  30 -  31 : temperature - debug info                                 */ 
  unsigned short  tempTrbCpu;

  /*  32 -  32 : Pulse Length                                             */ 
  /* pulse length = value * 2.5 uS                                        */ 
  unsigned char   pulseLength;

  /*  33 -  33 : zero - always zero                                       */ 
  unsigned char   zero0;

  /*  34 -  35 : Data Length                                              */ 
  unsigned short  dataLength;

  /*  36 -  36 : Channel Emission                                         */ 
  /* 0 - LR Off, 1 - L On R Off, 2 - L Off R On, 3 - LR On                */ 
  unsigned char   channelEmission;

  /*  37 -  37 : Channel Gain                                             */ 
  /* 0 - LR Norm, 1 - L High R Norm, 2 - L Norm R High, 3 - LR High       */ 
  unsigned char   channelGain;

  /*  38 -  38 : Work Frequency                                           */ 
  /* 10 - 100kHz, 40 - 400kHz, 120 - 1250kHz                              */ 
  unsigned char   workFrequency;

  /*  39 -  39 : Output Data Rate                                         */ 
  /* 1 - 50kSamp/Sec, 2 - 25kSamp/Sec, 5 - 10kSamp/Sec                    */ 
  unsigned char   outputDataRate;

  /*  40 -  40 : TVG                                                      */ 
  /* 0 - -10dB, 1 - 0dB, 2 - 10dB                                         */ 
  unsigned char   TVG;

  /*  41 -  41 : zero - always zero                                       */ 
  unsigned char   zero1;

  /*  42 -  43 : Cable Voltage                                            */ 
  unsigned short  cableVoltage;

  /*  44 -  45 : Depth Sensor Channel                                     */ 
  unsigned short  depthSensorChannel;

  /*  46 -  46 : zero - always zero                                       */ 
  unsigned char   zero2;

  /*  47 -  47 : Checksum                                                 */ 
  /* checksum 8 bit XOR                                                   */ 
  unsigned char   headerChecksum;

  /*  48 -  48 : L                                                        */ 
  unsigned char   left;

  /*  49 -  49 : R                                                        */ 
  unsigned char   right;

  /* data follows                                                         */ 

} TowfishDataHeaderType;


/* ---------------------------------------------------------------------- */ 
/* S-150 towfish data packet tail format                                  */ 
/* ---------------------------------------------------------------------- */ 

typedef struct
{
  /* data preceeds                                                        */ 

  /*  Offset   : Description                                              */ 
  /*   0 -   0 : L                                                        */ 
  unsigned char   left;

  /*   1 -   1 : R                                                        */ 
  unsigned char   right;

  /*   2 -   2 : zero - always zero                                       */ 
  unsigned char   zero;

  /*   3 -   3 : Checksum                                                 */ 
  /* checksum 8 bit XOR                                                   */ 
  unsigned char   dataChecksum;

  /*   4 -   7 : Final string should always be END0                       */ 
  unsigned char   finalString[4];

} TowfishDataTailType;


/* ---------------------------------------------------------------------- */ 
/*                         end S150Formats.cpp                            */ 
/* ---------------------------------------------------------------------- */ 


