Bodylight.js

Bodylight.js

  • Docs
  • GitHub

›API

Getting started

  • Introduction
  • Compiling Modelica

Simple project

  • Creating a simple project
  • Adding the model
  • Visualisation
  • Controls
  • Events and Actions

Physiological application

  • Pressure volume cardiac simulator
  • Creating the layout
  • Adding the heart
  • Heart Beat
  • Controls
  • Phases
  • Pressure volume chart
  • Rolling charts
  • Custom actions
  • Buttons
  • Finishing touches

API

  • Model
  • Plotly chart
  • Range
  • Toggle

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)
  1. play boolean (default: true) if true the model will be running after the reset.
  2. 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.

  1. stepSize{number} simulation time between steps.
  2. 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 given name{string}.

updateValueByName()

model.updateValueByName(name, modifier)
  • modifier{function|number}

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 given name {string}. If not found, returns {null}.

getSingleReal()

model.getSingleReal(reference)
  • Returns value{fmi2Real} of a variable matching the given reference{fmi2ValueReference}.

getSingleBoolean()

model.getSingleBoolean(reference)
  • Returns value{fmi2Boolean} of a variable matching the given reference{fmi2ValueReference}.

setValue()

model.setValue(reference, value)
  • Sets the value{fmi2Real} of the given reference{fmi2ValueReference} before the next step of the model.
← Finishing touchesPlotly chart →
  • pause()
  • play()
  • reset()
  • setSpeed()
  • getValueByName()
  • updateValueByName()
  • getReferenceFromName()
  • getSingleReal()
  • getSingleBoolean()
  • setValue()
Copyright © 2019 Creative Connections s.r.o.