Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Lehrstuhl für Informations- und Automatisierungssysteme
PyI40AAS
Commits
0b27e7d2
Verified
Commit
0b27e7d2
authored
Apr 17, 2020
by
Leon Mauritz Möller
Browse files
aas.examples: create formulas
check formulas for equality in data checker close
#66
parent
dffc1fa1
Pipeline
#269577
passed with stage
in 3 minutes and 6 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
aas/examples/data/_helper.py
View file @
0b27e7d2
...
...
@@ -183,13 +183,16 @@ class AASDataChecker(DataChecker):
:param expected_object: The expected qualifiable object
:return: The value of expression to be used in control statements
"""
# TODO add check of formula => not clear how to identify a formula
self
.
check_contained_element_length
(
object_
,
'qualifier'
,
model
.
Constraint
,
len
(
expected_object
.
qualifier
))
for
expected_element
in
expected_object
.
qualifier
:
element
=
self
.
_find_element_by_attribute
(
expected_element
,
object_
.
qualifier
,
'type'
)
if
self
.
check
(
element
is
not
None
,
'Constraint{} must exist'
.
format
(
repr
(
expected_element
))):
self
.
_check_qualifier_equal
(
element
,
expected_element
)
# type: ignore
if
isinstance
(
element
,
model
.
Formula
):
self
.
_check_formula_equal
(
element
,
expected_element
)
# type: ignore
elif
isinstance
(
element
,
model
.
Qualifier
):
self
.
_check_qualifier_equal
(
element
,
expected_element
)
# type: ignore
else
:
raise
TypeError
(
'Constraint class not implemented'
)
found_elements
=
self
.
_find_extra_elements_by_attribute
(
object_
.
qualifier
,
expected_object
.
qualifier
,
'type'
)
self
.
check
(
found_elements
==
set
(),
'Qualifiable Element {} must not have extra elements'
.
format
(
repr
(
object_
)),
value
=
found_elements
)
...
...
@@ -594,6 +597,19 @@ class AASDataChecker(DataChecker):
self
.
check_attribute_equal
(
object_
,
'value'
,
expected_value
.
value
)
self
.
check_attribute_equal
(
object_
,
'value_id'
,
expected_value
.
value_id
)
def
_check_formula_equal
(
self
,
object_
:
model
.
Formula
,
expected_value
:
model
.
Formula
):
"""
Checks if the given Formula objects are equal
:param object_: Given Formula object to check
:param expected_value: expected Formula object
:return:
"""
for
expected_ref
in
expected_value
.
depends_on
:
ref
=
self
.
_find_reference
(
expected_ref
,
object_
.
depends_on
)
if
self
.
check
(
ref
is
not
None
,
'Reference {} must exist'
.
format
(
repr
(
expected_ref
))):
self
.
_check_reference_equal
(
ref
,
expected_ref
)
# type: ignore
def
check_asset_equal
(
self
,
object_
:
model
.
Asset
,
expected_value
:
model
.
Asset
):
"""
Checks if the given Asset objects are equal
...
...
aas/examples/data/example_aas.py
View file @
0b27e7d2
...
...
@@ -161,7 +161,12 @@ def create_example_bill_of_material_submodel() -> model.Submodel:
local
=
False
,
value
=
'http://acplt.org/Properties/ExampleProperty'
,
id_type
=
model
.
KeyType
.
IRI
),)),
qualifier
=
None
,
qualifier
=
{
model
.
Formula
(
depends_on
=
{
model
.
Reference
((
model
.
Key
(
type_
=
model
.
KeyElements
.
GLOBAL_REFERENCE
,
local
=
False
,
value
=
'http://acplt.org/ValueId/ExampleValueId'
,
id_type
=
model
.
KeyType
.
IRI
),))}),
model
.
Formula
()},
kind
=
model
.
ModelingKind
.
INSTANCE
)
submodel_element_property2
=
model
.
Property
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment