Commit 168e818a authored by C. Albrecht's avatar C. Albrecht
Browse files

feature: Add a prototype for routines

parent 22e29441
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
from s3i.messages import ServiceReply, GetValueReply, SetValueReply from s3i.messages import ServiceReply, GetValueReply, SetValueReply
from ml.tools import find_broker_endpoint from ml.tools import find_broker_endpoint
from ml.app_logger import APP_LOGGER from ml.app_logger import APP_LOGGER
from routines import Send_Message
class BaseVariable: class BaseVariable:
...@@ -112,6 +113,27 @@ def model(self): ...@@ -112,6 +113,27 @@ def model(self):
return self.__model 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 @property
def ditto_features(self): def ditto_features(self):
return self.__ditto_features return self.__ditto_features
...@@ -238,8 +260,18 @@ def run_forever(self): ...@@ -238,8 +260,18 @@ def run_forever(self):
if self.__is_repo: if self.__is_repo:
threading.Thread(target=self.__repo_syn).start() threading.Thread(target=self.__repo_syn).start()
@staticmethod for func in self.user_func_list:
def add_user_def(func): 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. """Insert user-specified function in the thing object.
:param func: external defined function to be executed. :param func: external defined function to be executed.
......
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment