sensord: rename sensor_logs.h to sensor_log.h
[platform/core/system/sensord.git] / src / client / client_common.h
1 /*
2  * libsensord
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef _CLIENT_COMMON_H_
21 #define _CLIENT_COMMON_H_
22
23 /*header for each sensor type*/
24 #include <sensor_internal.h>
25 #include <sensor_handle_info.h>
26 #include <reg_event_info.h>
27 #include <sensor_log.h>
28
29 #define BASE_GATHERING_INTERVAL 100
30
31 #define CLIENT_NAME_SIZE NAME_MAX+10
32
33 enum log_id {
34         LOG_ID_START = 0,
35         LOG_ID_SENSOR_TYPE = 0,
36         LOG_ID_EVENT,
37         LOG_ID_DATA,
38         LOG_ID_PROPERTY,
39         LOG_ID_END,
40 };
41
42 struct log_attr {
43         const char *name;
44         unsigned long cnt;
45         const unsigned int print_per_cnt;
46 };
47
48 struct log_element {
49         log_id id;
50         int type;
51         struct log_attr log_attr;
52 };
53
54
55 typedef struct {
56         int handle;
57         unsigned int event_type;
58         sensor_event_data_t ev_data;
59         int sensor_state;
60         int sensor_option;
61         sensor_type_t sensor;
62         reg_event_info event_info;
63 } log_info;
64
65 bool is_one_shot_event(unsigned int event_type);
66 bool is_ontime_event(unsigned int event_type);
67 bool is_panning_event(unsigned int event_type);
68 bool is_single_state_event(unsigned int event_type);
69 unsigned int get_calibration_event_type(unsigned int event_type);
70 unsigned long long get_timestamp(void);
71
72 const char* get_log_element_name(log_id id, unsigned int type);
73 const char* get_sensor_name(sensor_id_t sensor_id);
74 const char* get_event_name(unsigned int event_type);
75 const char* get_data_name(unsigned int data_id);
76 void print_event_occurrence_log(sensor_handle_info &sensor_handle_info, const reg_event_info *event_info);
77
78 class sensor_info;
79 sensor_info *sensor_to_sensor_info(sensor_t sensor);
80 sensor_t sensor_info_to_sensor(const sensor_info *info);
81
82 #endif /* _CLIENT_COMMON_H_ */