FGDeadBand::FGDeadBand(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
{
+ string width_string;
+
+ WidthPropertyNode = 0;
+ WidthPropertySign = 1.0;
gain = 1.0;
width = 0.0;
- if (element->FindElement("width")) {
- width = element->FindElementValueAsNumber("width");
+ if ( element->FindElement("width") ) {
+ width_string = element->FindElementValue("width");
+ if (!is_number(width_string)) { // property
+ if (width_string[0] == '-') {
+ WidthPropertySign = -1.0;
+ width_string.erase(0,1);
+ }
+ WidthPropertyNode = PropertyManager->GetNode(width_string);
+ } else {
+ width = element->FindElementValueAsNumber("width");
+ }
}
if (element->FindElement("gain")) {
{
Input = InputNodes[0]->getDoubleValue() * InputSigns[0];
+ if (WidthPropertyNode != 0) {
+ width = WidthPropertyNode->getDoubleValue() * WidthPropertySign;
+ }
+
if (Input < -width/2.0) {
Output = (Input + width/2.0)*gain;
} else if (Input > width/2.0) {
if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
cout << " INPUT: " << InputNodes[0]->getName() << endl;
- cout << " DEADBAND WIDTH: " << width << endl;
+ if (WidthPropertyNode != 0) {
+ cout << " DEADBAND WIDTH: " << WidthPropertyNode->GetName() << endl;
+ } else {
+ cout << " DEADBAND WIDTH: " << width << endl;
+ }
cout << " GAIN: " << gain << endl;
- if (clip) cout << " CLIPTO: " << clipmin
- << ", " << clipmax << endl;
if (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl;
}
}