diff options
author | Marco Residori <marco_residori@mentor.com> | 2015-11-03 16:08:00 +0100 |
---|---|---|
committer | Marco Residori <marco_residori@mentor.com> | 2015-11-03 16:08:00 +0100 |
commit | 84c5768f082b3bac9583b5963ca2014174f726e3 (patch) | |
tree | b730a35d4b577fa31881c3077bd6a627c1bfa707 | |
parent | 6d53ef1f4ce53f5f1a92ccb9b6c87b873299814d (diff) | |
download | positioning-84c5768f082b3bac9583b5963ca2014174f726e3.tar.gz |
Add implementation of D-Bus method SetProperty of Configuration interface, add python test of Configuration interface
-rw-r--r-- | enhanced-position-service/dbus/src/configuration.cpp | 27 | ||||
-rw-r--r-- | enhanced-position-service/dbus/src/configuration.h | 4 | ||||
-rwxr-xr-x | enhanced-position-service/dbus/test/test-scripts/run-enhanced-position-service.sh | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | enhanced-position-service/dbus/test/test-scripts/test-configuration-interface.py (renamed from enhanced-position-service/dbus/test/test-scripts/test-enhanced-position-service-configuration.py) | 48 | ||||
-rwxr-xr-x | enhanced-position-service/dbus/test/test-scripts/test-enhanced-position-service.py | 2 |
5 files changed, 55 insertions, 28 deletions
diff --git a/enhanced-position-service/dbus/src/configuration.cpp b/enhanced-position-service/dbus/src/configuration.cpp index 385a7f9..8af7047 100644 --- a/enhanced-position-service/dbus/src/configuration.cpp +++ b/enhanced-position-service/dbus/src/configuration.cpp @@ -72,7 +72,9 @@ static DBus::Variant variant_array_uint32(std::vector< uint32_t > i) } Configuration::Configuration(DBus::Connection &connection, const char * path) - : DBus::ObjectAdaptor(connection, path) +: DBus::ObjectAdaptor(connection, path) +, mUpdateInterval(0) +, mSatelliteSystem(0) { } @@ -96,15 +98,32 @@ std::map< std::string, ::DBus::Variant > Configuration::GetProperties() { std::map< std::string, ::DBus::Variant > Properties; - Properties["UpdateInterval"] = variant_int32(1000); - Properties["SatelliteSystem"] = variant_uint32(GENIVI_ENHANCEDPOSITIONSERVICE_GPS|GENIVI_ENHANCEDPOSITIONSERVICE_GLONASS); + Properties["UpdateInterval"] = variant_int32(mUpdateInterval); + Properties["SatelliteSystem"] = variant_uint32(mSatelliteSystem); return Properties; } void Configuration::SetProperty(const std::string& name, const ::DBus::Variant& value) { - throw DBus::ErrorNotSupported("Method not supported yet"); + if(name == "UpdateInterval") + { + mUpdateInterval = value; + + LOG_INFO(gCtx,"UpdateInterval = %d", mUpdateInterval); + + PropertyChanged("UpdateInterval", value); + } + + if(name == "SatelliteSystem") + { + mSatelliteSystem = value; + + LOG_INFO(gCtx,"SatelliteSystem = %d", mSatelliteSystem); + + PropertyChanged("SatelliteSystem", value); + } + } std::map< std::string, ::DBus::Variant > Configuration::GetSupportedProperties() diff --git a/enhanced-position-service/dbus/src/configuration.h b/enhanced-position-service/dbus/src/configuration.h index 78c319a..35e6c6b 100644 --- a/enhanced-position-service/dbus/src/configuration.h +++ b/enhanced-position-service/dbus/src/configuration.h @@ -44,6 +44,10 @@ public: void shutdown(); +private: + + int32_t mUpdateInterval; + uint32_t mSatelliteSystem; }; #endif//__CONFIGURATION_H diff --git a/enhanced-position-service/dbus/test/test-scripts/run-enhanced-position-service.sh b/enhanced-position-service/dbus/test/test-scripts/run-enhanced-position-service.sh index 51a245f..c2f1112 100755 --- a/enhanced-position-service/dbus/test/test-scripts/run-enhanced-position-service.sh +++ b/enhanced-position-service/dbus/test/test-scripts/run-enhanced-position-service.sh @@ -35,7 +35,7 @@ if [ $# -ge 1 ]; then echo "Starting log-replayer..." eval "$TOP_DIR/build/log-replayer/src/log-replayer $LOG > /dev/null 2>&1" & echo "Starting enhanced-position-service..." - eval "$TOP_DIR/build/enhanced-position-service/dbus/src/enhanced-position-service > /dev/null 2>&1" & + eval "$TOP_DIR/build/enhanced-position-service/dbus/src/enhanced-position-service" & elif [ $1 = "-k" ]; then killall log-replayer killall enhanced-position-service diff --git a/enhanced-position-service/dbus/test/test-scripts/test-enhanced-position-service-configuration.py b/enhanced-position-service/dbus/test/test-scripts/test-configuration-interface.py index 44c6855..f35bf92 100755..100644 --- a/enhanced-position-service/dbus/test/test-scripts/test-enhanced-position-service-configuration.py +++ b/enhanced-position-service/dbus/test/test-scripts/test-configuration-interface.py @@ -5,14 +5,14 @@ * @licence app begin@ * SPDX-License-Identifier: MPL-2.0 * -* \copyright Copyright (C) 2014, XS Embedded GmbH +* \copyright Copyright (C) 2015, Mentor Graphics * -* \file test-enhanced-position-service.py +* \file test-configuration-interface.py * -* \brief This simple test shows how the enhanced-position-service -* can be easily tested using a python script +* \brief This simple test shows how the configuration interface of the +* enhanced-position-service can be easily tested using a python script * -* \author Marco Residori <marco.residori@xse.de> +* \author Marco Residori <marco_residori@mentor.com> * * \version 1.0 * @@ -30,16 +30,12 @@ import dbus import gobject import dbus.mainloop.glib -#constants as defined in the Positioning API -LATITUDE = 0x00000001 -LONGITUDE = 0x00000002 -ALTITUDE = 0x00000004 -CLIMB = 0x00000020 -SPEED = 0x00000010 -HEADING = 0x00000008 +#test constants +UPDATE_INTERVAL = 1500 +SATELLITE_SYSTEM = 2 print '\n--------------------------' -print 'Positioning Test' +print 'Configuration Interface Test' print '--------------------------\n' if __name__ == '__main__': @@ -49,11 +45,22 @@ if __name__ == '__main__': bus = dbus.SessionBus() #signal receiver -def catchall_positioning_signals_handler(changedValues): +def catchall_positioning_signals_handler(changedProperty, propertyValue): + print 'PropertyChanged' - satSystem = enhanced_position_interface.GetProperty(dbus.String("SatelliteSystem")) + + if changedProperty == 'SatelliteSystem': + print 'SatelliteSystem:' + str(propertyValue) + if propertyValue != SATELLITE_SYSTEM: + print '\nTest Failed:' + str(propertyValue) + '!=' + str(SATELLITE_SYSTEM) + '\n' + loop.quit() + - print 'SatelliteSystem:' +str(satSystem) + if changedProperty == 'UpdateInterval': + print 'UpdateInterval:' + str(propertyValue) + if propertyValue != UPDATE_INTERVAL: + print '\nTest Failed:' + str(propertyValue) + '!=' + str(UPDATE_INTERVAL) + '\n' + loop.quit() #add signal receiver @@ -72,15 +79,12 @@ enhanced_position = bus.get_object('org.genivi.positioning.EnhancedPosition','/o #get interface enhanced_position_interface = dbus.Interface(enhanced_position, dbus_interface='org.genivi.positioning.Configuration') -#enhanced_position_interface.SetProperty(dbus.String('SatelliteSystem'),dbus.UInt32(2, variant_level=1)) -enhanced_position_interface.SetProperty(dbus.String('UpdateInterval'),dbus.UInt32(2, variant_level=1)) +enhanced_position_interface.SetProperty(dbus.String('SatelliteSystem'),dbus.UInt32(SATELLITE_SYSTEM, variant_level=1)) -#satSystem = enhanced_position_interface.GetProperty(dbus.String('SatelliteSystem')) -#print 'SatelliteSystem:' + str(satSystem) +enhanced_position_interface.SetProperty('UpdateInterval', dbus.Int32(UPDATE_INTERVAL, variant_level=1)) #main loop - -gobject.timeout_add(10000, timeout) +gobject.timeout_add(3000, timeout) loop = gobject.MainLoop() loop.run() diff --git a/enhanced-position-service/dbus/test/test-scripts/test-enhanced-position-service.py b/enhanced-position-service/dbus/test/test-scripts/test-enhanced-position-service.py index ee784aa..3efd1ac 100755 --- a/enhanced-position-service/dbus/test/test-scripts/test-enhanced-position-service.py +++ b/enhanced-position-service/dbus/test/test-scripts/test-enhanced-position-service.py @@ -53,7 +53,7 @@ def catchall_positioning_signals_handler(changedValues): print 'PositonUpdate' position = enhanced_position_interface.GetPositionInfo(changedValues) timestamp = position[0] - print 'TIMESTAMP:' +str(timestamp) + print 'TIMESTAMP:' + str(timestamp) data = position[1] #print(data) for key in data: |