Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

rdControlLinear Class Reference

A class that represents a piece-wise linear control curve. More...

#include <rdControlLinear.h>

Inheritance diagram for rdControlLinear:

rdControl rdObject List of all members.

Public Member Functions

 rdControlLinear (rdArray< rdControlLinearNode > *aX=NULL, const char *aName="UNKOWN")
 Default constructor.

 rdControlLinear (IDOM_Element *aElement)
 Construct a control from an XML Element.

 rdControlLinear (const rdControlLinear &aControl)
 Copy constructor.

virtual ~rdControlLinear ()
 Destructor.

virtual rdControlcopy () const
 Construct a copy of this control.

virtual rdControlcopy (IDOM_Element *aElement) const
 Copy this control and modify the copy so that it is consistent with a specified XML element node.

rdControlLinear & operator= (const rdControlLinear &aControl)
 Assignment operator.

void setUseSteps (bool aTrueFalse)
 Set whether or not step functions are used between control nodes or linear interpolation.

bool getUseSteps () const
 Get whether or not step functions are used between control nodes or linear interpolation.

virtual int getNumParameters () const
 Get the number of parameters that are used to specify the control curve.

virtual void setParameterMin (int aI, double aMin)
 Set the minimum value of a control parameter.

virtual double getParameterMin (int aI) const
 Get the minimum value of a control parameter.

virtual void setParameterMax (int aI, double aMax)
 Set the maximum value of a control parameter.

virtual double getParameterMax (int aI) const
 Get the maximum value of a control parameter.

virtual double getParameterTime (int aI) const
 Get the time at which a parameter is specified.

virtual void getParameterNeighborhood (int aI, double &rTLower, double &rTUpper) const
 Get the time neighborhood (i.e., the lower and upper bounds of time) in which a control parameter affects the value of the control curve.

virtual int getParameterList (double aT, rdArray< int > &rList) const
 Get the list of parameters that affect the control curve at a specified time.

virtual int getParameterList (double aT1, double aT2, rdArray< int > &rList) const
 Get the list of parameters that affect the control curve between two specified times and that do NOT affect the control curve below the lower of these two times.

virtual void setParameterValue (int aI, double aP)
 Set the value of a control parameter.

virtual double getParameterValue (int aI) const
 Get the value of a control parameter.

virtual void setControlValue (double aT, double aX)
 Set the value of this control curve at time aT.

virtual double getControlValue (double aT) const
 Get the value of this control at time aT.

const rdArray< rdControlLinearNode > & getNodeArray () const
 Get the array of control nodes.

virtual void updateObject (bool aDeep=true)
 Update this object based on its XML node.

void updateData ()
 Update the member data of this object based on its XML node.

virtual void updateNode (bool aDeep=true)
 Update the XML node representing this object.

virtual void generateNode (IDOM_Element *aParent)
 Generate an XML node representing this object.


Static Public Attributes

const char PROP_USE_STEPS [] = "use_steps"
 Property for whether or not to use steps rather than interpolate.

const char PROP_T [] = "time"
 Property for time.

const char PROP_X [] = "value"
 Property for value.

const char PROP_MIN [] = "min"
 Property for minimum.

const char PROP_MAX [] = "max"
 Property for maximum.

const rdControlLinearNode DEFAULT_NODE
 Default control node.


Protected Attributes

bool _useSteps
 Flag that indicates whether or not to linearly interpolate between nodes or use step functions.

rdArray< rdControlLinearNode_nodes
 Array of control nodes.


Private Member Functions

void setNull ()
 Set the member data to their NULL values.

void copyData (const rdControlLinear &aControl)
 Copy the member variables of the specified control.


Detailed Description

A class that represents a piece-wise linear control curve.

The curve is specified by an array of control nodes (see class rdControlLinearNode) that occur at monotonically increasing times. The value of the control curve is computed by linearly interpolating the values of the appropriate control nodes.

Author:
Frank C. Anderson
Version:
1.0


Constructor & Destructor Documentation

rdControlLinear::rdControlLinear rdArray< rdControlLinearNode > *  aX = NULL,
const char *  aName = "UNKOWN"
 

Default constructor.

Parameters:
aX Pointer to an array of control nodes. By default, the value of the value of aX is NULL. If it is not NULL, the control nodes pointed to by aX are copied. This class keeps its own internal array of control nodes. The caller owns the array pointed to by aX, is free to use this array in any way, and, if necessary, is responsible for deleting the memory associated with aX.
aName Name of the control.

