Skip to content
Snippets Groups Projects
Commit 83991359 authored by Martin Hoffmann's avatar Martin Hoffmann Committed by Gerrit Code Review
Browse files

Merge "Coding Guideline: Fixes."

parents ab9c0edf 6fa0ae97
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,6 @@
*/
class RealtimeLogger : public fail::ExperimentFlow
{
private:
const fail::ElfSymbol m_symbol; //!< the target's memory symbol the plugin is listening on
std::string m_outputfile; //!< the output filename
......
......@@ -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);
}
double Sine::calculate() const {
double Sine::calculate() const
{
simtime_t tps = ticksPerSecond();
if(tps == 0){
// Simulator speed not valid.
return 0;
// Simulator speed not valid.
return 0;
}
// Get simulation time in seconds.
......@@ -56,7 +58,7 @@ double Sine::calculate() const {
for(Sine::SineParamsList_t::const_iterator it = m_params.begin();
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;
}
......
......@@ -22,22 +22,23 @@ static const float MYPI = 3.14159265358979323846f;
*/
class SignalForm {
mutable fail::Logger m_log;
mutable fail::Logger m_log;
public:
public:
/**
* Signalgenerator just calls the calculate method of a derived signal
* form.
*/
virtual double calculate(void) const = 0;
protected:
protected:
SignalForm() : m_log("SigForm", false) {};
fail::simtime_t ticksPerSecond(void) const {
fail::simtime_t ticksPerSecond(void) const
{
fail::simtime_t ticksPerSec = fail::simulator.getTimerTicksPerSecond();
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;
}
......@@ -84,14 +85,15 @@ private:
* Generating superimposed sine waves,
* according to the SineParams_t parameters.
*/
class Sine : public SignalForm {
public:
class Sine : public SignalForm
{
public:
//! Parameter set for a single wave
struct SineParams_t {
double freq_in_hz; //!< Freqency in Hz
double amplitude; //!< between 0..1
SineParams_t(double f, double a) : freq_in_hz(f), amplitude(a) {};
double freq_in_hz; //!< Freqency in Hz
double amplitude; //!< between 0..1
SineParams_t(double f, double a) : freq_in_hz(f), amplitude(a) {};
};
//! Multiple sine waves can be superimposed (e.g., summed up)
......@@ -106,8 +108,9 @@ class Sine : public SignalForm {
* simulator time t (in seconds):
* \f$x = sin(2 pi f t)\f$
**/
double sinus(double freq_hertz, double t) const {
return sin((2. * MYPI * freq_hertz) * t);
double sinus(double freq_hertz, double t) const
{
return sin((2. * MYPI * freq_hertz) * t);
}
double calculate(void) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment