OpenCurves  0.9

A plot generator which loads data from CSV style text files. More...

#include <plotfileloader.h>

Inheritance diagram for PlotFileLoader:
PlotGenerator

Public Member Functions

 PlotFileLoader (Curves *curves, const QStringList &plotFiles, QVector< TimeSampling > *timing=nullptr)
 Creates a loader for the given file set. More...
 
bool append (const QStringList &plotFiles, QVector< TimeSampling > *timing=nullptr)
 Append a list of files to the currently loading list of files. More...
 
void setTargetSampleCount (uint target)
 Set the target maximum number of sample points in a curve. More...
 
uint targetSampleCount () const
 Access the target sample count. More...
 
virtual bool isFileLoad () const override
 True. More...
 
- Public Member Functions inherited from PlotGenerator
 PlotGenerator (Curves *curves)
 Instantiate the generator thread to load data into curves. More...
 
virtual ~PlotGenerator ()
 Destructor. The thread should generally be stopped before destructing.
 
const Curvescurves () const
 Access the curves model to load data into.
 
void setTimeColumn (uint number)
 Set the expected time column for all curves created by this generator. More...
 
uint timeColumn () const
 The time column value in used. More...
 
void setTimeScale (double scale)
 Set the scale factor applied to all curves created by this generator. More...
 
double timeScale () const
 Access the time scale used by this generator. More...
 
void setControlFlags (uint flags)
 Sets ControlFlag values for this generator. More...
 
void setControlFlags (uint flags, bool on)
 Set the state of subset of ControlFlag values without affecting other flags. More...
 
uint controlFlags () const
 Access the current ControlFlag values.
 
void quit ()
 Call to request the generator terminate operation.
 

Protected Member Functions

void run () override
 File loading implementation.
 

Additional Inherited Members

- Public Types inherited from PlotGenerator
enum  ControlFlag { None = 0, RelativeTime = (1 << 0) }
 Plot generation control flags. Must be set before execution. More...
 
- Public Slots inherited from PlotGenerator
void abortLoad ()
 Request loading abort.
 
- Signals inherited from PlotGenerator
void itemName (const QString &name)
 Signal the current item name. More...
 
void itemProgress (int current)
 Update progress through the current item. More...
 
void overallProgress (int current, int total)
 This signal reports overall progress. More...
 
void beginNewCurves ()
 Begin the addition of new curves via Curves::newCurve() Block notification occurs at a per PlotSource level. More...
 
void endNewCurves ()
 End notification of new curves via Curves::newCurve(). More...
 
void loadComplete (int curveCount)
 Notify completion of curve generation. More...
 
- Protected Attributes inherited from PlotGenerator
Curves_curves
 Curves data model.
 
QMutex * _dataMutex
 Data mutex.
 
uint _controlFlags
 ControlFlag values affecting generation.
 
uint _timeColumn
 Index of the time column, zero for none.
 
double _timeScale
 Time scaling factor.
 
bool _abortFlag
 Abort requested?
 

Detailed Description

A plot generator which loads data from CSV style text files.

Data loading is supported by the PlotFile class. See that class for more details of how data are loaded.

The file loader may optionally down-sample the data file by skipping data lines. This is controlled by the targetSampleCount(). A crude estimate is made of the number of lines in the data file and lines are skipped to attempt to meet the target. The line count estimate is made by determining the length of the first data line and dividing the file by this value. All samples are loaded if the estimate does not exceed the target.

The first and last data lines are always preserved.

General usage is to construct the generator with the files to load, the start() the thread. Additional files may be queued using append(), but a new loader is required if this call fails.

Each file may optionally be given its own TimeSampling to set the time column, time scale and base time.

Constructor & Destructor Documentation

PlotFileLoader::PlotFileLoader ( Curves curves,
const QStringList &  plotFiles,
QVector< TimeSampling > *  timing = nullptr 
)

Creates a loader for the given file set.

Parameters
curvesThe Curves model to add curves to.
plotFilesThe list of files to load.
timingOptionally specifying timing data for each file. Uses as many as it can, attempting to match 1-to-1 with plotFiles, but supports element count mismatches. Falls back to the generator's general time settings.

Member Function Documentation

bool PlotFileLoader::append ( const QStringList &  plotFiles,
QVector< TimeSampling > *  timing = nullptr 
)

Append a list of files to the currently loading list of files.

This extends the files to load as if originally given to the constructor. The call is thread-safe and extends the list before or during loading, but fails if the loading thread has progressed beyond the load loop.

Parameters
plotFilesThe additional files to load.
timingOptional timing data for the plot files. See constructor.
Returns
True if the file list has been added, false if the thread has already completed loading.
virtual bool PlotFileLoader::isFileLoad ( ) const
inlineoverridevirtual

True.

Returns
true.

Reimplemented from PlotGenerator.

void PlotFileLoader::setTargetSampleCount ( uint  target)
inline

Set the target maximum number of sample points in a curve.

This limits the number of loaded samples for large files.

Parameters
targetThe target sample count.
uint PlotFileLoader::targetSampleCount ( ) const
inline

Access the target sample count.

Returns
The target number of samples per PlotInstance.

The documentation for this class was generated from the following file: