Skip to content

Commit

Permalink
updates to atlas plugin code to bring up to clang tidy and cppcheck s…
Browse files Browse the repository at this point in the history
…tandards
  • Loading branch information
jpswinski committed Oct 25, 2023
1 parent 47e1ec7 commit 5fc9711
Show file tree
Hide file tree
Showing 25 changed files with 284 additions and 275 deletions.
2 changes: 1 addition & 1 deletion packages/legacy/StatisticRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ StatisticRecord<T>::StatisticRecord(CommandProcessor* cmd_proc, const char* cmd_
RecordObject(rec_name)
{
/* Set Record to Data Allocated by RecordObject */
rec = (T*)recordData;
rec = reinterpret_cast<T*>(recordData);

/* Initialize Parameters */
statClear = CLEAR_NEVER;
Expand Down
2 changes: 1 addition & 1 deletion plugins/atlas/plugin/AltimetryHistogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ AltimetryHistogram::AltimetryHistogram(AtlasHistogram::type_t _type, int _intper
double _gps, double _rws, double _rww):
AtlasHistogram(rec_type, _type, _intperiod, _binsize, _pcenum, _mfc, _mfdata, _gps, _rws, _rww)
{
alt = (altHist_t*)recordData;
alt = reinterpret_cast<altHist_t*>(recordData);
}

/*----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion plugins/atlas/plugin/AltimetryHistogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AltimetryHistogram: public AtlasHistogram
double _rww );
virtual ~AltimetryHistogram (void);
static recordDefErr_t defineHistogram (void);
bool calcAttributes (double sigwidth, double bincal); // returns if signal is found
bool calcAttributes (double sigwidth, double bincal) override; // returns if signal is found

private:

Expand Down
2 changes: 1 addition & 1 deletion plugins/atlas/plugin/AltimetryProcessorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AltimetryProcessorModule: public CcsdsProcessorModule
* Methods
*--------------------------------------------------------------------*/

bool processSegments (List<CcsdsSpacePacket*>& segments, int numpkts);
bool processSegments (List<CcsdsSpacePacket*>& segments, int numpkts) override;
bool parseAltHist (List<CcsdsSpacePacket*>& segments, int numpkts);
bool parseAtmHist (List<CcsdsSpacePacket*>& segments, int numpkts);

Expand Down
77 changes: 38 additions & 39 deletions plugins/atlas/plugin/AtlasFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
/*----------------------------------------------------------------------------
* Constructor -
*----------------------------------------------------------------------------*/
AtlasFileWriter::AtlasFileWriter(CommandProcessor* cmd_proc, const char* obj_name, fmt_t _fmt, const char* _prefix, const char* inq_name, unsigned int _max_file_size):
AtlasFileWriter::AtlasFileWriter(CommandProcessor* cmd_proc, const char* obj_name, atlas_fmt_t _fmt, const char* _prefix, const char* inq_name, unsigned int _max_file_size):
CcsdsFileWriter(cmd_proc, obj_name, CcsdsFileWriter::USER_DEFINED, _prefix, inq_name, _max_file_size)
{
fmt = _fmt;
atlas_fmt = _fmt;
}

/*----------------------------------------------------------------------------
Expand All @@ -72,7 +72,7 @@ AtlasFileWriter::~AtlasFileWriter(void)
*----------------------------------------------------------------------------*/
CommandableObject* AtlasFileWriter::createObject(CommandProcessor* cmd_proc, const char* name, int argc, char argv[][MAX_CMD_SIZE])
{
fmt_t format = str2fmt(argv[0]);
atlas_fmt_t format = str2fmt(argv[0]);
const char* prefix = argv[1];
const char* stream = StringLib::checkNullStr(argv[2]);

Expand All @@ -95,7 +95,7 @@ CommandableObject* AtlasFileWriter::createObject(CommandProcessor* cmd_proc, con
/*----------------------------------------------------------------------------
* str2fmt -
*----------------------------------------------------------------------------*/
AtlasFileWriter::fmt_t AtlasFileWriter::str2fmt(const char* str)
AtlasFileWriter::atlas_fmt_t AtlasFileWriter::str2fmt(const char* str)
{
if(strcmp(str, "SCI_PKT") == 0) return SCI_PKT;
else if(strcmp(str, "SCI_CH") == 0) return SCI_CH;
Expand All @@ -114,7 +114,7 @@ AtlasFileWriter::fmt_t AtlasFileWriter::str2fmt(const char* str)
/*----------------------------------------------------------------------------
* str2fmt -
*----------------------------------------------------------------------------*/
const char* AtlasFileWriter::fmt2str(AtlasFileWriter::fmt_t _fmt)
const char* AtlasFileWriter::fmt2str(AtlasFileWriter::atlas_fmt_t _fmt)
{
if(_fmt == SCI_PKT) return "SCI_PKT";
else if(_fmt == SCI_CH) return "SCI_CH";
Expand All @@ -139,7 +139,7 @@ const char* AtlasFileWriter::fmt2str(AtlasFileWriter::fmt_t _fmt)
*----------------------------------------------------------------------------*/
int AtlasFileWriter::writeMsg(void* msg, int size, bool with_header)
{
switch(fmt)
switch(atlas_fmt)
{
case SCI_PKT: return writeSciPkt(msg, size, with_header);
case SCI_CH: return writeSciCh(msg, size, with_header);
Expand All @@ -162,7 +162,7 @@ int AtlasFileWriter::writeMsg(void* msg, int size, bool with_header)
*----------------------------------------------------------------------------*/
bool AtlasFileWriter::isBinary(void)
{
switch(fmt)
switch(atlas_fmt)
{
case SCI_PKT: return false;
case SCI_CH: return false;
Expand Down Expand Up @@ -198,18 +198,18 @@ int AtlasFileWriter::writeSciPkt (void* msg, int size, bool with_header)
if(!data) return 0;

pktStat_t* stat = (pktStat_t*)data;
cnt += fprintf(outfp, "%6d, ", stat->pce);
cnt += fprintf(outfp, "%6d, ", stat->segcnt);
cnt += fprintf(outfp, "%6d, ", stat->pktcnt);
cnt += fprintf(outfp, "%3d, ", stat->mfc_errors);
cnt += fprintf(outfp, "%3d, ", stat->hdr_errors);
cnt += fprintf(outfp, "%3d, ", stat->fmt_errors);
cnt += fprintf(outfp, "%3d, ", stat->dlb_errors);
cnt += fprintf(outfp, "%3d, ", stat->tag_errors);
cnt += fprintf(outfp, "%3d, ", stat->pkt_errors);
cnt += fprintf(outfp, "%4d, ", stat->warnings);
cnt += fprintf(outfp, "%7d, ", stat->min_tags);
cnt += fprintf(outfp, "%7d, ", stat->max_tags);
cnt += fprintf(outfp, "%6u, ", stat->pce);
cnt += fprintf(outfp, "%6u, ", stat->segcnt);
cnt += fprintf(outfp, "%6u, ", stat->pktcnt);
cnt += fprintf(outfp, "%3u, ", stat->mfc_errors);
cnt += fprintf(outfp, "%3u, ", stat->hdr_errors);
cnt += fprintf(outfp, "%3u, ", stat->fmt_errors);
cnt += fprintf(outfp, "%3u, ", stat->dlb_errors);
cnt += fprintf(outfp, "%3u, ", stat->tag_errors);
cnt += fprintf(outfp, "%3u, ", stat->pkt_errors);
cnt += fprintf(outfp, "%4u, ", stat->warnings);
cnt += fprintf(outfp, "%7u, ", stat->min_tags);
cnt += fprintf(outfp, "%7u, ", stat->max_tags);
cnt += fprintf(outfp, "%.1lf, ", stat->avg_tags);
cnt += fprintf(outfp, "\n");

Expand Down Expand Up @@ -237,16 +237,16 @@ int AtlasFileWriter::writeSciCh (void* msg, int size, bool with_header)
chStat_t* chstat = (chStat_t*)data;
for(int channel = 0; channel < NUM_CHANNELS; channel++)
{
cnt += fprintf(outfp, "%2d, ", chstat->pce + 1);
cnt += fprintf(outfp, "%2u, ", chstat->pce + 1);
cnt += fprintf(outfp, "%2d, ", channel + 1);
cnt += fprintf(outfp, "%7d, ", chstat->statcnt);
cnt += fprintf(outfp, "%7d, ", chstat->rx_cnt[channel]);
cnt += fprintf(outfp, "%7d, ", chstat->num_dupr[channel]);
cnt += fprintf(outfp, "%7u, ", chstat->statcnt);
cnt += fprintf(outfp, "%7u, ", chstat->rx_cnt[channel]);
cnt += fprintf(outfp, "%7u, ", chstat->num_dupr[channel]);
cnt += fprintf(outfp, "%7.1lf, ", chstat->tdc_calr[channel]);
cnt += fprintf(outfp, "%7.1lf, ", chstat->min_calr[channel]);
cnt += fprintf(outfp, "%7.1lf, ", chstat->max_calr[channel]);
cnt += fprintf(outfp, "%7.1lf, ", chstat->avg_calr[channel]);
cnt += fprintf(outfp, "%7d, ", chstat->num_dupf[channel]);
cnt += fprintf(outfp, "%7u, ", chstat->num_dupf[channel]);
cnt += fprintf(outfp, "%7.1lf, ", chstat->tdc_calf[channel]);
cnt += fprintf(outfp, "%7.1lf, ", chstat->min_calf[channel]);
cnt += fprintf(outfp, "%7.1lf, ", chstat->max_calf[channel]);
Expand Down Expand Up @@ -276,15 +276,15 @@ int AtlasFileWriter::writeSciTx (void* msg, int size, bool with_header)
if(!data) return 0;

txStat_t* stat = (txStat_t*)data;
cnt += fprintf(outfp, "%7d, ", stat->pce + 1);
cnt += fprintf(outfp, "%7d, ", stat->statcnt);
cnt += fprintf(outfp, "%5d, ", stat->txcnt);
cnt += fprintf(outfp, "%6d, ", stat->min_tags[STRONG_SPOT]);
cnt += fprintf(outfp, "%7d, ", stat->max_tags[STRONG_SPOT]);
cnt += fprintf(outfp, "%7u, ", stat->pce + 1);
cnt += fprintf(outfp, "%7u, ", stat->statcnt);
cnt += fprintf(outfp, "%5u, ", stat->txcnt);
cnt += fprintf(outfp, "%6u, ", stat->min_tags[STRONG_SPOT]);
cnt += fprintf(outfp, "%7u, ", stat->max_tags[STRONG_SPOT]);
cnt += fprintf(outfp, "%7.1lf, ", stat->avg_tags[STRONG_SPOT]);
cnt += fprintf(outfp, "%7.1lf, ", stat->std_tags[STRONG_SPOT]);
cnt += fprintf(outfp, "%6d, ", stat->min_tags[WEAK_SPOT]);
cnt += fprintf(outfp, "%7d, ", stat->max_tags[WEAK_SPOT]);
cnt += fprintf(outfp, "%6u, ", stat->min_tags[WEAK_SPOT]);
cnt += fprintf(outfp, "%7u, ", stat->max_tags[WEAK_SPOT]);
cnt += fprintf(outfp, "%7.1lf, ", stat->avg_tags[WEAK_SPOT]);
cnt += fprintf(outfp, "%7.1lf, ", stat->std_tags[WEAK_SPOT]);
cnt += fprintf(outfp, "%8.5lf, ", stat->min_delta);
Expand Down Expand Up @@ -338,11 +338,11 @@ int AtlasFileWriter::writeCcsdsStat (void* msg, int size, bool with_header)
CcsdsPacketParser::pktStats_t* stat = (CcsdsPacketParser::pktStats_t*)data;
if((size - typelen) == sizeof(CcsdsPacketParser::pktStats_t))
{
cnt += fprintf(outfp, "%6d, ", stat->total_pkts);
cnt += fprintf(outfp, "%6d, ", stat->total_bytes);
cnt += fprintf(outfp, "%6d, ", stat->pkts_dropped);
cnt += fprintf(outfp, "%3d, ", stat->curr_pkts);
cnt += fprintf(outfp, "%3d, ", stat->curr_bytes);
cnt += fprintf(outfp, "%6u, ", stat->total_pkts);
cnt += fprintf(outfp, "%6u, ", stat->total_bytes);
cnt += fprintf(outfp, "%6u, ", stat->pkts_dropped);
cnt += fprintf(outfp, "%3u, ", stat->curr_pkts);
cnt += fprintf(outfp, "%3u, ", stat->curr_bytes);
cnt += fprintf(outfp, "%.1lf, ", stat->max_bps);
cnt += fprintf(outfp, "%.1lf, ", stat->min_bps);
cnt += fprintf(outfp, "%.1lf, ", stat->avg_bps);
Expand Down Expand Up @@ -519,9 +519,6 @@ int AtlasFileWriter::writeTimeDiag (void* msg, int size, bool with_header)
{
int cnt = 0;

const int num_sxp_status = 11;
const char* sxp_status[num_sxp_status] = { "Unknown", "Good", "Not_Enabled", "Could_Not_Run", "Spot_At_TQ_Failed", "Spot_Velocity_Failed", "Range_Velocity_Failed", "Off_Nadir_Velocity_Failed", "Params_Failed", "Failed", "Timeout" };

if(with_header)
{
cnt += fprintf(outfp, "%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s,%12s\n", "REF", "TIME_REF", "SC_1PPS", "SC_TAT_RX", "SC_ATT_RX", "SC_POS_RX", "SC_ATT_SOL", "SC_POS_SOL", "SXP_PCE1_TIME_RX", "SXP_PCE2_TIME_RX", "SXP_PCE3_TIME_RX", "SXP_1ST_MF1_EXTRAP", "SXP_1ST_MF2_EXTRAP", "SXP_1ST_MF3_EXTRAP", "PCE1_1ST_MF_AFTER_1PPS", "PCE2_1ST_MF_AFTER_1PPS", "PCE3_1ST_MF_AFTER_1PPS", "SXP_STATUS");
Expand Down Expand Up @@ -551,8 +548,10 @@ int AtlasFileWriter::writeTimeDiag (void* msg, int size, bool with_header)
cnt += fprintf(outfp, "%12lf,", timediag->pce_1st_mf_1pps_delta[0]);
cnt += fprintf(outfp, "%12lf,", timediag->pce_1st_mf_1pps_delta[1]);
cnt += fprintf(outfp, "%12lf,", timediag->pce_1st_mf_1pps_delta[2]);
const int num_sxp_status = 11;
if(timediag->sxp_status[0] >= 0 && timediag->sxp_status[0] < num_sxp_status)
{
const char* sxp_status[num_sxp_status] = { "Unknown", "Good", "Not_Enabled", "Could_Not_Run", "Spot_At_TQ_Failed", "Spot_Velocity_Failed", "Range_Velocity_Failed", "Off_Nadir_Velocity_Failed", "Params_Failed", "Failed", "Timeout" };
cnt += fprintf(outfp, "%12s\n", sxp_status[timediag->sxp_status[0]]);
}
else
Expand Down
14 changes: 7 additions & 7 deletions plugins/atlas/plugin/AtlasFileWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@ class AtlasFileWriter: public CcsdsFileWriter
TIMEDIAG,
TIMESTAT,
INVALID
} fmt_t;
} atlas_fmt_t;

AtlasFileWriter (CommandProcessor* cmd_proc, const char* name, fmt_t _fmt, const char* _prefix, const char* inq_name, unsigned int _max_file_size=FILE_MAX_SIZE);
AtlasFileWriter (CommandProcessor* cmd_proc, const char* name, atlas_fmt_t _fmt, const char* _prefix, const char* inq_name, unsigned int _max_file_size=FILE_MAX_SIZE);
virtual ~AtlasFileWriter (void);

static CommandableObject* createObject (CommandProcessor* cmd_proc, const char* name, int argc, char argv[][MAX_CMD_SIZE]);

static fmt_t str2fmt (const char* str);
static const char* fmt2str (fmt_t _fmt);
static atlas_fmt_t str2fmt (const char* str);
static const char* fmt2str (atlas_fmt_t _fmt);

protected:

int writeMsg (void* msg, int size, bool with_header=false);
bool isBinary (void);
int writeMsg (void* msg, int size, bool with_header=false) override;
bool isBinary (void) override;

private:

fmt_t fmt;
atlas_fmt_t atlas_fmt;

int writeSciPkt (void* record, int size, bool with_header=false);
int writeSciCh (void* record, int size, bool with_header=false);
Expand Down
2 changes: 1 addition & 1 deletion plugins/atlas/plugin/AtlasHistogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ AtlasHistogram::AtlasHistogram(const char* _rec_type, type_t _type,
RecordObject(_rec_type)
{
/* Set Histogram Pointer */
hist = (hist_t*)recordData;
hist = reinterpret_cast<hist_t*>(recordData);

/* Initialize Histogram Fields */
hist->type = _type;
Expand Down
12 changes: 5 additions & 7 deletions plugins/atlas/plugin/CmdEchoProcessorModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ CommandableObject* CmdEchoProcessorModule::createObject(CommandProcessor* cmd_pr
ItosRecordParser* itos = NULL;
if(itos_name != NULL)
{
itos = (ItosRecordParser*)cmd_proc->getObject(itos_name, ItosRecordParser::TYPE);
itos = dynamic_cast<ItosRecordParser*>(cmd_proc->getObject(itos_name, ItosRecordParser::TYPE));
if(itos == NULL)
{
mlog(CRITICAL, "Unable to locate ITOS record parser: %s", itos_name);
Expand All @@ -120,10 +120,8 @@ bool CmdEchoProcessorModule::processSegments(List<CcsdsSpacePacket*>& segments,
{
(void)numpkts;

char echo_msg[ECHO_MSG_STR_SIZE];
char task_prefix[8];
bool status;
unsigned char* cmd_pkt;
char echo_msg[ECHO_MSG_STR_SIZE];
char task_prefix[8];

/* Process Segments */
int numsegs = segments.length();
Expand All @@ -136,8 +134,8 @@ bool CmdEchoProcessorModule::processSegments(List<CcsdsSpacePacket*>& segments,
/* Pull Out Fields */
memset(task_prefix, 0, 8);
memcpy(task_prefix, pktbuf + 12, 7);
status = pktbuf[19] == 0 ? false : true;
cmd_pkt = &pktbuf[20];
bool status = pktbuf[19] == 0 ? false : true;
unsigned char* cmd_pkt = &pktbuf[20];

/* Print Prolog */
if(pce == NOT_PCE)
Expand Down
2 changes: 1 addition & 1 deletion plugins/atlas/plugin/CmdEchoProcessorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CmdEchoProcessorModule: public CcsdsProcessorModule
* Methods
*--------------------------------------------------------------------*/

bool processSegments (List<CcsdsSpacePacket*>& segments, int numpkts);
bool processSegments (List<CcsdsSpacePacket*>& segments, int numpkts) override;
};

#endif /* __cmd_echo_processor_module__ */
6 changes: 2 additions & 4 deletions plugins/atlas/plugin/DiagLogProcessorModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ CommandableObject* DiagLogProcessorModule::createObject(CommandProcessor* cmd_pr
{
const char* diagq_name = StringLib::checkNullStr(argv[0]);
const char* prefix = StringLib::checkNullStr(argv[1]);
int pcenum = NOT_PCE;

if(argc > 2)
{
pcenum = (int)strtol(argv[2], NULL, 0);
int pcenum = (int)strtol(argv[2], NULL, 0);
if(pcenum < 1 || pcenum > NUM_PCES)
{
mlog(CRITICAL, "Invalid PCE specified: %d, must be between 1 and %d", pcenum, NUM_PCES);
Expand Down Expand Up @@ -115,7 +114,6 @@ bool DiagLogProcessorModule::processSegments(List<CcsdsSpacePacket*>& segments,

char diagmsg[DIAG_LOG_STR_SIZE + 2];
int msgindex = 0;
int msgsize = 0;

/* Populate Prefix */
if(prefix)
Expand All @@ -134,7 +132,7 @@ bool DiagLogProcessorModule::processSegments(List<CcsdsSpacePacket*>& segments,
/* Copy Out Log Message */
int diagmsg_len = strnlen((const char*)&pktbuf[DIAG_LOG_START], DIAG_LOG_STR_SIZE - (DIAG_LOG_START + msgindex));
memcpy(&diagmsg[msgindex], &pktbuf[DIAG_LOG_START], diagmsg_len);
msgsize = diagmsg_len + msgindex;
int msgsize = diagmsg_len + msgindex;

/* Decide on New Line */
if(diagmsg_len < (DIAG_LOG_STR_SIZE - DIAG_LOG_START))
Expand Down
2 changes: 1 addition & 1 deletion plugins/atlas/plugin/DiagLogProcessorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DiagLogProcessorModule: public CcsdsProcessorModule
* Methods
*--------------------------------------------------------------------*/

bool processSegments (List<CcsdsSpacePacket*>& segments, int numpkts);
bool processSegments (List<CcsdsSpacePacket*>& segments, int numpkts) override;
};

#endif /* __diag_log_processor_module__ */
Loading

0 comments on commit 5fc9711

Please sign in to comment.