Coding Guideline: Fixes.

Sorry, for the small changesets.

Change-Id: I12e7b1b4efff0c63020613e399f8185ace97aec7
This commit is contained in:
Martin Hoffmann
2013-11-11 13:27:43 +01:00
parent cf95437e65
commit 6fa0ae970b
3 changed files with 22 additions and 18 deletions

View File

@ -16,7 +16,6 @@
*/ */
class RealtimeLogger : public fail::ExperimentFlow class RealtimeLogger : public fail::ExperimentFlow
{ {
private: private:
const fail::ElfSymbol m_symbol; //!< the target's memory symbol the plugin is listening on const fail::ElfSymbol m_symbol; //!< the target's memory symbol the plugin is listening on
std::string m_outputfile; //!< the output filename std::string m_outputfile; //!< the output filename

View File

@ -37,15 +37,17 @@ uint8_t SignalGenerator::handleEvent(void)
Sine::Sine(const SineParams_t param) { Sine::Sine(const SineParams_t param)
{
m_params.push_back(param); m_params.push_back(param);
} }
double Sine::calculate() const { double Sine::calculate() const
{
simtime_t tps = ticksPerSecond(); simtime_t tps = ticksPerSecond();
if(tps == 0){ if(tps == 0){
// Simulator speed not valid. // Simulator speed not valid.
return 0; return 0;
} }
// Get simulation time in seconds. // Get simulation time in seconds.
@ -56,7 +58,7 @@ double Sine::calculate() const {
for(Sine::SineParamsList_t::const_iterator it = m_params.begin(); for(Sine::SineParamsList_t::const_iterator it = m_params.begin();
it != m_params.end(); it++) it != m_params.end(); it++)
{ {
val += it->amplitude * sinus(it->freq_in_hz, sec); val += it->amplitude * sinus(it->freq_in_hz, sec);
} }
return val; return val;
} }

View File

@ -22,22 +22,23 @@ static const float MYPI = 3.14159265358979323846f;
*/ */
class SignalForm { class SignalForm {
mutable fail::Logger m_log; mutable fail::Logger m_log;
public: public:
/** /**
* Signalgenerator just calls the calculate method of a derived signal * Signalgenerator just calls the calculate method of a derived signal
* form. * form.
*/ */
virtual double calculate(void) const = 0; virtual double calculate(void) const = 0;
protected: protected:
SignalForm() : m_log("SigForm", false) {}; SignalForm() : m_log("SigForm", false) {};
fail::simtime_t ticksPerSecond(void) const { fail::simtime_t ticksPerSecond(void) const
{
fail::simtime_t ticksPerSec = fail::simulator.getTimerTicksPerSecond(); fail::simtime_t ticksPerSec = fail::simulator.getTimerTicksPerSecond();
if(ticksPerSec == 0){ if(ticksPerSec == 0){
m_log << "Warning: Timer ticks per second equals 0" << std::endl; m_log << "Warning: Timer ticks per second equals 0" << std::endl;
} }
return ticksPerSec; return ticksPerSec;
} }
@ -84,14 +85,15 @@ private:
* Generating superimposed sine waves, * Generating superimposed sine waves,
* according to the SineParams_t parameters. * according to the SineParams_t parameters.
*/ */
class Sine : public SignalForm { class Sine : public SignalForm
public: {
public:
//! Parameter set for a single wave //! Parameter set for a single wave
struct SineParams_t { struct SineParams_t {
double freq_in_hz; //!< Freqency in Hz double freq_in_hz; //!< Freqency in Hz
double amplitude; //!< between 0..1 double amplitude; //!< between 0..1
SineParams_t(double f, double a) : freq_in_hz(f), amplitude(a) {}; SineParams_t(double f, double a) : freq_in_hz(f), amplitude(a) {};
}; };
//! Multiple sine waves can be superimposed (e.g., summed up) //! Multiple sine waves can be superimposed (e.g., summed up)
@ -106,8 +108,9 @@ class Sine : public SignalForm {
* simulator time t (in seconds): * simulator time t (in seconds):
* \f$x = sin(2 pi f t)\f$ * \f$x = sin(2 pi f t)\f$
**/ **/
double sinus(double freq_hertz, double t) const { double sinus(double freq_hertz, double t) const
return sin((2. * MYPI * freq_hertz) * t); {
return sin((2. * MYPI * freq_hertz) * t);
} }
double calculate(void) const; double calculate(void) const;