gv_fsm 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/templates.rb +18 -6
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e2b60dc6b9b04ce5e69c1737103af124f756c56324a9c92193b35223acacf9e
|
4
|
+
data.tar.gz: 55ba355493f4e6ffe0ed6ea9a48174b1a478a024b6d07c6b3b4d4dafc9d4ebc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 871eaa5cf354c80f516d31878efb9bea108ee55b76a04f3b4715bdc317e2eb8cb9b1005646248f9cff7838cb168aac7d120b8d3388d4be3cbf6ddf237426a0e0
|
7
|
+
data.tar.gz: 39e534fe925ac412a12b88c02e29bbfb106e3460509a7a4a1bbc077f7a6074e7b35f1071fb10151e8e96a1d08706b729919978efc025ee7361d7f6a3b5fd7d87
|
data/lib/templates.rb
CHANGED
@@ -457,12 +457,26 @@ public:
|
|
457
457
|
}
|
458
458
|
}
|
459
459
|
|
460
|
-
|
461
|
-
|
460
|
+
|
461
|
+
// Setup initial state links
|
462
|
+
void setup(state_t state) {
|
462
463
|
<%= ns %>::<%= self.sigint %>_requested = false;
|
463
|
-
<%= @prefix %>state_t prev_state = state;
|
464
464
|
_state.first = state;
|
465
465
|
_state.second = state;
|
466
|
+
}
|
467
|
+
|
468
|
+
// Evaluate the current state and update the next state
|
469
|
+
// to be used when main loop is customized (i.e., not using FSM::run())
|
470
|
+
state_t eval_state() {
|
471
|
+
(*this)(_state.first, _state.second);
|
472
|
+
_state.first = _state.second;
|
473
|
+
_state.second = (*this)(_state.second);
|
474
|
+
return _state.second;
|
475
|
+
}
|
476
|
+
|
477
|
+
// Run the FSM from a given state
|
478
|
+
void run(<%= @prefix %>state_t state, operation_fun operation = nullptr) {
|
479
|
+
setup(state);
|
466
480
|
<% if sigint then -%>
|
467
481
|
std::signal(SIGINT, [](int signum) {
|
468
482
|
<% if log == :syslog then -%>
|
@@ -475,9 +489,7 @@ public:
|
|
475
489
|
if (operation) {
|
476
490
|
operation(*_data);
|
477
491
|
}
|
478
|
-
(
|
479
|
-
_state.first = _state.second;
|
480
|
-
_state.second = (*this)(_state.second);
|
492
|
+
eval_state();
|
481
493
|
if (_timing_func) {
|
482
494
|
_timing_func();
|
483
495
|
}
|
data/lib/version.rb
CHANGED