Rename Model as Resource
authorJin Yoon <jinny.yoon@samsung.com>
Wed, 12 Jul 2017 10:26:03 +0000 (19:26 +0900)
committerJin Yoon <jinny.yoon@samsung.com>
Wed, 12 Jul 2017 10:26:03 +0000 (19:26 +0900)
Change-Id: Ie671b3e2bf00fdc45f230c1335b1edc40510bdd0

17 files changed:
CMakeLists.txt
inc/resource.h [moved from inc/model.h with 67% similarity]
inc/resource/resource_illuminance_sensor.h [moved from inc/model/model_illuminance_sensor.h with 74% similarity]
inc/resource/resource_infrared_motion_sensor.h [moved from inc/model/model_infrared_motion_sensor.h with 71% similarity]
inc/resource/resource_infrared_obstacle_avoidance_sensor.h [moved from inc/model/model_infrared_obstacle_avoidance_sensor.h with 67% similarity]
inc/resource/resource_touch_sensor.h [moved from inc/model/model_touch_sensor.h with 74% similarity]
inc/resource/resource_ultrasonic_sensor.h [moved from inc/model/model_ultrasonic_sensor.h with 69% similarity]
inc/resource_internal.h [moved from inc/model_internal.h with 78% similarity]
org.tizen.position-finder-server.manifest [changed mode: 0755->0644]
src/controller.c
src/main.c [deleted file]
src/resource.c [moved from src/model.c with 85% similarity]
src/resource/resource_illuminance_sensor.c [moved from src/model/model_illuminance_sensor.c with 72% similarity]
src/resource/resource_infrared_motion_sensor.c [moved from src/model/model_infrared_motion_sensor.c with 63% similarity]
src/resource/resource_infrared_obstacle_avoidance_sensor.c [moved from src/model/model_infrared_obstacle_avoidance_sensor.c with 61% similarity]
src/resource/resource_touch_sensor.c [moved from src/model/model_touch_sensor.c with 62% similarity]
src/resource/resource_ultrasonic_sensor.c [moved from src/model/model_ultrasonic_sensor.c with 59% similarity]

index 9953f4a..b1952ce 100644 (file)
@@ -33,12 +33,12 @@ INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc)
 ADD_EXECUTABLE(${PROJECT_NAME}
        ${PROJECT_ROOT_DIR}/src/controller.c
        ${PROJECT_ROOT_DIR}/src/connectivity.c
-       ${PROJECT_ROOT_DIR}/src/model.c
-       ${PROJECT_ROOT_DIR}/src/model/model_illuminance_sensor.c
-       ${PROJECT_ROOT_DIR}/src/model/model_infrared_motion_sensor.c
-       ${PROJECT_ROOT_DIR}/src/model/model_infrared_obstacle_avoidance_sensor.c
-       ${PROJECT_ROOT_DIR}/src/model/model_touch_sensor.c
-       ${PROJECT_ROOT_DIR}/src/model/model_ultrasonic_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_illuminance_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_motion_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_obstacle_avoidance_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_touch_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_ultrasonic_sensor.c
 )
 #${PROJECT_ROOT_DIR}/src/connectivity.c
 
similarity index 67%
rename from inc/model.h
rename to inc/resource.h
index 6cf1869..89fc1c8 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __POSITION_FINDER_MODEL_H__
-#define __POSITION_FINDER_MODEL_H__
+#ifndef __POSITION_FINDER_RESOURCE_H__
+#define __POSITION_FINDER_RESOURCE_H__
 
 #include <peripheral_io.h>
 
-#include "model_internal.h"
-#include "model/model_illuminance_sensor.h"
-#include "model/model_infrared_motion_sensor.h"
-#include "model/model_infrared_obstacle_avoidance_sensor.h"
-#include "model/model_touch_sensor.h"
-#include "model/model_ultrasonic_sensor.h"
+#include "resource_internal.h"
+#include "resource/resource_illuminance_sensor.h"
+#include "resource/resource_infrared_motion_sensor.h"
+#include "resource/resource_infrared_obstacle_avoidance_sensor.h"
+#include "resource/resource_touch_sensor.h"
+#include "resource/resource_ultrasonic_sensor.h"
 
-#endif /* __POSITION_FINDER_MODEL_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_H__ */
similarity index 74%
rename from inc/model/model_illuminance_sensor.h
rename to inc/resource/resource_illuminance_sensor.h
index 19eef2d..e95198b 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__
-#define __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
 
 /* You have to use this illuminance sensor ONLY ONE in the pi board */
