Skip to content

Commit

Permalink
Fixed deleteConnection and updateConnection.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@939 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Mar 18, 2003
1 parent 0f1f990 commit e6f0140
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 10 deletions.
79 changes: 75 additions & 4 deletions modeq/interactive.rml
Expand Up @@ -410,16 +410,36 @@ relation evaluate_graphical_api: (InteractiveStmts, InteractiveSymbolTable) =>
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => (resstr,st)

rule add_connection(cr,c1,c2,p) => (s1,newp) &
rule add_connection(cr,c1,c2,annlst,p) => (s1,newp) &
string_append(s1,"\n") => resstr
-----------------------
evaluate_graphical_api(
ISTMTS([IEXP(Absyn.CALL(
Absyn.CREF_IDENT("addConnection",_),
Absyn.FUNCTIONARGS([Absyn.CREF(c1),Absyn.CREF(c2),Absyn.CREF(cr)],annlst)))],_
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => (resstr,SYMBOLTABLE(newp,s,ic,iv,cf))

rule delete_connection(cr,c1,c2,p) => (s1,newp) &
string_append(s1,"\n") => resstr
-----------------------
evaluate_graphical_api(
ISTMTS([IEXP(Absyn.CALL(
Absyn.CREF_IDENT("deleteConnection",_),
Absyn.FUNCTIONARGS([Absyn.CREF(c1),Absyn.CREF(c2),Absyn.CREF(cr)],_)))],_
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => (resstr,SYMBOLTABLE(newp,s,ic,iv,cf))

rule delete_connection(cr,c1,c2,p) => (s1,newp) &
add_connection(cr,c1,c2,annlst,newp) => (s2,newp') &
string_append(s2,"\n") => resstr
-----------------------
evaluate_graphical_api(
ISTMTS([IEXP(Absyn.CALL(
Absyn.CREF_IDENT("updateConnection",_),
Absyn.FUNCTIONARGS([Absyn.CREF(c1),Absyn.CREF(c2),Absyn.CREF(cr)],annlst)))],_
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => (resstr,SYMBOLTABLE(newp',s,ic,iv,cf))

rule get_nth_connection_annotation(cr,p,n) => s1 &
string_append(s1,"\n") => resstr
Expand Down Expand Up @@ -1381,17 +1401,68 @@ relation get_nth_connection: (Absyn.ComponentRef, Absyn.Program, int) => string
axiom get_nth_connection(_,_,_) => "-1"
end

relation add_connection: (Absyn.ComponentRef, Absyn.ComponentRef, Absyn.ComponentRef,Absyn.Program) =>
(string,Absyn.Program) =
relation add_connection: (Absyn.ComponentRef, Absyn.ComponentRef, Absyn.ComponentRef,
Absyn.NamedArg list, Absyn.Program) =>
(string, Absyn.Program) =

rule Absyn.cref_to_path(model) => modelpath &
get_pathed_class_in_program(modelpath,p) => cdef &
add_to_equation(cdef,Absyn.EQUATIONITEM(Absyn.EQ_CONNECT(c1,c2),NONE))
=> newcdef &
update_program(Absyn.PROGRAM([newcdef],w),p)=> newp
---------------------------------------------------
add_connection(model,c1,c2,p as Absyn.PROGRAM(_,w)) => ("Ok",newp)
add_connection(model,c1,c2,[],p as Absyn.PROGRAM(_,w)) => ("Ok",newp)

rule Absyn.cref_to_path(model) => modelpath &
get_pathed_class_in_program(modelpath,p) => cdef &
annotation_list_to_absyn(annlst) => annotation &
add_to_equation(cdef,Absyn.EQUATIONITEM(Absyn.EQ_CONNECT(c1,c2),SOME(Absyn.COMMENT(SOME(annotation),NONE))))
=> newcdef &
update_program(Absyn.PROGRAM([newcdef],w),p)=> newp
---------------------------------------------------
add_connection(model,c1,c2,annlst,p as Absyn.PROGRAM(_,w)) => ("Ok",newp)
end

relation delete_connection: (Absyn.ComponentRef, Absyn.ComponentRef, Absyn.ComponentRef, Absyn.Program)
=> (string,Absyn.Program) =

rule Absyn.cref_to_path(model) => modelpath &
get_pathed_class_in_program(modelpath,p) => cdef &
delete_equation_in_class(cdef,c1,c2) => newcdef &
update_program(Absyn.PROGRAM([newcdef],w),p)=> newp
---------------------------------------------------
delete_connection(model,c1,c2,p as Absyn.PROGRAM(_,w)) => ("Ok",newp)

axiom delete_connection(model,c1,c2,p as Absyn.PROGRAM(_,w)) => ("-1",p)
end

relation delete_equation_in_class: (Absyn.Class, Absyn.ComponentRef, Absyn.ComponentRef)
=> Absyn.Class =

rule get_equation_list(parts) => eqlst &
delete_equation_in_eqlist(eqlst,c1,c2) => eqlst' &
replace_equation_list(parts,eqlst') => parts2
----------------------------
delete_equation_in_class(Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(parts,cmt)),c1,c2)
=> Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(parts2,cmt))
end

relation delete_equation_in_eqlist: (Absyn.EquationItem list, Absyn.ComponentRef,Absyn.ComponentRef) => Absyn.EquationItem list =

axiom delete_equation_in_eqlist([],_,_) => []

rule Absyn.cref_to_path(c1) => p1 & Absyn.path_string(p1) => s1 &
Absyn.cref_to_path(c2) => p2 & Absyn.path_string(p2) => s2 &
Absyn.cref_to_path(cn1) => pn1 & Absyn.path_string(pn1) => sn1 &
Absyn.cref_to_path(cn2) => pn2 & Absyn.path_string(pn2) => sn2 &
s1 = sn1 & s2 = sn2 &
delete_equation_in_eqlist(xs,c1,c2) => res
---------------------
delete_equation_in_eqlist(Absyn.EQUATIONITEM(Absyn.EQ_CONNECT(cn1,cn2),_)::xs,c1,c2) => res

rule delete_equation_in_eqlist(xs,c1,c2) => res
------------------------------------
delete_equation_in_eqlist(x::xs,c1,c2) => x::res
end

(** relation: get_nth_connection_annotation
Expand Down
8 changes: 2 additions & 6 deletions modeq/interactive_api.txt
Expand Up @@ -87,11 +87,6 @@ getConnectionCount(<cref>) Returns the number of
getNthConnection(<cref>,<int>) Returns the nth connection,
as a comma separated pair of
connectors, e.g. "R1.n,R2.p".
deleteConnection(<cref>,<cref>,<cref>) Deletes the connection between the two
connectors given as arguments A1,A2. A0 is
the model name.
deleteNthConnection(<cref>,<int>) Deletes the nth connection in class given
by A0.
getNthConnectionAnnotation(<cref>,<int>)
Returns the nth connection
annotation as comma separated
Expand All @@ -102,10 +97,11 @@ addConnection(<cref>,<cref>,<cref>, annotate=<expr>)
to model A2, with annotation
given by the named argument
annotate.

updateConnection(<cref>,<cref>,<cref>, annotate=<expr>)
Updates an allready existing
connection
deleteConnection(<cref>,<cref>,<cref>) Deletes the connection connect(A0,A1) in class
given by A2.

addEquation(<cref>,<expr>,<expr>) Adds the equation A1=A2 to the
model named by A0.
Expand Down

0 comments on commit e6f0140

Please sign in to comment.