Model
pause()
model.pause()
Pauses the continuous model, this is ignored in OneShot.
play()
model.play()
Continues the model execution.
reset()
model.reset(play, resetInputValues)
play
boolean (default:true
) if true the model will be running after the reset.resetInputValues
boolean (default:false
) if true the model will forget previously set values, useful in case we want to reset input Widgets, to their model given default values.
setSpeed()
model.setSpeed(stepSize, interval)
Configures the simulation speed of the model.
stepSize
{number} simulation time between steps.interval
{number} [ms] how often should model step. Lower limit is determined by the browser, safe option should be 10ms.
Usage
const stepSize = model.config.stepSize;
const interval = model.config.interval;
model.setSpeed(stepSize * 2, interval * 2);
getValueByName()
model.getValueByName(name)
- Returns
value
{fmi2Real} of a variable matching the givenname
{string}.
updateValueByName()
model.updateValueByName(name, modifier)
Updates the value of the variable matching the given name
{string} to the value of modifier
. If modifier
is a function then it will be called with the previous value of the variable.
Value will be set before the next step of the model.
Usage
model.updateValueByName(‘name’, 150)
model.updateValueByName(‘name’, value => value * 10)
model.updateValueByName(‘name’, value => {
// do other stuff here
return value * 150
})
Lower-level API
getReferenceFromName()
model.getReferenceFromName(name)
- Returns
reference
{fmi2ValueReference} to a variable matching the givenname
{string}. If not found, returns {null}.
getSingleReal()
model.getSingleReal(reference)
- Returns
value
{fmi2Real} of a variable matching the givenreference
{fmi2ValueReference}.
getSingleBoolean()
model.getSingleBoolean(reference)
- Returns
value
{fmi2Boolean} of a variable matching the givenreference
{fmi2ValueReference}.
setValue()
model.setValue(reference, value)
- Sets the
value
{fmi2Real} of the givenreference
{fmi2ValueReference} before the next step of the model.