$darkmode
simulation_actions.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2024 Robert Bosch GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  */
25 #pragma once
26 
27 #include <cloe/trigger.hpp> // for Trigger, Event, EventFactory, ...
28 #include <cloe/trigger/set_action.hpp> // for DEFINE_SET_STATE_ACTION, SetDataActionFactory
29 
30 #include "simulation_context.hpp"
31 #include "simulation_machine.hpp"
33 #include "simulation_sync.hpp"
34 
35 namespace engine::actions {
36 
37 DEFINE_SET_STATE_ACTION(Pause, "pause", "pause simulation", SimulationMachine, { ptr_->pause(); })
38 
39 DEFINE_SET_STATE_ACTION(Resume, "resume", "resume paused simulation", SimulationMachine,
40  { ptr_->resume(); })
41 
42 DEFINE_SET_STATE_ACTION(Stop, "stop", "stop simulation with neither success nor failure",
43  SimulationMachine, { ptr_->stop(); })
44 
45 DEFINE_SET_STATE_ACTION(Succeed, "succeed", "stop simulation with success", SimulationMachine,
46  { ptr_->succeed(); })
47 
48 DEFINE_SET_STATE_ACTION(Fail, "fail", "stop simulation with failure", SimulationMachine,
49  { ptr_->fail(); })
50 
51 DEFINE_SET_STATE_ACTION(Reset, "reset", "attempt to reset simulation", SimulationMachine,
52  { ptr_->reset(); })
53 
54 DEFINE_SET_STATE_ACTION(KeepAlive, "keep_alive", "keep simulation alive after termination",
55  SimulationContext, { ptr_->config.engine.keep_alive = true; })
56 
57 DEFINE_SET_STATE_ACTION(ResetStatistics, "reset_statistics", "reset simulation statistics",
58  SimulationStatistics, { ptr_->reset(); })
59 
60 DEFINE_SET_DATA_ACTION(RealtimeFactor, "realtime_factor", "modify the simulation speed",
61  SimulationSync, "factor", double, {
62  logger()->info("Setting target simulation speed: {}", value_);
63  ptr_->set_realtime_factor(value_);
64  })
65 
66 } // namespace engine::actions
#define DEFINE_SET_DATA_ACTION(xName, xActionName, xActionDesc, xDataType, xAttributeName, xAttributeType, xOperatorBlock)
Definition: set_action.hpp:210
#define DEFINE_SET_STATE_ACTION(xName, xname, xdescription, xState, xOperatorBlock)
Definition: set_action.hpp:142