Dymola’s HTML Report Generator

Hidden away near the end of the Dymola manual are details of Dymola’s HTML report generator. Using an HTML page in a browser as an interface, Dymola can send, and receive, information and commands from a page opened in the browser of a user’s PC. This report page is built in HTML and can interact with Dymola through the JavaScript interface. No knowledge of… or skills in Dymola are necessarily required to use or view the HTML report. This ultimately means it can even be used to help non Dymola users interact with Dymola models.

Tasks such as viewing results, changing parameter values, or viewing animations can be done via this mechanism. Other useful aspects are the ability to display model documentation. More advanced tasks can also be undertaken, such as writing Modelica classes… although I must admit I’m not sure how this would be very useful. What’s more, the report (HTML file) can be stored and sent to anyone with a browser, meaning the reader doesn’t need to actually have Dymola to view the report.

Figure 1: The example HTML report supplied with Dymola offers a range of useful reporting tools.

Figure 1: The example HTML report supplied with Dymola offers a range of useful reporting tools.

How do I enable the HTML Report functionality?

To access this functionality, Dymola must first be instructed to act as a server when the executable is launched. Don’t worry, this is much simpler than it sounds! It is easiest to do this by customizing a shortcut to your preferred Dymola.exe file. Either create a shortcut for launching Dymola, or open the properties of an existing one. All that needs to be done is to modify the target path with –serverport 8082 entered after the path, as shown below.

Figure 2: Modifying the Dymola startup command to launch as a server is very simple.

Figure 2: Modifying the Dymola startup command to launch as a server is very simple.

What underpins the HTML Report?

Using Dymola’s JavaScript interface, the HTML page can interact with Dymola by calling JavaScript functions declared in the HTML report. There are two main groupings of JavaScript functions which can be utilized.

The first is a special set of functions which have been developed to support the aims of the report generator. They are relatively intuitive and designed to enable users to work with the report generator without having to understand JavaScript. They can be called directly from the HTML page.

In addition to these, a second group of functions can be considered. These are the functions found within the DymolaCommands package. All of these commands are supported by JavaScript in the client web browser as per the user manual. These functions aren’t quite as straightforward as the previous ones, as you will have to write the JavaScript function to call the DymolaCommands function. This is a more advanced topic and not the focus of this blog post.

What can the HTML Report do?

A surprisingly large number of tasks can be completed using the inbuilt set of JavaScript commands. The example webpage (written in HTML) provided with Dymola (Dymola xxxx/Modelica/Library/javascript_interface/dymola_report_example.xhtml) provides an example of all the commands, including HTML syntax. All commands follow a common syntax:

insertXXXX(result_block, model, …);

Where result_block denotes the id of the block in the webpage, and the model path is contained in the ‘model’ variable. Further function specific arguments follow. To summarize the functions are their usage:

  • insertDiagram: Displays the diagram for the model path supplied.
  • insertIcon: Displays the icon for the model path supplied.
  • insertText: Displays the Modelica text for the model path supplied.
  • insertClass: Displays the Modelica text of the model path specified.
  • insertEquations: Displays the equation view of the model path specified.
  • insertDocumentation: Displays the documentation layer of the model specified.
  • insertParameterDialog: Enables the editing of the top-level parameter values of the model specified
  • insertCommand: Enables entries to be made into the command window.
  • insertPlot: Displays a plot of the specified variables present within a model on the path specified.
  • insertVariableValue: At a specified time, the value of a specific variable from the model the path points to is displayed.
  • insertSignalOperatorValue: This command enables result signal operators (such a max/min) to be applied to a specified variable in the model the path points towards.
  • insertAnimation: An animation window of the specified model path is displayed, which is interactive.
  • setClassTest: Enables the creation or editing of a Modelica class.

How can I distribute a HTML Report?

Distribution of the generated HTML report is relatively straightforward. If you don’t mind losing animation capability you can just print the webpage to a pdf file. Or, if the user you plan to send the report to has a licensed version of Dymola, you can just send them the HTML file you’ve created.

As I alluded to in the previous paragraph, several of the commands utilized in this mechanism (insertAnimation, insertCommand, insertVariableValue and setClassText) are dynamically linked to Dymola (i.e. they interact with it) so they cannot be included in a report which has been distributed to a user without Dymola licensed/installed.

Conclusion

Utilizing HTML reports may be an effective way of distributing results or models in your day to day life. I hope this post piqued your interest enough that you dig in and check out this functionality.

Nate Horn – Vice President

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion.

CONTACT US

Got a question? Just fill in this form and send it to us and we'll get back to you shortly.

Sending

© Copyright 2010-2024 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?