/* ---------------------------------------------------------------------- */ 
/* DiscoverSegyDefs.h                                                     */ 
/* ---------------------------------------------------------------------- */ 
/*                                                                        */ 
/* (c) Copyright 1997, 1998, 2000, 2002, 2005, 2006, 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.              */ 
/*                                                                        */ 
/* ---------------------------------------------------------------------- */ 
/*                                                                        */ 
/* EdgeTech JStar SEG-Y data format description.                          */ 
/*                                                                        */ 
/* ---------------------------------------------------------------------- */ 

#ifndef __DISCOVERSEGYDEFS_H__
#define __DISCOVERSEGYDEFS_H__


#include "SEGYDefs.h"



/* ---------------------------------------------------------------------- */ 
/* Estimated pressure information.                                        */ 
/* ---------------------------------------------------------------------- */ 

typedef struct
{
  /* Pressure in PSI * 1000.0                                             */ 
  long pressure;

  /* Depth estimate in mm                                                 */ 
  long depth;

} PressureInfoType;


/* ---------------------------------------------------------------------- */ 
/* Estimated altitude information.                                        */ 
/* ---------------------------------------------------------------------- */ 

typedef struct
{
  /* Altitude in mm                                                       */ 
  long altitude;

  /* Velocity in mm/s                                                     */ 
  long forwardVelocity;
  long crossTrackVelocity;

} AltitudeInfoType;


/* ---------------------------------------------------------------------- */ 
/* Each record of data has a 240 byte header, the content of which is     */ 
/* defined below.  The structure is intended to be compatible with most   */ 
/* implemented SEG-Y formats, as well as the original standard.           */ 
/*                                                                        */ 
/* Unused fields should be set to 0                                       */ 
/*                                                                        */ 
/* SEG-Y defined fields (** -> Highly Recommended in SEG-Y)               */ 
/* ---------------------------------------------------------------------- */ 

