27#include <IceUtil/IceUtil.h>
37 stateType = eDynamicRemoteState;
38 stateName =
"DynamicRemoteState";
39 greedyInputDictionary =
true;
46 RemoteStateInterface(source),
47 RemoteStateIceBase(source),
56 stateType = eDynamicRemoteState;
57 stateName =
"DynamicRemoteState";
58 greedyInputDictionary =
true;
65 stateName =
"DynamicRemoteState";
66 stateType = eDynamicRemoteState;
67 greedyInputDictionary =
true;
75 std::stringstream
str;
89 myProxy = RemoteStateIceBasePrx::checkedCast(
getProxy());
93DynamicRemoteState::__checkStatePreconditions()
96 StateParameterMap::iterator itProxy = inputParameters.find(
"proxyName");
97 StateParameterMap::iterator itState = inputParameters.find(
"stateName");
99 if (itProxy == inputParameters.end())
102 <<
"'proxyName' is not specified in the input parameters of the DynamicRemoteState '" +
108 if (itState == inputParameters.end())
111 <<
"'stateName' is not specified in the input parameters of the DynamicRemoteState '" +
117 if (!itProxy->second->set)
120 <<
"'proxyName' is not set in the input parameters of the DynamicRemoteState '" +
126 if (!itState->second->set)
129 << (
"'stateName' is not set in the input parameters of the DynamicRemoteState '" +
137 if (!proxyName.empty())
145 if (remoteStateId >= 0 && stateOffererPrx)
148 stateOffererPrx->removeInstance(remoteStateId);
156 SingleVariantPtr sVar = SingleVariantPtr::dynamicCast(itProxy->second->value);
157 proxyName = sVar->get()->getString();
159 if (proxyName.empty())
166 sVar = SingleVariantPtr::dynamicCast(itState->second->value);
167 std::string tempStateStr = sVar->get()->getString();
169 if (tempStateStr.empty())
176 stateClassName = tempStateStr;
177 stateName = tempStateStr;
191 catch (
const Ice::NotRegisteredException&)
193 ARMARX_WARNING <<
"The Component with name '" + proxyName +
"' is not registered in Ice."
197 catch (std::exception& e)
199 ARMARX_WARNING <<
"Could not get proxy for DynamicRemotestate with: proxyName: '" +
200 proxyName +
"' and stateName: '" + stateName +
"'!\n\n"
205 auto pos = globalStateIdentifier.find_last_of(
">");
206 if (pos != std::string::npos)
208 globalStateIdentifier.erase(globalStateIdentifier.find_last_of(
">") - 1);
226 itProxy->second->set =
false;
227 itState->second->set =
false;
233 << (
"Waited more than 10 seconds for dynamic remote state to be ready - bailing out");
244 bool loadingSuccessfull = __checkStatePreconditions();
246 if (!loadingSuccessfull)
256 remoteStateId = stateOffererPrx->createRemoteStateInstance(
257 stateClassName, myProxy, globalStateIdentifier, stateName);
258 globalStateIdentifier +=
"->" + stateName;
259 StateIceBasePtr state = stateOffererPrx->getStatechartInstance(remoteStateId);
260 subStateList = state->subStateList;
261 transitions = state->transitions;
270 inputParameters.clear();
284 inputParameters.clear();
296 result->setName(result->getDefaultName() + IceUtil::generateUUID());
305 result->setName(result->getDefaultName() + IceUtil::generateUUID());
DynamicRemoteStates can be used to connect to remote statecharts dynamically at runtime.
void onInitComponent() override
Pure virtual hook for the subclass.
void defineParameters() override
StateBasePtr clone() const override
bool _baseOnBreak(const EventPtr evt) override
If the call to RemoteState::_baseOnBreak() returns true the input parameters are redefined.
StateBasePtr createEmptyCopy() const override
DynamicRemoteState()
Initialize all instance variables.
void onConnectComponent() override
Pure virtual hook for the subclass.
void _baseOnExit() override
Calls RemoteState::_baseOnBreak() and redefines the input parameters.
DynamicRemoteState & operator=(const DynamicRemoteState &source)
Assignment operator which currently is set to fail on any invocation.
void _baseOnEnter() override
Does the setup of the remote statechart and calls RemoteState::_baseOnEnter() afterwards.
std::string getDefaultName() const override
Retrieve default name of component.
Base Class for all Logging classes.
The ManagedIceObject is the base class for all ArmarX objects.
ArmarXObjectSchedulerPtr getObjectScheduler() const
std::string getName() const
Retrieve name of object.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
bool removeProxyDependency(const std::string &name)
This function removes the dependency of this object on the in parameter name specified object.
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
bool _baseOnBreak(const EventPtr evt) override
Called by processEvent()-function or parentstate. Must NOT be called by user.
void _baseOnExit() override
Overridden function to redirect this call to the real state in the other application.
void _baseOnEnter() override
Overridden function to redirect this call to the real state in the other application.
This class is the implementation of the Slice Definition of a state.
bool addParameter(StateParameterMap ¶mMap, const std::string &key, VariantTypeId type, bool optional, VariantPtr defaultValue=VariantPtr()) const
std::unique_ptr< Impl > impl
The StateController class processes events and controls the statechart flow.
virtual void __enqueueEvent(const EventPtr event)
Class that offers the main functionality needed to create a statechart.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
const VariantTypeId String
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< RemoteState > RemoteStatePtr
IceInternal::Handle< SingleVariant > SingleVariantPtr
const LogSender::manipulator flush
IceInternal::Handle< Event > EventPtr
Typedef of EventPtr as IceInternal::Handle<Event> for convenience.
IceInternal::Handle< StateBase > StateBasePtr