StatechartContext.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::Statechart
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 #pragma once
25 #ifndef _ARMARX_CORE_STATECHARTCONTEXT_H
26 #define _ARMARX_CORE_STATECHARTCONTEXT_H
27 
28 
31 #include "../core/Component.h"
32 
33 #include <ArmarXCore/interface/observers/SystemObserverInterface.h>
34 #include <ArmarXCore/interface/observers/ConditionHandlerInterface.h>
35 
36 #include <unordered_map>
37 
38 
39 namespace armarx
40 {
41  class StatechartEventDistributor;
43 
44  class State;
46 
47  class DataFieldIdentifier;
48 
49  class StatechartManager;
51 
52  using StatechartProfilePtr = std::shared_ptr<class StatechartProfile>;
53 
54 
60  {
61  public:
63  };
64 
65 
90  virtual public Component,
92  {
93  private:
94  // inherited from Component
95  void onInitComponent() override;
96  void onConnectComponent() override;
97  void onDisconnectComponent() override;
98  void onExitComponent() override;
99 
100  protected:
109  virtual void onInitStatechartContext() {}
110 
119  virtual void onConnectStatechartContext() {}
120  public:
122  ~StatechartContext() override;
123 
128 
129  TimedVariantBaseList getDataListFromObserver(std::string observerName, const DataFieldIdentifierBaseList& identifierList) override;
131  ChannelRefPtr getChannelRef(const std::string& observerName, const std::string& channelName) override;
132  DatafieldRefPtr getDatafieldRef(const DataFieldIdentifier& datafieldIdentifier) override;
133  DatafieldRefPtr getDatafieldRef(ChannelRefPtr channelRef, const std::string& datafieldName) override;
134 
137 
145  bool setToplevelState(const armarx::StatePtr& newToplevelState, StringVariantContainerBaseMap startParameters = StringVariantContainerBaseMap());
146 
152  void setAutoEnterToplevelState(bool autoEnter);
153 
154  void setReportingTopic(std::string reportingTopic);
155 
161  void startStatechart();
162 
166  virtual void onInitStatechart() = 0;
167 
171  virtual void onConnectStatechart() = 0;
177  virtual void onExitStatechart() {}
178 
179  std::unordered_map<std::string, ObserverInterfacePrx> observerMap;
180 
186  ConditionHandlerInterfacePrx conditionHandlerPrx;
187  SystemObserverInterfacePrx systemObserverPrx;
188 
189  protected:
192  std::string reportingTopic;
193  };
195 
197  {
198  public:
200 
201 
202  protected:
204 
205  private:
206  StatechartProfilePtr selectedStatechartProfile;
207  friend class XMLStateComponent;
208  };
209 
210 }
211 
212 #endif
armarx::DataFieldIdentifierBaseList
::std::vector< ::armarx::DataFieldIdentifierBasePtr > DataFieldIdentifierBaseList
Definition: StatechartContextInterface.h:43
armarx::ManagedIceObject::getIceManager
IceManagerPtr getIceManager() const
Returns the IceManager.
Definition: ManagedIceObject.cpp:353
armarx::XMLStatechartContext
Definition: StatechartContext.h:196
armarx::XMLStateComponent
Definition: XMLStateComponent.h:115
armarx::StatechartContext::getDataFromObserver
VariantBasePtr getDataFromObserver(const DataFieldIdentifierBasePtr &identifier) override
Definition: StatechartContext.cpp:132
armarx::StatechartContext::onConnectStatechart
virtual void onConnectStatechart()=0
onConnectStatechart is called before armarx::StatechartContext::startStatechart() and after armarx::S...
armarx::StatechartContext::onInitStatechartContext
virtual void onInitStatechartContext()
onInitStatechartonInitStatechartContext can be implemented by subclasses
Definition: StatechartContext.h:109
armarx::StatechartContext::setReportingTopic
void setReportingTopic(std::string reportingTopic)
Definition: StatechartContext.cpp:192
armarx::StatechartContext::systemObserverPrx
SystemObserverInterfacePrx systemObserverPrx
Definition: StatechartContext.h:187
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:52
armarx::StatechartContext::conditionHandlerPrx
ConditionHandlerInterfacePrx conditionHandlerPrx
Definition: StatechartContext.h:186
armarx::StatechartContextInterface
Definition: StatechartContextInterface.h:46
armarx::StatechartContext::getChannelRef
ChannelRefPtr getChannelRef(const std::string &observerName, const std::string &channelName) override
Definition: StatechartContext.cpp:142
IceInternal::Handle< StatechartEventDistributor >
StatechartEventDistributor.h
armarx::XMLStatechartContext::getSelectedStatechartProfile
const StatechartProfilePtr & getSelectedStatechartProfile() const
Definition: StatechartContext.cpp:202
armarx::StatechartContext::setToplevelState
bool setToplevelState(const armarx::StatePtr &newToplevelState, StringVariantContainerBaseMap startParameters=StringVariantContainerBaseMap())
setToplevelState initializes newToplevelState with the current StatechartContext and the current Stat...
Definition: StatechartContext.cpp:180
armarx::StatechartContext::startStatechart
void startStatechart()
startStatechart actives both, the toplevel startchart stored in the variable statechart and the State...
Definition: StatechartContext.cpp:197
armarx::StatechartContext::reportingTopic
std::string reportingTopic
Definition: StatechartContext.h:192
armarx::StatechartContext::eventDistributor
StatechartEventDistributorPtr eventDistributor
The EventListenerInterface instance, that receives events from observers and redirects them to the co...
Definition: StatechartContext.h:184
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::StatechartContext
This class contains a statechart and provides the interfaces to distributed components.
Definition: StatechartContext.h:89
armarx::StatechartContext::observerMap
std::unordered_map< std::string, ObserverInterfacePrx > observerMap
Definition: StatechartContext.h:179
armarx::StatechartContextPropertyDefinitions::StatechartContextPropertyDefinitions
StatechartContextPropertyDefinitions(std::string prefix)
Definition: StatechartContext.cpp:40
armarx::StatechartContext::getDatafieldRef
DatafieldRefPtr getDatafieldRef(const DataFieldIdentifier &datafieldIdentifier) override
Definition: StatechartContext.cpp:169
armarx::StatechartContext::onExitStatechart
virtual void onExitStatechart()
onExitStatechart can be implemented by subclasses
Definition: StatechartContext.h:177
armarx::StatechartContext::stateReporter
Profiler::ProfilerPtr stateReporter
Definition: StatechartContext.h:191
armarx::StatechartContext::~StatechartContext
~StatechartContext() override
Definition: StatechartContext.cpp:55
armarx::State
Definition: State.h:54
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::StatechartContext::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: StatechartContext.cpp:60
armarx::StatechartContext::statechartManager
StatechartManagerPtr statechartManager
Definition: StatechartContext.h:185
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::StatechartContext::getDataListFromObserver
TimedVariantBaseList getDataListFromObserver(std::string observerName, const DataFieldIdentifierBaseList &identifierList) override
Definition: StatechartContext.cpp:122
IceUtil::Handle< StatechartManager >
armarx::Profiler::ProfilerPtr
std::shared_ptr< Profiler > ProfilerPtr
Definition: ManagedIceObject.h:77
armarx::XMLStatechartContext::setSelectedStatechartProfile
void setSelectedStatechartProfile(const StatechartProfilePtr &value)
Definition: StatechartContext.cpp:208
armarx::StatechartContext::onInitStatechart
virtual void onInitStatechart()=0
onInitStatechart this method is called when the statechart is started.
armarx::StatechartContext::StatechartContext
StatechartContext()
Definition: StatechartContext.cpp:48
armarx::StatechartContext::autoEnterToplevelState
bool autoEnterToplevelState
Definition: StatechartContext.h:190
armarx::StatechartContext::onConnectStatechartContext
virtual void onConnectStatechartContext()
onConnectStatechartContext can be implemented by subclasses
Definition: StatechartContext.h:119
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::StatechartManager
Definition: StatechartManager.h:42
armarx::StatechartContextPropertyDefinitions
The StatechartContextPropertyDefinitions class contains properties associated with all statecharts.
Definition: StatechartContext.h:58
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48
armarx::StatechartContext::setAutoEnterToplevelState
void setAutoEnterToplevelState(bool autoEnter)
setAutoStartStatechart controls whether the toplevelstate is automatically entered,...
Definition: StatechartContext.cpp:187
StatechartContextInterface.h