Disaggregate
Disaggregate Smart Meter data
|
Classes | |
struct | PlotData |
Structure for storing details about data elements to be plotted. More... | |
struct | PlotVars |
Structure for storing variables destined for a GNUplot script. More... | |
Functions | |
void | plot (PlotVars &gnuPlotVars, const bool verbose=false) |
Plot a graph using GNUplot. | |
void | sanitise (PlotVars *pv_p) |
Replace all characters which might confuse 'sed'. | |
void | sanitise (std::string *str_p) |
void | sanitise (std::list< PlotData > *data_p) |
void | instantiateTemplate (const PlotVars &gnuPlotVars, const bool verbose=false) |
Replaces all the tokens in the template file 'config/plotVars.inFilename' with variables from 'plotVars' and outputs the instantiated template as 'plotVars.outFilename' in the directory defined by DATA_OUTPUT_PATH. |
void GNUplot::instantiateTemplate | ( | const PlotVars & | plotVars, |
const bool | verbose = false |
||
) |
Replaces all the tokens in the template file 'config/plotVars.inFilename' with variables from 'plotVars' and outputs the instantiated template as 'plotVars.outFilename' in the directory defined by DATA_OUTPUT_PATH.
Tokens replaced in template = TITLE XLABEL YLABEL SETTERMINAL SETOUTPUT PLOTARGS
for each datafile: <tokenbase>FILE <tokenbase>KEY
The find-and-replace functionality is currently implemented using a 'system()' call to 'sed'. This is a bit of a hack but it was quick to implement, works perfectly well and isn't a bottleneck. In a perfect world, it'd be nice to implement a find-and-replace template instantiation system using something like Boost.Regex::regex_replace() or Boost's String Algorithms.
plotVars | Variables for insertion into the template. |
Definition at line 121 of file GNUplot.cpp.
References GNUplot::PlotVars::data, DATA_OUTPUT_PATH, GNUPLOT_OUTPUT_FILE_EXTENSION, GNUPLOT_SET_TERMINAL, GNUplot::PlotVars::inFilename, GNUplot::PlotVars::outFilename, GNUplot::PlotVars::plotArgs, sanitise(), GNUplot::PlotVars::title, GNUplot::PlotVars::xlabel, and GNUplot::PlotVars::ylabel.
Referenced by plot().
void GNUplot::plot | ( | PlotVars & | plotVars, |
const bool | verbose = false |
||
) |
Plot a graph using GNUplot.
First checks to see if config/'plotVars.outFilename'.template.gnu
exists. If it does, it uses that as the template (so individual devices can have their own specific templates). If it doesn't exist, the code uses config/'plotVars.inFilename'.template.gnu
as the template.
plotVars | Variables for insertion into the template. 'inFilename' will be changed if config/'inFilename'.template.gnu exists. Strings will be sanitised. |
Definition at line 32 of file GNUplot.cpp.
References DATA_OUTPUT_PATH, Utils::fileExists(), GNUPLOT_OUTPUT_FILE_EXTENSION, GNUplot::PlotVars::inFilename, instantiateTemplate(), GNUplot::PlotVars::outFilename, and sanitise().
Referenced by PowerStateGraph::displayAndPlotFingerprintList(), Histogram::drawGraph(), Array< Sample_t >::drawGraph(), Signature::drawHistWithStateBars(), and PowerStateSequence::plotGraph().
void GNUplot::sanitise | ( | std::list< PlotData > * | data_p | ) |
data_p | Input and output |
Definition at line 79 of file GNUplot.cpp.
References sanitise().
void GNUplot::sanitise | ( | std::string * | str_p | ) |
str_p | Input and output |
Definition at line 89 of file GNUplot.cpp.
void GNUplot::sanitise | ( | PlotVars * | pv_p | ) |
Replace all characters which might confuse 'sed'.
In particular, this function replaces: '/' -> '\/'
pv_p | Input and output |
Definition at line 67 of file GNUplot.cpp.
References GNUplot::PlotVars::data, GNUplot::PlotVars::inFilename, GNUplot::PlotVars::outFilename, GNUplot::PlotVars::title, GNUplot::PlotVars::xlabel, and GNUplot::PlotVars::ylabel.
Referenced by instantiateTemplate(), plot(), and sanitise().