Go to the documentation of this file.
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());
93 DynamicRemoteState::__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;
188 stateOffererPrx = getProxy<RemoteStateOffererIceBasePrx>(proxyName,
true);
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());
virtual void __enqueueEvent(const EventPtr event)
void _baseOnEnter() override
Does the setup of the remote statechart and calls RemoteState::_baseOnEnter() afterwards.
StateBasePtr createEmptyCopy() const override
void onConnectComponent() override
Pure virtual hook for the subclass.
void _baseOnEnter() override
Overridden function to redirect this call to the real state in the other application.
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
bool removeProxyDependency(const std::string &name)
This function removes the dependency of this object on the in parameter name specified object.
StateBasePtr clone() const override
const LogSender::manipulator flush
void _baseOnExit() override
Calls RemoteState::_baseOnBreak() and redefines the input parameters.
This Statetype is used to create a state instance that represents a state that is located in another ...
DynamicRemoteStates can be used to connect to remote statecharts dynamically at runtime.
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
bool addParameter(StateParameterMap ¶mMap, const std::string &key, VariantTypeId type, bool optional, VariantPtr defaultValue=VariantPtr()) const
DynamicRemoteState()
Initialize all instance variables.
void onInitComponent() override
Pure virtual hook for the subclass.
void defineParameters() override
The ManagedIceObject is the base class for all ArmarX objects.
bool _baseOnBreak(const EventPtr evt) override
If the call to RemoteState::_baseOnBreak() returns true the input parameters are redefined.
Base Class for all Logging classes.
std::string getName() const
Retrieve name of object.
const VariantTypeId String
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
std::unique_ptr< Impl > impl
bool _baseOnBreak(const EventPtr evt) override
Called by processEvent()-function or parentstate. Must NOT be called by user.
This file offers overloads of toIce() and fromIce() functions for STL container types.
ArmarXObjectSchedulerPtr getObjectScheduler() const
std::string getDefaultName() const override
Retrieve default name of component.
void _baseOnExit() override
Overridden function to redirect this call to the real state in the other application.
DynamicRemoteState & operator=(const DynamicRemoteState &source)
Assignment operator which currently is set to fail on any invocation.