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

Add individual channel status information to Telecommand #419

Draft
wants to merge 5 commits into
base: next
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
2 changes: 2 additions & 0 deletions src/algorithms/channel/adapters/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class Channel : public ChannelInterface
inline std::shared_ptr<TrackingInterface> tracking() const { return trk_; }
inline std::shared_ptr<TelemetryDecoderInterface> telemetry() const { return nav_; }

inline uint32_t fsm_state() const { return channel_fsm_->state(); }

private:
std::shared_ptr<ChannelFsm> channel_fsm_;
std::shared_ptr<AcquisitionInterface> acq_;
Expand Down
2 changes: 2 additions & 0 deletions src/algorithms/channel/libs/channel_fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class ChannelFsm
virtual bool Event_failed_acquisition_repeat();
virtual bool Event_failed_acquisition_no_repeat();

inline uint32_t state() const { return state_; }

private:
void start_tracking();
void stop_acquisition();
Expand Down
1 change: 1 addition & 0 deletions src/core/receiver/control_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ int ControlThread::run()

// start the telecommand listener thread
cmd_interface_.set_pvt(flowgraph_->get_pvt());
cmd_interface_.set_channels(flowgraph_->get_channels());
cmd_interface_thread_ = std::thread(&ControlThread::telecommand_listener, this);

#ifdef ENABLE_FPGA
Expand Down
8 changes: 8 additions & 0 deletions src/core/receiver/gnss_flowgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ class GNSSFlowgraph
return std::dynamic_pointer_cast<PvtInterface>(pvt_);
}

/*!
* \brief Returns a smart pointer to the Channels object
*/
std::shared_ptr<std::vector<std::shared_ptr<ChannelInterface>>> get_channels()
{
return std::make_shared<std::vector<std::shared_ptr<ChannelInterface>>>(channels_);
}

/*!
* \brief Priorize visible satellites in the specified vector
*/
Expand Down
60 changes: 48 additions & 12 deletions src/core/receiver/tcp_cmd_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "tcp_cmd_interface.h"
#include "channel.h"
#include "command_event.h"
#include "pvt_interface.h"
#include <boost/asio.hpp>
Expand All @@ -34,6 +35,7 @@ using b_io_context = boost::asio::io_context;
using b_io_context = boost::asio::io_service;
#endif


TcpCmdInterface::TcpCmdInterface()
{
register_functions();
Expand Down Expand Up @@ -74,6 +76,12 @@ void TcpCmdInterface::set_pvt(std::shared_ptr<PvtInterface> PVT_sptr)
}


void TcpCmdInterface::set_channels(std::shared_ptr<std::vector<std::shared_ptr<ChannelInterface>>> channels_sptr)
{
channels_sptr_ = std::move(channels_sptr);
}


time_t TcpCmdInterface::get_utc_time() const
{
return receiver_utc_time_;
Expand Down Expand Up @@ -123,18 +131,46 @@ std::string TcpCmdInterface::standby(const std::vector<std::string> &commandLine
std::string TcpCmdInterface::status(const std::vector<std::string> &commandLine __attribute__((unused)))
{
std::stringstream str_stream;
// todo: implement the receiver status report

// str_stream << "-------------------------------------------------------\n";
// str_stream << "ch | sys | sig | mode | Tlm | Eph | Doppler | CN0 |\n";
// str_stream << " | | | | | | [Hz] | [dB - Hz] |\n";
// str_stream << "-------------------------------------------------------\n";
// int n_ch = 10;
// for (int n = 0; n < n_ch; n++)
// {
// str_stream << n << "GPS | L1CA | TRK | YES | YES | 23412.4 | 44.3 |\n";
// }
// str_stream << "--------------------------------------------------------\n";

str_stream << "-------------------------------------------------------------------------\n";
str_stream << "| Ch | System | Signal | PRN | Mode | Tlm | Eph | Doppler | CN0 |\n";
str_stream << "| | | | | | | | [Hz] | [dB-Hz] |\n";
str_stream << "-------------------------------------------------------------------------\n";

int n_ch = static_cast<int>(channels_sptr_->size());
for (int n = 0; n < n_ch; n++)
{
std::shared_ptr<Channel>
ch_sptr = std::dynamic_pointer_cast<Channel>(channels_sptr_->at(n));

std::string system = ch_sptr->get_signal().get_satellite().get_system();
std::string signal = map_signal_pretty_name_.at(ch_sptr->get_signal().get_signal_str());
uint32_t prn = ch_sptr->get_signal().get_satellite().get_PRN();
std::string state = map_state_name_.at(ch_sptr->fsm_state());

str_stream << std::fixed << std::setprecision(1)
<< "| "
<< std::right << std::setw(3) << n
<< " | "
<< std::left << std::setw(7) << system
<< " | "
<< std::left << std::setw(6) << signal
<< " | "
<< std::right << std::setw(3) << prn
<< " | "
<< std::left << std::setw(4) << state
<< " | "
<< std::left << std::setw(3) << "---"
<< " | "
<< std::left << std::setw(3) << "---"
<< " | "
<< std::right << std::setw(9) << 23412.46
<< " | "
<< std::right << std::setw(7) << 44.32
<< " |"
<< "\n";
}
str_stream << "-------------------------------------------------------------------------\n";

double longitude_deg;
double latitude_deg;
Expand Down
22 changes: 22 additions & 0 deletions src/core/receiver/tcp_cmd_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
#include <cstdint>
#include <ctime>
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

class PvtInterface;
class ChannelInterface;

class TcpCmdInterface
{
Expand All @@ -53,6 +55,7 @@ class TcpCmdInterface
std::array<float, 3> get_LLH() const;

void set_pvt(std::shared_ptr<PvtInterface> PVT_sptr);
void set_channels(std::shared_ptr<std::vector<std::shared_ptr<ChannelInterface>>> channels_sptr);

private:
std::unordered_map<std::string, std::function<std::string(const std::vector<std::string> &)>>
Expand All @@ -69,6 +72,25 @@ class TcpCmdInterface

std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> control_queue_;
std::shared_ptr<PvtInterface> PVT_sptr_;
std::shared_ptr<std::vector<std::shared_ptr<ChannelInterface>>> channels_sptr_;

const std::map<std::string, std::string> map_signal_pretty_name_{
{"1C", "L1 C/A"},
{"1B", "E1"},
{"1G", "L1 C/A"},
{"2S", "L2C"},
{"2G", "L2 C/A"},
{"5X", "E5a"},
{"7X", "E5b"},
{"L5", "L5"},
{"B1", "B1I"},
{"B3", "B3I"}};

const std::map<uint32_t, std::string> map_state_name_{
{0, "STBY"},
{1, "ACQ"},
{2, "TRK"},
{3, "DROP"}};

float rx_latitude_;
float rx_longitude_;
Expand Down