26 RegisterPreProcessingModule< DeadZone > DeadZone::registerModule(
"DeadZone");
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!" << endl;
84 errorLog <<
"process(const VectorDouble &inputVector) - Not initialized!" << endl;
88 if( inputVector.size() != numInputDimensions ){
89 errorLog <<
"process(const VectorDouble &inputVector) - The size of the inputVector (" << inputVector.size() <<
") does not match that of the filter (" << numInputDimensions <<
")!" << endl;
95 if( processedData.size() == numOutputDimensions )
return true;
106 errorLog <<
"saveModelToFile(string filename) - The DeadZone has not been initialized" << 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!" << endl;
130 file <<
"GRT_DEAD_ZONE_FILE_V1.0" << endl;
132 file <<
"NumInputDimensions: " << numInputDimensions << endl;
133 file <<
"NumOutputDimensions: " << numOutputDimensions << 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!" << endl;
168 if( word !=
"GRT_DEAD_ZONE_FILE_V1.0" ){
169 errorLog <<
"loadModelFromFile(fstream &file) - Invalid file format!" << endl;
175 if( word !=
"NumInputDimensions:" ){
176 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read NumInputDimensions header!" << endl;
179 file >> numInputDimensions;
183 if( word !=
"NumOutputDimensions:" ){
184 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read NumOutputDimensions header!" << endl;
187 file >> numOutputDimensions;
191 if( word !=
"LowerLimit:" ){
192 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read LowerLimit header!" << endl;
198 if( word !=
"UpperLimit:" ){
199 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read UpperLimit header!" << endl;
205 return init(lowerLimit,upperLimit,numInputDimensions);
212 if( numDimensions == 0 ){
213 errorLog <<
"init(double lowerLimit,double upperLimit,UINT numDimensions) - NumDimensions must be greater than 0!" << endl;
217 if( lowerLimit >= upperLimit ){
218 errorLog <<
"init(double lowerLimit,double upperLimit,UINT numDimensions) - The lower limit must be less than the upperlimit!" << endl;
224 this->numInputDimensions = numDimensions;
225 this->numOutputDimensions = numDimensions;
226 processedData.clear();
227 processedData.resize(numOutputDimensions,0);
234 VectorDouble y =
filter(VectorDouble(1,x));
235 if( y.size() == 0 )
return 0;
242 errorLog <<
"filter(const VectorDouble &x) - Not Initialized!" << endl;
243 return VectorDouble();
246 if( x.size() != numInputDimensions ){
247 errorLog <<
"filter(const VectorDouble &x) - The Number Of Input Dimensions (" << numInputDimensions <<
") does not match the size of the input vector (" << x.size() <<
")!" << endl;
248 return VectorDouble();
251 for(UINT n=0; n<numInputDimensions; n++){
253 processedData[n] = 0;
259 return processedData;
virtual bool loadModelFromFile(string filename)
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
virtual bool process(const VectorDouble &inputVector)
double filter(const double x)
double upperLimit
The upper limit of the dead-zone region.
DeadZone(double lowerLimit=-0.1, double upperLimit=0.1, UINT numDimensions=1)
string getPreProcessingType() const
DeadZone & operator=(const DeadZone &rhs)
bool setLowerLimit(double lowerLimit)
bool copyBaseVariables(const PreProcessing *preProcessingModule)
virtual bool saveModelToFile(string filename) const
double lowerLimit
The lower limit of the dead-zone region.
The DeadZone class sets any values in the input signal that fall within the dead-zone region to zero...
bool setUpperLimit(double upperLimit)