From 7e817e54e19a3a0fcfb91ca05462a81deeb15500 Mon Sep 17 00:00:00 2001 From: Vibhor Gaur Date: Mon, 23 Feb 2015 19:57:54 +0530 Subject: [PATCH] Removing redundant temperature sensor events TEMPERATURE_BASE_DATA_SET and TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME were the same. TEMPERATURE_BASE_DATA_SET has been removed. TEMPERATURE_BASE_DATA_SET was used for polling events and TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME was used for event driven. Since both these represent the same pressure event, DATA_SET type has been removed and TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME has been renamed to TEMPERATURE_RAW_DATA_EVENT to make it simpler. These representations have been shifted to sensor_deprecated.h in case other packages outside sensord are using these representations. Change-Id: I7ebe005fcb2dd236cabf4c209a4456973f4597d1 --- src/libsensord/client_common.cpp | 3 +-- src/libsensord/sensor_deprecated.h | 3 +++ src/libsensord/sensor_temperature.h | 6 +----- src/temperature/temperature_sensor.cpp | 8 ++++---- test/src/auto_test.c | 2 +- test/src/tc-common.c | 4 ++-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index 1e3b344..2a67b15 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -60,7 +60,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, TEMPERATURE_RAW_DATA_EVENT, 0, 10), 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), @@ -71,7 +71,6 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_DATA, GRAVITY_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, LINEAR_ACCEL_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, ORIENTATION_BASE_DATA_SET, 0, 25), - FILL_LOG_ELEMENT(LOG_ID_DATA, TEMPERATURE_BASE_DATA_SET, 0, 25), }; typedef unordered_map log_map; diff --git a/src/libsensord/sensor_deprecated.h b/src/libsensord/sensor_deprecated.h index 094907a..52a833e 100644 --- a/src/libsensord/sensor_deprecated.h +++ b/src/libsensord/sensor_deprecated.h @@ -38,6 +38,9 @@ extern "C" #define ACCELEROMETER_EVENT_CALIBRATION_NEEDED 0x01 #define ACCELEROMETER_EVENT_SET_WAKEUP 0x02 +#define TEMPERATURE_BASE_DATA_SET (TEMPERATURE_SENSOR << 16) | 0x0001 +#define TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME (TEMPERATURE_SENSOR << 16) | 0x0001 + enum accelerometer_rotate_state { ROTATION_UNKNOWN = 0, ROTATION_LANDSCAPE_LEFT = 1, diff --git a/src/libsensord/sensor_temperature.h b/src/libsensord/sensor_temperature.h index 52b5730..2af4cc8 100755 --- a/src/libsensord/sensor_temperature.h +++ b/src/libsensord/sensor_temperature.h @@ -36,12 +36,8 @@ extern "C" * @{ */ -enum temperature_data_id { - TEMPERATURE_BASE_DATA_SET = (TEMPERATURE_SENSOR << 16) | 0x0001, -}; - enum temperature_event_type { - TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME = (TEMPERATURE_SENSOR << 16) | 0x0001, + TEMPERATURE_RAW_DATA_EVENT = (TEMPERATURE_SENSOR << 16) | 0x0001, }; /** diff --git a/src/temperature/temperature_sensor.cpp b/src/temperature/temperature_sensor.cpp index e9a154f..20d9955 100755 --- a/src/temperature/temperature_sensor.cpp +++ b/src/temperature/temperature_sensor.cpp @@ -30,7 +30,7 @@ temperature_sensor::temperature_sensor() { m_name = string(SENSOR_NAME); - register_supported_event(TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME); + register_supported_event(TEMPERATURE_RAW_DATA_EVENT); physical_sensor::set_poller(temperature_sensor::working, this); } @@ -85,9 +85,9 @@ bool temperature_sensor::process_event(void) AUTOLOCK(m_client_info_mutex); - if (get_client_cnt(TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME)) { + if (get_client_cnt(TEMPERATURE_RAW_DATA_EVENT)) { event.sensor_id = get_id(); - event.event_type = TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME; + event.event_type = TEMPERATURE_RAW_DATA_EVENT; raw_to_base(event.data); push(event); } @@ -129,7 +129,7 @@ int temperature_sensor::get_sensor_data(unsigned int type, sensor_data_t &data) if (ret < 0) return -1; - if (type == TEMPERATURE_BASE_DATA_SET) { + if (type == TEMPERATURE_RAW_DATA_EVENT) { raw_to_base(data); return 0; } diff --git a/test/src/auto_test.c b/test/src/auto_test.c index 31dd751..99a63c0 100644 --- a/test/src/auto_test.c +++ b/test/src/auto_test.c @@ -226,7 +226,7 @@ int main(int argc, char **argv) result = check_sensor_api(ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME, interval); fprintf(fp, "Rotation Vector - RAW_DATA_REPORT_ON_TIME - %d\n", result); - result = check_sensor_api(TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME, interval); + result = check_sensor_api(TEMPERATURE_RAW_DATA_EVENT, interval); fprintf(fp, "Temperature - RAW_DATA_REPORT_ON_TIME - %d\n", result); printf("Logs printed in ./auto_test.output\n"); diff --git a/test/src/tc-common.c b/test/src/tc-common.c index 53661c3..3aa57b6 100644 --- a/test/src/tc-common.c +++ b/test/src/tc-common.c @@ -83,7 +83,7 @@ unsigned int get_event_driven(sensor_type_t sensor_type, char str[]) break; case TEMPERATURE_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) - return TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME; + return TEMPERATURE_RAW_DATA_EVENT; break; case PROXIMITY_SENSOR: if (strcmp(str, "EVENT_CHANGE_STATE") == 0) @@ -189,7 +189,7 @@ int main(int argc, char **argv) } else if (strcmp(argv[1], "temperature") == 0) { sensor_type = TEMPERATURE_SENSOR; - event = TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME; + event = TEMPERATURE_RAW_DATA_EVENT; } else if (strcmp(argv[1], "geomagnetic") == 0) { sensor_type = GEOMAGNETIC_SENSOR; -- 2.7.4