smallneuron 2.3.12__tar.gz → 2.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {smallneuron-2.3.12/src/smallneuron.egg-info → smallneuron-2.4.1}/PKG-INFO +1 -1
- {smallneuron-2.3.12 → smallneuron-2.4.1}/pyproject.toml +1 -1
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/smallneuron.py +16 -15
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/sntimer.py +10 -8
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/snwatcher.py +3 -2
- {smallneuron-2.3.12 → smallneuron-2.4.1/src/smallneuron.egg-info}/PKG-INFO +1 -1
- {smallneuron-2.3.12 → smallneuron-2.4.1}/.gitignore +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/LICENSE +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/README.md +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/example.py +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/setup.cfg +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/__init__.py +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/build +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/gpio_h3.c +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/gpio_h3.h +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/gpio_h3.so +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/logger.py +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/sndummy.py +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/sngpio.py +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/sninput.py +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/snmqtt.py +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron/snserial.py +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron.egg-info/SOURCES.txt +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron.egg-info/dependency_links.txt +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron.egg-info/top_level.txt +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron_pelainux.egg-info/PKG-INFO +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron_pelainux.egg-info/SOURCES.txt +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron_pelainux.egg-info/dependency_links.txt +0 -0
- {smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron_pelainux.egg-info/top_level.txt +0 -0
|
@@ -131,19 +131,24 @@ class EventManager:
|
|
|
131
131
|
nodeTo._cmd =True
|
|
132
132
|
|
|
133
133
|
# Agregamos un evento a la cola
|
|
134
|
-
def putEvent(self, event, params=None): # lanzamos un evento ahora
|
|
135
|
-
log.debug("putEvent:", event, "params:", params)
|
|
134
|
+
def putEvent(self, event, params=None, valid_until=0): # lanzamos un evento ahora
|
|
135
|
+
log.debug("putEvent:", event, "params:", params, "valid_until", valid_until)
|
|
136
136
|
if params == None:
|
|
137
137
|
params = {}
|
|
138
138
|
|
|
139
|
-
self.events.put((event, params,
|
|
139
|
+
self.events.put((event, params, valid_until))
|
|
140
140
|
|
|
141
141
|
# lanza un thread para leer de un callback en varias modalidades
|
|
142
142
|
# que generaran eventos
|
|
143
|
-
def watchEvent(self,event,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
def watchEvent(self,event, # Evento que se generara
|
|
144
|
+
event_params={}, # Parametros del evento
|
|
145
|
+
data_pattern=None, # patron buscado en el retorno del callback
|
|
146
|
+
callback_obj=None, # objeto del callback
|
|
147
|
+
callback_function_args={}, #paramatros de l afuncion de callback
|
|
148
|
+
mode="loop",period=1,
|
|
149
|
+
valid_until=0 # validUntil
|
|
150
|
+
):
|
|
151
|
+
watcher=SnWatcher(self,event,event_params,event_pattern=data_pattern, valid_until=valid_until)
|
|
147
152
|
watcher.start(callback_obj,callback_function_args,mode,period)
|
|
148
153
|
return watcher
|
|
149
154
|
|
|
@@ -280,19 +285,15 @@ class EventManager:
|
|
|
280
285
|
log.notice("[-",self.count,"-] State:", self.currentState)
|
|
281
286
|
log.perfMark("event end:")
|
|
282
287
|
eventTuple = self.events.get()
|
|
283
|
-
event
|
|
284
|
-
params
|
|
288
|
+
event = eventTuple[0] # text del evento
|
|
289
|
+
params = eventTuple[1] # argumentos del evento
|
|
290
|
+
validUntil = eventTuple[2] # valid Until
|
|
285
291
|
|
|
286
292
|
log.perfMark(f"[%d] start event %s"%(self.count,event))
|
|
287
293
|
log.notice("[",self.count,"] Event:", event, params)
|
|
288
294
|
|
|
289
295
|
|
|
290
|
-
|
|
291
|
-
validUntil=self.count
|
|
292
|
-
if type(params) == dict:
|
|
293
|
-
validUntil=params.pop("validUntil", self.count)
|
|
294
|
-
|
|
295
|
-
if validUntil < self.count:
|
|
296
|
+
if validUntil != 0 and validUntil < self.count:
|
|
296
297
|
log.warn("[",self.count,"] ", event, " is caduced ", validUntil, "<", self.count)
|
|
297
298
|
|
|
298
299
|
elif event in self.net:
|
|
@@ -6,7 +6,7 @@ import re
|
|
|
6
6
|
import threading
|
|
7
7
|
import os.path
|
|
8
8
|
import traceback
|
|
9
|
-
from .logger import Logger
|
|
9
|
+
from .logger import Logger, logger_with_method
|
|
10
10
|
from time import sleep
|
|
11
11
|
from .smallneuron import EventManager
|
|
12
12
|
|
|
@@ -24,13 +24,15 @@ class SnTimer():
|
|
|
24
24
|
|
|
25
25
|
# Los eventos agregado con timer son por defecto
|
|
26
26
|
# solo validos para el siguiente estado
|
|
27
|
+
@logger_with_method(log)
|
|
27
28
|
def watchEvent(self, event, event_params={}, time=1.0, valid=1):
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
until=self.eventManager.count+valid
|
|
30
|
+
log.debug(f"event:{event}, params:{event_params} time:{time}s valid:{valid} until:{until}")
|
|
31
|
+
return self.eventManager.watchEvent(event=event,
|
|
32
|
+
event_params=event_params,
|
|
33
|
+
callback_obj=self,
|
|
34
|
+
callback_function_args={"time":time},
|
|
35
|
+
mode="noloop",
|
|
36
|
+
valid_until=until)
|
|
35
37
|
|
|
36
38
|
|
|
@@ -19,11 +19,12 @@ class SnWatcher():
|
|
|
19
19
|
seran parte del argumento del evento junto a los event_params
|
|
20
20
|
3. Si se repiten los elementos retornados por callback() con los events_params mandan los de callback()
|
|
21
21
|
'''
|
|
22
|
-
def __init__(self, eventManager, event, event_params={}, event_pattern=ModuleNotFoundError):
|
|
22
|
+
def __init__(self, eventManager, event, event_params={}, event_pattern=ModuleNotFoundError, valid_until=0):
|
|
23
23
|
self.em=eventManager
|
|
24
24
|
self.event=event
|
|
25
25
|
self.event_params=event_params
|
|
26
26
|
self.event_pattern=event_pattern
|
|
27
|
+
self.event_valid_until=valid_until
|
|
27
28
|
self.stoploop=False
|
|
28
29
|
self.thread=None
|
|
29
30
|
log.debug("created")
|
|
@@ -74,7 +75,7 @@ class SnWatcher():
|
|
|
74
75
|
resp={"data":data}
|
|
75
76
|
|
|
76
77
|
if self.event_pattern == None or re.search(self.event_pattern, resp["data"]) != None:
|
|
77
|
-
self.em.putEvent(self.event, dict(self.event_params,**resp))
|
|
78
|
+
self.em.putEvent(self.event, dict(self.event_params,**resp),self.event_valid_until)
|
|
78
79
|
log.info("trigger", self.event_params)
|
|
79
80
|
if mode=="match":
|
|
80
81
|
log.debug(threading.get_ident(),"_check loop match")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{smallneuron-2.3.12 → smallneuron-2.4.1}/src/smallneuron_pelainux.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|