Go to the documentation of this file.
29 #include <IceUtil/IceUtil.h>
40 stateType = eDynamicRemoteState;
41 stateName =
"DynamicRemoteState";
42 greedyInputDictionary =
true;
49 RemoteStateInterface(
source),
50 RemoteStateIceBase(
source),
59 stateType = eDynamicRemoteState;
60 stateName =
"DynamicRemoteState";
61 greedyInputDictionary =
true;
67 stateName =
"DynamicRemoteState";
68 stateType = eDynamicRemoteState;
69 greedyInputDictionary =
true;
76 std::stringstream
str;
89 myProxy = RemoteStateIceBasePrx::checkedCast(
getProxy());
93 bool DynamicRemoteState::__checkStatePreconditions()
96 StateParameterMap::iterator itProxy = inputParameters.find(
"proxyName");
97 StateParameterMap::iterator itState = inputParameters.find(
"stateName");
99 if (itProxy == inputParameters.end())
101 ARMARX_WARNING <<
"'proxyName' is not specified in the input parameters of the DynamicRemoteState '" + stateName +
"'." <<
flush;
105 if (itState == inputParameters.end())
107 ARMARX_WARNING <<
"'stateName' is not specified in the input parameters of the DynamicRemoteState '" + stateName +
"'." <<
flush;
111 if (!itProxy->second->set)
113 ARMARX_WARNING <<
"'proxyName' is not set in the input parameters of the DynamicRemoteState '" + stateName +
"'." <<
flush;
117 if (!itState->second->set)
119 ARMARX_WARNING << (
"'stateName' is not set in the input parameters of the DynamicRemoteState '" + stateName +
"'.") <<
flush;
125 if (!proxyName.empty())
133 if (remoteStateId >= 0 && stateOffererPrx)
136 stateOffererPrx->removeInstance(remoteStateId);
143 SingleVariantPtr sVar = SingleVariantPtr::dynamicCast(itProxy->second->value);
144 proxyName = sVar->get()->getString();
146 if (proxyName.empty())
153 sVar = SingleVariantPtr::dynamicCast(itState->second->value);
154 std::string tempStateStr = sVar->get()->getString();
156 if (tempStateStr.empty())
163 stateClassName = tempStateStr;
164 stateName = tempStateStr;
175 stateOffererPrx = getProxy<RemoteStateOffererIceBasePrx>(proxyName,
true);
178 catch (
const Ice::NotRegisteredException&)
180 ARMARX_WARNING <<
"The Component with name '" + proxyName +
"' is not registered in Ice." <<
flush;
183 catch (std::exception& e)
185 ARMARX_WARNING <<
"Could not get proxy for DynamicRemotestate with: proxyName: '" + proxyName +
"' and stateName: '" + stateName +
"'!\n\n" << e.what();
189 auto pos = globalStateIdentifier.find_last_of(
">");
190 if (pos != std::string::npos)
192 globalStateIdentifier.erase(globalStateIdentifier.find_last_of(
">") - 1);
210 itProxy->second->set =
false;
211 itState->second->set =
false;
216 ARMARX_WARNING << (
"Waited more than 10 seconds for dynamic remote state to be ready - bailing out");
227 bool loadingSuccessfull = __checkStatePreconditions();
229 if (!loadingSuccessfull)
239 remoteStateId = stateOffererPrx->createRemoteStateInstance(stateClassName, myProxy, globalStateIdentifier, stateName);
240 globalStateIdentifier +=
"->" + stateName;
241 StateIceBasePtr state = stateOffererPrx->getStatechartInstance(remoteStateId);
242 subStateList = state->subStateList;
243 transitions = state->transitions;
252 inputParameters.clear();
265 inputParameters.clear();
276 result->setName(result->getDefaultName() + IceUtil::generateUUID());
283 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.