-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename signalk_position to signalk_types
Implement ENUVector and AttitudeVector and provide serializers for them.
- Loading branch information
Showing
4 changed files
with
72 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
#include "signalk_types.h" | ||
|
||
namespace sensesp { | ||
|
||
/** | ||
* @brief Template specialization for SKOutputPosition::as_signalk_json() | ||
* | ||
* This specialization allows `Position` objects to be output as Signal K | ||
* deltas. | ||
* | ||
* @tparam | ||
* @return String | ||
*/ | ||
template <> | ||
void SKOutput<Position>::as_signalk_json(JsonDocument& doc) { | ||
doc["path"] = this->get_sk_path(); | ||
JsonObject value = doc["value"].to<JsonObject>(); | ||
value["latitude"] = output.latitude; | ||
value["longitude"] = output.longitude; | ||
if (output.altitude != kPositionInvalidAltitude) { | ||
value["altitude"] = output.altitude; | ||
} | ||
} | ||
|
||
template <> | ||
void SKOutput<ENUVector>::as_signalk_json(JsonDocument& doc) { | ||
doc["path"] = this->get_sk_path(); | ||
JsonObject value = doc["value"].to<JsonObject>(); | ||
value["east"] = output.east; | ||
value["north"] = output.north; | ||
if (output.up != kPositionInvalidAltitude) { | ||
value["up"] = output.up; | ||
} | ||
} | ||
|
||
template <> | ||
void SKOutput<AttitudeVector>::as_signalk_json(JsonDocument& doc) { | ||
doc["path"] = this->get_sk_path(); | ||
JsonObject value = doc["value"].to<JsonObject>(); | ||
value["roll"] = output.roll; | ||
value["pitch"] = output.pitch; | ||
value["yaw"] = output.yaw; | ||
} | ||
|
||
} // namespace sensesp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef SENSESP_SRC_SENSESP_SIGNALK_SIGNALK_TYPES_H_ | ||
#define SENSESP_SRC_SENSESP_SIGNALK_SIGNALK_TYPES_H_ | ||
|
||
#include <vector> | ||
|
||
#include "sensesp/signalk/signalk_output.h" | ||
#include "sensesp/types/position.h" | ||
|
||
namespace sensesp { | ||
|
||
template <> | ||
void SKOutput<Position>::as_signalk_json(JsonDocument& doc); | ||
|
||
template <> | ||
void SKOutput<ENUVector>::as_signalk_json(JsonDocument& doc); | ||
|
||
template <> | ||
void SKOutput<AttitudeVector>::as_signalk_json(JsonDocument& doc); | ||
|
||
typedef SKOutput<Position> SKOutputPosition; | ||
typedef SKOutput<ENUVector> SKOutputENUVector; | ||
typedef SKOutput<AttitudeVector> SKOutputAttitudeVector; | ||
|
||
} // namespace sensesp | ||
|
||
#endif |