26#include <ArmarXCore/interface/statechart/RemoteStateOffererIce.h>
57 return "StatechartExecutorExample";
70 getProxy(_statechartExecutor,
"SimpleStatechartExecutor");
72 getProxy(_remoteGuiPrx,
"RemoteGuiProvider");
73 _tabName =
"StatechartExecutorExample";
74 setupRemoteGuiWidget();
78 this, &StatechartExecutorExample::runRemoteGui);
79 _remoteGuiTask->start();
102 StatechartExecutorExample::setupRemoteGuiWidget()
106 WidgetPtr test0Button =
makeButton(
"Test_normal");
107 grid.addChild(test0Button);
108 WidgetPtr test1Button =
makeButton(
"Test_args");
109 grid.addChild(test1Button);
110 WidgetPtr test2Button =
makeButton(
"Test_wrongProxy");
111 grid.addChild(test2Button);
114 hlayout.addChild(grid);
117 hlayout.addChild(stopButton);
121 manualLayout.addChild(label1);
123 manualLayout.addChild(lineedit1);
125 manualLayout.addChild(label2);
127 manualLayout.addChild(lineedit2);
129 manualLayout.addChild(runManual);
132 vlayout.addChildren({hlayout, manualLayout});
134 _remoteGuiPrx->createTab(_tabName, vlayout);
138 StatechartExecutorExample::runRemoteGui()
140 int cycleDurationMs = 20;
141 CycleUtil
c(cycleDurationMs);
142 while (!_remoteGuiTask->isStopped())
144 _remoteGuiTab.receiveUpdates();
146 if (_remoteGuiTab.getButton(
"Stop").clicked())
148 _statechartExecutor->stopImmediatly();
150 auto output = _statechartExecutor->getSetOutputParameters();
151 for (
const auto& p : output)
154 ARMARX_INFO << p.first <<
": " << var->get()->getOutputValueOnly();
158 if (_remoteGuiTab.getButton(
"Test_normal").clicked())
160 std::string proxyName =
"StatechartExecutionGroupRemoteStateOfferer";
161 std::string stateName =
"TestStateForStatechartExecution";
172 param2->value =
new SingleVariant(1);
174 inputMap[
"intTest"] = param2;
176 std::vector<PosePtr>
v;
181 inputMap[
"intListTest"] = param3;
183 std::map<std::string, PosePtr> m;
189 inputMap[
"poseMapTest"] = param4;
191 _statechartExecutor->ensureVariantLibrariesAreLoaded(inputMap);
192 _statechartExecutor->startStatechart(proxyName, stateName, inputMap);
206 if (_remoteGuiTab.getButton(
"Test_args").clicked())
210 if (_remoteGuiTab.getButton(
"Test_wrongProxy").clicked())
212 StringVariantContainerBaseMap output =
213 _statechartExecutor->getSetOutputParameters();
217 SingleVariantPtr::dynamicCast(output[
"OutputInt"])->get()->get<
int>();
222 if (_remoteGuiTab.getButtonClicked(
"Run"))
226 _remoteGuiTab.sendUpdates();
227 c.waitForCycleDuration();
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
#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)
Brief description of class StatechartExecutorExample.
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)