TimeoutExample.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5*
6* ArmarX is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License version 2 as
8* published by the Free Software Foundation.
9*
10* ArmarX is distributed in the hope that it will be useful, but
11* WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17*
18* @package ArmarXCore::StatechartExamples::TimeoutExample
19* @author Mirko Waechter (mirko.waechter at kit dot edu)
20* @date 2012
21* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22* GNU General Public License
23*/
24
25#pragma once
26
30
31namespace armarx
32{
34 {
35 public:
37
38 // inherited from Component
39 std::string
40 getDefaultName() const override
41 {
42 return "TimeoutExample";
43 };
44
45 void onInitStatechart() override;
46 void onConnectStatechart() override;
47 void run();
48 };
49 struct stateInstallTimeout;
50 DEFINEEVENT(Next)
51 DEFINEEVENT(TimerExpired)
52
54 {
55 void
56 defineState() override
57 {
58 // setStateName("StatechartTimeoutexample");
59 }
60
61 void
62 defineSubstates() override
63 {
64 //add substates
66
67 StateBasePtr finalSuccess = addState<SuccessState>("Success");
68 StateBasePtr finalFailure = addState<FailureState>("Failure");
69
70 // add transition
73 addTransition<Success>(getInitState(), finalSuccess);
74 }
75 };
76
77
78 struct DelayState;
79
80 struct stateInstallTimeout : StateTemplate<stateInstallTimeout>
81 {
82
83
84 void
85 onEnter() override
86 {
87
89 }
90
91 void
92 onExit() override
93 {
94 }
95 };
96
97
98} // namespace armarx
#define ARMARXCOMPONENT_IMPORT_EXPORT
#define DEFINEEVENT(NEWEVENT)
this macro declares a new event-class derived vom Event, to have a compiletime check for typos in eve...
ActionEventIdentifier setTimeoutEvent(int timeoutDurationMs, const EventPtr &evt)
Utility function to start a timer on the systemObserver and register an event on the conditionHandler...
EventPtr createEvent()
Utility function to create a new Event.
Definition StateUtil.h:63
StateBasePtr addState(StateBasePtr pNewState)
Definition State.cpp:140
StateBasePtr setInitState(StateBasePtr initState, ParameterMappingPtr initialStateMapping=ParameterMappingPtr())
Sets the initial substate of this state.
Definition State.cpp:354
TransitionIceBase & addTransition(EventPtr event, StateIceBasePtr sourceState, StateIceBasePtr destinationState, ParameterMappingIceBasePtr mappingToNextStatesInput=nullptr, ParameterMappingIceBasePtr mappingToParentStatesLocal=nullptr, ParameterMappingIceBasePtr mappingToParentStatesOutput=nullptr)
Definition State.cpp:250
StateBasePtr getInitState() const
Getter for the initial state. The initial state is automatically entered, when this state is entered.
Definition State.cpp:107
std::string getDefaultName() const override
Retrieve default name of component.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< State > StatePtr
Definition State.h:44
IceInternal::Handle< StateBase > StateBasePtr
Definition StateBase.h:49
void defineState() override
Virtual function, in which this state can be configured.
void defineSubstates() override
Virtual function, in which substates, transition and mappings can be added.
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...