From 2df6936eaf25854c47ecc88516e649a197c5dafd Mon Sep 17 00:00:00 2001
From: Jochen Vothknecht <jochen3120@gmail.com>
Date: Wed, 15 Dec 2021 15:39:16 +0100
Subject: [PATCH] =?UTF-8?q?=E2=80=A6=E2=80=A6=E2=80=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 SiliconTorch/Device.py   |  2 +
 SiliconTorch/PropTest.py | 81 +++++++++++++++++-----------------------
 2 files changed, 36 insertions(+), 47 deletions(-)

diff --git a/SiliconTorch/Device.py b/SiliconTorch/Device.py
index 48c1579..de441e3 100644
--- a/SiliconTorch/Device.py
+++ b/SiliconTorch/Device.py
@@ -55,6 +55,7 @@ class MQTTProperty:
 
 
 
+from inspect import signature
 
 class MQTTTrigger:
 
@@ -77,6 +78,7 @@ class MQTTTrigger:
   # ###  TODO: !!!  ###
   # ###################
   def __call__(self, func) -> Callable[[Any], Any]:
+    print(f'__call__ with {signature(func)}')
     self.__function = func
     return self
 
diff --git a/SiliconTorch/PropTest.py b/SiliconTorch/PropTest.py
index d1a0d07..afcf79c 100644
--- a/SiliconTorch/PropTest.py
+++ b/SiliconTorch/PropTest.py
@@ -1,65 +1,52 @@
 
+from inspect import signature
 
 
-class MyProp:
 
-  def __init__(self, getter):
-    self.__getter = getter
+class MQTTTrigger:
 
-  def __get__(self, obj, cls):
-    print('GET IT!!!')
-    return self.__getter(obj)
+  def __init__(self, message: str = None, binaryMessage: bytes = None):
 
+    self.__function = None
 
-class MyDec:
-  def __init__(self, *args):
-    print(f'MyDec[  {args}  ]')
+    if binaryMessage is not None:
+      self.__message = binaryMessage
+    elif message is not None:
+      self.__message = bytes(message, 'UTF-8')
+    else:
+      self.__message = b''
 
-  def __call__(*args):
-    print(f'MyDec.call[  {args}  ]')
+  # ###################
+  # ###  TODO: !!!  ###
+  # ###################
+  def __call__(self, func=None):
+    print(f'__CALL__: self is of type {type(self)} and evaluates to str[ {self} ]')
 
+    if func is not None:
 
-class MyDesc:
+      print(f'storing function[ {signature(func)} ]')
+      self.__function = func
 
-  def __get__(self, obj, cls):
-    return None
+      return self.__execute
+    else:
+      print(f'__call__: executing business logic :)')
+      print(f'__call__: self is of type {type(self)} and evaluates to str[ {self} ]')
+      if self.__function is not None:
+        return self.__function(self)  # TODO: is this the right self we supply?!
 
-  def __set__(self, obj, value):
-    pass
+  def __execute(self):
+    print(f'__execute: executing business logic :)')
+    print(f'__execute: self is of type {type(self)} and evaluates to str[ {self} ]')
+    if self.__function is not None:
+      return self.__function(self)  # TODO: is this the right self we supply?!
 
-  def __delete__(self, obj):
-    pass
 
+class TestDevice:
 
-class C:
-  xy = MyDesc()
-
-  @MyProp
-  def wq(self):
-    print('wq')
-    return 'foo'
-  
-  y = 3
-  def x(self):
-    print(f'y: {__class__.y}')
-
-
-
-c = C()
-
-
-class Decorated:
-  @MyDec
-  def x(self): print('x')
-
-  @MyDec(1, 2, 3)
-  def y(self): print('y')
-
-d = Decorated()
-
-
-#d.x()
-#d.y()
+  @MQTTTrigger(message='restart')
+  def restart(self): print(f'self[ {self} ]   RESTART!!!')
 
+  OTA = MQTTTrigger(message='otää otää')
 
 
+dev = TestDevice()
-- 
GitLab