User manual

Dymola 2015 FD01 Release Notes 31
try {
var dymola = new DymolaInterface();
var result =
dymola.simulateModel("Modelica.Mechanics.Rotational.Examples.CoupledClutches");
if (result) {
result = dymola.plot(["J1.w", "J2.w", "J3.w", "J4.w"]);
if (result) {
result = dymola.ExportPlotAsImage("C:/temp/plot.png");
}
} else {
alert("Simulation failed.");
var log = dymola.getLastError();
alert(log);
}
} catch (e) {
alert("Exception: " + e);
}
For more information about the JavaScript interface, open the file
DymolaInterface.html, located in
Program Files (x86)\Dymola 2015 FD01\Modelica\Library\
java_interface\doc
with your favorite browser.
3.5.4 Report generator
Fundamentals
In Dymola 2015 FD01 a report generator is available. It is based on Dymola running as a
server. It enables a HTML page loaded in a browser to call Modelica functions using
JavaScript. It is possible to insert a model diagram, change parameters, simulate a model,
show plots, show animations, etc. It can be used as a “notebook” since it´s possible to re-
execute function calls, for example to make a simulation with changed parameters and
observe the changed plots. The resulting report can then be stored and sent to anyone (the
reader does not need Dymola to read the report).
XHTML can be used, as well as HTML5, SVG, WebGL, MathML and X3D (successor
standard for VRML). For example, 3D animations can be made directly in a browser using
X3DOM which renders 3D animations represented as X3D. It is written in JavaScript and
uses WebGL. For animation commands available in the animation, see section “Mouse and
keyboard commands available for animation in reports” on page 37 below.
In order to allow calling Modelica functions from HTML, a web server version of Dymola
has been developed. All functions available in the package DymolaCommands are possible
to call from JavaScript in the client web browser. An automatic JavaScript generator has
been developed. It creates the code for the parameter exchange.
To support the report generator, Dymola must be started specifying server port 8082, for
example by adding this port as the last part of
Target in a shortcut for starting Dymola:
Important.