Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KWH40
fml40-reference-implementation
Commits
dc576c61
Commit
dc576c61
authored
Apr 01, 2021
by
Jiahang Chen
Browse files
ADD list search by id and name
parent
d435b0b0
Pipeline
#439379
passed with stages
in 51 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ml/thing.py
View file @
dc576c61
...
...
@@ -32,15 +32,15 @@ class Thing:
operating Digital Twins complying the Forest Modeling Language (fml40)."""
def
__init__
(
self
,
model
:
dict
,
client_secret
=
""
,
grant_type
=
"password"
,
is_broker
=
False
,
is_repo
=
False
,
is_broker_rest
=
True
,
username
=
None
,
password
=
None
,
self
,
model
:
dict
,
client_secret
=
""
,
grant_type
=
"password"
,
is_broker
=
False
,
is_repo
=
False
,
is_broker_rest
=
True
,
username
=
None
,
password
=
None
,
):
"""
Constructor
...
...
@@ -120,7 +120,6 @@ def ditto_features(self):
def
ditto_features
(
self
,
value
):
self
.
__ditto_features
=
value
@
property
def
features
(
self
):
"""Returns thing's features.
...
...
@@ -303,7 +302,7 @@ def __connect_with_idp(self):
"""
#TODO: Use logger!
#
TODO: Use logger!
print
(
BColors
.
OKBLUE
+
"[S³I][IdP]"
...
...
@@ -394,6 +393,7 @@ def __connect_with_broker(self):
)
if
self
.
__is_broker_rest
:
self
.
broker
=
BrokerREST
(
token
=
self
.
access_token
)
def
receive
():
self
.
__endpoint
=
find_broker_endpoint
(
self
.
dir
,
thing_id
=
self
.
thing_id
)
while
True
:
...
...
@@ -610,7 +610,8 @@ def _getValue(self, source, uri_list):
# ??? What if the uri points to a Value object?
# Shouldn't it be serialized?!
print
(
source
)
print
(
uri_list
)
value
=
source
[
uri_list
[
0
]]
if
uri_list
.
__len__
()
==
1
:
# if is ditto-feature
...
...
@@ -640,6 +641,12 @@ def _getValue(self, source, uri_list):
uri_list_1
=
copy
.
deepcopy
(
uri_list
)
del
uri_list_1
[:
2
]
self
.
_getValue
(
item
,
uri_list_1
)
_f
=
self
.
_findValue
({
"identifier"
:
item
.
get
(
"identifier"
)},
uri_list
[
1
])
or
\
self
.
_findValue
({
"name"
:
item
.
get
(
"name"
)},
uri_list
[
1
])
if
_f
:
uri_list_1
=
copy
.
deepcopy
(
uri_list
)
del
uri_list_1
[:
2
]
self
.
_getValue
(
item
,
uri_list_1
)
else
:
if
self
.
_findValue
(
item
,
uri_list
[
1
]):
uri_list_1
=
copy
.
deepcopy
(
uri_list
)
...
...
@@ -790,10 +797,10 @@ def on_service_request(self, body_json):
+
": Send a S³I-B ServiceReply back to the requester "
)
else
:
print
(
BColors
.
OKBLUE
+
"[S³I][Broker]"
+
BColors
.
ENDC
+
res
.
text
)
print
(
BColors
.
OKBLUE
+
"[S³I][Broker]"
+
BColors
.
ENDC
+
res
.
text
)
def
on_get_value_reply
(
self
,
msg
):
"""Handles incoming S³I-B GetValueReply. Prints the content of msg to stdout.
...
...
@@ -961,6 +968,8 @@ def to_subthing_json(self):
}
if
self
.
thing_id
:
json_out
[
"identifier"
]
=
self
.
thing_id
else
:
json_out
[
"identifier"
]
=
self
.
model
[
"attributes"
][
"identifier"
]
for
key
in
self
.
roles
.
keys
():
json_out
[
"roles"
].
append
(
self
.
roles
[
key
].
to_json
())
for
key
in
self
.
features
.
keys
():
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment