Skip to content

Commit 9e49223

Browse files
committed
Make inputSignal a global element to avoid revalidation on embed.
To still test the revalidation if it is not possible to add a local embed element as a global element a new test element is added which still tests this code.
1 parent 4f50e0f commit 9e49223

File tree

8 files changed

+148
-52
lines changed

8 files changed

+148
-52
lines changed

examples/xml/embedtest/local/MBS.mbsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,31 @@
182182
<inputSignal ref="../Link[c6{mnp}1]"/>
183183
</Multiplexer>
184184
</Embed>
185+
<Embed xmlns="http://www.mbsim-env.de/MBXMLUtils" counterName="mn" count="2">
186+
<Parameter xmlns="http://www.mbsim-env.de/MBXMLUtils">
187+
<scalarParameter name="mnp">mn</scalarParameter>
188+
</Parameter>
189+
<TestElement name="TestElement{mnp}" xmlns="http://www.mbsim-env.de/MBSim">
190+
<localElement>1</localElement>
191+
<p:Embed xmlns:p="http://www.mbsim-env.de/MBXMLUtils" count="2" counterName="in">
192+
<Parameter xmlns="http://www.mbsim-env.de/MBXMLUtils">
193+
<scalarParameter name="inp">in</scalarParameter>
194+
</Parameter>
195+
<localElement>1</localElement>
196+
</p:Embed>
197+
<p:Embed xmlns:p="http://www.mbsim-env.de/MBXMLUtils" count="2" counterName="in" href="localElement.mbsmx">
198+
<Parameter xmlns="http://www.mbsim-env.de/MBXMLUtils">
199+
<scalarParameter name="inp">in</scalarParameter>
200+
<scalarParameter name="c">3</scalarParameter>
201+
</Parameter>
202+
</p:Embed>
203+
<p:Embed xmlns:p="http://www.mbsim-env.de/MBXMLUtils" count="2" counterName="in" parameterHref="localElement.mbspx">
204+
<localElement>1</localElement>
205+
</p:Embed>
206+
<p:Embed xmlns:p="http://www.mbsim-env.de/MBXMLUtils" count="2" counterName="in" href="localElement.mbsmx" parameterHref="localElement.mbspx"/>
207+
<localElement>1</localElement>
208+
</TestElement>
209+
</Embed>
185210
</links>
186211
<constraints/>
187212
<observers/>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2+
<localElement xmlns="http://www.mbsim-env.de/MBSim">
3+
1
4+
</localElement>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2+
<Parameter xmlns="http://www.mbsim-env.de/MBXMLUtils">
3+
<scalarParameter name="inp">in</scalarParameter>
4+
<scalarParameter name="c">5</scalarParameter>
5+
</Parameter>

kernel/mbsim/links/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ SUBDIRS = .
22

33
noinst_LTLIBRARIES = liblink.la
44
liblink_la_SOURCES = link.cc\
5+
test_element.cc\
56
mechanical_link.cc\
67
frame_link.cc\
78
fixed_frame_link.cc\
@@ -40,6 +41,7 @@ liblink_la_LIBADD = $(DEPS_LIBS) $(OPENMBVCPPINTERFACE_LIBS)
4041

4142
linkincludedir = $(includedir)/mbsim/links
4243
linkinclude_HEADERS = link.h\
44+
test_element.h\
4345
mechanical_link.h\
4446
generalized_friction.h\
4547
generalized_clutch.h\

kernel/mbsim/links/test_element.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright (C) 2004-2014 MBSim Development Team
2+
*
3+
* This library is free software; you can redistribute it and/or
4+
* modify it under the terms of the GNU Lesser General Public
5+
* License as published by the Free Software Foundation; either
6+
* version 2.1 of the License, or (at your option) any later version.
7+
*
8+
* This library is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* Lesser General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU Lesser General Public
14+
* License along with this library; if not, write to the Free Software
15+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16+
*
17+
* Contact: martin.o.foerg@googlemail.com
18+
*/
19+
20+
#include <config.h>
21+
#include "test_element.h"
22+
23+
namespace MBSim {
24+
25+
MBSIM_OBJECTFACTORY_REGISTERCLASS(MBSIM, TestElement)
26+
27+
TestElement::TestElement(const std::string &name) : Link(name) {
28+
}
29+
30+
}

kernel/mbsim/links/test_element.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* Copyright (C) 2004-2014 MBSim Development Team
2+
*
3+
* This library is free software; you can redistribute it and/or
4+
* modify it under the terms of the GNU Lesser General Public
5+
* License as published by the Free Software Foundation; either
6+
* version 2.1 of the License, or (at your option) any later version.
7+
*
8+
* This library is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* Lesser General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU Lesser General Public
14+
* License along with this library; if not, write to the Free Software
15+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16+
*
17+
* Contact: martin.o.foerg@googlemail.com
18+
*/
19+
20+
#ifndef _MBSIM_TESTELEMENT_H_
21+
#define _MBSIM_TESTELEMENT_H_
22+
23+
#include <mbsim/links/link.h>
24+
25+
namespace MBSim {
26+
27+
class TestElement : public Link {
28+
public:
29+
TestElement(const std::string &name = "");
30+
void updateWRef(fmatvec::Mat&, int) override {}
31+
void updateVRef(fmatvec::Mat&, int) override {}
32+
void updatehRef(fmatvec::Vec&, int) override {}
33+
void updaterRef(fmatvec::Vec&, int) override {}
34+
bool isActive() const override { return false; }
35+
bool gActiveChanged() override { return false; }
36+
};
37+
38+
}
39+
40+
#endif

kernel/schema/mbsim.xsd

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
<!-- We define plotFeature* and plotAttribute* as global elements for improved preprocessing:
321321
If a element which can be used inside a Embed element is a local element than the preprocessor must do a revalidation which is quite expensive.
322322
This can be avoided if we define such elements globally and reference it beside the Embed element.
323-
This way the XML validator can already validate the such element during the initial validation where still Embed elements exists in the model. -->
323+
This way the XML validator can already validate such elements during the initial validation where still Embed elements exists in the model. -->
324324
<xs:element name="plotFeature">
325325
<xs:annotation><xs:documentation xml:lang="de" xmlns="">
326326
Definiert die Plotfeatures für dieses Element.
@@ -8456,4 +8456,22 @@
84568456
</xs:complexContent>
84578457
</xs:complexType>
84588458

8459+
<xs:element name="TestElement" substitutionGroup="Link" type="TestElementType">
8460+
<xs:annotation>
8461+
<xs:documentation xml:lang="de" xmlns="">
8462+
Test Element ohne sinnvolle funktionalität.
8463+
</xs:documentation>
8464+
</xs:annotation>
8465+
</xs:element>
8466+
<xs:complexType name="TestElementType">
8467+
<xs:complexContent>
8468+
<xs:extension base="LinkType">
8469+
<xs:choice minOccurs="1" maxOccurs="unbounded">
8470+
<xs:element name="localElement" type="pv:unknownScalar"/>
8471+
<xs:element ref="pv:Embed"/>
8472+
</xs:choice>
8473+
</xs:extension>
8474+
</xs:complexContent>
8475+
</xs:complexType>
8476+
84598477
</xs:schema>

modules/mbsimControl/schema/mbsimcontrol.xsd

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@
3434

3535
<xs:import namespace="http://www.mbsim-env.de/MBSim"/>
3636