typedef struct 
{
  /* 0-3 : Time since 1/1/1970 in seconds (time() value)                  */ 
  long int timeSince1970; 

  /* 4-7 : Starting depth (window offset) in samples.                     */ 
  unsigned long int startDepth;    

  /* 8-11: Ping number (increments with ping) **                          */ 
  unsigned long int pingNum;        

  /* 12-15 : Channel Number (0 .. n) **                                   */ 
  /* 12-15 : PV: Reserved - do not use                                    */ 
  unsigned long int channelNum;     

  /* 16-27 : Reserved - do not use                                        */ 
  /* Formerly SSBLPositionType SSBLPosition;                              */ 
  short int unused1[6];

  /* 28-29 : ID Code (always 1 => seismic data) **                        */ 
  short int traceIDCode;   

  /*  30 -  31 : Validity flags bitmap                                    */ 
  /* Bit  0    : Lat Lon or XY valid                                      */ 
  /* Bit  1    : Course valid                                             */ 
  /* Bit  2    : Speed valid                                              */ 
  /* Bit  3    : Heading valid                                            */ 
  /* Bit  4    : Pressure valid                                           */ 
  /* Bit  5    : Pitch roll valid                                         */ 
  /* Bit  6    : Altitude valid                                           */ 
  /* Bit  7    : Reserved                                                 */ 
  /* Bit  8    : Water temperature valid                                  */ 
  /* Bit  9    : Depth valid                                              */ 
  /* Bit 10    : Annotaiton valid                                         */ 
  /* Bit 11    : Cable counter valid                                      */ 
  unsigned short int  validityFlags;

  /* 32-33 : Reserved for future use                                      */ 
  short int reserved1;

  /* 34-35 : DataFormatType                                               */ 
  /*   0 = 1 short  per sample  - envelope data                           */ 
  /* the total number of bytes of data to follow is  2 * samples.         */ 
  /*   1 = 2 shorts per sample  - stored as real(1), imag(1),             */ 
  /* the total number of bytes of data to follow is  4 * samples.         */ 
  /*   2 = 1 short  per sample  - before matched filter (raw)             */ 
  /* the total number of bytes of data to follow is  2 * samples.         */ 
  /*   3 = 1 short  per sample  - real part analytic signal               */ 
  /* the total number of bytes of data to follow is  2 * samples.         */ 
  /*   4 = 1 short  per sample  - pixel data / ceros data                 */ 
  /* the total number of bytes of data to follow is  2 * samples.         */ 
  /*   5 = 1 byte   per sample  - pixel data                              */ 
  /* the total number of bytes of data to follow is  1 * samples.         */ 
  /*   6 = 1 long   per sample  - raw data                                */ 
  /* the total number of bytes of data to follow is  4 * samples.         */ 
  /*   7 = 2 floats per sample  - stored as real(1), imag(1),             */ 
  /* the total number of bytes of data to follow is  8 * samples.         */ 
  /*   8 = 1 float  per sample  - envelope data                           */ 
  /* the total number of bytes of data to follow is  4 * samples.         */ 
  short int dataFormat;    

  /* 36-37 : Distance from tow point to antennae in cm                    */ 
  short int NMEAantennaeR; 

  /* 38-39 : Distance fro tow point to antennae starboard direction in cm */ 
  short int NMEAantennaeO; 
  
  /* 40-41 : pitch/roll received millisecond counter (formerly RS232)     */ 
  short int attitudeMilliseconds;          
  
  /* 42-43 : nav fix received millisecond counter (formerly RS232)        */ 
  short int navFixMilliseconds;          
  
  /* 44-71 : Reserved for future use (formerly RS232)                     */ 
  char reserved3[28];          

  /* -------------------------------------------------------------------- */ 
  /* Navigation data :                                                    */ 
  /* If the coorUnits are seconds(2), the x values represent longitude    */ 
  /* and the y values represent latitude.  A positive value designates    */ 
  /* the number of seconds east of Greenwich Meridian or north of the     */ 
  /* equator.                                                             */ 
  /* -------------------------------------------------------------------- */ 

  /* 72-75 : Meters or Seconds of Arc                                     */ 
  /* 72-75 : PV : Reserved                                                */ 
  long int sourceCoordX;   

  /* 76-79 : Meters or Seconds of Arc                                     */ 
  /* 76-76 : PV : Reserved                                                */ 
  long int sourceCoordY;   

  /* 80-83 : mm or 10000 * (Minutes of Arc)                               */ 
  long int groupCoordX;    

  /* 84-87 : mm or 10000 * (Minutes of Arc)                               */ 
  long int groupCoordY;    

  /* 88-89 : Units of coordinates - 1->length mm(x /y), 2->seconds of arc,*/ 
  /* 3 - length in generic units (normally decimeters)                    */ 
  short int coordUnits;    

  /* 90-113 : Annotation string                                           */ 
  char annotation[24];

  /* 114-115 : Samples in this packet **                                  */ 
  /* Note:  Large sample sizes require multiple packets.                  */ 
  unsigned short int samples;       

  /* 116-119 : Sample interval in ns of stored data **                    */ 
  unsigned long int sampleInterval;

  /* 120-121 : Gain factor of ADC                                         */ 
  unsigned short int ADCGain;       

  /* 122-123 : user pulse power setting (0 - 100) percent                 */ 
  short int pulsePower;    

  /* 124-125 : correlated data 1 - No, 2 - Yes                            */ 
  /* 124-125 : PV: Reserved                                               */ 
  short int correlated;    

  /* 126-127 : Starting frequency in 10 * Hz                              */ 
  unsigned short int startFreq;     

  /* 128-129 : Ending frequency in 10 * Hz                                */ 
  unsigned short int endFreq;       

  /* 130-131 : Sweep length in ms                                         */ 
  unsigned short int sweepLength;   

  /* 132-139                                                              */ 
  /* short int unused7[4];                                                */ 
  PressureInfoType pressureInfo;

  /* 140-141 : Sample rate in Hz mod 65536                                */ 
  /*           Exception for raw data its 1/2 the Sample Rate.            */ 
  unsigned short int sampleRate;

  /* 142-143 : Unique pulse identifier                                    */ 
  unsigned short int pulseID;    

  /* 144-155                                                              */ 
  /* PV : Altitude in mm then reserved for rest                           */ 
  AltitudeInfoType altitudeInfo;

  /* 156-157 : Year data recorded (CPU time)                              */ 
  short int year;          

  /* 158-159 : day                                                        */ 
  short int day;           

  /* 160-161 : hour                                                       */ 
  short int hour;          

  /* 162-163 : minute                                                     */ 
  short int minute;        

  /* 164-165 : second                                                     */ 
  short int second;        

  /* 166-167 : Always 3 (other not specified by standard)                 */ 
  short int timeBasis;     

  /* 168-169 :  weighting factor for block floating point expansion       */ 
  /*            -- defined as 2 -N volts for lsb                          */ 
  short int weightingFactor;

  /* 170-171 : Number of pulses in the water                              */ 
  short int numPulses;    

  /* -------------------------------------------------------------------- */ 
  /* From pitch/roll/temp/heading sensor                                  */ 
  /* -------------------------------------------------------------------- */ 

  /* 172-173 : Compass heading (100 * degrees)  0 to 360.00 degrees       */ 
  unsigned short int heading;       

  /* 174-175 : Pitch - bow up is positive                                 */ 
  /* ((degrees / 180.0) * 32768.0) to maximize resolution                 */ 
  short int pitch;         

  /* 176-177 : Roll  - port up is positive                                */ 
  /* ((degrees / 180.0) * 32768.0) to maximize resolution                 */ 
  short int roll;          

  /* 178-179 : Temperature of towfish electronics.(10 * degrees C)        */ 
  short int temperature;   

  /* -------------------------------------------------------------------- */ 
  /* User defined area from 180-239                                       */ 
  /* -------------------------------------------------------------------- */ 

  /* 180-181 : Heave compensation offset (samples)                        */ 
  /* 180-181 : PV: Reserved                                               */ 
  short int heaveCompensation;    

  /* 182-183 : TriggerSource (0 = internal, 1 = external)                 */ 
  short int trigSource;    

  /* 184-185 : Mark Number (0 = no mark)                                  */ 
  unsigned short int markNumber;    

  /* Note that the NMEA time fields are the time of the GPS fix and come  */ 
  /* from the same sentence which reported the fix.                       */ 

  /* 186-187 : Hour                                                       */ 
  short int NMEAHour;

  /* 188-189 : Minutes                                                    */ 
  short int NMEAMinutes;

  /* 190-191 : Seconds                                                    */ 
  short int NMEASeconds;

  /* 192-193 : Course                                                     */ 
  short int NMEACourse;

  /* 194-195 : Speed in tenths of a knot                                  */ 
  short int NMEASpeed;

  /* 196-197 : Day                                                        */ 
  short int NMEADay;

  /* 198-199 : Year                                                       */ 
  short int NMEAYear;

  /* 200-203 : Millieconds today                                          */ 
  /*           use with seconds since 1970 to get time to the ms          */ 
  unsigned long int millisecondsToday;

  /* 204-205 : Maximum absolute value for ADC samples for this packet     */ 
  unsigned short int ADCMax;        

  /* 206-207 : System constant in tenths of a dB                          */ 
  /* 206-207 : PV: Reserved                                               */ 
  short int calConst;      

  /* 208-209 : Vehicle ID                                                 */ 
  /* 208-209 : PV: Reserved                                               */ 
  short int vehicleID;     

  /* 210-215 : Sonar Software version number                              */ 
  char softwareVersion[6]; 

  /* Following items are not in X-Star                                    */ 

  /* 216-219 : Initial spherical correction factor (useful for multiping /*/ 
  /* deep application) in samples.                                        */ 
  /* A value of -1 indicates that the spherical spreading factor is       */ 
  /* disabled.                                                            */ 

  long int           sphericalCorrection;
  
  /* 220-221 : Packet number (1 - N) (Each ping starts with packet 1)     */ 
  unsigned short int packetNum;     

  /* 222-223 : A/D decimation * 100 before FFT                            */ 
  short int          ADCDecimation; 

  /* 224-225 : Decimation factor after FFT                                */ 
  short int          decimation;    

  /* 226-227 : Water Temperature (10 * degrees C)                         */ 
  short int          waterTemperature;

  /* 228-231 : Distance to the fish in meters                             */ 
  float              layback;

  /* 232-235 : found bottom offset in samples                             */ 
  long int           bottomOffset;

  /* 236-237 : cable out in decimeters                                    */ 
  unsigned short     cableOut;

  /* 238-239 : towfish depth in decimeters                                */ 
  unsigned short     towfishDepth;

  /* -------------------------------------------------------------------- */ 
  /* Data area begins here                                                */ 
  /* -------------------------------------------------------------------- */ 
  /* Data begins at byte 240, has this.samples points in it               */ 
  /* short int data[];                                                    */ 
  /* -------------------------------------------------------------------- */ 

} JStarDataType;


/* ---------------------------------------------------------------------- */ 

#endif  /* end Not __DISCOVERSEGYDEFS_H__ */ 


/* ---------------------------------------------------------------------- */ 
/*                       end DiscoverSegyDefs.h                           */ 
/* ---------------------------------------------------------------------- */ 

