From 6bf910fdf6bf2e1cd212ccaf79bceecce1c67961 Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Wed, 19 Nov 2014 17:41:05 +0530 Subject: [PATCH] Cleanup of sensor fusion related code Cleanup of legacy sensor fusion code remaining after private code sync with public code. Change-Id: I66673a52e23c67e4839a0abce1f10b959cb5610f --- src/shared/csensor_event_dispatcher.cpp | 4 --- src/shared/fusion_util.cpp | 56 --------------------------------- src/shared/fusion_util.h | 34 -------------------- src/shared/sensor_plugin_loader.cpp | 7 +---- src/shared/sensor_plugin_loader.h | 11 ------- src/shared/virtual_sensor.cpp | 7 +++++ src/shared/virtual_sensor.h | 5 ++- 7 files changed, 12 insertions(+), 112 deletions(-) delete mode 100644 src/shared/fusion_util.cpp delete mode 100755 src/shared/fusion_util.h diff --git a/src/shared/csensor_event_dispatcher.cpp b/src/shared/csensor_event_dispatcher.cpp index 3b90c34..f9f90d5 100755 --- a/src/shared/csensor_event_dispatcher.cpp +++ b/src/shared/csensor_event_dispatcher.cpp @@ -151,7 +151,6 @@ void csensor_event_dispatcher::dispatch_event(void) } else { sensor_event_t sensor_events[MAX_SENSOR_EVENT]; unsigned int event_cnt = 0; - sensor_events[event_cnt++] = *((sensor_event_t *)seed_event); virtual_sensors v_sensors = get_active_virtual_sensors(); @@ -160,11 +159,8 @@ void csensor_event_dispatcher::dispatch_event(void) while (it_v_sensor != v_sensors.end()) { int synthesized_cnt; - v_sensor_events.clear(); - (*it_v_sensor)->synthesize(*((sensor_event_t *)seed_event), v_sensor_events); - synthesized_cnt = v_sensor_events.size(); for (int i = 0; i < synthesized_cnt; ++i) diff --git a/src/shared/fusion_util.cpp b/src/shared/fusion_util.cpp deleted file mode 100644 index b6d2c14..0000000 --- a/src/shared/fusion_util.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * libsensord-share - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include - -int quat_to_matrix(const float *quat, float *R) -{ - if(quat == NULL || R == NULL) - return -1; - - float q0 = quat[3]; - float q1 = quat[0]; - float q2 = quat[1]; - float q3 = quat[2]; - - float sq_q1 = 2 * q1 * q1; - float sq_q2 = 2 * q2 * q2; - float sq_q3 = 2 * q3 * q3; - float q1_q2 = 2 * q1 * q2; - float q3_q0 = 2 * q3 * q0; - float q1_q3 = 2 * q1 * q3; - float q2_q0 = 2 * q2 * q0; - float q2_q3 = 2 * q2 * q3; - float q1_q0 = 2 * q1 * q0; - - R[0] = 1 - sq_q2 - sq_q3; - R[1] = q1_q2 - q3_q0; - R[2] = q1_q3 + q2_q0; - R[3] = q1_q2 + q3_q0; - R[4] = 1 - sq_q1 - sq_q3; - R[5] = q2_q3 - q1_q0; - R[6] = q1_q3 - q2_q0; - R[7] = q2_q3 + q1_q0; - R[8] = 1 - sq_q1 - sq_q2; - - return 0; -} - diff --git a/src/shared/fusion_util.h b/src/shared/fusion_util.h deleted file mode 100755 index 53310c1..0000000 --- a/src/shared/fusion_util.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * libsensord-share - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef _FUSION_UTIL_H_ -#define _FUSION_UTIL_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -int quat_to_matrix(const float *quat, float *R); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/shared/sensor_plugin_loader.cpp b/src/shared/sensor_plugin_loader.cpp index 9819a15..09f6711 100755 --- a/src/shared/sensor_plugin_loader.cpp +++ b/src/shared/sensor_plugin_loader.cpp @@ -17,15 +17,11 @@ * */ - #include - #include #include - #include #include - #include #include #include @@ -39,7 +35,6 @@ using std::unordered_set; #define ROOT_ELEMENT "PLUGIN" #define TEXT_ELEMENT "text" #define PATH_ATTR "path" - #define HAL_ELEMENT "HAL" #define SENSOR_ELEMENT "SENSOR" @@ -106,7 +101,7 @@ bool sensor_plugin_loader::load_module(const string &path, void** module, void** bool sensor_plugin_loader::insert_module(plugin_type type, const string &path) { if (type == PLUGIN_TYPE_HAL) { - DBG("insert sensor plugin [%s]", path); + DBG("insert sensor plugin [%s]", path.c_str()); sensor_hal *module; void *handle; diff --git a/src/shared/sensor_plugin_loader.h b/src/shared/sensor_plugin_loader.h index 332db4a..5964835 100755 --- a/src/shared/sensor_plugin_loader.h +++ b/src/shared/sensor_plugin_loader.h @@ -33,7 +33,6 @@ class sensor_hal; class sensor_base; -class sensor_fusion; using std::pair; using std::vector; @@ -60,15 +59,6 @@ typedef multimap sensor_plugins; * */ -typedef vector fusion_plugins; -/* -* a fusion_plugins is a group of fusion plugin -* -* ... -* -* -*/ - class sensor_plugin_loader { private: @@ -87,7 +77,6 @@ private: sensor_hal_plugins m_sensor_hals; sensor_plugins m_sensors; - fusion_plugins m_fusions; public: static sensor_plugin_loader& get_instance(); diff --git a/src/shared/virtual_sensor.cpp b/src/shared/virtual_sensor.cpp index 221884b..bd0aa84 100755 --- a/src/shared/virtual_sensor.cpp +++ b/src/shared/virtual_sensor.cpp @@ -46,3 +46,10 @@ bool virtual_sensor::deactivate(void) { return csensor_event_dispatcher::get_instance().delete_active_virtual_sensor(this); } + +bool virtual_sensor::push(sensor_event_t const &event) +{ + csensor_event_queue::get_instance().push(event); + return true; +} + diff --git a/src/shared/virtual_sensor.h b/src/shared/virtual_sensor.h index 94acc4c..d592ce6 100755 --- a/src/shared/virtual_sensor.h +++ b/src/shared/virtual_sensor.h @@ -28,12 +28,15 @@ public: virtual_sensor(); virtual ~virtual_sensor(); - virtual void synthesize(const sensor_event_t& event, vector &outs) = 0; + virtual void synthesize(const sensor_event_t &event, vector &outs) = 0; + virtual int get_sensor_data(const unsigned int event_type, sensor_data_t &data) = 0; bool is_virtual(void); protected: bool activate(void); bool deactivate(void); + + bool push(sensor_event_t const &event); }; #endif -- 2.7.4