From b0945fd222eef5d6054b75ec2b5a582969e3d272 Mon Sep 17 00:00:00 2001 From: Jin Yoon Date: Mon, 3 Jul 2017 20:15:14 +0900 Subject: MCC Pattern : Initial version Change-Id: I6a839878b65784fd92b570056d09b61cb7d612fd --- inc/controller.h | 6 ------ inc/model.h | 17 +++++++++++------ inc/model/model_infrared_motion_sensor.h | 8 +++----- inc/model/model_infrared_obstacle_avoidance_sensor.h | 8 +++----- inc/model/model_touch_sensor.h | 8 +++----- inc/model/model_ultrasonic_sensor.h | 6 +++--- 6 files changed, 23 insertions(+), 30 deletions(-) (limited to 'inc') diff --git a/inc/controller.h b/inc/controller.h index aef6e47..7ecdc1d 100644 --- a/inc/controller.h +++ b/inc/controller.h @@ -19,10 +19,4 @@ #ifndef __POSITION_FINDER_CONTROLLER_H__ #define __POSITION_FINDER_CONTROLLER_H__ -typedef int (*controller_event_cb)(const char *event_name, void *event_info, void *data); - -extern int controller_register_event_cb(const char *event_name, controller_event_cb event_cb, void *data); -extern int controller_unregister_event_cb(const char *event_name, controller_event_cb event_cb); -extern int controller_send_event(const char *event_name, void *event_info); - #endif /* __POSITION_FINDER_CONTROLLER_H__ */ diff --git a/inc/model.h b/inc/model.h index 074dfe0..def3713 100644 --- a/inc/model.h +++ b/inc/model.h @@ -27,13 +27,18 @@ enum sensor_type { }; typedef enum sensor_type sensor_type_e; -extern int model_init(sensor_type_e sensor_type); -extern void model_fini(void); +typedef struct _model_sensor_s model_sensor_s; +typedef model_sensor_s *model_sensor_h; -extern int model_alloc(void **data); +extern int model_init(const char *id, sensor_type_e sensor_type, int gpio_num1, int gpio_num2, model_sensor_h *out_info); +extern void model_fini(model_sensor_h info); -extern int model_read_int_value(int *out_value); -extern int model_read_double_value(double *out_value); -extern int model_write(void *data); +extern int model_read_int_value(model_sensor_h info, int *out_value); +extern int model_read_double_value(model_sensor_h info, double *out_value); + +extern int model_list_add_sensor(model_sensor_h info); +extern int model_list_remove_sensor(model_sensor_h info); +extern int model_list_get_sensor(const char *id, model_sensor_h *out_info); +extern int model_list_foreach(void (*cb)(model_sensor_h info)); #endif /* __POSITION_FINDER_MODEL_H__ */ diff --git a/inc/model/model_infrared_motion_sensor.h b/inc/model/model_infrared_motion_sensor.h index 4ff90c7..6667a96 100644 --- a/inc/model/model_infrared_motion_sensor.h +++ b/inc/model/model_infrared_motion_sensor.h @@ -19,11 +19,9 @@ #ifndef __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__ #define __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__ -typedef struct infrared_motion_event infrared_motion_event_s; +extern int model_init_infrared_motion_sensor(int gpio_num, void **peripheral_info); +extern void model_fini_infrared_motion_sensor(void *peripheral_info); -extern int model_init_infrared_motion_sensor(void); -extern void model_fini_infrared_motion_sensor(void); - -extern int model_read_infrared_motion_sensor(int *out_value); +extern int model_read_infrared_motion_sensor(void *peripheral_info, int *out_value); #endif /* __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__ */ diff --git a/inc/model/model_infrared_obstacle_avoidance_sensor.h b/inc/model/model_infrared_obstacle_avoidance_sensor.h index bfba8f9..0833684 100644 --- a/inc/model/model_infrared_obstacle_avoidance_sensor.h +++ b/inc/model/model_infrared_obstacle_avoidance_sensor.h @@ -19,11 +19,9 @@ #ifndef __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ #define __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ -typedef struct infrared_obstacle_avoidance_event infrared_obstacle_avoidance_event_s; +extern int model_init_infrared_obstacle_avoidance_sensor(int gpio_num, void **peripheral_info); +extern void model_fini_infrared_obstacle_avoidance_sensor(void *peripheral_info); -extern int model_init_infrared_obstacle_avoidance_sensor(void); -extern void model_fini_infrared_obstacle_avoidance_sensor(void); - -extern int model_read_infrared_obstacle_avoidance_sensor(int *out_value); +extern int model_read_infrared_obstacle_avoidance_sensor(void *peripheral_info, int *out_value); #endif /* __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */ diff --git a/inc/model/model_touch_sensor.h b/inc/model/model_touch_sensor.h index 4be2525..263bf62 100644 --- a/inc/model/model_touch_sensor.h +++ b/inc/model/model_touch_sensor.h @@ -19,11 +19,9 @@ #ifndef __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__ #define __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__ -typedef struct touch_event touch_event_s; +extern int model_init_touch_sensor(int gpio_num, void **peripheral_info); +extern void model_fini_touch_sensor(void *peripheral_info); -extern int model_init_touch_sensor(void); -extern void model_fini_touch_sensor(void); - -extern int model_read_touch_sensor(int *out_value); +extern int model_read_touch_sensor(void *peripheral_info, int *out_value); #endif /* __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__ */ diff --git a/inc/model/model_ultrasonic_sensor.h b/inc/model/model_ultrasonic_sensor.h index 93149af..d58737f 100644 --- a/inc/model/model_ultrasonic_sensor.h +++ b/inc/model/model_ultrasonic_sensor.h @@ -19,8 +19,8 @@ #ifndef __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__ #define __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__ -extern int model_init_ultrasonic_sensor(void); -extern void model_fini_ultrasonic_sensor(void); -extern int model_read_ultrasonic_sensor(double *value); +extern int model_init_ultrasonic_sensor(int gpio_num1, int gpio_num2, void **peripheral_info); +extern void model_fini_ultrasonic_sensor(void *peripheral_info); +extern int model_read_ultrasonic_sensor(void *peripheral_info, double *value); #endif /* __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__ */ -- cgit v1.2.3