diff --git a/SiliconTorch/Device.py b/SiliconTorch/Device.py index 3f33490c15a8ea8d44d2e6243a4e63006c005a5b..a14948a9b959effdc760f6409f3863c4d90c5334 100644 --- a/SiliconTorch/Device.py +++ b/SiliconTorch/Device.py @@ -10,6 +10,8 @@ class MQTTProperty: self.__ro = readOnly self.__value = initialValue + self.__mqtt = None + if getConvert is not None: self.__name = getConvert.__name__ self.__getConvert = getConvert @@ -21,17 +23,26 @@ class MQTTProperty: else: self.__setConvert = lambda x: x + if name is not None: + self.__name = name def __call__(self, getConvert: Callable[[str], Any]): self.__getConvert = getConvert + if self.__name is not None: + self.__name = getConvert.__name__ + def __get__(self, obj, cls): - pass + if self.__value is not None: + return self.__value + else: + raise AttributeError('not in sync') def __set__(self, obj, value): if self.__ro: raise AttributeError(f'MQTTProperty[ {self.__name} ] is read-only') - pass + + # TODO: publish value! def __del__(*ignored): raise AttributeError('deletion not supported') diff --git a/SiliconTorch/PropTest.py b/SiliconTorch/PropTest.py index b82115611fe488da3b6ac6db9ae7ee3a2e5c3bed..d1a0d0733f359f3afced17ee47fd15242249c6b2 100644 --- a/SiliconTorch/PropTest.py +++ b/SiliconTorch/PropTest.py @@ -38,6 +38,10 @@ class C: def wq(self): print('wq') return 'foo' + + y = 3 + def x(self): + print(f'y: {__class__.y}') diff --git a/SiliconTorch/fxCyanF.py b/SiliconTorch/fxCyanF.py index 8cd4f1a8809ef47a14ff038e780b953c7be81803..7b1f853f469e82dd0689a8db1ecade5e78c1d5b0 100644 --- a/SiliconTorch/fxCyanF.py +++ b/SiliconTorch/fxCyanF.py @@ -59,7 +59,7 @@ class Receiver: self._socket = socket(AF_INET, SOCK_DGRAM) self._socket.bind((host, port)) - self._callbacks = Set() + self._callbacks = set() t = Thread(target=self._recvLoop) t.daemon = True diff --git a/scripting/CyanLightSparkling.py b/scripting/CyanLightSparkling.py index f07c0c5853d9e0c615c1fd5a6f52f0af2eea5fb1..c771bf46926b1168058b9c6548c9d6750009f267 100755 --- a/scripting/CyanLightSparkling.py +++ b/scripting/CyanLightSparkling.py @@ -7,7 +7,7 @@ import random from socket import * -fps = 3 +fps = 4 pixels = 50 port = 4213