Changes as per the new sensord structure 07/50907/2
authorAdarsh Shree Ram <adarsh.ram@samsung.com>
Tue, 3 Nov 2015 11:44:03 +0000 (17:14 +0530)
committerAdarsh Shree Ram <adarsh.ram@samsung.com>
Tue, 3 Nov 2015 11:50:26 +0000 (17:20 +0530)
-UPdated CMakelists and spec files as per the new sensord structure
-updated header file inclusions as per the new file names
-moved files from shared to server folder

Change-Id: I06d7387d1c4a7dc0851e0ece7df0c11ddaa10b22

66 files changed:
packaging/sensord.spec
src/CMakeLists.txt
src/client/CMakeLists.txt
src/client/client.cpp
src/client/client_common.h
src/client/csensor_handle_info.h
src/client/poller.cpp
src/server/CMakeLists.txt
src/server/cclient_info_manager.cpp
src/server/cclient_info_manager.h
src/server/cclient_sensor_record.cpp
src/server/cconfig.h
src/server/command_worker.cpp
src/server/csensor_event_dispatcher.cpp
src/server/csensor_event_queue.cpp
src/server/csensor_usage.cpp
src/server/cvirtual_sensor_config.cpp
src/server/dbus_util.cpp
src/server/main.cpp
src/server/permission_checker.cpp
src/server/plugins/accel/accel_sensor.cpp
src/server/plugins/auto_rotation/auto_rotation_alg.cpp
src/server/plugins/auto_rotation/auto_rotation_alg_emul.cpp
src/server/plugins/auto_rotation/auto_rotation_sensor.cpp
src/server/plugins/bio_led_red/bio_led_red_sensor.cpp
src/server/plugins/fusion/CMakeLists.txt
src/server/plugins/fusion/fusion_sensor.cpp
src/server/plugins/geo/geo_sensor.cpp
src/server/plugins/gravity/CMakeLists.txt
src/server/plugins/gravity/gravity_sensor.cpp
src/server/plugins/gyro/gyro_sensor.cpp
src/server/plugins/light/light_sensor.cpp
src/server/plugins/linear_accel/CMakeLists.txt
src/server/plugins/linear_accel/linear_accel_sensor.cpp
src/server/plugins/orientation/CMakeLists.txt
src/server/plugins/orientation/orientation_sensor.cpp
src/server/plugins/pressure/pressure_sensor.cpp
src/server/plugins/proxi/proxi_sensor.cpp
src/server/plugins/rotation_vector/gaming_rv/CMakeLists.txt
src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.cpp
src/server/plugins/rotation_vector/geomagnetic_rv/CMakeLists.txt
src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp
src/server/plugins/rotation_vector/rv/CMakeLists.txt
src/server/plugins/rotation_vector/rv/rv_sensor.cpp
src/server/plugins/rotation_vector/rv_raw/rv_raw_sensor.cpp
src/server/plugins/temperature/temperature_sensor.cpp
src/server/plugins/tilt/CMakeLists.txt
src/server/plugins/tilt/tilt_sensor.cpp
src/server/plugins/ultraviolet/ultraviolet_sensor.cpp
src/server/plugins/uncal_gyro/CMakeLists.txt
src/server/plugins/uncal_gyro/uncal_gyro_sensor.cpp
src/server/sensor_base.h
src/server/sensor_plugin_loader.cpp [moved from src/shared/sensor_plugin_loader.cpp with 99% similarity]
src/server/sensor_plugin_loader.h [moved from src/shared/sensor_plugin_loader.h with 100% similarity]
src/server/worker_thread.cpp
src/shared/CMakeLists.txt
src/shared/cbase_lock.cpp
src/shared/cmutex.cpp
src/shared/cpacket.cpp
src/shared/csensor_config.cpp [new file with mode: 0755]
src/shared/csensor_config.h [new file with mode: 0755]
src/shared/csocket.h
src/shared/sensor_info.cpp
src/shared/sensor_logs.cpp [moved from src/shared/common.cpp with 99% similarity]
src/shared/sensor_logs.h [moved from src/shared/common.h with 100% similarity]
src/shared/sf_common.h

index 92d9bad..ed87346 100644 (file)
@@ -16,7 +16,6 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(libsystemd-daemon)
 BuildRequires:  pkgconfig(capi-system-info)
-BuildRequires:  pkgconfig(sensor-hal)
 BuildRequires:  pkgconfig(cynara-creds-socket)
 BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(cynara-session)
index c3b2022..862064f 100755 (executable)
@@ -4,89 +4,6 @@ project(sensord_src CXX)
 include_directories(${CMAKE_SOURCE_DIR}/src/shared)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 
-IF("${ACCEL}" STREQUAL "ON")
-add_subdirectory(plugins/accel)
-ENDIF()
-IF("${GYRO}" STREQUAL "ON")
-add_subdirectory(plugins/gyro)
-ENDIF()
-IF("${PROXI}" STREQUAL "ON")
-add_subdirectory(plugins/proxi)
-ENDIF()
-IF("${LIGHT}" STREQUAL "ON")
-add_subdirectory(plugins/light)
-ENDIF()
-IF("${GEO}" STREQUAL "ON")
-add_subdirectory(plugins/geo)
-ENDIF()
-IF("${AUTO_ROTATION}" STREQUAL "ON")
-add_subdirectory(plugins/auto_rotation)
-ENDIF()
-IF("${PRESSURE}" STREQUAL "ON")
-add_subdirectory(plugins/pressure)
-ENDIF()
-IF("${TEMPERATURE}" STREQUAL "ON")
-add_subdirectory(plugins/temperature)
-ENDIF()
-IF("${HUMIDITY}" STREQUAL "ON")
-add_subdirectory(humidity)
-ENDIF()
-IF("${ULTRAVIOLET}" STREQUAL "ON")
-add_subdirectory(plugins/ultraviolet)
-ENDIF()
-IF("${BIO_LED_RED}" STREQUAL "ON")
-add_subdirectory(plugins/bio_led_red)
-ENDIF()
-IF("${ORIENTATION}" STREQUAL "ON")
-set(SENSOR_FUSION_ENABLE "1")
-set(ORIENTATION_ENABLE "1")
-ENDIF()
-IF("${GEOMAGNETIC_RV}" STREQUAL "ON")
-set(SENSOR_FUSION_ENABLE "1")
-ENDIF()
-IF("${GAMING_RV}" STREQUAL "ON")
-set(SENSOR_FUSION_ENABLE "1")
-ENDIF()
-IF("${TILT}" STREQUAL "ON")
-set(SENSOR_FUSION_ENABLE "1")
-set(TILT_ENABLE "1")
-ENDIF()
-IF("${UNCAL_GYRO}" STREQUAL "ON")
-set(SENSOR_FUSION_ENABLE "1")
-set(UNCAL_GYRO_ENABLE "1")
-ENDIF()
-IF("${GRAVITY}" STREQUAL "ON")
-set(SENSOR_FUSION_ENABLE "1")
-set(ORIENTATION_ENABLE "1")
-set(GRAVITY_ENABLE "1")
-ENDIF()
-IF("${LINEAR_ACCEL}" STREQUAL "ON")
-set(SENSOR_FUSION_ENABLE "1")
-set(ORIENTATION_ENABLE "1")
-set(GRAVITY_ENABLE "1")
-set(LINEAR_ACCELERATION_ENABLE "1")
-ENDIF()
-IF("${SENSOR_FUSION_ENABLE}" STREQUAL "1")
-add_subdirectory(plugins/sensor_fusion)
-add_subdirectory(plugins/fusion)
-ENDIF()
-IF("${ORIENTATION_ENABLE}" STREQUAL "1")
-add_subdirectory(plugins/orientation)
-ENDIF()
-IF("${GRAVITY_ENABLE}" STREQUAL "1")
-add_subdirectory(plugins/gravity)
-ENDIF()
-IF("${LINEAR_ACCELERATION_ENABLE}" STREQUAL "1")
-add_subdirectory(plugins/linear_accel)
-ENDIF()
-IF("${TILT_ENABLE}" STREQUAL "1")
-add_subdirectory(plugins/tilt)
-ENDIF()
-IF("${UNCAL_GYRO_ENABLE}" STREQUAL "1")
-add_subdirectory(plugins/uncal_gyro)
-ENDIF()
-
-add_subdirectory(plugins/rotation_vector)
 add_subdirectory(server)
 add_subdirectory(client)
 add_subdirectory(shared)
index d85785c..3f989c8 100755 (executable)
@@ -29,7 +29,7 @@ add_library(${PROJECT_NAME} SHARED
        poller.cpp
 )
 
-target_link_libraries(${PROJECT_NAME} ${lib_pkgs_LDFLAGS} "sensord-share" "sensor-hal")
+target_link_libraries(${PROJECT_NAME} ${lib_pkgs_LDFLAGS} "sensord-share")
 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
 
index 9167a7a..fd9c84a 100644 (file)
@@ -24,7 +24,7 @@
 #include <client_common.h>
 #include <vconf.h>
 #include <cmutex.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sensor_info.h>
 #include <sensor_info_manager.h>
 #include <vector>
index 5d6a752..db3ae6d 100755 (executable)
@@ -24,7 +24,7 @@
 #include <sensor_internal.h>
 #include <csensor_handle_info.h>
 #include <creg_event_info.h>
-#include <common.h>
+#include <sensor_logs.h>
 
 #define BASE_GATHERING_INTERVAL        100
 
index 51fb8be..6a22dc9 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <creg_event_info.h>
 #include <command_channel.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <string.h>
 #include <unordered_map>
 
index 64292e5..e174caf 100755 (executable)
@@ -16,7 +16,7 @@
  * limitations under the License.
  *
  */
-#include <common.h>
+#include <sensor_logs.h>
 #include <poller.h>
 #include <sf_common.h>
 
index 4d4ebfb..f751ecc 100755 (executable)
@@ -2,8 +2,7 @@ cmake_minimum_required(VERSION 2.6)
 project(sensord CXX)
 
 INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(server_pkgs REQUIRED glib-2.0 gio-2.0 dlog libsystemd-daemon cynara-client cynara-creds-socket cynara-session)
-
+PKG_CHECK_MODULES(server_pkgs REQUIRED glib-2.0 gio-2.0 dlog libsystemd-daemon libxml-2.0 cynara-client cynara-creds-socket cynara-session)
 FOREACH(flag ${server_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
 ENDFOREACH(flag)
@@ -24,10 +23,117 @@ SET(SERVER_SRCS
        command_worker.cpp
        permission_checker.cpp
        main.cpp
+
+)
+
+add_library(sensord-server SHARED
+       worker_thread.cpp
+       cvirtual_sensor_config.cpp
+       csensor_event_queue.cpp
+       csensor_event_dispatcher.cpp
+       csensor_usage.cpp
+       cplugin_info_list.cpp
+       sensor_plugin_loader.cpp
+       sensor_base.cpp
+       physical_sensor.cpp
+       virtual_sensor.cpp
+       cclient_info_manager.cpp
+       cclient_sensor_record.cpp
+       cconfig.cpp
 )
+target_link_libraries(sensord-server ${shared_pkgs_LDFLAGS} "-lrt -ldl -pthread" "sensord-share")
+configure_file(sensord-server.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/sensord-server.pc @ONLY)
+install(TARGETS sensord-server DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(FILES sensord-server.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 
 add_executable(${PROJECT_NAME} ${SERVER_SRCS})
 
-target_link_libraries(${PROJECT_NAME} ${server_pkgs_LDFLAGS} "sensord-server" "sensor-hal")
+target_link_libraries(${PROJECT_NAME} ${server_pkgs_LDFLAGS} "sensord-server")
 
 install(TARGETS ${PROJECT_NAME} DESTINATION bin)
+
+
+
+IF("${ACCEL}" STREQUAL "ON")
+add_subdirectory(plugins/accel)
+ENDIF()
+IF("${GYRO}" STREQUAL "ON")
+add_subdirectory(plugins/gyro)
+ENDIF()
+IF("${PROXI}" STREQUAL "ON")
+add_subdirectory(plugins/proxi)
+ENDIF()
+IF("${LIGHT}" STREQUAL "ON")
+add_subdirectory(plugins/light)
+ENDIF()
+IF("${GEO}" STREQUAL "ON")
+add_subdirectory(plugins/geo)
+ENDIF()
+IF("${AUTO_ROTATION}" STREQUAL "ON")
+add_subdirectory(plugins/auto_rotation)
+ENDIF()
+IF("${PRESSURE}" STREQUAL "ON")
+add_subdirectory(plugins/pressure)
+ENDIF()
+IF("${TEMPERATURE}" STREQUAL "ON")
+add_subdirectory(plugins/temperature)
+ENDIF()
+IF("${HUMIDITY}" STREQUAL "ON")
+add_subdirectory(humidity)
+ENDIF()
+IF("${ULTRAVIOLET}" STREQUAL "ON")
+add_subdirectory(plugins/ultraviolet)
+ENDIF()
+IF("${BIO_LED_RED}" STREQUAL "ON")
+add_subdirectory(plugins/bio_led_red)
+ENDIF()
+IF("${ORIENTATION}" STREQUAL "ON")
+set(SENSOR_FUSION_ENABLE "1")
+set(ORIENTATION_ENABLE "1")
+ENDIF()
+IF("${GEOMAGNETIC_RV}" STREQUAL "ON")
+set(SENSOR_FUSION_ENABLE "1")
+ENDIF()
+IF("${GAMING_RV}" STREQUAL "ON")
+set(SENSOR_FUSION_ENABLE "1")
+ENDIF()
+IF("${TILT}" STREQUAL "ON")
+set(SENSOR_FUSION_ENABLE "1")
+set(TILT_ENABLE "1")
+ENDIF()
+IF("${UNCAL_GYRO}" STREQUAL "ON")
+set(SENSOR_FUSION_ENABLE "1")
+set(UNCAL_GYRO_ENABLE "1")
+ENDIF()
+IF("${GRAVITY}" STREQUAL "ON")
+set(SENSOR_FUSION_ENABLE "1")
+set(ORIENTATION_ENABLE "1")
+set(GRAVITY_ENABLE "1")
+ENDIF()
+IF("${LINEAR_ACCEL}" STREQUAL "ON")
+set(SENSOR_FUSION_ENABLE "1")
+set(ORIENTATION_ENABLE "1")
+set(GRAVITY_ENABLE "1")
+set(LINEAR_ACCELERATION_ENABLE "1")
+ENDIF()
+IF("${SENSOR_FUSION_ENABLE}" STREQUAL "1")
+add_subdirectory(sensor_fusion)
+add_subdirectory(plugins/fusion)
+ENDIF()
+IF("${ORIENTATION_ENABLE}" STREQUAL "1")
+add_subdirectory(plugins/orientation)
+ENDIF()
+IF("${GRAVITY_ENABLE}" STREQUAL "1")
+add_subdirectory(plugins/gravity)
+ENDIF()
+IF("${LINEAR_ACCELERATION_ENABLE}" STREQUAL "1")
+add_subdirectory(plugins/linear_accel)
+ENDIF()
+IF("${TILT_ENABLE}" STREQUAL "1")
+add_subdirectory(plugins/tilt)
+ENDIF()
+IF("${UNCAL_GYRO_ENABLE}" STREQUAL "1")
+add_subdirectory(plugins/uncal_gyro)
+ENDIF()
+
+add_subdirectory(plugins/rotation_vector)
index 4877972..540491c 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #include <cclient_info_manager.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <csocket.h>
 
 using std::pair;
index c6f79e3..f49b324 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <cclient_sensor_record.h>
 #include <unordered_map>
-#include <common.h>
+#include <sensor_logs.h>
 #include <cmutex.h>
 #include <vector>
 
index d6b1432..24d4c6c 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #include <cclient_sensor_record.h>
-#include <common.h>
+#include <sensor_logs.h>
 
 using std::pair;
 using std::string;
index dd23b11..ef2802f 100755 (executable)
@@ -22,7 +22,7 @@
 
 #include <string>
 #include <unordered_map>
-#include <common.h>
+#include <sensor_logs.h>
 
 class cconfig
 {
index f8148de..dd8cab2 100644 (file)
 #include <command_worker.h>
 #include <sensor_plugin_loader.h>
 #include <sensor_info.h>
-#include <sensor_accel.h>
-#include <sensor_gyro.h>
-#include <sensor_geomag.h>
-#include <sensor_orientation.h>
-#include <sensor_linear_accel.h>
-#include <sensor_gravity.h>
+#include <sensor_types.h>
 #include <thread>
 #include <string>
 #include <vector>
index 8b23060..e82b6e2 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <csensor_event_dispatcher.h>
 #include <sensor_plugin_loader.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <thread>
 #include <vector>
index ed95497..f75fa42 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #include <csensor_event_queue.h>
-#include "common.h"
+#include "sensor_logs.h"
 
 csensor_event_queue& csensor_event_queue::get_instance()
 {
index ad9d750..0e06826 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <sensor_internal.h>
 #include <csensor_usage.h>
-#include <common.h>
+#include <sensor_logs.h>
 
 csensor_usage::csensor_usage()
 : m_interval(POLL_MAX_HZ_MS)
index a636e87..25538ce 100755 (executable)
@@ -18,7 +18,7 @@
  */
 
 #include <cvirtual_sensor_config.h>
-#include "common.h"
+#include "sensor_logs.h"
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <string>
index 662be73..8f2941a 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <dbus_util.h>
 #include <gio/gio.h>
 
index 91c8674..28c425e 100755 (executable)
@@ -18,7 +18,7 @@
  */
 
 #include <signal.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <server.h>
 #include <dbus_util.h>
 #include <sensor_plugin_loader.h>
index dea1763..e06e680 100755 (executable)
@@ -22,7 +22,7 @@
 #include <cynara-session.h>
 #include <permission_checker.h>
 #include <sf_common.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sensor_plugin_loader.h>
 #include <sensor_base.h>
 
index 8bd5451..29341b6 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 
 #include <accel_sensor.h>
index 3663ad3..2f3ee2a 100644 (file)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <auto_rotation_alg.h>
 
 auto_rotation_alg::auto_rotation_alg()
index 4c6d542..353a20a 100644 (file)
@@ -18,8 +18,8 @@
  */
 
 #include <sensor_common.h>
-#include <common.h>
-#include <sensor_auto_rotation.h>
+#include <sensor_logs.h>
+#include <sensor_types.h>
 #include <auto_rotation_alg_emul.h>
 #include <stdlib.h>
 #include <math.h>
index 5601fae..9c8c9d9 100755 (executable)
@@ -26,7 +26,7 @@
 #include <sys/types.h>
 #include <dlfcn.h>
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 
 #include <virtual_sensor.h>
index 42405b8..b98da86 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 
 #include <bio_led_red_sensor.h>
index 4554eae..98d03c2 100755 (executable)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME fusion_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${fusion_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index bb04436..40099a7 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <fusion_sensor.h>
 #include <sensor_plugin_loader.h>
index 7c9f670..39e2578 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 
 #include <geo_sensor.h>
index 66bf3fa..e37d2d3 100755 (executable)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME gravity_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${gravity_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index dfe3ae7..9f1a625 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <gravity_sensor.h>
 #include <sensor_plugin_loader.h>
index aeab006..f9787f1 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 
 #include <gyro_sensor.h>
index 0b9062e..4c6c6e8 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <light_sensor.h>
 #include <sensor_plugin_loader.h>
index 586dad0..75eae9d 100755 (executable)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME linear_accel_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${linear_accel_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index fc2a1bb..87f2dd0 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <linear_accel_sensor.h>
 #include <sensor_plugin_loader.h>
index 15a5054..989d597 100755 (executable)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME orientation_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${orientation_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index e560007..d9e2902 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <orientation_sensor.h>
 #include <sensor_plugin_loader.h>
index 33f3b76..f528883 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <pressure_sensor.h>
 #include <sensor_plugin_loader.h>
index ab11ee3..fb4c07d 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <proxi_sensor.h>
 #include <sensor_plugin_loader.h>
index da5bc7b..a43850f 100755 (executable)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME gaming_rv_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${gaming_rv_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index f491038..b2c2209 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <gaming_rv_sensor.h>
 #include <sensor_plugin_loader.h>
index 7055dc7..4c2718d 100755 (executable)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME geomagnetic_rv_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${geomagnetic_rv_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index f4aafe8..2361718 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <geomagnetic_rv_sensor.h>
 #include <sensor_plugin_loader.h>
index dd785ff..13759b5 100755 (executable)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME rv_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${rv_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index e42716b..df9c18c 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <rv_sensor.h>
 #include <sensor_plugin_loader.h>
index 3b9b09e..6e989e4 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 
 #include <rv_raw_sensor.h>
index 679be58..197efda 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <temperature_sensor.h>
 #include <sensor_plugin_loader.h>
index 727727c..5c8312a 100755 (executable)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME tilt_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${tilt_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index a898dea..918c3c1 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <tilt_sensor.h>
 #include <sensor_plugin_loader.h>
index 0b0cd43..496dd03 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 
 #include <ultraviolet_sensor.h>
index d983a91..f38b3c9 100644 (file)
@@ -5,7 +5,7 @@ SET(SENSOR_NAME uncal_gyro_sensor)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/plugins/sensor_fusion)
+include_directories(${CMAKE_SOURCE_DIR}/src/server/sensor_fusion)
 
 FOREACH(flag ${gravity_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index 831b6fe..2d9e60b 100755 (executable)
@@ -25,7 +25,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <dlfcn.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <sf_common.h>
 #include <uncal_gyro_sensor.h>
 #include <sensor_plugin_loader.h>
index 90e27e9..612547a 100644 (file)
@@ -32,7 +32,7 @@
 #include <cplugin_info_list.h>
 #include <cmutex.h>
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <sensor_common.h>
 #include <worker_thread.h>
 #include <sensor_info.h>
similarity index 99%
rename from src/shared/sensor_plugin_loader.cpp
rename to src/server/sensor_plugin_loader.cpp
index 3b5831c..2c10fd4 100755 (executable)
@@ -24,7 +24,7 @@
 #include <sensor_base.h>
 #include <dlfcn.h>
 #include <dirent.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <unordered_set>
 #include <algorithm>
 
index d49d381..2726706 100755 (executable)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 #include <worker_thread.h>
 #include <thread>
 
index b11b4b1..41f824f 100644 (file)
@@ -17,76 +17,36 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/src/client)
 
-add_library(sensord-server SHARED
-       worker_thread.cpp
-       cvirtual_sensor_config.cpp
-       csensor_event_queue.cpp
-       csensor_event_dispatcher.cpp
-       csensor_usage.cpp
-       cclient_info_manager.cpp
-       cclient_sensor_record.cpp
-       cplugin_info_list.cpp
-       sensor_plugin_loader.cpp
-       sensor_base.cpp
-       physical_sensor.cpp
-       virtual_sensor.cpp
-       iio_common.cpp
-)
 
 add_library(sensord-share SHARED
+       cbase_lock.cpp
+       cmutex.cpp
        cpacket.cpp
        csocket.cpp
+       sensor_logs.cpp
        sensor_info.cpp
 )
 
-target_link_libraries(sensord-server ${shared_pkgs_LDFLAGS} "-lrt -ldl -pthread" "sensord-share")
+
 target_link_libraries(sensord-share ${shared_pkgs_LDFLAGS} "-lrt -ldl -pthread")
-configure_file(sensord-server.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/sensord-server.pc @ONLY)
+
 configure_file(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc @ONLY)
 
-install(TARGETS sensord-server DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
 install(TARGETS sensord-share DESTINATION ${CMAKE_INSTALL_LIBDIR})
-install(FILES sensord-server.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+
 install(FILES ${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 install(FILES
-       worker_thread.h
-       cvirtual_sensor_config.h
-       csensor_event_queue.h
-       cplugin_info_list.h
-       sensor_plugin_loader.h
-       sensor_base.h
-       physical_sensor.h
-       virtual_sensor.h
        cpacket.h
        csocket.h
        cbase_lock.h
        sensor_info.h
-       iio_common.h
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
 )
 
-install(FILES sensor_accel.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_geomag.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_light.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_proxi.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_gyro.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_pressure.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_context.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_auto_rotation.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_gravity.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_linear_accel.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_orientation.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_tilt.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_rv.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_geomagnetic_rv.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_gaming_rv.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_temperature.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_motion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_fusion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_ultraviolet.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_bio_led_red.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
+
 install(FILES sensor_deprecated.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES sensor_uncal_gyro.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
+install(FILES sensor_types.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
 install(FILES sensor_internal_deprecated.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
 install(FILES sensor_internal.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
 
index c4f6107..5a1a639 100755 (executable)
@@ -20,7 +20,7 @@
 #include <pthread.h>
 #include <cbase_lock.h>
 #include <stdio.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <errno.h>
 #include <sys/time.h>
 
index 3ffc9f0..fb09f7c 100755 (executable)
@@ -18,7 +18,7 @@
  */
 
 #include <cmutex.h>
-#include "common.h"
+#include "sensor_logs.h"
 
 cmutex::cmutex()
 {
index aef8070..8e680b0 100755 (executable)
@@ -21,7 +21,7 @@
 #include <errno.h>
 #include <string.h>
 #include <new>
-#include <common.h>
+#include <sensor_logs.h>
 #include <cpacket.h>
 #include <sf_common.h>
 
diff --git a/src/shared/csensor_config.cpp b/src/shared/csensor_config.cpp
new file mode 100755 (executable)
index 0000000..ba8111b
--- /dev/null
@@ -0,0 +1,279 @@
+/*
+ * 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 <csensor_config.h>
+#include "sensor_logs.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <sstream>
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using std::ifstream;
+using std::string;
+using std::istringstream;
+
+#define ROOT_ELEMENT   "SENSOR"
+#define TEXT_ELEMENT   "text"
+#define MODEL_ID_ATTR  "id"
+#define DEFAULT_ATTR   "value"
+
+csensor_config::csensor_config()
+{
+}
+
+csensor_config& csensor_config::get_instance(void)
+{
+       static bool load_done = false;
+       static csensor_config inst;
+
+       if (!load_done) {
+               inst.load_config(SENSOR_CONFIG_FILE_PATH);
+               inst.get_device_id();
+               if (!inst.m_device_id.empty())
+                       INFO("Device ID = %s", inst.m_device_id.c_str());
+               else
+                       ERR("Failed to get Device ID");
+               load_done = true;
+       }
+
+       return inst;
+}
+
+bool csensor_config::load_config(const string& config_path)
+{
+       xmlDocPtr doc;
+       xmlNodePtr cur;
+
+       DBG("csensor_config::load_config(\"%s\") is called!\n",config_path.c_str());
+
+       doc = xmlParseFile(config_path.c_str());
+
+       if (doc == NULL) {
+               ERR("There is no %s\n",config_path.c_str());
+               return false;
+       }
+
+       cur = xmlDocGetRootElement(doc);
+       if(cur == NULL) {
+               ERR("There is no root element in %s\n",config_path.c_str());
+               xmlFreeDoc(doc);
+               return false;
+       }
+
+       if(xmlStrcmp(cur->name, (const xmlChar *)ROOT_ELEMENT)) {
+               ERR("Wrong type document: there is no [%s] root element in %s\n",ROOT_ELEMENT,config_path.c_str());
+               xmlFreeDoc(doc);
+               return false;
+       }
+
+       xmlNodePtr model_list_node_ptr;
+       xmlNodePtr model_node_ptr;
+       xmlNodePtr element_node_ptr;
+       xmlAttrPtr attr_ptr;
+       char* prop = NULL;
+
+       model_list_node_ptr = cur->xmlChildrenNode;
+
+       while (model_list_node_ptr != NULL) {
+               //skip garbage element, [text]
+               if (!xmlStrcmp(model_list_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) {
+                       model_list_node_ptr = model_list_node_ptr->next;
+                       continue;
+               }
+
+               //insert Model_list to config map
+               m_sensor_config[(const char*)model_list_node_ptr->name];
+               DBG("<%s>\n",(const char*)model_list_node_ptr->name);
+
+               model_node_ptr = model_list_node_ptr->xmlChildrenNode;
+               while (model_node_ptr != NULL){
+                       //skip garbage element, [text]
+                       if (!xmlStrcmp(model_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) {
+                               model_node_ptr = model_node_ptr->next;
+                               continue;
+                       }
+
+
+                       string model_id;
+                       prop = (char*)xmlGetProp(model_node_ptr,(const xmlChar*)MODEL_ID_ATTR);
+                       model_id = prop;
+                       free(prop);
+
+                       //insert Model to Model_list
+                       m_sensor_config[(const char*)model_list_node_ptr->name][model_id];
+                       DBG("<%s id=\"%s\">\n",(const char*)model_list_node_ptr->name,model_id.c_str());
+
+                       element_node_ptr = model_node_ptr->xmlChildrenNode;
+                       while (element_node_ptr != NULL) {
+                               //skip garbage element, [text]
+                               if (!xmlStrcmp(element_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) {
+                                       element_node_ptr = element_node_ptr->next;
+                                       continue;
+                               }
+
+                               //insert Element to Model
+                               m_sensor_config[(const char*)model_list_node_ptr->name][model_id][(const char*)element_node_ptr->name];
+                               DBG("<%s id=\"%s\"><%s>\n",(const char*)model_list_node_ptr->name,model_id.c_str(),(const char*)element_node_ptr->name);
+
+                               attr_ptr = element_node_ptr->properties;
+                               while (attr_ptr != NULL) {
+
+                                       string key,value;
+                                       key = (char*)attr_ptr->name;
+                                       prop = (char*)xmlGetProp(element_node_ptr,attr_ptr->name);
+                                       value = prop;
+                                       free(prop);
+
+                                       //insert attribute to Element
+                                       m_sensor_config[(const char*)model_list_node_ptr->name][model_id][(const char*)element_node_ptr->name][key]=value;
+                                       DBG("<%s id=\"%s\"><%s \"%s\"=\"%s\">\n",(const char*)model_list_node_ptr->name,model_id.c_str(),(const char*)element_node_ptr->name,key.c_str(),value.c_str());
+                                       attr_ptr = attr_ptr->next;
+                               }
+
+
+                               element_node_ptr = element_node_ptr->next;
+                       }
+
+                       DBG("\n");
+                       model_node_ptr = model_node_ptr->next;
+               }
+
+               DBG("\n");
+               model_list_node_ptr = model_list_node_ptr->next;
+       }
+
+       xmlFreeDoc(doc);
+       return true;
+}
+
+
+bool csensor_config::get(const string& sensor_type,const string& model_id, const string& element, const string& attr, string& value)
+{
+       auto it_model_list = m_sensor_config.find(sensor_type);
+
+       if (it_model_list == m_sensor_config.end())     {
+               ERR("There is no <%s> element\n",sensor_type.c_str());
+               return false;
+       }
+
+       auto it_model = it_model_list->second.find(model_id);
+
+       if (it_model == it_model_list->second.end()) {
+               ERR("There is no <%s id=\"%s\"> element\n",sensor_type.c_str(),model_id.c_str());
+               return false;
+       }
+
+       auto it_element = it_model->second.find(element);
+
+       if (it_element == it_model->second.end()) {
+               DBG("There is no <%s id=\"%s\"><%s> element\n",sensor_type.c_str(),model_id.c_str(),element.c_str());
+               return false;
+       }
+
+       auto it_attr = it_element->second.find(attr);
+
+       if (it_attr == it_element->second.end()) {
+               DBG("There is no <%s id=\"%s\"><%s \"%s\">\n",sensor_type.c_str(),model_id.c_str(),element.c_str(),attr.c_str());
+               return false;
+       }
+
+       value = it_attr->second;
+
+       return true;
+}
+
+bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, const string& attr, double& value)
+{
+       string str_value;
+
+       if (get(sensor_type,model_id,element,attr,str_value) == false)
+               return false;
+
+       istringstream convert(str_value);
+
+       if ( !(convert >> value))
+               value = 0;
+
+       return true;
+}
+
+bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, const string& attr, long& value)
+{
+       string str_value;
+
+       if (get(sensor_type,model_id,element,attr,str_value) == false)
+               return false;
+
+       istringstream convert(str_value);
+
+       if ( !(convert >> value))
+               value = 0;
+
+       return true;
+}
+
+bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, string& value)
+{
+       if (get(sensor_type, model_id, element, m_device_id, value))
+               return true;
+
+       if (get(sensor_type, model_id, element, DEFAULT_ATTR, value))
+               return true;
+
+       return false;
+}
+
+bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, double& value)
+{
+       if (get(sensor_type, model_id, element, m_device_id, value))
+               return true;
+
+       if (get(sensor_type, model_id, element, DEFAULT_ATTR, value))
+               return true;
+
+       return false;
+}
+
+bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, long& value)
+{
+       if (get(sensor_type, model_id, element, m_device_id, value))
+               return true;
+
+       if (get(sensor_type, model_id, element, DEFAULT_ATTR, value))
+               return true;
+
+       return false;
+}
+
+bool csensor_config::is_supported(const string& sensor_type,const string& model_id)
+{
+       auto it_model_list = m_sensor_config.find(sensor_type);
+
+       if (it_model_list == m_sensor_config.end())
+               return false;
+
+       auto it_model = it_model_list->second.find(model_id);
+
+       if (it_model == it_model_list->second.end())
+               return false;
+
+       return true;
+}
diff --git a/src/shared/csensor_config.h b/src/shared/csensor_config.h
new file mode 100755 (executable)
index 0000000..5ce6c74
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ *
+ */
+
+#if !defined(_CSENSOR_CONFIG_CLASS_H_)
+#define _CSENSOR_CONFIG_CLASS_H_
+
+#include <cconfig.h>
+
+#define SENSOR_CONFIG_FILE_PATH "/usr/etc/sensors.xml"
+
+typedef std::unordered_map<std::string,std::string> Element;
+/*
+* an Element  is a group of attributes
+* <Element value1 = "10.0", value2 =  "20.0"/>
+*
+* "value" -> "LSM330DLC"
+*
+*/
+
+typedef std::unordered_map<std::string,Element> Model;
+/*
+* a Model is a group of elements to consist of  specific vendor's one sensor configuration
+* <NAME value = "LSM330DLC" />
+* <VENDOR value = "ST Microelectronics"/>
+* <RAW_DATA_UNIT value = "1" />
+* <RESOLUTION value = "12" />
+*
+* <NAME> -> <value = "LSM330DLC"/>
+*
+*/
+
+typedef std::unordered_map<std::string,Model> Model_list;
+/*
+* a Model_list is  a group of Model
+* <MODEL id = "lsm330dlc_accel">
+* </MODEL>
+* <MODEL id = "mpu6500">
+* </MODEL>
+*
+* "lsm330dlc_accel" -> <Model>
+*
+*/
+
+typedef std::unordered_map<std::string,Model_list> Sensor_config;
+/*
+* a SensorConfig represents sensors.xml
+* <ACCEL/>
+* <GYRO/>
+* <PROXIMITY/>
+*
+* "ACCEL" -> Model_list
+*
+*/
+
+class csensor_config : public cconfig
+{
+private:
+       csensor_config();
+       csensor_config(csensor_config const&) {};
+       csensor_config& operator=(csensor_config const&);
+
+       bool load_config(const std::string& config_path);
+
+       Sensor_config m_sensor_config;
+public:
+       static csensor_config& get_instance(void);
+
+       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, const std::string& attr, std::string& value);
+       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, const std::string& attr, double& value);
+       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, const std::string& attr, long& value);
+
+       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, std::string& value);
+       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, double& value);
+       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, long& value);
+
+       bool is_supported(const std::string &sensor_type, const std::string &model_id);
+};
+
+#endif
index c7f719f..9014bc2 100644 (file)
@@ -26,7 +26,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
-#include "common.h"
+#include "sensor_logs.h"
 
 class csocket {
 public:
index c80c736..c25f366 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #include <sensor_info.h>
-#include <common.h>
+#include <sensor_logs.h>
 #include <algorithm>
 #include <vector>
 #include <string>
similarity index 99%
rename from src/shared/common.cpp
rename to src/shared/sensor_logs.cpp
index 4f9f100..b1b5c0f 100644 (file)
@@ -24,7 +24,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <string.h>
-#include "common.h"
+#include "sensor_logs.h"
 #include <dlog.h>
 #include <stdarg.h>
 #include <stddef.h>
similarity index 100%
rename from src/shared/common.h
rename to src/shared/sensor_logs.h
index 381ac45..af649b9 100644 (file)
@@ -17,7 +17,7 @@
  *
  */
 
-#include <common.h>
+#include <sensor_logs.h>
 
 #if !defined(_SF_COMMON_H_)
 #define _SF_COMMON_H_