26#include <ArmarXCore/interface/statechart/RemoteStateOffererIce.h>
55 return "StatechartExecutorExample";
68 getProxy(_statechartExecutor,
"SimpleStatechartExecutor");
70 getProxy(_remoteGuiPrx,
"RemoteGuiProvider");
71 _tabName =
"StatechartExecutorExample";
72 setupRemoteGuiWidget();
76 this, &StatechartExecutorExample::runRemoteGui);
77 _remoteGuiTask->start();
100 StatechartExecutorExample::setupRemoteGuiWidget()
104 WidgetPtr test0Button =
makeButton(
"Test_normal");
105 grid.addChild(test0Button);
106 WidgetPtr test1Button =
makeButton(
"Test_args");
107 grid.addChild(test1Button);
108 WidgetPtr test2Button =
makeButton(
"Test_wrongProxy");
109 grid.addChild(test2Button);
112 hlayout.addChild(grid);
115 hlayout.addChild(stopButton);
119 manualLayout.addChild(label1);
121 manualLayout.addChild(lineedit1);
123 manualLayout.addChild(label2);
125 manualLayout.addChild(lineedit2);
127 manualLayout.addChild(runManual);
130 vlayout.addChildren({hlayout, manualLayout});
132 _remoteGuiPrx->createTab(_tabName, vlayout);
136 StatechartExecutorExample::runRemoteGui()
138 int cycleDurationMs = 20;
139 CycleUtil
c(cycleDurationMs);
140 while (!_remoteGuiTask->isStopped())
142 _remoteGuiTab.receiveUpdates();
144 if (_remoteGuiTab.getButton(
"Stop").clicked())
146 _statechartExecutor->stopImmediatly();
148 auto output = _statechartExecutor->getSetOutputParameters();
149 for (
const auto& p : output)
152 ARMARX_INFO << p.first <<
": " << var->get()->getOutputValueOnly();
156 if (_remoteGuiTab.getButton(
"Test_normal").clicked())
158 std::string proxyName =
"StatechartExecutionGroupRemoteStateOfferer";
159 std::string stateName =
"TestStateForStatechartExecution";
170 param2->value =
new SingleVariant(1);
172 inputMap[
"intTest"] = param2;
174 std::vector<PosePtr>
v;
179 inputMap[
"intListTest"] = param3;
181 std::map<std::string, PosePtr> m;
187 inputMap[
"poseMapTest"] = param4;
189 _statechartExecutor->ensureVariantLibrariesAreLoaded(inputMap);
190 _statechartExecutor->startStatechart(proxyName, stateName, inputMap);
204 if (_remoteGuiTab.getButton(
"Test_args").clicked())
208 if (_remoteGuiTab.getButton(
"Test_wrongProxy").clicked())
210 StringVariantContainerBaseMap output =
211 _statechartExecutor->getSetOutputParameters();
215 SingleVariantPtr::dynamicCast(output[
"OutputInt"])->get()->get<
int>();
220 if (_remoteGuiTab.getButtonClicked(
"Run"))
224 _remoteGuiTab.sendUpdates();
225 c.waitForCycleDuration();
#define DEFINEEVENT(NEWEVENT)
this macro declares a new event-class derived vom Event, to have a compiletime check for typos in eve...
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
static SingleTypeVariantListPtr FromStdVector(const std::vector< T1 > &vec)
static StateParameterPtr create()
StatechartExecutorExamplePropertyDefinitions(std::string prefix)
virtual void onInitComponent() override
virtual void onDisconnectComponent() override
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
virtual void onConnectComponent() override
virtual void onExitComponent() override
virtual std::string getDefaultName() const override
static StringValueMapPtr FromStdMap(const std::map< std::string, Type > &map)
FromStdMap creates a StringValueMap from a std::map<std::string, Type>.
#define ARMARX_INFO
The normal logging level.
detail::VBoxLayoutBuilder makeVBoxLayout(std::string const &name="")
detail::HBoxLayoutBuilder makeHBoxLayout(std::string const &name="")
detail::SimpleGridLayoutBuilder makeSimpleGridLayout(std::string const &name="")
detail::ButtonBuilder makeButton(std::string const &name)
detail::LabelBuilder makeLabel(std::string const &name)
detail::LineEditBuilder makeLineEdit(std::string const &name)
double v(double t, double v0, double a0, double j)
QMap< QString, StateParameterPtr > StateParameterMap
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< StateParameter > StateParameterPtr
IceInternal::Handle< SingleVariant > SingleVariantPtr
IceInternal::Handle< Pose > PosePtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Derived & label(std::string const &label)
SimpleGridLayoutBuilder & cols(int n)
Derived & value(ValueT const &value)