Skip to content

Commit 84898c0

Browse files
committed
can now add the board name to the logger output
1 parent 45b6c35 commit 84898c0

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

src/Flux/flxLogger.cpp

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <time.h>
2424

2525
flxLogger::flxLogger()
26-
: _timestampType{TimeStampNone}, _outputDeviceID{false}, _sampleNumberEnabled{false}, _currentSampleNumber{0}
26+
: _timestampType{TimeStampNone}, _outputDeviceID{false}, _outputLocalName{false}, _sampleNumberEnabled{false}, _currentSampleNumber{0}
2727
{
2828
setName("Logger", "Data logging action");
2929

@@ -46,12 +46,19 @@ flxLogger::flxLogger()
4646
flxRegister(resetSampleNumber, "Reset Sample Counter", "Reset the sample number counter to the provided value");
4747

4848
// Output the device ID to the log output?
49-
flxRegister(enableIDOutput, "Output ID", "Include the Device ID in the log output");
49+
flxRegister(enableIDOutput, "Output ID", "Include the Board ID in the log output");
5050

5151
// and the parameter to support the ID?
52-
flxRegister(getDeviceID, "Device ID");
52+
flxRegister(getDeviceID, "Board ID");
5353
removeParameter(getDeviceID); // added on enable of prop
5454

55+
// Output the device Name/ to the log output?
56+
flxRegister(enableNameOutput, "Output Name", "Include the Board Name in the log output");
57+
58+
// and the parameter to support the Name?
59+
flxRegister(getLocalName, "Board Name");
60+
removeParameter(getLocalName); // added on enable of prop
61+
5562
_opsToLog.setName("Logger Objects");
5663

5764
flux.add(this);
@@ -401,6 +408,59 @@ std::string flxLogger::get_device_id(void)
401408
return sBuffer;
402409
}
403410

411+
412+
//----------------------------------------------------------------------------
413+
// Device name methods for output
414+
//----------------------------------------------------------------------------
415+
bool flxLogger::get_name_enable(void)
416+
{
417+
return _outputLocalName;
418+
}
419+
420+
//----------------------------------------------------------------------------
421+
void flxLogger::set_name_enable(bool newMode)
422+
{
423+
if (newMode == _outputLocalName)
424+
return;
425+
426+
// Are we going from having an ID to not having an ID?
427+
if (!newMode)
428+
{
429+
// Remove ID parameter from our internal parameter list
430+
auto iter = std::find(_paramsToLog.begin(), _paramsToLog.end(), &getLocalName);
431+
432+
if (iter != _paramsToLog.end())
433+
_paramsToLog.erase(iter);
434+
}
435+
else
436+
{
437+
// We want the name to be after sample number, timestamp and ID - if they are enabled.
438+
auto iter = _paramsToLog.begin();
439+
if (iter != _paramsToLog.end())
440+
{
441+
// sample number?
442+
if (*iter == &sampleNumber)
443+
iter++;
444+
445+
if (iter != _paramsToLog.end() && *iter == &timestamp)
446+
iter++;
447+
448+
if (iter != _paramsToLog.end() && *iter == &getDeviceID)
449+
iter++;
450+
}
451+
452+
// Add the ID parameter to our output list.
453+
_paramsToLog.insert(iter, &getLocalName);
454+
}
455+
_outputLocalName = newMode;
456+
}
457+
//----------------------------------------------------------------------------
458+
std::string flxLogger::get_name(void)
459+
{
460+
return flux.localName();
461+
}
462+
463+
404464
//----------------------------------------------------------------------------
405465
// Log sample number property get/set
406466
//----------------------------------------------------------------------------

src/Flux/flxLogger.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class flxLogger : public flxActionType<flxLogger>
4646

4747
std::string get_device_id(void);
4848

49+
bool get_name_enable(void);
50+
void set_name_enable(bool);
51+
52+
std::string get_name(void);
53+
4954
bool get_num_mode(void);
5055
void set_num_mode(bool);
5156

@@ -250,6 +255,10 @@ class flxLogger : public flxActionType<flxLogger>
250255
flxPropertyRWBool<flxLogger, &flxLogger::get_id_enable, &flxLogger::set_id_enable> enableIDOutput = {false};
251256
flxParameterOutString<flxLogger, &flxLogger::get_device_id> getDeviceID;
252257

258+
// output Local name to the log
259+
flxPropertyRWBool<flxLogger, &flxLogger::get_name_enable, &flxLogger::set_name_enable> enableNameOutput = {false};
260+
flxParameterOutString<flxLogger, &flxLogger::get_name> getLocalName;
261+
253262
// Sample number - this increments and outputs a number for each sample taken.
254263
flxPropertyRWBool<flxLogger, &flxLogger::get_num_mode, &flxLogger::set_num_mode> numberMode = {false};
255264

@@ -278,6 +287,8 @@ class flxLogger : public flxActionType<flxLogger>
278287
// output device id?
279288
bool _outputDeviceID;
280289

290+
bool _outputLocalName;
291+
281292
bool _sampleNumberEnabled;
282293
uint32_t _currentSampleNumber;
283294

0 commit comments

Comments
 (0)