- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Missing token: SEMICOLON??
Missing token: SEMICOLON??
Missing token: SEMICOLON??
Hello,
I started with a .mo model file, generated a .mo class file (see below) with a command like:
omc Transformer.mo library.mo > Transformer_f.mo
Now I'm trying to generate C code from it with:
omc Transformer_f.mo > Transformer.c
but I'm getting an error:
[Transformer_f.mo:10:17-10:17:writable] Error: Missing token: SEMICOLON
I tried adding the +s=true tag but same error, anything wrong with what I'm doing?
Thank you for your time & help!
Best regards,
Paul
Transformer_f.mo:
class Transformer_im
parameter Real R_11(fixed = false) = 6.0 "R_11";
parameter Real C_31(fixed = false) = 0.01 "C_31";
parameter Real v_32(fixed = false) = 0.0 "v_32";
parameter Real L_41(fixed = false) = 1e-05 "L_41";
parameter Real L_61(fixed = false) = 1e-05 "L_61";
parameter Real R_71(fixed = false) = 6.0 "R_71";
parameter Real N_81(fixed = false) = 1.0 "N_81";
parameter Real R_121(fixed = false) = 0.01 "R_121";
Real Resistor1.p.v;
Real Resistor1.p.i;
Real Resistor1.n.v;
Real Resistor1.n.i;
Real Resistor1.i;
Real Resistor1.v;
parameter Real Resistor1.R = R_11 "Resistance";
Real CCS1.p.v;
Real CCS1.p.i;
Real CCS1.n.v;
Real CCS1.n.i;
Real CCS1.i;
Real CCS1.v;
Real CCS1.Iin;
Real Capacitor1.p.v;
Real Capacitor1.p.i;
Real Capacitor1.n.v;
Real Capacitor1.n.i;
Real Capacitor1.i;
Real Capacitor1.v(start = v_32);
parameter Real Capacitor1.C(fixed = true) = C_31 "Capacitance";
Real Inductor1.p.v;
Real Inductor1.p.i;
Real Inductor1.n.v;
Real Inductor1.n.i;
Real Inductor1.i;
Real Inductor1.v;
parameter Real Inductor1.L = L_41 "Inductance";
Real PotentialSensor1.p.v;
Real PotentialSensor1.p.i;
Real PotentialSensor1.v;
Real Inductor2.p.v;
Real Inductor2.p.i;
Real Inductor2.n.v;
Real Inductor2.n.i;
Real Inductor2.i;
Real Inductor2.v;
parameter Real Inductor2.L = L_61 "Inductance";
Real Resistor2.p.v;
Real Resistor2.p.i;
Real Resistor2.n.v;
Real Resistor2.n.i;
Real Resistor2.i;
Real Resistor2.v;
parameter Real Resistor2.R = R_71 "Resistance";
parameter Real IdealTransformer1.N = N_81 "Transformer turn ration N1/N2";
Real IdealTransformer1.p1.v;
Real IdealTransformer1.p1.i;
Real IdealTransformer1.n1.v;
Real IdealTransformer1.n1.i;
Real IdealTransformer1.p2.v;
Real IdealTransformer1.p2.i;
Real IdealTransformer1.n2.v;
Real IdealTransformer1.n2.i;
Real IdealTransformer1.v2;
Real IdealTransformer1.v1;
Real IdealTransformer1.i1;
Real IdealTransformer1.i2;
Real Ground1.p.v;
Real Ground1.p.i;
Real Ground2.p.v;
Real Ground2.p.i;
Real VoltageSensor1.p.v;
Real VoltageSensor1.p.i;
Real VoltageSensor1.n.v;
Real VoltageSensor1.n.i;
Real VoltageSensor1.i;
Real VoltageSensor1.v;
Real Resistor3.p.v;
Real Resistor3.p.i;
Real Resistor3.n.v;
Real Resistor3.n.i;
Real Resistor3.i;
Real Resistor3.v;
parameter Real Resistor3.R = R_121 "Resistance";
Real OutPutPort1.vo;
Real OutPutPort1.vi;
Real OutPutPort2.vo;
Real OutPutPort2.vi;
Real InPutPort1.vo;
Real InPutPort1.vi;
equation
Resistor1.R * Resistor1.i = Resistor1.v;
Resistor1.i = Resistor1.p.i;
Resistor1.n.i = -Resistor1.i;
Resistor1.v = Resistor1.p.v - Resistor1.n.v;
CCS1.Iin = CCS1.i;
CCS1.i = CCS1.p.i;
CCS1.n.i = -CCS1.i;
CCS1.v = CCS1.p.v - CCS1.n.v;
Capacitor1.C * der(Capacitor1.v) = Capacitor1.i;
Capacitor1.i = Capacitor1.p.i;
Capacitor1.n.i = -Capacitor1.i;
Capacitor1.v = Capacitor1.p.v - Capacitor1.n.v;
Inductor1.L * der(Inductor1.i) = Inductor1.v;
Inductor1.i = Inductor1.p.i;
Inductor1.n.i = -Inductor1.i;
Inductor1.v = Inductor1.p.v - Inductor1.n.v;
PotentialSensor1.p.i = 0.0;
PotentialSensor1.v = PotentialSensor1.p.v;
Inductor2.L * der(Inductor2.i) = Inductor2.v;
Inductor2.i = Inductor2.p.i;
Inductor2.n.i = -Inductor2.i;
Inductor2.v = Inductor2.p.v - Inductor2.n.v;
Resistor2.R * Resistor2.i = Resistor2.v;
Resistor2.i = Resistor2.p.i;
Resistor2.n.i = -Resistor2.i;
Resistor2.v = Resistor2.p.v - Resistor2.n.v;
IdealTransformer1.v1 = IdealTransformer1.p1.v - IdealTransformer1.n1.v;
0.0 = IdealTransformer1.p1.i + IdealTransformer1.n1.i;
IdealTransformer1.i1 = IdealTransformer1.p1.i;
IdealTransformer1.v2 = IdealTransformer1.p2.v - IdealTransformer1.n2.v;
0.0 = IdealTransformer1.p2.i + IdealTransformer1.n2.i;
IdealTransformer1.i2 = IdealTransformer1.p2.i;
IdealTransformer1.v1 = IdealTransformer1.N * IdealTransformer1.v2;
IdealTransformer1.i2 = (-IdealTransformer1.N) * IdealTransformer1.i1;
Ground1.p.v = 0.0;
Ground2.p.v = 0.0;
VoltageSensor1.i = 0.0;
VoltageSensor1.i = VoltageSensor1.p.i;
VoltageSensor1.n.i = -VoltageSensor1.i;
VoltageSensor1.v = VoltageSensor1.p.v - VoltageSensor1.n.v;
Resistor3.R * Resistor3.i = Resistor3.v;
Resistor3.i = Resistor3.p.i;
Resistor3.n.i = -Resistor3.i;
Resistor3.v = Resistor3.p.v - Resistor3.n.v;
OutPutPort1.vi = OutPutPort1.vo;
OutPutPort2.vi = OutPutPort2.vo;
InPutPort1.vi = InPutPort1.vo;
VoltageSensor1.v = OutPutPort1.vi;
PotentialSensor1.v = OutPutPort2.vi;
InPutPort1.vo = CCS1.Iin;
CCS1.p.i + PotentialSensor1.p.i + Resistor1.n.i + Inductor1.p.i = 0.0;
CCS1.n.i + Ground2.p.i + Resistor1.p.i + IdealTransformer1.n1.i = 0.0;
Ground1.p.i + VoltageSensor1.n.i + Capacitor1.n.i + Resistor2.n.i + IdealTransformer1.n2.i = 0.0;
VoltageSensor1.p.i + Capacitor1.p.i + Resistor2.p.i + Resistor3.p.i = 0.0;
Inductor1.n.i + IdealTransformer1.p1.i = 0.0;
Inductor2.p.i + IdealTransformer1.p2.i = 0.0;
Inductor2.n.i + Resistor3.n.i = 0.0;
CCS1.n.v = Ground2.p.v;
CCS1.n.v = IdealTransformer1.n1.v;
CCS1.n.v = Resistor1.p.v;
Capacitor1.n.v = Ground1.p.v;
Capacitor1.n.v = IdealTransformer1.n2.v;
Capacitor1.n.v = Resistor2.n.v;
Capacitor1.n.v = VoltageSensor1.n.v;
Capacitor1.p.v = Resistor2.p.v;
Capacitor1.p.v = Resistor3.p.v;
Capacitor1.p.v = VoltageSensor1.p.v;
CCS1.p.v = Inductor1.p.v;
CCS1.p.v = PotentialSensor1.p.v;
CCS1.p.v = Resistor1.n.v;
Inductor2.n.v = Resistor3.n.v;
IdealTransformer1.p1.v = Inductor1.n.v;
IdealTransformer1.p2.v = Inductor2.p.v;
end Transformer_im;
Re: Missing token: SEMICOLON??
That's not a Modelica file, but a "flat Modelica" file. They cannot be used as input to the compiler.
- sjoelund.se
- 1700 Posts
Re: Missing token: SEMICOLON??
Ok thank you, indeed I passed directly the model file and it worked!
However, on some other models, I get a "Too few equations, under-determined system." error.
The class file output by omc indeed shows more variables than equations but my old compiler (modelicac) used to pass these models.
I compared the class file and they are roughly the same.
Is there an flag I should give to omc in order to pass, or am I doing something wrong?
I didn't forget the mass in my model.
I noticed
Thank you very much!
Paul
Re: Missing token: SEMICOLON??
It might just be something that changed in the Modelica specification (modelicac does not follow recent standards). I can't really say without seeing the model in question, but you could try with --std=1.x or --std=2.x to see if that makes a difference.
- sjoelund.se
- 1700 Posts
Re: Missing token: SEMICOLON??
Tried with std 1.x & 2.x but the errors were the same.
Here is the model:
model Switched_im
parameter Real VA_11(fixed=false) =0.1 "VA_11";
parameter Real f_12(fixed=false) =4000 "f_12";
parameter Real Ron_21(fixed=false) =0.0001 "Ron_21";
parameter Real Roff_22(fixed=false) =100000000 "Roff_22";
parameter Real Ron_31(fixed=false) =0.0001 "Ron_31";
parameter Real Roff_32(fixed=false) =100000000 "Roff_32";
parameter Real C_41(fixed=false) =0.0000000001 "C_41";
parameter Real v_42(fixed=false) =0 "v_42";
parameter Real C_51(fixed=false) =0.0000000001 "C_51";
parameter Real v_52(fixed=false) =0 "v_52";
parameter Real R_61(fixed=false) =1000000 "R_61";
parameter Real C_121(fixed=false) =0.00000000001 "C_121";
parameter Real v_122(fixed=false) =0 "v_122";
VsourceAC VsourceAC1(VA=VA_11, f=f_12);
Switch Switch1(Ron=Ron_21, Roff=Roff_22) "Switch";
Switch Switch2(Ron=Ron_31, Roff=Roff_32) "Switch";
Capacitor Capacitor1(C=C_41, v(start=v_42)) "Capacitor";
Capacitor Capacitor2(C=C_51, v(start=v_52)) "Capacitor";
Resistor Resistor1(R=R_61) "Resistor";
OpAmp OpAmp1;
OpAmp OpAmp2;
Ground Ground1;
VoltageSensor VoltageSensor1;
VoltageSensor VoltageSensor2;
Capacitor Capacitor3(C=C_121, v(start=v_122)) "Capacitor";
OutPutPort OutPutPort1;
OutPutPort OutPutPort2;
InPutPort InPutPort1;
InPutPort InPutPort2;
equation
connect (VoltageSensor2.n,VoltageSensor1.n);
connect (OpAmp1.in_p,VoltageSensor1.n);
connect (OpAmp2.in_p,VoltageSensor1.n);
connect (Capacitor3.n,VoltageSensor1.n);
connect (Ground1.p,VoltageSensor1.n);
connect (VsourceAC1.p,VoltageSensor1.n);
connect (VoltageSensor2.p,OpAmp2.out);
connect (Capacitor2.n,OpAmp2.out);
connect (VoltageSensor1.p,Capacitor1.n);
connect (OpAmp1.out,Capacitor1.n);
connect (OpAmp2.in_n,Resistor1.n);
connect (Capacitor2.p,Resistor1.n);
connect (OpAmp1.in_n,Switch2.n);
connect (Capacitor1.p,Switch2.n);
connect (Switch1.p,VsourceAC1.n);
connect (Resistor1.p,VsourceAC1.n);
connect (Switch2.p,Switch1.n);
connect (Capacitor3.p,Switch1.n);
VoltageSensor2.v = OutPutPort1.vi;
VoltageSensor1.v = OutPutPort2.vi;
InPutPort1.vo = Switch1.inp;
InPutPort2.vo = Switch2.inp;
end Switched_im;
And here is the class output by omc (error: The model has 78 equation(s) and 80 variable(s)):
class Switched_im
parameter Real VA_11(fixed = false) = 0.1 "VA_11";
parameter Real f_12(fixed = false) = 4000.0 "f_12";
parameter Real Ron_21(fixed = false) = 0.0001 "Ron_21";
parameter Real Roff_22(fixed = false) = 100000000.0 "Roff_22";
parameter Real Ron_31(fixed = false) = 0.0001 "Ron_31";
parameter Real Roff_32(fixed = false) = 100000000.0 "Roff_32";
parameter Real C_41(fixed = false) = 1e-10 "C_41";
parameter Real v_42(fixed = false) = 0.0 "v_42";
parameter Real C_51(fixed = false) = 1e-10 "C_51";
parameter Real v_52(fixed = false) = 0.0 "v_52";
parameter Real R_61(fixed = false) = 1000000.0 "R_61";
parameter Real C_121(fixed = false) = 9.999999999999999e-12 "C_121";
parameter Real v_122(fixed = false) = 0.0 "v_122";
Real VsourceAC1.p.v;
Real VsourceAC1.p.i;
Real VsourceAC1.n.v;
Real VsourceAC1.n.i;
Real VsourceAC1.i;
Real VsourceAC1.v;
parameter Real VsourceAC1.VA = VA_11 "Amplitude";
parameter Real VsourceAC1.f = f_12 "Frequency";
parameter Real VsourceAC1.PI = 3.141592653589793;
Real Switch1.p.v;
Real Switch1.p.i;
Real Switch1.n.v;
Real Switch1.n.i;
Real Switch1.i;
Real Switch1.v;
parameter Real Switch1.Ron = Ron_21 "Resistance when the Switch is closed";
parameter Real Switch1.Roff = Roff_22 "Resistance when the switch is open";
Real Switch1.inp;
Real Switch1.Rx;
Real Switch2.p.v;
Real Switch2.p.i;
Real Switch2.n.v;
Real Switch2.n.i;
Real Switch2.i;
Real Switch2.v;
parameter Real Switch2.Ron = Ron_31 "Resistance when the Switch is closed";
parameter Real Switch2.Roff = Roff_32 "Resistance when the switch is open";
Real Switch2.inp;
Real Switch2.Rx;
Real Capacitor1.p.v;
Real Capacitor1.p.i;
Real Capacitor1.n.v;
Real Capacitor1.n.i;
Real Capacitor1.i;
Real Capacitor1.v(start = v_42);
parameter Real Capacitor1.C(fixed = true) = C_41 "Capacitance";
Real Capacitor2.p.v;
Real Capacitor2.p.i;
Real Capacitor2.n.v;
Real Capacitor2.n.i;
Real Capacitor2.i;
Real Capacitor2.v(start = v_52);
parameter Real Capacitor2.C(fixed = true) = C_51 "Capacitance";
Real Resistor1.p.v;
Real Resistor1.p.i;
Real Resistor1.n.v;
Real Resistor1.n.i;
Real Resistor1.i;
Real Resistor1.v;
parameter Real Resistor1.R = R_61 "Resistance";
Real OpAmp1.in_p.v;
Real OpAmp1.in_p.i;
Real OpAmp1.in_n.v;
Real OpAmp1.in_n.i;
Real OpAmp1.out.v;
Real OpAmp1.out.i;
Real OpAmp2.in_p.v;
Real OpAmp2.in_p.i;
Real OpAmp2.in_n.v;
Real OpAmp2.in_n.i;
Real OpAmp2.out.v;
Real OpAmp2.out.i;
Real Ground1.p.v;
Real Ground1.p.i;
Real VoltageSensor1.p.v;
Real VoltageSensor1.p.i;
Real VoltageSensor1.n.v;
Real VoltageSensor1.n.i;
Real VoltageSensor1.i;
Real VoltageSensor1.v;
Real VoltageSensor2.p.v;
Real VoltageSensor2.p.i;
Real VoltageSensor2.n.v;
Real VoltageSensor2.n.i;
Real VoltageSensor2.i;
Real VoltageSensor2.v;
Real Capacitor3.p.v;
Real Capacitor3.p.i;
Real Capacitor3.n.v;
Real Capacitor3.n.i;
Real Capacitor3.i;
Real Capacitor3.v(start = v_122);
parameter Real Capacitor3.C(fixed = true) = C_121 "Capacitance";
Real OutPutPort1.vo;
Real OutPutPort1.vi;
Real OutPutPort2.vo;
Real OutPutPort2.vi;
Real InPutPort1.vo;
Real InPutPort1.vi;
Real InPutPort2.vo;
Real InPutPort2.vi;
equation
VsourceAC1.v = VsourceAC1.VA * sin(2.0 * VsourceAC1.PI * VsourceAC1.f * time);
VsourceAC1.i = VsourceAC1.p.i;
VsourceAC1.n.i = -VsourceAC1.i;
VsourceAC1.v = VsourceAC1.p.v - VsourceAC1.n.v;
Switch1.Rx * Switch1.i = Switch1.v;
Switch1.Rx = if Switch1.inp > 0.0 then Switch1.Ron else Switch1.Roff;
Switch1.i = Switch1.p.i;
Switch1.n.i = -Switch1.i;
Switch1.v = Switch1.p.v - Switch1.n.v;
Switch2.Rx * Switch2.i = Switch2.v;
Switch2.Rx = if Switch2.inp > 0.0 then Switch2.Ron else Switch2.Roff;
Switch2.i = Switch2.p.i;
Switch2.n.i = -Switch2.i;
Switch2.v = Switch2.p.v - Switch2.n.v;
Capacitor1.C * der(Capacitor1.v) = Capacitor1.i;
Capacitor1.i = Capacitor1.p.i;
Capacitor1.n.i = -Capacitor1.i;
Capacitor1.v = Capacitor1.p.v - Capacitor1.n.v;
Capacitor2.C * der(Capacitor2.v) = Capacitor2.i;
Capacitor2.i = Capacitor2.p.i;
Capacitor2.n.i = -Capacitor2.i;
Capacitor2.v = Capacitor2.p.v - Capacitor2.n.v;
Resistor1.R * Resistor1.i = Resistor1.v;
Resistor1.i = Resistor1.p.i;
Resistor1.n.i = -Resistor1.i;
Resistor1.v = Resistor1.p.v - Resistor1.n.v;
OpAmp1.in_p.i = 0.0;
OpAmp1.in_n.i = 0.0;
OpAmp1.in_p.v - OpAmp1.in_n.v = 0.0;
OpAmp2.in_p.i = 0.0;
OpAmp2.in_n.i = 0.0;
OpAmp2.in_p.v - OpAmp2.in_n.v = 0.0;
Ground1.p.v = 0.0;
VoltageSensor1.i = 0.0;
VoltageSensor1.i = VoltageSensor1.p.i;
VoltageSensor1.n.i = -VoltageSensor1.i;
VoltageSensor1.v = VoltageSensor1.p.v - VoltageSensor1.n.v;
VoltageSensor2.i = 0.0;
VoltageSensor2.i = VoltageSensor2.p.i;
VoltageSensor2.n.i = -VoltageSensor2.i;
VoltageSensor2.v = VoltageSensor2.p.v - VoltageSensor2.n.v;
Capacitor3.C * der(Capacitor3.v) = Capacitor3.i;
Capacitor3.i = Capacitor3.p.i;
Capacitor3.n.i = -Capacitor3.i;
Capacitor3.v = Capacitor3.p.v - Capacitor3.n.v;
OutPutPort1.vi = OutPutPort1.vo;
OutPutPort2.vi = OutPutPort2.vo;
InPutPort1.vi = InPutPort1.vo;
InPutPort2.vi = InPutPort2.vo;
VoltageSensor2.v = OutPutPort1.vi;
VoltageSensor1.v = OutPutPort2.vi;
InPutPort1.vo = Switch1.inp;
InPutPort2.vo = Switch2.inp;
OpAmp1.in_p.i + OpAmp2.in_p.i + Ground1.p.i + VoltageSensor1.n.i + VoltageSensor2.n.i + VsourceAC1.p.i + Capacitor3.n.i = 0.0;
OpAmp1.in_n.i + Switch2.n.i + Capacitor1.p.i = 0.0;
OpAmp1.out.i + VoltageSensor1.p.i + Capacitor1.n.i = 0.0;
OpAmp2.in_n.i + Capacitor2.p.i + Resistor1.n.i = 0.0;
OpAmp2.out.i + VoltageSensor2.p.i + Capacitor2.n.i = 0.0;
VsourceAC1.n.i + Switch1.p.i + Resistor1.p.i = 0.0;
Switch1.n.i + Switch2.p.i + Capacitor3.p.i = 0.0;
Capacitor3.n.v = Ground1.p.v;
Capacitor3.n.v = OpAmp1.in_p.v;
Capacitor3.n.v = OpAmp2.in_p.v;
Capacitor3.n.v = VoltageSensor1.n.v;
Capacitor3.n.v = VoltageSensor2.n.v;
Capacitor3.n.v = VsourceAC1.p.v;
Capacitor2.n.v = OpAmp2.out.v;
Capacitor2.n.v = VoltageSensor2.p.v;
Capacitor1.n.v = OpAmp1.out.v;
Capacitor1.n.v = VoltageSensor1.p.v;
Capacitor2.p.v = OpAmp2.in_n.v;
Capacitor2.p.v = Resistor1.n.v;
Capacitor1.p.v = OpAmp1.in_n.v;
Capacitor1.p.v = Switch2.n.v;
Resistor1.p.v = Switch1.p.v;
Resistor1.p.v = VsourceAC1.n.v;
Capacitor3.p.v = Switch1.n.v;
Capacitor3.p.v = Switch2.p.v;
end Switched_im;
Thank you for your time,
Paul
FYI modelicac used to report when it failed, and it passed that model (simulation was correct somehow)
Re: Missing token: SEMICOLON??
The model is not very useful, but I suspect modelicac allowed input variables not on the top level class to count as inputs to the simulation. InPutPort1.vi lacks an equation in your model, which is not allowed in Modelica.
- sjoelund.se
- 1700 Posts
Re: Missing token: SEMICOLON??
Yes there seems to be a logic: the number of missing equations in the error message corresponds to the number of inputs to the model.
I'm confused about your message though because "InPutPort1.vi = InPutPort1.vo;" looks equation enough to me, when coupled with "InPutPort1.vo = Switch1.inp;", I wonder what's missing...
Anyway, would you know a way around this please? Maybe by hand-modifying the original .mo file?
Side question: I noticed the generated C code specifies "FMI 1.0", is there a way to make it 2.0 compatible?
Thanks again,
Paul
Re: Missing token: SEMICOLON??
(Current) OMC generates FMI 2.0 by default as far as I remember. Look in your model closer and you see why vi is not assigned. As far as I can see, you have
Code:
// input vi
vo := vi;
inpu := vo;
- sjoelund.se
- 1700 Posts
Re: Missing token: SEMICOLON??
Ok, you were talking about the initial .mo, yes InPutPort.vis aren't assigned.
Compilation passes for when I add "InPutPort1.vi = 0;" for each port but I'm not sure it is recommended to set that value at the beginning?
This adds the same lines to the class output...
Here is the code InPutPort code
model InPutPort
Real vo;
input Real vi;
equation
vi=vo;
end InPutPort;
And the Switch code:
model Switch
parameter Real Ron=0.01 "Resistance when the Switch is closed";
parameter Real Roff=1e5 "Resistance when the Switch is open";
extends TwoPin;
Real inp,Rx;
equation
Rx*i= v;
Rx=if inp >0 then Ron
else Roff;
end Switch;
Thanks,
Paul
Re: Missing token: SEMICOLON??
In order to follow the Modelica specification and define the variable to be an input (that can somehow be controlled externally):
Code:
model M
InPutPort p(vi=r);
input Real r;
end M;
Only inputs in the top-level model are kept. Any other input variables need to be connected. (This is a change from Modelica 2.x, in which some tools allowed these sort of models)
- sjoelund.se
- 1700 Posts
Re: Missing token: SEMICOLON??
I see, thank you for that alternative.
I must have failed to implement it though:
model InPutPort // Unchanged
Real vo;
input Real vi;
equation
vi=vo;
end InPutPort;
partial model TwoPin // Unchanged
Pin p, n;
Real i, v;
equation
i = p.i;
n.i = -i;
v = p.v - n.v;
end TwoPin;
model Switch // Made 'inp' an input and added an InPutPort. Named it 'in' because 'p' was taken by TwoPin
parameter Real Ron=0.01 "Resistance when the Switch is closed";
parameter Real Roff=1e5 "Resistance when the switch is open";
extends TwoPin;
InPutPort in(vi=inp);
Real Rx;
input Real inp;
equation
Rx*i= v;
Rx=if inp >0 then Ron
else Roff;
end Switch;
This gives me "Error: No viable alternative near token: InPutPort", do you see what is wrong there? So I can fix all the other components!
Thank you very much,
Paul
Re: Missing token: SEMICOLON??
Note: the model file hasn't changed after I changed the components, so it may be my script to generate the models that is obsolete.
Do you know what equations are missing in the model in order to pass compilation? If I change generate them, I should be good to go.
Thanks,
Paul
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Missing token: SEMICOLON??