Commits

Ginés Martínez Sánchez committed d423e3f Draft

writing inter_event example

  • Participants
  • Parent commits 87bf298

Comments (0)

Files changed (2)

File ginsfsm/examples/inter_event/financiera/financiera/c_financiera.py

-# -*- encoding: utf-8 -*-
-""" GFinanciera GObj
-
-.. autoclass:: GFinanciera
-    :members: start_up
-
-"""
-
-from ginsfsm.gobj import GObj
-
-
-def ac_sample(self, event):
-    """ Event attributes:
-        * :attr:`data`: example.
-
-    """
-    if self.output_event_name is not None:
-        self.broadcast_event(self.output_event_name, data=event.data)
-
-
-GFINANCIERA_FSM = {
-    'event_list': (
-        'EV_INPUT_EVENT:top input',
-        'EV_OUTPUT_EVENT:top output',
-    ),
-    'state_list': (
-        'ST_IDLE',
-    ),
-    'machine': {
-        'ST_IDLE':
-        (
-            ('EV_INPUT_EVENT',      ac_sample,      None),
-        ),
-    }
-}
-
-GFINANCIERA_GCONFIG = {
-    'subscriber': [
-        None, None, 0, None,
-        "subcriber of all output-events."
-        "Default is ``None``, i.e., the parent"
-    ],
-
-    # If some name is None then the parent don't want receive it.
-    'output_event_name': [
-        str, 'EV_OUTPUT_EVENT', 0, None,
-        "Name of the *sample output* event."
-        " ``None`` if you want ignore the event"
-    ],
-}
-
-
-class GFinanciera(GObj):
-    """  GFinanciera GObj.
-    A Sample gobj.
-
-    .. ginsfsm::
-       :fsm: GFINANCIERA_FSM
-       :gconfig: GFINANCIERA_GCONFIG
-
-    *Input-Events:*
-        * :attr:`'EV_INPUT_EVENT'`: sample input event.
-
-          Event attributes:
-
-              * ``data``: sample event attribute.
-
-    *Output-Events:*
-        * :attr:`'EV_OUTPUT_EVENT'`: sample output event.
-
-          Event attributes:
-
-              * ``data``: sample event attribute.
-
-    """
-    def __init__(self):
-        GObj.__init__(self, GFINANCIERA_FSM, GFINANCIERA_GCONFIG)
-
-    def start_up(self):
-        """ Initialization zone.
-        """
-        if self.config.subscriber is None:
-            self.config.subscriber = self.parent
-        self.subscribe_event(None, self.config.subscriber)

File ginsfsm/examples/inter_event/financiera/financiera/c_prestamos.py

+# -*- encoding: utf-8 -*-
+""" GPrestamos GObj
+
+.. autoclass:: GPrestamos
+    :members: start_up
+
+"""
+
+from ginsfsm.gobj import GObj
+
+
+def ac_sample(self, event):
+    """ Event attributes:
+        * :attr:`data`: example.
+
+    """
+    if self.output_event_name is not None:
+        self.broadcast_event(self.output_event_name, data=event.data)
+
+
+GPRESTAMOS_FSM = {
+    'event_list': (
+        'EV_INPUT_EVENT:top input',
+        'EV_OUTPUT_EVENT:top output',
+    ),
+    'state_list': (
+        'ST_IDLE',
+    ),
+    'machine': {
+        'ST_IDLE':
+        (
+            ('EV_INPUT_EVENT',      ac_sample,      None),
+        ),
+    }
+}
+
+GPRESTAMOS_GCONFIG = {
+    'subscriber': [
+        None, None, 0, None,
+        "subcriber of all output-events."
+        "Default is ``None``, i.e., the parent"
+    ],
+
+    # If some name is None then the parent don't want receive it.
+    'output_event_name': [
+        str, 'EV_OUTPUT_EVENT', 0, None,
+        "Name of the *sample output* event."
+        " ``None`` if you want ignore the event"
+    ],
+}
+
+
+class GPrestamos(GObj):
+    """  GPrestamos GObj.
+    A Sample gobj.
+
+    .. ginsfsm::
+       :fsm: GPRESTAMOS_FSM
+       :gconfig: GPRESTAMOS_GCONFIG
+
+    *Input-Events:*
+        * :attr:`'EV_INPUT_EVENT'`: sample input event.
+
+          Event attributes:
+
+              * ``data``: sample event attribute.
+
+    *Output-Events:*
+        * :attr:`'EV_OUTPUT_EVENT'`: sample output event.
+
+          Event attributes:
+
+              * ``data``: sample event attribute.
+
+    """
+    def __init__(self):
+        GObj.__init__(self, GPRESTAMOS_FSM, GPRESTAMOS_GCONFIG)
+
+    def start_up(self):
+        """ Initialization zone.
+        """
+        if self.config.subscriber is None:
+            self.config.subscriber = self.parent
+        self.subscribe_event(None, self.config.subscriber)