[MERGED] libosmocore[master]: contrib/fsm-to-dot: mark arrows that feed events

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Mar 26 13:03:22 UTC 2018


Neels Hofmeyr has submitted this change and it was merged.

Change subject: contrib/fsm-to-dot: mark arrows that feed events
......................................................................


contrib/fsm-to-dot: mark arrows that feed events

Most arrows draw state transitions, but some want to show that an event is
delivered to a state. Mark those with a "halfopen" arrow head.

Change-Id: Ib07380894a6d513896c9135f175ecbf653a23eec
---
M contrib/fsm-to-dot.py
1 file changed, 12 insertions(+), 7 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/fsm-to-dot.py b/contrib/fsm-to-dot.py
index 872577e..83c95b6 100755
--- a/contrib/fsm-to-dot.py
+++ b/contrib/fsm-to-dot.py
@@ -137,10 +137,11 @@
     return cmp(event.name, other.name)
 
 class Edge:
-  def __init__(edge, to_state, event_name=None, style=None, action=None, color=None):
+  def __init__(edge, to_state, event_name=None, style=None, action=None, color=None, arrow_head=None):
     edge.to_state = to_state
     edge.style = style
     edge.color = color
+    edge.arrow_head = arrow_head
     edge.events = []
     edge.actions = []
     edge.add_event_name(event_name)
@@ -330,7 +331,8 @@
 
   def add_special_state(fsm, additional_states, name, in_state=None,
                         out_state=None, event_name=None, kind=KIND_FUNC,
-                        state_action=None, label=None, edge_action=None):
+                        state_action=None, label=None, edge_action=None,
+                        style='dotted', arrow_head=None):
     additional_state = None
     for s in additional_states:
       if s.short_name == name:
@@ -356,13 +358,13 @@
 
     if out_state:
       additional_state.out_state_names.append(out_state.name)
-      additional_state.add_out_edge(Edge(out_state, event_name, 'dotted',
-                                         action=edge_action))
+      additional_state.add_out_edge(Edge(out_state, event_name, style=style,
+                                         action=edge_action, arrow_head=arrow_head))
 
     if in_state:
       in_state.out_state_names.append(additional_state.name)
-      in_state.add_out_edge(Edge(additional_state, event_name, 'dotted',
-                                 action=edge_action))
+      in_state.add_out_edge(Edge(additional_state, event_name, style=style,
+                                 action=edge_action, arrow_head=arrow_head))
 
 
   def find_event_edges(fsm, c_files):
@@ -425,7 +427,8 @@
         # them to the graph as well
         additional_funcs = [f for f in funcs_for_in_event if f not in fsm.action_funcs]
         for af in additional_funcs:
-          fsm.add_special_state(additional_states, af, None, state, in_event_name)
+          fsm.add_special_state(additional_states, af, None, state, in_event_name,
+                                arrow_head='halfopen')
 
     fsm.states.extend(additional_states)
 
@@ -540,6 +543,8 @@
           attrs.append('style=%s'% out_edge.style)
         if out_edge.color:
           attrs.append('color=%s'% out_edge.color)
+        if out_edge.arrow_head:
+          attrs.append('arrowhead=%s'% out_edge.arrow_head)
         attrs_str = ''
         if attrs:
           attrs_str = ' [%s]' % (','.join(attrs))

-- 
To view, visit https://gerrit.osmocom.org/7499
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib07380894a6d513896c9135f175ecbf653a23eec
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list