29 classType =
"DeadZone";
30 preProcessingType = classType;
31 debugLog.setProceedingText(
"[DEBUG DeadZone]");
32 errorLog.setProceedingText(
"[ERROR DeadZone]");
33 warningLog.setProceedingText(
"[WARNING DeadZone]");
34 init(lowerLimit,upperLimit,numDimensions);
40 classType =
"DeadZone";
41 preProcessingType = classType;
42 debugLog.setProceedingText(
"[DEBUG DeadZone]");
43 errorLog.setProceedingText(
"[ERROR DeadZone]");
44 warningLog.setProceedingText(
"[WARNING DeadZone]");
63 if( preProcessing == NULL )
return false;
76 errorLog <<
"clone(const PreProcessing *preProcessing) - PreProcessing Types Do Not Match!" << std::endl;
84 errorLog <<
"process(const VectorFloat &inputVector) - Not initialized!" << std::endl;
88 if( inputVector.size() != numInputDimensions ){
89 errorLog <<
"process(const VectorFloat &inputVector) - The size of the inputVector (" << inputVector.size() <<
") does not match that of the filter (" << numInputDimensions <<
")!" << std::endl;
95 if( processedData.size() == numOutputDimensions )
return true;
106 errorLog <<
"saveModelToFile(std::string filename) - The DeadZone has not been initialized" << std::endl;
111 file.open(filename.c_str(), std::ios::out);
125 if( !file.is_open() ){
126 errorLog <<
"saveModelToFile(fstream &file) - The file is not open!" << std::endl;
130 file <<
"GRT_DEAD_ZONE_FILE_V1.0" << std::endl;
132 file <<
"NumInputDimensions: " << numInputDimensions << std::endl;
133 file <<
"NumOutputDimensions: " << numOutputDimensions << std::endl;
134 file <<
"LowerLimit: " <<
lowerLimit << std::endl;
135 file <<
"UpperLimit: " <<
upperLimit << std::endl;
143 file.open(filename.c_str(), std::ios::in);
158 if( !file.is_open() ){
159 errorLog <<
"loadModelFromFile(fstream &file) - The file is not open!" << std::endl;
168 if( word !=
"GRT_DEAD_ZONE_FILE_V1.0" ){
169 errorLog <<
"loadModelFromFile(fstream &file) - Invalid file format!" << std::endl;
175 if( word !=
"NumInputDimensions:" ){
176 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read NumInputDimensions header!" << std::endl;
179 file >> numInputDimensions;
183 if( word !=
"NumOutputDimensions:" ){
184 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read NumOutputDimensions header!" << std::endl;
187 file >> numOutputDimensions;
191 if( word !=
"LowerLimit:" ){
192 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read LowerLimit header!" << std::endl;
198 if( word !=
"UpperLimit:" ){
199 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read UpperLimit header!" << std::endl;
205 return init(lowerLimit,upperLimit,numInputDimensions);
212 if( numDimensions == 0 ){
213 errorLog <<
"init(Float lowerLimit,Float upperLimit,UINT numDimensions) - NumDimensions must be greater than 0!" << std::endl;
217 if( lowerLimit >= upperLimit ){
218 errorLog <<
"init(Float lowerLimit,Float upperLimit,UINT numDimensions) - The lower limit must be less than the upperlimit!" << std::endl;
224 this->numInputDimensions = numDimensions;
225 this->numOutputDimensions = numDimensions;
226 processedData.clear();
227 processedData.
resize(numOutputDimensions,0);
235 if( y.
getSize() == 0 )
return 0;
242 errorLog <<
"filter(const VectorFloat &x) - Not Initialized!" << std::endl;
246 if( x.
getSize() != numInputDimensions ){
247 errorLog <<
"filter(const VectorFloat &x) - The Number Of Input Dimensions (" << numInputDimensions <<
") does not match the size of the input vector (" << x.size() <<
")!" << std::endl;
251 for(UINT n=0; n<numInputDimensions; n++){
253 processedData[n] = 0;
259 return processedData;
virtual bool saveModelToFile(std::string filename) const
Float upperLimit
The upper limit of the dead-zone region.
DeadZone & operator=(const DeadZone &rhs)
virtual bool process(const VectorFloat &inputVector)
virtual bool resize(const unsigned int size)
Float filter(const Float x)
bool setUpperLimit(Float upperLimit)
unsigned int getSize() const
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
std::string getPreProcessingType() const
Float lowerLimit
The lower limit of the dead-zone region.
bool setLowerLimit(Float lowerLimit)
DeadZone(Float lowerLimit=-0.1, Float upperLimit=0.1, UINT numDimensions=1)
The DeadZone class sets any values in the input signal that fall within the dead-zone region to zero...
bool copyBaseVariables(const PreProcessing *preProcessingModule)
virtual bool loadModelFromFile(std::string filename)