Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename signalk_position to signalk_types #743

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions src/sensesp/signalk/signalk_position.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions src/sensesp/signalk/signalk_position.h

This file was deleted.

46 changes: 46 additions & 0 deletions src/sensesp/signalk/signalk_types.cpp
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
26 changes: 26 additions & 0 deletions src/sensesp/signalk/signalk_types.h
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
Loading