SMACC
Loading...
Searching...
No Matches
eg_random_generator.h
Go to the documentation of this file.
1#pragma once
2#include <smacc/common.h>
5#include <typeinfo>
6#include <boost/statechart/event.hpp>
7#include <functional>
8
9namespace smacc
10{
11 namespace state_reactors
12 {
13 template <typename TSource, typename TState>
14 struct EventA : sc::event<EventA<TSource, TState>>
15 {
16 };
17
18 template <typename TSource, typename TState>
19 struct EventB : sc::event<EventB<TSource, TState>>
20 {
21 };
22
23 template <typename TSource, typename TState>
24 struct EventC : sc::event<EventC<TSource, TState>>
25 {
26 };
27
29 {
33 };
34
35 //-----------------------------------------------------------------------
37 {
38 public:
39 EgRandomGenerator(RandomGenerateReactorMode mode, double evAMin = 1, double evAMax = 4, double evBMin = 5, double evBMax = 8, double evCMin = 9, double evCMax = 12);
40
41 virtual void onEntry() override;
42
43 template <typename TState, typename TSource>
45 {
46 this->postEventA = [this]() { this->postEvent<EventA<TSource, TState>>(); };
47 this->postEventB = [this]() { this->postEvent<EventB<TSource, TState>>(); };
48 this->postEventC = [this]() { this->postEvent<EventC<TSource, TState>>(); };
49 }
50
51 void postRandomEvents();
52
53 virtual void update() override;
54
56
57 private:
58 std::function<void()> postEventA;
59 std::function<void()> postEventB;
60 std::function<void()> postEventC;
61
62 double evAMin_;
63 double evAMax_;
64 double evBMin_;
65 double evBMax_;
66 double evCMin_;
67 double evCMax_;
68
69 double minValue;
70 double maxValue;
71 };
72 } // namespace state_reactors
73} // namespace smacc