rdControlLinear::rdControlLinear IDOM_Element *  aElement  ) 
 

Construct a control from an XML Element.

Parameters:
aElement XML element.

rdControlLinear::rdControlLinear const rdControlLinear &  aControl  ) 
 

Copy constructor.

Parameters:
aControl Control to copy.


Member Function Documentation

rdControl * rdControlLinear::copy IDOM_Element *  aElement  )  const [virtual]
 

Copy this control and modify the copy so that it is consistent with a specified XML element node.

The copy is constructed by first using the contructor for the IDOM_Element in order to establish the relationship of the control with the XML node. Then, the assignment operator is used to set all member variables of the copy to the values of this object. Finally, the data members of the copy are updated from the IDOM_Elment using updateObject().

Parameters:
aElement XML element.
Returns:
Pointer to a copy of this actuator.

Implements rdControl.

void rdControlLinear::generateNode IDOM_Element *  aParent  )  [virtual]
 

Generate an XML node representing this object.

Parameters:
aParent Intended parent of the node to be generated. If aParent is NULL, the intent is for this object to serve as the root element of a new document.
See also:
rdObject::generateNode()

Reimplemented from rdControl.

double rdControlLinear::getControlValue double  aT  )  const [virtual]
 

Get the value of this control at time aT.

Parameters:
aT Time at which to get the control.
Returns:
Control value. If the value of the curve is not defined, rdMath::NAN is returned. If aT is before the first control node, the value of the first control node is returned. If aT is after the last control node, the value of the last control node is returned.

Implements rdControl.

const rdArray< rdControlLinearNode > & rdControlLinear::getNodeArray  )  const
 

Get the array of control nodes.

Returns:
Array of nodes.

int rdControlLinear::getNumParameters  )  const [virtual]
 

Get the number of parameters that are used to specify the control curve.

Returns:
Number of parameters.

Implements rdControl.

int rdControlLinear::getParameterList double  aT1,
double  aT2,
rdArray< int > &  rList
const [virtual]
 

Get the list of parameters that affect the control curve between two specified times and that do NOT affect the control curve below the lower of these two times.

This method is useful when solving for a set of controls for a dynamic simulation. When solving for a set of controls, one always wants to go forward in time. Therefore, one does not want to change control parameters that affect the control curve at past times.

A control parameter is included in the list only if it affects the control curve in the specified time interval AND does NOT affect the control curve below the lower bound of the specified time interval. So, it is possible that some of the parameters on the returned list could affect the control curve at times greater than the upper bound of the specified time interval.

Parameters:
aTLower Lower time bound. The control curves are not affected below this time by any of the returned parameters.
aTUpper Upper time bound. The control curves may be affected for times greater than this time.
rList List of control parameters (their indices to be exact) that affect the curve between aTLower and aTUpper but not before aTLower.
Returns:
Number of parameters indices in the list.

Implements rdControl.

int rdControlLinear::getParameterList double  aT,
rdArray< int > &  rList
const [virtual]
 

Get the list of parameters that affect the control curve at a specified time.

Parameters:
aT Time in question.
rList Array of control parameters that affect the curve at time aT. For rdControlLinear, if aT lies between two nodes, the indices of these two nodes is returned; if aT equals the time at which a node occurs, the index of that node is returned; if aT is less than the time of the first node in the array, the index of the first node (i.e., 0) is returned; if aT is greater than the time of the last node, the index of the last node (i.e., size-1) is returned.
Returns:
Number of parameters in the list.

Implements rdControl.

double rdControlLinear::getParameterMax int  aI  )  const [virtual]
 

Get the maximum value of a control parameter.

Parameters:
aI Index of the parameter.
Returns:
Maximum value of the parameter.
Exceptions:
rdException if aI is invalid.

Implements rdControl.

double rdControlLinear::getParameterMin int  aI  )  const [virtual]
 

Get the minimum value of a control parameter.

Parameters:
aI Index of the parameter.
Returns:
Minimum value of the parameter.
Exceptions:
rdException if aI is invalid.

Implements rdControl.

void rdControlLinear::getParameterNeighborhood int  aI,
double &  rTLower,
double &  rTUpper
const [virtual]
 

Get the time neighborhood (i.e., the lower and upper bounds of time) in which a control parameter affects the value of the control curve.

Changes in the specified parameter are guarranteed not to change the value of the control curve below the lower bound time or above the upper bound time. If a parameter influences the value of the control curve for all times, rdMath::MINUS_INFINITY and rdMath::PLUS_INFINITY are returned for the upper and lower bound times, respectively.

Parameters:
aI Index of the parameter.
rTLower Time below which the curve is not affected by the specified parameter. For rdControlLinear, aTLower is the time of parameter aI-1 or of aI if there is no parameter aI-1. If there are no nodes at all or if aI is invalid, aTLower is given the value rdMath::NAN.
rTUpper Time above which the curve is not affected by the specified parameter. For rdControlLinear, aTUpper is the time of parameter aI+1 or of aI if there is no parameter aI+1. If there are no nodes at all or if aI is invalid, aTUpper is given the value rdMath::NAN.
Exceptions:
rdException if aI is invalid.

Implements rdControl.

double rdControlLinear::getParameterTime int  aI  )  const [virtual]
 

Get the time at which a parameter is specified.

Parameters for some types of control curves do not have a time at which they are specified. For example, in a Fourier series the control parameters are the cooefficients in the expansion, and each term in the expansion corresponds not to a specific time but to a frequency. Another example is a constant that has the same value for all times. In these cases, this method returns rdMath::NAN.

Parameters:
aI Index of the parameter.
Returns:
Time at which the control parameter occurs. For rdControlLinear this value is not defined, and so rdMath::NAN is always returned.
Exceptions:
rdException if aI is invalid.

Implements rdControl.

double rdControlLinear::getParameterValue int  aI  )  const [virtual]
 

Get the value of a control parameter.

Parameters:
aI Index of the parameter.
Returns:
Value of the parameter. For rdControlLinear, the parameter value is simply the value of the control node.

Implements rdControl.

bool rdControlLinear::getUseSteps  )  const
 

Get whether or not step functions are used between control nodes or linear interpolation.

When step functions are used, the value of the control curve between two nodes is the value of the node that occurs later in time.

Returns:
True if steps functions are used. False if linear interpolation is used.

rdControlLinear & rdControlLinear::operator= const rdControlLinear &  aControl  ) 
 

Assignment operator.

Returns:
Reference to the altered object.

void rdControlLinear::setControlValue double  aT,
double  aX
[virtual]
 

Set the value of this control curve at time aT.

This method adds a set of control parameters at the specified time unless the specified time equals the time of an existing control node, in which case the parameters of that control node are changed.

Parameters:
aT Time at which to set the control.
Returns:
Control value.

Implements rdControl.

void rdControlLinear::setParameterMax int  aI,
double  aMax
[virtual]
 

Set the maximum value of a control parameter.

Parameters:
aI Index of the parameter.
aMax Maximum value of the parameter.
Exceptions:
rdException if aI is invalid.

Implements rdControl.

void rdControlLinear::setParameterMin int  aI,
double  aMin
[virtual]
 

Set the minimum value of a control parameter.

Parameters:
aI Index of the parameter.
aMin Minimum value of the parameter.
Exceptions:
rdException if aI is invalid.

Implements rdControl.

void rdControlLinear::setParameterValue int  aI,
double  aP
[virtual]
 

Set the value of a control parameter.

Parameters:
aI Index of the parameter.
aX Value of the parameter. For rdControlLinear, the parameter value is simply the value of the control node.
See also:
getNumParameters()
Exceptions:
rdException if aI is invalid.

Implements rdControl.

void rdControlLinear::setUseSteps bool  aTrueFalse  ) 
 

Set whether or not step functions are used between control nodes or linear interpolation.

When step functions are used, the value of the control curve between two nodes is the value of the node that occurs later in time.

Parameters:
aTrueFalse If true, step functions will be used to determine the value between adjacent nodes. If false, linear interpolation will be used.

void rdControlLinear::updateData  ) 
 

Update the member data of this object based on its XML node.

Member objects (children) are not updated.

Reimplemented from rdControl.

void rdControlLinear::updateNode bool  aDeep = true  )  [virtual]
 

Update the XML node representing this object.

Parameters:
aDeep If true, update the XML node of this object AND the XML nodes of all class members that are rdObjects (child nodes); if false, update only the XML node of this object without updating the XML nodes of its children.

Reimplemented from rdControl.

void rdControlLinear::updateObject bool  aDeep = true  )  [virtual]
 

Update this object based on its XML node.

Parameters:
aDeep If true, update this object and all its child objects (that is, member variables that are rdObject's); if false, update only the member variables that are not rdObject's.

Reimplemented from rdControl.


The documentation for this class was generated from the following files:
Generated on Wed Aug 20 02:17:10 2003 for Simulation Software by doxygen1.3