From 236ed8857cdfddfcefce659021be21c2ce8cbedb Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Tue, 8 Sep 2015 10:03:05 +0900 Subject: [PATCH] Modify the term "Diagnostics" to "Maintenance" in file names ThingsDignostics and DiagnosticsCollection files are renamed to ThingsMaintenance and MaintenanceCollection files. Update properties of Configuration resource "Device Name" and "Location Name" properties are added and "SystemTime" property is removed. Change-Id: I0f4028aea14997a6a35ae5660671e47aedb2b67b Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/2394 Tested-by: jenkins-iotivity Reviewed-by: Abhishek Pandey Reviewed-by: Madan Lanka --- .../linux/configuration/ConfigurationCollection.cpp | 17 +++++++++++++---- .../linux/configuration/ConfigurationCollection.h | 14 +++++++++----- .../linux/configuration/FactorySetCollection.cpp | 14 +++++++++++--- ...nosticsCollection.cpp => MaintenanceCollection.cpp} | 2 +- ...DiagnosticsCollection.h => MaintenanceCollection.h} | 2 +- .../sampleapp/linux/configuration/SConscript | 2 +- .../sampleapp/linux/configuration/bootstrapserver.cpp | 11 ++++++----- .../sampleapp/linux/configuration/con-client.cpp | 18 +++++++++++------- .../sampleapp/linux/configuration/con-server.cpp | 18 +++++++++++------- .../tizen/ConServerApp/inc/configurationresource.h | 2 +- .../tizen/ConServerApp/src/configurationresource.cpp | 4 ++-- service/things-manager/sdk/inc/ThingsConfiguration.h | 2 +- .../inc/{ThingsDiagnostics.h => ThingsMaintenance.h} | 0 service/things-manager/sdk/src/ThingsConfiguration.cpp | 5 +++-- .../{ThingsDiagnostics.cpp => ThingsMaintenance.cpp} | 2 +- 15 files changed, 72 insertions(+), 41 deletions(-) rename service/things-manager/sampleapp/linux/configuration/{DiagnosticsCollection.cpp => MaintenanceCollection.cpp} (99%) rename service/things-manager/sampleapp/linux/configuration/{DiagnosticsCollection.h => MaintenanceCollection.h} (99%) mode change 100644 => 100755 service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp mode change 100644 => 100755 service/things-manager/sampleapp/tizen/ConServerApp/inc/configurationresource.h mode change 100644 => 100755 service/things-manager/sampleapp/tizen/ConServerApp/src/configurationresource.cpp rename service/things-manager/sdk/inc/{ThingsDiagnostics.h => ThingsMaintenance.h} (100%) mode change 100644 => 100755 service/things-manager/sdk/src/ThingsConfiguration.cpp rename service/things-manager/sdk/src/{ThingsDiagnostics.cpp => ThingsMaintenance.cpp} (99%) diff --git a/service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.cpp b/service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.cpp index 4f3f2b9..a01b3c6 100755 --- a/service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.cpp +++ b/service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.cpp @@ -61,15 +61,22 @@ void ConfigurationResource::setConfigurationRepresentation(OCRepresentation& rep { string value; + if (rep.getValue("n", value)) + { + m_deviceName = value; + std::cout << "\t\t\t\t" << "m_deviceName: " << m_deviceName << std::endl; + } + if (rep.getValue("loc", value)) { m_location = value; std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl; } - if (rep.getValue("st", value)) + if (rep.getValue("locn", value)) { - std::cout << "\t\t\t\t" << "SystemTime is not allowed to be written." << std::endl; + m_locationName = value; + std::cout << "\t\t\t\t" << "m_locationName: " << m_locationName << std::endl; } if (rep.getValue("c", value)) @@ -87,8 +94,9 @@ void ConfigurationResource::setConfigurationRepresentation(OCRepresentation& rep OCRepresentation ConfigurationResource::getConfigurationRepresentation() { + m_configurationRep.setValue("n", m_deviceName); m_configurationRep.setValue("loc", m_location); - m_configurationRep.setValue("st", m_systemTime); + m_configurationRep.setValue("locn", m_locationName); m_configurationRep.setValue("c", m_currency); m_configurationRep.setValue("r", m_region); @@ -102,8 +110,9 @@ std::string ConfigurationResource::getUri() void ConfigurationResource::factoryReset() { + m_deviceName = defaultDeviceName; m_location = defaultLocation; - m_systemTime = defaultSystemTime; + m_locationName = defaultLocationName; m_currency = defaultCurrency; m_region = defaultRegion; } diff --git a/service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.h b/service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.h index 9b3e864..e40b6bd 100755 --- a/service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.h +++ b/service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.h @@ -38,8 +38,9 @@ typedef std::function< static std::string defaultConURI = "/oic/con"; static std::string defaultConResourceType = "oic.wk.con"; +extern std::string defaultDeviceName; extern std::string defaultLocation; -extern std::string defaultSystemTime; +extern std::string defaultLocationName; extern std::string defaultCurrency; extern std::string defaultRegion; @@ -48,8 +49,9 @@ class ConfigurationResource public: // Configuration members std::string m_configurationUri; + std::string m_deviceName; std::string m_location; - std::string m_systemTime; + std::string m_locationName; std::string m_currency; std::string m_region; std::vector< std::string > m_configurationTypes; @@ -60,14 +62,16 @@ public: public: /// Constructor ConfigurationResource() : - m_location(defaultLocation), m_systemTime(defaultSystemTime), m_currency( - defaultCurrency), m_region(defaultRegion) + m_deviceName(defaultDeviceName), m_location(defaultLocation), + m_locationName(defaultLocationName), m_currency(defaultCurrency), + m_region(defaultRegion) { m_configurationUri = defaultConURI; // URI of the resource m_configurationTypes.push_back(defaultConResourceType); // resource type name. m_configurationInterfaces.push_back(DEFAULT_INTERFACE); // resource interface. + m_configurationRep.setValue("st", m_deviceName); m_configurationRep.setValue("loc", m_location); - m_configurationRep.setValue("st", m_systemTime); + m_configurationRep.setValue("locn", m_locationName); m_configurationRep.setValue("c", m_currency); m_configurationRep.setValue("r", m_region); m_configurationRep.setUri(m_configurationUri); diff --git a/service/things-manager/sampleapp/linux/configuration/FactorySetCollection.cpp b/service/things-manager/sampleapp/linux/configuration/FactorySetCollection.cpp index aa8689e..bab6112 100755 --- a/service/things-manager/sampleapp/linux/configuration/FactorySetCollection.cpp +++ b/service/things-manager/sampleapp/linux/configuration/FactorySetCollection.cpp @@ -72,15 +72,22 @@ void FactorySetResource::setFactorySetRepresentation(OCRepresentation& rep) { string value; + if (rep.getValue("n", value)) + { + m_deviceName = value; + std::cout << "\t\t\t\t" << "m_deviceName: " << m_deviceName << std::endl; + } + if (rep.getValue("loc", value)) { m_location = value; std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl; } - if (rep.getValue("st", value)) + if (rep.getValue("locn", value)) { - std::cout << "\t\t\t\t" << "SystemTime is not allowed to be written." << std::endl; + m_locationName = value; + std::cout << "\t\t\t\t" << "m_locationName: " << m_locationName << std::endl; } if (rep.getValue("c", value)) @@ -98,8 +105,9 @@ void FactorySetResource::setFactorySetRepresentation(OCRepresentation& rep) OCRepresentation FactorySetResource::getFactorySetRepresentation() { + m_configurationRep.setValue("n", m_deviceName); m_configurationRep.setValue("loc", m_location); - m_configurationRep.setValue("st", m_systemTime); + m_configurationRep.setValue("locn", m_locationName); m_configurationRep.setValue("c", m_currency); m_configurationRep.setValue("r", m_region); diff --git a/service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.cpp b/service/things-manager/sampleapp/linux/configuration/MaintenanceCollection.cpp similarity index 99% rename from service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.cpp rename to service/things-manager/sampleapp/linux/configuration/MaintenanceCollection.cpp index d1dcb29..1b78dd8 100755 --- a/service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.cpp +++ b/service/things-manager/sampleapp/linux/configuration/MaintenanceCollection.cpp @@ -28,7 +28,7 @@ #include "OCPlatform.h" #include "OCApi.h" -#include "DiagnosticsCollection.h" +#include "MaintenanceCollection.h" using namespace OC; using namespace std; diff --git a/service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.h b/service/things-manager/sampleapp/linux/configuration/MaintenanceCollection.h similarity index 99% rename from service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.h rename to service/things-manager/sampleapp/linux/configuration/MaintenanceCollection.h index 1a182b5..09858c6 100755 --- a/service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.h +++ b/service/things-manager/sampleapp/linux/configuration/MaintenanceCollection.h @@ -46,7 +46,7 @@ class MaintenanceResource { public: - // diagnostics members + // Maintenance members std::string m_maintenanceUri; std::string m_factoryReset; std::string m_reboot; diff --git a/service/things-manager/sampleapp/linux/configuration/SConscript b/service/things-manager/sampleapp/linux/configuration/SConscript index 962b7f2..7285e13 100644 --- a/service/things-manager/sampleapp/linux/configuration/SConscript +++ b/service/things-manager/sampleapp/linux/configuration/SConscript @@ -53,7 +53,7 @@ if 'rt' in linux_sample_env.get('LIBS'): ###################################################################### #build sampleapp ###################################################################### -conserver = linux_sample_env.Program('con-server', ['ConfigurationCollection.cpp', 'DiagnosticsCollection.cpp', 'FactorySetCollection.cpp', 'con-server.cpp']) +conserver = linux_sample_env.Program('con-server', ['ConfigurationCollection.cpp', 'MaintenanceCollection.cpp', 'FactorySetCollection.cpp', 'con-server.cpp']) conclient = linux_sample_env.Program('con-client', 'con-client.cpp') bootstrapserver = linux_sample_env.Program('bootstrapserver', 'bootstrapserver.cpp') Alias("ConServerApp", conserver) diff --git a/service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp b/service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp old mode 100644 new mode 100755 index a1548e6..0b2f4f2 --- a/service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp +++ b/service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp @@ -37,11 +37,11 @@ bool prepareResponse(std::shared_ptr< OCResourceRequest > request); OCStackResult sendResponse(std::shared_ptr< OCResourceRequest > pRequest); OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest > request); -#define DefaultRegion "Seoul, Korea" -#define DefaultSystemTime "00:00:00" +#define DefaultDeviceName "Legacy Device" #define DefaultLocation "37.256616, 127.052806" +#define DefaultLocationName "Living Room" #define DefaultCurrency "Won" - +#define DefaultRegion "Seoul, Korea" class BootstrapResource { @@ -88,10 +88,11 @@ public: OCRepresentation getBootstrapRepresentation() { - m_bootstrapRep.setValue< std::string >("r", DefaultRegion); - m_bootstrapRep.setValue< std::string >("st", DefaultSystemTime); + m_bootstrapRep.setValue< std::string >("n", DefaultDeviceName); m_bootstrapRep.setValue< std::string >("loc", DefaultLocation); + m_bootstrapRep.setValue< std::string >("locn", DefaultLocationName); m_bootstrapRep.setValue< std::string >("c", DefaultCurrency); + m_bootstrapRep.setValue< std::string >("r", DefaultRegion); return m_bootstrapRep; } diff --git a/service/things-manager/sampleapp/linux/configuration/con-client.cpp b/service/things-manager/sampleapp/linux/configuration/con-client.cpp index 9786ca6..a7a67e9 100755 --- a/service/things-manager/sampleapp/linux/configuration/con-client.cpp +++ b/service/things-manager/sampleapp/linux/configuration/con-client.cpp @@ -29,7 +29,7 @@ #include "OCApi.h" //#include "ThingsManager.h" #include "ThingsConfiguration.h" -#include "ThingsDiagnostics.h" +#include "ThingsMaintenance.h" #include "GroupManager.h" using namespace OC; @@ -116,10 +116,12 @@ void onUpdate(const HeaderOptions& headerOptions, const OCRepresentation& rep, c std::cout << "\tResource URI: " << rep.getUri() << std::endl; + if (rep.hasAttribute("n")) + std::cout << "\t\tDeviceName:" << rep.getValue< std::string >("n") << std::endl; if (rep.hasAttribute("loc")) std::cout << "\t\tLocation:" << rep.getValue< std::string >("loc") << std::endl; - if (rep.hasAttribute("st")) - std::cout << "\t\tSystemTime:" << rep.getValue< std::string >("st") << std::endl; + if (rep.hasAttribute("locn")) + std::cout << "\t\tLocationName:" << rep.getValue< std::string >("locn") << std::endl; if (rep.hasAttribute("c")) std::cout << "\t\tCurrency:" << rep.getValue< std::string >("c") << std::endl; if (rep.hasAttribute("r")) @@ -139,10 +141,12 @@ void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, cons std::cout << "\tResource URI: " << rep.getUri() << std::endl; + if (rep.hasAttribute("n")) + std::cout << "\t\tDeviceName:" << rep.getValue< std::string >("n") << std::endl; if (rep.hasAttribute("loc")) std::cout << "\t\tLocation:" << rep.getValue< std::string >("loc") << std::endl; - if (rep.hasAttribute("st")) - std::cout << "\t\tSystemTime:" << rep.getValue< std::string >("st") << std::endl; + if (rep.hasAttribute("locn")) + std::cout << "\t\tLocationName:" << rep.getValue< std::string >("locn") << std::endl; if (rep.hasAttribute("c")) std::cout << "\t\tCurrency:" << rep.getValue< std::string >("c") << std::endl; if (rep.hasAttribute("r")) @@ -446,8 +450,8 @@ int main(int argc, char* argv[]) } else if (g_Steps == 4) { - ConfigurationName name = "r"; - ConfigurationValue value = "U.S.A (new region)"; + ConfigurationName name = "n"; + ConfigurationValue value = "OIC Device"; if(g_configurationCollection == NULL) { diff --git a/service/things-manager/sampleapp/linux/configuration/con-server.cpp b/service/things-manager/sampleapp/linux/configuration/con-server.cpp index 4d1ee17..136b22f 100755 --- a/service/things-manager/sampleapp/linux/configuration/con-server.cpp +++ b/service/things-manager/sampleapp/linux/configuration/con-server.cpp @@ -28,9 +28,9 @@ #include "OCPlatform.h" #include "OCApi.h" #include "ThingsConfiguration.h" -#include "ThingsDiagnostics.h" +#include "ThingsMaintenance.h" #include "ConfigurationCollection.h" -#include "DiagnosticsCollection.h" +#include "MaintenanceCollection.h" #include "FactorySetCollection.h" using namespace OC; @@ -44,9 +44,11 @@ pthread_mutex_t mutex_lock = PTHREAD_MUTEX_INITIALIZER; // Default system configuration value's variables // The variable's names should be same as the names of "extern" variables defined in // "ConfigurationResource.h" + +std::string defaultDeviceName; std::string defaultLocation; +std::string defaultLocationName; std::string defaultRegion; -std::string defaultSystemTime; std::string defaultCurrency; //static ThingsManager* g_thingsmanager; @@ -231,13 +233,15 @@ void onBootstrap(const HeaderOptions& headerOptions, const OCRepresentation& rep std::cout << "\n\nGET request was successful" << std::endl; std::cout << "\tResource URI: " << rep.getUri() << std::endl; + defaultDeviceName = rep.getValue< std::string >("n"); + defaultLocation = rep.getValue< std::string >("loc"); + defaultLocationName = rep.getValue< std::string >("locn"); defaultRegion = rep.getValue< std::string >("r"); - defaultSystemTime = rep.getValue< std::string >("st"); defaultCurrency = rep.getValue< std::string >("c"); - defaultLocation = rep.getValue< std::string >("loc"); + std::cout << "\tSystemTime : " << defaultDeviceName << std::endl; std::cout << "\tLocation : " << defaultLocation << std::endl; - std::cout << "\tSystemTime : " << defaultSystemTime << std::endl; + std::cout << "\tLocationName : " << defaultLocationName << std::endl; std::cout << "\tCurrency : " << defaultCurrency << std::endl; std::cout << "\tRegion : " << defaultRegion << std::endl; @@ -253,7 +257,7 @@ int main() OCPlatform::Configure(cfg); g_thingsConf = new ThingsConfiguration(); - //g_thingsDiag = new ThingsDiagnostics(); + //g_thingsDiag = new ThingsMaintenance(); //************************************************************** if (getuid() != 0) diff --git a/service/things-manager/sampleapp/tizen/ConServerApp/inc/configurationresource.h b/service/things-manager/sampleapp/tizen/ConServerApp/inc/configurationresource.h old mode 100644 new mode 100755 index 14bfd8b..9464c11 --- a/service/things-manager/sampleapp/tizen/ConServerApp/inc/configurationresource.h +++ b/service/things-manager/sampleapp/tizen/ConServerApp/inc/configurationresource.h @@ -37,7 +37,7 @@ static std::string defaultURIPrefix = "/oic/con"; static std::string defaultResourceTypePrefix = "oic.con"; extern std::string defaultLocation; -extern std::string defaultSystemTime; +extern std::string defaultDeviceName; extern std::string defaultCurrency; extern std::string defaultRegion; diff --git a/service/things-manager/sampleapp/tizen/ConServerApp/src/configurationresource.cpp b/service/things-manager/sampleapp/tizen/ConServerApp/src/configurationresource.cpp old mode 100644 new mode 100755 index 529a13f..daf72ed --- a/service/things-manager/sampleapp/tizen/ConServerApp/src/configurationresource.cpp +++ b/service/things-manager/sampleapp/tizen/ConServerApp/src/configurationresource.cpp @@ -31,7 +31,7 @@ using namespace OC; // Constructor ConfigurationResource::ConfigurationResource() : - m_location(defaultLocation), m_systemTime(defaultSystemTime), m_currency( + m_location(defaultLocation), m_systemTime(defaultDeviceName), m_currency( defaultCurrency), m_region(defaultRegion) { m_configurationUri = "/oic/con"; // URI of the resource @@ -124,7 +124,7 @@ std::string ConfigurationResource::getUri() void ConfigurationResource::factoryReset() { m_location = defaultLocation; - m_systemTime = defaultSystemTime; + m_systemTime = defaultDeviceName; m_currency = defaultCurrency; m_region = defaultRegion; } diff --git a/service/things-manager/sdk/inc/ThingsConfiguration.h b/service/things-manager/sdk/inc/ThingsConfiguration.h index a45326d..517fdc9 100755 --- a/service/things-manager/sdk/inc/ThingsConfiguration.h +++ b/service/things-manager/sdk/inc/ThingsConfiguration.h @@ -97,7 +97,7 @@ namespace OIC std::string getJSON(); }; -#define NUMCONFUNIT 5 +#define NUMCONFUNIT 6 typedef std::string ConfigurationName; typedef std::string ConfigurationValue; diff --git a/service/things-manager/sdk/inc/ThingsDiagnostics.h b/service/things-manager/sdk/inc/ThingsMaintenance.h similarity index 100% rename from service/things-manager/sdk/inc/ThingsDiagnostics.h rename to service/things-manager/sdk/inc/ThingsMaintenance.h diff --git a/service/things-manager/sdk/src/ThingsConfiguration.cpp b/service/things-manager/sdk/src/ThingsConfiguration.cpp old mode 100644 new mode 100755 index 9c68645..d148b29 --- a/service/things-manager/sdk/src/ThingsConfiguration.cpp +++ b/service/things-manager/sdk/src/ThingsConfiguration.cpp @@ -73,9 +73,10 @@ namespace OIC ConfigurationUnitInfo unit[] = { { "all", "All attributes", "/oic/con" }, - { "r", "Region", "/oic/con" }, - { "st", "System Time", "/oic/con"}, + { "n", "Device Name", "/oic/con"}, { "loc", "Location", "/oic/con"}, + { "locn", "Location Name", "/oic/con"}, + { "r", "Region", "/oic/con" }, { "c","Currency", "/oic/con" } }; for (int i = 0; i < NUMCONFUNIT; i++) diff --git a/service/things-manager/sdk/src/ThingsDiagnostics.cpp b/service/things-manager/sdk/src/ThingsMaintenance.cpp similarity index 99% rename from service/things-manager/sdk/src/ThingsDiagnostics.cpp rename to service/things-manager/sdk/src/ThingsMaintenance.cpp index b9cf49b..bf3361e 100755 --- a/service/things-manager/sdk/src/ThingsDiagnostics.cpp +++ b/service/things-manager/sdk/src/ThingsMaintenance.cpp @@ -27,7 +27,7 @@ #include #include -#include "ThingsDiagnostics.h" +#include "ThingsMaintenance.h" using namespace OC; -- 2.7.4