37+
<!-- We define inputSignal as global elements for improved preprocessing:
38+
If a element which can be used inside a Embed element is a local element than the preprocessor must do a revalidation which is quite expensive.
39+
This can be avoided if we define such elements globally and reference it beside the Embed element.
40+
This way the XML validator can already validate such elements during the initial validation where still Embed elements exists in the model. -->
41+
<xs:element name="inputSignal">
42+
<xs:annotation>
43+
<xs:documentation xml:lang="de" xmlns="">
44+
Pfad des Eingangssignals (als "ref" attribute)
45+
</xs:documentation>
46+
</xs:annotation>
47+
<xs:complexType>
48+
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
49+
</xs:complexType>
50+
</xs:element>
51+
3752
<xs:simpleType name="SignalReferenceType">
3853
<xs:restriction base="pv:stringPartialEval"/>
3954
</xs:simpleType>
@@ -89,16 +104,7 @@
89104
<xs:complexContent>
90105
<xs:extension base="SignalType">
91106
<xs:sequence>
92-
<xs:element name="inputSignal">
93-
<xs:annotation>
94-
<xs:documentation xml:lang="de" xmlns="">
95-
ref=Pfad des Eingangssignals
96-
</xs:documentation>
97-
</xs:annotation>
98-
<xs:complexType>
99-
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
100-
</xs:complexType>
101-
</xs:element>
107+
<xs:element ref="inputSignal"/>
102108
</xs:sequence>
103109
</xs:extension>
104110
</xs:complexContent>
@@ -791,14 +797,7 @@
791797
<xs:complexContent>
792798
<xs:extension base="SignalType">
793799
<xs:choice minOccurs="1" maxOccurs="unbounded">
794-
<xs:element name="inputSignal">
795-
<xs:annotation><xs:documentation xml:lang="de" xmlns="">
796-
Eingangssignal
797-
</xs:documentation></xs:annotation>
798-
<xs:complexType>
799-
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
800-
</xs:complexType>
801-
</xs:element>
800+
<xs:element ref="inputSignal"/>
802801
<xs:element ref="pv:Embed"/>
803802
</xs:choice>
804803
</xs:extension>
@@ -816,11 +815,7 @@
816815
<xs:complexContent>
817816
<xs:extension base="SignalType">
818817
<xs:sequence>
819-
<xs:element name="inputSignal">
820-
<xs:complexType>
821-
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
822-
</xs:complexType>
823-
</xs:element>
818+
<xs:element ref="inputSignal"/>
824819
<xs:element name="indices" type="pv:indexVector">
825820
<xs:annotation>
826821
<xs:documentation xml:lang="de" xmlns="">
@@ -845,14 +840,7 @@
845840
<xs:extension base="SignalType">
846841
<xs:sequence>
847842
<xs:choice minOccurs="1" maxOccurs="unbounded">
848-
<xs:element name="inputSignal">
849-
<xs:annotation><xs:documentation xml:lang="de" xmlns="">
850-
Eingangssignal
851-
</xs:documentation></xs:annotation>
852-
<xs:complexType>
853-
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
854-
</xs:complexType>
855-
</xs:element>
843+
<xs:element ref="inputSignal"/>
856844
<xs:element ref="pv:Embed"/>
857845
</xs:choice>
858846
<xs:element name="multiplexInputSignals" type="pv:booleanFullEval" minOccurs="0"/>
@@ -905,11 +893,7 @@
905893
</xs:documentation>
906894
</xs:annotation>
907895
</xs:element>
908-
<xs:element name="inputSignal">
909-
<xs:complexType>
910-
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
911-
</xs:complexType>
912-
</xs:element>
896+
<xs:element ref="inputSignal"/>
913897
<xs:element name="systemMatrix" type="pv:nounitMatrix"/>
914898
<xs:element name="inputMatrix" type="pv:nounitMatrix"/>
915899
<xs:element name="outputMatrix" type="pv:nounitMatrix" minOccurs="0"/>
@@ -931,11 +915,7 @@
931915
</xs:documentation>
932916
</xs:annotation>
933917
</xs:element>
934-
<xs:element name="inputSignal">
935-
<xs:complexType>
936-
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
937-
</xs:complexType>
938-
</xs:element>
918+
<xs:element ref="inputSignal"/>
939919
<xs:element name="systemFunction">
940920
<xs:annotation><xs:documentation xml:lang="de" xmlns="">
941921
Systemfunktion
@@ -1279,11 +1259,7 @@
12791259
<xs:complexContent>
12801260
<xs:extension base="SignalType">
12811261
<xs:sequence>
1282-
<xs:element name="inputSignal">
1283-
<xs:complexType>
1284-
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
1285-
</xs:complexType>
1286-
</xs:element>
1262+
<xs:element ref="inputSignal"/>
12871263
<xs:element name="threshold" type="pv:unknownVector" minOccurs="0"/>
12881264
</xs:sequence>
12891265
</xs:extension>
@@ -1295,11 +1271,7 @@
12951271
<xs:complexContent>
12961272
<xs:extension base="SignalType">
12971273
<xs:sequence>
1298-
<xs:element name="inputSignal">
1299-
<xs:complexType>
1300-
<xs:attribute name="ref" type="SignalReferenceType" use="required"/>
1301-
</xs:complexType>
1302-
</xs:element>
1274+
<xs:element ref="inputSignal"/>
13031275
<xs:element name="threshold" type="pv:unknownScalar" minOccurs="0"/>
13041276
</xs:sequence>
13051277
</xs:extension>

0 commit comments

Comments
 (0)