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