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

Added DummyUnit and DummyObserver as simple examples for the documentation

parent fc80da40
No related branches found
No related tags found
No related merge requests found
Showing
with 421 additions and 1 deletion
set(SCENARIO_COMPONENTS
DummyUnitApp
DummyUnitObserver
)
# optional 3rd parameter: "path/to/global/config.cfg"
......
# ==================================================================
# ArmarX properties
# ==================================================================
# ArmarX.DataPath: Semicolon-separated search list for data files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DataPath = ""
# ArmarX.Verbosity: Global logging level for whole application
# Attributes:
# - Default: Verbose
# - Case sensitivity: no
# - Required: no
# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning}
# ArmarX.Verbosity = Verbose
# ArmarX.DisableLogging: Turn logging off in whole application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# - Possible values: {0, 1, false, no, true, yes}
# ArmarX.DisableLogging = 0
# ArmarX.CachePath: Path for cache files
# Attributes:
# - Default: ${HOME}/.armarx/mongo/.cache
# - Case sensitivity: no
# - Required: no
# ArmarX.CachePath = ${HOME}/.armarx/mongo/.cache
# ArmarX.ApplicationName: Application name
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ApplicationName = ""
# ArmarX.Config: Comma-separated list of configuration files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.Config = ""
# ==================================================================
# ArmarX.DummyUnit properties
# ==================================================================
# ArmarX.DummyUnit.ReportPeriod: The unit's reporting period in ms
# Attributes:
# - Case sensitivity: no
# - Required: yes
ArmarX.DummyUnit.ReportPeriod = 1000
# ArmarX.DummyUnit.MinimumLoggingLevel: Local logging level only for this component
# Attributes:
# - Default: Undefined
# - Case sensitivity: no
# - Required: no
# - Possible values: {Error, Fatal, Info, Undefined, Verbose, Warning}
# ArmarX.DummyUnit.MinimumLoggingLevel = Undefined
# ArmarX.DummyUnit.ObjectName: Name of IceGrid well-known object
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DummyUnit.ObjectName = ""
# ==================================================================
# ArmarX properties
# ==================================================================
# ArmarX.DataPath: Semicolon-separated search list for data files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DataPath = ""
# ArmarX.Verbosity: Global logging level for whole application
# Attributes:
# - Default: Verbose
# - Case sensitivity: no
# - Required: no
# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning}
# ArmarX.Verbosity = Verbose
# ArmarX.DisableLogging: Turn logging off in whole application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# - Possible values: {0, 1, false, no, true, yes}
# ArmarX.DisableLogging = 0
# ArmarX.CachePath: Path for cache files
# Attributes:
# - Default: ${HOME}/.armarx/mongo/.cache
# - Case sensitivity: no
# - Required: no
# ArmarX.CachePath = ${HOME}/.armarx/mongo/.cache
# ArmarX.ApplicationName: Application name
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ApplicationName = ""
# ArmarX.Config: Comma-separated list of configuration files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.Config = ""
# ==================================================================
# ArmarX.DummyUnitObserver properties
# ==================================================================
# ArmarX.DummyUnitObserver.ReportPeriod: The unit's reporting period in ms
# Attributes:
# - Case sensitivity: no
# - Required: yes
ArmarX.DummyUnitObserver.ReportPeriod = <set value!>
# ArmarX.DummyUnitObserver.MinimumLoggingLevel: Local logging level only for this component
# Attributes:
# - Default: Undefined
# - Case sensitivity: no
# - Required: no
# - Possible values: {Error, Fatal, Info, Undefined, Verbose, Warning}
# ArmarX.DummyUnitObserver.MinimumLoggingLevel = Undefined
# ArmarX.DummyUnitObserver.ObjectName: Name of IceGrid well-known object
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DummyUnitObserver.ObjectName = ""
......@@ -21,3 +21,6 @@ add_subdirectory(PlatformUnitObserver)
add_subdirectory(RobotStateComponent)
add_subdirectory(RobotStateObserver)
add_subdirectory(HandUnitObserver)
add_subdirectory(DummyUnit)
add_subdirectory(DummyUnitObserver)
armarx_component_set_name(DummyUnitObserver)
set(COMPONENT_LIBS RobotAPIUnits RobotAPICore RobotAPIInterfaces ArmarXInterfaces ArmarXCore ArmarXCoreObservers)
set(SOURCES main.cpp DummyUnitObserverApp.h)
armarx_add_component_executable("${SOURCES}")
/*
* 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
*/
#include <Core/core/application/Application.h>
#include <RobotAPI/units/DummyUnitObserver.h>
namespace armarx
{
class DummyUnitObserverApp :
virtual public armarx::Application
{
void setup(const ManagedIceObjectRegistryInterfacePtr& registry, Ice::PropertiesPtr properties)
{
registry->addObject( Component::create<DummyUnitObserver>(properties) );
}
};
}
/*
* 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
*/
#include "DummyUnitObserverApp.h"
#include <Core/core/logging/Logging.h>
int main(int argc, char* argv[])
{
armarx::ApplicationPtr app = armarx::Application::createInstance<armarx::DummyUnitObserverApp>();
app->setName("DummyUnitObserver");
return app->main(argc, argv);
}
......@@ -9,6 +9,7 @@ set(SLICE_FILES
observers/KinematicUnitObserverInterface.ice
observers/PlatformUnitObserverInterface.ice
observers/DummyUnitObserverInterface.ice
robotstate/LinkedPoseBase.ice
robotstate/PoseBase.ice
......
/*
* 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_CORE_DUMMY_UNIT_OBSERVER_SLICE_
#define _ARMARX_CORE_DUMMY_UNIT_OBSERVER_SLICE_
#include <RobotAPI/interface/units/DummyUnitInterface.ice>
#include <Core/interface/observers/ObserverInterface.ice>
module armarx
{
interface DummyUnitObserverInterface extends ObserverInterface, DummyUnitListener
{
};
};
#endif
......@@ -26,6 +26,7 @@
#include <RobotAPI/interface/units/UnitInterface.ice>
#include <Core/interface/observers/VariantBase.ice>
#include <Core/interface/observers/ObserverInterface.ice>
/*
* The DummyUnit is a SensorActorUnit that is only implemented for documentation
......
......@@ -48,6 +48,7 @@ set(LIB_HEADERS
PlatformUnitObserver.h
SensorActorUnit.h
DummyUnit.h
DummyUnitObserver.h
)
set(LIB_FILES
......@@ -71,6 +72,7 @@ set(LIB_FILES
PlatformUnitObserver.cpp
SensorActorUnit.cpp
DummyUnit.cpp
DummyUnitObserver.cpp
)
armarx_add_library("${LIB_NAME}" "${LIB_VERSION}" "${LIB_SOVERSION}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}")
......@@ -29,12 +29,21 @@ void DummyUnit::onInitComponent()
{
period = getProperty<int>("ReportPeriod").getValue();
periodicValue = VariantPtr(new Variant(10));
offeringTopic("PeriodicDummyValue");
}
void DummyUnit::onConnectComponent()
{
listenerPrx = getTopic<DummyUnitListenerPrx>("PeriodicDummyValue");
if(periodicTask)
{
periodicTask->stop();
}
periodicTask = new PeriodicTask<DummyUnit>(this, &DummyUnit::reportValue, period, false, "DummyValueProducer");
periodicTask->start();
}
void DummyUnit::onExitComponent()
......@@ -43,9 +52,15 @@ void DummyUnit::onExitComponent()
void DummyUnit::setPeriodicValue(const VariantBasePtr &value, const Ice::Current &c)
{
periodicValue = VariantPtr::dynamicCast(value);
}
PropertyDefinitionsPtr DummyUnit::createPropertyDefinitions()
{
return PropertyDefinitionsPtr(new DummyUnitPropertyDefinitions(getConfigIdentifier()));
}
void DummyUnit::reportValue()
{
listenerPrx->reportPeriodicValue(periodicValue);
}
......@@ -30,6 +30,7 @@
#include <Core/core/application/properties/Properties.h>
#include <Core/core/system/ImportExportComponent.h>
#include <Core/observers/variant/Variant.h>
#include <Core/core/services/tasks/PeriodicTask.h>
#include <RobotAPI/interface/units/DummyUnitInterface.h>
......@@ -62,10 +63,14 @@ namespace armarx
virtual PropertyDefinitionsPtr createPropertyDefinitions();
protected:
void reportValue();
DummyUnitListenerPrx listenerPrx;
PeriodicTask<DummyUnit>::pointer_type periodicTask;
int period;
Variant value;
VariantPtr periodicValue;
};
}
......
/*
* 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 "DummyUnitObserver.h"
armarx::DummyUnitObserver::DummyUnitObserver()
{
}
void armarx::DummyUnitObserver::onInitObserver()
{
usingTopic("PeriodicDummyValue");
}
void armarx::DummyUnitObserver::onConnectObserver()
{
}
void armarx::DummyUnitObserver::reportPeriodicValue(const armarx::VariantBasePtr &value, const Ice::Current &)
{
ARMARX_INFO << VariantPtr::dynamicCast(value);
}
armarx::PropertyDefinitionsPtr armarx::DummyUnitObserver::createPropertyDefinitions()
{
return armarx::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_ROBOTAPI_DUMMYUNIT_OBSERVER_H
#define _ARMARX_ROBOTAPI_DUMMYUNIT_OBSERVER_H
#include <RobotAPI/interface/observers/DummyUnitObserverInterface.h>
#include <Core/observers/Observer.h>
#include <Core/core/application/properties/Properties.h>
namespace armarx
{
class DummyUnitPropertyDefinitions : public ComponentPropertyDefinitions
{
public:
DummyUnitPropertyDefinitions(std::string prefix) :
ComponentPropertyDefinitions(prefix)
{
// No required properties
}
};
class DummyUnitObserver :
virtual public Observer,
virtual public DummyUnitObserverInterface
{
public:
DummyUnitObserver();
virtual std::string getDefaultName() const { return "DummyUnitObserver"; }
void onInitObserver();
void onConnectObserver();
void reportPeriodicValue(const VariantBasePtr &value, const ::Ice::Current& = ::Ice::Current());
virtual PropertyDefinitionsPtr createPropertyDefinitions();
};
}
#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