30 classType =
"TimeseriesBuffer";
31 featureExtractionType = classType;
32 debugLog.setProceedingText(
"[DEBUG TimeseriesBuffer]");
33 errorLog.setProceedingText(
"[ERROR TimeseriesBuffer]");
34 warningLog.setProceedingText(
"[WARNING TimeseriesBuffer]");
36 init(bufferSize,numDimensions);
41 classType =
"TimeseriesBuffer";
42 featureExtractionType = classType;
43 debugLog.setProceedingText(
"[DEBUG TimeseriesBuffer]");
44 errorLog.setProceedingText(
"[ERROR TimeseriesBuffer]");
45 warningLog.setProceedingText(
"[WARNING TimeseriesBuffer]");
57 this->bufferSize = rhs.bufferSize;
67 if( featureExtraction == NULL )
return false;
77 errorLog <<
"clone(FeatureExtraction *featureExtraction) - FeatureExtraction Types Do Not Match!" << std::endl;
85 errorLog <<
"computeFeatures(const VectorFloat &inputVector) - Not initialized!" << std::endl;
89 if( inputVector.size() != numInputDimensions ){
90 errorLog <<
"computeFeatures(const VectorFloat &inputVector) - The size of the inputVector (" << inputVector.size() <<
") does not match that of the filter (" << numInputDimensions <<
")!" << std::endl;
101 return init( bufferSize, numInputDimensions );
109 file.open(filename.c_str(), std::ios::out);
123 file.open(filename.c_str(), std::ios::in);
137 if( !file.is_open() ){
138 errorLog <<
"saveModelToFile(fstream &file) - The file is not open!" << std::endl;
143 file <<
"GRT_TIMESERIES_BUFFER_FILE_V1.0" << std::endl;
147 errorLog <<
"saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << std::endl;
159 if( !file.is_open() ){
160 errorLog <<
"loadModelFromFile(fstream &file) - The file is not open!" << std::endl;
169 if( word !=
"GRT_TIMESERIES_BUFFER_FILE_V1.0" ){
170 errorLog <<
"loadModelFromFile(fstream &file) - Invalid file format!" << std::endl;
175 errorLog <<
"loadFeatureExtractionSettingsFromFile(fstream &file) - Failed to load base feature extraction settings from file!" << std::endl;
180 if( word !=
"BufferSize:" ){
181 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read BufferSize header!" << std::endl;
187 return init(bufferSize,numInputDimensions);
193 featureDataReady =
false;
195 if( bufferSize == 0 ){
196 errorLog <<
"init(UINT bufferSize,UINT numDimensions) - The bufferSize must be greater than zero!" << std::endl;
200 if( numDimensions == 0 ){
201 errorLog <<
"init(UINT bufferSize,UINT numDimensions) - The numDimensions must be greater than zero!" << std::endl;
206 numInputDimensions = numDimensions;
207 numOutputDimensions = bufferSize * numInputDimensions;
208 this->bufferSize = bufferSize;
210 featureVector.
resize(numOutputDimensions,0);
226 errorLog <<
"update(const VectorFloat &x) - Not Initialized!" << std::endl;
230 if( x.
getSize() != numInputDimensions ){
231 errorLog <<
"update(const VectorFloat &x)- The Number Of Input Dimensions (" << numInputDimensions <<
") does not match the size of the input vector (" << x.
getSize() <<
")!" << std::endl;
240 for(UINT j=0; j<numInputDimensions; j++){
242 featureVector[ colIndex++ ] =
dataBuffer[i][j];
248 featureDataReady =
true;
249 }
else featureDataReady =
false;
251 return featureVector;
255 if( bufferSize > 0 ){
256 this->bufferSize = bufferSize;
257 if( initialized )
return init(bufferSize, numInputDimensions);
260 errorLog <<
"setBufferSize(UINT bufferSize) - The bufferSize must be larger than zero!" << std::endl;
265 if( initialized )
return bufferSize;
virtual bool loadModelFromFile(std::string filename)
bool push_back(const T &value)
virtual bool saveModelToFile(std::string filename) const
TimeseriesBuffer & operator=(const TimeseriesBuffer &rhs)
bool setBufferSize(UINT bufferSize)
bool getBufferFilled() const
VectorFloat update(Float x)
virtual bool resize(const unsigned int size)
unsigned int getSize() const
TimeseriesBuffer(UINT bufferSize=5, UINT numDimensions=1)
virtual ~TimeseriesBuffer()
virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction)
virtual bool computeFeatures(const VectorFloat &inputVector)
Vector< T > getData(const bool rawBuffer=false) const
This class implements the TimeseriesBuffer feature extraction module.
unsigned int getSize() const
CircularBuffer< VectorFloat > dataBuffer
A buffer used to store the timeseries data.
Vector< VectorFloat > getDataBuffer()
bool resize(const unsigned int newBufferSize)