21 #define GRT_DLL_EXPORTS 27 std::string TimeseriesBuffer::id =
"TimeseriesBuffer";
35 init(bufferSize,numDimensions);
50 this->bufferSize = rhs.bufferSize;
60 if( featureExtraction == NULL )
return false;
62 if( this->
getId() == featureExtraction->
getId() ){
70 errorLog <<
"deepCopyFrom(FeatureExtraction *featureExtraction) - FeatureExtraction Types Do Not Match!" << std::endl;
78 errorLog <<
"computeFeatures(const VectorFloat &inputVector) - Not initialized!" << std::endl;
82 if( inputVector.size() != numInputDimensions ){
83 errorLog <<
"computeFeatures(const VectorFloat &inputVector) - The size of the inputVector (" << inputVector.size() <<
") does not match that of the filter (" << numInputDimensions <<
")!" << std::endl;
94 return init( bufferSize, numInputDimensions );
101 if( !file.is_open() ){
102 errorLog <<
"save(fstream &file) - The file is not open!" << std::endl;
107 file <<
"GRT_TIMESERIES_BUFFER_FILE_V1.0" << std::endl;
111 errorLog <<
"saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << std::endl;
123 if( !file.is_open() ){
124 errorLog <<
"load(fstream &file) - The file is not open!" << std::endl;
133 if( word !=
"GRT_TIMESERIES_BUFFER_FILE_V1.0" ){
134 errorLog <<
"load(fstream &file) - Invalid file format!" << std::endl;
139 errorLog <<
"loadFeatureExtractionSettingsFromFile(fstream &file) - Failed to load base feature extraction settings from file!" << std::endl;
144 if( word !=
"BufferSize:" ){
145 errorLog <<
"load(fstream &file) - Failed to read BufferSize header!" << std::endl;
151 return init(bufferSize,numInputDimensions);
157 featureDataReady =
false;
159 if( bufferSize == 0 ){
160 errorLog <<
"init(UINT bufferSize,UINT numDimensions) - The bufferSize must be greater than zero!" << std::endl;
164 if( numDimensions == 0 ){
165 errorLog <<
"init(UINT bufferSize,UINT numDimensions) - The numDimensions must be greater than zero!" << std::endl;
170 numInputDimensions = numDimensions;
171 numOutputDimensions = bufferSize * numInputDimensions;
172 this->bufferSize = bufferSize;
174 featureVector.
resize(numOutputDimensions,0);
190 errorLog <<
"update(const VectorFloat &x) - Not Initialized!" << std::endl;
194 if( x.
getSize() != numInputDimensions ){
195 errorLog <<
"update(const VectorFloat &x)- The Number Of Input Dimensions (" << numInputDimensions <<
") does not match the size of the input vector (" << x.
getSize() <<
")!" << std::endl;
204 for(UINT j=0; j<numInputDimensions; j++){
206 featureVector[ colIndex++ ] =
dataBuffer[i][j];
212 featureDataReady =
true;
213 }
else featureDataReady =
false;
215 return featureVector;
219 if( bufferSize > 0 ){
220 this->bufferSize = bufferSize;
221 if( initialized )
return init(bufferSize, numInputDimensions);
224 errorLog <<
"setBufferSize(UINT bufferSize) - The bufferSize must be larger than zero!" << std::endl;
229 if( initialized )
return bufferSize;
bool push_back(const T &value)
TimeseriesBuffer & operator=(const TimeseriesBuffer &rhs)
std::string getId() const
bool setBufferSize(const UINT bufferSize)
virtual bool load(std::fstream &file)
bool getBufferFilled() const
virtual bool resize(const unsigned int size)
virtual bool save(std::fstream &file) const
VectorFloat update(const Float x)
TimeseriesBuffer(const UINT bufferSize=5, const UINT numDimensions=1)
static std::string getId()
virtual ~TimeseriesBuffer()
virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction)
UINT getBufferSize() const
virtual bool computeFeatures(const VectorFloat &inputVector)
Vector< T > getData(const bool rawBuffer=false) const
Vector< VectorFloat > getDataBuffer() const
This class implements the TimeseriesBuffer feature extraction module.
unsigned int getSize() const
CircularBuffer< VectorFloat > dataBuffer
A buffer used to store the timeseries data.
bool resize(const unsigned int newBufferSize)