[SSM] Fix Tizen sample and soft sensor declaration
authorjk13 <jihyeok13.kim@samsung.com>
Fri, 13 Feb 2015 00:25:04 +0000 (09:25 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 13 Feb 2015 05:21:47 +0000 (05:21 +0000)
1. Fix Tizen sample to load description and so from specific location
2. Fix Soft Sensor declaration to support which built under Tizen IDE

Change-Id: I73bdc793c5b1b6e100e9af36aca9503be9522b3e
Signed-off-by: jk13 <jihyeok13.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/335
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/soft-sensor-manager/SSMCore/src/Common/PlatformLayer.h
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore.h
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMModelDefinition.h
service/soft-sensor-manager/SampleApp/tizen/SSMTesterApp/src/ssmtesterapp.cpp
service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/include/DiscomfortIndexSensor.h
service/soft-sensor-manager/SoftSensorPlugin/IndoorTrajectorySensor/include/ITS.h

index 4ed125c..2648219 100644 (file)
@@ -37,6 +37,8 @@
 
 #elif defined(TIZEN)
 
+#include <dlog.h>
+
 #endif
 
 #endif
@@ -64,8 +66,9 @@ void ReportMessage(const char *tag, const char *msg);
 
 #elif defined(TIZEN)
 
-#define REPORT_MESSAGE(tag, msg) printf("[%s] %s\n", tag, msg)
-#define PRINT_LOG(strError) printf("[SSM] %s:%d %s\n", __PRETTY_FUNCTION__, __LINE__, strError)
+void ReportMessage(const char *tag, const char *msg);
+#define REPORT_MESSAGE(tag, msg) ReportMessage(tag, msg)
+#define PRINT_LOG(strError) dlog_print(DLOG_DEBUG, "SSM", "%s:%d %s", __PRETTY_FUNCTION__, __LINE__, strError)
 
 #else //Default linux
 
index 4c690d4..91b229b 100644 (file)
@@ -28,17 +28,6 @@ using namespace OIC;
 
 #define IN
 #define OUT
-/*
-#if defined(WIN32) && defined(SSMCORE_WINDOWS_EXPORTS)
-#define INTERFACE_DECLSPEC    __declspec(dllexport)
-#elif defined(WIN32)
-#define INTERFACE_DECLSPEC    __declspec(dllimport)
-#pragma comment(lib, "SSMCore_Windows.lib")
-#else
-#define INTERFACE_DECLSPEC
-#endif
-*/
-#define INTERFACE_DECLSPEC
 
 /**
 * @class    IQueryEngine
index c670db3..73cbe58 100644 (file)
 #include <string>
 #include <vector>
 
+#if defined(WIN32)
+
+#if defined(SSMSENSOR_WINDOWS_EXPORTS)
+#define INTERFACE_DECLSPEC    __declspec(dllexport)
+#elif defined(WIN32)
+#define INTERFACE_DECLSPEC    __declspec(dllimport)
+#endif
+
+#elif defined(TIZEN)
+
+#include <tizen.h>
+
+#define INTERFACE_DECLSPEC EXPORT_API
+
+#else
+
+#define INTERFACE_DECLSPEC
+
+#endif
+
 #define SSM_MODEL_RETRY 3
 typedef enum {SSM_ONCE, SSM_REPEAT} TypeofEvent;
 typedef enum {SSM_EVENT_NORMAL, SSM_EVENT_ADDED, SSM_REMOVED, SSM_UPDATED} RESOURCE_EVENT_TYPE;
@@ -37,6 +57,7 @@ class ISSMResource
         ISSMResource(const std::string &n, const std::string &t) :
             name(n), type(t)
         {
+               location = SENSOR_LOCATION_LOCAL;
         }
         SENSOR_LOCATION location;
         std::string name;
index caa3abe..de80aac 100644 (file)
@@ -30,10 +30,15 @@ typedef struct appdata {
        Evas_Object *unregister_query_label;
 } appdata_s;
 
+typedef struct threadContext{
+       appdata_s *ad;
+       const char *log;
+} threadContext_s;
+
 #define ELM_DEMO_EDJ "opt/usr/apps/org.iotivity.service.ssm.ssmtesterapp/res/ui_controls.edj"
 
 char log_buffer[10000];
-void updateLog(appdata_s *ad , char *newlog)
+void updateLog(appdata_s *ad, const char *newlog)
 {
        const char *log_text = NULL;
 
@@ -41,17 +46,30 @@ void updateLog(appdata_s *ad , char *newlog)
        strcpy(log_buffer,log_text);
        strcat(log_buffer,newlog);
        elm_entry_entry_set(ad->log,log_buffer);
+       elm_entry_cursor_end_set(ad->log);
+}
+
+void* updateCallbackLog(void *data)
+{
+       threadContext_s  *pThreadContext = (threadContext_s*)data;
+
+       updateLog(pThreadContext->ad, pThreadContext->log);
+
+       return NULL;
 }
 
 class CQueryEngineEvent : public OIC::IQueryEngineEvent
 {
 private:
        appdata_s *m_pAppData;
+       threadContext_s m_ThreadContext;
 
 public:
        CQueryEngineEvent(appdata_s *pAppData)
        {
                m_pAppData = pAppData;
+               m_ThreadContext.ad = m_pAppData;
+               m_ThreadContext.log = NULL;
        }
 
        OIC::SSMRESULT onQueryEngineEvent(int cqid, OIC::IDataReader *pResult)
@@ -85,7 +103,8 @@ public:
                                        sprintf(buf,"Type: %s Value: %s<br>", (pModelData->getPropertyName(j)).c_str(), (pModelData->getPropertyValue(j)).c_str());
                                        strcat(log,buf);
                                }
-                               updateLog(m_pAppData, log);
+                               m_ThreadContext.log = log;
+                               ecore_main_loop_thread_safe_call_sync((void *(*)(void *))updateCallbackLog, &m_ThreadContext);
                        }
                }
 
@@ -157,7 +176,7 @@ discomfort_index_cb(void *data , Evas_Object *obj , void *event_info)
 {
        appdata_s *ad = (appdata_s *)data;
        elm_entry_entry_set(ad->query_text, "subscribe Device.DiscomfortIndexSensor "\
-                       "if Device.DiscomfortIndexSensor.discomfortIndex > 0");
+                       "if Device.DiscomfortIndexSensor.discomfortIndex != 0");
 }
 
 static void
@@ -435,6 +454,10 @@ app_create(void *data)
                                "<Name>MyPC</Name>"
                                "<Type>PC</Type>"
                                "</Device>"
+                               "<Config>"
+                               "<SoftSensorDescription>/opt/usr/apps/org.iotivity.service.ssm.ssmtesterapp/lib/SoftSensorDescription.xml</SoftSensorDescription>"
+                               "<SoftSensorRepository>/opt/usr/apps/org.iotivity.service.ssm.ssmtesterapp/lib/</SoftSensorRepository>"
+                               "</Config>"
                                "</SSMCore>";
 
        g_pQueryEngineEvent = new CQueryEngineEvent(ad);
index a0145f2..6bed98e 100644 (file)
  */
 #include "SSMModelDefinition.h"
 
-#define _EXPORT_
-
 #ifdef __cplusplus
 extern "C"
 {
 #endif
-void _EXPORT_ InitializeContext(ICtxDelegate *pDelegate);
+INTERFACE_DECLSPEC void InitializeContext(ICtxDelegate *pDelegate);
 #ifdef __cplusplus
-
 }
 ;
 #endif
@@ -88,7 +85,7 @@ namespace DiscomfortIndexSensorName
             DIResult makeDiscomfortIndex(InValue *data);
             ContextData setOutput(int property_count, InValue *data);
 
-            friend void _EXPORT_ initializeContext(ICtxDelegate *pDelegate);
+            friend void INTERFACE_DECLSPEC initializeContext(ICtxDelegate *pDelegate);
     };
 }
 ;
index adb1ecc..ab20039 100644 (file)
@@ -37,7 +37,7 @@
 extern "C"
 {
 #endif
-void _EXPORT_ InitializeContext(ICtxDelegate *pDelegate);
+INTERFACE_DECLSPEC void InitializeContext(ICtxDelegate *pDelegate);
 #ifdef __cplusplus
 
 };
@@ -114,7 +114,7 @@ namespace ITSName
             Trajectory *makeTrajectory(CurrentService *CService);
             ITSResult setOutput( Trajectory *m_result, ContextData *out );
 
-            friend void _EXPORT_ initializeContext(ICtxDelegate *pDelegate);
+            friend void INTERFACE_DECLSPEC initializeContext(ICtxDelegate *pDelegate);
     };
 }
 ;