*/
#include <fcntl.h>
#include <sys/stat.h>
-
#include <linux/input.h>
#include <csensor_config.h>
-
#include <accel_sensor_hal.h>
#include <sys/poll.h>
using std::ifstream;
-using config::csensor_config;
#define GRAVITY 9.80665
#define G_TO_MG 1000
#include <iio_common.h>
using std::ifstream;
-using config::csensor_config;
#define SENSOR_TYPE_MAGNETIC "MAGNETIC"
#define ELEMENT_NAME "NAME"
#include <fcntl.h>
#include <sys/stat.h>
#include <dirent.h>
-
#include <linux/input.h>
#include <csensor_config.h>
-
#include <gyro_sensor_hal.h>
#include <sys/ioctl.h>
#include <fstream>
#include <sys/poll.h>
using std::ifstream;
-using config::csensor_config;
#define DPS_TO_MDPS 1000
#define MIN_RANGE(RES) (-((1 << (RES))/2))
#include <fcntl.h>
#include <sys/stat.h>
#include <dirent.h>
-
#include <linux/input.h>
#include <csensor_config.h>
-
#include <light_sensor_hal.h>
#include <sys/ioctl.h>
#include <iio_common.h>
using std::ifstream;
-using config::csensor_config;
#define SENSOR_TYPE_LIGHT "LIGHT"
#define ELEMENT_NAME "NAME"
#include <common.h>
#include <sf_common.h>
-
#include <pressure_sensor.h>
#include <sensor_plugin_loader.h>
#include <algorithm>
#include <csensor_config.h>
-using config::csensor_config;
using std::bind1st;
using std::mem_fun;
#include <physical_sensor.h>
#include <sensor_hal.h>
-class pressure_sensor : public physical_sensor {
+class pressure_sensor : public physical_sensor
+{
public:
pressure_sensor();
virtual ~pressure_sensor();
bool process_event(void);
float pressure_to_altitude(float pressure);
void raw_to_base(sensor_data_t &data);
-
};
#endif
using std::ifstream;
using std::string;
-using config::csensor_config;
#define SENSOR_TYPE_PRESSURE "PRESSURE"
#define ELEMENT_NAME "NAME"
#include <iio_common.h>
using std::ifstream;
-using config::csensor_config;
#define NO_FLAG 0
#define PROXIMITY_TYPE 8
#define PROXI_CODE 0x0019
-
proxi_sensor_hal::proxi_sensor_hal()
: m_state(PROXIMITY_STATE_FAR)
, m_fired_time(0)
add_library(sensord-server SHARED
crw_lock.cpp
worker_thread.cpp
+ cconfig.cpp
csensor_config.cpp
cvirtual_sensor_config.cpp
csensor_event_queue.cpp
install(FILES
crw_lock.h
worker_thread.h
+ cconfig.h
csensor_config.h
cvirtual_sensor_config.h
csensor_event_queue.h
--- /dev/null
+/*
+ * 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 <cconfig.h>
+#include <fstream>
+
+using std::ifstream;
+
+cconfig::cconfig(void)
+{
+
+}
+
+cconfig::~cconfig(void)
+{
+
+}
+
+bool cconfig::get_device_id(void)
+{
+ const string INFO_INI_PATH = "/etc/info.ini";
+ const string START_DELIMETER = "Model=";
+ const string END_DELIMETER = ";";
+ string line;
+ ifstream in_file;
+ std::size_t start_pos, end_pos;
+ bool ret = false;
+
+ in_file.open(INFO_INI_PATH);
+
+ if (!in_file.is_open())
+ return false;
+
+ while (!in_file.eof()) {
+ getline(in_file, line);
+ start_pos = line.find(START_DELIMETER);
+
+ if (start_pos != std::string::npos) {
+ start_pos = start_pos + START_DELIMETER.size();
+ end_pos = line.find(END_DELIMETER, start_pos);
+
+ if (end_pos != std::string::npos) {
+ m_device_id = line.substr(start_pos, end_pos - start_pos);
+ ret = true;
+ break;
+ }
+ }
+ }
+
+ in_file.close();
+
+ return ret;
+}
--- /dev/null
+/*
+ * 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 _CCONFIG_H_
+#define _CCONFIG_H_
+
+#include <string>
+#include <unordered_map>
+#include <common.h>
+
+using std::unordered_map;
+using std::string;
+using std::istringstream;
+
+class cconfig
+{
+protected:
+ virtual bool load_config(const string& config_path) = 0;
+
+ string m_device_id;
+public:
+ cconfig();
+ virtual ~cconfig();
+
+ bool get_device_id(void);
+
+};
+
+#endif /* _CCONFIG_H_ */
#include <iostream>
#include <fstream>
-using namespace config;
using std::ifstream;
#define ROOT_ELEMENT "SENSOR"
return true;
}
-
-bool csensor_config::get_device_id(void)
-{
- const string INFO_INI_PATH = "/etc/info.ini";
- const string START_DELIMETER = "Model=";
- const string END_DELIMETER = ";";
- string line;
- ifstream in_file;
- std::size_t start_pos, end_pos;
- bool ret = false;
-
- in_file.open(INFO_INI_PATH);
-
- if (!in_file.is_open())
- return false;
-
- while (!in_file.eof()) {
- getline(in_file, line);
- start_pos = line.find(START_DELIMETER);
-
- if (start_pos != std::string::npos) {
- start_pos = start_pos + START_DELIMETER.size();
- end_pos = line.find(END_DELIMETER, start_pos);
-
- if (end_pos != std::string::npos) {
- m_device_id = line.substr(start_pos, end_pos - start_pos);
- ret = true;
- break;
- }
- }
- }
-
- in_file.close();
-
- return ret;
-}
#if !defined(_CSENSOR_CONFIG_CLASS_H_)
#define _CSENSOR_CONFIG_CLASS_H_
-#include <string>
-#include <unordered_map>
-#include <common.h>
-
-using std::unordered_map;
-using std::string;
-using std::istringstream;
+#include <cconfig.h>
#define SENSOR_CONFIG_FILE_PATH "/usr/etc/sensors.xml"
*
*/
-namespace config
+class csensor_config : public cconfig
{
- class csensor_config
- {
- private:
- csensor_config();
- csensor_config(csensor_config const&) {};
- csensor_config& operator=(csensor_config const&);
- bool load_config(const string& config_path);
- Sensor_config m_sensor_config;
- string m_device_id;
- public:
- static csensor_config& get_instance(void);
+private:
+ csensor_config();
+ csensor_config(csensor_config const&) {};
+ csensor_config& operator=(csensor_config const&);
+
+ bool load_config(const string& config_path);
+
+ Sensor_config m_sensor_config;
+public:
+ static csensor_config& get_instance(void);
+
+ bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, string& value);
+ bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, double& value);
+ bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, long& value);
- bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, string& value);
- bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, double& value);
- bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, long& value);
+ bool get(const string& sensor_type, const string& model_id, const string& element, string& value);
+ bool get(const string& sensor_type, const string& model_id, const string& element, double& value);
+ bool get(const string& sensor_type, const string& model_id, const string& element, long& value);
- bool get(const string& sensor_type, const string& model_id, const string& element, string& value);
- bool get(const string& sensor_type, const string& model_id, const string& element, double& value);
- bool get(const string& sensor_type, const string& model_id, const string& element, long& value);
+ bool is_supported(const string &sensor_type, const string &model_id);
+};
- bool is_supported(const string &sensor_type, const string &model_id);
- bool get_device_id(void);
- };
-}
#endif
#include <string>
#include <iostream>
#include <sstream>
-#include <fstream>
-using std::ifstream;
using std::string;
using std::stringstream;
return true;
}
-bool cvirtual_sensor_config::get_device_id(void)
-{
- const string INFO_INI_PATH = "/etc/info.ini";
- const string START_DELIMETER = "Model=";
- const string END_DELIMETER = ";";
- string line;
- ifstream in_file;
- std::size_t start_pos, end_pos;
- bool ret = false;
-
- in_file.open(INFO_INI_PATH);
-
- if (!in_file.is_open())
- return false;
-
- while (!in_file.eof()) {
- getline(in_file, line);
- start_pos = line.find(START_DELIMETER);
-
- if (start_pos != std::string::npos) {
- start_pos = start_pos + START_DELIMETER.size();
- end_pos = line.find(END_DELIMETER, start_pos);
-
- if (end_pos != std::string::npos) {
- m_device_id = line.substr(start_pos, end_pos - start_pos);
- ret = true;
- break;
- }
- }
- }
-
- in_file.close();
-
- return ret;
-}
#if !defined(_CVIRTUAL_SENSOR_CONFIG_CLASS_H_)
#define _CVIRTUAL_SENSOR_CONFIG_CLASS_H_
-#include <string>
-#include <unordered_map>
-#include <common.h>
-
-using std::unordered_map;
-using std::string;
-using std::istringstream;
+#include <cconfig.h>
#define VIRTUAL_SENSOR_CONFIG_FILE_PATH "/usr/etc/virtual_sensors.xml"
*
*/
-class cvirtual_sensor_config
+class cvirtual_sensor_config : public cconfig
{
private:
cvirtual_sensor_config();
cvirtual_sensor_config(cvirtual_sensor_config const&) {};
cvirtual_sensor_config& operator=(cvirtual_sensor_config const&);
+
bool load_config(const string& config_path);
+
Virtual_sensor_config m_virtual_sensor_config;
- string m_device_id;
public:
static cvirtual_sensor_config& get_instance(void);
bool get(const string& sensor_type, const string& element, int *value, int count = 1);
bool is_supported(const string &sensor_type);
- bool get_device_id(void);
};
#endif
using std::ifstream;
using std::fstream;
-using config::csensor_config;
cmutex sensor_hal::m_shared_mutex;
#include <sys/ioctl.h>
#include <iio_common.h>
-
using std::ifstream;
-using config::csensor_config;
#define SENSOR_TYPE_TEMPERATURE "TEMPERATURE"
#define ELEMENT_NAME "NAME"