SMACC2
Loading...
Searching...
No Matches
eg_random_generator.hpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16#include <boost/statechart/event.hpp>
17#include <functional>
18#include <smacc2/common.hpp>
21#include <typeinfo>
22
23namespace smacc2
24{
25namespace state_reactors
26{
27template <typename TSource, typename TState>
28struct EventA : sc::event<EventA<TSource, TState>>
29{
30};
31
32template <typename TSource, typename TState>
33struct EventB : sc::event<EventB<TSource, TState>>
34{
35};
36
37template <typename TSource, typename TState>
38struct EventC : sc::event<EventC<TSource, TState>>
39{
40};
41
43{
47};
48
49//-----------------------------------------------------------------------
51{
52public:
54 RandomGenerateReactorMode mode, double evAMin = 1, double evAMax = 4, double evBMin = 5,
55 double evBMax = 8, double evCMin = 9, double evCMax = 12);
56
57 void onEntry() override;
58
59 template <typename TState, typename TSource>
61 {
62 this->postEventA = [this]() { this->postEvent<EventA<TSource, TState>>(); };
63 this->postEventB = [this]() { this->postEvent<EventB<TSource, TState>>(); };
64 this->postEventC = [this]() { this->postEvent<EventC<TSource, TState>>(); };
65 }
66
67 void postRandomEvents();
68
69 void update() override;
70
72
73private:
74 std::function<void()> postEventA;
75 std::function<void()> postEventB;
76 std::function<void()> postEventC;
77
78 double evAMin_;
79 double evAMax_;
80 double evBMin_;
81 double evBMax_;
82 double evCMin_;
83 double evCMax_;
84
85 double minValue;
86 double maxValue;
87};
88} // namespace state_reactors
89} // namespace smacc2