#include "FGFCSComponent.h"
#include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLElement.h"
+#include "math/FGPropertyValue.h"
#include <iostream>
#include <cstdlib>
namespace JSBSim {
-static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.29 2010/09/07 00:40:03 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.32 2011/06/16 03:39:38 jberndt Exp $";
static const char *IdHdr = ID_FCSCOMPONENT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
{
Element *input_element, *clip_el;
- Input = Output = clipmin = clipmax = 0.0;
+ Input = Output = clipmin = clipmax = delay_time = 0.0;
treenode = 0;
delay = index = 0;
ClipMinPropertyNode = ClipMaxPropertyNode = 0;
Name = element->GetAttributeValue("name");
- FGPropertyManager *tmp=0;
-
input_element = element->FindElement("input");
while (input_element) {
input = input_element->GetDataLine();
} else {
InputSigns.push_back( 1.0);
}
+ FGPropertyManager* node = 0L;
if (PropertyManager->HasNode(input)) {
- tmp = PropertyManager->GetNode(input);
+ node = PropertyManager->GetNode(input);
+ InputNodes.push_back(new FGPropertyValue( node ));
} else {
- tmp = 0L;
- // cerr << fgcyan << "In component: " + Name + " property "
- // + input + " is initially undefined." << reset << endl;
+ InputNodes.push_back(new FGPropertyValue( input,
+ PropertyManager ));
}
- InputNodes.push_back( tmp );
InputNames.push_back( input );
input_element = element->FindNextElement("input");
Element* delay_elem = element->FindElement("delay");
if ( delay_elem ) {
- delay = (unsigned int)delay_elem->GetDataAsNumber();
+ delay_time = delay_elem->GetDataAsNumber();
string delayType = delay_elem->GetAttributeValue("type");
if (delayType.length() > 0) {
if (delayType == "time") {
- delay = (int)(delay / dt);
+ delay = (unsigned int)(delay_time / dt);
} else if (delayType == "frames") {
- // no op. the delay type of "frames" is assumed and is the default.
+ delay = (unsigned int)delay_time;
} else {
cerr << "Unallowed delay type" << endl;
}
} else {
- delay = (int)(delay / dt);
+ delay = (unsigned int)(delay_time / dt);
}
output_array.resize(delay);
for (int i=0; i<delay; i++) output_array[i] = 0.0;
FGFCSComponent::~FGFCSComponent()
{
Debug(1);
+ for (unsigned int i=0; i<InputNodes.size(); i++) {
+ delete InputNodes[i];
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
}
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGFCSComponent::LateBind(void)
-{
- FGPropertyManager* node = 0L;
-
- for (unsigned int i=0; i<InputNodes.size(); i++) {
- if (!InputNodes[i]) {
- if (PropertyManager->HasNode(InputNames[i])) {
- node = PropertyManager->GetNode(InputNames[i]);
- InputNodes[i] = node;
- } else {
- throw(InputNames[i]);
- }
- }
- }
-}
-
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
// The old way of naming FCS components allowed upper or lower case, spaces, etc.