The MAUVE Toolchain
PeriodicStateMachine.hpp
1 /*
2  * Copyright 2017 ONERA
3  *
4  * This file is part of the MAUVE Base Components project.
5  *
6  * MAUVE Base Components is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License version 3 as
8  * published by the Free Software Foundation.
9  *
10  * MAUVE Base Components is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with MAUVE. If not, see <https://www.gnu.org/licenses/lgpl-3.0>.
17  */
18 #ifndef MAUVE_BASE_PERIODICSTATEMACHINE_HPP
19 #define MAUVE_BASE_PERIODICSTATEMACHINE_HPP
20 
21 #include <mauve/runtime.hpp>
22 
23 namespace mauve {
24  namespace base {
25 
31  template <typename SHELL, typename CORE>
32  struct PeriodicStateMachine : public runtime::FiniteStateMachine<SHELL, CORE> {
33  public:
35  runtime::Property<runtime::time_ns_t>& period =
36  this->mk_property("period", runtime::sec_to_ns(1));
37  private:
40  runtime::ExecState<CORE>& exec_state =
41  this->mk_execution("E", &CORE::update);
43  runtime::SynchroState<CORE>& sync_state =
44  this->mk_synchronization("S", period);
45  protected:
49  virtual bool configure_hook() override;
50  };
51 
52  }
53 }
54 
55 #include "ipp/PeriodicStateMachine.ipp"
56 
57 #endif // MAUVE_BASE_PERIODICSTATEMACHINE_HPP
The MAUVE namespace.
Definition: tracing.hpp:24
Definition: AbstractCore.hpp:32
Definition: AbstractCore.hpp:30
Defines a Periodic State Machine.
Definition: PeriodicStateMachine.hpp:32
virtual bool configure_hook() override
Configure the PSM.
Definition: PeriodicStateMachine.ipp:27
runtime::Property< runtime::time_ns_t > & period
Property to set the PSM period.
Definition: PeriodicStateMachine.hpp:35
Definition: FiniteStateMachine.hpp:44
Property< T > & mk_property(std::string const &name, T init_value)
Create a new property.
Definition: HasProperty.ipp:28