RemoteAccessableState.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 20122012
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
25 #pragma once
26 
27 
30 
31 namespace armarx
32 {
34  virtual public RemoteStateOfferer<StatechartContext>
35  {
36  public:
37  // inherited from Component
38  std::string
39  getStateOffererName() const override
40  {
41  return "RemoteAccessable";
42  }
43 
44  // inherited from RemoteStateOfferer
45  void onInitRemoteStateOfferer() override;
46  };
47 
48  struct Stateadd_x_to_y : StateTemplate<Stateadd_x_to_y>
49  {
50  void
51  defineParameters() override
52  {
53  addToInput("x", VariantType::Float, false);
54  addToInput("y", VariantType::Float, false);
55 
56  addToOutput("result", VariantType::Float, false);
57  }
58 
59  void
60  defineSubstates() override
61  {
62  setInitState(addState<State>("DummySubstate1"));
63  addState<State>("DummySubstate2");
64  }
65 
66  void
67  onEnter() override
68  {
69  float result = getInput<float>("x") + getInput<float>("y");
70  setOutput("result", result);
71  ARMARX_INFO << "result: " << result << std::endl;
72  sendEvent<Success>();
73  }
74  };
75 
76 
77 } // namespace armarx
armarx::Stateadd_x_to_y::onEnter
void onEnter() override
Definition: RemoteAccessableState.h:67
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
armarx::StateTemplate
Definition: State.h:38
Statechart.h
armarx::RemoteStateOfferer
Class that holds states, which offer functionality for other states over Ice.
Definition: RemoteStateOfferer.h:203
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx::RemoteAccessableState::getStateOffererName
std::string getStateOffererName() const override
Implement this function to specify the RemoteStateOfferer prefix.
Definition: RemoteAccessableState.h:39
armarx::Stateadd_x_to_y
Definition: RemoteAccessableState.h:48
armarx::Stateadd_x_to_y::defineParameters
void defineParameters() override
Definition: RemoteAccessableState.h:51
armarx::Stateadd_x_to_y::defineSubstates
void defineSubstates() override
Definition: RemoteAccessableState.h:60
armarx::RemoteAccessableState
Definition: RemoteAccessableState.h:33
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
ImportExportComponent.h