BuildRequires: pkgconfig(capi-system-info)
%define accel_state ON
+%define auto_rotation_state ON
%define gyro_state ON
%define proxi_state ON
%define light_state ON
-DORIENTATION=%{orientation_state} -DGRAVITY=%{gravity_state} \
-DLINEAR_ACCEL=%{linear_accel_state} -DRV=%{rv_state} \
-DGEOMAGNETIC_RV=%{geomagnetic_rv_state} -DGAMING_RV=%{gaming_rv_state} \
- -DUNCAL_GYRO=%{uncal_gyro_state} \
+ -DUNCAL_GYRO=%{uncal_gyro_state} -DAUTO_ROTATION=%{auto_rotation_state} \
-DTILT=%{tilt_state} -DTEST_SUITE=%{build_test_suite} \
-DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir}
<SENSOR>
<MODULE path = "/usr/lib/sensord/libaccel_sensor.so"/>
+ <MODULE path = "/usr/lib/sensord/libauto_rotation_sensor.so"/>
<MODULE path = "/usr/lib/sensord/libgyro_sensor.so"/>
<MODULE path = "/usr/lib/sensord/libgeo_sensor.so"/>
<MODULE path = "/usr/lib/sensord/libproxi_sensor.so"/>
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src/libsensord)
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(auto_rot_pkgs REQUIRED vconf)
-
-FOREACH(flag ${auto_rot_pkgs_LDFLAGS})
+FOREACH(flag ${auto_rotation_pkgs_LDFLAGS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
ENDFOREACH(flag)
-FOREACH(flag ${auto_rot_pkgs_CFLAGS})
+FOREACH(flag ${auto_rotation_pkgs_CFLAGS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
ENDFOREACH(flag)
add_library(${SENSOR_NAME} SHARED
- auto_rotation_sensor.cpp
- auto_rotation_alg.cpp
- auto_rotation_alg_emul.cpp
- )
+ auto_rotation_sensor.cpp
+ auto_rotation_alg.cpp
+ auto_rotation_alg_emul.cpp
+)
-target_link_libraries(${SENSOR_NAME} ${auto_rot_pkgs_LDFLAGS} "-lm")
+target_link_libraries(${SENSOR_NAME} ${auto_rotation_pkgs_LDFLAGS} "-lm")
install(TARGETS ${SENSOR_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/sensord)
#include <virtual_sensor.h>
#include <auto_rotation_sensor.h>
#include <sensor_plugin_loader.h>
+#include <cvirtual_sensor_config.h>
#include <auto_rotation_alg.h>
#include <auto_rotation_alg_emul.h>
using std::bind1st;
using std::mem_fun;
-#define SENSOR_NAME "AUTO_ROTATION_SENSOR"
-#define AUTO_ROTATION_LIB "/usr/lib/sensord/libauto-rotation.so"
+#define SENSOR_NAME "AUTO_ROTATION_SENSOR"
+#define SENSOR_TYPE_AUTO_ROTATION "AUTO_ROTATION"
+
+#define MS_TO_US 1000
+
+#define ELEMENT_NAME "NAME"
+#define ELEMENT_VENDOR "VENDOR"
+#define ELEMENT_RAW_DATA_UNIT "RAW_DATA_UNIT"
+#define ELEMENT_DEFAULT_SAMPLING_TIME "DEFAULT_SAMPLING_TIME"
+
+#define AUTO_ROTATION_LIB "/usr/lib/sensord/libauto_rotation_sensor.so"
auto_rotation_sensor::auto_rotation_sensor()
: m_accel_sensor(NULL)
, m_rotation_time(1) // rotation state is valid from initial state, so set rotation time to non-zero value
, 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");
+ throw ENXIO;
+ }
+
+ INFO("m_vendor = %s", m_vendor.c_str());
+
+ if (!config.get(SENSOR_TYPE_AUTO_ROTATION, ELEMENT_RAW_DATA_UNIT, m_raw_data_unit)) {
+ ERR("[RAW_DATA_UNIT] is empty\n");
+ throw ENXIO;
+ }
+
+ INFO("m_raw_data_unit = %s", m_raw_data_unit.c_str());
+
+ if (!config.get(SENSOR_TYPE_AUTO_ROTATION, ELEMENT_DEFAULT_SAMPLING_TIME, &m_default_sampling_time)) {
+ ERR("[DEFAULT_SAMPLING_TIME] is empty\n");
+ throw ENXIO;
+ }
+
+ INFO("m_default_sampling_time = %d", m_default_sampling_time);
+
+ m_interval = m_default_sampling_time * MS_TO_US;
}
auto_rotation_sensor::~auto_rotation_sensor()
bool auto_rotation_sensor::on_start(void)
{
- const int SAMPLING_TIME = 60;
m_rotation = AUTO_ROTATION_DEGREE_UNKNOWN;
m_alg->start();
m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT);
- m_accel_sensor->add_interval((int)this , SAMPLING_TIME, true);
+ m_accel_sensor->add_interval((int)this , (m_interval/MS_TO_US), true);
m_accel_sensor->start();
return activate();
return;
}
-int auto_rotation_sensor::get_sensor_data(unsigned int data_id, sensor_data_t &data)
+int auto_rotation_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t &data)
{
- if (data_id != AUTO_ROTATION_CHANGE_STATE_EVENT)
+ if (event_type != AUTO_ROTATION_CHANGE_STATE_EVENT)
return -1;
AUTOLOCK(m_value_mutex);
return 0;
}
-bool auto_rotation_sensor::get_properties(sensor_properties_t &properties)
+bool auto_rotation_sensor::get_properties(sensor_properties_s &properties)
{
properties.name = "Auto Rotation Sensor";
properties.vendor = "Samsung Electronics";
#define _AUTO_ROTATION_SENSOR_H_
#include <sensor_internal.h>
-#include <vconf.h>
#include <string>
#include <auto_rotation_alg.h>
-using std::string;
-
class auto_rotation_sensor : public virtual_sensor {
public:
auto_rotation_sensor();
void synthesize(const sensor_event_t& event, vector<sensor_event_t> &outs);
- int get_sensor_data(unsigned int data_id, sensor_data_t &data);
- virtual bool get_properties(sensor_properties_t &properties);
+ int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
+ virtual bool get_properties(sensor_properties_s &properties);
private:
sensor_base *m_accel_sensor;
cmutex m_value_mutex;
int m_rotation;
+ unsigned int m_interval;
unsigned long long m_rotation_time;
auto_rotation_alg *m_alg;
+ string m_vendor;
+ string m_raw_data_unit;
+ int m_default_sampling_time;
+
auto_rotation_alg *get_alg();
virtual bool on_start(void);
virtual bool on_stop(void);
/*header for each sensor type*/
#include <sensor_accel.h>
+#include <sensor_auto_rotation.h>
#include <sensor_geomag.h>
#include <sensor_light.h>
#include <sensor_proxi.h>
<ROLL_ROTATION_COMPENSATION value="-1" />
</ORIENTATION>
+ <AUTO_ROTATION>
+ <NAME value="AUTO_ROTATION_SENSOR" />
+ <VENDOR value="SAMSUNG" />
+ <RAW_DATA_UNIT value="DEGREES" />
+ <DEFAULT_SAMPLING_TIME value="60" />
+ </AUTO_ROTATION>
+
<GRAVITY>
<NAME value="GRAVITY_SENSOR" />
<VENDOR value="SAMSUNG" />
<ROLL_ROTATION_COMPENSATION value="-1" />
</ORIENTATION>
+ <AUTO_ROTATION>
+ <NAME value="AUTO_ROTATION_SENSOR" />
+ <VENDOR value="SAMSUNG" />
+ <RAW_DATA_UNIT value="DEGREES" />
+ <DEFAULT_SAMPLING_TIME value="60" />
+ </AUTO_ROTATION>
+
<GRAVITY>
<NAME value="GRAVITY_SENSOR" />
<VENDOR value="SAMSUNG" />