Skip to content
Snippets Groups Projects
Commit e05529eb authored by Mirko Wächter's avatar Mirko Wächter
Browse files

RobotControl statecharts now takes a property for loading a state on startup

parent 66c2b52f
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@
#include <Core/observers/variant/ChannelRef.h>
#include <Core/statechart/DynamicRemoteState.h>
#include <Core/core/exceptions/local/ExpressionException.h>
namespace armarx
{
......@@ -64,6 +65,11 @@ namespace armarx
startRobotStatechart();
}
PropertyDefinitionsPtr RobotControl::createPropertyDefinitions()
{
return PropertyDefinitionsPtr(new RobotControlContextProperties(getConfigIdentifier()));
}
void RobotControl::createStaticInstance()
{
getObjectScheduler()->waitForObjectState(eManagedIceObjectStarted, 5000);
......@@ -71,9 +77,31 @@ namespace armarx
std::map<int, StateBasePtr> stateList = getChildStatesByName(stateId,"Functional");
ARMARX_INFO << "Functional State Id:" << stateList.begin()->first << flush;
assert(stateList.size() > 0);
int robotFunctionalStateId = stateList.begin()->first;
robotFunctionalState = stateList.begin()->second;
callRemoteState(stateId, StringVariantContainerBaseMap());
const std::string proxyName = getProperty<std::string>("proxyName").getValue();
const std::string stateName = getProperty<std::string>("stateName").getValue();
ARMARX_IMPORTANT << VAROUT(proxyName) << VAROUT(stateName);
if(!proxyName.empty() && !stateName.empty())
{
auto statebase = robotFunctionalState->findSubstateByName("DynamicRemoteState");
ARMARX_CHECK_EXPRESSION(statebase);
DynamicRemoteStatePtr state = DynamicRemoteStatePtr::dynamicCast(statebase);
if(!state)
{
ARMARX_ERROR << "dynamic state pointer null";
return;
}
state->getObjectScheduler()->waitForObjectState(eManagedIceObjectStarted, 5000);
EventPtr evt = createEvent<EvLoadScenario>();
evt->eventReceiverName = "toAll";
evt->properties["proxyName"] = new SingleVariant(proxyName);
evt->properties["stateName"] = new SingleVariant(stateName);
issueEvent(robotFunctionalStateId, evt);
}
}
......
......@@ -30,6 +30,22 @@
namespace armarx
{
// ****************************************************************
// Component and context
// ****************************************************************
struct RobotControlContextProperties : StatechartContextPropertyDefinitions
{
RobotControlContextProperties(std::string prefix):
StatechartContextPropertyDefinitions(prefix)
{
defineOptionalProperty<std::string>("proxyName", "", "name of the proxy to load");
defineOptionalProperty<std::string>("stateName", "", "name of the state to load");
}
};
/**
* \class RobotControl
* \brief RobotControl is used for dynamically loading and starting robot programs
......@@ -62,7 +78,7 @@ namespace armarx
void hardReset(const Ice::Current & = ::Ice::Current());
virtual PropertyDefinitionsPtr createPropertyDefinitions();
private:
void createStaticInstance();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment