gv_fsm 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3579818099a2f3e8d172c9534af08877f3e4b27f4fc09f9c9aa77c6275256ce3
4
- data.tar.gz: 5b4acdd1da41b63fbac514f2a481766c5b5c08ba34881ef708d11871910e8d0d
3
+ metadata.gz: 48a490d68d563a441424cfdd79c6c6051d30d4b6e55765239936aed794a898a5
4
+ data.tar.gz: fc16d72b89d439ae9b18f021e46a9cbf1c5caf4b48ed71a45bad2db72998005b
5
5
  SHA512:
6
- metadata.gz: 5f481dacfc667927287eecc1b5f901fd915a593ab533b6de35f573e0cb1b66219c5cd37e24f9c54095e1049f8a7f3f67094530338a9c653cbb72585d1ccbcdf3
7
- data.tar.gz: 4b835c1bc4f03a6d80e37f64f219b0801756ffaeeedbd7da20f53ffbc428b48efd92ac075c189b5379d30ef125ebaf4417e259b0729d1c9e9ac0a94db08b3e14
6
+ metadata.gz: ff52872fa8b822d0b63085cf1721bff88123d64112d3ba1103bdaf6da7e5eb1e801f5fed4526d029128b0853ab1527c45f1fc625d61cc37a9350c81709c5a578
7
+ data.tar.gz: 2d4c28d766e9c34bbe379af163f3302f53501870497df608142c7b67e9f02059846944d17ecac780c4d732a68be00eb790625ffbbd6d2d90b4040c764ea6dcea
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'ruby-graphviz'
4
4
  require 'erb'
5
-
5
+ require 'pry'
6
6
  require File.expand_path('../templates.rb', __FILE__)
7
7
  require File.expand_path("../version.rb", __FILE__)
8
8
 
@@ -32,6 +32,7 @@ module GV_FSM
32
32
  GraphViz.parse(filename) do |g|
33
33
  g.each_node do |id|
34
34
  n = g.get_node(id)
35
+ binding.pry
35
36
  label = n[:label].source.empty? ? "do_#{id}" : n[:label].source
36
37
  @states << {id: id, function: @prefix+label}
37
38
  end
@@ -47,7 +47,7 @@ module GV_FSM
47
47
  } <%= @prefix %>state_t;
48
48
 
49
49
  // State human-readable names
50
- const char *state_names[] = {<%= states_list.map {|sn| '"'+sn+'"'}.join(", ") %>};
50
+ extern const char *state_names[];
51
51
 
52
52
  <% if transition_functions_list.count > 0 then %>
53
53
  // State function and state transition prototypes
@@ -73,12 +73,7 @@ module GV_FSM
73
73
 
74
74
 
75
75
  // List of state functions
76
- <% fw = state_functions_list.max {|a, b| a.length <=> b.length}.length %>
77
- state_func_t *const <%= @prefix %>state_table[<%= @prefix.upcase %>NUM_STATES] = {
78
- <% @states.each do |s| %>
79
- <%= (s[:function] + ',').ljust(fw+1) %> // in state <%= s[:id] %>
80
- <% end %>
81
- };
76
+ extern state_func_t *const <%= @prefix %>state_table[<%= @prefix.upcase %>NUM_STATES];
82
77
 
83
78
 
84
79
  <% if transition_functions_list.count > 0 then %>
@@ -89,21 +84,13 @@ module GV_FSM
89
84
  <% end %>
90
85
 
91
86
  // Table of transition functions
92
- transition_func_t *const <%= @prefix %>transition_table[<%= @prefix.upcase %>NUM_STATES][<%= @prefix.upcase %>NUM_STATES] = {
93
- <% sl = states_list %>
94
- <% fw = transition_functions_list.max {|a, b| a.length <=> b.length}.length %>
95
- <% sw = states_list.max {|a, b| a.length <=> b.length}.length %>
96
- /* <%= "states:".ljust(sw) %> <%= sl.map {|e| e.ljust(fw) }.join(", ") %> */
97
- <% transitions_map.each_with_index do |l, i| %>
98
- /* <%= sl[i].ljust(sw) %> */ {<%= l.map {|e| e.ljust(fw)}.join(", ") %>},
99
- <% end %>
100
- };
87
+ extern transition_func_t *const <%= @prefix %>transition_table[<%= @prefix.upcase %>NUM_STATES][<%= @prefix.upcase %>NUM_STATES];
101
88
  <% else %>
102
89
  // No transition functions
103
90
  <% end %>
104
91
 
105
92
  // state manager
106
- <%= @prefix %>state_t <%= @prefix %>run_state(<%= @prefix %>state_t cur_state, void *data);
93
+ <%= @prefix %>state_t <%= @prefix %>run_state(<%= @prefix %>state_t cur_state, state_data_t *data);
107
94
 
108
95
  <% if !@ino then %>
109
96
  #endif
@@ -121,6 +108,33 @@ module GV_FSM
121
108
  <% placeholder = "Your Code Here" %>
122
109
  // SEARCH FOR <%= placeholder %> FOR CODE INSERTION POINTS!
123
110
 
111
+ // GLOBALS
112
+ // State human-readable names
113
+ const char *state_names[] = {<%= states_list.map {|sn| '"'+sn+'"'}.join(", ") %>};
114
+
115
+ // List of state functions
116
+ <% fw = state_functions_list.max {|a, b| a.length <=> b.length}.length %>
117
+ state_func_t *const <%= @prefix %>state_table[<%= @prefix.upcase %>NUM_STATES] = {
118
+ <% @states.each do |s| %>
119
+ <%= (s[:function] + ',').ljust(fw+1) %> // in state <%= s[:id] %>
120
+ <% end %>
121
+ };
122
+ <% if transition_functions_list.count > 0 then %>
123
+
124
+ // Table of transition functions
125
+ transition_func_t *const <%= @prefix %>transition_table[<%= @prefix.upcase %>NUM_STATES][<%= @prefix.upcase %>NUM_STATES] = {
126
+ <% sl = states_list %>
127
+ <% fw = transition_functions_list.max {|a, b| a.length <=> b.length}.length %>
128
+ <% sw = [states_list, "states:"].flatten.max {|a, b| a.length <=> b.length}.length %>
129
+ /* <%= "states:".ljust(sw) %> <%= sl.map {|e| e.ljust(fw) }.join(", ") %> */
130
+ <% transitions_map.each_with_index do |l, i| %>
131
+ /* <%= sl[i].ljust(sw) %> */ {<%= l.map {|e| e.ljust(fw)}.join(", ") %>},
132
+ <% end %>
133
+ };
134
+ <% else %>
135
+ // No transition functions
136
+ <% end %>
137
+
124
138
  // ____ _ _
125
139
  // / ___|| |_ __ _| |_ ___
126
140
  // \\___ \\| __/ _` | __/ _ \\
@@ -1,3 +1,3 @@
1
1
  module GV_FSM
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gv_fsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Bosetti