Removing redundant accelerometer events 66/35566/3
authorAnkur <ankur29.garg@samsung.com>
Wed, 18 Feb 2015 10:27:13 +0000 (15:57 +0530)
committerAnkur <ankur29.garg@samsung.com>
Wed, 18 Feb 2015 11:11:48 +0000 (16:41 +0530)
ACCELEROMETER_BASE_DATA_SET and ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME were the same
ACCELEROMETER_BASE_DATA_SET has been removed.

ACCELEROMETER_BASE_DATA_SET was used for polling events and ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME was used for event driven
Since both these represent the same accelerometer event, DATA_SET type has been removed.

And ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME has been renamed to ACCELEROMETER_RAW_DATA_EVENT to make it simpler.

The change has been tested on rd-pq device for all sensord API and all API were found to be working.

Change-Id: I7602335045a1847b9ea3e58247b6ddcc82bbda7f

src/accel/accel_sensor.cpp
src/auto_rotation/auto_rotation_sensor.cpp
src/libsensord/client_common.cpp
src/libsensord/sensor_accel.h
src/linear_accel/linear_accel_sensor.cpp
src/orientation/orientation_sensor.cpp
src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp
src/rotation_vector/rv/rv_sensor.cpp
src/server/command_worker.cpp
test/src/auto_test.c
test/src/tc-common.c

