%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGDeadBand.h"
+#include "input_output/FGXMLElement.h"
+#include "input_output/FGPropertyManager.h"
+#include <iostream>
+
+using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGDeadBand.cpp,v 1.9 2009/10/24 22:59:30 jberndt Exp $";
static const char *IdHdr = ID_DEADBAND;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl;
+ if (IsOutput) {
+ for (unsigned int i=0; i<OutputNodes.size(); i++)
+ cout << " OUTPUT: " << OutputNodes[i]->getName() << endl;
+ }
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification