AGX Dynamics  2.37.2.0
agxSDK::SimulationControl Class Reference

A class for adding input and output arguments, to be used when running a co-simulation. More...

#include <SimulationControl.h>

+ Inheritance diagram for agxSDK::SimulationControl:

Classes

class  InputArgumentCollection
 
class  OutputArgumentCollection
 

Public Types

typedef agx::observer_ptr< const Argument > ArgumentConstObserver
 
typedef agx::ref_ptr< const Argument > ArgumentConstRef
 
typedef agx::observer_ptr< Argument > ArgumentObserver
 
typedef agx::ref_ptr< Argument > ArgumentRef
 
typedef agx::Vector< SimulationControlArgumentRef > InputArgumentRefVector
 
typedef agx::Vector< SimulationControlArgumentRef > OutputArgumentRefVector
 
- Public Types inherited from agx::Singleton
enum  Priority { HIGHEST_PRIORITY = 2147483647, LOWEST_PRIORITY = 10000, DEFAULT_PRIORITY = 1073741824 }
 Specifies the ranges of the priority which can be assigned to a singleton at the time of creation. More...
 

Public Member Functions

void addInitInputArgument (const agx::String &portName, SimulationControlArgument *inputArgument)
 Adds an input argument. More...
 
void addInitOutputArgument (const agx::String &portName, SimulationControlArgument *outputArgument)
 Adds an output argument. More...
 
void addInputArgument (const agx::String &portName, SimulationControlArgument *inputArgument)
 Adds an input argument. More...
 
void addOutputArgument (const agx::String &portName, SimulationControlArgument *outputArgument)
 Adds an output argument. More...
 
bool applyInitInputValues (agxSDK::Simulation *simulation, const agx::RealVector &initInputs) const
 
void clear ()
 
const char * getInitInputValueName (size_t valueNr)
 Returns name associated to input value only for scene initialization, by the argument it belongs to. More...
 
const char * getInitOutputValueName (size_t valueNr)
 Returns name associated to output value only for scene initialization, by the argument it belongs to. More...
 
const char * getInputValueName (size_t valueNr)
 Returns name associated to input value by the argument it belongs to. More...
 
agx::String getLastErrorMessage () const
 
const char * getOutputValueName (size_t valueNr)
 Returns name associated to output value by the argument it belongs to. More...
 
size_t getTotalNumInitInputValues () const
 Get total size of input values from all input arguments only for scene initialization. More...
 
size_t getTotalNumInitOutputValues () const
 Get total size of output values from all output arguments only for scene initialization. More...
 
size_t getTotalNumInputValues () const
 Get total size of input values from all input arguments. More...
 
size_t getTotalNumOutputValues () const
 Get total size of output values from all output arguments. More...
 
bool obtainInitOutputValues (agxSDK::Simulation *simulation, const agx::RealVector &initOutputs) const
 
bool step (const agx::RealVector &inputs, const agx::RealVector &outputs, agxSDK::Simulation *simulation)
 Steps the simulation one time step, using inputs and returning outputs. More...
 
- Public Member Functions inherited from agx::Singleton
 Singleton (int priority=DEFAULT_PRIORITY)
 Default constructor. More...
 
virtual std::string getClassName () const =0
 
int getPriority () const
 Return the shutdown priority of the singleton instance. More...
 

Static Public Member Functions

static SimulationControl * instance ()
 Gets (and possibly creates) and instance of the singleton. More...
 

Protected Member Functions

 SimulationControl ()
 
void shutdown () override
 Implement this method to cleanup your Singleton class. More...
 
- Protected Member Functions inherited from agx::Singleton
virtual ~Singleton ()
 Destructor. More...
 
void _shutdown ()
 

Detailed Description

A class for adding input and output arguments, to be used when running a co-simulation.

Definition at line 67 of file SimulationControl.h.

Member Typedef Documentation

◆ ArgumentConstObserver

Definition at line 73 of file SimulationControl.h.

◆ ArgumentConstRef

Definition at line 73 of file SimulationControl.h.

◆ ArgumentObserver

◆ ArgumentRef

Definition at line 73 of file SimulationControl.h.

◆ InputArgumentRefVector

◆ OutputArgumentRefVector

Constructor & Destructor Documentation

◆ SimulationControl()

agxSDK::SimulationControl::SimulationControl ( )
protected

Member Function Documentation

◆ addInitInputArgument()

void agxSDK::SimulationControl::addInitInputArgument ( const agx::String &  portName,
SimulationControlArgument *  inputArgument 
)

