ClientState.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::RemoteAccessableStateExample::
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
29//#include <interface/TestCenter/TestCenter.h>
30
32
33namespace armarx
34{
36 {
37 public:
38 // inherited from Component
39 std::string
40 getDefaultName() const override
41 {
42 return "ClientState";
43 };
44
45 void onInitStatechart() override;
46 void onConnectStatechart() override;
47 };
48
49 //Event Definitions
50 DEFINEEVENT(OuterTimer)
51
53 {
54 void
55 defineState() override
56 {
57 // setStateName("Client");
58 }
59
60 void
62 {
63
66
67 addToOutput("result", VariantType::Float, false);
68 }
69
70 void
71 defineSubstates() override
72 {
73 //add substates
74 StateBasePtr remoteState = addRemoteState("add_x_to_y", "RemoteAccessableStateOfferer");
75 setInitState(remoteState, createMapping()->mapFromParent("*", "*"));
76 StatePtr finalSuccess = addState<SuccessState>("Success");
77 StatePtr finalFailure = addState<FailureState>("Failure");
78
79 // add transitions
81 addTransition<Success>(remoteState, finalSuccess);
82 }
83 };
84
85
86} // 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...
std::string getDefaultName() const override
Retrieve default name of component.
Definition ClientState.h:40
StateBasePtr addState(StateBasePtr pNewState)
Definition State.cpp:140
bool addToInput(const std::string &key, const ContainerType &type, bool optional, VariantContainerBasePtr defaultValue=VariantContainerBasePtr())
Adds a key,type-pair to the input parameters.
Definition State.cpp:309
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
bool addToOutput(const std::string &key, VariantTypeId type, bool optional)
Adds a key,type-pair to the output parameters.
Definition State.cpp:319
virtual RemoteStatePtr addRemoteState(std::string stateName, std::string proxyName, std::string instanceName="")
Function to add a new remote substate to this state.
Definition State.cpp:158
StateBasePtr getInitState() const
Getter for the initial state. The initial state is automatically entered, when this state is entered.
Definition State.cpp:107
const VariantTypeId Float
Definition Variant.h:919
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
ParameterMappingPtr createMapping()
Returns a new and empty instance of ParameterMapping.
void defineParameters() override
Virtual function, in which input/local/output parameters can be specified.
Definition ClientState.h:61
void defineState() override
Virtual function, in which this state can be configured.
Definition ClientState.h:55
void defineSubstates() override
Virtual function, in which substates, transition and mappings can be added.
Definition ClientState.h:71