Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » akhn
  • » Profile

Posts

Posts

Hi,

maybe someone can help me with a little Problem. When i'm trying to simulate this code i'm always getting the messages = "Simulation execution failed for model: Simulator
Error, input data file does not match model.

Code:


class Simulator
  A a;
  B b;

  equation
  connect(a.outPort,b.inPort);
end Simulator;

connector Port
  String Name;
end Port;

class A
  Port outPort;
 
  equation
when time >= 2 then
    outPort.Name="Peter";
end when; 
end A;

class B
  Port inPort;
end B;

It works if i leave the when condition aside. The original Code also works, if i use another variable type like boolean or integer. If i simulate a class like Test the when equation works with the String variables. It would be really nice, if someone could tell me the reason why the execution for the simulation of the code above fails.

Code:


class Test
  String name="Peter";
  String newname;
 
  equation
  when time >=2 then
    newname=name;
    end when;
  end Test;

Hi,

i'm fairly new to OM and having some problems with a project i'm working on. My task is to model a simplifierd Computer/Software which gets command packets as an input and routes the right signals to the according triggers of state machines. My main problem with the model i've come up with is that it doesn't allow repated alteration between two states since i used when equations so i can trigger a transition only once. Is there a good possibility to reset the trigger variable immediately after the transition of the state machine? The only solution i've come up with is to set back the signal manually after a certain amount of time because otherwise i'm always having to much equations.
Here is a basic example of my code (Trigger Variables: outPortOn.Signal, outPortOff.Signal):

Code:


class Simulator
  Console console;
  PacketRouter packetrouter;
  Buffer buffer;
 
  equation
 
   connect(console.outPort,packetrouter.inPort);
   connect(packetrouter.outPortOn,buffer.inPortOn);
   connect(packetrouter.outPortOff,buffer.inPortOff);
 
end Simulator;

connector Port
  Boolean Signal;
end Port;

connector PacketPort
  extends Port;
  Integer Address;
end PacketPort;

class Console
  PacketPort outPort;
 
  equation
 
  when time >= 8 then
    outPort.Signal=true;
    outPort.Address=0;
  elsewhen time >= 6 then
    outPort.Signal=true;
    outPort.Address=1;
  elsewhen time >= 4 then
    outPort.Signal=true;
    outPort.Address=0;
  elsewhen time >= 2 then
    outPort.Signal=true;
    outPort.Address=1;
  end when;
 
end Console;

class PacketRouter
  PacketPort inPort;
  Port outPortOn;
  Port outPortOff;
 
  equation
 
  when inPort.Address==1 then
    outPortOn.Signal=inPort.Signal;
  end when;

  when inPort.Address==0 then
    outPortOff.Signal=inPort.Signal;
  end when;
     
end PacketRouter;

class Buffer
  Port inPortOn;
  Port inPortOff;
  Port outPortOn;
  Port outPortOff;
 
  equation
 
  when sample(0,1) then
   outPortOn.Signal=inPortOn.Signal;
   outPortOff.Signal=inPortOff.Signal;
  end when;
 
end Buffer;

  • Index
  • » Users
  • » akhn
  • » Profile
You are here: