#include <simgear/sg_inlines.h>
#include <simgear/props/props_io.hxx>
+#include <simgear/structure/SGExpression.hxx>
+
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Main/util.hxx>
using simgear::PropertyList;
+
+
+
FGPeriodicalValue::FGPeriodicalValue( SGPropertyNode_ptr root )
{
SGPropertyNode_ptr minNode = root->getChild( "min" );
FGXMLAutoInput::FGXMLAutoInput( SGPropertyNode_ptr node, double value, double offset, double scale) :
value(0.0),
- abs(false),
- _condition(NULL)
+ abs(false)
{
parse( node, value, offset, scale );
}
value = valueNode->getDoubleValue();
}
+ if ((n = node->getChild("expression")) != NULL) {
+ _expression = SGReadDoubleExpression(fgGetNode("/"), n->getChild(0));
+ return;
+ }
+
n = node->getChild( "property" );
// if no <property> element, check for <prop> element for backwards
// compatibility
else
property->setDoubleValue( 0 ); // if scale is zero, value*scale is zero
}
- }
+
+ return;
+ } // of have a <property> or <prop>
- if ( n == NULL && valueNode == NULL ) {
- // no <value> element and no <prop> element, use text node
+
+ if (valueNode == NULL) {
+ // no <value>, <prop> or <expression> element, use text node
const char * textnode = node->getStringValue();
char * endp = NULL;
// try to convert to a double value. If the textnode does not start with a number
void FGXMLAutoInput::set_value( double aValue )
{
+ if (!property)
+ return;
+
double s = get_scale();
if( s != 0 )
property->setDoubleValue( (aValue - get_offset())/s );
double FGXMLAutoInput::get_value()
{
- if( property != NULL )
+ if (_expression) {
+ // compute the expression value
+ value = _expression->getValue(NULL);
+ } else if( property != NULL ) {
value = property->getDoubleValue();
-
+ }
+
if( scale )
value *= scale->get_value();
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
-#include <simgear/props/condition.hxx>
+
+template<typename T>
+class SGExpression;
+
+typedef SGExpression<double> SGExpressiond;
+class SGCondition;
typedef SGSharedPtr<class FGXMLAutoInput> FGXMLAutoInput_ptr;
typedef SGSharedPtr<class FGPeriodicalValue> FGPeriodicalValue_ptr;
FGXMLAutoInput_ptr max; // A maximum clip defaults to no clipping
FGPeriodicalValue_ptr periodical; //
SGSharedPtr<const SGCondition> _condition;
-
+ SGSharedPtr<SGExpressiond> _expression; ///< expression to generate the value
+
public:
FGXMLAutoInput( SGPropertyNode_ptr node = NULL, double value = 0.0, double offset = 0.0, double scale = 1.0 );