-extern int model_read_illuminance_sensor(int i2c_bus, int *out_value);
-extern void model_close_illuminance_sensor(void);
+extern int resource_read_illuminance_sensor(int i2c_bus, int *out_value);
+extern void resource_close_illuminance_sensor(void);
 
-#endif /* __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__ */
 
similarity index 71%
rename from inc/model/model_infrared_motion_sensor.h
rename to inc/resource/resource_infrared_motion_sensor.h
index fabd14b..fa99633 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__
-#define __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
 
-extern void model_close_infrared_motion_sensor(int sensor_index);
-extern int model_read_infrared_motion_sensor(int pin_num, int *out_value);
+extern void resource_close_infrared_motion_sensor(int sensor_index);
+extern int resource_read_infrared_motion_sensor(int pin_num, int *out_value);
 
-#endif /* __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__ */
  * limitations under the License.
  */
 
-#ifndef __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
-#define __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
 
-extern void model_close_infrared_obstacle_avoidance_sensor(int pin_num);
-extern int model_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value);
+extern void resource_close_infrared_obstacle_avoidance_sensor(int pin_num);
+extern int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value);
 
-#endif /* __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
similarity index 74%
rename from inc/model/model_touch_sensor.h
rename to inc/resource/resource_touch_sensor.h
index d3f9f53..e209a80 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__
-#define __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
 
-extern void model_close_touch_sensor(int pin_num);
-extern int model_read_touch_sensor(int pin_num, int *out_value);
+extern void resource_close_touch_sensor(int pin_num);
+extern int resource_read_touch_sensor(int pin_num, int *out_value);
 
-#endif /* __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__ */
similarity index 69%
rename from inc/model/model_ultrasonic_sensor.h
rename to inc/resource/resource_ultrasonic_sensor.h
index 401f37c..29fdd00 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__
-#define __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__
+#ifndef __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
 
-extern void model_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num);
-extern int model_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value);
+extern void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num);
+extern int resource_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value);
 
-#endif /* __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__ */
similarity index 78%
rename from inc/model_internal.h
rename to inc/resource_internal.h
index ea73236..1844db6 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __POSITION_FINDER_MODEL_INTERNAL_H__
-#define __POSITION_FINDER_MODEL_INTERNAL_H__
+#ifndef __POSITION_FINDER_RESOURCE_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_INTERNAL_H__
 
 #include <peripheral_io.h>
 
 #define PIN_MAX 40
 
