.Modelica_DeviceDrivers.Utilities.Functions.loadRealParameter

Information

Load parameters from file during initialization

The function expects a file format in the style "identifier=value".

Example

Consider following example file and assume it's saved under location
"modelica://Modelica_DeviceDrivers/Resources/test/Util/parameterInitValues.txt":

arrayvar_1=0.1
arrayvar_2=0.2
arrayvar_3=0.3
var1=13

Such a file could be accessed by the following Modelica code.

model TestLoadRealParameter
extends Modelica.Icons.Example;
  import Modelica_DeviceDrivers.Utilities.Functions.*;
  parameter Real var1 = loadRealParameter(
   Modelica.Utilities.Files.loadResource("modelica://Modelica_DeviceDrivers/Resources/test/Util/parameterInitValues.txt"), "var1");
  parameter Integer n = 3 "Size of arrayvar";
  parameter Real arrayvar[n] = loadRealParameterVector(
   Modelica.Utilities.Files.loadResource("modelica://Modelica_DeviceDrivers/Resources/test/Util/parameterInitValues.txt"), "arrayvar", n);
equation
  when sample(0, 0.1) then
    Modelica.Utilities.Streams.print("var1: "+String(var1));
    for i in 1:3 loop
        Modelica.Utilities.Streams.print("arrayvar["+String(i)+"] = "+String(arrayvar[i]));
    end for;
  end when;
end TestLoadRealParameter;

Interface

function loadRealParameter
  extends Modelica.Icons.Function;
  input String file = "Washout.ini";
  input String name = "K_Px";
  output Real u;
end loadRealParameter;

Generated at 2024-11-23T19:25:52Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos