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

rdControlSet Class Reference

An class for holding and managing a set of controls for a dynamic simulation. More...

#include <rdControlSet.h>

Inheritance diagram for rdControlSet:

rdPtrArray rdObject List of all members.

Public Member Functions

 rdControlSet ()
 Default constructor.

 rdControlSet (const char *aFileName)
 Construct an control set from file.

virtual ~rdControlSet ()
 Destructor.

int getControlIndex (const char *aName) const
 Get the index of a control.

void getControlList (const char *aType, rdArray< int > &rList, bool aForModelControls=true) const
 Get the list of controls of a specified type.

rdControlappendControl (rdControl *aControl)
 Append a control on to the control set.

rdControlsetControl (int aIndex, rdControl *aControl)
 Set the control at an index.

rdControlgetControl (int aIndex) const
 Get the control at an index.

rdControlgetControl (const char *aName) const
 Get the first control that has a specified name.

int getNumControls (bool aForActuatorControls=true) const
 Get the number of controls.

void getControlValues (double aT, double rX[], bool aForModelControls=true) const
 Get the values of the control curves held in this set at a specified time.

void getControlValues (double aT, rdArray< double > &rX, bool aForModelControls=true) const
 Get the values of the control curves held in this set at a specified time.

void setControlValues (double aT, const double aX[], bool aForModelControls=true)
 Set the values of the control curves held in this set at a specified time.

void setControlValues (double aT, const rdArray< double > &aX, bool aForModelControls=true)
 Set the values of the control curves held in this set at a specified time.

int getNumParameters (bool aForModelControls=true) const
 Get the number of control parameters.

void getParameterList (rdArray< int > &rList, bool aForModelControls=true) const
 Get a list of parameters for all controls or just the controls that are model controls.

void getParameterList (double aT, rdArray< int > &rList, bool aForModelControls=true) const
 Get the list of parameters that affect the control curves at a specified time.

void getParameterList (double aTLower, double aTUpper, rdArray< int > &rList, bool aForModelControls=true) const
 Get the list of parameters that affect the control curves between two specified times and that do NOT affect the control curve below the lower of these two times.

void getParameterMins (rdArray< double > &rMins, const rdArray< int > *aList=NULL) const
 Get the minimum values allowed for the control parameters.

void getParameterMaxs (rdArray< double > &rMaxs, const rdArray< int > *aList=NULL) const
 Get the maximum values allowed for the control parameters.

void getParameterValues (double rP[], const rdArray< int > *aList=NULL) const
 Get the values of the control parameters.

void getParameterValues (rdArray< double > &rP, const rdArray< int > *aList=NULL) const
 Get the values of the control parameters.

void setParameterValues (const double aP[], const rdArray< int > *aList=NULL)
void setParameterValues (const rdArray< double > &aP, const rdArray< int > *aList=NULL)
 Set the values of the control parameters.

int mapParameterToControl (int aIndex) const
 Map a control-set parameter to a control.

int mapParameterToParameter (int aIndex) const
 Map a control-set parameter to a parameter of a particular control.

void generateParameterMaps ()
 Generate the maps relating a parmeter in the control set to a control and a parameter of a control.

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

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

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


Static Public Member Functions

void RegisterType (const rdControl &aControl)
 Register a supported control type.


Protected Attributes

rdPtrArray _defaultControls
 Pointer array of default controls.

rdArray< int > _ptcMap
 Map from parameters to controls.

rdArray< int > _ptpMap
 Map from set parameters to control parameters.


Private Member Functions

void setNull ()
 Set the member variables to their null values.

void constructDefaultControls ()
 Construct the default controls.


Static Private Attributes

rdPtrArray _ControlTypes
 Pointer array of supported control types.


Detailed Description

An class for holding and managing a set of controls for a dynamic simulation.

Author:
Frank C. Anderson
Version:
1.0


Constructor & Destructor Documentation

rdControlSet::rdControlSet const char *  aFileName  ) 
 

Construct an control set from file.

Parameters:
aFileName Name of the file.

rdControlSet::~rdControlSet  )  [virtual]
 

Destructor.

Todo:
Figure out why the default controls can't be deleted.


Member Function Documentation

rdControl * rdControlSet::appendControl rdControl aControl  ) 
 

Append a control on to the control set.

This method should always return NULL. If it does not return NULL, it means that an model was already stored at what was thought to be the first empty location.

Parameters:
aControl Control to be appended.
Returns:
Pointer to the control previously held.

void rdControlSet::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.

Reimplemented from rdObject.

void rdControlSet::generateParameterMaps  ) 
 

