Skip to content

Commit

Permalink
[SSM] Fix Tizen sample and soft sensor declaration
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-on: https://gerrit.iotivity.org/gerrit/335
Tested-by: jenkins-iotivity <[email protected]>
Reviewed-by: Uze Choi <[email protected]>
  • Loading branch information
jk13 authored and uzchoi committed Feb 13, 2015
1 parent 24b1931 commit fea1aa7
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

#elif defined(TIZEN)

#include <dlog.h>

#endif

#endif
Expand Down Expand Up @@ -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

Expand Down
11 changes: 0 additions & 11 deletions service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@
#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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,46 @@ 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;

log_text = elm_entry_entry_get(ad->log);
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)
Expand Down Expand Up @@ -85,7 +103,8 @@ class CQueryEngineEvent : public OIC::IQueryEngineEvent
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);
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@
*/
#include "SSMModelDefinition.h"

#define _EXPORT_

#ifdef __cplusplus
extern "C"
{
#endif
void _EXPORT_ InitializeContext(ICtxDelegate *pDelegate);
INTERFACE_DECLSPEC void InitializeContext(ICtxDelegate *pDelegate);
#ifdef __cplusplus

}
;
#endif
Expand Down Expand Up @@ -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);
};
}
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
extern "C"
{
#endif
void _EXPORT_ InitializeContext(ICtxDelegate *pDelegate);
INTERFACE_DECLSPEC void InitializeContext(ICtxDelegate *pDelegate);
#ifdef __cplusplus

};
Expand Down Expand Up @@ -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);
};
}
;
Expand Down

0 comments on commit fea1aa7

Please sign in to comment.