formatting, typos, comments, details

Change-Id: Iae5f1acb653a694622e9ac2bad93efcfca588f3a
This commit is contained in:
Horst Schirmeier
2013-10-14 14:43:39 +02:00
parent 7591c9edc5
commit 4cb97a7fa5
138 changed files with 1566 additions and 1576 deletions

View File

@ -7,35 +7,35 @@ using namespace fail;
bool RealtimeLogger::run()
{
MemoryManager& mm = simulator.getMemoryManager();
MemoryManager& mm = simulator.getMemoryManager();
uint32_t value; //! @todo more generic datatype
uint32_t value; //! @todo more generic datatype
m_log << "Realtime Logger started. Listening to: " << m_symbol << std::endl;
MemAccessListener ev_mem(m_symbol.getAddress());
m_log << "Realtime Logger started. Listening to: " << m_symbol << std::endl;
MemAccessListener ev_mem(m_symbol.getAddress());
if(m_ostream.is_open()) {
m_log << "Writing output to: " << m_outputfile << std::endl;
while (true) {
simulator.addListenerAndResume(&ev_mem);
/* A Memory Accesses happend: Get simulation time and log it */
fail::simtime_t simtime = simulator.getTimerTicks();
mm.getBytes(m_symbol.getAddress(), m_symbol.getSize(), &value);
handleEvent(simtime, value);
}
} else {
m_log << "No output file." << std::endl;
}
return true;
if (m_ostream.is_open()) {
m_log << "Writing output to: " << m_outputfile << std::endl;
while (true) {
simulator.addListenerAndResume(&ev_mem);
/* A Memory Accesses happend: Get simulation time and log it */
fail::simtime_t simtime = simulator.getTimerTicks();
mm.getBytes(m_symbol.getAddress(), m_symbol.getSize(), &value);
handleEvent(simtime, value);
}
} else {
m_log << "No output file." << std::endl;
}
return true;
}
void RealtimeLogger::handleEvent(fail::simtime_t simtime, uint32_t value)
{
simtime_t per_second = simulator.getTimerTicksPerSecond();
double sec = (double)simtime / per_second;
double msec = sec*1000;
if(m_ostream.is_open()){
m_ostream << std::dec << msec << ";" << value << std::endl;
}
simtime_t per_second = simulator.getTimerTicksPerSecond();
double sec = (double)simtime / per_second;
double msec = sec*1000;
if (m_ostream.is_open()) {
m_ostream << std::dec << msec << ";" << value << std::endl;
}
}

View File

@ -1,5 +1,5 @@
#ifndef __REALTIMELOGGER_HPP__
#define __REALTIMELOGGER_HPP__
#define __REALTIMELOGGER_HPP__
#include <string>
#include <unistd.h>
@ -11,39 +11,38 @@
/**
* @class RealtimeLogger
* @brief Listens to a memory location and outputs content on write access
* @brief Listens to a memory location and outputs content on write access
* from SUT to file
*/
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
fail::Logger m_log; //!< debug output
std::ofstream m_ostream; //!< Outputfile stream
const fail::ElfSymbol m_symbol; //!< the target's memory symbol the plugin is listening on
std::string m_outputfile; //!< the output filename
fail::Logger m_log; //!< debug output
std::ofstream m_ostream; //!< Outputfile stream
public:
/**
* Constructor of RealtimeLogger.
*
* @param symbol The global memory address the plugin listens to
* @param outputfile The path to the file to write the output to
*/
RealtimeLogger( const fail::ElfSymbol & symbol, const std::string& outputfile ) : m_symbol(symbol), m_outputfile(outputfile) , m_log("RTLogger", false) {
m_ostream.open(m_outputfile.c_str() );
if(!m_ostream.is_open()){
m_log << "Could not open " << m_outputfile.c_str() << " for writing." << std::endl;
}
}
/**
* Constructor of RealtimeLogger.
*
* @param symbol The global memory address the plugin listens to
* @param outputfile The path to the file to write the output to
*/
RealtimeLogger( const fail::ElfSymbol & symbol, const std::string& outputfile ) : m_symbol(symbol), m_outputfile(outputfile) , m_log("RTLogger", false) {
m_ostream.open(m_outputfile.c_str() );
if (!m_ostream.is_open()) {
m_log << "Could not open " << m_outputfile.c_str() << " for writing." << std::endl;
}
}
bool run();
bool run();
private:
/**
* Handle the memory event
*/
void handleEvent(fail::simtime_t simtime, uint32_t value);
/**
* Handle the memory event
*/
void handleEvent(fail::simtime_t simtime, uint32_t value);
};
#endif // __REALTIMELOGGER_HPP__