Generate the maps relating a parmeter in the control set to a control and a parameter of a control.

This method should be called any time there is a change in the number or types of controls held in the control set.

rdControl * rdControlSet::getControl const char *  aName  )  const
 

Get the first control that has a specified name.

This method can be slow.

Parameters:
aName Name of the desired control.
Returns:
Control with the specified name. If there is no such control, NULL is returned.

rdControl * rdControlSet::getControl int  aIndex  )  const
 

Get the control at an index.

Parameters:
aIndex Array index of the control to be returned.
Returns:
Control at aIndex.

int rdControlSet::getControlIndex const char *  aName  )  const
 

Get the index of a control.

This method can be slow, so minimize its use if possible.

Parameters:
aName Name of the control.
Returns:
Index of the first control with the name aName. If no control is found with the specified name, -1 is returned.
See also:
getControl()

void rdControlSet::getControlList const char *  aType,
rdArray< int > &  rList,
bool  aForModelControls = true
const
 

Get the list of controls of a specified type.

This method can be slow, so minimize its use if possible.

Parameters:
aType Type of the control (e.g., rdControlLinear).
aList Array of indices of the controls of type aType.
aForModelControls If true, only model controls are considered. If false, all controls are considered.
See also:
getControl()

void rdControlSet::getControlValues double  aT,
rdArray< double > &  rX,
bool  aForModelControls = true
const
 

Get the values of the control curves held in this set at a specified time.

This is the bread-and-butter method of the controls class; it is called repeatedly throughout an integration.

Parameters:
aT Time at which to get the values of the control curves.
rX Array of control curve values.
aForModelControls If true, only model controls are considered. If false, all controls are considered.

void rdControlSet::getControlValues double  aT,
double  rX[],
bool  aForModelControls = true
const
 

Get the values of the control curves held in this set at a specified time.

This is the bread-and-butter method of the controls class; it is called repeatedly throughout an integration.

Parameters:
aT Time at which to get the values of the control curves.
rX Array of control curve values.
aForModelControls If true, only model controls are considered. If false, all controls are considered.

int rdControlSet::getNumControls bool  aForActuatorControls = true  )  const
 

Get the number of controls.

Parameters:
aForModelControls If true, only model controls are considered. If false, all controls are considered.
Returns:
Number of controls.

int rdControlSet::getNumParameters bool  aForModelControls = true  )  const
 

Get the number of control parameters.

Parameters:
aForModelControls If true, only model controls are considered. If false, all controls are considered.
Returns:
Number of control parameters.

void rdControlSet::getParameterList double  aTLower,
double  aTUpper,
rdArray< int > &  rList,
bool  aForModelControls = true
const
 

Get the list of parameters that affect the control curves 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.
aForModelControls If true, only model controls are considered. If false, all controls are considered.
See also:
getParameterMins()

getParameterMaxs()

getParameterValues()

void rdControlSet::getParameterList double  aT,
rdArray< int > &  rList,
bool  aForModelControls = true
const
 

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

This list can be used to get parameter mins, maxs, and values.

Parameters:
aT Time in question.
rList List of parameters.
aForModelControls If true, only model controls are considered. If false, all controls are considered.
See also:
getParameterMins()

getParameterMaxs()

getParameterValues()

void rdControlSet::getParameterList rdArray< int > &  rList,
bool  aForModelControls = true
const
 

Get a list of parameters for all controls or just the controls that are model controls.

This list can be used to get parameter mins, maxs, and values.

Parameters:
rList List of parameters.
aForModelControls If true, only model controls are considered. If false, all controls are considered.
See also:
getParameterMins()

getParameterMaxs()

getParameterValues()

void rdControlSet::getParameterMaxs rdArray< double > &  rMaxs,
const rdArray< int > *  aList = NULL
const
 

Get the maximum values allowed for the control parameters.

Parameters:
rP Array of maximum allowed values.
aForModelControls If true, only model controls are considered. If false, all controls are considered.

void rdControlSet::getParameterMins rdArray< double > &  rMins,
const rdArray< int > *  aList = NULL
const
 

Get the minimum values allowed for the control parameters.

Parameters:
rP Array of minimum allowed values.
aForModelControls If true, only model controls are considered. If false, all controls are considered.

void rdControlSet::getParameterValues rdArray< double > &  rP,
const rdArray< int > *  aList = NULL
const
 

Get the values of the control parameters.

Parameters:
rP Array of parameters values, the length of which should equal the total number of parameters or the size of aList.
aList If NULL, the values for all parameters for all controls in the control set are gotten.

