From: jk13 Date: Fri, 28 Nov 2014 06:30:17 +0000 (+0900) Subject: [SSM] Reflect current OIC api style and add Tizen Inproc Sample X-Git-Tag: 1.2.0+RC1~2074^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94fab6ec3ecefa29af11763fb3135cbf6d84f2e4;p=platform%2Fupstream%2Fiotivity.git [SSM] Reflect current OIC api style and add Tizen Inproc Sample Problem: Need to reflect new OIC API design To provide Tizen Inproc sample How: Change SSM OIC wrapping class to reflect current OIC api sets Modify previous Tizen sample to use Inproc API Change-Id: I3cde8a769684375cf03678f2af945f680fa85ca5 Signed-off-by: jk13 --- diff --git a/service/soft-sensor-manager/SDK/build/linux/Makefile b/service/soft-sensor-manager/SDK/build/linux/Makefile index cd76579..323937b 100644 --- a/service/soft-sensor-manager/SDK/build/linux/Makefile +++ b/service/soft-sensor-manager/SDK/build/linux/Makefile @@ -1,4 +1,4 @@ - +-include ../../../build/linux/root_path.inc -include ../../../build/linux/environment.mk BOOST=${BOOST_BASE} @@ -6,12 +6,14 @@ SRC_PATH=../../src INC_PATH=../../include RST_NAME=release +GAR=ar + # Insert your project name. -TARGET=SDKlib +TARGET=${SSM_LIB} CXX=g++ CXX_FLAGS=-std=c++0x -Wall -pthread -DLINUX -CXX_INC=-I../../ -I${INC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} +CXX_INC=-I../../ -I${INC_PATH}/ -I${FD_SSMCORE}/include -I${FD_SSMCORE}/src -I${IOT_BASE}/include/ -I${IOT_LOG_DIR}/include -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} CXX_LIB= SRCLIST=${wildcard ${SRC_PATH}/*.cpp} @@ -30,7 +32,7 @@ pre_job: @echo " " ${TARGET}: ${OBJLIST} - @cp -Rdp ./*.o ./${RST_NAME}/ + ${GAR} -r ./${RST_NAME}/$@ ./*.o @cp -Rdp ${INC_PATH}/*.h ./${RST_NAME}/ @echo " " diff --git a/service/soft-sensor-manager/SDK/include/SSMClient.h b/service/soft-sensor-manager/SDK/include/SSMClient.h index 1ee47bd..36d6d57 100644 --- a/service/soft-sensor-manager/SDK/include/SSMClient.h +++ b/service/soft-sensor-manager/SDK/include/SSMClient.h @@ -168,7 +168,6 @@ class SSMClient { private: SSMReturn m_retResponse; - OCPlatform *m_pPlatform; CSemaphore m_sem; /** * @brief SoftSensorManager Resource. @@ -233,11 +232,16 @@ class SSMClient // friend option. for callback from SSMResource void onFoundResource(std::shared_ptr< OCResource > resource); - void onCreateQueryEngine(const OCRepresentation &rep, const int eCode); - void onReleaseQueryEngine(const OCRepresentation &rep, const int eCode); - void onRegisterQuery(const OCRepresentation &rep, const int eCode); - void onUnregisterQuery(const OCRepresentation &rep, const int eCode); - void onObserve(const OCRepresentation &rep, const int &eCode); + void onCreateQueryEngine(const HeaderOptions &headerOptions, const OCRepresentation &rep, + const int eCode); + void onReleaseQueryEngine(const HeaderOptions &headerOptions, const OCRepresentation &rep, + const int eCode); + void onRegisterQuery(const HeaderOptions &headerOptions, const OCRepresentation &rep, + const int eCode); + void onUnregisterQuery(const HeaderOptions &headerOptions, const OCRepresentation &rep, + const int eCode); + void onObserve(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int &eCode, + const int &sequenceNumber); }; #endif /* RESOURCECLIENT_H_ */ diff --git a/service/soft-sensor-manager/SDK/src/SSMClient.cpp b/service/soft-sensor-manager/SDK/src/SSMClient.cpp index 174456c..4f0b574 100644 --- a/service/soft-sensor-manager/SDK/src/SSMClient.cpp +++ b/service/soft-sensor-manager/SDK/src/SSMClient.cpp @@ -29,17 +29,11 @@ const char *SSM_RESOURCE_URI = "/service/SoftSensorManager"; #define SSM_RESOURCE_TYPE = "core.SoftSensorManager" -#define COAP_IP "134.134.161.33" -#define COAP_PORT 5683 -#define COAP_MODE ModeType::Client -#define COAP_SRVTYPE ServiceType::InProc - #define COAP_SERVER_ADDR "coap://224.0.1.187/oc/core?rt=core.SoftSensorManager" SSMClient::SSMClient() { m_sem.create(100000); - m_pPlatform = NULL; m_appListener = NULL; m_retResponse = SSM_ERROR; _findResource(); @@ -49,34 +43,30 @@ SSMClient::SSMClient() SSMClient::~SSMClient() { _releaseQueryEngine(m_queryEngineId); - if (m_pPlatform) - { - delete m_pPlatform; - m_pPlatform = NULL; - } } void SSMClient::_findResource() { // Create PlatformConfig object - PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable); + PlatformConfig cfg(OC::ServiceType::InProc, OC::ModeType::Both, + "0.0.0.0", 0, OC::QualityOfService::LowQos); // Create a OCPlatform instance. // Note: Platform creation is synchronous call. try { - m_pPlatform = new OCPlatform(cfg); + OCPlatform::Configure(cfg); // Find all resources OCStackResult result; - if ((result = m_pPlatform->findResource("", COAP_SERVER_ADDR, - std::bind(&SSMClient::onFoundResource, this, std::placeholders::_1))) + if ((result = OCPlatform::findResource("", COAP_SERVER_ADDR, + std::bind(&SSMClient::onFoundResource, this, std::placeholders::_1))) != OC_STACK_OK) { - delete m_pPlatform; - m_pPlatform = NULL; + std::cout << "Faile to Find Resource... " << std::endl; return; } + std::cout << "Find Resource... " << std::endl; m_sem.wait(); @@ -91,20 +81,13 @@ void SSMClient::_createQueryEngine(void) { OCRepresentation rep; - AttributeMap requestAttributeMap; - AttributeValues commandValue; - QueryParamsMap queryParamsMap; - commandValue.push_back("CreateQueryEngine"); - - requestAttributeMap["command"] = commandValue; - - rep.setAttributeMap(requestAttributeMap); + rep.setValue("command", std::string("CreateQueryEngine")); if (m_SSMResource->put(rep, queryParamsMap, std::bind(&SSMClient::onCreateQueryEngine, this, std::placeholders::_1, - std::placeholders::_2)) != OC_STACK_OK) + std::placeholders::_2, std::placeholders::_3)) != OC_STACK_OK) { return; } @@ -116,25 +99,14 @@ void SSMClient::_releaseQueryEngine(std::string queryEngineId) { OCRepresentation rep; - AttributeMap requestAttributeMap; - AttributeValues commandValue; - AttributeValues queryEngineIdValue; - QueryParamsMap queryParamsMap; - commandValue.push_back("ReleaseQueryEngine"); - - requestAttributeMap["command"] = commandValue; - - queryEngineIdValue.push_back(queryEngineId); - - requestAttributeMap["queryEngineId"] = queryEngineIdValue; - - rep.setAttributeMap(requestAttributeMap); + rep.setValue("command", std::string("ReleaseQueryEngine")); + rep.setValue("queryEngineId", queryEngineId); m_SSMResource->put(rep, queryParamsMap, std::bind(&SSMClient::onReleaseQueryEngine, this, std::placeholders::_1, - std::placeholders::_2)); + std::placeholders::_2, std::placeholders::_3)); m_sem.wait(); } @@ -144,39 +116,25 @@ SSMReturn SSMClient::registerQuery(std::string queryString, ISSMClientListener * { OCRepresentation rep; - AttributeMap requestAttributeMap; - AttributeValues commandValue; - AttributeValues queryEngineIdValue; - AttributeValues contextQueryValue; - QueryParamsMap queryParamsMap; - commandValue.push_back("ExecuteContextQuery"); - - requestAttributeMap["command"] = commandValue; - queryEngineIdValue.push_back(m_queryEngineId); - - requestAttributeMap["queryEngineId"] = queryEngineIdValue; - - contextQueryValue.push_back(queryString); - - requestAttributeMap["contextQuery"] = contextQueryValue; + rep.setValue("command", std::string("ExecuteContextQuery")); + rep.setValue("queryEngineId", m_queryEngineId); + rep.setValue("contextQuery", queryString); m_appListener = listener; - rep.setAttributeMap(requestAttributeMap); - if (m_SSMResource->put(rep, queryParamsMap, std::bind(&SSMClient::onRegisterQuery, this, std::placeholders::_1, - std::placeholders::_2)) != OC_STACK_OK) + std::placeholders::_2, std::placeholders::_3)) != OC_STACK_OK) return SSM_ERROR_NETWORK; m_sem.wait(); if (m_retResponse == SSM_SUCCESS) { - cqid = m_responseAttributeMap["CQID"].back(); + cqid = m_responseAttributeMap["CQID"]; } return m_retResponse; @@ -186,30 +144,15 @@ SSMReturn SSMClient::unregisterQuery(std::string cqid) { OCRepresentation rep; - AttributeMap requestAttributeMap; - AttributeValues commandValue; - AttributeValues queryEngineIdValue; - AttributeValues cqidValue; - QueryParamsMap queryParamsMap; - commandValue.push_back("KillContextQuery"); - - requestAttributeMap["command"] = commandValue; - - queryEngineIdValue.push_back(m_queryEngineId); - - requestAttributeMap["queryEngineId"] = queryEngineIdValue; - - cqidValue.push_back(cqid); - - requestAttributeMap["CQID"] = cqidValue; - - rep.setAttributeMap(requestAttributeMap); + rep.setValue("command", std::string("KillContextQuery")); + rep.setValue("queryEngineId", m_queryEngineId); + rep.setValue("CQID", cqid); if (m_SSMResource->put(rep, queryParamsMap, std::bind(&SSMClient::onUnregisterQuery, this, std::placeholders::_1, - std::placeholders::_2)) != OC_STACK_OK) + std::placeholders::_2, std::placeholders::_3)) != OC_STACK_OK) return SSM_ERROR_NETWORK; m_sem.wait(); @@ -246,7 +189,8 @@ void SSMClient::onFoundResource(std::shared_ptr< OCResource > resource) m_sem.release(); } -void SSMClient::onCreateQueryEngine(const OCRepresentation &rep, const int eCode) +void SSMClient::onCreateQueryEngine(const HeaderOptions &headerOptions, const OCRepresentation &rep, + const int eCode) { if (eCode != 0) { @@ -254,15 +198,14 @@ void SSMClient::onCreateQueryEngine(const OCRepresentation &rep, const int eCode goto CLEANUP; } - m_responseAttributeMap = rep.getAttributeMap(); - m_queryEngineId = m_responseAttributeMap["queryEngineId"].back(); - m_responseAttributeMap["queryEngineId"].pop_back(); + m_queryEngineId = rep.getValue("queryEngineId"); m_retResponse = SSM_SUCCESS; CLEANUP: m_sem.release(); } -void SSMClient::onRegisterQuery(const OCRepresentation &rep, const int eCode) +void SSMClient::onRegisterQuery(const HeaderOptions &headerOptions, const OCRepresentation &rep, + const int eCode) { QueryParamsMap queryParamsMap; @@ -281,14 +224,16 @@ void SSMClient::onRegisterQuery(const OCRepresentation &rep, const int eCode) } m_SSMResource->observe(ObserveType::Observe, queryParamsMap, - std::bind(&SSMClient::onObserve, this, std::placeholders::_1, std::placeholders::_2)); + std::bind(&SSMClient::onObserve, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); m_retResponse = SSM_SUCCESS; CLEANUP: m_sem.release(); } -void SSMClient::onUnregisterQuery(const OCRepresentation &rep, const int eCode) +void SSMClient::onUnregisterQuery(const HeaderOptions &headerOptions, const OCRepresentation &rep, + const int eCode) { if (eCode != 0) { @@ -309,7 +254,8 @@ void SSMClient::onUnregisterQuery(const OCRepresentation &rep, const int eCode) CLEANUP: m_sem.release(); } -void SSMClient::onReleaseQueryEngine(const OCRepresentation &rep, const int eCode) +void SSMClient::onReleaseQueryEngine(const HeaderOptions &headerOptions, + const OCRepresentation &rep, const int eCode) { if (eCode != 0) { @@ -324,7 +270,8 @@ void SSMClient::onReleaseQueryEngine(const OCRepresentation &rep, const int eCod CLEANUP: m_sem.release(); } -void SSMClient::onObserve(const OCRepresentation &rep, const int &eCode) +void SSMClient::onObserve(const HeaderOptions &headerOptions, const OCRepresentation &rep, + const int &eCode, const int &sequenceNumber) { SSMReturn ret = SSM_SUCCESS; diff --git a/service/soft-sensor-manager/SSMCore/build/linux/Makefile b/service/soft-sensor-manager/SSMCore/build/linux/Makefile index dbec597..f6a3f19 100644 --- a/service/soft-sensor-manager/SSMCore/build/linux/Makefile +++ b/service/soft-sensor-manager/SSMCore/build/linux/Makefile @@ -1,4 +1,4 @@ - +-include ../../../build/linux/root_path.inc -include ../../../build/linux/environment.mk BOOST=${BOOST_BASE} @@ -7,13 +7,13 @@ INC_PATH=../../include RST_NAME=release # Insert your project name. -TARGET=SSMCoreUbuntu +TARGET=${SSMCORE_LIB} EXCLUDE_LIST=SSMCore_JNI.cpp # C++ type Compile Flag define. CXX=g++ -CXX_FLAGS=-std=c++0x -Wall -pthread -DLINUX -DMODEL_DIRECTORY=${MODEL_DIR} -DHIGH_LOCATION=${HIGH_LOCATION} -ldl -CXX_INC=-I../../ -I${INC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} -I${SRC_PATH} -I${SRC_PATH}/Common -I${SRC_PATH}/QueryProcessor -I${SRC_PATH}/SensorProcessor -I${SRC_PATH}/SSMInterface +CXX_FLAGS=-std=c++0x -Wall -pthread -DLINUX -ldl +CXX_INC=-I${INC_PATH}/ -I${SRC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_LOG_DIR}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} CXX_LIB=-L"" CXX_SRCPATH=${wildcard ${SRC_PATH}/**/*.cpp} @@ -34,8 +34,8 @@ GCC_OBJLIST=${GCC_USESRCS:.c=.o} # Linker FLAGS define. LD_FLAGS=-std=c++0x -Wall -DLINUX -# GAR=ar -LD_LIB=${IOT_RELEASE}/${IOT_LIB} ${IOT_CSDK_RELEASE}/${IOT_CSDK_LIB} -lpthread -ldl +GAR=ar +# LD_LIB=${IOT_RELEASE}/${IOT_LIB} ${IOT_CSDK_RELEASE}/${IOT_CSDK_LIB} ${IOT_LOG_DIR}/lib/${IOT_LOG_LIB} -lpthread -ldl # Force metatargets to build: @@ -51,8 +51,8 @@ pre_job: @echo "${MODEL_DIR}" ${TARGET}: ${GCC_OBJLIST} ${CXX_OBJLIST} - $(CXX) $(LD_FLAGS) -o ./${RST_NAME}/$@ $^ ${LD_LIB} - # ${GAR} -r ./${RST_NAME}/$@ ./*.o + # $(CXX) $(LD_FLAGS) -o ./${RST_NAME}/$@ $^ ${LD_LIB} + ${GAR} -r ./${RST_NAME}/$@ ./*.o @echo " " %.o : ${SRC_PATH}/**/%.c @@ -70,6 +70,7 @@ ${TARGET}: ${GCC_OBJLIST} ${CXX_OBJLIST} post_job: @echo " " cp -Rdp ./${RST_NAME}/${TARGET} ${OUTPUTS_DIR}/ + cp -Rdp ${INC_PATH}/SSMInterface.h ${OUTPUTS_DIR}/ cp -Rdp ${SRC_PATH}/SSMInterface/SSMModelDefinition.h ${OUTPUTS_DIR}/ @echo "---------------- SSMCore Build Successful. ---------------" @echo "Enter to ${RST_NAME} folder." diff --git a/service/soft-sensor-manager/SSMCore/src/Common/InternalInterface.h b/service/soft-sensor-manager/SSMCore/src/Common/InternalInterface.h index dd9fe3e..e0db5b2 100644 --- a/service/soft-sensor-manager/SSMCore/src/Common/InternalInterface.h +++ b/service/soft-sensor-manager/SSMCore/src/Common/InternalInterface.h @@ -113,21 +113,21 @@ class IContextRepository : public IBase ; /** - * @fn setCurrentDeviceInfo - * @brief set device information + * @fn initRepository + * @brief initialize repository using given info * * @param [in] std::string name - Device name * @param [in] std::string type - Device Type * @param [in] std::string pathSoftSensors - SoftSensors Repository path * @param [in] std::string pathDescription - SoftSensors Description path - * @return void + * @return SSMRESULT * * @warning * @exception * @see */ - virtual void setCurrentDeviceInfo(IN std::string name, IN std::string type, - IN std::string pathSoftSensors, IN std::string pathDescription) = 0; + virtual SSMRESULT initRepository(IN std::string name, IN std::string type, + IN std::string pathSoftSensors, IN std::string pathDescription) = 0; virtual SSMRESULT registerResourceFinderEvent(IN IResourceEvent *pResourceEvent) = 0; virtual SSMRESULT startResourceFinder() = 0; @@ -1123,16 +1123,15 @@ class IContextExecutor : public IBase IEvent *pEvent) = 0; }; -static const OID OID_IResponseReactor = { 0x3140a3dc, 0xf912, 0x4d88, { 0x97, 0x3c, 0x86, 0xe8, 0x35, 0x69, 0xa7, 0xf8 } }; +static const OID OID_ISensingEngine = { 0x3140a3dc, 0xf912, 0x4d88, { 0x97, 0x3c, 0x86, 0xe8, 0x35, 0x69, 0xa7, 0xf8 } }; /** - * @class IResponseReactor - * @brief Interface for implement of reactor pattern - * Delegate requested context to context executor layer. + * @class ISensingEngine + * @brief Class for implementing main abstration of SensorProcessor * * * @see */ -class IResponseReactor : public IBase +class ISensingEngine : public IBase , public IEvent { public: @@ -1149,7 +1148,8 @@ class IResponseReactor : public IBase * @exception * @see */ - virtual void registerContext(TypeofEvent callType, ISSMResource *pSSMResouce, IEvent *pEvent) = 0; + virtual SSMRESULT registerContext(TypeofEvent callType, ISSMResource *pSSMResouce, + IEvent *pEvent) = 0; /** * @fn unregisterContext @@ -1164,8 +1164,8 @@ class IResponseReactor : public IBase * @exception * @see */ - virtual void unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource, - IEvent *pEvent) = 0; + virtual SSMRESULT unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource, + IEvent *pEvent) = 0; /** * @fn getList @@ -1178,7 +1178,7 @@ class IResponseReactor : public IBase * @exception * @see */ - virtual void getList(std::vector *pList) = 0; + virtual SSMRESULT getList(std::vector *pList) = 0; }; class IResourceFinderEvent @@ -1199,13 +1199,6 @@ class IResourceFinder : public IBase virtual SSMRESULT stopObserveResource(IN ISSMResource *pSensor) = 0; }; -static const OID OID_IResourceConnectivity = { 0x8e42b098, 0x9aa5, 0x43f3, { 0x84, 0xa, 0x21, 0x44, 0xc9, 0x4c, 0xc7, 0x99 } }; -class IResourceConnectivity : public IBase -{ - public: - virtual void *getPlatform() = 0; -}; - /** * @class ISoftSensorManager * @brief ISoftSensorManager Interface diff --git a/service/soft-sensor-manager/SSMCore/src/Common/ThreadManager.cpp b/service/soft-sensor-manager/SSMCore/src/Common/ThreadManager.cpp index bb86402..4a8e050 100644 --- a/service/soft-sensor-manager/SSMCore/src/Common/ThreadManager.cpp +++ b/service/soft-sensor-manager/SSMCore/src/Common/ThreadManager.cpp @@ -1,3 +1,22 @@ +/****************************************************************** +* +* Copyright 2014 Samsung Electronics All Rights Reserved. +* +* +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +******************************************************************/ #include "ThreadManager.h" CSimpleMutex::CSimpleMutex() diff --git a/service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.cpp b/service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.cpp index bab1e7c..58d2df4 100644 --- a/service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.cpp +++ b/service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.cpp @@ -36,7 +36,7 @@ SSMRESULT CPropagationEngine::finalConstruct() SSM_CLEANUP_ASSERT(m_pContextRepository->registerResourceFinderEvent(this)); - SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResponseReactor, (IBase **)&m_pResponseReactor)); + SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ISensingEngine, (IBase **)&m_pSensingEngine)); SSM_CLEANUP_ASSERT(initializeEngine()); @@ -148,7 +148,7 @@ SSMRESULT CPropagationEngine::addResourceFromGetList() std::vector contextModelList; std::stringstream sstream; - m_pResponseReactor->getList(&contextModelList); + m_pSensingEngine->getList(&contextModelList); for (std::vector::iterator itor = contextModelList.begin(); itor != contextModelList.end(); ++itor) { @@ -288,12 +288,12 @@ CLEANUP: return res; } -SSMRESULT CPropagationEngine::installResponseReactor(IN IResponseReactor *pResponseReactor) +SSMRESULT CPropagationEngine::installCurrentSensors() { SSMRESULT res = SSM_E_FAIL; std::vector contextModelList; - pResponseReactor->getList(&contextModelList); + m_pSensingEngine->getList(&contextModelList); for (std::vector::iterator itor = contextModelList.begin(); itor != contextModelList.end(); ++itor) @@ -449,7 +449,7 @@ SSMRESULT CPropagationEngine::initializeEngine() SSM_CLEANUP_ASSERT(updateDeviceInfo(&ssmResource, NULL)); - SSM_CLEANUP_ASSERT(installResponseReactor(m_pResponseReactor)); + SSM_CLEANUP_ASSERT(installCurrentSensors()); CLEANUP: SAFE_RELEASE(pRootModel); @@ -525,11 +525,11 @@ SSMRESULT CPropagationEngine::onModelStatusChange(IN IContextModel::Status newSt { case IContextModel::STATUS_ACTIVATE: pModel->addRef(); - m_pResponseReactor->registerContext(SSM_REPEAT, pSSMResource, (CContextModel *)pModel); + m_pSensingEngine->registerContext(SSM_REPEAT, pSSMResource, (CContextModel *)pModel); break; case IContextModel::STATUS_DEACTIVATE: - m_pResponseReactor->unregisterContext(SSM_REPEAT, pSSMResource, (CContextModel *)pModel); + m_pSensingEngine->unregisterContext(SSM_REPEAT, pSSMResource, (CContextModel *)pModel); //pModel->CleanUpModelData(); pModel->release(); break; @@ -537,7 +537,7 @@ SSMRESULT CPropagationEngine::onModelStatusChange(IN IContextModel::Status newSt case IContextModel::STATUS_START_READ_VALUE: //Model must be released from OnEvent callType pModel->addRef(); - m_pResponseReactor->registerContext(SSM_ONCE, pSSMResource, (CContextModel *)pModel); + m_pSensingEngine->registerContext(SSM_ONCE, pSSMResource, (CContextModel *)pModel); break; case IContextModel::STATUS_STOP_READ_VALUE: diff --git a/service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.h b/service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.h index 45eca05..0b59a69 100644 --- a/service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.h +++ b/service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.h @@ -56,7 +56,7 @@ class CPropagationEngine : CSimpleMutex m_mtxContextModelList; CSimpleMutex m_mtxLookUpList; - CObjectPtr m_pResponseReactor; + CObjectPtr m_pSensingEngine; CObjectPtr m_pDeviceModel; @@ -75,9 +75,9 @@ class CPropagationEngine : SSMRESULT addResourceFromGetList(); //TODO: Install Context model from SSMResource - SSMRESULT installContextModelFromISSMResource(IN ISSMResource *pSSMResource); + SSMRESULT installCurrentSensors(); - SSMRESULT installResponseReactor(IN IResponseReactor *pResponseReactor); + SSMRESULT installContextModelFromISSMResource(IN ISSMResource *pSSMResource); SSMRESULT installContextModel(IN IContextModel *pParentModel, IN IContextModel::ConstructionType constructionType, diff --git a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.cpp b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.cpp index 51a13db..d771aaf 100644 --- a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.cpp @@ -51,18 +51,18 @@ class CQueryEngineEvent: public IQueryEngineEvent std::stringstream sstream; // QueryEngine Id - queryEventResult["queryEngineId"].push_back(m_queryEngineId); + queryEventResult["queryEngineId"] = m_queryEngineId; // CQID sstream << cqid; - queryEventResult["CQID"].push_back(sstream.str()); + queryEventResult["CQID"] = sstream.str(); sstream.str(""); pResult->getAffectedModels(&affectedModels); // Affected Model Count sstream << affectedModels.size(); - queryEventResult["modelCount"].push_back(sstream.str()); + queryEventResult["modelCount"] = sstream.str(); sstream.str(""); //TODO: we assume that contains only one model at time @@ -71,14 +71,14 @@ class CQueryEngineEvent: public IQueryEngineEvent { // Model Name sstream << (*itor); - queryEventResult["modelName"].push_back(sstream.str()); + queryEventResult["modelName"] = sstream.str(); sstream.str(""); pResult->getModelDataCount(*itor, &dataCount); // Data Count sstream << dataCount; - queryEventResult["dataCount"].push_back(sstream.str()); + queryEventResult["dataCount"] = sstream.str(); sstream.str(""); //FixME: we have to support multiple data count @@ -88,26 +88,28 @@ class CQueryEngineEvent: public IQueryEngineEvent // Data Id sstream << pModelData->getDataId(); - queryEventResult["dataId"].push_back(sstream.str()); + queryEventResult["dataId"] = sstream.str(); sstream.str(""); // Property Count sstream << pModelData->getPropertyCount(); - queryEventResult["propertyCount"].push_back(sstream.str()); + queryEventResult["propertyCount"] = sstream.str(); sstream.str(""); for (int j = 0; j < pModelData->getPropertyCount(); j++) { // Property Name & Value sstream << pModelData->getPropertyValue(j).c_str(); - queryEventResult[pModelData->getPropertyName(j).c_str()].push_back(sstream.str()); + queryEventResult[pModelData->getPropertyName(j).c_str()] = sstream.str(); sstream.str(""); } } } g_vecQueryEventResults.push_back(queryEventResult); - OCPlatform::notifyObservers(m_hSSMResource); + + //TODO: need to modify for notifying proper clients + OCPlatform::notifyAllObservers(m_hSSMResource); return SSM_S_OK; } @@ -115,7 +117,6 @@ class CQueryEngineEvent: public IQueryEngineEvent SSMResourceServer::SSMResourceServer() { - m_pPlatform = NULL; m_hSSMResource = NULL; } @@ -126,16 +127,10 @@ SSMResourceServer::~SSMResourceServer() int SSMResourceServer::initializeManager(std::string &xmlDescription) { SSMRESULT res = SSM_E_FAIL; - CObjectPtr < IResourceConnectivity > pResourceConnectivity; SSM_CLEANUP_ASSERT(InitializeSSMCore(xmlDescription)); SSM_CLEANUP_ASSERT(StartSSMCore()); - SSM_CLEANUP_ASSERT( - CreateGlobalInstance(OID_IResourceConnectivity, (IBase **) &pResourceConnectivity)); - - m_pPlatform = (OC::OCPlatform *) pResourceConnectivity->getPlatform(); - if (createResource() != 0) { SSM_CLEANUP_ASSERT (SSM_E_FAIL); @@ -165,15 +160,14 @@ CLEANUP: int SSMResourceServer::createResource() { std::string resourceURI = "/service/SoftSensorManager"; // URI of the resource - std::string resourceTypeName = - "core.SoftSensorManager"; // resource type name. In this case, it is light + std::string resourceTypeName = "core.SoftSensorManager"; // resource type name. std::string resourceInterface = DEFAULT_INTERFACE; // resource interface. // OCResourceProperty is defined ocstack.h uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE; // This will internally create and register the resource. - OCStackResult result = m_pPlatform->registerResource(m_hSSMResource, resourceURI, + OCStackResult result = OCPlatform::registerResource(m_hSSMResource, resourceURI, resourceTypeName, resourceInterface, std::bind(&SSMResourceServer::entityHandler, this, std::placeholders::_1, std::placeholders::_2), resourceProperty); @@ -186,8 +180,8 @@ int SSMResourceServer::createResource() return 0; } -void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > request, - std::shared_ptr< OCResourceResponse > response) +OCEntityHandlerResult SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > request, + std::shared_ptr< OCResourceResponse > response) { SSMRESULT res = SSM_E_FAIL; @@ -195,14 +189,17 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque { // Get the request type and request flag std::string requestType = request->getRequestType(); - RequestHandlerFlag requestFlag = request->getRequestHandlerFlag(); + int requestFlag = request->getRequestHandlerFlag(); - if (requestFlag == RequestHandlerFlag::InitFlag) + if (requestFlag & RequestHandlerFlag::InitFlag) { // entity handler to perform resource initialization operations } - else if (requestFlag == RequestHandlerFlag::RequestFlag) + + if (requestFlag & RequestHandlerFlag::RequestFlag) { + cout << "\t\trequestFlag : Request\n"; + // If the request type is GET if (requestType == "GET") { @@ -237,7 +234,7 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque AttributeMap responseAttributeMap; // Process query params and do required operations .. - if (requestAttributeMap["command"].back() == "CreateQueryEngine") + if (requestAttributeMap["command"] == "CreateQueryEngine") { CQueryEngineEvent *queryEngineEvent = NULL; @@ -245,7 +242,7 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque if (res != SSM_S_OK) { - responseAttributeMap["error"].push_back("CreateQueryEngine failed"); + responseAttributeMap["error"] = "CreateQueryEngine failed"; goto CLEANUP; } @@ -256,8 +253,8 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque if (queryEngineEvent == NULL) { - responseAttributeMap["error"].push_back( - "QueryEngineEvent create failed"); + responseAttributeMap["error"] = + "QueryEngineEvent create failed"; goto CLEANUP; } @@ -265,49 +262,49 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque if (res != SSM_S_OK) { - responseAttributeMap["error"].push_back("RegisterQueryEvent failed"); + responseAttributeMap["error"] = "RegisterQueryEvent failed"; goto CLEANUP; } - responseAttributeMap["queryEngineId"].push_back(sstream.str()); + responseAttributeMap["queryEngineId"] = sstream.str(); } - else if (requestAttributeMap["command"].back() == "ReleaseQueryEngine") + else if (requestAttributeMap["command"] == "ReleaseQueryEngine") { pQueryEngine = (IQueryEngine *) stoi( - requestAttributeMap["queryEngineId"].back()); + requestAttributeMap["queryEngineId"]); ReleaseQueryEngine(pQueryEngine); } - else if (requestAttributeMap["command"].back() == "ExecuteContextQuery") + else if (requestAttributeMap["command"] == "ExecuteContextQuery") { int CQID = 0; pQueryEngine = (IQueryEngine *) stoi( - requestAttributeMap["queryEngineId"].back()); + requestAttributeMap["queryEngineId"]); res = pQueryEngine->executeContextQuery( - requestAttributeMap["contextQuery"].back(), &CQID); + requestAttributeMap["contextQuery"], &CQID); if (res != SSM_S_OK) { - responseAttributeMap["error"].push_back("ExecuteContextQuery failed"); + responseAttributeMap["error"] = "ExecuteContextQuery failed"; goto CLEANUP; } sstream << CQID; - responseAttributeMap["CQID"].push_back(sstream.str()); + responseAttributeMap["CQID"] = sstream.str(); } - else if (requestAttributeMap["command"].back() == "KillContextQuery") + else if (requestAttributeMap["command"] == "KillContextQuery") { pQueryEngine = (IQueryEngine *) stoi( - requestAttributeMap["queryEngineId"].back()); + requestAttributeMap["queryEngineId"]); - res = pQueryEngine->killContextQuery(stoi(requestAttributeMap["CQID"].back())); + res = pQueryEngine->killContextQuery(stoi(requestAttributeMap["CQID"])); if (res != SSM_S_OK) { - responseAttributeMap["error"].push_back("KillContextQuery failed"); + responseAttributeMap["error"] = "KillContextQuery failed"; goto CLEANUP; } } @@ -330,12 +327,12 @@ CLEANUP: // DELETE request operations } } - else if (requestFlag == RequestHandlerFlag::ObserverFlag) + + if (requestFlag & RequestHandlerFlag::ObserverFlag) { // perform observe related operations on the resource. } } - else - { - } + + return OC_EH_OK; } diff --git a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.h b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.h index 7643411..5206e40 100644 --- a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.h +++ b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.h @@ -34,11 +34,10 @@ class SSMResourceServer int initializeManager(std::string &xmlDescription); int terminateManager(); - void entityHandler(std::shared_ptr< OC::OCResourceRequest > request, - std::shared_ptr< OC::OCResourceResponse > response); + OCEntityHandlerResult entityHandler(std::shared_ptr< OC::OCResourceRequest > request, + std::shared_ptr< OC::OCResourceResponse > response); private: - OC::OCPlatform *m_pPlatform; OCResourceHandle m_hSSMResource; int createResource(); }; diff --git a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp index 5eed956..0d0149e 100644 --- a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp @@ -23,11 +23,10 @@ #include "QueryProcessor/ConditionedModel.h" #include "QueryProcessor/EvaluationEngine.h" #include "QueryProcessor/PropagationEngine.h" -#include "SensorProcessor/ResponseReactor.h" +#include "SensorProcessor/SensingEngine.h" #include "SensorProcessor/ContextExecutor.h" #include "SensorProcessor/ContextDataReader.h" #include "SensorProcessor/ResourceFinder.h" -#include "SensorProcessor/ResourceConnectivity.h" inline bool operator<( const OID &lhs, const OID &rhs ) { @@ -121,8 +120,9 @@ SSMRESULT CSoftSensorManager::initializeCore(IN std::string xmlDescription) } SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase **)&m_pContextRepository)); - SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResponseReactor, (IBase **)&m_pResponseReactor)); - m_pContextRepository->setCurrentDeviceInfo(name, type, pathSoftSensors, pathDescription); + SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ISensingEngine, (IBase **)&m_pSensingEngine)); + SSM_CLEANUP_ASSERT(m_pContextRepository->initRepository(name, type, pathSoftSensors, + pathDescription)); SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IPropagationEngine, (IBase **)&m_pPropagationEngine)); @@ -173,7 +173,7 @@ unsigned long CSoftSensorManager::releaseQueryEngine(IN IQueryEngine *pQueryEngi SSMRESULT CSoftSensorManager::getInstalledModelList(OUT std::vector *pList) { - m_pResponseReactor->getList(pList); + m_pSensingEngine->getList(pList); return SSM_S_OK; } @@ -238,18 +238,11 @@ SSMRESULT CreateGlobalInstance(IN const OID &objectID, OUT IBase **ppvObject) SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextDataReader, ppvObject)); } } - else if (IsEqualOID(OID_IResponseReactor, objectID)) + else if (IsEqualOID(OID_ISensingEngine, objectID)) { - if (g_globalInstance->find(OID_IResponseReactor) == g_globalInstance->end()) + if (g_globalInstance->find(OID_ISensingEngine) == g_globalInstance->end()) { - SSM_CLEANUP_ASSERT(CreateInstance(OID_IResponseReactor, ppvObject)); - } - } - else if (IsEqualOID(OID_IResourceConnectivity, objectID)) - { - if (g_globalInstance->find(OID_IResourceConnectivity) == g_globalInstance->end()) - { - SSM_CLEANUP_ASSERT(CreateInstance(OID_IResourceConnectivity, ppvObject)); + SSM_CLEANUP_ASSERT(CreateInstance(OID_ISensingEngine, ppvObject)); } } else @@ -313,9 +306,9 @@ SSMRESULT CreateInstance(IN const OID &objectID, OUT IBase **ppObject) { SSM_CLEANUP_ASSERT(CreateNewObject(objectID, ppObject)); } - else if (IsEqualOID(OID_IResponseReactor, objectID)) + else if (IsEqualOID(OID_ISensingEngine, objectID)) { - SSM_CLEANUP_ASSERT(CreateNewObject(objectID, ppObject)); + SSM_CLEANUP_ASSERT(CreateNewObject(objectID, ppObject)); } else if (IsEqualOID(OID_IContextExecutor, objectID)) { @@ -353,10 +346,6 @@ SSMRESULT CreateInstance(IN const OID &objectID, OUT IBase **ppObject) { SSM_CLEANUP_ASSERT(CreateNewObject(objectID, ppObject)); } - else if (IsEqualOID(OID_IResourceConnectivity, objectID)) - { - SSM_CLEANUP_ASSERT(CreateNewObject(objectID, ppObject)); - } CLEANUP: return res; diff --git a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.h b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.h index 1718097..8baa123 100644 --- a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.h +++ b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.h @@ -44,7 +44,7 @@ class CSoftSensorManager : private: CObjectPtr m_pContextRepository; CObjectPtr m_pPropagationEngine; - CObjectPtr m_pResponseReactor; + CObjectPtr m_pSensingEngine; public: SSMRESULT finalConstruct(); diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.cpp b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.cpp index 9f26e55..2fbcd84 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.cpp @@ -75,22 +75,6 @@ void CContextExecutor::getDataFromDatabase(std::string modelName, int startIndex m_pContextDataReader->getContextData(modelName, startIndex, count, data, pLastIndex); } -std::string CContextExecutor::checkError(std::vector data) -{ - std::string errorMsg = "OK"; - - for (unsigned int i = 0 ; i < data.size() ; ++i) - { - if (data[i].outputProperty[0].find("error") != data[i].outputProperty[0].end()) - { - errorMsg = data[i].outputProperty[0].find("error")->second ; - break; - } - } - - return errorMsg; -} - void CContextExecutor::registerContext(TypeofEvent callType, ISSMResource *pSSMResource, IEvent *pEvent) { @@ -242,10 +226,12 @@ std::map > CContextExecutor::getPreparedC std::string primitiveSensor) { //check m_relatedSoftSensor / apply timestamp - std::map > returnData; SSMRESULT ret = SSM_E_FAIL; + std::map > returnData; + std::vector contextDataList; + for (unsigned int i = 0; i < m_relatedSoftSensor[primitiveSensor].size(); ++i) { std::string softSensorName = m_relatedSoftSensor[primitiveSensor][i]; @@ -253,24 +239,26 @@ std::map > CContextExecutor::getPreparedC { ret = SSM_S_OK; std::vector inputList = m_registeredResources[softSensorName]->inputList; - std::vector contextDataList; for (unsigned int j = 0; j < inputList.size(); j++) //check all "inputlist" arrived or not { if (m_storedPrimitiveSensorData.find(inputList[j]) == m_storedPrimitiveSensorData.end()) { + //Still we have partial data ret = SSM_E_FAIL; break; } else { - std::vector primitiveSensorData = m_storedPrimitiveSensorData[inputList[j]]; - for (unsigned k = 0; k < primitiveSensorData.size(); k++) + //Copy all properties of current primitiveSensor data to outputs + for (std::vector::iterator itor = m_storedPrimitiveSensorData[inputList[j]].begin(); + itor != m_storedPrimitiveSensorData[inputList[j]].end(); ++itor) { - contextDataList.push_back(primitiveSensorData[k]); + contextDataList.push_back(*itor); } } } + //We have all inputs if (ret == SSM_S_OK) { returnData.insert(std::make_pair(softSensorName, contextDataList)); @@ -296,27 +284,14 @@ int CContextExecutor::onEvent(std::string type, TypeofEvent callType, //find soft sensor std::map > readyContextList = getPreparedContextList(type); - if (readyContextList.size() > 0) + //Run SoftSensor! readyContextList has all data for run + std::map >::iterator iter; + for (iter = readyContextList.begin(); iter != readyContextList.end(); ++iter) { - //Run SoftSensor! readyContextList has all data for run - std::map >::iterator iter = readyContextList.begin(); - for (; iter != readyContextList.end(); ++iter) - { - std::string softSensorName = iter->first; - std::vector inputData = iter->second; - std::string errorMsg = checkError(inputData); + std::string softSensorName = iter->first; + std::vector inputData = iter->second; - if (!errorMsg.compare("OK")) - { - runLogic(inputData, softSensorName); - } - else - { - inputData.clear(); - inputData.push_back(makeErrorContextData(softSensorName, errorMsg)); - addOutput(inputData); - } - } + runLogic(inputData, softSensorName); } } else //This data is primitive @@ -421,18 +396,4 @@ void CContextExecutor::runLogic(std::vector inputData, std::string m_ctxEventList[softSensor]->onCtxEvent(SPF_START, inputData); } m_mtxLibraryIO.unlock(); -} - -ContextData CContextExecutor::makeErrorContextData(std::string rootName, std::string errMsg) -{ - std::map errorMap; - ContextData errorContextData; - - errorMap.insert(std::make_pair("error", errMsg)); - errorMap.insert(std::make_pair("available", "false")); - errorContextData.rootName = rootName; - errorContextData.outputPropertyCount = 2; - errorContextData.outputProperty.push_back(errorMap); - - return errorContextData; } \ No newline at end of file diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.h b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.h index c8f88a9..6b3a6c9 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.h +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.h @@ -214,9 +214,6 @@ class CContextExecutor : std::map > getPreparedContextList( IN std::string primitiveSensor); void runLogic(IN std::vector inputData, IN std::string softSensor); - ContextData makeErrorContextData(IN std::string rootName, IN std::string errMsg); - std::string checkError(IN std::vector data); - }; #endif diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.cpp b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.cpp index f6c6423..20793e0 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.cpp @@ -65,23 +65,23 @@ void CContextRepository::finalRelease() { } -void CContextRepository::setCurrentDeviceInfo(IN std::string name, IN std::string type, +SSMRESULT CContextRepository::initRepository(IN std::string name, IN std::string type, IN std::string pathSoftSensors, IN std::string pathDescription) { - //TODO: Someone need to provides a way to generate permanent uuid function - /* - m_currentDeviceInfo.friendlyName = name; - //m_currentDeviceInfo.ID="2fac1234-31f8-11b4-a222-08002b34c003"; - m_currentDeviceInfo.ID = udn; - m_currentDeviceInfo.IPAddress = "127.0.0.1"; - m_currentDeviceInfo.tp = tp; - //m_currentDeviceInfo.type = SSM_DEVICE_MOBILE; - m_currentDeviceInfo.type = td; - */ + SSMRESULT res = SSM_E_FAIL; + + std::vector dict; + m_name = name; m_type = type; m_pathSoftSensors = pathSoftSensors; m_pathSoftSensorsDescription = pathDescription; + + SSM_CLEANUP_ASSERT(loadXMLFromFile(m_pathSoftSensorsDescription.c_str(), &dict)); + SSM_CLEANUP_ASSERT(makeSSMResourceListForDictionaryData(dict, &m_lstSoftSensor)); + +CLEANUP: + return res; } SSMRESULT CContextRepository::loadXMLFromString(char *xmlData, @@ -118,7 +118,7 @@ SSMRESULT CContextRepository::loadXMLFromString(char *xmlData, keyStr = subItem->name(); // key valueStr = subItem->value(); // value - if (!keyStr.compare("root_name")) + if (!keyStr.compare("name")) { dictionaryData.rootName = trim_both(valueStr); } @@ -131,58 +131,29 @@ SSMRESULT CContextRepository::loadXMLFromString(char *xmlData, keyStr = subItem2->name(); // key valueStr = subItem2->value(); // value - if (!keyStr.compare("attribute_property_count")) - { - dictionaryData.attributePropertyCount = trim_both(valueStr); - } - else if (!keyStr.compare("output_property_count")) - { - dictionaryData.outputPropertyCount = trim_both(valueStr); - } - if (!keyStr.compare("inputs_count")) - { - dictionaryData.inputCount = trim_both(valueStr); - } - else if (!keyStr.compare("app_inputs_count")) - { - dictionaryData.appInputCount = trim_both(valueStr); - } - else if (!keyStr.compare("app_input")) - { - dictionaryData.appInputs.push_back(trim_both(valueStr)); - } - else if (!keyStr.compare("input")) + if (!keyStr.compare("input")) { dictionaryData.inputs.push_back(trim_both(valueStr)); } ////std::cout<value() <first_node(); subItem3 ; subItem3 = subItem3->next_sibling()) { - std::string newKeyStr = subItem3->name(); // key valueStr = subItem3->value(); // value - if (!keyStr.compare("attribute_property") || !keyStr.compare("output_property") ) - { - propertyMap.insert(std::make_pair(trim_both(newKeyStr), trim_both(valueStr))) ; - } - else if (!keyStr.compare("enter_condition")) + if (!keyStr.compare("attribute") || !keyStr.compare("output") ) { - enterconditionVector.push_back(trim_both(valueStr)); + propertyMap.insert(std::make_pair(trim_both(newKeyStr), trim_both(valueStr))); } } - if (!keyStr.compare("attribute_property")) + if (!keyStr.compare("attribute")) { dictionaryData.attributeProperty.push_back(propertyMap); } - else if (!keyStr.compare("output_property")) + else if (!keyStr.compare("output")) { dictionaryData.outputProperty.push_back(propertyMap); } - else if (!keyStr.compare("enter_condition")) - { - dictionaryData.enterConditions.push_back(enterconditionVector); - } } } //for accurate data. @@ -250,23 +221,20 @@ CLEANUP: SSMRESULT CContextRepository::getSoftSensorList(OUT std::vector *pSoftSensorList) { - SSMRESULT res = SSM_E_FAIL; - std::vector dict; - - SSM_CLEANUP_ASSERT(loadXMLFromFile(m_pathSoftSensorsDescription.c_str(), &dict)); - - SSM_CLEANUP_ASSERT(makeSSMResourceListForDictionaryData(dict, pSoftSensorList)); + for (size_t i = 0; i < m_lstSoftSensor.size(); i++) + { + pSoftSensorList->push_back(m_lstSoftSensor.at(i)); + } -CLEANUP: - return res; + return SSM_S_OK; } SSMRESULT CContextRepository::getPrimitiveSensorList(OUT std::vector *pPrimitiveSensorList) { - for (size_t i = 0; i < m_lstSensor.size(); i++) + for (size_t i = 0; i < m_lstPrimitiveSensor.size(); i++) { - pPrimitiveSensorList->push_back(m_lstSensor.at(i)); + pPrimitiveSensorList->push_back(m_lstPrimitiveSensor.at(i)); } return SSM_S_OK; @@ -274,7 +242,7 @@ SSMRESULT CContextRepository::getPrimitiveSensorList(OUT std::vector::iterator itor; - itor = std::find(m_lstSensor.begin(), m_lstSensor.end(), pSensor); + itor = std::find(m_lstPrimitiveSensor.begin(), m_lstPrimitiveSensor.end(), pSensor); - if (itor != m_lstSensor.end()) + if (itor != m_lstPrimitiveSensor.end()) { - m_lstSensor.erase(itor); + m_lstPrimitiveSensor.erase(itor); return SSM_S_OK; } diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.h b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.h index 314408f..d3e13e3 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.h +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.h @@ -42,7 +42,8 @@ class CContextRepository : { private: CSimpleMutex m_mtxFileIO; - std::vector m_lstSensor; + std::vector m_lstPrimitiveSensor; + std::vector m_lstSoftSensor; CObjectPtr m_resourceFinder; std::string m_name; std::string m_type; @@ -72,21 +73,21 @@ class CContextRepository : /** - * @fn setCurrentDeviceInfo - * @brief set device information + * @fn initRepository + * @brief initialize repository using given info * * @param [in] std::string name - Device name * @param [in] std::string type - Device Type * @param [in] std::string pathSoftSensors - SoftSensors Repository path * @param [in] std::string pathDescription - SoftSensors Description path - * @return void + * @return SSMRESULT * * @warning * @exception * @see */ - void setCurrentDeviceInfo(IN std::string name, IN std::string type, IN std::string pathSoftSensors, - IN std::string pathDescription); + SSMRESULT initRepository(IN std::string name, IN std::string type, IN std::string pathSoftSensors, + IN std::string pathDescription); /** * @fn getSoftSensorList diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceConnectivity.cpp b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceConnectivity.cpp deleted file mode 100644 index 67214c8..0000000 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceConnectivity.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************** -* -* Copyright 2014 Samsung Electronics All Rights Reserved. -* -* -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -******************************************************************/ -#include "ResourceConnectivity.h" - -SSMRESULT CResourceConnectivity::finalConstruct() -{ - SSMRESULT res = SSM_E_FAIL; - OC::PlatformConfig cfg(OC::ServiceType::InProc, OC::ModeType::Both, - "134.134.161.33", 56831, OC::QualityOfService::NonConfirmable); - - m_pPlatform = new OC::OCPlatform(cfg); - - SSM_CLEANUP_NULL_ASSERT(m_pPlatform); - - res = SSM_S_OK; - -CLEANUP: - return res; -} - -void CResourceConnectivity::finalRelease() -{ - SAFE_DELETE(m_pPlatform); -} - -void *CResourceConnectivity::getPlatform() -{ - return m_pPlatform; -} diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceConnectivity.h b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceConnectivity.h deleted file mode 100644 index ec28c81..0000000 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceConnectivity.h +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************** -* -* Copyright 2014 Samsung Electronics All Rights Reserved. -* -* -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -******************************************************************/ -#ifndef _ResourceConnectivity_H_ -#define _ResourceConnectivity_H_ - -#include "SSMInterface/SSMCore.h" -#include "Common/PlatformLayer.h" -#include "Common/InternalInterface.h" -#include "OCPlatform.h" - -class CResourceConnectivity : - public CObjectRoot - , public IResourceConnectivity -{ - public: - SSMRESULT queryInterface(const OID &objectID, IBase **ppObject) - { - if (ppObject == NULL) - return SSM_E_POINTER; - - if (IsEqualOID(objectID, OID_IResourceConnectivity)) - { - IBase *pBase = (IResourceConnectivity *)this; - pBase->addRef(); - *ppObject = pBase; - return SSM_S_OK; - } - - return SSM_E_NOINTERFACE; - } - - SSMRESULT finalConstruct(); - void finalRelease(); - - void *getPlatform(); - - private: - OC::OCPlatform *m_pPlatform; -}; - -#endif diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp index dcf1f1c..0fc67b3 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp @@ -23,12 +23,14 @@ SSMRESULT CResourceFinder::finalConstruct() { SSMRESULT res = SSM_E_FAIL; + OC::PlatformConfig cfg(OC::ServiceType::InProc, OC::ModeType::Both, + "0.0.0.0", 0, OC::QualityOfService::LowQos); + SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase **)&m_pTasker)); - SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResourceConnectivity, - (IBase **)&m_pResourceConnectivity)); + + OC::OCPlatform::Configure(cfg); m_pResourceFinderEvent = NULL; - m_pPlatform = (OC::OCPlatform *)m_pResourceConnectivity->getPlatform(); CLEANUP: return res; @@ -52,15 +54,21 @@ void CResourceFinder::onResourceFound(std::shared_ptr resource) pMessage[0] = RESOURCE_DISCOVER_REQUESTPROFILE; pMessage[1] = (int)new std::shared_ptr(resource); + std::string path = resource->host() + resource->uri(); + m_pTasker->addTask(this, pMessage); } } SSMRESULT CResourceFinder::startResourceFinder() { - //m_pPlatform->findResource("", "oc/core/service/SoftSensorManager/SoftSensor", - m_pPlatform->findResource("", "coap://224.0.1.187/oc/core?rt=SoftSensorManager.Sensor", - std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1)); + OCStackResult res = OC_STACK_ERROR; + + res = OC::OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=SoftSensorManager.Sensor", + std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1)); + + if (res != OC_STACK_OK) + return SSM_E_FAIL; return SSM_S_OK; } @@ -91,7 +99,7 @@ void CResourceFinder::onExecute(IN void *pArg) SSM_CLEANUP_ASSERT(pResourceHandler->initHandler(*pResource, this)); m_mapResourceHandler[pResource->get()->host() + pResource->get()->uri()] = pResourceHandler; pResource->get()->get(queryParams, std::bind(&OICResourceHandler::onGetResourceProfile, - pResourceHandler, std::placeholders::_1, std::placeholders::_2)); + pResourceHandler, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); break; case RESOURCE_DISCOVER_SETUP_RESOURCE: diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h index dc1b524..4ddd214 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h @@ -24,6 +24,7 @@ #include "Common/PlatformLayer.h" #include "Common/InternalInterface.h" #include "OCPlatform.h" +#include "OCApi.h" class CResourceFinder : public CObjectRoot @@ -90,7 +91,7 @@ CLEANUP: m_pResource.get()->observe(OC::ObserveType::Observe, queryParams, std::bind(&OICResourceHandler::onResourceDataReceived, - this, std::placeholders::_1, std::placeholders::_2)); + this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); return SSM_S_OK; } @@ -102,7 +103,9 @@ CLEANUP: return SSM_S_OK; } - void onResourceDataReceived(const OC::OCRepresentation &representation, const int &eCode) + void onResourceDataReceived(const OC::HeaderOptions headerOptions, + const OC::OCRepresentation &representation, + const int &eCode, const int &sequenceNumber) { if (eCode == 0) { @@ -121,9 +124,9 @@ CLEANUP: { for (size_t i = 0; i < attributeMap.size() / 3; i++) { - outputProperty["name"] = attributeMap.find(std::to_string(i * 3))->second.front(); - outputProperty["type"] = attributeMap.find(std::to_string(i * 3 + 1))->second.front(); - outputProperty["value"] = attributeMap.find(std::to_string(i * 3 + 2))->second.front(); + outputProperty["name"] = attributeMap.find(std::to_string(i * 3))->second; + outputProperty["type"] = attributeMap.find(std::to_string(i * 3 + 1))->second; + outputProperty["value"] = attributeMap.find(std::to_string(i * 3 + 2))->second; ctxData.outputProperty.push_back(outputProperty); } @@ -138,7 +141,8 @@ CLEANUP: } } - void onGetResourceProfile(const OC::OCRepresentation &representation, const int &eCode) + void onGetResourceProfile(const OC::HeaderOptions &headerOptions, + const OC::OCRepresentation &representation, const int &eCode) { //unpack attributeMap @@ -184,8 +188,6 @@ CLEANUP: }; enum RESOURCE_DISCOVER_STATE {RESOURCE_DISCOVER_REQUESTPROFILE, RESOURCE_DISCOVER_SETUP_RESOURCE}; - OC::OCPlatform *m_pPlatform; - CObjectPtr m_pResourceConnectivity; IResourceFinderEvent *m_pResourceFinderEvent; CObjectPtr m_pTasker; std::map m_mapResourceHandler; diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResponseReactor.cpp b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/SensingEngine.cpp similarity index 81% rename from service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResponseReactor.cpp rename to service/soft-sensor-manager/SSMCore/src/SensorProcessor/SensingEngine.cpp index 8363cf1..20c5300 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResponseReactor.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/SensingEngine.cpp @@ -17,9 +17,9 @@ * limitations under the License. * ******************************************************************/ -#include "ResponseReactor.h" +#include "SensingEngine.h" -SSMRESULT CResponseReactor::finalConstruct() +SSMRESULT CSensingEngine::finalConstruct() { SSMRESULT res = SSM_S_OK; @@ -31,12 +31,12 @@ CLEANUP: return res; } -void CResponseReactor::finalRelease() +void CSensingEngine::finalRelease() { } -void CResponseReactor::registerContext(TypeofEvent callType, ISSMResource *pSSMResource, - IEvent *pEvent) +SSMRESULT CSensingEngine::registerContext(TypeofEvent callType, ISSMResource *pSSMResource, + IEvent *pEvent) { m_mtxRequestedContextData.lock(); // if already exists @@ -53,9 +53,11 @@ void CResponseReactor::registerContext(TypeofEvent callType, ISSMResource *pSSMR m_pContextExecutor->registerContext(callType, pSSMResource, this); m_mtxRequestedContextData.unlock(); + + return SSM_S_OK; } -void CResponseReactor::unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource, +SSMRESULT CSensingEngine::unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource, IEvent *pEvent) { m_mtxUnregisterContext.lock(); @@ -70,20 +72,24 @@ void CResponseReactor::unregisterContext(TypeofEvent callType, ISSMResource *pSS } m_mtxUnregisterContext.unlock(); + + return SSM_S_OK; } -void CResponseReactor::getList(std::vector *pList) +SSMRESULT CSensingEngine::getList(std::vector *pList) { pList->clear(); m_pContextRepository->getSoftSensorList(pList); m_pContextRepository->getPrimitiveSensorList(pList); + + return SSM_S_OK; } //Dispatch to upper layer -int CResponseReactor::onEvent(std::string type, TypeofEvent callType, - std::vector ctxData) +int CSensingEngine::onEvent(std::string type, TypeofEvent callType, + std::vector ctxData) { std::map::iterator itor; diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResponseReactor.h b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/SensingEngine.h similarity index 84% rename from service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResponseReactor.h rename to service/soft-sensor-manager/SSMCore/src/SensorProcessor/SensingEngine.h index 3652f18..7f6827a 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResponseReactor.h +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/SensingEngine.h @@ -22,22 +22,18 @@ #include "SSMInterface/SSMCore.h" #include "Common/PlatformLayer.h" - -//temp include -#include "ContextRepository.h" -#include "ContextExecutor.h" +#include "Common/InternalInterface.h" /** - * @class CResponseReactor - * @brief Class for implement of reactor pattern - * Delegate requested context to context executor layer. + * @class CSensingEngine + * @brief Class for implementing main abstration of SensorProcessor * * * @see */ -class CResponseReactor : +class CSensingEngine : public CObjectRoot - , public IResponseReactor + , public ISensingEngine { private: CObjectPtr m_pContextRepository; @@ -57,7 +53,6 @@ class CResponseReactor : CSimpleMutex m_mtxUnregisterContext; public: - SSMRESULT finalConstruct(); void finalRelease(); @@ -66,7 +61,7 @@ class CResponseReactor : if (ppObject == NULL) return SSM_E_POINTER; - if (IsEqualOID(objectID, OID_IResponseReactor)) + if (IsEqualOID(objectID, OID_ISensingEngine)) { IBase *pBase = this; pBase->addRef(); @@ -85,13 +80,14 @@ class CResponseReactor : * @param [in] ISSMResource *pSSMResource - Requested context model resource. * @param [in] IEvent *pEvent - IEvent class for callback. * - * @return void + * @return SSMRESULT * * @warning * @exception * @see */ - void registerContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, IN IEvent *pEvent); + SSMRESULT registerContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, + IN IEvent *pEvent); /** * @fn unregisterContext @@ -101,13 +97,14 @@ class CResponseReactor : * @param [in] ISSMResource *pSSMResource - Requested context model resource. * @param [in] IEvent *pEvent - IEvent class for callback. * - * @return void + * @return SSMRESULT * * @warning * @exception * @see */ - void unregisterContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, IN IEvent *pEvent); + SSMRESULT unregisterContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, + IN IEvent *pEvent); /** * @fn getList @@ -115,13 +112,13 @@ class CResponseReactor : * * @param [out] std::vector *pList - ISSMResource vector of low level context models or high level context models. * - * @return void + * @return SSMRESULT * * @warning * @exception * @see */ - virtual void getList(OUT std::vector *pList); + SSMRESULT getList(OUT std::vector *pList); /** * @fn onEvent @@ -140,6 +137,4 @@ class CResponseReactor : */ int onEvent(IN std::string name, IN TypeofEvent callType, IN std::vector ctxData); }; - - -#endif +#endif \ No newline at end of file diff --git a/service/soft-sensor-manager/SampleApp/linux/Makefile b/service/soft-sensor-manager/SampleApp/linux/Makefile index 52a3596..67a1609 100644 --- a/service/soft-sensor-manager/SampleApp/linux/Makefile +++ b/service/soft-sensor-manager/SampleApp/linux/Makefile @@ -1,4 +1,4 @@ - +-include ../../build/linux/root_path.inc -include ../../build/linux/environment.mk MAKE=make diff --git a/service/soft-sensor-manager/SampleApp/linux/ClientApp/build/Makefile b/service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/build/Makefile similarity index 62% rename from service/soft-sensor-manager/SampleApp/linux/ClientApp/build/Makefile rename to service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/build/Makefile index 37378e3..54a71c8 100644 --- a/service/soft-sensor-manager/SampleApp/linux/ClientApp/build/Makefile +++ b/service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/build/Makefile @@ -1,4 +1,4 @@ - +-include ../../../../build/linux/root_path.inc -include ../../../../build/linux/environment.mk BOOST=${BOOST_BASE} @@ -7,15 +7,19 @@ INC_PATH=../include RST_NAME=release # Insert your project name. -TARGET=ClientApp +TARGET=SSMTesterApp CXX=g++ CXX_FLAGS=-std=c++0x -Wall -DLINUX -CXX_INC=-I${SRC_PATH}/ -I${INC_PATH}/ -I${OUTPUTS_DIR} -I${IOT_BASE}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} +CXX_INC=-I${SRC_PATH}/ -I${INC_PATH}/ -I${OUTPUTS_DIR} -I${IOT_BASE}/include/ -I${IOT_LOG_DIR}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} + +CXX_LIB+=${OUTPUTS_DIR}/${SSM_LIB} +CXX_LIB+=${OUTPUTS_DIR}/${SSMCORE_LIB} CXX_LIB+=${IOT_RELEASE}/${IOT_LIB} CXX_LIB+=${IOT_CSDK_RELEASE}/${IOT_CSDK_LIB} -CXX_LIB+=-lpthread +CXX_LIB+=${IOT_LOG_DIR}/lib/${IOT_LOG_LIB} +CXX_LIB+=-lpthread -ldl SRCLIST=${wildcard ${SRC_PATH}/*.cpp} OBJPATH=${SRCLIST:.cpp=.o} @@ -28,11 +32,11 @@ all: pre_job ${TARGET} post_job pre_job: @echo " " - @echo "--------- ClientApp Build Begin. -----------" + @echo "--------- ${TARGET} Build Begin. -----------" @mkdir -p ${RST_NAME} @echo " " -${TARGET}: ${OBJLIST} ${OUTPUTS_DIR}/SSMClient.o +${TARGET}: ${OBJLIST} $(CXX) $(CXX_FLAGS) -o ./${RST_NAME}/$@ $^ ${CXX_LIB} @echo " " @@ -43,7 +47,7 @@ ${TARGET}: ${OBJLIST} ${OUTPUTS_DIR}/SSMClient.o post_job: @echo " " cp -Rdp ./${RST_NAME}/${TARGET} ${OUTPUTS_DIR}/ - @echo "----------- ClientApp Build Successful. ------------" + @echo "----------- ${TARGET} Build Successful. ------------" @echo "Enter to ${RST_NAME} folder." @echo " " diff --git a/service/soft-sensor-manager/SampleApp/linux/ClientApp/include/SSMTestApp.h b/service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/include/SSMTestApp.h similarity index 100% rename from service/soft-sensor-manager/SampleApp/linux/ClientApp/include/SSMTestApp.h rename to service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/include/SSMTestApp.h diff --git a/service/soft-sensor-manager/SampleApp/linux/ClientApp/src/SSMTestApp.cpp b/service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/src/SSMTestApp.cpp similarity index 97% rename from service/soft-sensor-manager/SampleApp/linux/ClientApp/src/SSMTestApp.cpp rename to service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/src/SSMTestApp.cpp index 907790d..e4a0d1d 100644 --- a/service/soft-sensor-manager/SampleApp/linux/ClientApp/src/SSMTestApp.cpp +++ b/service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/src/SSMTestApp.cpp @@ -107,15 +107,15 @@ void SSMTestApp::onRegisterQuery(const AttributeMap &attributeMap, SSMReturn &eC { if (strcmp(itor->first.c_str(), "temperature") == 0) { - std::cout << "* Temperature : " << itor->second.front().c_str() << "℃" << std::endl; + std::cout << "* Temperature : " << itor->second.c_str() << "℃" << std::endl; } else if (strcmp(itor->first.c_str(), "humidity") == 0) { - std::cout << "* Humidity : " << itor->second.front().c_str() << "%" << std::endl; + std::cout << "* Humidity : " << itor->second.c_str() << "%" << std::endl; } else if (strcmp(itor->first.c_str(), "discomfortIndex") == 0) { - int DI = std::stoi(itor->second.front().c_str()); + int DI = std::stoi(itor->second.c_str()); std::cout << "* DiscomfortIndex : " << DI << "%" << std::endl; diff --git a/service/soft-sensor-manager/SampleApp/linux/THSensorApp/build/Makefile b/service/soft-sensor-manager/SampleApp/linux/THSensorApp/build/Makefile index eaa5630..28802e8 100644 --- a/service/soft-sensor-manager/SampleApp/linux/THSensorApp/build/Makefile +++ b/service/soft-sensor-manager/SampleApp/linux/THSensorApp/build/Makefile @@ -1,4 +1,4 @@ - +-include ../../../../build/linux/root_path.inc -include ../../../../build/linux/environment.mk BOOST=${BOOST_BASE} @@ -11,10 +11,11 @@ TARGET=THSensorApp CXX=g++ CXX_FLAGS=-std=c++0x -Wall -DLINUX -CXX_INC=-I${INC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} +CXX_INC=-I${INC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_LOG_DIR}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} CXX_LIB+=${IOT_RELEASE}/${IOT_LIB} CXX_LIB+=${IOT_CSDK_RELEASE}/${IOT_CSDK_LIB} +CXX_LIB+=${IOT_LOG_DIR}/lib/${IOT_LOG_LIB} CXX_LIB+=-lpthread SRCLIST=${wildcard ${SRC_PATH}/*.cpp} @@ -28,7 +29,7 @@ all: pre_job ${TARGET} post_job pre_job: @echo " " - @echo "---------- THSensorApp Build Begin. ------------" + @echo "---------- ${TARGET} Build Begin. ------------" @mkdir -p ${RST_NAME} @echo " " @@ -43,7 +44,7 @@ ${TARGET}: ${OBJLIST} post_job: @echo " " cp -Rdp ./${RST_NAME}/* ${OUTPUTS_DIR}/ - @echo "----------- THSensorApp Build Successful. -------------" + @echo "----------- ${TARGET} Build Successful. -------------" @echo "Enter to ${RST_NAME} folder." @echo " " diff --git a/service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h b/service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h index 8431ceb..d8b5dc8 100644 --- a/service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h +++ b/service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h @@ -35,8 +35,8 @@ using namespace std; #include #include -#define COAP_IP "134.134.161.33" -#define COAP_PORT 56830 +#define COAP_IP "0.0.0.0" +#define COAP_PORT 0 #define COAP_MODE ModeType::Server #define COAP_SRVTYPE ServiceType::InProc @@ -50,27 +50,39 @@ class TemphumidResource /// Access this property from a TB client int m_humid; int m_temp; - string m_resourceUri; + std::string m_resourceUri; + std::vector m_resourceTypes; + std::vector m_resourceInterfaces; OCResourceHandle m_resourceHandle; + OCRepresentation m_resourceRep; + ObservationIds m_interestedObservers; public: /// Constructor TemphumidResource() : - m_humid(0), m_temp(0), m_resourceUri("/Thing_TempHumSensor"), m_resourceHandle(NULL) + m_humid(0), m_temp(0) { + m_resourceUri = "/Thing_TempHumSensor"; + m_resourceTypes.push_back(COAP_TYPE_NAME); + m_resourceInterfaces.push_back(DEFAULT_INTERFACE); + + printf("Running thing as %s\n", m_resourceUri.c_str()); + m_resourceRep.setUri(m_resourceUri); + m_resourceRep.setResourceTypes(m_resourceTypes); + m_resourceRep.setResourceInterfaces(m_resourceInterfaces); } ~TemphumidResource() { } - void registerResource(OC::OCPlatform &platform); + void registerResource(); OCResourceHandle getHandle(); - void setRepresentation(AttributeMap &attributeMap); + void setResourceRepresentation(OCRepresentation &rep); - void getRepresentation(AttributeMap &attributeMap); + OCRepresentation getResourceRepresentation(); }; #endif /* THINGRESOURCESERVER_H_ */ diff --git a/service/soft-sensor-manager/SampleApp/linux/THSensorApp/src/ThingResourceServer.cpp b/service/soft-sensor-manager/SampleApp/linux/THSensorApp/src/ThingResourceServer.cpp index 8c32639..2950101 100644 --- a/service/soft-sensor-manager/SampleApp/linux/THSensorApp/src/ThingResourceServer.cpp +++ b/service/soft-sensor-manager/SampleApp/linux/THSensorApp/src/ThingResourceServer.cpp @@ -22,24 +22,20 @@ int g_Observation = 0; -void entityHandler(std::shared_ptr< OCResourceRequest > request, - std::shared_ptr< OCResourceResponse > response); +OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request, + std::shared_ptr< OCResourceResponse > response); /* * TempResourceFunctions */ -void TemphumidResource::registerResource(OC::OCPlatform &platform) +void TemphumidResource::registerResource() { - string resourceURI = m_resourceUri; // URI of the resource - string resourceTypeName = COAP_TYPE_NAME; // resource type name. - string resourceInterface = DEFAULT_INTERFACE; // resource interface. - uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE; // This will internally create and register the resource. - OCStackResult result = platform.registerResource(m_resourceHandle, resourceURI, - resourceTypeName, resourceInterface, &entityHandler, resourceProperty); + OCStackResult result = OC::OCPlatform::registerResource(m_resourceHandle, m_resourceUri, + m_resourceTypes[0], m_resourceInterfaces[0], &entityHandler, resourceProperty); if (OC_STACK_OK != result) { @@ -52,29 +48,37 @@ OCResourceHandle TemphumidResource::getHandle() return m_resourceHandle; } -void TemphumidResource::setRepresentation(AttributeMap &attributeMap) +void TemphumidResource::setResourceRepresentation(OCRepresentation &rep) { - cout << "\t\t\t" << "Received representation: " << endl; - cout << "\t\t\t\t" << "temp: " << attributeMap["temp"][0] << endl; - cout << "\t\t\t\t" << "humid: " << attributeMap["humid"][0] << endl; + int tempHumid; + int tempTemp; + + rep.getValue("2", tempTemp); + rep.getValue("5", tempHumid); - m_temp = std::stoi(attributeMap["temp"][0]); - m_humid = std::stoi(attributeMap["humid"][0]); + m_humid = tempHumid; + m_temp = tempTemp; + + cout << "\t\t\t" << "Received representation: " << endl; + cout << "\t\t\t\t" << "temp: " << m_humid << endl; + cout << "\t\t\t\t" << "humid: " << m_temp << endl; } -void TemphumidResource::getRepresentation(AttributeMap &attributeMap) +OCRepresentation TemphumidResource::getResourceRepresentation() { - attributeMap["0"].push_back("temperature"); - attributeMap["1"].push_back("int"); - - attributeMap["2"].push_back(to_string(m_temp)); - attributeMap["3"].push_back("humidity"); - attributeMap["4"].push_back("int"); + // This representation is temporaily for soft-sensor-management - name, type, vale + m_resourceRep.setValue("0", std::string("temperature")); + m_resourceRep.setValue("1", std::string("int")); + m_resourceRep.setValue("2", std::to_string(m_temp)); + m_resourceRep.setValue("3", std::string("humidity")); + m_resourceRep.setValue("4", std::string("int")); + m_resourceRep.setValue("5", std::to_string(m_humid)); - attributeMap["5"].push_back(to_string(m_humid)); + return m_resourceRep; } +// Create the instance of the TemphumidResource class TemphumidResource g_myResource; void *TestSensorVal(void *param) @@ -97,7 +101,7 @@ void *TestSensorVal(void *param) cout << "Notifying observers with resource handle: " << g_myResource.getHandle() << endl; - OCStackResult result = OCPlatform::notifyObservers(g_myResource.getHandle()); + OCStackResult result = OCPlatform::notifyAllObservers(g_myResource.getHandle()); if (OC_STACK_NO_OBSERVERS == result) { @@ -109,8 +113,8 @@ void *TestSensorVal(void *param) return NULL; } -void entityHandler(std::shared_ptr< OCResourceRequest > request, - std::shared_ptr< OCResourceResponse > response) +OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request, + std::shared_ptr< OCResourceResponse > response) { cout << "\tIn Server CPP entity handler:\n"; @@ -118,15 +122,16 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, { // Get the request type and request flag std::string requestType = request->getRequestType(); - RequestHandlerFlag requestFlag = request->getRequestHandlerFlag(); + int requestFlag = request->getRequestHandlerFlag(); - if (requestFlag == RequestHandlerFlag::InitFlag) + if (requestFlag & RequestHandlerFlag::InitFlag) { cout << "\t\trequestFlag : Init\n"; // entity handler to perform resource initialization operations } - else if (requestFlag == RequestHandlerFlag::RequestFlag) + + if (requestFlag & RequestHandlerFlag::RequestFlag) { cout << "\t\trequestFlag : Request\n"; @@ -136,20 +141,14 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, cout << "\t\t\trequestType : GET\n"; // Check for query params (if any) - QueryParamsMap queryParamsMap = request->getQueryParameters(); - // Process query params and do required operations .. // Get the representation of this resource at this point and send it as response - OCRepresentation rep = request->getResourceRepresentation(); - AttributeMap attributeMap; - - g_myResource.getRepresentation(attributeMap); + OCRepresentation rep = g_myResource.getResourceRepresentation(); if (response) { // TODO Error Code - rep.setAttributeMap(attributeMap); response->setErrorCode(200); response->setResourceRepresentation(rep, DEFAULT_INTERFACE); } @@ -167,7 +166,8 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, // DELETE request operations } } - else if (requestFlag == RequestHandlerFlag::ObserverFlag) + + if (requestFlag & RequestHandlerFlag::ObserverFlag) { pthread_t threadId; @@ -187,18 +187,20 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, { std::cout << "Request invalid" << std::endl; } + + return OC_EH_OK; } int main() { // Create PlatformConfig object - PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable); + PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, OC::QualityOfService::LowQos); try { - OCPlatform platform(cfg); + OC::OCPlatform::Configure(cfg); - g_myResource.registerResource(platform); + g_myResource.registerResource(); int input = 0; cout << "Type any key to terminate" << endl; diff --git a/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/build/Makefile b/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/build/Makefile index 360f3ef..a195f01 100644 --- a/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/build/Makefile +++ b/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/build/Makefile @@ -1,4 +1,4 @@ - +-include ../../../../build/linux/root_path.inc -include ../../../../build/linux/environment.mk BOOST=${BOOST_BASE} @@ -11,10 +11,11 @@ TARGET=THSensorApp1 CXX=g++ CXX_FLAGS=-std=c++0x -Wall -DLINUX -CXX_INC=-I${INC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} +CXX_INC=-I${INC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_LOG_DIR}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} CXX_LIB+=${IOT_RELEASE}/${IOT_LIB} CXX_LIB+=${IOT_CSDK_RELEASE}/${IOT_CSDK_LIB} +CXX_LIB+=${IOT_LOG_DIR}/lib/${IOT_LOG_LIB} CXX_LIB+=-lpthread SRCLIST=${wildcard ${SRC_PATH}/*.cpp} @@ -28,7 +29,7 @@ all: pre_job ${TARGET} post_job pre_job: @echo " " - @echo "---------- THSensorApp Build Begin. ------------" + @echo "---------- ${TARGET} Build Begin. ------------" @mkdir -p ${RST_NAME} @echo " " @@ -43,7 +44,7 @@ ${TARGET}: ${OBJLIST} post_job: @echo " " cp -Rdp ./${RST_NAME}/* ${OUTPUTS_DIR}/ - @echo "----------- THSensorApp Build Successful. -------------" + @echo "----------- ${TARGET} Build Successful. -------------" @echo "Enter to ${RST_NAME} folder." @echo " " diff --git a/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h b/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h index eada4e6..b32b589 100644 --- a/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h +++ b/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h @@ -35,8 +35,8 @@ using namespace std; #include #include -#define COAP_IP "134.134.161.33" -#define COAP_PORT 56838 +#define COAP_IP "0.0.0.0" +#define COAP_PORT 0 #define COAP_MODE ModeType::Server #define COAP_SRVTYPE ServiceType::InProc @@ -50,27 +50,39 @@ class TemphumidResource /// Access this property from a TB client int m_humid; int m_temp; - string m_resourceUri; + std::string m_resourceUri; + std::vector m_resourceTypes; + std::vector m_resourceInterfaces; OCResourceHandle m_resourceHandle; + OCRepresentation m_resourceRep; + ObservationIds m_interestedObservers; public: /// Constructor TemphumidResource() : - m_humid(0), m_temp(0), m_resourceUri("/Thing_TempHumSensor1"), m_resourceHandle(NULL) + m_humid(0), m_temp(0) { + m_resourceUri = "/Thing_TempHumSensor1"; + m_resourceTypes.push_back(COAP_TYPE_NAME); + m_resourceInterfaces.push_back(DEFAULT_INTERFACE); + + printf("Running thing as %s\n", m_resourceUri.c_str()); + m_resourceRep.setUri(m_resourceUri); + m_resourceRep.setResourceTypes(m_resourceTypes); + m_resourceRep.setResourceInterfaces(m_resourceInterfaces); } ~TemphumidResource() { } - void registerResource(OC::OCPlatform &platform); + void registerResource(); OCResourceHandle getHandle(); - void setRepresentation(AttributeMap &attributeMap); + void setResourceRepresentation(OCRepresentation &rep); - void getRepresentation(AttributeMap &attributeMap); + OCRepresentation getResourceRepresentation(); }; #endif /* THINGRESOURCESERVER_H_ */ diff --git a/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/src/ThingResourceServer1.cpp b/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/src/ThingResourceServer1.cpp index b1d3857..6652fef 100644 --- a/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/src/ThingResourceServer1.cpp +++ b/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/src/ThingResourceServer1.cpp @@ -22,24 +22,20 @@ int g_Observation = 0; -void entityHandler(std::shared_ptr< OCResourceRequest > request, - std::shared_ptr< OCResourceResponse > response); +OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request, + std::shared_ptr< OCResourceResponse > response); /* - * TempResourceFunctions - */ +* TempResourceFunctions +*/ -void TemphumidResource::registerResource(OC::OCPlatform &platform) +void TemphumidResource::registerResource() { - string resourceURI = m_resourceUri; // URI of the resource - string resourceTypeName = COAP_TYPE_NAME; // resource type name. - string resourceInterface = DEFAULT_INTERFACE; // resource interface. - uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE; // This will internally create and register the resource. - OCStackResult result = platform.registerResource(m_resourceHandle, resourceURI, - resourceTypeName, resourceInterface, &entityHandler, resourceProperty); + OCStackResult result = OC::OCPlatform::registerResource(m_resourceHandle, m_resourceUri, + m_resourceTypes[0], m_resourceInterfaces[0], &entityHandler, resourceProperty); if (OC_STACK_OK != result) { @@ -52,29 +48,37 @@ OCResourceHandle TemphumidResource::getHandle() return m_resourceHandle; } -void TemphumidResource::setRepresentation(AttributeMap &attributeMap) +void TemphumidResource::setResourceRepresentation(OCRepresentation &rep) { - cout << "\t\t\t" << "Received representation: " << endl; - cout << "\t\t\t\t" << "temp: " << attributeMap["temp"][0] << endl; - cout << "\t\t\t\t" << "humid: " << attributeMap["humid"][0] << endl; + int tempHumid; + int tempTemp; + + rep.getValue("2", tempTemp); + rep.getValue("5", tempHumid); - m_temp = std::stoi(attributeMap["temp"][0]); - m_humid = std::stoi(attributeMap["humid"][0]); + m_humid = tempHumid; + m_temp = tempTemp; + + cout << "\t\t\t" << "Received representation: " << endl; + cout << "\t\t\t\t" << "temp: " << m_humid << endl; + cout << "\t\t\t\t" << "humid: " << m_temp << endl; } -void TemphumidResource::getRepresentation(AttributeMap &attributeMap) +OCRepresentation TemphumidResource::getResourceRepresentation() { - attributeMap["0"].push_back("temperature"); - attributeMap["1"].push_back("int"); - - attributeMap["2"].push_back(to_string(m_temp)); - attributeMap["3"].push_back("humidity"); - attributeMap["4"].push_back("int"); + // This representation is temporaily for soft-sensor-management - name, type, vale + m_resourceRep.setValue("0", std::string("temperature")); + m_resourceRep.setValue("1", std::string("int")); + m_resourceRep.setValue("2", std::to_string(m_temp)); + m_resourceRep.setValue("3", std::string("humidity")); + m_resourceRep.setValue("4", std::string("int")); + m_resourceRep.setValue("5", std::to_string(m_humid)); - attributeMap["5"].push_back(to_string(m_humid)); + return m_resourceRep; } +// Create the instance of the TemphumidResource class TemphumidResource g_myResource; void *TestSensorVal(void *param) @@ -97,7 +101,7 @@ void *TestSensorVal(void *param) cout << "Notifying observers with resource handle: " << g_myResource.getHandle() << endl; - OCStackResult result = OCPlatform::notifyObservers(g_myResource.getHandle()); + OCStackResult result = OCPlatform::notifyAllObservers(g_myResource.getHandle()); if (OC_STACK_NO_OBSERVERS == result) { @@ -109,8 +113,8 @@ void *TestSensorVal(void *param) return NULL; } -void entityHandler(std::shared_ptr< OCResourceRequest > request, - std::shared_ptr< OCResourceResponse > response) +OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request, + std::shared_ptr< OCResourceResponse > response) { cout << "\tIn Server CPP entity handler:\n"; @@ -118,15 +122,16 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, { // Get the request type and request flag std::string requestType = request->getRequestType(); - RequestHandlerFlag requestFlag = request->getRequestHandlerFlag(); + int requestFlag = request->getRequestHandlerFlag(); - if (requestFlag == RequestHandlerFlag::InitFlag) + if (requestFlag & RequestHandlerFlag::InitFlag) { cout << "\t\trequestFlag : Init\n"; // entity handler to perform resource initialization operations } - else if (requestFlag == RequestHandlerFlag::RequestFlag) + + if (requestFlag & RequestHandlerFlag::RequestFlag) { cout << "\t\trequestFlag : Request\n"; @@ -136,20 +141,14 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, cout << "\t\t\trequestType : GET\n"; // Check for query params (if any) - QueryParamsMap queryParamsMap = request->getQueryParameters(); - // Process query params and do required operations .. // Get the representation of this resource at this point and send it as response - OCRepresentation rep = request->getResourceRepresentation(); - AttributeMap attributeMap; - - g_myResource.getRepresentation(attributeMap); + OCRepresentation rep = g_myResource.getResourceRepresentation(); if (response) { // TODO Error Code - rep.setAttributeMap(attributeMap); response->setErrorCode(200); response->setResourceRepresentation(rep, DEFAULT_INTERFACE); } @@ -167,7 +166,8 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, // DELETE request operations } } - else if (requestFlag == RequestHandlerFlag::ObserverFlag) + + if (requestFlag & RequestHandlerFlag::ObserverFlag) { pthread_t threadId; @@ -178,7 +178,7 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, if (!startedThread) { - pthread_create(&threadId, NULL, TestSensorVal, (void *) NULL); + pthread_create(&threadId, NULL, TestSensorVal, (void *)NULL); startedThread = 1; } } @@ -187,19 +187,20 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request, { std::cout << "Request invalid" << std::endl; } + + return OC_EH_OK; } int main() { // Create PlatformConfig object - - PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable); + PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, OC::QualityOfService::LowQos); try { - OCPlatform platform(cfg); + OC::OCPlatform::Configure(cfg); - g_myResource.registerResource(platform); + g_myResource.registerResource(); int input = 0; cout << "Type any key to terminate" << endl; diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/CMakeLists.txt b/service/soft-sensor-manager/SampleApp/tizen/ClientApp/CMakeLists.txt deleted file mode 100644 index 95611d0..0000000 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(oic) - -SET(CMAKE_SHARED_LINKER_FLAGS " -Wl,--as-needed") -SET(CMAKE_EXE_LINKER_FLAGS " -Wl,--as-needed -Wl,--hash-style=both") -SET(EX_SERVER "simpleserver") -SET(EX_CLIENT "simpleclient") -SET(EX_CLIENTSERVER "simpleclientserver") -SET(OCTBSTACK "octbstack") - -INCLUDE_DIRECTORIES(include) -INCLUDE_DIRECTORIES(csdk/stack/include) -INCLUDE_DIRECTORIES(csdk/ocsocket/include) -INCLUDE_DIRECTORIES(csdk/ocrandom/include) -INCLUDE_DIRECTORIES(csdk/logger/include) -INCLUDE_DIRECTORIES(csdk/libcoap-4.1.1) -INCLUDE_DIRECTORIES(${INCLUDE_INSTALL_DIR}/boost) -LINK_DIRECTORIES(${CMAKE_BINARY_DIR}) - -#SET(EXTRA_CXXFLAGS "-std=c++11") -SET(EXTRA_CXXFLAGS "-g3 -std=c++0x") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}") - -SET(SRCS - OCLib/OCReflect.cpp - OCLib/OCPlatform.cpp - OCLib/OCResource.cpp - OCLib/OCUtilities.cpp - OCLib/InProcServerWrapper.cpp - OCLib/InProcClientWrapper.cpp) -ADD_LIBRARY(${PROJECT_NAME} STATIC ${SRCS}) - -ADD_EXECUTABLE(${EX_SERVER} examples/simpleserver.cpp) -TARGET_LINK_LIBRARIES(${EX_SERVER} ${PROJECT_NAME} ${OCTBSTACK} pthread) -INSTALL(TARGETS ${EX_SERVER} DESTINATION ${BIN_INSTALL_DIR}) - -ADD_EXECUTABLE(${EX_CLIENT} examples/simpleclient.cpp) -TARGET_LINK_LIBRARIES(${EX_CLIENT} ${PROJECT_NAME} ${OCTBSTACK} pthread) -INSTALL(TARGETS ${EX_CLIENT} DESTINATION ${BIN_INSTALL_DIR}) - -ADD_EXECUTABLE(${EX_CLIENTSERVER} examples/simpleclientserver.cpp) -TARGET_LINK_LIBRARIES(${EX_CLIENTSERVER} ${PROJECT_NAME} ${OCTBSTACK} pthread) -INSTALL(TARGETS ${EX_CLIENTSERVER} DESTINATION ${BIN_INSTALL_DIR}) - -ADD_SUBDIRECTORY(csdk) -#ADD_SUBDIRECTORY(examples) -ADD_SUBDIRECTORY(oic-sample) diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/build.sh b/service/soft-sensor-manager/SampleApp/tizen/ClientApp/build.sh deleted file mode 100644 index 7b56050..0000000 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Prevent Support Tool(Defect analysis and commit) Execution Batch File!! - -# variables -SDBPATH=/home/iotivity/tizen-sdk/tools/sdb -GBSRPMPATH=/home/iotivity/GBS-ROOT/rsa/local/repos/rsa/armv7l/RPMS -PACKAGE=oic-0.0.1-0.armv7l.rpm - -gbs build -A armv7l --include-all --ccache - -$SDBPATH root on - -$SDBPATH push $GBSRPMPATH/$PACKAGE /root/ - -$SDBPATH shell rpm -Uvh --force /root/oic-0.0.1-0.armv7l.rpm - -$SDBPATH shell /usr/apps/com.samsung.oicapp-test/bin/oicapp-test diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/com.samsung.oicapp-test.rule b/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/com.samsung.oicapp-test.rule deleted file mode 100644 index fad1929..0000000 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/com.samsung.oicapp-test.rule +++ /dev/null @@ -1,3 +0,0 @@ -com.samsung.oicapp-test system::use_internet r - -system::use_internet com.samsung.oicapp-test r diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/com.samsung.oicapp-test.xml b/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/com.samsung.oicapp-test.xml deleted file mode 100644 index 5a79f6e..0000000 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/com.samsung.oicapp-test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Name - OIC test Application - - com.samsung.oicapp-test.png - - - diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/ISSMClientListener.h b/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/ISSMClientListener.h deleted file mode 100644 index f425b3d..0000000 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/ISSMClientListener.h +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************** - * - * Copyright 2014 Samsung Electronics All Rights Reserved. - * - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************/ - -/** - * @file ISSMClientListener.h - * @brief This file contains client listener interfaces. - */ - -#ifndef ISSMCLIENTLISTENER_H_ -#define ISSMCLIENTLISTENER_H_ -#include -#include "OCPlatform.h" - -/** - * @brief This enum defines Soft Sensor return types - */ -typedef enum -{ - SSM_SUCCESS, SSM_ERROR, SSM_ERROR_QUERY_PARSING, SSM_ERROR_NO_QUERY, SSM_ERROR_NETWORK -} SSMReturn; - -using namespace OC; -/** - * @brief ISSMClientListener is a listener interface from which application is derived to get callback from SoftSensorManager service - */ -class ISSMClientListener -{ - public: - /** - * @brief onRegisterQuery is a pure virtual operation which should be implemented in applications to get callback messages. - * @param [in] attributeMap - A data map in which SoftSensorManager service sends sensor data with cqid. - * @param [in] eCode - The address of listener class. When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that - * SSMClient can callback message to the appication. - * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request. - * @return SSMReturn - - */ - virtual void onRegisterQuery(const AttributeMap &attributeMap, SSMReturn &eCode) = 0; - virtual ~ISSMClientListener() - { - } -}; - -#endif /* ISSMCLIENTLISTENER_H_ */ diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/SSMClient.cpp b/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/SSMClient.cpp deleted file mode 100644 index e3375f2..0000000 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/SSMClient.cpp +++ /dev/null @@ -1,337 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Samsung Electronics All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -#include -#include - -#include "SSMClient.h" -#include "OCPlatform.h" -#include "OCApi.h" - -const char *SSM_RESOURCE_URI = "/service/SoftSensorManager"; - -#define SSM_RESOURCE_TYPE = "core.SoftSensorManager" - -#define COAP_IP "134.134.161.33" -#define COAP_PORT 5683 -#define COAP_MODE ModeType::Client -#define COAP_SRVTYPE ServiceType::InProc - -#define COAP_SERVER_ADDR "coap://224.0.1.187/oc/core?rt=core.SoftSensorManager" - -SSMClient::SSMClient() -{ - m_sem.create(100000); - m_pPlatform = NULL; - m_appListener = NULL; - m_retResponse = SSM_ERROR; - _findResource(); - _createQueryEngine(); -} - -SSMClient::~SSMClient() -{ - _releaseQueryEngine(m_queryEngineId); - if (m_pPlatform) - { - delete m_pPlatform; - m_pPlatform = NULL; - } -} - -void SSMClient::_findResource() -{ - // Create PlatformConfig object - PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::Confirmable); - - // Create a OCPlatform instance. - // Note: Platform creation is synchronous call. - try - { - m_pPlatform = new OCPlatform(cfg); - - // Find all resources - OCStackResult result; - if ((result = m_pPlatform->findResource("", COAP_SERVER_ADDR, - std::bind(&SSMClient::onFoundResource, this, std::placeholders::_1))) - != OC_STACK_OK) - { - delete m_pPlatform; - m_pPlatform = NULL; - return; - } - - m_sem.wait(); - - } - catch (OCException e) - { - //log(e.what()); - } -} - -void SSMClient::_createQueryEngine(void) -{ - OCRepresentation rep; - - AttributeMap requestAttributeMap; - AttributeValues commandValue; - - QueryParamsMap queryParamsMap; - - commandValue.push_back("CreateQueryEngine"); - - requestAttributeMap["command"] = commandValue; - - rep.setAttributeMap(requestAttributeMap); - - if (m_SSMResource->put(rep, queryParamsMap, - std::bind(&SSMClient::onCreateQueryEngine, this, std::placeholders::_1, - std::placeholders::_2)) != OC_STACK_OK) - { - return; - } - - m_sem.wait(); -} - -void SSMClient::_releaseQueryEngine(std::string queryEngineId) -{ - OCRepresentation rep; - - AttributeMap requestAttributeMap; - AttributeValues commandValue; - AttributeValues queryEngineIdValue; - - QueryParamsMap queryParamsMap; - - commandValue.push_back("ReleaseQueryEngine"); - - requestAttributeMap["command"] = commandValue; - - queryEngineIdValue.push_back(queryEngineId); - - requestAttributeMap["queryEngineId"] = queryEngineIdValue; - - rep.setAttributeMap(requestAttributeMap); - - m_SSMResource->put(rep, queryParamsMap, - std::bind(&SSMClient::onReleaseQueryEngine, this, std::placeholders::_1, - std::placeholders::_2)); - - m_sem.wait(); -} - -SSMReturn SSMClient::registerQuery(std::string queryString, ISSMClientListener *listener, - std::string &cqid) -{ - OCRepresentation rep; - - AttributeMap requestAttributeMap; - AttributeValues commandValue; - AttributeValues queryEngineIdValue; - AttributeValues contextQueryValue; - - QueryParamsMap queryParamsMap; - - commandValue.push_back("ExecuteContextQuery"); - - requestAttributeMap["command"] = commandValue; - - queryEngineIdValue.push_back(m_queryEngineId); - - requestAttributeMap["queryEngineId"] = queryEngineIdValue; - - contextQueryValue.push_back(queryString); - - requestAttributeMap["contextQuery"] = contextQueryValue; - - m_appListener = listener; - - rep.setAttributeMap(requestAttributeMap); - - if (m_SSMResource->put(rep, queryParamsMap, - std::bind(&SSMClient::onRegisterQuery, this, std::placeholders::_1, - std::placeholders::_2)) != OC_STACK_OK) - return SSM_ERROR_NETWORK; - - m_sem.wait(); - - if (m_retResponse == SSM_SUCCESS) - { - cqid = m_responseAttributeMap["CQID"].back(); - } - - return m_retResponse; -} - -SSMReturn SSMClient::unregisterQuery(std::string cqid) -{ - OCRepresentation rep; - - AttributeMap requestAttributeMap; - AttributeValues commandValue; - AttributeValues queryEngineIdValue; - AttributeValues cqidValue; - - QueryParamsMap queryParamsMap; - - commandValue.push_back("KillContextQuery"); - - requestAttributeMap["command"] = commandValue; - - queryEngineIdValue.push_back(m_queryEngineId); - - requestAttributeMap["queryEngineId"] = queryEngineIdValue; - - cqidValue.push_back(cqid); - - requestAttributeMap["CQID"] = cqidValue; - - rep.setAttributeMap(requestAttributeMap); - - if (m_SSMResource->put(rep, queryParamsMap, - std::bind(&SSMClient::onUnregisterQuery, this, std::placeholders::_1, - std::placeholders::_2)) != OC_STACK_OK) - return SSM_ERROR_NETWORK; - - m_sem.wait(); - - return m_retResponse; -} - -/** - * Callback Function List. - */ -// Callback to found resources -void SSMClient::onFoundResource(std::shared_ptr< OCResource > resource) -{ - std::string resourceURI; - try - { - // Do some operations with resource object. - if (resource) - { - // Get the resource URI - resourceURI = resource->uri(); - - if (resourceURI.compare(SSM_RESOURCE_URI) == 0) - { - m_SSMResource = resource; - } - } - } - catch (std::exception &e) - { - //log(e.what()); - } - - m_sem.release(); -} - -void SSMClient::onCreateQueryEngine(const OCRepresentation &rep, const int eCode) -{ - if (eCode != 0) - { - m_retResponse = SSM_ERROR_NETWORK; - goto CLEANUP; - } - - m_responseAttributeMap = rep.getAttributeMap(); - m_queryEngineId = m_responseAttributeMap["queryEngineId"].back(); - m_responseAttributeMap["queryEngineId"].pop_back(); - m_retResponse = SSM_SUCCESS; - -CLEANUP: m_sem.release(); -} - -void SSMClient::onRegisterQuery(const OCRepresentation &rep, const int eCode) -{ - QueryParamsMap queryParamsMap; - - if (eCode != 0) - { - m_retResponse = SSM_ERROR_NETWORK; - goto CLEANUP; - } - - m_responseAttributeMap = rep.getAttributeMap(); - - if (m_responseAttributeMap.find("error") != m_responseAttributeMap.end()) - { - m_retResponse = SSM_ERROR_QUERY_PARSING; - goto CLEANUP; - } - - m_SSMResource->observe(ObserveType::Observe, queryParamsMap, - std::bind(&SSMClient::onObserve, this, std::placeholders::_1, std::placeholders::_2)); - - m_retResponse = SSM_SUCCESS; - -CLEANUP: m_sem.release(); -} - -void SSMClient::onUnregisterQuery(const OCRepresentation &rep, const int eCode) -{ - if (eCode != 0) - { - m_retResponse = SSM_ERROR_NETWORK; - goto CLEANUP; - } - - m_responseAttributeMap = rep.getAttributeMap(); - - if (m_responseAttributeMap.find("error") != m_responseAttributeMap.end()) - { - m_retResponse = SSM_ERROR_NO_QUERY; - goto CLEANUP; - } - - m_retResponse = SSM_SUCCESS; - -CLEANUP: m_sem.release(); -} - -void SSMClient::onReleaseQueryEngine(const OCRepresentation &rep, const int eCode) -{ - if (eCode != 0) - { - m_retResponse = SSM_ERROR_NETWORK; - goto CLEANUP; - } - - m_responseAttributeMap = rep.getAttributeMap(); - - m_retResponse = SSM_SUCCESS; - -CLEANUP: m_sem.release(); -} - -void SSMClient::onObserve(const OCRepresentation &rep, const int &eCode) -{ - SSMReturn ret = SSM_SUCCESS; - - if (eCode != 0) - { - ret = SSM_ERROR_NETWORK; - } - - m_appListener->onRegisterQuery(rep.getAttributeMap(), ret); -} diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/SSMClient.h b/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/SSMClient.h deleted file mode 100644 index 1ee47bd..0000000 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/SSMClient.h +++ /dev/null @@ -1,243 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 Samsung Electronics All Rights Reserved. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -/** - * @file SSMClient.h - * @brief This file contains the declaration of classes and its members related to SSMClient. - */ - -#ifndef RESOURCECLIENT_H_ -#define RESOURCECLIENT_H_ - -#include - -#include "OCResource.h" -#include "OCPlatform.h" -#include "ISSMClientListener.h" - -using namespace OC; - -#if defined(WIN32) -class CSemaphore -{ - private: - HANDLE hSemaphore; - int m_MaxTimeOut; - - public: - /** - * This is CSemaphore constructor. - */ - CSemaphore() - { - m_MaxTimeOut = 0; - } - /** - *This is CSemaphore destructor. - */ - ~CSemaphore() - { - } - - /** - * This is a function to creat a semaphore - * This is syncronus call. - * @param maximumRequestTimeOut - * [IN] Request Time out. - * - * @return None - * - */ - void create(int maximumRequestTimeOut) - { - hSemaphore = CreateSemaphore(NULL, 1, 1, NULL); - m_MaxTimeOut = maximumRequestTimeOut; - } - - /** - * This is a function to wait for semaphore - * - * @return None - * - */ - void wait() - { - WaitForSingleObject(hSemaphore, m_MaxTimeOut); - } - - /** - * This is a function to release semaphore - * - * @return None - * - */ - void release() - { - ReleaseSemaphore(hSemaphore, 1, NULL); - } - -}; - -#elif defined(LINUX) -#include - -#define SEM_SUCCESS 0 - -class CSemaphore -{ - private: - sem_t hSemaphore; - timespec m_MaxTimeOut; - - public: - /** - * This is CSemaphore constructor. - */ - CSemaphore() - { - m_MaxTimeOut.tv_sec = 0; - m_MaxTimeOut.tv_nsec = 0; - } - /** - *This is CSemaphore destructor. - */ - ~CSemaphore() - { - } - /** - * This is a function to creat a semaphore - * This is syncronus call. - * @param maximumRequestTimeOut - * [IN] Request Time out. - * - * @return None - * - */ - void create(int maximumRequestTimeOut) - { - if ( sem_init(&hSemaphore, 1, 0) < SEM_SUCCESS ) - { - perror("Error : sem_init."); - exit(0); - } - m_MaxTimeOut.tv_sec = maximumRequestTimeOut; - } - - void wait() - { - sem_wait( &hSemaphore ); - } - - /** - * This is a function to release semaphore - * - * @return None - * - */ - void release() - { - sem_post(&hSemaphore); - } - -}; -#endif - -/** - * @brief SSMClient is a wrapper class to provide SoftSensorManager functionality to Application. - * Basically, SoftSensorManager is developed in Resource model (i.e. messaging with basic functions of put, get, and post). - * SSMClient abstracts the resource based operations from client applications and provides c++ style functions. - */ -class SSMClient -{ - private: - SSMReturn m_retResponse; - OCPlatform *m_pPlatform; - CSemaphore m_sem; - /** - * @brief SoftSensorManager Resource. - */ - std::shared_ptr< OCResource > m_SSMResource; - /** - * @brief attribute map . - */ - AttributeMap m_responseAttributeMap; - /** - * @brief query engine. - */ - std::string m_queryEngineId; - /** - * @brief app listener - */ - ISSMClientListener *m_appListener; - - /** - * @brief internal find resource function - */ - void _findResource(void); - - /** - * @brief internal Query engine function - */ - void _createQueryEngine(void); - - /** - * @brief internal release query function - */ - void _releaseQueryEngine(std::string queryEngineId); - - public: - /** - * Constructor for SSMClient. - */ - SSMClient(); - ~SSMClient(); - - /** - * This API sends query strings of applications to SoftSensorManager on Iotivity Base messaging. - * - * @param [in] queryString - A conditions query statement where the caller application specifies sensors for required data and conditions when the caller wants to get the data. - * @param [in] listener - The address of listener class. When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that - * SSMClient can callback message to the application. - * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request. - * @return SSMReturn - - */ - SSMReturn registerQuery(std::string queryString, ISSMClientListener *listener, - std::string &cqid); - /** - * This API is to cancel the registered sends query strings of applications to SoftSensorManager on Iotivity Base messaging. - * - * @param [in] listener - The address of listener class. When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that - * SSMClient can callback message to the application. - * @param [in] cqid - A query id generated from SoftSensorManager service for the queryString request. - * @return SSMReturn - */ - SSMReturn unregisterQuery(std::string cqid); - - // friend option. for callback from SSMResource - void onFoundResource(std::shared_ptr< OCResource > resource); - void onCreateQueryEngine(const OCRepresentation &rep, const int eCode); - void onReleaseQueryEngine(const OCRepresentation &rep, const int eCode); - void onRegisterQuery(const OCRepresentation &rep, const int eCode); - void onUnregisterQuery(const OCRepresentation &rep, const int eCode); - void onObserve(const OCRepresentation &rep, const int &eCode); -}; - -#endif /* RESOURCECLIENT_H_ */ diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/packaging/oic.service b/service/soft-sensor-manager/SampleApp/tizen/ClientApp/packaging/oic.service deleted file mode 100644 index e15779f..0000000 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/packaging/oic.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=OIC -After=deviced.service - -[Service] -Type=simple -ExecStart=/usr/bin/simpleserver -TimeoutStopSec=1s -Restart=always - -[Install] -WantedBy=multi-user.target diff --git a/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/CMakeLists.txt b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/CMakeLists.txt new file mode 100644 index 0000000..7aa6d40 --- /dev/null +++ b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/CMakeLists.txt @@ -0,0 +1,45 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ssm) + +SET(CMAKE_SHARED_LINKER_FLAGS " -Wl,--as-needed") +SET(CMAKE_EXE_LINKER_FLAGS " -Wl,--as-needed -Wl,--hash-style=both") +#SET(EX_SERVER "simpleserver") +#SET(EX_CLIENT "simpleclient") +#SET(EX_CLIENTSERVER "simpleclientserver") +#SET(OCTBSTACK "octbstack") + +#INCLUDE_DIRECTORIES(include) +#INCLUDE_DIRECTORIES(csdk/stack/include) +#INCLUDE_DIRECTORIES(csdk/ocsocket/include) +#INCLUDE_DIRECTORIES(csdk/ocrandom/include) +#INCLUDE_DIRECTORIES(csdk/logger/include) +#INCLUDE_DIRECTORIES(${INCLUDE_INSTALL_DIR}/boost) +#LINK_DIRECTORIES(${CMAKE_BINARY_DIR}) + +#SET(EXTRA_CXXFLAGS "-std=c++11") +#SET(EXTRA_CXXFLAGS "-g3 -std=c++0x") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}") + +#SET(SRCS +# OCLib/OCReflect.cpp +# OCLib/OCPlatform.cpp +# OCLib/OCResource.cpp +# OCLib/InProcServerWrapper.cpp +# OCLib/InProcClientWrapper.cpp) +#ADD_LIBRARY(${PROJECT_NAME} STATIC ${SRCS}) + +#ADD_EXECUTABLE(${EX_SERVER} examples/simpleserver.cpp) +#TARGET_LINK_LIBRARIES(${EX_SERVER} ${PROJECT_NAME} ${OCTBSTACK} pthread) +#INSTALL(TARGETS ${EX_SERVER} DESTINATION ${BIN_INSTALL_DIR}) + +#ADD_EXECUTABLE(${EX_CLIENT} examples/simpleclient.cpp) +#TARGET_LINK_LIBRARIES(${EX_CLIENT} ${PROJECT_NAME} ${OCTBSTACK} pthread) +#INSTALL(TARGETS ${EX_CLIENT} DESTINATION ${BIN_INSTALL_DIR}) + +#ADD_EXECUTABLE(${EX_CLIENTSERVER} examples/simpleclientserver.cpp) +#TARGET_LINK_LIBRARIES(${EX_CLIENTSERVER} ${PROJECT_NAME} ${OCTBSTACK} pthread) +#INSTALL(TARGETS ${EX_CLIENTSERVER} DESTINATION ${BIN_INSTALL_DIR}) + +#ADD_SUBDIRECTORY(csdk) +#ADD_SUBDIRECTORY(examples) +ADD_SUBDIRECTORY(oic-sample) diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/README b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/README similarity index 100% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/README rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/README diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/RELEASE.txt b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/RELEASE.txt similarity index 100% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/RELEASE.txt rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/RELEASE.txt diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/makefile_org b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/makefile_org similarity index 100% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/makefile_org rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/makefile_org diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/CMakeLists.txt b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/CMakeLists.txt similarity index 87% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/CMakeLists.txt rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/CMakeLists.txt index 3579ac5..c0aae0a 100644 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/CMakeLists.txt +++ b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/CMakeLists.txt @@ -1,11 +1,11 @@ -SET(TESTAPP "oicapp-test") +SET(TESTAPP "ssmtester") FILE(GLOB SRCS src/*.c src/*.cpp) SET(VENDOR "samsung") SET(PACKAGE ${TESTAPP}) SET(PKGNAME "com.${VENDOR}.${PACKAGE}") -SET(PREFIX "/usr/apps/com.samsung.oicapp-test") +SET(PREFIX "/usr/apps/com.samsung.ssmtester") SET(BINDIR "${PREFIX}/bin") SET(RESDIR "${PREFIX}/res") SET(DATADIR "${PREFIX}/data") @@ -38,8 +38,10 @@ ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") +LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib) + ADD_EXECUTABLE(${TESTAPP} ${SRCS}) -TARGET_LINK_LIBRARIES(${TESTAPP} ${pkgs_LDFLAGS} ${PROJECT_NAME} ${OCTBSTACK} pthread) +TARGET_LINK_LIBRARIES(${TESTAPP} ${pkgs_LDFLAGS} ssmcore oc octbstack oc_logger oc_logger_core pthread dl) INSTALL(TARGETS ${TESTAPP} DESTINATION ${BINDIR}) diff --git a/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/com.samsung.ssmtester.rule b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/com.samsung.ssmtester.rule new file mode 100644 index 0000000..701ef6f --- /dev/null +++ b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/com.samsung.ssmtester.rule @@ -0,0 +1,3 @@ +com.samsung.ssmtester system::use_internet r + +system::use_internet com.samsung.ssmtester r diff --git a/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/com.samsung.ssmtester.xml b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/com.samsung.ssmtester.xml new file mode 100644 index 0000000..ea0671f --- /dev/null +++ b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/com.samsung.ssmtester.xml @@ -0,0 +1,10 @@ + + + + Name + SSM test Application + + com.samsung.oicapp-test.png + + + diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-log.h b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-log.h similarity index 100% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-log.h rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-log.h diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-test.cpp b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-test.cpp similarity index 76% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-test.cpp rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-test.cpp index c553ba6..f0b7367 100644 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-test.cpp +++ b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-test.cpp @@ -14,48 +14,58 @@ #include #include +#include #include "oicapp-test.h" #include "oicapp-utils.h" -#include "OCResource.h" -#include "OCPlatform.h" -#include "SSMClient.h" -#include "ISSMClientListener.h" +#include "SSMInterface.h" static oicapp_data *g_ad = NULL; -class CSSMClientListener: public ISSMClientListener +int g_CQID = 9999; + +class CQueryEngineEvent : public IQueryEngineEvent { public: - void onRegisterQuery(const AttributeMap &attributeMap, SSMReturn::SSMReturn &eCode) - { - //EFL UI printing - char *queryResult = ""; + SSMRESULT onQueryEngineEvent(int cqid, IDataReader *pResult) + { std::stringstream sstream; - for (AttributeMap::const_iterator itor = attributeMap.begin(); itor != attributeMap.end(); itor++) + int dataCount = 0; + IModelData *pModelData = NULL; + std::vector affectedModels; + + pResult->getAffectedModels(&affectedModels); + + for (std::vector::iterator itor = affectedModels.begin(); + itor != affectedModels.end(); ++itor) { - //if (itor->first == "queryEngineId") - //{ - // sstream << itor->first.c_str() << " : " << std::hex << stoi(itor->second.front().c_str()) << "\n"; - //} - //else - //{ - sstream << itor->first.c_str() << " : " << itor->second.front().c_str() << "\n"; - //} + printf("Printing %s\n", itor->c_str()); + pResult->getModelDataCount(*itor, &dataCount); + for (int i = 0; i < dataCount; i++) + { + pResult->getModelData(*itor, i, &pModelData); + printf("dataId: %d\n", pModelData->getDataId()); + for (int j = 0; j < pModelData->getPropertyCount(); j++) + { + sstream << "Type: " << pModelData->getPropertyName(j).c_str() << + " Value: " << pModelData->getPropertyValue(j).c_str() << "
"; + } + } } -// queryResult = const_cast(sstream .str().c_str()); - oicapp_util_put_msg (g_ad, g_ad->input_msg); + sstream << std::ends; + oicapp_util_put_msg(g_ad, sstream.str().c_str()); + return SSM_S_OK; } }; -CSSMClientListener *g_SSMClientListener = new CSSMClientListener(); -SSMClient *g_SSMClient = NULL; +CQueryEngineEvent *g_SSMClientListener = new CQueryEngineEvent(); +SSMInterface *g_SSMClient = new SSMInterface(); static Elm_Object_Item *oicapp_append_separator(Evas_Object *genlist, oicapp_data *ad) @@ -64,7 +74,7 @@ static Elm_Object_Item *oicapp_append_separator(Evas_Object *genlist, item = elm_genlist_item_append(genlist, &ad->itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + //elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); return item; } @@ -181,7 +191,7 @@ static Elm_Object_Item *_gl_append_item(oicapp_data *ad, Elm_Genlist_Item_Class static void oicapp_append_contents(oicapp_data *ad) { Elm_Object_Item *item; - + /* oicapp_append_separator(ad->genlist, ad); _gl_append_item(ad, &ad->itc_edit); @@ -196,6 +206,26 @@ static void oicapp_append_contents(oicapp_data *ad) ad->item_multiline = item; oicapp_append_separator(ad->genlist, ad); + */ + oicapp_append_separator(ad->genlist, ad); + + elm_genlist_item_append(ad->genlist, &ad->itc_edit, ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + + oicapp_append_separator(ad->genlist, ad); + + elm_genlist_item_append(ad->genlist, &ad->itc_btn, ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + + oicapp_append_separator(ad->genlist, ad); + + oicapp_append_separator(ad->genlist, ad); + + oicapp_append_separator(ad->genlist, ad); + + item = _gl_append_item(ad, &ad->itc_multiline); + + ad->item_multiline = item; + + oicapp_append_separator(ad->genlist, ad); } static Evas_Object *oicapp_create_conform(Evas_Object *win) @@ -236,9 +266,33 @@ static void _btn_clicked(void *data, Evas_Object *obj, void *event_info) { oicapp_data *ad = (oicapp_data *)data; - std::string cqid; + std::string str = std::string(ad->input_msg); + + std::string strGT = ">"; + + std::string strLT = "<"; + + std::size_t foundGT = str.find(strGT); - g_SSMClient->registerQuery(std::string(ad->input_msg), g_SSMClientListener, cqid); + std::size_t foundLT = str.find(strLT); + + std::stringstream sstream; + + if (foundGT != std::string::npos) + { + str.replace(foundGT, strGT.length(), ">"); + } + + if (foundLT != std::string::npos) + { + str.replace(foundLT, strLT.length(), "<"); + } + + g_SSMClient->registerQuery(str, g_SSMClientListener, g_CQID); + + sstream << "Query executed! cqid = " << g_CQID << std::ends; + + oicapp_util_put_msg(ad, sstream.str().c_str()); ERR("button clicked(%s)", ad->input_msg); } @@ -264,8 +318,6 @@ static void _edit_unfocused(void *data, Evas_Object *obj, void *event_info) ad->input_msg = strdup(elm_entry_entry_get(obj)); -// oicapp_util_put_msg(ad, ad->input_msg); - DBG("Clicked : %s", ad->input_msg); } @@ -282,6 +334,14 @@ static Evas_Object *_gl_edit_content_get(void *data, Evas_Object *obj, return entry; } +static char *_item_Text_get(void *data, Evas_Object *obj, const char *part) +{ + char *buf = + "subscribe Device.DiscomfortIndexSensor if Device.DiscomfortIndexSensor.discomfortIndex > 0"; + + return strdup(buf); +} + static inline void oicapp_init_itcs(oicapp_data *ad) { ad->itc_seperator.item_style = "dialogue/separator"; @@ -291,7 +351,7 @@ static inline void oicapp_init_itcs(oicapp_data *ad) ad->itc_seperator.func.del = NULL; ad->itc_edit.item_style = "dialogue/editfield"; - ad->itc_edit.func.text_get = NULL; + ad->itc_edit.func.text_get = _item_Text_get; ad->itc_edit.func.content_get = _gl_edit_content_get; ad->itc_edit.func.state_get = NULL; ad->itc_edit.func.del = NULL; @@ -304,7 +364,6 @@ static inline void oicapp_init_itcs(oicapp_data *ad) ad->itc_multiline.item_style = "multiline/1text"; ad->itc_multiline.func.text_get = _gl_multiline_text_get; - //ad->itc_multiline.func.text_get = NULL; ad->itc_multiline.func.content_get = NULL; ad->itc_multiline.func.state_get = NULL; ad->itc_multiline.func.del = NULL; @@ -344,7 +403,7 @@ static int oicapp_create(void *data) ad->genlist = oicapp_create_genlist(ad->navi); - it = elm_naviframe_item_push(ad->navi, "OIC Tester", NULL, NULL, ad->genlist, NULL); + it = elm_naviframe_item_push(ad->navi, "SSM Tester", NULL, NULL, ad->genlist, NULL); elm_naviframe_item_pop_cb_set(it, _back_cb, ad); ad->ip_addr = oicapp_util_wifi(); @@ -360,8 +419,6 @@ static int oicapp_create(void *data) oicapp_append_contents(ad); - g_SSMClient = new SSMClient(); - return 0; } @@ -369,6 +426,9 @@ static int oicapp_terminate(void *data) { oicapp_data *ad = (oicapp_data *)data; + if (g_CQID != 9999) + g_SSMClient->unregisterQuery(g_CQID); + if (ad->win) evas_object_del(ad->win); diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-test.h b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-test.h similarity index 100% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-test.h rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-test.h diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-utils.c b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-utils.c similarity index 96% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-utils.c rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-utils.c index 82a4a4c..8b0b822 100644 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-utils.c +++ b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-utils.c @@ -63,6 +63,7 @@ void oicapp_util_put_msg(oicapp_data *ad, const char *msg) DBG("Output msg : %s", ad->output_msg); elm_genlist_item_update(ad->item_multiline); + elm_genlist_item_item_class_update(ad->item_multiline, &(ad->itc_multiline)); } char* oicapp_util_wifi() diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-utils.h b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-utils.h similarity index 100% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-utils.h rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/oic-sample/src/oicapp-utils.h diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/packaging/oic.manifest b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/packaging/ssm.manifest similarity index 100% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/packaging/oic.manifest rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/packaging/ssm.manifest diff --git a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/packaging/oic.spec b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/packaging/ssm.spec similarity index 65% rename from service/soft-sensor-manager/SampleApp/tizen/ClientApp/packaging/oic.spec rename to service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/packaging/ssm.spec index 3db8067..827571d 100644 --- a/service/soft-sensor-manager/SampleApp/tizen/ClientApp/packaging/oic.spec +++ b/service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/packaging/ssm.spec @@ -1,16 +1,17 @@ -Name: oic +Name: ssm Summary: Open Interconnect Consortium Version: 0.0.1 Release: 0 Group: Network & Connectivity/Service License: Apache-2.0 Source0: %{name}-%{version}.tar.gz -Source1: %{name}.service +Source1: libDiscomfortIndexSensor.so +Source2: SoftSensorDescription.xml Source1001: %{name}.manifest BuildRequires: cmake -BuildRequires: boost-devel +#BuildRequires: boost-devel #BuildRequires: pkgconfig(glib-2.0) -Buildrequires: gettext-tools +#Buildrequires: gettext-tools BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(ecore-x) BuildRequires: pkgconfig(elementary) @@ -32,8 +33,10 @@ cp %{SOURCE1001} . %install -rm -rf %{buildroot}/BUILD/oic* +rm -rf %{buildroot}/BUILD/ssm* #%make_install +cp -af %{SOURCE1} %{buildroot}/usr/apps/com.samsung.ssmtester/bin/ +cp -af %{SOURCE2} %{buildroot}/usr/apps/com.samsung.ssmtester/bin/ %post @@ -44,8 +47,7 @@ rm -rf %{buildroot}/BUILD/oic* %files %manifest %{name}.manifest %defattr(-,root,root,-) -%{_bindir}/simple* -/usr/apps/com.samsung.oicapp-test/* +/usr/apps/com.samsung.ssmtester/* /usr/share/* -/etc/smack/accesses2.d/com.samsung.oicapp-test.rule +/etc/smack/accesses2.d/com.samsung.ssmtester.rule #%%license LICENSE.APLv2 diff --git a/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/SoftSensorDescription.xml b/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/SoftSensorDescription.xml new file mode 100644 index 0000000..7910214 --- /dev/null +++ b/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/SoftSensorDescription.xml @@ -0,0 +1,41 @@ + + + + DiscomfortIndexSensor + + + version + string + 1.0 + + + lifetime + int + 60 + + + + + timestamp + string + + + temperature + string + + + humidity + string + + + discomfortIndex + int + + + + Thing_TempHumSensor + Thing_TempHumSensor1 + + + + diff --git a/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/build/linux/HighContextDictionary.xml b/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/build/linux/HighContextDictionary.xml deleted file mode 100644 index 4e5e413..0000000 --- a/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/build/linux/HighContextDictionary.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - DiscomfortIndexSensor - - 2 - - version - string - 1.0 - - - lifetime - int - 60 - - - - 4 - - timestamp - string - "" - - - temperature - int - 0 - - - humidity - int - 0 - - - discomfortIndex - int - 0 - - - - 0 - - - 2 - Thing_TempHumSensor - Thing_TempHumSensor1 - - - - Thing_TempHumSensor - Thing_TempHumSensor1 - - - - - diff --git a/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/build/linux/Makefile b/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/build/linux/Makefile index 4fc2c18..4aae123 100644 --- a/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/build/linux/Makefile +++ b/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/build/linux/Makefile @@ -1,4 +1,4 @@ - +-include ../../../../build/linux/root_path.inc -include ../../../../build/linux/environment.mk SRC_PATH=../../src @@ -23,7 +23,7 @@ all: pre_job ${TARGET} post_job pre_job: @echo " " - @echo "---------- SoftSensor Build Begin. ------------" + @echo "---------- ${TARGET} Build Begin. ------------" @mkdir -p ${RST_NAME} @echo " " @@ -38,8 +38,8 @@ ${TARGET}: ${OBJLIST} post_job: @echo " " cp -Rdp ./${RST_NAME}/lib${TARGET}.so ${OUTPUTS_DIR}/ - cp -Rdp ./HighContextDictionary.xml ${OUTPUTS_DIR}/ - @echo "-------------- SoftSensor Build Successful. -------------" + cp -Rdp ../../${SSXML_NAME} ${OUTPUTS_DIR}/ + @echo "-------------- ${TARGET} Build Successful. -------------" @echo "Enter to ${RST_NAME} folder." @echo " " diff --git a/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/src/DiscomfortIndexSensor.cpp b/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/src/DiscomfortIndexSensor.cpp index aebbf9b..2dfe1a7 100644 --- a/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/src/DiscomfortIndexSensor.cpp +++ b/service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/src/DiscomfortIndexSensor.cpp @@ -180,6 +180,9 @@ DIResult DiscomfortIndexSensor::makeDiscomfortIndex(InValue *data) int discomfortIndex = (int) ERROR; double sumDI = 0.0; + m_result.m_temperature = ""; + m_result.m_humidity = ""; + for (int i = 0; i < PHYSICAL_EA; i++) { if (i != 0) @@ -256,14 +259,14 @@ ContextData DiscomfortIndexSensor::setOutput(int property_count, InValue *data) output_property.clear(); output_property.insert(std::make_pair("name", "temperature")); - output_property.insert(std::make_pair("type", "int")); + output_property.insert(std::make_pair("type", "string")); output_property.insert(std::make_pair("value", m_result.m_temperature)); out.outputProperty.push_back(output_property); output_property.clear(); output_property.insert(std::make_pair("name", "humidity")); - output_property.insert(std::make_pair("type", "int")); + output_property.insert(std::make_pair("type", "string")); output_property.insert(std::make_pair("value", m_result.m_humidity)); out.outputProperty.push_back(output_property); diff --git a/service/soft-sensor-manager/build/linux/Makefile b/service/soft-sensor-manager/build/linux/Makefile index ee41b51..2b79304 100644 --- a/service/soft-sensor-manager/build/linux/Makefile +++ b/service/soft-sensor-manager/build/linux/Makefile @@ -1,4 +1,7 @@ +IOTIVITY_DIR=${shell cd ../../../../ && pwd} +${shell echo "ROOT_DIR=${IOTIVITY_DIR}" > ./root_path.inc} +-include ./root_path.inc -include ./environment.mk MAKE=make @@ -21,7 +24,6 @@ pre_job: @echo "* *" @echo "* It's build script for SoftSensorManagement system. *" @echo "* Before build, Open the environment.mk file. *" - @echo "* And, Modify ROOT_DIR path, which depend on your PC. *" @echo "* And, Modify BOOST_BASE path, which depend on your PC. *" @echo "* *" @echo "*********************************************************" @@ -51,13 +53,10 @@ post_job: clean: -# @cd ${CUR_DIR}/../../../resource/ && make clean -# @cd ${CUR_DIR}/../../../resource/csdk && make deepclean -# @cd ${CUR_DIR}/9_Arduino_THSensorApp && make clean -# @cd ${CUR_DIR} rm -rf ./${RST_NAME} @for subdir in ${MAKE_LIST} ; do \ echo ">>>>>>>>>>>> $${subdir}/Makefile clean run <<<<<<<<<<<<<<" ; \ ${MAKE} clean -C $${subdir} ; \ echo " " ; \ done + rm -rf ./root_path.inc diff --git a/service/soft-sensor-manager/build/linux/environment.mk b/service/soft-sensor-manager/build/linux/environment.mk index c10c51f..6652271 100644 --- a/service/soft-sensor-manager/build/linux/environment.mk +++ b/service/soft-sensor-manager/build/linux/environment.mk @@ -1,16 +1,15 @@ -# root path of each PC. -ROOT_DIR=${PWD}/../../../.. - # boost folder path. -BOOST_BASE=/home/iotivity/Desktop/boost_1_56_0 +BOOST_BASE=/usr/include # ioc-resource folder path. IOT_BASE=${ROOT_DIR}/resource IOT_MAKE_PATH=${IOT_BASE} IOT_RELEASE=${IOT_MAKE_PATH}/release/obj -IOT_CSDK_RELEASE=${IOT_BASE}/csdk/release +IOT_CSDK_RELEASE=${IOT_BASE}/csdk/linux/release +IOT_LOG_DIR=${IOT_BASE}/oc_logger IOT_LIB=liboc.a IOT_CSDK_LIB=liboctbstack.a +IOT_LOG_LIB=liboc_logger.a # service folder path. FD_SSM=${ROOT_DIR}/service/soft-sensor-manager @@ -23,15 +22,18 @@ FD_BUILD=${FD_SSM}/build # outputs directory path. OUTPUTS_DIR=${FD_BUILD}/linux/release EXEC_DIR=${OUTPUTS_DIR} -MODEL_DIR="\"${EXEC_DIR}/\"" -HIGH_LOCATION="\"${EXEC_DIR}/HighContextDictionary.xml\"" +SSXML_NAME="SoftSensorDescription.xml" +SSM_LIB = libSSM.a +SSMCORE_LIB=libSSMCore.a # SoftSensorManager makefile path -MAKE_01=${FD_SDK}/build/linux -MAKE_02=${FD_SSMCORE}/build/linux +MAKE_01=${FD_SSMCORE}/build/linux +MAKE_02=${FD_SDK}/build/linux MAKE_03=${FD_SAMPLEAPP}/linux MAKE_04=${FD_SAMPLEAPP}/arduino MAKE_05=${FD_SOFTSENSOR}/DiscomfortIndexSensor/build/linux +MAKE_06=${FD_SOFTSENSOR}/IndoorTrajectorySensor/build/linux -MAKE_LIST=${MAKE_01} ${MAKE_02} ${MAKE_05} ${MAKE_03} +MAKE_LIST=${MAKE_01} ${MAKE_02} ${MAKE_05} ${MAKE_06} ${MAKE_03} +#MAKE_LIST=${MAKE_01} ${MAKE_02} ${MAKE_05} ${MAKE_03}