如何在openmodelica中从输出块连接到输入块?

如何在openmodelica中从输出块连接到输入块?,modelica,openmodelica,Modelica,Openmodelica,我有一个openmodelica接口 block InputInterfaceBlock CPSModel.ConnectionObjects.SocketConnection con = CPSModel.ConnectionObjects.SocketConnection("/pathToSocket/rpcSocket"); Modelica.Blocks.Interfaces.RealOutput y annotation( Placement(visibl

我有一个
openmodelica
接口

block InputInterfaceBlock

   CPSModel.ConnectionObjects.SocketConnection con =     CPSModel.ConnectionObjects.SocketConnection("/pathToSocket/rpcSocket");

  Modelica.Blocks.Interfaces.RealOutput y annotation(
    Placement(visible = true, transformation(origin = {194, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

 algorithm
   while true loop
    y := CPSModel.Functions.readFromSocket(con);
    print("Message from server : " + String(y) + "\n");
   end while;

  annotation(
     __OpenModelica_simulationFlags(jacobian = "coloredNumerical", s = "dassl", lv = "LOG_STATS"),
uses(Modelica(version = "3.2.2")),
Icon(graphics = {Text(origin = {4, -1}, extent = {{-62, 73}, {62, -73}}, textString = "Input\nInterface", fontName =            "DejaVu Sans Mono Bold")}));

   annotation(
     Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
end InputInterfaceBlock;
我有一个接口块(
InputInterfaceBlock
),它从路径中定义的套接字进行读取。我希望此接口块连接到另一个块(
OutputInterfaceBlock

我的模型如下

model MechatronicSystem

  CPSModel.Models.InputInterfaceBlock Input annotation(
      Placement(visible = true, transformation(origin = {-90, 8}, extent = {{-28, -28}, {28, 28}}, rotation = 0)));

  CPSModel.Models.OutputInterfaceBlock Output annotation(
      Placement(visible = true, transformation(origin = {72, 12}, extent = {{28, 28}, {-28, -28}}, rotation = 0)));

equation
  connect(Input.y, Output.y) annotation(
    Line(points = {{-60, 8}, {44, 8}, {44, 12}, {42, 12}}, color = {0, 0, 127}));
annotation(
      uses(Modelica(version = "3.2.2")));
end MechatronicSystem;
我可以从套接字接收
InputInterfaceBlock
中的数据到模型,但是当我尝试将该数据发送到
OutputInterfaceBlock
时。在
输出接口块
中未接收到它

block OutputInterfaceBlock

  CPSModel.ConnectionObjects.SocketConnection con = CPSModel.ConnectionObjects.SocketConnection("pathToModel/rpcSocket");

  Modelica.Blocks.Interfaces.RealInput y annotation(
    Placement(visible = true, transformation(origin = {194, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

algorithm
    print("Trying to send : " + String(y) + "\n");
        CPSModel.Functions.writeToSocket(con, y);
        print("Message send to server." + "\n");

annotation(
    __OpenModelica_simulationFlags(jacobian = "coloredNumerical", s = "dassl", lv = "LOG_STATS"),
uses(Modelica(version = "3.2.2")),
Icon(graphics = {Text(origin = {4, -1}, extent = {{-62, 73}, {62, -73}}, textString = "Output\nInterface", fontName = "DejaVu Sans Mono")}));
  annotation(
    Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
end OutputInterfaceBlock;

如何修复它?

您在InputInterfaceBlock中使用的是
while true
循环,但Modelica中的不同算法不是共同例程,而是正常算法

当样本(0.1,0.1)为。。。结束时或类似的,它将每0.1s运行一次代码

while循环导致模型应卡在InputInterfaceBlock中,而不调用OutputInterfaceBlock