从连接器数组中提取数组

时间:2015-03-29 18:47:06

标签: modelica openmodelica

似乎至少不鼓励使用连接器作为参数编写Modelica函数。如果我尝试的话,我会收到警告。

假设我有一个连接器

connector con
  Real x;
  Real y;
end con;

记录

record rec
  Real x;
  Real y;
end rec;

和一个功能

function f
  input rec r[:];
  output Real z;
algorithm
  ...
end f;

给定一组连接器,即con c[N],如何将其转换为记录数组rec

一种方法是使用函数

function convert
  input Integer N;
  input Real x[N];
  input Real y[N];
  output rec z[N];
algorithm 
  z.x := x;
  z.y := y;
end convert;

并通过convert(size(c, 1), c.x, c.y)调用。

有更简单的方法吗?

0 个答案:

没有答案
相关问题