From c7a9a0568a32cac9fff4de85180745721c954962 Mon Sep 17 00:00:00 2001 From: Ankur Date: Wed, 18 Feb 2015 16:55:35 +0530 Subject: [PATCH] Removing redundant gyroscope events GYRO_BASE_DATA_SET and GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME were the same GYRO_BASE_DATA_SET has been removed. GYRO_BASE_DATA_SET was used for polling events and GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME was used for event driven Since both these represent the same gyroscope event, DATA_SET type has been removed. And GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME has been renamed to GYROSCOPE_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: Ie4d6642691a8d57abed5f0b6387922fc871904c4 --- src/gyro/gyro_sensor.cpp | 14 +++++++------- src/libsensord/client_common.cpp | 5 ++--- src/libsensord/sensor_gyro.h | 8 ++------ src/orientation/orientation_sensor.cpp | 8 ++++---- src/rotation_vector/rv/rv_sensor.cpp | 8 ++++---- src/server/command_worker.cpp | 2 +- test/src/auto_test.c | 2 +- test/src/tc-common.c | 4 ++-- 8 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/gyro/gyro_sensor.cpp b/src/gyro/gyro_sensor.cpp index cdf4109..c7b0001 100755 --- a/src/gyro/gyro_sensor.cpp +++ b/src/gyro/gyro_sensor.cpp @@ -35,8 +35,8 @@ gyro_sensor::gyro_sensor() { m_name = string(SENSOR_NAME); - register_supported_event(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME); - register_supported_event(GYROSCOPE_EVENT_UNPROCESSED_DATA_REPORT_ON_TIME); + register_supported_event(GYROSCOPE_RAW_DATA_EVENT); + register_supported_event(GYROSCOPE_UNPROCESSED_DATA_EVENT); physical_sensor::set_poller(gyro_sensor::working, this); } @@ -91,15 +91,15 @@ bool gyro_sensor::process_event(void) AUTOLOCK(m_client_info_mutex); - if (get_client_cnt(GYROSCOPE_EVENT_UNPROCESSED_DATA_REPORT_ON_TIME)) { + if (get_client_cnt(GYROSCOPE_UNPROCESSED_DATA_EVENT)) { event.sensor_id = get_id(); - event.event_type = GYROSCOPE_EVENT_UNPROCESSED_DATA_REPORT_ON_TIME; + event.event_type = GYROSCOPE_UNPROCESSED_DATA_EVENT; push(event); } - if (get_client_cnt(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME)) { + if (get_client_cnt(GYROSCOPE_RAW_DATA_EVENT)) { event.sensor_id = get_id(); - event.event_type = GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME; + event.event_type = GYROSCOPE_RAW_DATA_EVENT; raw_to_base(event.data); push(event); } @@ -136,7 +136,7 @@ int gyro_sensor::get_sensor_data(unsigned int type, sensor_data_t &data) { int state; - if (type != GYRO_BASE_DATA_SET) + if (type != GYROSCOPE_RAW_DATA_EVENT) return -1; state = m_sensor_hal->get_sensor_data(data); diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index f022992..f97e9b0 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -51,7 +51,7 @@ log_element g_log_elements[] = { 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_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, GYROSCOPE_RAW_DATA_EVENT, 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), FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_EVENT_LEVEL_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, 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), FILL_LOG_ELEMENT(LOG_ID_DATA, PRESSURE_BASE_DATA_SET, 0, 25), @@ -154,7 +153,7 @@ bool is_ontime_event(unsigned int event_type) switch (event_type ) { case ACCELEROMETER_RAW_DATA_EVENT: case PROXIMITY_EVENT_STATE_REPORT_ON_TIME: - case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME: + case GYROSCOPE_RAW_DATA_EVENT: case LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME: case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME: case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME: diff --git a/src/libsensord/sensor_gyro.h b/src/libsensord/sensor_gyro.h index 4a5ce87..0425afe 100755 --- a/src/libsensord/sensor_gyro.h +++ b/src/libsensord/sensor_gyro.h @@ -36,13 +36,9 @@ extern "C" * @{ */ -enum gyro_data_id { - GYRO_BASE_DATA_SET = (GYROSCOPE_SENSOR << 16) | 0x0001, -}; - enum gyro_event_type { - GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME = (GYROSCOPE_SENSOR << 16) | 0x0001, - GYROSCOPE_EVENT_UNPROCESSED_DATA_REPORT_ON_TIME = (GYROSCOPE_SENSOR << 16) | 0x0002, + GYROSCOPE_RAW_DATA_EVENT = (GYROSCOPE_SENSOR << 16) | 0x0001, + GYROSCOPE_UNPROCESSED_DATA_EVENT = (GYROSCOPE_SENSOR << 16) | 0x0002, }; /** diff --git a/src/orientation/orientation_sensor.cpp b/src/orientation/orientation_sensor.cpp index 0719a1b..424db60 100755 --- a/src/orientation/orientation_sensor.cpp +++ b/src/orientation/orientation_sensor.cpp @@ -235,7 +235,7 @@ bool orientation_sensor::on_start(void) 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); + m_gyro_sensor->add_client(GYROSCOPE_RAW_DATA_EVENT); m_gyro_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); m_gyro_sensor->start(); m_magnetic_sensor->add_client(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME); @@ -253,7 +253,7 @@ bool orientation_sensor::on_stop(void) 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); + m_gyro_sensor->delete_client(GYROSCOPE_RAW_DATA_EVENT); m_gyro_sensor->delete_interval((intptr_t)this, false); m_gyro_sensor->stop(); m_magnetic_sensor->delete_client(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME); @@ -306,7 +306,7 @@ void orientation_sensor::synthesize(const sensor_event_t &event, vectorget_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data); - m_gyro_sensor->get_sensor_data(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME, gyro_data); + m_gyro_sensor->get_sensor_data(GYROSCOPE_RAW_DATA_EVENT, gyro_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); diff --git a/src/rotation_vector/rv/rv_sensor.cpp b/src/rotation_vector/rv/rv_sensor.cpp index 392d930..9c80252 100755 --- a/src/rotation_vector/rv/rv_sensor.cpp +++ b/src/rotation_vector/rv/rv_sensor.cpp @@ -201,7 +201,7 @@ bool rv_sensor::on_start(void) 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); + m_gyro_sensor->add_client(GYROSCOPE_RAW_DATA_EVENT); m_gyro_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); m_gyro_sensor->start(); m_magnetic_sensor->add_client(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME); @@ -219,7 +219,7 @@ bool rv_sensor::on_stop(void) 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); + m_gyro_sensor->delete_client(GYROSCOPE_RAW_DATA_EVENT); m_gyro_sensor->delete_interval((intptr_t)this, false); m_gyro_sensor->stop(); m_magnetic_sensor->delete_client(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME); @@ -272,7 +272,7 @@ void rv_sensor::synthesize(const sensor_event_t& event, vector & m_enable_orientation |= ACCELEROMETER_ENABLED; } - else if (event.event_type == GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME) { + else if (event.event_type == GYROSCOPE_RAW_DATA_EVENT) { diff_time = event.data.timestamp - m_time; if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR)) @@ -344,7 +344,7 @@ int rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_t &data) return -1; 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_gyro_sensor->get_sensor_data(GYROSCOPE_RAW_DATA_EVENT, gyro_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); diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index d9c5baa..048f2d5 100755 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -854,7 +854,7 @@ void insert_priority_list(unsigned int event_type) event_type == GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME || event_type == ROTATION_VECTOR_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(GYROSCOPE_RAW_DATA_EVENT); priority_list.insert(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME); } diff --git a/test/src/auto_test.c b/test/src/auto_test.c index 283aaf1..a770c69 100644 --- a/test/src/auto_test.c +++ b/test/src/auto_test.c @@ -208,7 +208,7 @@ int main(int argc, char **argv) result = check_sensor_api(GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME, interval); fprintf(fp, "Gravity - RAW_DATA_REPORT_ON_TIME - %d\n", result); - result = check_sensor_api(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME, interval); + result = check_sensor_api(GYROSCOPE_RAW_DATA_EVENT, interval); fprintf(fp, "Gyroscope - RAW_DATA_REPORT_ON_TIME - %d\n", result); result = check_sensor_api(LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, interval); diff --git a/test/src/tc-common.c b/test/src/tc-common.c index 368143a..12dcde6 100644 --- a/test/src/tc-common.c +++ b/test/src/tc-common.c @@ -67,7 +67,7 @@ unsigned int get_event_driven(sensor_type_t sensor_type, char str[]) break; case GYROSCOPE_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) - return GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME; + return GYROSCOPE_RAW_DATA_EVENT; break; case PRESSURE_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) @@ -181,7 +181,7 @@ int main(int argc, char **argv) } else if (strcmp(argv[1], "gyroscope") == 0) { sensor_type = GYROSCOPE_SENSOR; - event = GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME; + event = GYROSCOPE_RAW_DATA_EVENT; } else if (strcmp(argv[1], "pressure") == 0) { sensor_type = PRESSURE_SENSOR; -- 2.7.4