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

Kahu exporter #1

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions Plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ set(OCPN_RELEASE_REPO
# ------- Plugin setup --------
#
set(PKG_NAME radar_pi)
set(PKG_VERSION 5.5.4)
set(PKG_PRERELEASE "") # Empty, or a tag like 'beta'
set(PKG_VERSION 5.5.4730)
set(PKG_PRERELEASE "redhog") # Empty, or a tag like 'beta'

set(DISPLAY_NAME radar) # Dialogs, installer artifacts, ...
set(PLUGIN_API_NAME Radar) # As of GetCommonName() in plugin API
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Kahu-exporter
===================================
This is a branch of `radar_pi` that writes all received radar spokes in msgpack format to a file (or named pipe), `radar-data.msgpack` in the current directory.


radar_pi - Radar Plugin for OpenCPN
===================================
Expand Down
6 changes: 6 additions & 0 deletions include/RadarInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "RadarReceive.h"
#include "radar_pi.h"

#include <msgpack.hpp>
#include <iostream>

PLUGIN_BEGIN_NAMESPACE

class RadarDraw;
Expand Down Expand Up @@ -225,6 +228,9 @@ class RadarInfo {
time_t m_idle_standby; // When we will change to standby
time_t m_idle_transmit; // When we will change to transmit

std::ofstream* radar_data;
msgpack::packer<std::ofstream>* radar_data_packer;

/* Methods */

RadarInfo(radar_pi* pi, int radar);
Expand Down
18 changes: 18 additions & 0 deletions src/RadarInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ RadarInfo::RadarInfo(radar_pi *pi, int radar) {
for (size_t z = 0; z < GUARD_ZONES; z++) {
m_guard_zone[z] = new GuardZone(m_pi, this, z);
}

radar_data = new std::ofstream("radar-data.msgpack", std::ios::binary);
radar_data_packer = new msgpack::packer<std::ofstream>(radar_data);
}

void RadarInfo::Shutdown() {
Expand Down Expand Up @@ -218,6 +221,9 @@ RadarInfo::~RadarInfo() {
delete m_polar_lookup;
m_polar_lookup = 0;
}

delete radar_data_packer;
delete radar_data;
}

/**
Expand Down Expand Up @@ -460,6 +466,18 @@ void RadarInfo::CalculateRotationSpeed(SpokeBearing angle) {
*/
void RadarInfo::ProcessRadarSpoke(SpokeBearing angle, SpokeBearing bearing, uint8_t *data, size_t len, int range_meters,
wxLongLong time_rec) {

msgpack::zone zone;
std::map<std::string, msgpack::type::variant> spoke;
spoke["type"] = "spoke";
spoke["angle"] = angle;
spoke["bearing"] = bearing;
spoke["data"] = msgpack::type::raw_ref((const char*) data, len);
spoke["data_len"] = len;
spoke["range_meters"] = range_meters;
spoke["time_rec"] = time_rec.GetValue();
radar_data_packer->pack(spoke);

int orientation;
int i;

Expand Down