-struct _model_s {
+struct _resource_s {
        int opened;
        peripheral_gpio_h sensor_h;
 };
-typedef struct _model_s model_s;
+typedef struct _resource_s resource_s;
 
-extern model_s *model_get_info(int pin_num);
+extern resource_s *resource_get_info(int pin_num);
 
-#endif /* __POSITION_FINDER_MODEL_INTERNAL_H__ */
+#endif /* __POSITION_FINDER_RESOURCE_INTERNAL_H__ */
old mode 100755 (executable)
new mode 100644 (file)
index 27c3015..69a040e 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "log.h"
 #include "controller.h"
-#include "model.h"
+#include "resource.h"
 
 #define I2C_BUS_1 0x1
 #define GPIO_NOT_USED -1
@@ -45,7 +45,7 @@ static Eina_Bool _infrared_motion_getter_timer(void *data)
 {
        int value = 0;
 
-       retv_if(model_read_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+       retv_if(resource_read_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
        _I("Infrared Motion Value is [%d]", value);
 
        return ECORE_CALLBACK_RENEW;
@@ -55,7 +55,7 @@ static Eina_Bool _ultrasonic_getter_timer(void *data)
 {
        double value = 0;
 
-       retv_if(model_read_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+       retv_if(resource_read_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
        _I("Ultra Sonic Distance is [%d cm]", value);
 
        return ECORE_CALLBACK_RENEW;
@@ -65,7 +65,7 @@ static Eina_Bool _illuminance_getter_timer(void *data)
 {
        int value = 0;
 
-       retv_if(model_read_illuminance_sensor(I2C_BUS_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+       retv_if(resource_read_illuminance_sensor(I2C_BUS_1, &value) == -1, ECORE_CALLBACK_CANCEL);
        _I("Ultra Sonic Distance is [%d lux]", value);
 
        return ECORE_CALLBACK_RENEW;
@@ -108,9 +108,9 @@ static void service_app_terminate(void *data)
                        ecore_timer_del(ad->getter_timer[i]);
                }
        }
-       model_close_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1);
-       model_close_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1);
-       model_close_illuminance_sensor();
+       resource_close_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1);
+       resource_close_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1);
+       resource_close_illuminance_sensor();
        free(ad);
 }
 
diff --git a/src/main.c b/src/main.c
deleted file mode 100644 (file)
index 1da7c7d..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * 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 <tizen.h>
-#include <Ecore.h>
-#include <service_app.h>
-#include <unistd.h>
-#include <glib.h>
-
-#include "log.h"
-#include "model.h"
-
-typedef struct app_data_s {
-       Ecore_Timer *getter_timer;
-       void *event;
-} app_data;
-
-static Eina_Bool _getter_timer(void *data)
-{
-#if 0
-       int value = 0;
-       retv_if(model_read_int_value(&value) == -1, ECORE_CALLBACK_CANCEL);
-       _I("Value is [%d]", value);
-#else
-       double value = 0.0;
-       retv_if(model_read_double_value(&value) == -1, ECORE_CALLBACK_RENEW);
-       _I("Value is [%f]", value);
-#endif
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-static bool service_app_create(void *data)
-{
-       app_data *ad = (app_data *)data;
-
-       retv_if(model_init(SENSOR_TYPE_ULTRASONIC) == -1, false);
-
-       ad->getter_timer = ecore_timer_add(3.0, _getter_timer, NULL);
-       if (!ad->getter_timer) {
-               _D("Failed to add getter timer");
-               return false;
-       }
-
-    return true;
-}
-
-static void service_app_terminate(void *data)
-{
-       app_data *ad = (app_data *)data;
-       ecore_timer_del(ad->getter_timer);
-       model_fini();
-       free(ad);
-}
-
-static void service_app_control(app_control_h app_control, void *data)
-{
-    // Todo: add your code here.
-}
-
-static void service_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LANGUAGE_CHANGED*/
-}
-
-static void service_app_region_changed(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void service_app_low_battery(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void service_app_low_memory(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LOW_MEMORY*/
-}
-
-int main(int argc, char* argv[])
-{
-       app_data *ad = NULL;
-       int ret = 0;
-       service_app_lifecycle_callback_s event_callback;
-       app_event_handler_h handlers[5] = {NULL, };
-
-       ad = (app_data *)calloc(1, sizeof(app_data));
-
-       event_callback.create = service_app_create;
-       event_callback.terminate = service_app_terminate;
-       event_callback.app_control = service_app_control;
-
-       service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
-
-       ret = service_app_main(argc, argv, &event_callback, ad);
-
-       return ret;
-}
similarity index 85%
rename from src/model.c
rename to src/resource.c
index f9298a7..7d49961 100644 (file)
  */
 
 #include <peripheral_io.h>
-#include "model.h"
+#include "resource.h"
 
-static model_s model_info[PIN_MAX] = { 0, };
+static resource_s resource_info[PIN_MAX] = { 0, };
 
-model_s *model_get_info(int pin_num)
+resource_s *resource_get_info(int pin_num)
 {
-       return &model_info[pin_num];
+       return &resource_info[pin_num];
 }
similarity index 72%
rename from src/model/model_illuminance_sensor.c
rename to src/resource/resource_illuminance_sensor.c
index 9a0f381..e5b5dda 100644 (file)
@@ -25,7 +25,7 @@
 #include <sys/time.h>
 
 #include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
 
 #define I2C_PIN_MAX 28
 /* I2C */
 static struct {
        int opened;
        peripheral_i2c_h sensor_h;
-} model_sensor_s;
+} resource_sensor_s;
 
-void model_close_illuminance_sensor(void)
+void resource_close_illuminance_sensor(void)
 {
-       ret_if(!model_sensor_s.opened);
+       ret_if(!resource_sensor_s.opened);
 
        _I("Infrared Motion Sensor is finishing...");
-       peripheral_i2c_close(model_sensor_s.sensor_h);
-       model_sensor_s.opened = 0;
+       peripheral_i2c_close(resource_sensor_s.sensor_h);
+       resource_sensor_s.opened = 0;
 }
 
 /* You have to use this illuminance sensor ONLY ONE in the pi board */
-int model_read_illuminance_sensor(int i2c_bus, int *out_value)
+int resource_read_illuminance_sensor(int i2c_bus, int *out_value)
 {
        int ret = PERIPHERAL_ERROR_NONE;
        unsigned char buf[10] = { 0, };
 
-       if (!model_sensor_s.opened) {
-               ret = peripheral_i2c_open(i2c_bus, GY30_ADDR, &model_sensor_s.sensor_h);
-               retv_if(!model_sensor_s.sensor_h, -1);
-               model_sensor_s.opened = 1;
+       if (!resource_sensor_s.opened) {
+               ret = peripheral_i2c_open(i2c_bus, GY30_ADDR, &resource_sensor_s.sensor_h);
+               retv_if(!resource_sensor_s.sensor_h, -1);
+               resource_sensor_s.opened = 1;
        }
 
-       ret = peripheral_i2c_write_byte(model_sensor_s.sensor_h, GY30_CONT_HIGH_RES_MODE);
+       ret = peripheral_i2c_write_byte(resource_sensor_s.sensor_h, GY30_CONT_HIGH_RES_MODE);
        retv_if(ret < 0, -1);
 
-       ret = peripheral_i2c_read(model_sensor_s.sensor_h, buf, 2);
+       ret = peripheral_i2c_read(resource_sensor_s.sensor_h, buf, 2);
        retv_if(ret < 0, -1);
 
        *out_value = (buf[0] << 8 | buf[1]) / GY30_CONSTANT_NUM; // Just Sum High 8bit and Low 8bit
similarity index 63%
rename from src/model/model_infrared_motion_sensor.c
rename to src/resource/resource_infrared_motion_sensor.c
index f606b8a..d8e86e3 100644 (file)
 #include <sys/time.h>
 
 #include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
 
-void model_close_infrared_motion_sensor(int pin_num)
+void resource_close_infrared_motion_sensor(int pin_num)
 {
-       ret_if(!model_get_info(pin_num)->opened);
+       ret_if(!resource_get_info(pin_num)->opened);
 
        _I("Infrared Motion Sensor is finishing...");
-       model_get_info(pin_num)->opened = 0;
+       resource_get_info(pin_num)->opened = 0;
 }
 
-int model_read_infrared_motion_sensor(int pin_num, int *out_value)
+int resource_read_infrared_motion_sensor(int pin_num, int *out_value)
 {
        int ret = PERIPHERAL_ERROR_NONE;
 
-       if (!model_get_info(pin_num)->opened) {
-               ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
-               retv_if(!model_get_info(pin_num)->sensor_h, -1);
+       if (!resource_get_info(pin_num)->opened) {
+               ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+               retv_if(!resource_get_info(pin_num)->sensor_h, -1);
 
-               ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
                retv_if(ret != 0, -1);
 
-               model_get_info(pin_num)->opened = 1;
+               resource_get_info(pin_num)->opened = 1;
        }
 
-       ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, out_value);
+       ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
        retv_if(ret < 0, -1);
 
        _I("Infrared Motion Sensor Value : %d", *out_value);
 #include <sys/time.h>
 
 #include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
 
-void model_close_infrared_obstacle_avoidance_sensor(int pin_num)
+void resource_close_infrared_obstacle_avoidance_sensor(int pin_num)
 {
-       ret_if(!model_get_info(pin_num)->opened);
+       ret_if(!resource_get_info(pin_num)->opened);
 
        _I("Infrared Obstacle Avoidance Sensor is finishing...");
-       peripheral_gpio_close(model_get_info(pin_num)->sensor_h);
-       model_get_info(pin_num)->opened = 0;
+       peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+       resource_get_info(pin_num)->opened = 0;
 }
 
-int model_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value)
+int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value)
 {
        int ret = PERIPHERAL_ERROR_NONE;
 
-       if (!model_get_info(pin_num)->opened) {
-               ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
-               retv_if(!model_get_info(pin_num)->sensor_h, -1);
+       if (!resource_get_info(pin_num)->opened) {
+               ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+               retv_if(!resource_get_info(pin_num)->sensor_h, -1);
 
-               ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
                retv_if(ret != 0, -1);
 
-               model_get_info(pin_num)->opened = 1;
+               resource_get_info(pin_num)->opened = 1;
        }
 
-       ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, out_value);
+       ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
        retv_if(ret < 0, -1);
 
        _I("Infrared Obstacle Avoidance Sensor Value : %d", *out_value);
similarity index 62%
rename from src/model/model_touch_sensor.c
rename to src/resource/resource_touch_sensor.c
index ba472c5..a8ba4ba 100644 (file)
 #include <sys/time.h>
 
 #include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
 
-void model_close_touch_sensor(int pin_num)
+void resource_close_touch_sensor(int pin_num)
 {
-       ret_if(!model_get_info(pin_num)->opened);
+       ret_if(!resource_get_info(pin_num)->opened);
 
        _I("Touch Sensor is finishing...");
-       peripheral_gpio_close(model_get_info(pin_num)->sensor_h);
-       model_get_info(pin_num)->opened = 0;
+       peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+       resource_get_info(pin_num)->opened = 0;
 }
 
-int model_read_touch_sensor(int pin_num, int *out_value)
+int resource_read_touch_sensor(int pin_num, int *out_value)
 {
        int ret = PERIPHERAL_ERROR_NONE;
 
-       if (!model_get_info(pin_num)->opened) {
+       if (!resource_get_info(pin_num)->opened) {
                _I("Touch sensor is initializing...");
 
-               ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
-               retv_if(!model_get_info(pin_num)->sensor_h, -1);
+               ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+               retv_if(!resource_get_info(pin_num)->sensor_h, -1);
 
-               ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
                retv_if(ret != 0, -1);
 
-               model_get_info(pin_num)->opened = 1;
+               resource_get_info(pin_num)->opened = 1;
        }
 
-       ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, out_value);
+       ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
        retv_if(ret < 0, -1);
 
        _I("Touch Sensor Value : %d", *out_value);
similarity index 59%
rename from src/model/model_ultrasonic_sensor.c
rename to src/resource/resource_ultrasonic_sensor.c
index 0d2ae75..c397920 100644 (file)
 #include <sys/time.h>
 
 #include "log.h"
-#include "model_internal.h"
+#include "resource_internal.h"
 
-void model_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num)
+void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num)
 {
-       ret_if(!model_get_info(echo_pin_num)->opened);
-       ret_if(!model_get_info(trig_pin_num)->opened);
+       ret_if(!resource_get_info(echo_pin_num)->opened);
+       ret_if(!resource_get_info(trig_pin_num)->opened);
 
        _I("Ultrasonic sensor is finishing...");
 
-       peripheral_gpio_close(model_get_info(echo_pin_num)->sensor_h);
-       peripheral_gpio_close(model_get_info(trig_pin_num)->sensor_h);
+       peripheral_gpio_close(resource_get_info(echo_pin_num)->sensor_h);
+       peripheral_gpio_close(resource_get_info(trig_pin_num)->sensor_h);
 
-       model_get_info(echo_pin_num)->opened = 0;
-       model_get_info(trig_pin_num)->opened = 0;
+       resource_get_info(echo_pin_num)->opened = 0;
+       resource_get_info(trig_pin_num)->opened = 0;
 }
 
 static int _get_echo_value(int echo_pin_num)
@@ -46,53 +46,53 @@ static int _get_echo_value(int echo_pin_num)
        int ret = 0;
        int value = 0;
 
-       ret = peripheral_gpio_read(model_get_info(echo_pin_num)->sensor_h, &value);
+       ret = peripheral_gpio_read(resource_get_info(echo_pin_num)->sensor_h, &value);
        retv_if(ret < 0, -1);
 
        return value;
 }
 
-int model_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value)
+int resource_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value)
 {
        int ret = 0;
        double duration = 0.0;
        struct timeval start_time, end_time, temp_start_time, temp_end_time;
 
-       if (!model_get_info(echo_pin_num)->opened) {
+       if (!resource_get_info(echo_pin_num)->opened) {
                _I("Ultrasonic sensor is initializing...");
 
-               ret = peripheral_gpio_open(echo_pin_num, &model_get_info(echo_pin_num)->sensor_h);
-               retv_if(!model_get_info(echo_pin_num)->sensor_h, -1);
+               ret = peripheral_gpio_open(echo_pin_num, &resource_get_info(echo_pin_num)->sensor_h);
+               retv_if(!resource_get_info(echo_pin_num)->sensor_h, -1);
 
-               ret = peripheral_gpio_set_direction(model_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               ret = peripheral_gpio_set_direction(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
                retv_if(ret != 0, -1);
 
-               model_get_info(echo_pin_num)->opened = 1;
+               resource_get_info(echo_pin_num)->opened = 1;
        }
 
-       if (!model_get_info(trig_pin_num)->opened) {
+       if (!resource_get_info(trig_pin_num)->opened) {
                _I("Ultrasonic sensor is initializing...");
 
-               ret = peripheral_gpio_open(trig_pin_num, &model_get_info(trig_pin_num)->sensor_h);
-               retv_if(!model_get_info(trig_pin_num)->sensor_h, -1);
+               ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h);
+               retv_if(!resource_get_info(trig_pin_num)->sensor_h, -1);
 
-               ret = peripheral_gpio_set_direction(model_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
                retv_if(ret != 0, -1);
 
-               model_get_info(trig_pin_num)->opened = 1;
+               resource_get_info(trig_pin_num)->opened = 1;
        }
 
-       ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 0);
+       ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
        retv_if(ret < 0, -1);
 
        sleep(1);
 
-       ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 1);
+       ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 1);
        retv_if(ret < 0, -1);
 
        usleep(10);
 
-       ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 0);
+       ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
        retv_if(ret < 0, -1);
 
        _D("Count the distance");