2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief sample navigation application main
21 #include <dbus/dbus.h>
22 #include <libwebsockets.h>
26 #include <Ecore_Evas.h>
27 #include <Elementary.h>
28 #include "samplenavi.h"
31 #include "ico_apf_ecore.h"
32 #include "ico_apf_log.h"
39 //#define TEST_TIME 0.001
40 //#define TEST_TIME 0.066
43 //#define DEBUG_METER_TEXT_DSP
45 //#define DEBUG_VIC_INFO_SET
46 #ifdef DEBUG_VIC_INFO_SET
48 extern int route_data_count;
49 extern CsvRoute csv_route[MAX_ROUTE_POINTS];
50 static double test_lat = 35.47945;
51 static double test_lon = 139.40026;
52 static int test_dir = 0;
53 static int test_cnt = 0;
57 /*============================================================================*/
58 /* Define fixed parameters */
59 /*============================================================================*/
61 #define CONFIG_FILE "/opt/apps/org.tizen.ico.app-samplenavi/res/config.txt"
62 #define DBUS_SERVICE "org.automotive.message.broker"
63 #define DBUS_INTERFACE "org.freedesktop.DBus.Properties"
64 #define DBUS_METHOD "Get"
65 #define MAX_PARA_NUM 4 /* Lat,Lon,Dir,VicSpeed */
69 #define VEHICLESPEED 3
72 #define ICO_APP_BUF_SIZE (1024)
74 /*============================================================================*/
75 /* Define data types */
76 /*============================================================================*/
82 dbus_uint32_t u32_val;
83 dbus_uint16_t u16_val;
95 char interface_name[64];
96 char property_name[32];
105 /*============================================================================*/
106 /* Function prototype for static(internal) functions */
107 /*============================================================================*/
108 static double get_time();
109 static void set_default_data();
110 static void load_config_file();
111 static void e_ui_draw();
112 static void e_ui_init();
113 static void e_map_init();
114 static void e_map_draw();
116 static void convert_data_evas_cv(Evas_Object *eo, IplImage *iplimage);
117 static void evas_object_image_from_cv(Evas_Object *eo, const char *filepath);
119 static Eina_Bool _time_interval_navi_cb(void *cam);
120 static Eina_Bool _time_interval_map_renew_cb(void *data);
121 static Eina_Bool callback_listener(void *data);
122 static int callback_http(struct libwebsocket_context *context,
123 struct libwebsocket *wsi,
124 enum libwebsocket_callback_reasons reason,
125 void *user, void *in, size_t len);
126 static bool parse_elementary_value(union VicVal_t *vic_val_p,
127 DBusMessageIter *iter);
128 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter);
129 static int getAmbDbus(int key, union VicVal_t *vic_val_p);
130 static void getLocationFromAmb();
131 static int get_config();
132 static char *edje_parse_str(void *in, int arg_num);
133 static void event_message(struct libwebsocket *wsi, char *format, ...);
134 static void _touch_up_edje(void *data, Evas *evas, Evas_Object *obj,
136 static int loading_edje_file(const char *edje_file);
137 static void res_callback(ico_apf_resource_notify_info_t *info,
140 /*============================================================================*/
141 /* Tables and Valiables */
142 /*============================================================================*/
143 int conf_data[CONF_DATA_MAX];
144 static const char *config_path = RESOURCE_DIR "/samplenavi.conf";
145 static const char *setting_button_path = IMAGES_DIR "/na_bt3_off.png";
146 static const char *goal_text_img_path = IMAGES_DIR "/na_goal_text.png";
147 static const char *default_url =
148 "file:///opt/apps/org.tizen.ico.app-samplenavi/res/Map/map.html";
151 static char sscrntype[32];
155 static Evas_Object *g_edje; /* loaded edje objects */
156 static char edje_str[ICO_APP_BUF_SIZE];
159 static int ui_vicspeed = 0;
160 static Evas_Object *ui_vicspeed_text;
161 static Evas_Object *ui_meter_l;
162 static Evas_Object *ui_meter_c[10];
163 static Evas_Object *ui_meter_r[10];
164 static int fig_l = 0;
165 static int fig_c = 0;
166 static int fig_r = 0;
168 const static char *meter_l_path = {
169 IMAGES_DIR "/Meter/Meters_SpeedNum_1l.png"
172 const static char *meter_c_path[10] = {
173 IMAGES_DIR "/Meter/Meters_SpeedNum_0c.png",
174 IMAGES_DIR "/Meter/Meters_SpeedNum_1c.png",
175 IMAGES_DIR "/Meter/Meters_SpeedNum_2c.png",
176 IMAGES_DIR "/Meter/Meters_SpeedNum_3c.png",
177 IMAGES_DIR "/Meter/Meters_SpeedNum_4c.png",
178 IMAGES_DIR "/Meter/Meters_SpeedNum_5c.png",
179 IMAGES_DIR "/Meter/Meters_SpeedNum_6c.png",
180 IMAGES_DIR "/Meter/Meters_SpeedNum_7c.png",
181 IMAGES_DIR "/Meter/Meters_SpeedNum_8c.png",
182 IMAGES_DIR "/Meter/Meters_SpeedNum_9c.png"
185 const static char *meter_r_path[10] = {
186 IMAGES_DIR "/Meter/Meters_SpeedNum_0r.png",
187 IMAGES_DIR "/Meter/Meters_SpeedNum_1r.png",
188 IMAGES_DIR "/Meter/Meters_SpeedNum_2r.png",
189 IMAGES_DIR "/Meter/Meters_SpeedNum_3r.png",
190 IMAGES_DIR "/Meter/Meters_SpeedNum_4r.png",
191 IMAGES_DIR "/Meter/Meters_SpeedNum_5r.png",
192 IMAGES_DIR "/Meter/Meters_SpeedNum_6r.png",
193 IMAGES_DIR "/Meter/Meters_SpeedNum_7r.png",
194 IMAGES_DIR "/Meter/Meters_SpeedNum_8r.png",
195 IMAGES_DIR "/Meter/Meters_SpeedNum_9r.png"
199 static DBusConnection *g_connection = NULL; /* D-Bus Connection */
200 static int property_num = 0;
201 const static char Bus_name[] = DBUS_SERVICE;
202 static struct vic_data_t vic_data[MAX_PARA_NUM];
204 const struct vic_key_data_t vic_key_data[] = {
205 {LATITUDE , "Latitude" },
206 {LONGITUDE , "Longitude" },
207 {DIRECTION , "Direction" },
208 {VEHICLESPEED, "VehicleSpeed"},
213 static Ecore_Evas *window;
220 IplImage *captureImage;
221 static CvCapture *capture;
228 Evas_Object *ui_goal_text;
229 Evas_Object *ui_address;
233 Evas_Object *ui_fps_bg;
234 Evas_Object *ui_polygon_count;
235 Evas_Object *ui_polygon_count_bg;
239 Evas_Object *browser;
242 static const char *test_camera_path = IMAGES_DIR "/test_cameraview.png";
245 static int connected = 0;
246 static struct libwebsocket *socket_val = NULL;
247 static struct libwebsocket_context *context;
248 static struct libwebsocket_protocols protocols[] = {
250 "http-only", /* name */
251 callback_http, /* callback */
252 0 /* per_session_data_size */
258 static int port = 50414;
259 static char addr[16] = "127.0.0.1";
260 static char proxy_uri[512] = "";
262 /*============================================================================*/
264 /*============================================================================*/
265 /*--------------------------------------------------------------------------*/
268 * Time acquisition(second).
271 * @return time(second)
273 /*--------------------------------------------------------------------------*/
274 static double get_time()
276 struct timeval sec_timeofday;
277 gettimeofday(&sec_timeofday, NULL);
278 return ((sec_timeofday.tv_sec) + (sec_timeofday.tv_usec / 1000000.0));
281 /*--------------------------------------------------------------------------*/
283 * @brief set_default_data
284 * Set Default data without define in conf file.
289 /*--------------------------------------------------------------------------*/
290 static void set_default_data()
294 for (i = 0; i < CONF_DATA_MAX; i++) {
295 if (conf_data[i] == 0) {
298 conf_data[USB_CAMERA_ID] = DEF_USB_CAMERA_ID;
300 case LANDMARK_POSITION:
301 conf_data[LANDMARK_POSITION] = DEF_LANDMARK_POSITION;
303 case LANDMARK_ROTATION:
304 conf_data[LANDMARK_ROTATION] = DEF_LANDMARK_ROTATION;
311 /*--------------------------------------------------------------------------*/
313 * @brief load_config_file
314 * A config file is loaded.
319 /*--------------------------------------------------------------------------*/
320 static void load_config_file()
327 for (i = 0; i < CONF_DATA_MAX; i++) {
331 if ((fp = fopen(config_path, "r")) == NULL) {
332 fprintf(stderr, "%s\n",
333 "Error : can't open file.(samplenavi.conf)\n");
336 uim_debug("USB_CAMERA_ID = %d", conf_data[USB_CAMERA_ID]);
337 uim_debug("LANDMARK_POSITION = %d", conf_data[LANDMARK_POSITION]);
338 uim_debug("LANDMARK_ROTATION = %d", conf_data[LANDMARK_ROTATION]);
342 while (fscanf(fp, "%s", str) != EOF) {
343 if (strncmp(str, "USBCAMERAID", 11) == 0) {
344 valuestr = strtok((char *) (str) + 12, "=");
345 if (valuestr != NULL) {
346 conf_data[USB_CAMERA_ID] = atoi(valuestr);
349 else if (strncmp(str, "LANDMARKPOSITION", 16) == 0) {
350 valuestr = strtok((char *) (str) + 17, "=");
351 if (valuestr != NULL) {
352 conf_data[LANDMARK_POSITION] = atoi(valuestr);
355 else if (strncmp(str, "LANDMARKROTATION", 16) == 0) {
356 valuestr = strtok((char *) (str) + 17, "=");
357 if (valuestr != NULL) {
358 conf_data[LANDMARK_ROTATION] = atoi(valuestr);
361 else if (strncmp(str, "WEBSOCKETPORT", 13) == 0) {
362 valuestr = strtok((char *) (str) + 14, "=");
363 if (valuestr != NULL) {
364 port = atoi(valuestr);
367 else if (strncmp(str, "IPADDR", 6) == 0) {
368 valuestr = strtok((char *) (str) + 7, "=");
369 if (valuestr != NULL) {
370 strcpy(addr, valuestr);
373 else if (strncmp(str, "PROXYURI", 8) == 0) {
374 valuestr = strtok((char *) (str) + 9, "=");
375 if (valuestr != NULL) {
376 strcpy(proxy_uri, valuestr);
385 uim_debug("USB_CAMERA_ID = %d", conf_data[USB_CAMERA_ID]);
386 uim_debug("LANDMARK_POSITION = %d", conf_data[LANDMARK_POSITION]);
387 uim_debug("LANDMARK_ROTATION = %d", conf_data[LANDMARK_ROTATION]);
388 uim_debug("WEBSOKET_PORT = %d", port);
389 uim_debug("IP_ADDR = %s", addr);
390 uim_debug("PROXY_URI = %s", proxy_uri);
395 /*--------------------------------------------------------------------------*/
403 /*--------------------------------------------------------------------------*/
404 static void e_ui_draw()
415 evas_object_show(ui_bg);
416 evas_object_show(ui_btn);
419 #ifdef DEBUG_METER_TEXT_DSP
420 sprintf(str, "[kph] %d", ui_vicspeed);
421 evas_object_text_text_set(ui_vicspeed_text, str);
422 evas_object_show(ui_vicspeed_text);
424 evas_object_show(ui_vicspeed_text);
427 uim_debug("MAX SPEED OVER [%d]", value);
431 w_fig_r = (value % 10);
433 w_fig_c = (value % 10);
435 w_fig_l = (value % 10);
438 if (w_fig_r != fig_r) {
439 evas_object_hide(ui_meter_r[fig_r]);
440 evas_object_show(ui_meter_r[w_fig_r]);
444 if (w_fig_c != fig_c || fig_c == 0) {
445 evas_object_hide(ui_meter_c[fig_c]);
447 if (w_fig_c != 0 || w_fig_l == 1) {
448 evas_object_show(ui_meter_c[w_fig_c]);
454 if (w_fig_l != fig_l) {
455 evas_object_hide(ui_meter_l);
458 evas_object_show(ui_meter_l);
465 if (enable_navi == TRUE && set_route == TRUE) {
466 if (goal_square_length <= (GOAL_MESSAGE_LENGTH * GOAL_MESSAGE_LENGTH)) {
467 evas_object_show(ui_goal_text);
470 evas_object_hide(ui_goal_text);
475 sprintf(str, "FPS : %.2f", fps);
476 evas_object_text_text_set(ui_fps, str);
477 sprintf(str, "Polygon : %d", polygon_count);
478 evas_object_text_text_set(ui_polygon_count, str);
482 /*--------------------------------------------------------------------------*/
485 * Initialize UI Layer.
490 /*--------------------------------------------------------------------------*/
491 static void e_ui_init()
498 ui_bg = evas_object_rectangle_add(e_ui);
499 evas_object_color_set(ui_bg, 0, 34, 119, 255);
500 evas_object_move(ui_bg, W_TEXTAREA_X, W_TEXTAREA_Y);
501 evas_object_resize(ui_bg, W_TEXTAREA_WIDTH, W_TEXTAREA_HEIGHT);
502 evas_object_show(ui_bg);
503 evas_object_layer_set(ui_bg, LAYER_UI);
505 ui_btn = evas_object_image_add(e_ui);
506 evas_object_image_file_set(ui_btn, setting_button_path, NULL);
507 evas_object_image_fill_set(ui_btn, 0, 0, W_NAVIBUTTON_WIDTH,
508 W_NAVIBUTTON_HEIGHT);
509 evas_object_move(ui_btn, W_NAVIBUTTON_X, W_NAVIBUTTON_Y);
510 evas_object_resize(ui_btn, W_NAVIBUTTON_WIDTH, W_NAVIBUTTON_HEIGHT);
511 evas_object_show(ui_btn);
512 evas_object_layer_set(ui_btn, LAYER_UI);
514 ui_goal_text = evas_object_image_add(e_ui);
515 evas_object_image_file_set(ui_goal_text, goal_text_img_path, NULL);
516 evas_object_image_fill_set(ui_goal_text, 0, 0, W_GOALMESSAGE_WIDTH,
517 W_GOALMESSAGE_HEIGHT);
518 evas_object_move(ui_goal_text, W_GOALMESSAGE_X, W_GOALMESSAGE_Y);
519 evas_object_resize(ui_goal_text, W_GOALMESSAGE_WIDTH,
520 W_GOALMESSAGE_HEIGHT);
521 evas_object_hide(ui_goal_text);
522 evas_object_layer_set(ui_goal_text, LAYER_UI);
525 #ifdef DEBUG_METER_TEXT_DSP
526 ui_vicspeed_text = evas_object_text_add(e_ui);
527 evas_object_text_style_set(ui_vicspeed_text, EVAS_TEXT_STYLE_PLAIN);
528 evas_object_color_set(ui_vicspeed_text, 255, 255, 255, 255);
529 evas_object_text_font_set(ui_vicspeed_text, "Utopia", 28);
530 sprintf(str, "[kph] %d", ui_vicspeed);
531 evas_object_text_text_set(ui_vicspeed_text, str);
532 evas_object_move(ui_vicspeed_text, 0, 430);
533 evas_object_resize(ui_vicspeed_text, W_METER_UNIT_WIDTH,
534 W_METER_UNIT_HEIGHT);
535 evas_object_show(ui_vicspeed_text);
536 evas_object_layer_set(ui_vicspeed_text, LAYER_UI);
538 ui_meter_l = evas_object_image_add(e_ui);
539 evas_object_image_file_set(ui_meter_l, meter_l_path, NULL);
540 evas_object_image_fill_set(ui_meter_l, 0, 0, W_METER_HEIGHT,
542 evas_object_move(ui_meter_l, W_METER_X, W_METER_Y);
543 evas_object_resize(ui_meter_l, W_METER_HEIGHT, W_METER_WIDTH);
544 evas_object_hide(ui_meter_l);
545 evas_object_layer_set(ui_meter_l, LAYER_UI);
547 for (i = 0; i < 10; i++) {
548 ui_meter_c[i] = evas_object_image_add(e_ui);
549 evas_object_image_file_set(ui_meter_c[i], meter_c_path[i], NULL);
550 evas_object_image_fill_set(ui_meter_c[i], 0, 0, W_METER_HEIGHT,
552 evas_object_move(ui_meter_c[i], W_METER_X, W_METER_Y);
553 evas_object_resize(ui_meter_c[i], W_METER_HEIGHT, W_METER_WIDTH);
554 evas_object_hide(ui_meter_c[i]);
555 evas_object_layer_set(ui_meter_c[i], LAYER_UI);
557 ui_meter_r[i] = evas_object_image_add(e_ui);
558 evas_object_image_file_set(ui_meter_r[i], meter_r_path[i], NULL);
559 evas_object_image_fill_set(ui_meter_r[i], 0, 0, W_METER_HEIGHT,
561 evas_object_move(ui_meter_r[i], W_METER_X, W_METER_Y);
562 evas_object_resize(ui_meter_r[i], W_METER_HEIGHT, W_METER_WIDTH);
563 evas_object_hide(ui_meter_r[i]);
564 evas_object_layer_set(ui_meter_r[i], LAYER_UI);
566 evas_object_show(ui_meter_r[0]);
568 ui_vicspeed_text = evas_object_text_add(e_ui);
569 evas_object_text_style_set(ui_vicspeed_text, EVAS_TEXT_STYLE_PLAIN);
570 evas_object_color_set(ui_vicspeed_text, 255, 255, 255, 255);
571 evas_object_text_font_set(ui_vicspeed_text, "Utopia", 24);
572 evas_object_text_text_set(ui_vicspeed_text, "kph");
573 evas_object_move(ui_vicspeed_text, W_METER_UNIT_X, W_METER_UNIT_Y);
574 evas_object_resize(ui_vicspeed_text, W_METER_UNIT_WIDTH,
575 W_METER_UNIT_HEIGHT);
576 evas_object_show(ui_vicspeed_text);
578 evas_object_layer_set(ui_vicspeed_text, LAYER_UI);
582 sprintf(str, "FPS : %.2f", fps);
584 ui_fps_bg = evas_object_rectangle_add(e_ui);
585 evas_object_color_set(ui_fps_bg, 255, 255, 255, 255);
586 evas_object_move(ui_fps_bg, 0, 0);
587 evas_object_resize(ui_fps_bg, 150, 20);
588 evas_object_show(ui_fps_bg);
589 evas_object_layer_set(ui_fps_bg, LAYER_UI);
591 ui_fps = evas_object_text_add(e_ui);
592 evas_object_text_style_set(ui_fps, EVAS_TEXT_STYLE_PLAIN);
593 evas_object_color_set(ui_fps, 0, 0, 0, 255);
594 evas_object_text_font_set(ui_fps, "Utopia", 14);
595 evas_object_text_text_set(ui_fps, str);
596 evas_object_move(ui_fps, 0, 0);
597 evas_object_resize(ui_fps, 250, 250);
598 evas_object_show(ui_fps);
599 evas_object_layer_set(ui_fps, LAYER_UI);
601 sprintf(str, "Polygon : %d", polygon_count);
603 ui_polygon_count_bg = evas_object_rectangle_add(e_ui);
604 evas_object_color_set(ui_polygon_count_bg, 255, 255, 255, 255);
605 evas_object_move(ui_polygon_count_bg, 0, 20);
606 evas_object_resize(ui_polygon_count_bg, 150, 20);
607 evas_object_show(ui_polygon_count_bg);
608 evas_object_layer_set(ui_polygon_count_bg, LAYER_UI);
610 ui_polygon_count = evas_object_text_add(e_ui);
611 evas_object_text_style_set(ui_polygon_count, EVAS_TEXT_STYLE_PLAIN);
612 evas_object_color_set(ui_polygon_count, 0, 0, 0, 255);
613 evas_object_text_font_set(ui_polygon_count, "Utopia", 14);
614 evas_object_text_text_set(ui_polygon_count, str);
615 evas_object_move(ui_polygon_count, 0, 20);
616 evas_object_resize(ui_polygon_count, 250, 250);
617 evas_object_show(ui_polygon_count);
618 evas_object_layer_set(ui_polygon_count, LAYER_UI);
622 /*--------------------------------------------------------------------------*/
625 * Initialize MAP Layer.
630 /*--------------------------------------------------------------------------*/
631 static void e_map_init()
633 e_map = ecore_evas_get(window);
634 browser = ewk_view_add(e_map);
635 ewk_context_proxy_uri_set(ewk_view_context_get(browser), proxy_uri);
636 evas_object_move(browser, W_MAP_ORIGINE_X, W_MAP_ORIGINE_Y);
637 evas_object_resize(browser, W_MAP_WIDTH, W_MAP_HEIGHT);
638 evas_object_show(browser);
639 ewk_view_uri_set(browser, default_url);
640 evas_object_layer_set(browser, LAYER_MAP);
643 /*--------------------------------------------------------------------------*/
646 * Draw Map Layer(EWebKit2)
651 /*--------------------------------------------------------------------------*/
652 static void e_map_draw()
654 evas_object_show(browser);
658 /*--------------------------------------------------------------------------*/
660 * @brief convert_data_evas_cv
661 * Convert IplImage object to Evas_Object.
663 * @param[out] eo Evas_Object
664 * @param[in] iplimagenone IplImage object
667 /*--------------------------------------------------------------------------*/
668 static void convert_data_evas_cv(Evas_Object *eo, IplImage *iplimage)
670 int image_data_size = (iplimage->width) * iplimage->height * 4;
671 unsigned char image[image_data_size];
674 if (image_data_size == 0) {
675 uim_debug("convert_data_evas_cv: IplImage empty error.");
679 for (i = 0; i < (iplimage->width * iplimage->height); i++) {
680 image[i * 4] = iplimage->imageData[(3 * i)];
681 image[(i * 4) + 1] = iplimage->imageData[(3 * i) + 1];
682 image[(i * 4) + 2] = iplimage->imageData[(3 * i) + 2];
683 image[(i * 4) + 3] = 255;
686 /* convert to Evas_Object */
687 evas_object_image_colorspace_set(eo, EVAS_COLORSPACE_ARGB8888);
688 evas_object_image_size_set(eo, iplimage->width, iplimage->height);
689 evas_object_image_data_set(eo, image);
692 /*--------------------------------------------------------------------------*/
694 * @brief evas_object_image_from_cv
695 * Load the picture to an IplImage object.
697 * @param[out] eo Evas_Object
698 * @param[in] filepath path of the file
701 /*--------------------------------------------------------------------------*/
702 static void evas_object_image_from_cv(Evas_Object *eo, const char *filepath)
707 iplimage = cvLoadImage(filepath, CV_LOAD_IMAGE_COLOR);
709 uim_debug("cvLoadImageError.");
712 convert_data_evas_cv(eo, iplimage);
716 /*--------------------------------------------------------------------------*/
718 * @brief _time_interval_navi_cb
719 * main timer for navigation.
721 * @param[out] cam Evas_Object
723 * @retval ECORE_CALLBACK_RENEW Return value to keep a callback
724 * @retval ECORE_CALLBACK_CANCEL Return value to remove a callback
726 /*--------------------------------------------------------------------------*/
727 static Eina_Bool _time_interval_navi_cb(void *cam)
729 static double webcam_timer = 0;
733 static double total_frame_time = 0;
734 static int frame_count = 0;
740 webcam_timer += TIME_INTERVAL_AR;
742 if (webcam_timer >= TIME_INTERVAL_CAMERA) {
745 /* Capture from Camera */
746 cam = evas_object_image_add(e_cam);
748 captureImage = cvQueryFrame(capture);
749 convert_data_evas_cv(cam, captureImage);
751 evas_object_image_fill_set(cam, 0, 0, W_WIDTH, W_NAVI_HEIGHT);
752 evas_object_move(cam, W_NAVI_ORIGINE_X, W_NAVI_ORIGINE_Y);
753 evas_object_resize(cam, W_WIDTH, W_NAVI_HEIGHT);
754 evas_object_show(cam);
757 evas_object_image_fill_set(cam, 0, 0, W_NAVI_WIDTH, W_NAVI_HEIGHT);
758 evas_object_move(cam, W_NAVI_ORIGINE_X, W_NAVI_ORIGINE_Y);
759 evas_object_resize(cam, W_NAVI_WIDTH, W_NAVI_HEIGHT);
760 evas_object_show(cam);
763 getLocationFromAmb();
774 /* render Map View */
779 if (frame_count == 0) {
783 else if (frame_count < 5) {
785 total_frame_time += t1 - t0;
791 total_frame_time -= total_frame_time / 4;
792 total_frame_time += t1 - t0;
795 fps = 4.0 * 1.0 / total_frame_time;
800 return ECORE_CALLBACK_RENEW;
803 /*--------------------------------------------------------------------------*/
805 * @brief _time_interval_map_renew_cb
806 * timer for renewal of a map.
808 * @param[out] data user data(UNUSED)
810 * @retval ECORE_CALLBACK_RENEW Return value to keep a callback
811 * @retval ECORE_CALLBACK_CANCEL Return value to remove a callback
813 /*--------------------------------------------------------------------------*/
814 static Eina_Bool _time_interval_map_renew_cb(void *data)
817 #ifdef DEBUG_VIC_INFO_SET
822 if (test_cnt < route_data_count) {
823 test_lat = csv_route[test_cnt].lat;
824 test_lon = csv_route[test_cnt].lon;
826 if ((test_cnt + 1) != route_data_count) {
827 lat_tmp = csv_route[test_cnt + 1].lat - test_lat;
828 lon_tmp = csv_route[test_cnt + 1].lon - test_lon;
830 if (lat_tmp >= 0 && lon_tmp >= 0) {
833 atan((fabs(lon_tmp) / fabs(lat_tmp))) * 180.0 / (atan(1.0) *
836 else if (lat_tmp < 0 && lon_tmp >= 0) {
839 atan((fabs(lat_tmp) / fabs(lon_tmp))) * 180.0 / (atan(1.0) *
842 else if (lat_tmp < 0 && lon_tmp < 0) {
845 atan((fabs(lon_tmp) / fabs(lat_tmp))) * 180.0 / (atan(1.0) *
848 else if (lat_tmp >= 0 && lon_tmp < 0) {
851 atan((fabs(lat_tmp) / fabs(lon_tmp))) * 180.0 / (atan(1.0) *
854 test_dir = test_dir + add_angle;
856 camera_geocode.lat = test_lat;
857 camera_geocode.lon = test_lon;
858 camera_geocode.dir = test_dir;
861 uim_debug("test_lat = [%f]", test_lat);
862 uim_debug("test_lon = [%f]", test_lon);
863 uim_debug("test_dir = [%d]", test_dir);
869 && ((map_pos.lat != camera_geocode.lat)
870 || (map_pos.lon != camera_geocode.lon))) {
871 map_pos.lat = camera_geocode.lat;
872 map_pos.lon = camera_geocode.lon;
874 uim_debug("map_pos.lat = [%f]", map_pos.lat);
875 uim_debug("map_pos.lon = [%f]", map_pos.lon);
877 event_message(socket_val, "CHG VAL VIC_INFO LAT %f LON %f",
878 map_pos.lat, map_pos.lon);
879 uim_debug("SEND LAT LON TO SINARIO(samplenavi)");
882 return ECORE_CALLBACK_RENEW;
885 /*--------------------------------------------------------------------------*/
887 * @brief callback_listener
888 * timer for libwebsocket connection surveillance.
890 * @param[out] data libwebsocket context
892 * @retval ECORE_CALLBACK_RENEW Return value to keep a callback
893 * @retval ECORE_CALLBACK_CANCEL Return value to remove a callback
895 /*--------------------------------------------------------------------------*/
896 static Eina_Bool callback_listener(void *data)
899 libwebsocket_service((struct libwebsocket_context *) data, 0);
902 uim_debug("WEBSOCKET CONNECTED ERROR");
903 if (context != NULL) {
904 libwebsocket_context_destroy(context);
907 context = libwebsocket_create_context(port, NULL,
909 libwebsocket_internal_extensions,
910 NULL, NULL, -1, -1, 0);
912 if (context == NULL) {
913 uim_debug("libwebsocket_create_context failed. (line:%d)",
922 return ECORE_CALLBACK_RENEW;
925 /*--------------------------------------------------------------------------*/
927 * @brief callback_http
928 * this callback function is notified from libwebsockets
930 * @param[in] context libwebsocket context
931 * @param[in] wsi libwebsockets management table
932 * @param[in] reason event type
933 * @param[in] user intact
934 * @param[in] in receive message
935 * @param[in] len message size[BYTE]
940 /*--------------------------------------------------------------------------*/
942 callback_http(struct libwebsocket_context *context, struct libwebsocket *wsi,
943 enum libwebsocket_callback_reasons reason, void *user, void *in,
947 unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 +
948 LWS_SEND_BUFFER_POST_PADDING];
949 unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
952 uim_debug("call callback_http! size = %d", len);
953 uim_debug("callback_http REASON %d", reason);
956 case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
957 uim_debug("CONNECTION %x", wsi);
959 case LWS_CALLBACK_ESTABLISHED:
960 uim_debug("ESTABLISHED %x", wsi);
962 n = sprintf((char *) p, "%s", "ANS HELLO");
964 case LWS_CALLBACK_ADD_POLL_FD:
965 uim_debug("RECIEVE REASON LWS_CALLBACK_ADD_POLL_FD");
967 case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED:
969 ("RECIEVE REASON LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED");
971 case LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER:
973 ("RECIEVE REASON LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER");
975 case LWS_CALLBACK_CLIENT_ESTABLISHED:
976 uim_debug("RECIEVE REASON LWS_CALLBACK_CLIENT_ESTABLISHED");
978 case LWS_CALLBACK_SET_MODE_POLL_FD:
979 uim_debug("RECIEVE REASON LWS_CALLBACK_SET_MODE_POLL_FD");
981 case LWS_CALLBACK_CLEAR_MODE_POLL_FD:
982 uim_debug("RECIEVE REASON LWS_CALLBACK_CLEAR_MODE_POLL_FD");
984 case LWS_CALLBACK_CLIENT_WRITEABLE:
985 uim_debug("RECIEVE REASON LWS_CALLBACK_CLIENT_WRITEABLE");
987 case LWS_CALLBACK_RECEIVE:
990 && (strncmp((char *) in, "OPEN", strlen("OPEN")) == 0)) {
992 uim_debug("OPEN loading_edje_file [%s]", (char *) in);
993 strncpy(edje_str, edje_parse_str(in, 1), sizeof(edje_str));
994 loading_edje_file(&edje_str[0]);
996 event_message(socket_val, "RESULT SUCCESS");
997 uim_debug("SEND RESULT SUCCESS");
1000 else if ((in != NULL) && (strncmp("CLOSE", in, strlen("CLOSE")) == 0)) {
1001 evas_object_hide(g_edje);
1002 evas_object_del(g_edje);
1003 uim_debug("ONSCREEN CLOSE");
1006 /* Get route from navi.js */
1007 if (strncmp((char *) in, "<route>", strlen("<route>")) == 0) {
1008 uim_debug("<route> recv");
1009 init_e3d(e_3d, in, len);
1014 memset(data, 0, sizeof(data));
1015 strncpy(data, (char *) in, len);
1016 uim_debug("RECIEVE[%d] %s", len, data);
1019 uim_debug("ERROR data=null (line:%d)", __LINE__);
1023 if (strncmp((char *) data, "CHG SEQ REQ_NAV", 15) == 0) {
1024 uim_debug("RECIEVE COMMAND CHG SEQ REQ_NAV");
1028 else if (strncmp((char *) data, "CHG SEQ END_NAV", 15) == 0) {
1029 uim_debug("RECIEVE COMMAND CHG SEQ END_NAV");
1031 enable_navi = FALSE;
1033 else if (strncmp((char *) data, "ERR", 3) == 0) {
1036 case LWS_CALLBACK_CLIENT_RECEIVE:
1037 memset(data, 0, sizeof(data));
1038 strncpy(data, (char *) in, len);
1039 uim_debug("CLIENT_RECIEVE[%d] %s", len, data);
1041 case LWS_CALLBACK_CLOSED:
1042 uim_debug("RECIEVE REASON LWS_CALLBACK_CLOSED");
1046 uim_debug("REASON %d", reason);
1053 /*--------------------------------------------------------------------------*/
1055 * @brief parse_elementary_value
1056 * The message content received from DBus is acquired.
1058 * @param[out] vic_val_p Vehicles information data
1059 * @param[in] iter message received from DBus
1061 * @retval TRUE success
1062 * @retval FALSE error
1064 /*--------------------------------------------------------------------------*/
1066 parse_elementary_value(union VicVal_t *vic_val_p, DBusMessageIter *iter)
1068 dbus_int32_t i32_val;
1069 dbus_int32_t i16_val;
1070 dbus_uint32_t u32_val;
1071 dbus_uint16_t u16_val;
1080 if (vic_val_p == NULL || iter == NULL) {
1081 uim_debug("Err Parameter NG ");
1085 sig = dbus_message_iter_get_arg_type(iter);
1088 case DBUS_TYPE_INT32:
1089 dbus_message_iter_get_basic(iter, &i32_val);
1090 vic_val_p->i32_val = i32_val;
1093 case DBUS_TYPE_INT16:
1094 dbus_message_iter_get_basic(iter, &i16_val);
1095 vic_val_p->i16_val = i16_val;
1098 case DBUS_TYPE_UINT32:
1099 dbus_message_iter_get_basic(iter, &u32_val);
1100 vic_val_p->u32_val = u32_val;
1103 case DBUS_TYPE_UINT16:
1104 dbus_message_iter_get_basic(iter, &u16_val);
1105 vic_val_p->u16_val = u16_val;
1108 case DBUS_TYPE_BOOLEAN:
1109 dbus_message_iter_get_basic(iter, &b_val);
1110 vic_val_p->b_val = b_val;
1113 case DBUS_TYPE_BYTE:
1114 dbus_message_iter_get_basic(iter, &byte_val);
1115 vic_val_p->byte_val = byte_val;
1118 case DBUS_TYPE_DOUBLE:
1119 dbus_message_iter_get_basic(iter, &d_val);
1120 vic_val_p->d_val = d_val;
1123 case DBUS_TYPE_STRING:
1125 dbus_message_iter_get_basic(iter, &s_val);
1126 w_s_val = (char *) malloc(strlen(s_val) + 1);
1127 if (w_s_val == NULL) {
1128 uim_debug("Err malloc");
1131 strncpy(w_s_val, s_val, strlen(s_val));
1132 vic_val_p->s_val = w_s_val;
1137 uim_debug("Err parse_elementary_value: unknown type");
1144 /*--------------------------------------------------------------------------*/
1146 * @brief parse_value
1147 * parse message received from DBus
1149 * @param[out] vic_val_p Vehicles information data
1150 * @param[in] iter message received from DBus
1152 * @retval TRUE success
1153 * @retval FALSE error
1155 /*--------------------------------------------------------------------------*/
1156 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter)
1160 if (vic_val_p == NULL || iter == NULL) {
1161 uim_debug("Err Parameter NG ");
1165 curr = dbus_message_iter_get_arg_type(iter);
1168 case DBUS_TYPE_BYTE:
1169 case DBUS_TYPE_BOOLEAN:
1170 case DBUS_TYPE_INT16:
1171 case DBUS_TYPE_INT32:
1172 case DBUS_TYPE_UINT16:
1173 case DBUS_TYPE_UINT32:
1174 case DBUS_TYPE_DOUBLE:
1175 case DBUS_TYPE_STRING:
1176 return parse_elementary_value(vic_val_p, iter);
1177 case DBUS_TYPE_ARRAY:
1178 case DBUS_TYPE_STRUCT:
1179 case DBUS_TYPE_DICT_ENTRY:
1181 case DBUS_TYPE_INVALID:
1189 /*--------------------------------------------------------------------------*/
1192 * Vehicle information is acquired from AMB.(D-Bus)
1194 * @param[in] key vic_data index
1195 * @param[out] vic_val_p Vehicles information data
1197 * @retval = 0 success
1200 /*--------------------------------------------------------------------------*/
1201 static int getAmbDbus(int key, union VicVal_t *vic_val_p)
1203 /* local variable */
1204 DBusMessage *message;
1207 const char *v_string[] = { vic_data[key].interface_name,
1208 vic_data[key].property_name
1210 const char *dest = Bus_name;
1212 int reply_timeout = 1000; /* Millisecond */
1213 DBusMessageIter iter;
1214 DBusMessageIter iter_array;
1215 union VicVal_t *tmp_vic_val_p = vic_val_p;
1218 dbus_error_init(&error);
1220 if (NULL == g_connection) {
1221 /* obtain the right to use dbus */
1222 g_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
1224 if (g_connection == NULL) {
1225 uim_debug("Err dbus_bus_get");
1227 /* Release err parameter */
1228 dbus_error_free(&error);
1233 /* Constructs a new message */
1234 message = dbus_message_new_method_call(DBUS_SERVICE,
1235 vic_data[key].path_name,
1236 DBUS_INTERFACE, DBUS_METHOD);
1237 if (message == NULL) {
1238 uim_debug("Err dbus_message_new_method_call");
1240 /* Release the connection */
1241 dbus_connection_unref(g_connection);
1242 g_connection = NULL;
1246 /* Gets the type of a message */
1247 result = dbus_message_append_args(message,
1251 &v_string[1], DBUS_TYPE_INVALID);
1254 uim_debug("Err dbus_message_append_args");
1256 /* Release the connection */
1257 dbus_connection_unref(g_connection);
1258 g_connection = NULL;
1260 /* Release the message */
1261 dbus_message_unref(message);
1266 /* Gets the error name */
1267 if (dest && !dbus_message_set_destination(message, dest)) {
1268 uim_debug("Err dbus_message_new_method_call");
1270 /* Release the connection */
1271 dbus_connection_unref(g_connection);
1272 g_connection = NULL;
1274 /* Release the message */
1275 dbus_message_unref(message);
1280 /* Queues a message to send */
1281 reply = dbus_connection_send_with_reply_and_block(g_connection,
1283 reply_timeout, &error);
1284 if (reply == NULL) {
1285 uim_debug( "Err dbus_connection_send_with_reply_and_block" );
1287 /* Release the connection */
1288 dbus_connection_unref(g_connection);
1289 g_connection = NULL;
1291 /* Release the message */
1292 dbus_message_unref(message);
1294 /* Release err parameter */
1295 dbus_error_free(&error);
1300 /* Gets the result */
1301 dbus_message_iter_init(reply, &iter);
1302 dbus_message_iter_recurse(&iter, &iter_array);
1304 /* Type conversion of the resulting value */
1305 result = parse_value(tmp_vic_val_p, &iter_array);
1306 if (result != TRUE) {
1307 uim_debug("Err parse_elementary_value");
1309 /* Release the connection */
1310 dbus_connection_unref(g_connection);
1311 g_connection = NULL;
1313 /* Release the message */
1314 dbus_message_unref(message);
1315 dbus_message_unref(reply);
1320 /* Release the message */
1321 dbus_message_unref(message);
1322 dbus_message_unref(reply);
1327 /*--------------------------------------------------------------------------*/
1329 * @brief getLocationFromAmb
1330 * Location information acquisition from AMB.
1335 /*--------------------------------------------------------------------------*/
1336 static void getLocationFromAmb()
1338 union VicVal_t vic_val[32];
1342 for (i = 0; i < property_num; i++) {
1343 result = getAmbDbus(i, vic_val);
1346 uim_debug("Err getAmbDbus : Unacquired [%s]",vic_data[i].name);
1350 switch (vic_data[i].property) {
1352 if ((camera_geocode.lat != vic_val[0].d_val) &&
1353 (vic_val[0].d_val != 0)) {
1354 uim_debug("%s(%f)", vic_data[i].name, vic_val[0].d_val);
1355 camera_geocode.lat = vic_val[0].d_val;
1359 if ((camera_geocode.lon != vic_val[0].d_val) &&
1360 (vic_val[0].d_val != 0)) {
1361 uim_debug("%s(%f)", vic_data[i].name, vic_val[0].d_val);
1362 camera_geocode.lon = vic_val[0].d_val;
1366 if (camera_geocode.dir != vic_val[0].i32_val) {
1367 uim_debug("%s(%d)", vic_data[i].name, vic_val[0].i32_val);
1368 camera_geocode.dir = vic_val[0].i32_val;
1372 if (ui_vicspeed != vic_val[0].i32_val) {
1373 uim_debug("%s(%d)", vic_data[i].name, vic_val[0].i32_val);
1374 ui_vicspeed = vic_val[0].i32_val;
1378 uim_debug("ERROR no property : %s", vic_data[i].name);
1385 /*--------------------------------------------------------------------------*/
1388 * The config file for vehicle information acquisition is read.
1392 * @retval = 0 success
1395 /*--------------------------------------------------------------------------*/
1396 static int get_config()
1405 fp = fopen(CONFIG_FILE, "r");
1407 uim_debug("File open error");
1411 for (m = 0; k < MAX_PARA_NUM; m++) {
1412 if (fgets(buff, sizeof(buff) - 2, fp) != NULL) {
1413 tp = strtok(buff, clm);
1416 for (j = 0; vic_key_data[j].id != -1; j++) {
1417 if (strcmp(tp, vic_key_data[j].name) == 0) {
1418 vic_data[k].property = vic_key_data[j].id;
1419 strcpy(vic_data[k].name, tp);
1420 strcpy(vic_data[k].path_name, strtok(NULL, clm));
1421 strcpy(vic_data[k].interface_name,
1423 strcpy(vic_data[k].property_name,
1426 uim_debug("vic_data[%d].property=%d", k,
1427 vic_data[k].property);
1428 uim_debug("vic_data[%d].name=%s", k,
1430 uim_debug("vic_data[%d].path_name=%s", k,
1431 vic_data[k].path_name);
1432 uim_debug("vic_data[%d].interface_name=%s", k,
1433 vic_data[k].interface_name);
1434 uim_debug("vic_data[%d].property_name=%s", k,
1435 vic_data[k].property_name);
1440 if (vic_key_data[j].id == -1) {
1442 ("Err config.txt Line:%d Unregistered parameter name",
1448 uim_debug("config.txt Line:%d Comment out '#'Discovery",
1453 uim_debug("config.txt Line:%d Comment out Null line", m + 1);
1457 uim_debug("config.txt The end of data reading");
1464 if (property_num == 0) {
1465 uim_debug("config.txt No valid data");
1472 /*--------------------------------------------------------------------------*/
1474 * @brief edje_parse_str
1475 * A character string is decomposed by a delimiter.
1477 * @param[in] key vic_data index
1478 * @param[in] vic_val_p Vehicles information data
1479 * @return The pointer address to a lexical token
1480 * @retval > 0 success
1481 * @retval NULL error
1483 /*--------------------------------------------------------------------------*/
1484 static char *edje_parse_str(void *in, int arg_num)
1489 uim_debug("edje_parse_str %s, arg = %d", in, arg_num);
1490 data = strtok(in, " ");
1491 /* arg_num : 0 to n */
1492 for (i = 0; i < arg_num; i++) {
1493 data = strtok(NULL, " ");
1495 uim_debug("edje_parse_str data: %s", data);
1499 /*--------------------------------------------------------------------------*/
1501 * @brief event_message
1504 * @param[in] wsi libwebsockets management table to send
1505 * @param[in] fromat message to send
1508 /*--------------------------------------------------------------------------*/
1509 static void event_message(struct libwebsocket *wsi, char *format, ...)
1514 va_start(list, format);
1515 vsnprintf(message, sizeof(message), format, list);
1518 uim_debug("Setting screen: event_message wsi = %p, %s", wsi, message);
1521 unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 +
1522 LWS_SEND_BUFFER_POST_PADDING];
1523 unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
1525 n = sprintf((char *) p, "%s", message);
1526 n = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT);
1527 uim_debug("Setting screen: libwebsocket_write return = %d", n);
1530 uim_debug("Setting screen: wsi is not initialized");
1536 /*--------------------------------------------------------------------------*/
1538 * @brief _touch_up_edje
1539 * Touch-up event processing.
1541 * @param[in] data user data
1542 * @param[in] obj evas object of the button
1543 * @param[in] event_info evas event infomation
1546 /*--------------------------------------------------------------------------*/
1548 _touch_up_edje(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1550 /* get name from userdata */
1552 uim_debug("Setting screen: user data is %s", (const char *) data);
1555 event_message(socket_val, "TOUCH %s %s", edje_str, data);
1556 uim_debug("SEND TOUCH %s ", data);
1560 uim_debug("Setting screen: user data is NULL");
1564 /*--------------------------------------------------------------------------*/
1566 * @brief loading_edje_file
1567 * Loading of edje file.
1569 * @param[in] edje_file edje file
1571 * @retval = 0 success
1574 /*--------------------------------------------------------------------------*/
1575 static int loading_edje_file(const char *edje_file)
1577 Evas_Object *part; /* part handle */
1578 Eina_List *group; /* edje group list */
1579 Eina_List *list; /* part list in edje */
1580 int group_count = 0; /* group counter */
1581 int name_count = 0; /* name counter */
1583 g_evas = ecore_evas_get(window);
1585 uim_debug("Setting screen: could not create evas.");
1590 evas_object_del(g_edje);
1592 /* create and add object in canvas from edje */
1593 g_edje = edje_object_add(g_evas);
1595 uim_debug("Setting screen: could not create edje object!");
1599 /* get group list */
1600 group = edje_file_collection_list(edje_file);
1601 while (group != NULL) {
1602 /* Set the edj file */
1603 if (!edje_object_file_set
1604 (g_edje, edje_file, (const char *) group->data)) {
1605 int err = edje_object_load_error_get(g_edje);
1606 const char *errmsg = edje_load_error_str(err);
1607 uim_debug("Setting screen: could not load %s: %s", edje_file,
1610 edje_file_collection_list_free(group);
1611 evas_object_del(g_edje);
1614 uim_debug("Setting screen: group[%d] data : %s", group_count,
1615 (const char *) group->data);
1618 list = edje_object_access_part_list_get(g_edje);
1619 while (list != NULL) {
1620 uim_debug("Setting screen: list[%d] data : %s", name_count,
1621 (const char *) list->data);
1623 /* set callback for part name */
1625 edje_object_part_object_get((const Evas_Object *) g_edje,
1626 (const char *) list->data);
1628 uim_debug("Setting screen: list[%d] name : %s", name_count,
1629 (const char *) list->data);
1630 evas_object_event_callback_add(part, EVAS_CALLBACK_MOUSE_UP,
1631 _touch_up_edje, list->data);
1634 uim_debug("Setting screen: list[%d] is NULL", name_count);
1643 group = group->next;
1646 uim_debug("Setting screen: group num is %d", group_count);
1647 uim_debug("Setting screen: name num is %d", name_count);
1649 /* Put in the image */
1650 evas_object_move(g_edje, 0, 0);
1651 /* Resize the image */
1652 evas_object_resize(g_edje, W_WIDTH, W_HEIGHT);
1653 /* Show the image */
1654 evas_object_show(g_edje);
1656 evas_object_layer_set(g_edje, LAYER_UI);
1661 /*--------------------------------------------------------------------------*/
1663 * @brief res_callback
1664 * Notice event processing of a resource state.
1666 * @param[in] info rsource information
1667 * @param[in] user_data user data(UNUSED)
1670 /*--------------------------------------------------------------------------*/
1672 res_callback(ico_apf_resource_notify_info_t *info, void *user_data)
1676 uim_debug("##==> Callbacked evt=%d res=%d id=%d bid=%d appid=%s dev=%s"
1677 " user_data=%d", info->state, info->resid, info->id, info->bid,
1678 info->appid, info->device, (int) user_data);
1680 switch (info->state) {
1681 case ICO_APF_RESOURCE_STATE_ACQUIRED:
1682 case ICO_APF_RESOURCE_STATE_DEPRIVED:
1683 case ICO_APF_RESOURCE_STATE_WAITTING:
1684 case ICO_APF_RESOURCE_STATE_RELEASED:
1685 if (info->resid == ICO_APF_RESID_INT_SCREEN) {
1687 ico_apf_resource_reply_int_screen_mode(info->device,
1688 info->bid, info->id,
1690 uim_debug("##==> callback reply int_screen(%s,%d,%d,1) = %d",
1691 info->device, info->bid, info->id, ret);
1693 else if (info->resid == ICO_APF_RESID_ON_SCREEN) {
1695 ico_apf_resource_reply_int_screen_mode_disp(info->device,
1697 uim_debug("##==> callback reply on_screen(%s,%d,1) = %d",
1698 info->device, info->id, ret);
1702 ico_apf_resource_reply_screen_mode(info->device, info->id, 1);
1703 uim_debug("##==> callback reply screen(%s,%d,1) = %d",
1704 info->device, info->id, ret);
1713 /*--------------------------------------------------------------------------*/
1715 * @brief sample navigation application
1718 * @param main() finction's standard parameter (argc,argv)
1720 * @retval =0 success
1721 * @retval =-1 failed
1723 /*--------------------------------------------------------------------------*/
1724 int main(int argc, char *argv[])
1728 char appid[ICO_UXF_MAX_PROCESS_NAME + 1];
1732 /* Setting the log output */
1733 if (ico_apf_get_app_id(0, appid) == ICO_APP_CTL_E_NONE) {
1734 ico_apf_log_open(appid);
1739 elm_init(argc, argv);
1741 enable_navi = FALSE;
1745 if (0 != get_config()) {
1746 uim_debug("ERROR get_config()");
1752 for (i = 1; i < argc; i++) {
1753 if (argv[i][0] == '-') {
1754 if (strcasecmp(argv[i], "-basescreen") == 0) {
1755 getscreen = 1; /* get base screen */
1756 strcpy(sscrntype, "BasicScreen");
1757 uim_debug("BasicScreen");
1759 else if (strcasecmp(argv[i], "-intscreen") == 0) {
1760 getscreen = 2; /* get interrupt screen */
1761 strcpy(sscrntype, "IntScreen");
1763 else if (strcasecmp(argv[i], "-onscreen") == 0) {
1764 getscreen = 3; /* get on screen */
1765 strcpy(sscrntype, "OnScreen");
1772 if (getscreen > 0) {
1773 /* initialize resource control for Ecore */
1774 if (ico_apf_ecore_init(NULL) != ICO_APF_E_NONE) {
1775 uim_debug("ico_apf_ecore_init() Error");
1776 ecore_evas_shutdown();
1780 /* set resource request callback */
1781 ico_apf_resource_set_event_cb(res_callback, NULL);
1783 /* acquire a right to display a screen */
1784 if (getscreen == 1) {
1785 ret = ico_apf_resource_get_screen_mode(NULL, 0);
1787 else if (getscreen == 2) {
1788 ret = ico_apf_resource_get_int_screen_mode(NULL, 0, 0);
1791 ret = ico_apf_resource_get_int_screen_mode_disp(NULL, 0);
1794 uim_debug("getscreen = %d, ret = %d", getscreen, ret);
1797 window = ecore_evas_new(NULL, 0, 0, W_WIDTH, W_HEIGHT, "frame=0");
1801 ecore_evas_show(window);
1804 e_cam = ecore_evas_get(window);
1805 cam = evas_object_image_add(e_cam);
1807 capture = cvCreateCameraCapture(conf_data[USB_CAMERA_ID]);
1809 uim_debug("cvCaptureFromCAM failed.");
1813 captureImage = cvQueryFrame(capture);
1814 uim_debug("camera width = %d, height = %d", captureImage->width,
1815 captureImage->height);
1816 convert_data_evas_cv(cam, captureImage);
1820 evas_object_image_from_cv(cam, test_camera_path);
1821 #else /* _USE_OPENCV_ */
1822 evas_object_image_file_set(cam, test_camera_path, NULL);
1823 #endif /* _USE_OPENCV_ */
1827 evas_object_image_fill_set(cam, 0, 0, W_NAVI_WIDTH, W_NAVI_HEIGHT);
1828 evas_object_move(cam, W_NAVI_ORIGINE_X, W_NAVI_ORIGINE_Y);
1829 evas_object_resize(cam, W_NAVI_WIDTH, W_NAVI_HEIGHT);
1830 evas_object_show(cam);
1833 e_3d = ecore_evas_get(window);
1836 e_ui = ecore_evas_get(window);
1841 libwebsocket_create_context(port, NULL, protocols,
1842 libwebsocket_internal_extensions, NULL,
1844 if (context == NULL) {
1845 fprintf(stderr, "libwebsocket_create_context failed.");
1850 ecore_timer_add(0.05, callback_listener, context);
1852 /* Browser(Map) Layer */
1858 ecore_timer_add(TIME_INTERVAL_AR, _time_interval_navi_cb, cam);
1860 ecore_timer_add(TEST_TIME, _time_interval_map_renew_cb, NULL);
1863 ecore_main_loop_begin();
1869 cvReleaseCapture(&capture);
1872 if (NULL != g_connection) {
1873 dbus_connection_unref(g_connection);
1874 g_connection = NULL;
1877 ico_apf_ecore_term();
1879 ecore_evas_free(window);
1880 ecore_evas_shutdown();
1885 fprintf(stderr, "Evas engine error.");
1886 ecore_evas_shutdown();