modelJSONWriter

Model for writing results to a json file

Extends from Modelica.Blocks.Icons.DiscreteBlock (Graphical layout of discrete block component icon).

Information

This model samples the model inputs u and saves them to a json file.

Typical use and important parameters

The parameter nin defines the number of variables that are stored. In Dymola, this parameter is updated automatically when inputs are connected to the component.

The parameter fileName defines to what file name the results are saved. The file is in the current working directory, unless an absolute path is provided.

The parameter keyNames defines the key names that are used to store the json values corresponding to the inputs u.

Dynamics

This model samples its inputs at the time defined by the parameter outputTime and writes them to the file fileName. The model has the following options:

  • If outputTime==OutputTime.Initial, results are saved at initialisation.
  • If outputTime==OutputTime.Custom, results are saved when the built-in variable time achieves customTime.
  • If outputTime==OutputTime.Terminal, results are saved when the simulation terminates.

Parameters

TypeNameDefaultDescription
IntegerninNumber of inputs
StringfileNamegetInstanceName() + ".json"File name, including extension
StringvarKeys{"key" + String(i) for i in 1:nin}Key names, indices by default
Buildings.Utilities.IO.Files.BaseClasses.OutputTimeoutputTimeBuildings.Utilities.IO.Files.BaseClasses.OutputTime.TerminalTime when results are written to file
Modelica.Units.SI.TimecustomTime0Custom time when results are stored, used if outputTime=Custom only

Connectors

TypeNameDefaultDescription
Modelica.Blocks.Interfaces.RealVectorInputuVariables that are saved

Revisions

  • April 9, 2019 by Filip Jorissen:
    First implementation. See #1114.