diff --git a/scenarios/CMakeLists.txt b/scenarios/CMakeLists.txt index a2af915ff2dae8e5f67ab8a06f366d36a393987a..80acd6c86f7b5badbe08ddedcf909e44e33f9909 100644 --- a/scenarios/CMakeLists.txt +++ b/scenarios/CMakeLists.txt @@ -1,2 +1,3 @@ -add_subdirectory(WeissHapticSensorsUnitTest) \ No newline at end of file +add_subdirectory(WeissHapticSensorsUnitTest) +add_subdirectory(DummyTest) \ No newline at end of file diff --git a/scenarios/DummyTest/CMakeLists.txt b/scenarios/DummyTest/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e161430903c52c2d0677c74af2c9c66fbb1481ee --- /dev/null +++ b/scenarios/DummyTest/CMakeLists.txt @@ -0,0 +1,6 @@ +set(SCENARIO_COMPONENTS + DummyUnitApp + ) + +# optional 3rd parameter: "path/to/global/config.cfg" +armarx_scenario("DummyUnitTest" "${SCENARIO_COMPONENTS}") diff --git a/source/RobotAPI/applications/CMakeLists.txt b/source/RobotAPI/applications/CMakeLists.txt index 343addf16d384b97802185c482262eaea61242d9..560432bc17c56c06168cae8bdb283ef245eddeb5 100644 --- a/source/RobotAPI/applications/CMakeLists.txt +++ b/source/RobotAPI/applications/CMakeLists.txt @@ -20,3 +20,4 @@ add_subdirectory(PlatformUnitSimulation) add_subdirectory(PlatformUnitObserver) add_subdirectory(RobotStateComponent) add_subdirectory(RobotStateObserver) +add_subdirectory(DummyUnit) \ No newline at end of file diff --git a/source/RobotAPI/applications/DummyUnit/CMakeLists.txt b/source/RobotAPI/applications/DummyUnit/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1951cd058c6c9ba00fd8580b0a2147818186e621 --- /dev/null +++ b/source/RobotAPI/applications/DummyUnit/CMakeLists.txt @@ -0,0 +1,6 @@ +armarx_component_set_name("DummyUnitApp") + +set(COMPONENT_LIBS RobotAPIInterfaces RobotAPIUnits ArmarXCore) +set(EXE_SOURCE main.cpp DummyUnitApp.h) + +armarx_add_component_executable("${EXE_SOURCE}") diff --git a/source/RobotAPI/applications/DummyUnit/DummyUnitApp.h b/source/RobotAPI/applications/DummyUnit/DummyUnitApp.h new file mode 100644 index 0000000000000000000000000000000000000000..cfd6861b99233a61b97091dea5db7517aaa06bf1 --- /dev/null +++ b/source/RobotAPI/applications/DummyUnit/DummyUnitApp.h @@ -0,0 +1,42 @@ +/* + * 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 diff --git a/source/RobotAPI/applications/DummyUnit/main.cpp b/source/RobotAPI/applications/DummyUnit/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..56c78e7f2a620e5223afc0e507833d2c54b03e7e --- /dev/null +++ b/source/RobotAPI/applications/DummyUnit/main.cpp @@ -0,0 +1,32 @@ +/* + * 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); +} diff --git a/source/RobotAPI/interface/CMakeLists.txt b/source/RobotAPI/interface/CMakeLists.txt index 4fa3f1ba89d44f53b52ddfceee7786afec483ca9..194b47ee12e8b6916f4485cc563524f01c0197d8 100644 --- a/source/RobotAPI/interface/CMakeLists.txt +++ b/source/RobotAPI/interface/CMakeLists.txt @@ -26,6 +26,7 @@ set(SLICE_FILES units/TCPControlUnit.ice units/TCPMoverUnitInterface.ice units/UnitInterface.ice + units/DummyUnitInterface.ice ) # generate the interface library diff --git a/source/RobotAPI/interface/units/DummyUnitInterface.ice b/source/RobotAPI/interface/units/DummyUnitInterface.ice new file mode 100644 index 0000000000000000000000000000000000000000..71b89cae20dfe6b87975be5c6b270bfcdfcd673c --- /dev/null +++ b/source/RobotAPI/interface/units/DummyUnitInterface.ice @@ -0,0 +1,47 @@ +/* + * 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 diff --git a/source/RobotAPI/units/CMakeLists.txt b/source/RobotAPI/units/CMakeLists.txt index fd4a6fda6ed0eee68f165b88c9f6c7510ef8893c..6d796a84edb5c213d8fd19b904ef8220feeaf95f 100644 --- a/source/RobotAPI/units/CMakeLists.txt +++ b/source/RobotAPI/units/CMakeLists.txt @@ -46,6 +46,7 @@ set(LIB_HEADERS KinematicUnitObserver.h PlatformUnitObserver.h SensorActorUnit.h + DummyUnit.h ) set(LIB_FILES @@ -67,6 +68,7 @@ set(LIB_FILES KinematicUnitObserver.cpp PlatformUnitObserver.cpp SensorActorUnit.cpp + DummyUnit.cpp ) armarx_add_library("${LIB_NAME}" "${LIB_VERSION}" "${LIB_SOVERSION}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}") diff --git a/source/RobotAPI/units/DummyUnit.cpp b/source/RobotAPI/units/DummyUnit.cpp new file mode 100644 index 0000000000000000000000000000000000000000..46e5ee14b9531d3e9594585624cb5b74fea01625 --- /dev/null +++ b/source/RobotAPI/units/DummyUnit.cpp @@ -0,0 +1,51 @@ +/* + * 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())); +} diff --git a/source/RobotAPI/units/DummyUnit.h b/source/RobotAPI/units/DummyUnit.h new file mode 100644 index 0000000000000000000000000000000000000000..6873469398dda7e59ecaeabe6d0ce3f6276c4fcc --- /dev/null +++ b/source/RobotAPI/units/DummyUnit.h @@ -0,0 +1,73 @@ +/* + * 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 +