Adds an input argument.

Input to AGX Dynamics (output from Simulink) Will get data at the initialization of the scene as specified in the AGX block-argument in Simulink

Parameters
portName- Name of the variable, useful at debugging. DOes not correspond to any port in simulink.

◆ addInitOutputArgument()

void agxSDK::SimulationControl::addInitOutputArgument ( const agx::String &  portName,
SimulationControlArgument *  outputArgument 
)

Adds an output argument.

Output from AGX Dynamics (input to Simulink)

Parameters
portName- The name of the Simulink output port ( Will send data from AGX at the initialization to Simulink to the named input port

◆ addInputArgument()

void agxSDK::SimulationControl::addInputArgument ( const agx::String &  portName,
SimulationControlArgument *  inputArgument 
)

Adds an input argument.

Input to AGX Dynamics (output from Simulink)

Parameters
portName- The name of the Simulink output port

◆ addOutputArgument()

void agxSDK::SimulationControl::addOutputArgument ( const agx::String &  portName,
SimulationControlArgument *  outputArgument 
)

Adds an output argument.

Output from AGX Dynamics (input to Simulink)

Parameters
portName- The name of the Simulink input port

◆ applyInitInputValues()

bool agxSDK::SimulationControl::applyInitInputValues ( agxSDK::Simulation *  simulation,
const agx::RealVector &  initInputs 
) const

◆ clear()

void agxSDK::SimulationControl::clear ( )

◆ getInitInputValueName()

const char* agxSDK::SimulationControl::getInitInputValueName ( size_t  valueNr)

Returns name associated to input value only for scene initialization, by the argument it belongs to.

Parameters
valueNrThe number of the input value.
Return values
Thename. 0 if valueNr >= number of input values.

◆ getInitOutputValueName()

const char* agxSDK::SimulationControl::getInitOutputValueName ( size_t  valueNr)

Returns name associated to output value only for scene initialization, by the argument it belongs to.

Parameters
valueNrThe number of the output value.
Return values
Thename. 0 if valueNr >= number of output values.

◆ getInputValueName()

const char* agxSDK::SimulationControl::getInputValueName ( size_t  valueNr)

Returns name associated to input value by the argument it belongs to.

Parameters
valueNrThe number of the input value.
Return values
Thename. 0 if valueNr >= number of input values.

◆ getLastErrorMessage()

agx::String agxSDK::SimulationControl::getLastErrorMessage ( ) const
Returns
the last error message set by any method. Will be cleared every timestep

◆ getOutputValueName()

const char* agxSDK::SimulationControl::getOutputValueName ( size_t  valueNr)

Returns name associated to output value by the argument it belongs to.

Parameters
valueNrThe number of the output value.
Return values
Thename. 0 if valueNr >= number of output values.

◆ getTotalNumInitInputValues()

size_t agxSDK::SimulationControl::getTotalNumInitInputValues ( ) const

Get total size of input values from all input arguments only for scene initialization.

◆ getTotalNumInitOutputValues()

size_t agxSDK::SimulationControl::getTotalNumInitOutputValues ( ) const

Get total size of output values from all output arguments only for scene initialization.

◆ getTotalNumInputValues()

size_t agxSDK::SimulationControl::getTotalNumInputValues ( ) const

Get total size of input values from all input arguments.

◆ getTotalNumOutputValues()

size_t agxSDK::SimulationControl::getTotalNumOutputValues ( ) const

Get total size of output values from all output arguments.

◆ instance()

static SimulationControl* agxSDK::SimulationControl::instance ( )
static

Gets (and possibly creates) and instance of the singleton.

◆ obtainInitOutputValues()

bool agxSDK::SimulationControl::obtainInitOutputValues ( agxSDK::Simulation *  simulation,
const agx::RealVector &  initOutputs 
) const

◆ shutdown()

void agxSDK::SimulationControl::shutdown ( )
overrideprotectedvirtual

Implement this method to cleanup your Singleton class.

Reimplemented from agx::Singleton.

◆ step()

bool agxSDK::SimulationControl::step ( const agx::RealVector &  inputs,
const agx::RealVector &  outputs,
agxSDK::Simulation *  simulation 
)

Steps the simulation one time step, using inputs and returning outputs.

If anything goes wrong, reports to LOGGER_WARNING and returns false.

Parameters
inputsThe inputs. Fixed size.
outputsThe outputs. Fixed size, just write at the right positions.
Return values
Dideverything go ok?

The documentation for this class was generated from the following file: