Cleanup of sensor fusion related code 24/30524/2
authorRamasamy <ram.kannan@samsung.com>
Wed, 19 Nov 2014 12:11:05 +0000 (17:41 +0530)
committerRamasamy Kannan <ram.kannan@samsung.com>
Thu, 20 Nov 2014 05:34:30 +0000 (21:34 -0800)
Cleanup of legacy sensor fusion code remaining after private
code sync with public code.

Change-Id: I66673a52e23c67e4839a0abce1f10b959cb5610f

src/shared/csensor_event_dispatcher.cpp
src/shared/fusion_util.cpp [deleted file]
src/shared/fusion_util.h [deleted file]
src/shared/sensor_plugin_loader.cpp
src/shared/sensor_plugin_loader.h
src/shared/virtual_sensor.cpp
src/shared/virtual_sensor.h

index 3b90c34..f9f90d5 100755 (executable)
@@ -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 (file)
index b6d2c14..0000000
+++ /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 <fusion_util.h>
-#include <math.h>
-#include <stdlib.h>
-
-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 (executable)
index 53310c1..0000000
+++ /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
index 9819a15..09f6711 100755 (executable)
  *
  */
 
-
 #include <sensor_plugin_loader.h>
-
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
-
 #include <sensor_hal.h>
 #include <sensor_base.h>
-
 #include <dlfcn.h>
 #include <dirent.h>
 #include <common.h>
@@ -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;
 
index 332db4a..5964835 100755 (executable)
@@ -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_type_t, sensor_base*> sensor_plugins;
 *
 */
 
-typedef vector<sensor_fusion*> fusion_plugins;
-/*
-* a fusion_plugins is a group of fusion plugin
-* <FUSION>
-* ...
-* </FUSION>
-*
-*/
-
 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();
index 221884b..bd0aa84 100755 (executable)
@@ -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;
+}
+
index 94acc4c..d592ce6 100755 (executable)
@@ -28,12 +28,15 @@ public:
        virtual_sensor();
        virtual ~virtual_sensor();
 
-       virtual void synthesize(const sensor_event_t& event, vector<sensor_event_t> &outs) = 0;
+       virtual void synthesize(const sensor_event_t &event, vector<sensor_event_t> &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