36    encoded = latlon_in * ((double)(0x007FFFFFL) / 180.0);
 
   37    encoded += (encoded > 0.0) ? 0.5 : -0.5;
 
   40    out.as_long = (
long int)encoded;
 
   42    return (out.as_compressed);
 
   49    in.as_compressed = latlon_in;
 
   51    if (in.as_long & 0x00800000L) 
 
   52        in.as_long |= ~0xFFFFFFL; 
 
   54    return (
double)in.as_long * (180.0 / (double)(0x007FFFFFL));
 
   57unsigned char Encode_heading(
float heading)
 
   59    return ((
unsigned char)(heading * 255.0 / 360.0 + 0.5));
 
   62double Decode_heading(
unsigned char heading) { 
return ((
double)heading * 360.0 / 255.0); }
 
   68char Encode_est_velocity(
float est_velocity)
 
   70    return ((
char)(est_velocity * 25.0 + 0.5)); 
 
   73float Decode_est_velocity(
char est_velocity) { 
return (est_velocity / 25.0); }
 
   77unsigned char Encode_salinity(
float salinity)
 
   84        output = (salinity - 20.0) * 10;
 
   87        return ((
unsigned char)output);
 
   91float Decode_salinity(
unsigned char sal)
 
   95    return (((
float)sal / 10.0) + 20.0);
 
   98unsigned short Encode_depth(
float depth)
 
  107        return ((
short unsigned int)((depth + .05) * 1.0 / 0.1));
 
  109        return ((
short unsigned int)(((depth - 100) + 0.1) * 1.0 / 0.2 + 1000));
 
  111        return ((
short unsigned int)(((depth - 200) + 0.25) * 1.0 / 0.5 + 1500));
 
  113        return ((
short unsigned int)(((depth - 1000) + 0.5) * 1.0 / 1.0 + 3100));
 
  117float Decode_depth(
unsigned short depth)
 
  124    unsigned short DEPTH_MODE_MASK = 0x1FFF; 
 
  125    depth &= DEPTH_MODE_MASK;                
 
  127        return (depth * 0.1 / 1.0);
 
  128    else if (depth <= 1500)
 
  129        return (100 + (depth - 1000) * 0.2 / 1.0);
 
  130    else if (depth <= 3100)
 
  131        return (200 + (depth - 1500) * 0.5 / 1.0);
 
  132    else if (depth <= 8100)
 
  133        return (1000 + (depth - 3100) * 1.0 / 1.0);
 
  138unsigned char Encode_temperature(
float temperature)
 
  140    if (temperature < -4)
 
  143    temperature = temperature * 256.0 / 40.0 + 0.5;
 
  144    if (temperature > 255)
 
  146    return ((
unsigned char)temperature);
 
  149float Decode_temperature(
unsigned char temperature) { 
return (temperature * 40.0 / 256.0 - 4.0); }
 
  151unsigned char Encode_sound_speed(
float sound_speed)
 
  153    return ((
unsigned char)((sound_speed - 1425.0) * 2));
 
  156float Decode_sound_speed(
unsigned char sound_speed) { 
return ((
float)sound_speed / 2.0 + 1425.0); }
 
  158unsigned short Encode_hires_altitude(
float alt) 
 
  166        return ((
unsigned short)alt);
 
  169float Decode_hires_altitude(
unsigned short alt) { 
return ((
float)alt / 100.0); }
 
  171unsigned short Encode_gfi_pitch_oil(
float gfi, 
float pitch, 
float oil)
 
  178    unsigned short result;
 
  184    result = (
unsigned short)(gfi * 31.0 / 100.0);
 
  190    result |= ((
unsigned short)oil << 5);
 
  193    else if (pitch < -90)
 
  195    pitch *= 63.0 / 180.0;
 
  201    temp = ((short)pitch << 10);
 
  202    result |= temp & 0xFC00;
 
  206void Decode_gfi_pitch_oil(
unsigned short gfi_pitch_oil, 
float* gfi, 
float* pitch, 
float* oil)
 
  211    temp = (
unsigned int)((gfi_pitch_oil & 0x001F) * 100.0 / 31.0);
 
  213    temp = (gfi_pitch_oil & 0x03E0) >> 5;
 
  214    *oil = temp * 100.0 / 31.0;
 
  215    temp_pitch = ((short)(gfi_pitch_oil & 0xFC00)) >> 10;
 
  216    *pitch = temp_pitch * 180.0 / 63.0;
 
  219TIME_DATE Encode_time_date(
long secs_since_1970)
 
  233    time_t secs_since_1970_time_t(secs_since_1970);
 
  234    tm = *gmtime(&secs_since_1970_time_t);
 
  235    comp.as_long = (
unsigned long)tm.tm_sec >> 2;
 
  236    comp.as_long += (
unsigned long)tm.tm_min << 4;
 
  237    comp.as_long += (
unsigned long)tm.tm_hour << (4 + 6);
 
  238    comp.as_long += (
unsigned long)tm.tm_mday << (4 + 6 + 5);
 
  239    comp.as_long += (
unsigned long)(tm.tm_mon + 1) << (4 + 6 + 5 + 5);
 
  240    return (comp.as_time_date);
 
  243long Decode_time_date(
TIME_DATE input, 
short* mon, 
short* day, 
short* hour, 
short* min, 
short* sec)
 
  247    comp.as_time_date = input;
 
  249    *mon = (short)((comp.as_long >> (4 + 6 + 5 + 5)) & 0x000F);
 
  250    *day = (short)((comp.as_long >> (4 + 6 + 5)) & 0x001F);
 
  251    *hour = (short)((comp.as_long >> (4 + 6)) & 0x001F);
 
  252    *min = (short)((comp.as_long >> (4)) & 0x003F);
 
  253    *sec = (short)(((comp.as_long) & 0x000F) * 4);
 
  261unsigned char Encode_watts(
float volts, 
float amps)
 
  264    float watts = (volts * amps) / 4;
 
  270    return ((
unsigned char)watts);
 
  273float Decode_watts(
unsigned char watts_encoded) { 
return ((
float)watts_encoded * 4.0); }
 
  275char Encode_speed(SPEED_MODE mode, 
float speed)
 
  283            else if (speed < -127)
 
  286        case SPEED_MODE_KNOTS: 
 
  288        case SPEED_MODE_MSEC:
 
  292            else if (speed < -127)
 
  297    speed += (speed > 0.0) ? 0.5 : -0.5;
 
  299    return ((
char)speed);
 
  302float Decode_speed(SPEED_MODE mode, 
char speed)
 
  306        case SPEED_MODE_RPM: 
return (speed * 20.0);
 
  307        case SPEED_MODE_MSEC: 
return ((
float)speed / 30.0);
 
  308        case SPEED_MODE_KNOTS: 
 
  314double DecodeRangerLL(
unsigned char c1, 
unsigned char c2, 
unsigned char c3, 
unsigned char c4,
 
  317    int deg100, deg10, deg1, min10, min1, minp1000, minp100, minp10, minp1, sign;
 
  318    double fMin, fDeg, fSign, fRet;
 
  321    deg100 = ((c1 & 0xf0) >> 4);
 
  323    deg1 = ((c2 & 0xf0) >> 4);
 
  324    fDeg = deg100 * 100.0 + deg10 * 10.0 + deg1 * 1.0;
 
  328    if ((sign == 0x0c) || (sign == 0x0d))
 
  334    min10 = ((c3 & 0xf0) >> 4);
 
  336    minp1000 = ((c4 & 0xf0) >> 4);
 
  338    minp10 = ((c5 & 0xf0) >> 4);
 
  340    fMin = min10 * 10.0 + min1 * 1.0 + minp1000 * 0.1 + minp100 * 0.01 + minp10 * 0.001 +
 
  343    fRet = (fDeg + (fMin / 60.0)) * fSign;
 
  348double DecodeRangerBCD2(
unsigned char c1, 
unsigned char c2)
 
  350    int i1000, i100, i10, i1;
 
  352    i1000 = ((c1 & 0xf0) >> 4);
 
  354    i10 = ((c2 & 0xf0) >> 4);
 
  357    return i1000 * 1000.0 + i100 * 100.0 + i10 * 10.0 + i1 * 1.0;
 
  360double DecodeRangerBCD(
unsigned char c1)
 
  364    i10 = ((c1 & 0xf0) >> 4);
 
  367    return i10 * 10.0 + i1 * 1.0;