sensord: enable auto-rotation sensor 33/57633/4
authorkibak.yoon <kibak.yoon@samsung.com>
Thu, 21 Jan 2016 07:22:17 +0000 (16:22 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Thu, 21 Jan 2016 08:36:05 +0000 (17:36 +0900)
Change-Id: I560ed1275e278212837d89dba362da9c19a6f952
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/server/CMakeLists.txt
src/server/plugins/CMakeLists.txt
src/server/plugins/auto_rotation/auto_rotation_sensor.cpp
src/server/plugins/auto_rotation/auto_rotation_sensor.h

index e059764..a17facd 100755 (executable)
@@ -4,7 +4,7 @@ project(sensord CXX)
 INCLUDE(FindPkgConfig)
 PKG_CHECK_MODULES(server_pkgs REQUIRED glib-2.0 gio-2.0 dlog libsystemd-daemon libxml-2.0 cynara-client cynara-creds-socket cynara-session)
 
-#add_subdirectory(plugins)
+add_subdirectory(plugins)
 
 add_definitions(${PLUGIN_DEFS})
 
index d2bfdbc..3dae2cb 100755 (executable)
@@ -19,21 +19,6 @@ include_directories(${CMAKE_SOURCE_DIR}/src/server)
 include_directories(${CMAKE_SOURCE_DIR}/src/shared)
 
 
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/accel")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/accel/accel_sensor.cpp")
-
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/gyro")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/gyro/gyro_sensor.cpp")
-
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/proxi")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/proxi/proxi_sensor.cpp")
-
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/light")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/light/light_sensor.cpp")
-
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/geo")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/geo/geo_sensor.cpp")
-
 IF("${AUTO_ROTATION}" STREQUAL "ON")
 list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation")
 list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation/auto_rotation_alg.cpp")
@@ -42,18 +27,6 @@ list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation/auto_rotatio
 list (APPEND PLUGIN_DEFS "-DENABLE_AUTO_ROTATION")
 ENDIF()
 
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/pressure")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pressure/pressure_sensor.cpp")
-
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/temperature")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/temperature/temperature_sensor.cpp")
-
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/ultraviolet")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/ultraviolet/ultraviolet_sensor.cpp")
-
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/bio_led_red")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/bio_led_red/bio_led_red_sensor.cpp")
-
 IF("${ORIENTATION}" STREQUAL "ON")
 set(SENSOR_FUSION_ENABLE "1")
 set(ORIENTATION_ENABLE "1")
@@ -145,10 +118,6 @@ list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/gaming_rv/
 list (APPEND PLUGIN_DEFS "-DENABLE_GAMING_RV")
 ENDIF()
 
-list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/rv_raw")
-list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/rv_raw/rv_raw_sensor.cpp")
-
-
 set(PLUGIN_SRCS ${PLUGIN_SRCS} PARENT_SCOPE)
 set(DIR_INCLUDE ${DIR_INCLUDE} PARENT_SCOPE)
 set(PLUGIN_DEFS ${PLUGIN_DEFS} PARENT_SCOPE)
index 64cef31..15046be 100755 (executable)
@@ -60,10 +60,6 @@ auto_rotation_sensor::auto_rotation_sensor()
 , m_alg(NULL)
 {
        cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
-       m_name = string(SENSOR_NAME);
-
-       register_supported_event(AUTO_ROTATION_CHANGE_STATE_EVENT);
-
 
        if (!config.get(SENSOR_TYPE_AUTO_ROTATION, ELEMENT_VENDOR, m_vendor)) {
                ERR("[VENDOR] is empty\n");
@@ -87,6 +83,8 @@ auto_rotation_sensor::auto_rotation_sensor()
        INFO("m_default_sampling_time = %d", m_default_sampling_time);
 
        m_interval = m_default_sampling_time * MS_TO_US;
+
+       init();
 }
 
 auto_rotation_sensor::~auto_rotation_sensor()
@@ -96,6 +94,21 @@ auto_rotation_sensor::~auto_rotation_sensor()
        INFO("auto_rotation_sensor is destroyed!\n");
 }
 
+sensor_type_t auto_rotation_sensor::get_type(void)
+{
+       return AUTO_ROTATION_SENSOR;
+}
+
+unsigned int auto_rotation_sensor::get_event_type(void)
+{
+       return (AUTO_ROTATION_SENSOR << 16) | 0x0001;
+}
+
+const char* auto_rotation_sensor::get_name(void)
+{
+       return SENSOR_NAME;
+}
+
 bool auto_rotation_sensor::check_lib(void)
 {
        if (access(AUTO_ROTATION_LIB, F_OK) < 0)
@@ -135,18 +148,12 @@ bool auto_rotation_sensor::init()
        return true;
 }
 
-void auto_rotation_sensor::get_types(vector<sensor_type_t> &types)
-{
-       types.push_back(AUTO_ROTATION_SENSOR);
-}
-
 bool auto_rotation_sensor::on_start(void)
 {
        m_rotation = AUTO_ROTATION_DEGREE_UNKNOWN;
 
        m_alg->start();
 
-       m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->add_interval((intptr_t)this , (m_interval/MS_TO_US), true);
        m_accel_sensor->start();
 
@@ -155,7 +162,6 @@ bool auto_rotation_sensor::on_start(void)
 
 bool auto_rotation_sensor::on_stop(void)
 {
-       m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->delete_interval((intptr_t)this , true);
        m_accel_sensor->stop();
 
@@ -164,8 +170,6 @@ bool auto_rotation_sensor::on_stop(void)
 
 void auto_rotation_sensor::synthesize(const sensor_event_t& event, vector<sensor_event_t> &outs)
 {
-       AUTOLOCK(m_mutex);
-
        if (event.event_type == ACCELEROMETER_RAW_DATA_EVENT) {
                int rotation;
                float acc[3];
@@ -176,7 +180,6 @@ void auto_rotation_sensor::synthesize(const sensor_event_t& event, vector<sensor
                if (!m_alg->get_rotation(acc, event.data.timestamp, m_rotation, rotation))
                        return;
 
-               AUTOLOCK(m_value_mutex);
                sensor_event_t rotation_event;
 
                INFO("Rotation: %d, ACC[0]: %f, ACC[1]: %f, ACC[2]: %f", rotation, event.data.values[0], event.data.values[1], event.data.values[2]);
@@ -195,13 +198,8 @@ void auto_rotation_sensor::synthesize(const sensor_event_t& event, vector<sensor
        return;
 }
 
-int auto_rotation_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t &data)
+int auto_rotation_sensor::get_sensor_data(sensor_data_t &data)
 {
-       if (event_type != AUTO_ROTATION_CHANGE_STATE_EVENT)
-               return -1;
-
-       AUTOLOCK(m_value_mutex);
-
        data.accuracy = SENSOR_ACCURACY_GOOD;
        data.timestamp = m_rotation_time;
        data.values[0] = m_rotation;
@@ -210,7 +208,7 @@ int auto_rotation_sensor::get_sensor_data(const unsigned int event_type, sensor_
        return 0;
 }
 
-bool auto_rotation_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
+bool auto_rotation_sensor::get_properties(sensor_properties_s &properties)
 {
        properties.name = "Auto Rotation Sensor";
        properties.vendor = "Samsung Electronics";
index f5bfceb..92e234f 100755 (executable)
@@ -29,15 +29,15 @@ public:
        auto_rotation_sensor();
        virtual ~auto_rotation_sensor();
 
-       bool init();
-       virtual void get_types(std::vector<sensor_type_t> &types);
-
-       static bool working(void *inst);
+       /* module info */
+       virtual sensor_type_t get_type();
+       virtual unsigned int get_event_type(void);
+       virtual const char* get_name(void);
 
        void synthesize(const sensor_event_t& event, std::vector<sensor_event_t> &outs);
 
-       int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
-       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
+       int get_sensor_data(sensor_data_t &data);
+       virtual bool get_properties(sensor_properties_s &properties);
 private:
        sensor_base *m_accel_sensor;
        cmutex m_value_mutex;
@@ -51,6 +51,8 @@ private:
        std::string m_raw_data_unit;
        int m_default_sampling_time;
 
+       bool init();
+
        auto_rotation_alg *get_alg();
        virtual bool on_start(void);
        virtual bool on_stop(void);