View File

@ -1,5 +1,5 @@
#ifndef __SERIAL_OUTPUT_HPP__
#define __SERIAL_OUTPUT_HPP__
#define __SERIAL_OUTPUT_HPP__
#include <string>
@ -8,7 +8,7 @@
// Check if configuration dependencies are satisfied:
#if !defined(CONFIG_EVENT_IOPORT)
#warning The serialoutput plugin may (depending on its use) need ioport event. Enable these in the cmake configuration tool.
#warning The serialoutput plugin may (depending on its use) need ioport event. Enable these in the cmake configuration tool.
#endif
/**
@ -18,7 +18,7 @@
*/
class SerialOutput : public fail::ExperimentFlow
{
private:
bool m_out; //!< Defines the direction of the listener.
unsigned m_port; //!< the port the listener is listening on
@ -27,7 +27,7 @@ private:
public:
/**
* Constructor of SerialOutput.
*
*
* @param port the port the listener is listening on
* @param out Defines the direction of the listener.
* \arg \c true Output on the given port is captured. This is default.
@ -37,7 +37,7 @@ public:
bool run();
/**
* Resets the output variable which contains the traffic of
* ioport.
* ioport.
*/
void resetOutput();
/**

View File

@ -7,59 +7,58 @@ using namespace fail;
bool SignalGenerator::run()
{
m_log << "Signalgenerator started. @ " << m_symbol << std::endl;
m_log << "Signalgenerator started. @ " << m_symbol << std::endl;
MemoryManager& mm = simulator.getMemoryManager();
MemReadListener l_mem(m_symbol.getAddress());
MemoryManager& mm = simulator.getMemoryManager();
MemReadListener l_mem(m_symbol.getAddress());
/**
* for EZS we currently use 8bit ADCs.
* @todo Make more versatile for future use.
*/
uint8_t value;
/**
* for EZS we currently use 8bit ADCs.
* @todo Make more versatile for future use.
*/
uint8_t value;
while (true) {
simulator.addListenerAndResume(&l_mem);
value = handleEvent();
mm.setBytes(m_symbol.getAddress(), sizeof(value), &value);
}
return true;
while (true) {
simulator.addListenerAndResume(&l_mem);
value = handleEvent();
mm.setBytes(m_symbol.getAddress(), sizeof(value), &value);
}
return true;
}
uint8_t SignalGenerator::handleEvent(void)
{
double val = m_signal->calculate();
// Scale to uint8: 0 .. 255
val = val * 127; // -1: -127 .. +1: +127
val = val + 127; // -127: 0 .. +127 : 254
return (uint8_t) val;
double val = m_signal->calculate();
// Scale to uint8: 0 .. 255
val = val * 127; // -1: -127 .. +1: +127
val = val + 127; // -127: 0 .. +127 : 254
return (uint8_t) val;
}
Sine::Sine(const SineParams_t param)
{
m_params.push_back(param);
m_params.push_back(param);
}
double Sine::calculate() const
{
simtime_t tps = ticksPerSecond();
if(tps == 0){
// Simulator speed not valid.
return 0;
}
simtime_t tps = ticksPerSecond();
if (tps == 0) {
// Simulator speed not valid.
return 0;
}
// Get simulation time in seconds.
double sec = (double)simulator.getTimerTicks() / tps;
// Get simulation time in seconds.
double sec = (double)simulator.getTimerTicks() / tps;
// Sum up all sine waves
double val = 0;
for(Sine::SineParamsList_t::const_iterator it = m_params.begin();
it != m_params.end(); it++)
{
val += it->amplitude * sinus(it->freq_in_hz, sec);
}
return val;
// Sum up all sine waves
double val = 0;
for (Sine::SineParamsList_t::const_iterator it = m_params.begin();
it != m_params.end(); it++)
{
val += it->amplitude * sinus(it->freq_in_hz, sec);
}
return val;
}

View File