void rdControlSet::getParameterValues double  rP[],
const rdArray< int > *  aList = NULL
const
 

Get the values of the control parameters.

Parameters:
rP Array of parameters values, the length of which should equal the total number of parameters or the size of aList.
aList If NULL, the values for all parameters for all controls in the control set are gotten. Otherwise, the parameters in the list are gotten.

int rdControlSet::mapParameterToControl int  aIndex  )  const
 

Map a control-set parameter to a control.

In the control set, the paramters for each of the controls are concatenated into an array. Since there is not a one-to-one correspondence between control-set parameters and controls (i.e., a particular control may have many parameters), it is necessary both to map to which control each control-set parameter belongs and to map to which parameter within a particular control a control-set parameter corresponds.

Parameters:
aIndex Index of the parameter in this control set.
Returns:
Index of the control to which the specified parameter belongs. If no such parameter exists, -1 is returned.
See also:
mapParameterToParameter()

int rdControlSet::mapParameterToParameter int  aIndex  )  const
 

Map a control-set parameter to a parameter of a particular control.

In the control set, the paramters for each of the controls are concatenated into an array. Since there is not a one-to-one correspondence between control-set parameters and controls (i.e., a particular control may have many parameters), it is necessary both to map to which control each control-set parameter belongs and to map to which parameter within a particular control a control-set parameter corresponds.

Parameters:
aIndex Index of the parameter in the control set.
Returns:
Index of the parameter with in a particular to which the specified parameter corresponds. If no such parameter exists, -1 is returned.
See also:
mapParameterToControl()

void rdControlSet::RegisterType const rdControl aControl  )  [static]
 

Register a supported control type.

Any control type that is supported can be written to and read from an XML file. The control must have implemented the following methods to be supported: 1) copy constructor 2) virtual rdControl* copy() const, 3) virtual rdControl* copy(IDOM_Element*) const, 4) rdControl& operator=() (!! with the appropriate return type), 5) virtual void updateObject(bool aDeep=true), 6) virtual void updateNode(bool aDeep=true), and 7) virtual void generateNode(IDOM_Element *aParent).

Because this method is static, registration of control types needs to be done only once per process and an rdControlSet does not need to be instantiated to do so.

This method makes a copy of the specified control, so the caller may continue to use the spacified control (aControl) for whatever purpose.

Parameters:
aControl Control of the type to be registered.

rdControl * rdControlSet::setControl int  aIndex,
rdControl aControl
 

Set the control at an index.

Sending in NULL for the rdControl pointer essentially removes the control at aIndex from the set. The caller is responsible for deleting any controls that are removed from this list in this way. For this reason, the control pointer previously held at aIndex is returned by this method.

It is permissible to send in any positive value for aIndex, and there can be gaps in the array of controls. However, it is advisible to use appendControl(rdControl*) when adding a control so the array of controls remains contiguous.

Parameters:
aIndex Array index where the control is to be stored.
aControl control to be stored.
Returns:
Pointer to the control previously held at aIndex.

void rdControlSet::setControlValues double  aT,
const rdArray< double > &  aX,
bool  aForModelControls = true
 

Set the values of the control curves held in this set at a specified time.

Normally to modify the value of a control curve setParameterValues() would be used. The shape of the control curve is determined by the parameters.

If parameters exist at the specified time, these parameters are modified to give the control curve the specified value. Otherwise, new parameters are added to the control curve.

Parameters:
aT Time at which the value of the control curve is to be set.
aX Array of control curve values, the length of which should equal the number of controls.
aForModelControls If true, only model controls are considered. If false, all controls are considered.

void rdControlSet::setControlValues double  aT,
const double  aX[],
bool  aForModelControls = true
 

Set the values of the control curves held in this set at a specified time.

Normally to modify the value of a control curve setParameterValues() would be used. The shape of the control curve is determined by the parameters.

If parameters exist at the specified time, these parameters are modified to give the control curve the specified value. Otherwise, new parameters are added to the control curve.

Parameters:
aT Time at which the value of the control curve is to be set.
aX Array of control curve values, the length of which should equal the number of controls.
aForModelControls If true, only model controls are considered. If false, all controls are considered.

void rdControlSet::setParameterValues const rdArray< double > &  aP,
const rdArray< int > *  aList = NULL
 

Set the values of the control parameters.

Parameters:
aP Array of control parameters, the length of which should be either the total number of parameters (if aList=NULL) or the same length as aList.
aList If NULL, the values for all parameters for all controls in the control set are set.

void rdControlSet::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 rdPtrArray.


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