index 8bb436d..1dc28ff 100755 (executable)
@@ -42,8 +42,8 @@ accel_sensor::accel_sensor()
        m_name = string(SENSOR_NAME);
 
        vector<unsigned int> supported_events = {
-               ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME,
-               ACCELEROMETER_EVENT_UNPROCESSED_DATA_REPORT_ON_TIME,
+               ACCELEROMETER_RAW_DATA_EVENT,
+               ACCELEROMETER_UNPROCESSED_DATA_EVENT,
        };
 
        for_each(supported_events.begin(), supported_events.end(),
@@ -104,15 +104,15 @@ bool accel_sensor::process_event(void)
        AUTOLOCK(m_mutex);
        AUTOLOCK(m_client_info_mutex);
 
-       if (get_client_cnt(ACCELEROMETER_EVENT_UNPROCESSED_DATA_REPORT_ON_TIME)) {
+       if (get_client_cnt(ACCELEROMETER_UNPROCESSED_DATA_EVENT)) {
                base_event.sensor_id = get_id();
-               base_event.event_type = ACCELEROMETER_EVENT_UNPROCESSED_DATA_REPORT_ON_TIME;
+               base_event.event_type = ACCELEROMETER_UNPROCESSED_DATA_EVENT;
                push(base_event);
        }
 
-       if (get_client_cnt(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME)) {
+       if (get_client_cnt(ACCELEROMETER_RAW_DATA_EVENT)) {
                base_event.sensor_id = get_id();
-               base_event.event_type = ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME;
+               base_event.event_type = ACCELEROMETER_RAW_DATA_EVENT;
                raw_to_base(base_event.data);
                push(base_event);
        }
@@ -152,7 +152,7 @@ int accel_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
                return -1;
        }
 
-       if (type == ACCELEROMETER_BASE_DATA_SET) {
+       if (type == ACCELEROMETER_RAW_DATA_EVENT) {
                raw_to_base(data);
        } else {
                ERR("Does not support type: 0x%x", type);
index efefb8b..cdf7609 100755 (executable)
@@ -110,7 +110,7 @@ bool auto_rotation_sensor::on_start(void)
 
        m_alg->start();
 
-       m_accel_sensor->add_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->add_interval((int)this , SAMPLING_TIME, true);
        m_accel_sensor->start();
 
@@ -119,7 +119,7 @@ bool auto_rotation_sensor::on_start(void)
 
 bool auto_rotation_sensor::on_stop(void)
 {
-       m_accel_sensor->delete_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->delete_interval((int)this , true);
        m_accel_sensor->stop();
 
@@ -130,7 +130,7 @@ void auto_rotation_sensor::synthesize(const sensor_event_t& event, vector<sensor
 {
        AUTOLOCK(m_mutex);
 
-       if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) {
+       if (event.event_type == ACCELEROMETER_RAW_DATA_EVENT) {
                int rotation;
                float acc[3];
                acc[0] = event.data.values[0];
index 831be17..f022992 100755 (executable)
@@ -50,7 +50,7 @@ log_element g_log_elements[] = {
        FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME, 0, 10),
        FILL_LOG_ELEMENT(LOG_ID_EVENT, CONTEXT_EVENT_REPORT, 0, 1),
        FILL_LOG_ELEMENT(LOG_ID_EVENT, AUTO_ROTATION_EVENT_CHANGE_STATE, 0, 1),
-       FILL_LOG_ELEMENT(LOG_ID_EVENT, ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10),
+       FILL_LOG_ELEMENT(LOG_ID_EVENT, ACCELEROMETER_RAW_DATA_EVENT, 0, 10),
        FILL_LOG_ELEMENT(LOG_ID_EVENT, GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10),
        FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10),
        FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10),
@@ -64,7 +64,6 @@ log_element g_log_elements[] = {
        FILL_LOG_ELEMENT(LOG_ID_EVENT, ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10),
        FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_RV_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10),
 
-       FILL_LOG_ELEMENT(LOG_ID_DATA, ACCELEROMETER_BASE_DATA_SET, 0, 25),
        FILL_LOG_ELEMENT(LOG_ID_DATA, GYRO_BASE_DATA_SET, 0, 25),
        FILL_LOG_ELEMENT(LOG_ID_DATA, PROXIMITY_BASE_DATA_SET, 0, 25),
        FILL_LOG_ELEMENT(LOG_ID_DATA, PROXIMITY_DISTANCE_DATA_SET, 0, 25),
@@ -153,7 +152,7 @@ bool is_one_shot_event(unsigned int event_type)
 bool is_ontime_event(unsigned int event_type)
 {
        switch (event_type ) {
-       case ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME:
+       case ACCELEROMETER_RAW_DATA_EVENT:
        case PROXIMITY_EVENT_STATE_REPORT_ON_TIME:
        case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME:
        case LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME:
index 596abae..ed98ff1 100755 (executable)
@@ -36,13 +36,9 @@ extern "C"
  * @{
  */
 
-enum accelerometer_data_id {
-       ACCELEROMETER_BASE_DATA_SET                             = (ACCELEROMETER_SENSOR << 16) | 0x0001,
-};
-
 enum accelerometer_event_type {
-       ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME                                     = (ACCELEROMETER_SENSOR << 16) | 0x0001,
-       ACCELEROMETER_EVENT_UNPROCESSED_DATA_REPORT_ON_TIME                     = (ACCELEROMETER_SENSOR << 16) | 0x0002,
+       ACCELEROMETER_RAW_DATA_EVENT                                    = (ACCELEROMETER_SENSOR << 16) | 0x0001,
+       ACCELEROMETER_UNPROCESSED_DATA_EVENT                    = (ACCELEROMETER_SENSOR << 16) | 0x0002,
 };
 
 /**
index 8ae8153..2ce3a78 100755 (executable)
@@ -150,7 +150,7 @@ bool linear_accel_sensor::on_start(void)
        m_gravity_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
        m_gravity_sensor->start();
 
-       m_accel_sensor->add_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
        m_accel_sensor->start();
 
@@ -165,7 +165,7 @@ bool linear_accel_sensor::on_stop(void)
        m_gravity_sensor->delete_interval((intptr_t)this, false);
        m_gravity_sensor->stop();
 
-       m_accel_sensor->delete_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->delete_interval((intptr_t)this, false);
        m_accel_sensor->stop();
 
@@ -197,7 +197,7 @@ void linear_accel_sensor::synthesize(const sensor_event_t &event, vector<sensor_
 
        unsigned long long diff_time;
 
-       if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) {
+       if (event.event_type == ACCELEROMETER_RAW_DATA_EVENT) {
                diff_time = event.data.timestamp - m_time;
 
                if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR))
@@ -248,7 +248,7 @@ int linear_accel_sensor::get_sensor_data(const unsigned int event_type, sensor_d
 {
        sensor_data_t gravity_data, accel_data;
        ((virtual_sensor *)m_gravity_sensor)->get_sensor_data(GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME, gravity_data);
-       m_accel_sensor->get_sensor_data(ACCELEROMETER_BASE_DATA_SET, accel_data);
+       m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data);
 
        accel_data.values[0] = m_accel_rotation_direction_compensation[0] * (accel_data.values[0] - m_accel_static_bias[0]) / m_accel_scale;
        accel_data.values[1] = m_accel_rotation_direction_compensation[1] * (accel_data.values[1] - m_accel_static_bias[1]) / m_accel_scale;
index 7629132..0719a1b 100755 (executable)
@@ -232,7 +232,7 @@ bool orientation_sensor::on_start(void)
 {
        AUTOLOCK(m_mutex);
 
-       m_accel_sensor->add_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
        m_accel_sensor->start();
        m_gyro_sensor->add_client(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
@@ -250,7 +250,7 @@ bool orientation_sensor::on_stop(void)
 {
        AUTOLOCK(m_mutex);
 
-       m_accel_sensor->delete_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->delete_interval((intptr_t)this, false);
        m_accel_sensor->stop();
        m_gyro_sensor->delete_client(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
@@ -294,7 +294,7 @@ void orientation_sensor::synthesize(const sensor_event_t &event, vector<sensor_e
        euler_angles<float> euler_orientation;
        float azimuth_offset;
 
-       if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) {
+       if (event.event_type == ACCELEROMETER_RAW_DATA_EVENT) {
                diff_time = event.data.timestamp - m_time;
 
                if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR))
@@ -388,7 +388,7 @@ int orientation_sensor::get_sensor_data(const unsigned int event_type, sensor_da
        if (event_type != ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME)
                return -1;
 
-       m_accel_sensor->get_sensor_data(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME, accel_data);
+       m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data);
        m_gyro_sensor->get_sensor_data(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME, gyro_data);
        m_magnetic_sensor->get_sensor_data(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME, magnetic_data);
 
index ea5a446..3f6646e 100755 (executable)
@@ -171,7 +171,7 @@ bool geomagnetic_rv_sensor::on_start(void)
 {
        AUTOLOCK(m_mutex);
 
-       m_accel_sensor->add_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
        m_accel_sensor->start();
        m_magnetic_sensor->add_client(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
@@ -186,7 +186,7 @@ bool geomagnetic_rv_sensor::on_stop(void)
 {
        AUTOLOCK(m_mutex);
 
-       m_accel_sensor->delete_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->delete_interval((intptr_t)this, false);
        m_accel_sensor->stop();
        m_magnetic_sensor->delete_client(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
@@ -225,7 +225,7 @@ void geomagnetic_rv_sensor::synthesize(const sensor_event_t& event, vector<senso
        sensor_event_t rv_event;
        quaternion<float> quaternion_geo_rv;
 
-       if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) {
+       if (event.event_type == ACCELEROMETER_RAW_DATA_EVENT) {
                diff_time = event.data.timestamp - m_time;
 
                if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR))
@@ -291,7 +291,7 @@ int geomagnetic_rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_
        if (event_type != GEOMAGNETIC_RV_EVENT_RAW_DATA_REPORT_ON_TIME)
                return -1;
 
-       m_accel_sensor->get_sensor_data(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME, accel_data);
+       m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data);
        m_magnetic_sensor->get_sensor_data(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME, magnetic_data);
 
        pre_process_data(accel, accel_data.values, m_accel_static_bias, m_accel_rotation_direction_compensation, m_accel_scale);
index 7846940..392d930 100755 (executable)
@@ -198,7 +198,7 @@ bool rv_sensor::on_start(void)
 {
        AUTOLOCK(m_mutex);
 
-       m_accel_sensor->add_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
        m_accel_sensor->start();
        m_gyro_sensor->add_client(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
@@ -216,7 +216,7 @@ bool rv_sensor::on_stop(void)
 {
        AUTOLOCK(m_mutex);
 
-       m_accel_sensor->delete_client(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+       m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT);
        m_accel_sensor->delete_interval((intptr_t)this, false);
        m_accel_sensor->stop();
        m_gyro_sensor->delete_client(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
@@ -260,7 +260,7 @@ void rv_sensor::synthesize(const sensor_event_t& event, vector<sensor_event_t> &
        sensor_event_t rv_event;
        quaternion<float> quaternion_orientation;
 
-       if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) {
+       if (event.event_type == ACCELEROMETER_RAW_DATA_EVENT) {
                diff_time = event.data.timestamp - m_time;
 
                if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR))
@@ -343,7 +343,7 @@ int rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_t &data)
        if (event_type != ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME)
                return -1;
 
-       m_accel_sensor->get_sensor_data(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME, accel_data);
+       m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data);
        m_gyro_sensor->get_sensor_data(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME, gyro_data);
        m_magnetic_sensor->get_sensor_data(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME, magnetic_data);
 
index c161171..d9c5baa 100755 (executable)
@@ -853,13 +853,13 @@ void insert_priority_list(unsigned int event_type)
                        event_type == LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME ||
                        event_type == GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME ||
                        event_type == ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME) {
-               priority_list.insert(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+               priority_list.insert(ACCELEROMETER_RAW_DATA_EVENT);
                priority_list.insert(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
                priority_list.insert(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
        }
 
        if (event_type == GEOMAGNETIC_RV_EVENT_RAW_DATA_REPORT_ON_TIME) {
-               priority_list.insert(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+               priority_list.insert(ACCELEROMETER_RAW_DATA_EVENT);
                priority_list.insert(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
        }
 }
index e897f74..283aaf1 100644 (file)
@@ -199,7 +199,7 @@ int main(int argc, char **argv)
 
        fp = fopen("auto_test.output", "w+");
 
-       result = check_sensor_api(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       result = check_sensor_api(ACCELEROMETER_RAW_DATA_EVENT, interval);
        fprintf(fp, "Accelerometer - RAW_DATA_REPORT_ON_TIME - %d\n", result);
 
        result = check_sensor_api(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
index 81d83d9..368143a 100644 (file)
@@ -63,7 +63,7 @@ unsigned int get_event_driven(sensor_type_t sensor_type, char str[])
        switch (sensor_type) {
        case ACCELEROMETER_SENSOR:
                if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
-                       return ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME;
+                       return ACCELEROMETER_RAW_DATA_EVENT;
                break;
        case GYROSCOPE_SENSOR:
                if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
@@ -177,7 +177,7 @@ int main(int argc, char **argv)
 
        if (strcmp(argv[1], "accelerometer") == 0) {
                 sensor_type = ACCELEROMETER_SENSOR;
-                event = ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME;
+                event = ACCELEROMETER_RAW_DATA_EVENT;
        }
        else if (strcmp(argv[1], "gyroscope") == 0) {
                 sensor_type = GYROSCOPE_SENSOR;