@ -1,5 +1,5 @@
#ifndef __SIGNALGENERATOR_HPP__
#define __SIGNALGENERATOR_HPP__
#define __SIGNALGENERATOR_HPP__
#include <unistd.h>
#include "efw/ExperimentFlow.hpp"
@ -22,26 +22,26 @@ static const float MYPI = 3.14159265358979323846f;
*/
class SignalForm {
mutable fail::Logger m_log;
mutable fail::Logger m_log;
public:
/**
* Signalgenerator just calls the calculate method of a derived signal
* form.
*/
virtual double calculate(void) const = 0;
/**
* Signalgenerator just calls the calculate method of a derived signal
* form.
*/
virtual double calculate(void) const = 0;
protected:
SignalForm() : m_log("SigForm", false) {};
SignalForm() : m_log("SigForm", false) {};
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;
}
return ticksPerSec;
}
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;
}
return ticksPerSec;
}
};
@ -55,25 +55,25 @@ protected:
class SignalGenerator : public fail::ExperimentFlow
{
private:
const fail::ElfSymbol m_symbol; //!< the target's memory symbol the plugin is listening on to generate value
fail::Logger m_log; //!< debug output
const SignalForm *const m_signal; //!< Abstract signal form provided by the user
const fail::ElfSymbol m_symbol; //!< the target's memory symbol the plugin is listening on to generate value
fail::Logger m_log; //!< debug output
const SignalForm *const m_signal; //!< Abstract signal form provided by the user
public:
/**
* Constructor
*
* @param symbol The resulting signal value is placed in the SUT symbol
* @param signal The Signal form to be generated @see SignalForm
*/
SignalGenerator( const fail::ElfSymbol & symbol, SignalForm *signal ) : m_symbol(symbol), m_log("SigGen", false), m_signal(signal){}
/**
* Constructor
*
* @param symbol The resulting signal value is placed in the SUT symbol
* @param signal The Signal form to be generated @see SignalForm
*/
SignalGenerator( const fail::ElfSymbol & symbol, SignalForm *signal ) : m_symbol(symbol), m_log("SigGen", false), m_signal(signal){}
bool run();
bool run();
private:
/**
* Handle the memory event
*/
uint8_t handleEvent(void);
/**
* Handle the memory event
*/
uint8_t handleEvent(void);
};
#include <vector>
@ -89,31 +89,31 @@ 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) {};
};
//! 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) {};
};
//! Multiple sine waves can be superimposed (e.g., summed up)
typedef std::vector<SineParams_t> SineParamsList_t;
SineParamsList_t m_params;
//! Multiple sine waves can be superimposed (e.g., summed up)
typedef std::vector<SineParams_t> SineParamsList_t;
SineParamsList_t m_params;
Sine(const SineParams_t param);
Sine(const SineParamsList_t paramlist) : m_params(paramlist) {};
Sine(const SineParams_t param);
Sine(const SineParamsList_t paramlist) : m_params(paramlist) {};
/**
* Calculate sinus value of frequency freq_hertz based on the given
* 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);
}
/**
* Calculate sinus value of frequency freq_hertz based on the given
* 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 calculate(void) const;
double calculate(void) const;
};
#endif // __SIGNALGENERATOR_HPP__

View File

@ -23,7 +23,7 @@ bool TracingPlugin::run()
if (m_tracetype | TRACE_MEM) {
simulator.addListener(&ev_mem);
}
if(m_protoStreamFile) {
if (m_protoStreamFile) {
ps = new ProtoOStream(m_protoStreamFile);
}

View File

@ -1,5 +1,5 @@
#ifndef __TRACING_PLUGIN_HPP__
#define __TRACING_PLUGIN_HPP__
#define __TRACING_PLUGIN_HPP__
#include <ostream>
@ -12,7 +12,7 @@
// Check if configuration dependencies are satisfied:
#if !defined(CONFIG_EVENT_BREAKPOINTS) || !defined(CONFIG_EVENT_MEMREAD) || !defined(CONFIG_EVENT_MEMWRITE)
#warning The tracing plugin may (depending on its use) need breakpoints and/or read/write memory access events. Enable these in the cmake configuration tool.
#warning The tracing plugin may (depending on its use) need breakpoints and/or read/write memory access events. Enable these in the cmake configuration tool.
#endif
/**
@ -31,8 +31,6 @@
* FIXME: more explicit startup/shutdown; listener-based event interface needed?
* -> should simulator.removeFlow make sure all remaining active events
* are delivered?
* FIXME: trace a sequence of pb messages, not a giant single one (pb weren't
* made for huge messages)
* FIXME: destructor -> removeFlow?
*/
class TracingPlugin : public fail::ExperimentFlow