Select Git revision
datastorage.h
datastorage.h 6.69 KiB
/*************************************************************************
* Copyright (C) 2007 by Oliver Bock *
* bock@tfh-berlin.de *
* *
* This file is part of Fidelity. *
* *
* Fidelity is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, version 3 of the License. *
* *
* Fidelity is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with Fidelity. If not, see <http://www.gnu.org/licenses/>. *
* *
*************************************************************************/
#ifndef DATASTORAGE_H
#define DATASTORAGE_H
#include <QVector>
#include <QDir>
#include <QFile>
#include <QTextStream>
#include <QDataStream>
#include <QPointer>
#include <QMessageBox>
#include <complex>
#include "AComponent.h"
#include "ControlNode.h"
#include "VOTableRoot.h"
#include "VOResource.h"
#include "VOTable.h"
#include "VOField.h"
#include "VOData.h"
#include "VOBinary.h"
#include "VOStream.h"
#include "VOTableData.h"
#include "VOTR.h"
#include "VOTD.h"
#include "PlotDialog.h"
using std::complex;
namespace Fidelity {
namespace Plugin {
namespace Component {
/**
* @author Oliver Bock <bock@tfh-berlin.de>
*
* This class defines a component plugin which provides means for data storage and output in VOTable format.<br>
* <br>
* Parameters:<br>
* <br>
* <table border="1">
* <tr><th>Parameter</th> <th>Unit</th> <th>Notes</th></tr>
* <tr><td>output-path</td> <td> </td> <td>File system path (without filename!) where
* the output files should be written to</td></tr>
* <tr><td>enable-channel2</td> <td> </td> <td>Enable the second data channel (control node).<br>
* <i>Note: leads to higher memory and CPU time consumption!</i></td></tr>
* <tr><td>enable-binary-storage</td> <td> </td> <td>This flag defines whether the output is stored as binary data (default).<br>
* Disable this flag to use XML (VOTable's TABLEDATA) output.</td></tr>
* </table>
* <br>
* Beam nodes:
* <ul>
* <li>n/a</li>
* </ul>
* <br>
* Control nodes:
* <ul>
* <li>cn1: double value input</li>
* <li>cn2: double value input</li>
* </ul>
* <br>
* Mathematical description (LaTeX):<br>
* <br>
* Under construction...<br>
* <br>
*/
class DataStorage : public AComponent
{
Q_OBJECT
Q_INTERFACES(Fidelity::Plugin::Base::IPlugin Fidelity::Plugin::Component::Base::IComponent);
public:
/**
* Constructor
*/
DataStorage();
/**
* Destructor
*/
~DataStorage();
/**
* This method is used by ComponentFactory to create new individual components
* from the "original" one loaded during the loading of the plugin cache.
* @return The new component to be used in a simulation setup.
*/
IComponent* createInstance() const;
/**
* This method is called in the initialisation phase of the simulation.
* @param timeStepAmount The number of time steps this simulation is going to execute.
* @param timeStepLength The time step length describes amount of time in which
* the continuous time is discretised.
* @param defaultFrequency The frequency of the laser being used.
* @param speedOfLight The speed of light constant c.
*/
void init(const long& timeStepAmount, const double& timeStepLength, const double& defaultFrequency, const double& speedOfLight);
/**
* This method is called before each time step.
*/
void pre();
/**
* This method is called at each time step of the main simulation loop.
* @param iteration The current iteration (counter value of the main loop).
* @param t Current time t in seconds.
*/
void step(const long& iteration, const double& t);
/**
* This method is called after each time step.
*/
void post();
/**
* This method is called after the simulation run.
*/
void finalise();
/**
* Returns the XML Schema definition for this component.
* @return The XML schema definition.
*/
QDomDocument xmlSchema() const;
private:
/**
* The path the output.fsd file will be written to after the simulation run.
*/
Parameter<QString>* m_OutputPath;
/**
* The label to be used for channel 1.
*/
Parameter<QString>* m_Channel1Label;
/**
* The unit to be used for channel 1.
*/
Parameter<QString>* m_Channel1Unit;
/**
* The label to be used for channel 2.
*/
Parameter<QString>* m_Channel2Label;
/**
* The unit to be used for channel 2.
*/
Parameter<QString>* m_Channel2Unit;
/**
* The description of the output data.
*/
Parameter<QString>* m_OutputDescription;
/**
* This flag defines whether the second data channel is enabled.
*/
Parameter<bool>* m_EnableChannel2;
/**
* This flag defines whether the output is stored as binary data (default).<br>
* Disable this flag to use XML (VOTable's TABLEDATA) output.
*/
Parameter<bool>* m_EnableBinaryStorage;
/**
* The first input control node of the data storage.
*/
ControlNode<double>* m_ControlNode1;
/**
* The second input control node of the data storage.
*/
ControlNode<double>* m_ControlNode2;
/**
* This is the storage container for the time values.
*/
QVector<double>* m_TimeStorage;
/**
* This is the first storage container for double values.
*/
QVector<double>* m_DataStorage1;
/**
* This is the second storage container for double values.
*/
QVector<double>* m_DataStorage2;
/**
* This member indicates whether or not the data should be plotted.
*/
bool m_ShowPlot;
/**
* The optimize methode is called during init().<br>
* It should offer different ways (and maybe more than one at a time; should be defined in sim-setup!)
* to prepare the computation done during step(). There'll be different optimizations for
* different simulation methods (TD, FD, FFT). Maybe this optimizations could have
* their own factory....?
*/
void optimize();
/**
* Initialise private members of this class.
* Called in the Constructor of this class.
*/
void initAttributes();
};}}}
#endif