smallneuron 2.1.4__tar.gz → 2.2.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.
Files changed (29) hide show
  1. {smallneuron-2.1.4/src/smallneuron.egg-info → smallneuron-2.2.1}/PKG-INFO +1 -1
  2. {smallneuron-2.1.4 → smallneuron-2.2.1}/pyproject.toml +1 -1
  3. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/smallneuron.py +31 -21
  4. {smallneuron-2.1.4 → smallneuron-2.2.1/src/smallneuron.egg-info}/PKG-INFO +1 -1
  5. {smallneuron-2.1.4 → smallneuron-2.2.1}/.gitignore +0 -0
  6. {smallneuron-2.1.4 → smallneuron-2.2.1}/LICENSE +0 -0
  7. {smallneuron-2.1.4 → smallneuron-2.2.1}/README.md +0 -0
  8. {smallneuron-2.1.4 → smallneuron-2.2.1}/example.py +0 -0
  9. {smallneuron-2.1.4 → smallneuron-2.2.1}/setup.cfg +0 -0
  10. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/__init__.py +0 -0
  11. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/build +0 -0
  12. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/gpio_h3.c +0 -0
  13. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/gpio_h3.h +0 -0
  14. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/gpio_h3.so +0 -0
  15. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/logger.py +0 -0
  16. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/sndummy.py +0 -0
  17. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/sngpio.py +0 -0
  18. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/sninput.py +0 -0
  19. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/snmqtt.py +0 -0
  20. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/snserial.py +0 -0
  21. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/sntimer.py +0 -0
  22. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron/snwatcher.py +0 -0
  23. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron.egg-info/SOURCES.txt +0 -0
  24. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron.egg-info/dependency_links.txt +0 -0
  25. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron.egg-info/top_level.txt +0 -0
  26. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron_pelainux.egg-info/PKG-INFO +0 -0
  27. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron_pelainux.egg-info/SOURCES.txt +0 -0
  28. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron_pelainux.egg-info/dependency_links.txt +0 -0
  29. {smallneuron-2.1.4 → smallneuron-2.2.1}/src/smallneuron_pelainux.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smallneuron
3
- Version: 2.1.4
3
+ Version: 2.2.1
4
4
  Summary: Small Neuron Workflow
5
5
  Author-email: Andres Artigas <andres@artigas.cl>
6
6
  Project-URL: Homepage, https://github.com/pypa/sampleproject
@@ -3,7 +3,7 @@ requires = ["setuptools", "setuptools-scm"]
3
3
 
4
4
  [project]
5
5
  name = "smallneuron"
6
- version = "2.1.4"
6
+ version = "2.2.1"
7
7
  authors = [
8
8
  { name="Andres Artigas", email="andres@artigas.cl" },
9
9
  ]
@@ -47,7 +47,7 @@ class Node:
47
47
 
48
48
  def __eq__(self, other):
49
49
  return self.state == other.state
50
-
50
+
51
51
 
52
52
  class LambdaNode(Node):
53
53
  def __init__(self, state, lambdaEnter, desc="", style=""):
@@ -91,7 +91,7 @@ class EventManager:
91
91
  if event in self.cmds:
92
92
  print("Error event already in cmds ", event)
93
93
  raise "Error event already in cmds"
94
- elif event in self.net:
94
+ elif event in self.net:
95
95
  if nodeFrom.state in self.net[event]:
96
96
  print("Error edge already included ", event, nodeFrom, nodeTo)
97
97
  raise "Error edge already included"
@@ -227,6 +227,21 @@ class EventManager:
227
227
  threading.Thread(target=self.loop).start()
228
228
  self.putEvent("_start_") # lanzamos evento de inicio
229
229
 
230
+ def change_state(self,event, params,node_to:Node):
231
+ # indicamos al nodo actual que salimos
232
+ log.info("[",self.count,"] leave ", self.currentNode.state)
233
+ self.currentNode.leave(event,params,node_to.state)
234
+
235
+ # Entramos al nodo nuevo
236
+ log.info("[",self.count,"] enter ", node_to.state, params)
237
+ node_to.enter(event, params, self.currentState)
238
+ self.currentNode=node_to
239
+ self.prevState = self.currentState
240
+ self.currentState = node_to.state
241
+ self.currentArgs = params
242
+ self.count = self.count + 1 # increment event count
243
+ log.perfMark(f" print graph")
244
+
230
245
  def loop(self):
231
246
  try:
232
247
  self.printGraph()
@@ -254,29 +269,24 @@ class EventManager:
254
269
  if not self.currentState in self.net[event]:
255
270
  log.warn("[",self.count,"] ", event, " not valid for state ", self.currentState, "discarted!")
256
271
  else:
257
- log.perfMark(f" get node")
258
- node: Node = self.net[event][self.currentState][0]
259
- log.info("[",self.count,"] entqer ", node.state, params, self.currentState)
260
-
261
- # indicamos al nodo actual que salimos
262
- log.perfMark(f" leave old node")
263
- self.currentNode.leave(event,params,node.state)
264
-
265
- # Entramos al nodo nuevo
266
- log.perfMark(f" enter node")
267
- node.enter(event, params, self.currentState)
268
- self.currentNode=node
269
- self.prevState = self.currentState
270
- self.currentState = node.state
271
- self.currentArgs = params
272
- self.count = self.count + 1 # increment event count
273
- log.perfMark(f" print graph")
272
+ node_to: Node = self.net[event][self.currentState][0]
273
+ self.change_state(event, params, node_to)
274
274
  self.printGraph(event)
275
275
  elif event in self.cmds:
276
276
  log.info("[", self.count, "] Manager new cmd ", event)
277
- node: Node = self.cmds[event][0]
277
+ node_to: Node = self.cmds[event][0]
278
278
  log.perfMark(f" enter cmd")
279
- node.enter(event, params, self.currentState)
279
+ res=node_to.enter(event, params, self.currentState)
280
+ if type(res) == tuple:
281
+ try:
282
+ new_params,new_state = res
283
+ if not new_state in Node.nodelist:
284
+ log.error(f"Invalid respond on cmd {event} new node {new_state} not exist")
285
+ else:
286
+ self.printGraph(event)
287
+ self.change_state(event, new_params, Node.nodelist[new_state])
288
+ except:
289
+ log.error(f"Invalid respond of cmd {event} in node {node_to.state}")
280
290
  self.printGraph(event)
281
291
  else:
282
292
  log.warn("[",self.count,"] ", event, " not exist")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smallneuron
3
- Version: 2.1.4
3
+ Version: 2.2.1
4
4
  Summary: Small Neuron Workflow
5
5
  Author-email: Andres Artigas <andres@artigas.cl>
6
6
  Project-URL: Homepage, https://github.com/pypa/sampleproject
File without changes
File without changes
File without changes
File without changes
File without changes