Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BaSys4Forestry - Projektmanagement
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lehrstuhl für Informations- und Automatisierungssysteme
BaSys4Forestry - Projektmanagement
Commits
090cfbf9
Commit
090cfbf9
authored
1 year ago
by
zrgt
Browse files
Options
Downloads
Patches
Plain Diff
Add semantic_ids
parent
d621deba
No related branches found
No related tags found
No related merge requests found
Pipeline
#283264
passed
1 year ago
Stage: build
Changes
2
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
demos/demo2/demo2_dzwald.py
+39
-0
39 additions, 0 deletions
demos/demo2/demo2_dzwald.py
demos/demo2/demo2_dzwald_example.json
+3436
-7
3436 additions, 7 deletions
demos/demo2/demo2_dzwald_example.json
with
3475 additions
and
7 deletions
demos/demo2/demo2_dzwald.py
+
39
−
0
View file @
090cfbf9
import
os
,
sys
,
inspect
import
os
,
sys
,
inspect
import
re
from
typing
import
List
from
typing
import
List
import
basyx
import
basyx
...
@@ -374,6 +375,44 @@ def create_aas():
...
@@ -374,6 +375,44 @@ def create_aas():
waldweg
,
waldweg
,
zu_faellende_baeume
,
zu_faellende_baeume
,
]
]
def
remove_iteration_ending
(
val
:
str
):
# remove iteration ending like {00}
val
=
re
.
sub
(
r
'
\{\d+\}$
'
,
''
,
val
)
# remove one or more digits at the end
val
=
re
.
sub
(
r
'
_?\d+$
'
,
''
,
val
)
return
val
def
set_semantic_id
(
referable
:
model
.
SubmodelElement
):
# example = "https://admin-shell.io/kwh40/forestml40/Waldweg/0/1/Beschreibung"
if
isinstance
(
referable
,
model
.
Submodel
):
base
=
"
https://admin-shell.io/kwh40/forestml40
"
postfix
=
f
"
{
referable
.
id_short
}
/0/1
"
else
:
base
=
referable
.
parent
.
semantic_id
.
key
[
0
].
value
postfix
=
remove_iteration_ending
(
referable
.
id_short
)
referable
.
semantic_id
=
model
.
GlobalReference
(
(
basyx
.
aas
.
model
.
Key
(
model
.
KeyTypes
.
GLOBAL_REFERENCE
,
f
"
{
base
}
/
{
postfix
}
"
),)
)
def
set_semantic_id_for_each_in
(
obj
):
set_semantic_id
(
obj
)
try
:
iter
(
obj
)
except
TypeError
as
e
:
print
(
e
)
return
se_objects
=
list
(
obj
)
for
se
in
se_objects
:
set_semantic_id_for_each_in
(
se
)
for
submodel
in
submodels
:
set_semantic_id_for_each_in
(
submodel
)
aas_dz_wald
=
models
.
DZWald
(
aas_dz_wald
=
models
.
DZWald
(
dzwald_id
=
"
https://www.company.com/dz_wald/1
"
,
dzwald_id
=
"
https://www.company.com/dz_wald/1
"
,
asset
=
basyx
.
aas
.
model
.
AssetInformation
(),
asset
=
basyx
.
aas
.
model
.
AssetInformation
(),
...
...
This diff is collapsed.
Click to expand it.
demos/demo2/demo2_dzwald_example.json
+
3436
−
7
View file @
090cfbf9
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment