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})
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")
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")
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)
, 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");
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()
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)
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();
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();
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];
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]);
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;
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";
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;
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);