From 598adbc50b0a26cdd9245979f0b4ce8648818129 Mon Sep 17 00:00:00 2001 From: miettinen Date: Tue, 24 Jun 2014 07:05:46 +0000 Subject: [PATCH] Sysdyn unit validation: correct handling for relations and boolean operators (not, and, or) (refs #4987). Added a sample model and a function library. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29707 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sampleModels/LogisticFunc.sysdyn | Bin 0 -> 31655 bytes .../LogisticFunctions.sysdynFunctions | Bin 0 -> 12344 bytes .../unitParser/UnitCheckingNodeFactory.java | 9 +++- .../unitParser/nodes/LogicalExpression.java | 49 ++++++++++++++++++ .../unitParser/nodes/LogicalFactor.java | 49 ++++++++++++++++++ .../sysdyn/unitParser/nodes/LogicalTerm.java | 49 ++++++++++++++++++ .../sysdyn/unitParser/nodes/Relation.java | 14 +++-- 7 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 org.simantics.sysdyn.feature/rootfiles/sampleModels/LogisticFunc.sysdyn create mode 100644 org.simantics.sysdyn.feature/rootfiles/sampleModels/LogisticFunctions.sysdynFunctions create mode 100644 org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalExpression.java create mode 100644 org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalFactor.java create mode 100644 org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalTerm.java diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/LogisticFunc.sysdyn b/org.simantics.sysdyn.feature/rootfiles/sampleModels/LogisticFunc.sysdyn new file mode 100644 index 0000000000000000000000000000000000000000..683e59d0383af02dffe7209cf38731865b961a8e GIT binary patch literal 31655 zcmeI52XtK3wfE}bM~2YkNq$PzHfc&y=bj#-QR9! zpMLHY%+!o2_7vNDa*0GD!quxfT`sN67pifes6MiIWO-%2sy$uGh+x;2a;Dgx?irOj zu$;@J#_u^QHGW*b>&lKAV+3r#{pA)}C4a3==-u()h zV!m8x%goG|bEP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AMR7ntN;K2 literal 0 HcmV?d00001 diff --git a/org.simantics.sysdyn.feature/rootfiles/sampleModels/LogisticFunctions.sysdynFunctions b/org.simantics.sysdyn.feature/rootfiles/sampleModels/LogisticFunctions.sysdynFunctions new file mode 100644 index 0000000000000000000000000000000000000000..8475b3f71d0f8d677067a9ccdc4724696d6662c2 GIT binary patch literal 12344 zcmeI2je8W;6~+T5o3I!K1;h_zL|d~$5`v-?3<3da6ak6i7YNJlB&;Sg>&|SFRh03o z*!o>RTD9t^(Ep%+U;Dmi?n%y0A`xi&^s(;qoXq{*d(M0A+_@jaGpvnTQMDBuXa<$I z76u1vryJ!)tD~c18LXq5f84LDx8X-&vr+L!!e$UJXLZq^jr|}(V6=i<;Gb*xr&z1{ zL0pS#e$+#@O3QmxDHEys;VX%^}?$_CQGz{amxXz$FnCF9w`u zU2{WL_tUB~S?IxX%WrIDKM*y`x|z;{xCs01`P@ar@G`uQU7>gSi z9`IRmbKT-;(exVI&vuOl^(Mt%7c3lZ#u=X@&vqWdR7D{X>N(Qzr)y!8WBmqenmxzL zjavEiBs=gXYu=D4hQeEfdGkc_aTvaa=bV9chGhzY(|g%`FcR`jfP;h0sC=NWI7A zxc6AipQ(qnAjSjOhMMYe&n$1c&m^tog)feaecnYo>B@as-Tq z&)E8@asOQ0yF+=Hd|F?y;&bEi7go%y9Bay0)qUy6U!@WY{EXkI#fgnB}^0ifn9 z)_iG{zLucwJyC>FXUyMN@wM^zMm!2f%8gjkd@EcW!S;uV9ZB7Hna?5YRKlrnH^zij z5d5AMXA3n>S7!Nv{JqKYqeK)(1MEmaB~!T|LB;u<5-}H9cVRxTPzN7?{m3l_*J;P+ zaeWuI-|@G&egm7zF;L>Qy~YasRPStt9iQU*8La3y#q~QF`@`S&upeO85%AOey32iz zx-VdzF!sUflU4sk*Ph}^{Yl5FztyqozvNi;e+%Y4SbehUb8{i5FzR#Rl2!kxW7R+7 zSoI$P^Bz=x*73)0{%`35-5mUu2EH z-Lb|~n?5$4oWSV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ww<%Z053G%DzNM7Uh1H8TU&|^ zLd*E3zfp<<`9Zw&D=p%@Ho-fD3fb!gS~q2?`GHwdHEdJ8GgHluV5r_L{4?fUUz+2-wo7r_Qd{`KGZ3-&w~0O=)Fn!2d{FS}AM}p4Bs+!VK@Usu z@*niBHo=F5<{$K)O!cxK^xihrkxX^&L5~V=Uuu*W-QzHpkG6?FCNwwDV}i%?6Ml&` zo6YQ>`7aH0;mNixJSF5dji&{!deeBOEyJ@}hHTS#Uf}BI(($$wCxm1!os{C`&!tms af@Pukxm3wiFMBRk+f=jvZ(qpf(!T&k7*Fm1 literal 0 HcmV?d00001 diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitCheckingNodeFactory.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitCheckingNodeFactory.java index 35f22dfb..b24af37a 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitCheckingNodeFactory.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/UnitCheckingNodeFactory.java @@ -8,6 +8,7 @@ * * Contributors: * Semantum Oy - initial API and implementation + * VTT Technical Research Centre of Finland *******************************************************************************/ package org.simantics.sysdyn.unitParser; @@ -28,6 +29,9 @@ import org.simantics.sysdyn.unitParser.nodes.ForIndex; import org.simantics.sysdyn.unitParser.nodes.FunctionArguments; import org.simantics.sysdyn.unitParser.nodes.FunctionCall; import org.simantics.sysdyn.unitParser.nodes.IfThenElse; +import org.simantics.sysdyn.unitParser.nodes.LogicalExpression; +import org.simantics.sysdyn.unitParser.nodes.LogicalFactor; +import org.simantics.sysdyn.unitParser.nodes.LogicalTerm; import org.simantics.sysdyn.unitParser.nodes.Multiplication; import org.simantics.sysdyn.unitParser.nodes.NamedArguments; import org.simantics.sysdyn.unitParser.nodes.ParenthesisExpression; @@ -42,8 +46,11 @@ public class UnitCheckingNodeFactory { private static HashMap> constructors = new HashMap>(); static { + constructors.put("logical_expression", LogicalExpression.class); + constructors.put("logical_term", LogicalTerm.class); + constructors.put("logical_factor", LogicalFactor.class); constructors.put("relation", Relation.class); - constructors.put("term", Term.class); + constructors.put("term", Term.class); constructors.put("factor", Factor.class); constructors.put("arithmetic_expression", Arithmetic.class); constructors.put("ifthenelse", IfThenElse.class); diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalExpression.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalExpression.java new file mode 100644 index 00000000..d154ec9d --- /dev/null +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalExpression.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2014 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland + *******************************************************************************/ +package org.simantics.sysdyn.unitParser.nodes; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.simantics.sysdyn.unitParser.UnitCheckingException; +import org.simantics.sysdyn.unitParser.UnitCheckingNode; +import org.simantics.sysdyn.unitParser.nodes.UnitResult.UnitType; +import org.simantics.sysdyn.utils.Function; + +/** + * See UnitCheckingNodeFactory for mapping + * @author Tuomas Miettinen + * + */ +public class LogicalExpression extends UnitCheckingNode { + + public LogicalExpression(int id) { + super(id); + } + + @Override + public UnitResult getUnits(HashMap units, ArrayList functions, boolean allowEquivalents) throws UnitCheckingException { + UnitResult result; + + if (jjtGetNumChildren() == 1) { + result = ((UnitCheckingNode)jjtGetChild(0)).getUnits(units, functions, allowEquivalents); + } else { + // If the logical expression is of type logical_term or logical_term, allow + // all units as input and output unit is scalar + result = new UnitResult(allowEquivalents); + result.setUnitType(UnitType.SCALAR); + } + + return result; + } + +} diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalFactor.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalFactor.java new file mode 100644 index 00000000..ca304bbd --- /dev/null +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalFactor.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2014 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland + *******************************************************************************/ +package org.simantics.sysdyn.unitParser.nodes; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.simantics.sysdyn.unitParser.UnitCheckingException; +import org.simantics.sysdyn.unitParser.UnitCheckingNode; +import org.simantics.sysdyn.unitParser.nodes.UnitResult.UnitType; +import org.simantics.sysdyn.utils.Function; + +/** + * See UnitCheckingNodeFactory for mapping + * @author Tuomas Miettinen + * + */ +public class LogicalFactor extends UnitCheckingNode { + + public LogicalFactor(int id) { + super(id); + } + + @Override + public UnitResult getUnits(HashMap units, ArrayList functions, boolean allowEquivalents) throws UnitCheckingException { + UnitResult result; + + if (jjtGetNumChildren() == 1) { + result = ((UnitCheckingNode)jjtGetChild(0)).getUnits(units, functions, allowEquivalents); + } else { + // If the logical factor is of type not relation, allow + // all units as input and output unit is scalar + result = new UnitResult(allowEquivalents); + result.setUnitType(UnitType.SCALAR); + } + + return result; + } + +} diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalTerm.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalTerm.java new file mode 100644 index 00000000..288a9142 --- /dev/null +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/LogicalTerm.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2014 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland + *******************************************************************************/ +package org.simantics.sysdyn.unitParser.nodes; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.simantics.sysdyn.unitParser.UnitCheckingException; +import org.simantics.sysdyn.unitParser.UnitCheckingNode; +import org.simantics.sysdyn.unitParser.nodes.UnitResult.UnitType; +import org.simantics.sysdyn.utils.Function; + +/** + * See UnitCheckingNodeFactory for mapping + * @author Tuomas Miettinen + * + */ +public class LogicalTerm extends UnitCheckingNode { + + public LogicalTerm(int id) { + super(id); + } + + @Override + public UnitResult getUnits(HashMap units, ArrayList functions, boolean allowEquivalents) throws UnitCheckingException { + UnitResult result; + + if (jjtGetNumChildren() == 1) { + result = ((UnitCheckingNode)jjtGetChild(0)).getUnits(units, functions, allowEquivalents); + } else { + // If the logical term is of type logical_factor and logical_factor, allow + // all units as input and output unit is scalar + result = new UnitResult(allowEquivalents); + result.setUnitType(UnitType.SCALAR); + } + + return result; + } + +} diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/Relation.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/Relation.java index 5831092b..878b53e1 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/Relation.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/Relation.java @@ -17,6 +17,7 @@ import java.util.HashMap; import org.simantics.sysdyn.unitParser.UnitCheckingException; import org.simantics.sysdyn.unitParser.UnitCheckingNode; +import org.simantics.sysdyn.unitParser.nodes.UnitResult.UnitType; import org.simantics.sysdyn.utils.Function; /** @@ -40,8 +41,9 @@ public class Relation extends UnitCheckingNode { UnitCheckingNode candidateNode = null; base = ((UnitCheckingNode)jjtGetChild(0)); - if(!(base instanceof Arithmetic) && jjtGetNumChildren() > 1) + if(!(base instanceof Arithmetic) && jjtGetNumChildren() > 1) { base = ((UnitCheckingNode)jjtGetChild(1)); + } if(base instanceof Arithmetic) { result.appendResult(base.getUnits(units, functions, allowEquivalents)); @@ -53,15 +55,21 @@ public class Relation extends UnitCheckingNode { operator = ((UnitCheckingNode)jjtGetChild(i-1)); UnitResult candidateUnits = candidateNode.getUnits(units, functions, allowEquivalents); if(!result.equals(candidateUnits)) { - result.equals(candidateUnits); throw new UnitCheckingException("Not equals exception: " + base.printNode() + " [" + result.getFullUnit() + "] " + operator.printNode() + " " + candidateNode.printNode() + " [" + candidateUnits.getFullUnit() + "]" ); } } - } + + if (jjtGetNumChildren() > 1) { + // If there is an actual relation (e.g. a > b), the output + // unit is a scalar. + result = new UnitResult(allowEquivalents); + result.setUnitType(UnitType.SCALAR); + } + } return result; -- 2.47.1