Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KWH40
fml40-reference-implementation
Commits
168e818a
Commit
168e818a
authored
Aug 04, 2021
by
C. Albrecht
Browse files
feature: Add a prototype for routines
parent
22e29441
Changes
2
Show whitespace changes
Inline
Side-by-side
ml/thing.py
View file @
168e818a
...
...
@@ -13,6 +13,7 @@
from
s3i.messages
import
ServiceReply
,
GetValueReply
,
SetValueReply
from
ml.tools
import
find_broker_endpoint
from
ml.app_logger
import
APP_LOGGER
from
routines
import
Send_Message
class
BaseVariable
:
...
...
@@ -112,6 +113,27 @@ def model(self):
return
self
.
__model
@
property
def
stanford2010
(
self
):
return
self
.
__stanford2010
@
stanford2010
.
setter
def
stanford2010
(
self
,
value
):
self
.
__stanford2010
=
value
@
property
def
db
(
self
):
return
self
.
__db
def
add_startup_code
():
pass
def
add_routine
(
func
,
frequence
):
pass
def
add_shutodwn_code
():
pass
@
property
def
ditto_features
(
self
):
return
self
.
__ditto_features
...
...
@@ -238,8 +260,18 @@ def run_forever(self):
if
self
.
__is_repo
:
threading
.
Thread
(
target
=
self
.
__repo_syn
).
start
()
@
staticmethod
def
add_user_def
(
func
):
for
func
in
self
.
user_func_list
:
threading
.
Thread
(
target
=
func
).
start
()
# TODO: Compare id
if
thing_id
==
"s3i:..."
:
# TODO: Construct Send_Message object
endpoints
=
[
""
]
send_message
=
Send_Message
(
self
,
endpoints
)
send_message
.
work
()
def
add_user_def
(
self
,
func
):
"""Insert user-specified function in the thing object.
:param func: external defined function to be executed.
...
...
routines/send_msg.py
0 → 100644
View file @
168e818a
from
ml.tools
import
make_sub_thing
from
ml.thing
import
Thing
from
s3i.message
import
UserMessage
class
Send_Message
:
def
__init__
(
self
,
thing
,
endpoints
,
message
=
""
)
->
None
:
super
().
__init__
()
self
.
thing
=
thing
self
.
endpoints
=
endpoints
def
work
():
# TODO: Fill message
# TODO: Send message to proper endpoint
msg
=
UserMessage
()
msg
.
fill
()
endpoints
=
[
"s3ib://s3i..."
]
thing
.
__send_message_to_broker
(
endpoints
,
msg
)
\ No newline at end of file
Write
Preview
Markdown
is supported
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