DCCL v3
WhoiUtil.h
1 // Copyright 2009-2017 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (for 2013-)
3 // Massachusetts Institute of Technology (for 2007-2014)
4 // Community contributors (see AUTHORS file)
5 //
6 //
7 // This file is part of the Dynamic Compact Control Language Library
8 // ("DCCL").
9 //
10 // DCCL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 2.1 of the License, or
13 // (at your option) any later version.
14 //
15 // DCCL is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with DCCL. If not, see <http://www.gnu.org/licenses/>.
22 /* Latitude/Longitude
23  * Each are encoded into 3 bytes, giving a resolution of
24  * about 2 meters. The compressed form is stored in a LATLON_COMPRESSED struct,
25  * which is 3 bytes.
26 */
27 typedef struct {
28  char compressed[3];
29 }
31 
32 typedef union {
33  long as_long;
34  LATLON_COMPRESSED as_compressed;
35 }
36 
38 
39 typedef struct
40 {
41  unsigned char compressed[3];
42 }
43 TIME_DATE;
44 
45 typedef union
46 {
47  long as_long;
48  TIME_DATE as_time_date;
49 }
51 
52 typedef enum
53  {
54  SPEED_MODE_RPM = 0,
55  SPEED_MODE_MSEC = 1,
56  SPEED_MODE_KNOTS = 2
57  }
58 SPEED_MODE;
59 
60 typedef enum
61  {
62  PS_DISABLED = 0,
63  PS_SHIPS_POLE = 1,
64  PS_GATEWAY_BUOY = 2, // "automatically" set...
65  PS_NAMED_TRANSPONDER = 3, // could be a drifter, or moored; label indicates who...
66  PS_VEHICLE_POSITION = 4,
67  PS_LAST = 5, // Pay no attention to the PS_INVALID behind the curtain...
68  PS_INVALID = 0x080 // Or'd in to indicate that the systems position is (temporarily) invalid (ship turning, etc.)
69  }
70 POSITION_SEND ;
71 
72 LATLON_COMPRESSED Encode_latlon(double latlon_in);
73 double Decode_latlon(LATLON_COMPRESSED latlon_in);
74 unsigned char Encode_heading(float heading);
75 double Decode_heading(unsigned char heading);
76 char Encode_est_velocity(float est_velocity);
77 float Decode_est_velocity(char est_velocity);
78 unsigned char Encode_salinity(float salinity);
79 float Decode_salinity(unsigned char sal);
80 unsigned short Encode_depth(float depth);
81 float Decode_depth(unsigned short depth);
82 unsigned char Encode_temperature(float temperature);
83 float Decode_temperature(unsigned char temperature);
84 unsigned char Encode_sound_speed(float sound_speed);
85 float Decode_sound_speed(unsigned char sound_speed);
86 unsigned short Encode_hires_altitude(float alt);
87 float Decode_hires_altitude(unsigned short alt);
88 unsigned short Encode_gfi_pitch_oil(float gfi, float pitch, float oil);
89 void Decode_gfi_pitch_oil(unsigned short gfi_pitch_oil,
90  float *gfi, float *pitch, float *oil);
91 TIME_DATE Encode_time_date(long secs_since_1970);
92 long Decode_time_date(TIME_DATE input, short *mon, short *day, short *hour,
93  short *min, short *sec);
94 unsigned char Encode_watts(float volts, float amps);
95 float Decode_watts(unsigned char watts_encoded);
96 char Encode_speed(SPEED_MODE mode, float speed);
97 float Decode_speed(SPEED_MODE mode, char speed);
98 
99 double DecodeRangerLL(unsigned char c1, unsigned char c2,unsigned char c3, unsigned char c4,unsigned char c5);
100 double DecodeRangerBCD2(unsigned char c1, unsigned char c2);
101 double DecodeRangerBCD(unsigned char c1);