Skip to content
Snippets Groups Projects
Commit 927b700b authored by Peter Kaiser's avatar Peter Kaiser
Browse files

Units: Added DummyUnit as minimum working example for documentation

parent 8894ac3d
No related branches found
No related tags found
No related merge requests found
add_subdirectory(WeissHapticSensorsUnitTest) add_subdirectory(WeissHapticSensorsUnitTest)
\ No newline at end of file add_subdirectory(DummyTest)
\ No newline at end of file
set(SCENARIO_COMPONENTS
DummyUnitApp
)
# optional 3rd parameter: "path/to/global/config.cfg"
armarx_scenario("DummyUnitTest" "${SCENARIO_COMPONENTS}")
...@@ -20,3 +20,4 @@ add_subdirectory(PlatformUnitSimulation) ...@@ -20,3 +20,4 @@ add_subdirectory(PlatformUnitSimulation)
add_subdirectory(PlatformUnitObserver) add_subdirectory(PlatformUnitObserver)
add_subdirectory(RobotStateComponent) add_subdirectory(RobotStateComponent)
add_subdirectory(RobotStateObserver) add_subdirectory(RobotStateObserver)
add_subdirectory(DummyUnit)
\ No newline at end of file
armarx_component_set_name("DummyUnitApp")
set(COMPONENT_LIBS RobotAPIInterfaces RobotAPIUnits ArmarXCore)
set(EXE_SOURCE main.cpp DummyUnitApp.h)
armarx_add_component_executable("${EXE_SOURCE}")
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::application::DummyUnit
* @author Peter Kaiser (peter dot kaiser at kit dot edu)
* @date 2014
* @copyright http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#ifndef _ARMARX_APPLICATION_RobotAPI_DummyUnit_H
#define _ARMARX_APPLICATION_RobotAPI_DummyUnit_H
#include <Core/core/application/Application.h>
#include <RobotAPI/units/DummyUnit.h>
namespace armarx
{
class DummyUnitApp :
virtual public armarx::Application
{
void setup(const ManagedIceObjectRegistryInterfacePtr& registry, Ice::PropertiesPtr properties)
{
registry->addObject(Component::create<DummyUnit>(properties));
}
};
}
#endif
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::application::DummyUnitApp
* @author Peter Kaiser (peter dot kaiser at kit dot edu)
* @date 2014
* @copyright http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#include "DummyUnitApp.h"
int main(int argc, char* argv[])
{
armarx::ApplicationPtr app = armarx::Application::createInstance <armarx::DummyUnitApp>();
app->setName("DummyUnit");
return app->main(argc, argv);
}
...@@ -26,6 +26,7 @@ set(SLICE_FILES ...@@ -26,6 +26,7 @@ set(SLICE_FILES
units/TCPControlUnit.ice units/TCPControlUnit.ice
units/TCPMoverUnitInterface.ice units/TCPMoverUnitInterface.ice
units/UnitInterface.ice units/UnitInterface.ice
units/DummyUnitInterface.ice
) )
# generate the interface library # generate the interface library
......
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package ArmarX::RobotAPI
* @author Peter Kaiser (peter dot kaiser at kit dot edu)
* @copyright 2014
* @license http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#ifndef _ARMARX_CORE_DUMMYUNIT_SLICE_
#define _ARMARX_CORE_DUMMYUNIT_SLICE_
#include <RobotAPI/interface/units/UnitInterface.ice>
#include <Core/interface/observers/VariantBase.ice>
/*
* The DummyUnit is a SensorActorUnit that is only implemented for documentation
* purposes. It is designed to be a minimum working example and has no real use.
*/
module armarx
{
interface DummyUnitInterface extends SensorActorUnitInterface
{
void setPeriodicValue(VariantBase value);
};
interface DummyUnitListener
{
void reportPeriodicValue(VariantBase value);
};
};
#endif
...@@ -46,6 +46,7 @@ set(LIB_HEADERS ...@@ -46,6 +46,7 @@ set(LIB_HEADERS
KinematicUnitObserver.h KinematicUnitObserver.h
PlatformUnitObserver.h PlatformUnitObserver.h
SensorActorUnit.h SensorActorUnit.h
DummyUnit.h
) )
set(LIB_FILES set(LIB_FILES
...@@ -67,6 +68,7 @@ set(LIB_FILES ...@@ -67,6 +68,7 @@ set(LIB_FILES
KinematicUnitObserver.cpp KinematicUnitObserver.cpp
PlatformUnitObserver.cpp PlatformUnitObserver.cpp
SensorActorUnit.cpp SensorActorUnit.cpp
DummyUnit.cpp
) )
armarx_add_library("${LIB_NAME}" "${LIB_VERSION}" "${LIB_SOVERSION}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}") armarx_add_library("${LIB_NAME}" "${LIB_VERSION}" "${LIB_SOVERSION}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}")
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::units
* @author Peter Kaiser (peter dot kaiser at kit dot edu)
* @date 2014
* @copyright http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#include "DummyUnit.h"
using namespace armarx;
void DummyUnit::onInitComponent()
{
period = getProperty<int>("ReportPeriod").getValue();
offeringTopic("PeriodicDummyValue");
}
void DummyUnit::onConnectComponent()
{
listenerPrx = getTopic<DummyUnitListenerPrx>("PeriodicDummyValue");
}
void DummyUnit::onExitComponent()
{
}
void DummyUnit::setPeriodicValue(const VariantBasePtr &value, const Ice::Current &c)
{
}
PropertyDefinitionsPtr DummyUnit::createPropertyDefinitions()
{
return PropertyDefinitionsPtr(new DummyUnitPropertyDefinitions(getConfigIdentifier()));
}
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::units
* @author Peter Kaiser (peter dot kaiser at kit dot edu)
* @date 2014
* @copyright http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#ifndef _ARMARX_COMPONENT_DUMMY_UNIT_H
#define _ARMARX_COMPONENT_DUMMY_UNIT_H
#include <RobotAPI/units/SensorActorUnit.h>
#include <Core/core/Component.h>
#include <Core/core/application/properties/Properties.h>
#include <Core/core/system/ImportExportComponent.h>
#include <Core/observers/variant/Variant.h>
#include <RobotAPI/interface/units/DummyUnitInterface.h>
namespace armarx
{
class DummyUnitPropertyDefinitions:
public ComponentPropertyDefinitions
{
public:
DummyUnitPropertyDefinitions(std::string prefix):
ComponentPropertyDefinitions(prefix)
{
defineRequiredProperty<int>("ReportPeriod","The unit's reporting period in ms");
}
};
class DummyUnit :
virtual public DummyUnitInterface,
virtual public SensorActorUnit
{
public:
virtual std::string getDefaultName() const { return "DummyUnit"; }
virtual void onInitComponent();
virtual void onConnectComponent();
virtual void onExitComponent();
virtual void setPeriodicValue(const VariantBasePtr &value, const Ice::Current& c = ::Ice::Current());
virtual PropertyDefinitionsPtr createPropertyDefinitions();
protected:
DummyUnitListenerPrx listenerPrx;
int period;
Variant value;
};
}
#endif
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