DCCL v4
Loading...
Searching...
No Matches
WhoiUtil.h
1// Copyright 2012-2023:
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*/
29typedef struct //NOLINT
30{
31 char compressed[3];
33
34typedef union { //NOLINT
35 long as_long;
36 LATLON_COMPRESSED as_compressed;
37}
38
40
41typedef struct //NOLINT
42{
43 unsigned char compressed[3];
44} TIME_DATE;
45
46typedef union { //NOLINT
47 long as_long;
48 TIME_DATE as_time_date;
50
51typedef enum //NOLINT
52{
53 SPEED_MODE_RPM = 0,
54 SPEED_MODE_MSEC = 1,
55 SPEED_MODE_KNOTS = 2
56} SPEED_MODE;
57
58typedef 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
70LATLON_COMPRESSED Encode_latlon(double latlon_in);
71double Decode_latlon(LATLON_COMPRESSED latlon_in);
72unsigned char Encode_heading(float heading);
73double Decode_heading(unsigned char heading);
74char Encode_est_velocity(float est_velocity);
75float Decode_est_velocity(char est_velocity);
76unsigned char Encode_salinity(float salinity);
77float Decode_salinity(unsigned char sal);
78unsigned short Encode_depth(float depth);
79float Decode_depth(unsigned short depth);
80unsigned char Encode_temperature(float temperature);
81float Decode_temperature(unsigned char temperature);
82unsigned char Encode_sound_speed(float sound_speed);
83float Decode_sound_speed(unsigned char sound_speed);
84unsigned short Encode_hires_altitude(float alt);
85float Decode_hires_altitude(unsigned short alt);
86unsigned short Encode_gfi_pitch_oil(float gfi, float pitch, float oil);
87void Decode_gfi_pitch_oil(unsigned short gfi_pitch_oil, float* gfi, float* pitch, float* oil);
88TIME_DATE Encode_time_date(long secs_since_1970);
89long Decode_time_date(TIME_DATE input, short* mon, short* day, short* hour, short* min, short* sec);
90unsigned char Encode_watts(float volts, float amps);
91float Decode_watts(unsigned char watts_encoded);
92char Encode_speed(SPEED_MODE mode, float speed);
93float Decode_speed(SPEED_MODE mode, char speed);
94
95double DecodeRangerLL(unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4,
96 unsigned char c5);
97double DecodeRangerBCD2(unsigned char c1, unsigned char c2);
98double DecodeRangerBCD(unsigned char c1);