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 Vehicles Sample APP
11 * Vehicles information is displayed.
24 //#include <VehicleInfo.h>
26 #include <Ecore_Evas.h>
28 #include <dbus/dbus.h> /* dbus */
29 #include <string.h> /* test log output */
30 #include <stdbool.h> // bool type define //TEST
31 //#include "app_log.h"
33 #include "ico_apf_ecore.h"
34 #include "ico_apf_log.h"
35 //#include "ico_uxf_conf_common.h"
37 //#define DEBUG_PRINT(...) ICO_UXF_DEBUG(__VA_ARGS__)
38 //#define ERROR_PRINT(...) ICO_UXF_WARN(__VA_ARGS__)
44 #define DEBUG_PRINT(...) LOG_PRINT(__VA_ARGS__)
45 #define LOG_PRINT(fmt,...) \
46 {log_print("%s> "fmt" (%s,%s:%d)\n", log_curtime("DBG"), ##__VA_ARGS__,\
47 __func__, __FILE__, __LINE__); }
49 static FILE *sDbgFd = (FILE *) 0;
50 void log_print(const char *fmt, ...)
55 vfprintf(sDbgFd, fmt, list);
60 /* local time difference(sec) */
61 static int sTimeZone = (99 * 60 * 60);
63 char *log_curtime(const char *level)
66 struct timeval NowTime;
70 gettimeofday(&NowTime, (struct timezone *) 0);
71 if (sTimeZone > (24 * 60 * 60)) {
75 NowTime.tv_sec -= sTimeZone;
77 sprintf(sBuf, "%02d:%02d:%02d.%03d[%s]@%d",
78 (int) ((NowTime.tv_sec / 3600) % 24),
79 (int) ((NowTime.tv_sec / 60) % 60),
80 (int) (NowTime.tv_sec % 60),
81 (int) NowTime.tv_usec / 1000, level, getpid());
87 /*============================================================================*/
88 /* Define fixed parameters */
89 /*============================================================================*/
90 #define WIDTH (700) /* Background width */
91 #define HEIGHT (934) /* Background height */
93 /* Count vehicle information */
94 static int property_num = 0;
96 /* max size of vehicle information */
97 #define MAX_PARA_NUM 32
99 /* vehicle information ID */
100 #define VEHICLESPEED 0
101 #define ACCELERATIONX 1
102 #define SHIFTPOSITION 2
103 #define ENGINESPEED 3
106 #define GEARPOSITION 6
111 #define BRAKEPRESSURE 10
114 #define BRAKESIGNAL 13
116 /* Definition for use with D-Bus */
117 #define DBUS_SERVICE "org.automotive.message.broker"
118 #define DBUS_INTERFACE "org.freedesktop.DBus.Properties"
119 #define DBUS_METHOD "Get"
121 /* Definition for files */
122 //#define CONFIG_FILE "/home/rpf/src/app/vic_inf_dspTP/vicsample_config.txt"
123 //#define TMP_LOG "/home/rpf/var/log/uifw/tmp_vic_inf_dspTP.log"
124 //#define LOG_NAME "/home/rpf/var/log/uifw/vic_inf_dspTP.log"
125 #define CONFIG_FILE "/opt/apps/org.tizen.ico.app-vicsample/res/vicsample_config.txt"
126 #define TMP_LOG "/tmp/tmp_ico-app-vicsample.log"
127 #define LOG_NAME "/tmp/ico-app-vicsample.log"
130 /* coordinates of vehicle information table frame */
131 #define VTX_SX 50.0F /* X position of the upper left corner */
132 #define VTX_SY 30.0F /* Y position of the upper left corner */
133 #define VTX_EX 650.0F /* X position of the lower right */
134 #define VTX_EY 830.0F /* Y position of the lower right */
135 #define FIX_LINE_NUM 6 /* The number of lines of the table */
136 /* Percentage of the column 13 = 1+4+4+4 */
137 /* No.[1]:Name(JP)[4]:Name(EN)[4]:Value[4] */
138 #define FIX_SEQ_BASE (VTX_EX - VTX_SX) / 13
139 /* X position of the 1st frame vertical line */
140 #define FIX_SEQ_LINE1 VTX_SX + FIX_SEQ_BASE
141 /* X position of the 2nd frame vertical line */
142 #define FIX_SEQ_LINE2 FIX_SEQ_LINE1 + (FIX_SEQ_BASE * 4)
143 /* X position of the 3rd frame vertical line */
144 #define FIX_SEQ_LINE3 FIX_SEQ_LINE2 + (FIX_SEQ_BASE * 4)
146 /* Horizontal line interval size */
147 #define UFIX_LINE_BASE (VTX_EY - VTX_SY)/MAX_PARA_NUM
149 /*============================================================================*/
150 /* Define data types */
151 /*============================================================================*/
154 dbus_int32_t i32_val;
155 dbus_int32_t i16_val;
156 dbus_uint32_t u32_val;
157 dbus_uint16_t u16_val;
169 char interface_name[64];
170 char property_name[32];
173 struct vic_key_data_t
179 /*============================================================================*/
180 /* Function prototype for static(internal) functions */
181 /*============================================================================*/
182 static void _canvas_resize_cb(Ecore_Evas *ee);
183 static void _on_destroy(Ecore_Evas *ee __UNUSED__);
184 static Eina_Bool _timer_cb(void *data);
185 static void cmdlog_output(int key);
186 static void drawVehicleInfo(void);
187 static void _on_mousedown(void *data, Evas *evas, Evas_Object *o,
189 static int getVehicleInfo(int key, union VicVal_t *vic_val_p);
190 static bool parse_elementary_value(union VicVal_t *vic_val_p,
191 DBusMessageIter *iter);
193 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter);
195 static bool parse_dict_entry(union VicVal_t *vic_val_p,
196 DBusMessageIter *iter);
198 static bool parse_array(union VicVal_t *vic_val_p, DBusMessageIter *iter);
200 static bool parse_struct(union VicVal_t *vic_val_p, DBusMessageIter *iter);
201 static int get_config(void);
203 /*============================================================================*/
204 /* Tables and Valiables */
205 /*============================================================================*/
206 const static char Bus_name[] = DBUS_SERVICE;
207 static struct vic_data_t vic_data[MAX_PARA_NUM];
209 const struct vic_key_data_t vic_key_data[] = {
210 {VEHICLESPEED, "VehicleSpeed"},
211 {ACCELERATIONX, "AccelerationX"},
212 {SHIFTPOSITION, "ShiftPosition"},
213 {ENGINESPEED, "EngineSpeed"},
214 {LATITUDE, "Latitude"},
215 {ALTITUDE, "Altitude"},
216 {GEARPOSITION, "GearPosition"},
217 {LONGITUDE, "Longitude"},
219 {DIRECTION, "Direction"},
220 {BRAKEPRESSURE, "BrakePressure"},
221 {LEFTTURN, "LeftTurn"},
222 {RIGHTTURN, "RightTurn"},
223 {BRAKESIGNAL, "BrakeSignal"},
227 /* Storage area of vehicle information */
228 static union VicVal_t s_vic_val[MAX_PARA_NUM];
229 /* Object for displaying vehicle information */
230 static Evas_Object *vic_val_text[MAX_PARA_NUM];
232 /* Table border line */
233 const static Evas_Coord f_vtx[FIX_LINE_NUM][4] = {
234 {VTX_SX, VTX_SY, VTX_SX, VTX_EY}, // Border of the Left frame
235 {VTX_EX, VTX_SY, VTX_EX, VTX_EY}, // Border of the Right frame
236 {VTX_SX, VTX_SY, VTX_EX, VTX_SY}, // Border of the upper frame
237 {VTX_SX, VTX_EY, VTX_EX, VTX_EY}, // Border of the lower frame
239 {FIX_SEQ_LINE1, VTX_SY, FIX_SEQ_LINE1, VTX_EY}, // Border of the column 1
240 {FIX_SEQ_LINE2, VTX_SY, FIX_SEQ_LINE2, VTX_EY}, // Border of the column 2
241 //{FIX_SEQ_LINE3, VTX_SY, FIX_SEQ_LINE3, VTX_EY} // Border of the column 3
244 //#define WIDTH (300)
245 //#define HEIGHT (300)
247 static Ecore_Evas *ee;
248 static Evas_Object *text, *bg;
249 static char sscrntype[32];
251 static const char commands[] =
253 "\tm - impose a minumum size to the window\n"
254 "\tx - impose a maximum size to the window\n"
255 "\tb - impose a base size to the window\n"
256 "\ts - impose a step size (different than 1 px) to the window\n"
257 "\th - print help\n";
259 /* to inform current window's size */
260 static void _canvas_resize_cb(Ecore_Evas *ee)
265 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
266 snprintf(buf, sizeof(buf), "%s %d x %d", sscrntype, w, h);
267 evas_object_text_text_set(text, buf);
268 evas_object_move(text, VTX_SX, VTX_SY - 22);
269 evas_object_resize(bg, w, h);
272 static void _on_destroy(Ecore_Evas *ee __UNUSED__)
274 ecore_main_loop_quit();
277 /* drawing current time */
278 static Eina_Bool _timer_cb(void *data)
283 timer = time(NULL); /* get time in seconds */
284 date = localtime(&timer); /* Converted to calendar time */
285 sprintf(str, "%s", asctime(date));
286 evas_object_text_text_set((Evas_Object *) data, str);
288 // drawVehicleInfo(); /* Get the vehicle information than AMB */ TEST
290 return EINA_TRUE; /* Continuation of the timer */
293 /* log output for DBUS command result (Debug functin) */
294 static void cmdlog_output(int key)
298 "dbus-send --system --dest=org.automotive.message.broker --type=method_call --print-reply";
299 char mes2[] = "org.freedesktop.DBus.Properties.Get";
300 char mes3[] = "string:";
302 sprintf(str, "%s %s %s %s\"%s\" %s\"%s\" > %s",
303 mes1, vic_data[key].path_name, mes2, mes3,
304 vic_data[key].interface_name, mes3, vic_data[key].property_name,
307 DEBUG_PRINT("%s(D-bus Command Result)", vic_data[key].name);
316 static void drawVehicleInfo()
318 union VicVal_t vic_val[32];
323 for (i = 0; i < property_num; i++) {
324 result = getVehicleInfo(i, vic_val);
327 uim_debug("Err getVehicleInfo : %s", vic_data[i].name);
331 switch (vic_data[i].property) {
333 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
337 // if (vic_val[0].i32_val != s_vic_val[i].i32_val) {
338 // uim_debug("%s update Front:%d Back:%d", vic_data[i].name,
339 // s_vic_val[i].i32_val, vic_val[0].i32_val);
340 s_vic_val[i].i32_val = vic_val[0].i32_val;
343 sprintf(vic_str, "%d", vic_val[0].i32_val);
344 evas_object_text_text_set(vic_val_text[i], vic_str);
348 // uim_debug("%s no update:%d", vic_data[i].name,
349 // vic_val[0].i32_val);
355 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
359 // if (vic_val[0].u16_val != s_vic_val[i].u16_val) {
360 // uim_debug("%s update Front:%d Back:%d", vic_data[i].name,
361 // s_vic_val[i].u16_val, vic_val[0].u16_val);
362 s_vic_val[i].u16_val = vic_val[0].u16_val;
365 sprintf(vic_str, "%d", vic_val[0].i32_val);
366 sprintf(vic_str, "%d", vic_val[0].u16_val);
367 evas_object_text_text_set(vic_val_text[i], vic_str);
370 // uim_debug("%s no update:%d", vic_data[i].name,
371 // vic_val[0].u16_val);
377 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
378 vic_val[0].byte_val);
381 // if (vic_val[0].byte_val != s_vic_val[i].byte_val) {
382 // uim_debug("%s update Front:%d Back:%d", vic_data[i].name,
383 // s_vic_val[i].byte_val, vic_val[0].byte_val);
384 s_vic_val[i].byte_val = vic_val[0].byte_val;
387 sprintf(vic_str, "%d", vic_val[0].byte_val);
388 evas_object_text_text_set(vic_val_text[i], vic_str);
391 // uim_debug("%s noupdate:%d", vic_data[i].name,
392 // vic_val[0].byte_val);
400 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
403 s_vic_val[i].i32_val = vic_val[0].i32_val;
404 sprintf(vic_str, "%d", vic_val[0].i32_val);
405 evas_object_text_text_set(vic_val_text[i], vic_str);
411 uim_debug("%s(D-bus I/F Result) = %f", vic_data[i].name,
414 s_vic_val[i].d_val = vic_val[0].d_val;
415 sprintf(vic_str, "%f", vic_val[0].d_val);
416 evas_object_text_text_set(vic_val_text[i], vic_str);
421 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
422 vic_val[0].byte_val);
424 s_vic_val[i].byte_val = vic_val[0].byte_val;
425 sprintf(vic_str, "%d", vic_val[0].byte_val);
426 evas_object_text_text_set(vic_val_text[i], vic_str);
432 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
435 s_vic_val[i].b_val = vic_val[0].b_val;
436 if (vic_val[0].b_val == TRUE) {
437 sprintf(vic_str, "%s", "true");
440 sprintf(vic_str, "%s", "false");
442 evas_object_text_text_set(vic_val_text[i], vic_str);
446 uim_debug("Err no property : %s\n", vic_data[i].name);
453 static void _on_mousedown(void *data, Evas *evas, Evas_Object *o,
460 /* Get the vehicle information than AMB */
461 DBusConnection *g_connection = NULL;
462 static int getVehicleInfo(int key, union VicVal_t *vic_val_p)
465 DBusMessage *message;
468 const char *v_string[] = {
469 vic_data[key].interface_name,
470 vic_data[key].property_name
472 const char *dest = Bus_name;
474 int reply_timeout = 1000; /* Millisecond */
475 DBusMessageIter iter;
476 DBusMessageIter iter_array;
479 dbus_error_init(&error);
481 if (NULL == g_connection) {
482 /* obtain the right to use dbus */
483 g_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
485 if (g_connection == NULL) {
486 uim_debug("Err dbus_bus_get");
488 /* Release err parameter */
489 dbus_error_free(&error);
493 /* Constructs a new message */
494 message = dbus_message_new_method_call(DBUS_SERVICE,
495 vic_data[key].path_name,
496 DBUS_INTERFACE, DBUS_METHOD);
497 if (message == NULL) {
498 uim_debug("Err dbus_message_new_method_call");
500 /* Release the connection */
501 dbus_connection_unref(g_connection);
506 /* Gets the type of a message */
507 result = dbus_message_append_args(message,
511 &v_string[1], DBUS_TYPE_INVALID);
513 uim_debug("Err dbus_message_append_args");
515 /* Release the connection */
516 dbus_connection_unref(g_connection);
518 /* Release the message */
519 dbus_message_unref(message);
524 /* Gets the error name */
525 if ((dest) && (!dbus_message_set_destination(message, dest))) {
526 uim_debug("Err dbus_message_new_method_call");
528 /* Release the connection */
529 dbus_connection_unref(g_connection);
532 /* Release the message */
533 dbus_message_unref(message);
538 /* Queues a message to send */
539 reply = dbus_connection_send_with_reply_and_block(g_connection,
541 reply_timeout, &error);
543 uim_debug("Err dbus_connection_send_with_reply_and_block");
545 /* Release the connection */
546 dbus_connection_unref(g_connection);
549 /* Release the message */
550 dbus_message_unref(message);
552 /* Release err parameter */
553 dbus_error_free(&error);
558 /* Gets the result */
559 dbus_message_iter_init(reply, &iter);
560 dbus_message_iter_recurse(&iter, &iter_array);
562 /* Type conversion of the resulting value */
563 // result = parse_elementary_value(vic_val_p, &iter_array);
564 union VicVal_t *tmp_vic_val_p = vic_val_p; //TEST
565 result = parse_value(tmp_vic_val_p, &iter_array); //TEST
567 if (result != TRUE) {
568 uim_debug("Err parse_elementary_value");
570 /* Release the connection */
571 dbus_connection_unref(g_connection);
574 /* Release the message */
575 dbus_message_unref(message);
576 dbus_message_unref(reply);
581 /* Release the message */
582 dbus_message_unref(message);
583 dbus_message_unref(reply);
588 /* Parse of the value */
589 static bool parse_elementary_value(union VicVal_t *vic_val_p,
590 DBusMessageIter *iter)
592 dbus_int32_t i32_val;
593 dbus_int32_t i16_val;
594 dbus_uint32_t u32_val;
595 dbus_uint16_t u16_val;
604 if ((vic_val_p == NULL) || (iter == NULL)) {
605 uim_debug("Err Parameter NG ");
609 sig = dbus_message_iter_get_arg_type(iter);
612 case DBUS_TYPE_INT32:
613 dbus_message_iter_get_basic(iter, &i32_val);
614 vic_val_p->i32_val = i32_val;
617 case DBUS_TYPE_INT16:
618 dbus_message_iter_get_basic(iter, &i16_val);
619 vic_val_p->i16_val = i16_val;
622 case DBUS_TYPE_UINT32:
623 dbus_message_iter_get_basic(iter, &u32_val);
624 vic_val_p->u32_val = u32_val;
627 case DBUS_TYPE_UINT16:
628 dbus_message_iter_get_basic(iter, &u16_val);
629 vic_val_p->u16_val = u16_val;
632 case DBUS_TYPE_BOOLEAN:
633 dbus_message_iter_get_basic(iter, &b_val);
634 vic_val_p->b_val = b_val;
638 dbus_message_iter_get_basic(iter, &byte_val);
639 vic_val_p->byte_val = byte_val;
642 case DBUS_TYPE_DOUBLE:
643 dbus_message_iter_get_basic(iter, &d_val);
644 vic_val_p->d_val = d_val;
647 case DBUS_TYPE_STRING:
648 dbus_message_iter_get_basic(iter, &s_val);
649 w_s_val = (char *) malloc(strlen(s_val) + 1); // Release required
650 if (w_s_val == NULL) {
651 uim_debug("Err malloc");
654 strncpy(w_s_val, s_val, strlen(s_val));
655 vic_val_p->s_val = w_s_val;
657 // vic_val_p->s_val = s_val;
660 uim_debug("Err parse_elementary_value: unknown type");
667 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter)
671 if ((vic_val_p == NULL) || (iter == NULL)) {
672 uim_debug("Err Parameter NG ");
676 curr = dbus_message_iter_get_arg_type(iter);
680 case DBUS_TYPE_BOOLEAN:
681 case DBUS_TYPE_INT16:
682 case DBUS_TYPE_INT32:
683 case DBUS_TYPE_UINT16:
684 case DBUS_TYPE_UINT32:
685 case DBUS_TYPE_DOUBLE:
686 case DBUS_TYPE_STRING:
687 return parse_elementary_value(vic_val_p, iter);
688 case DBUS_TYPE_ARRAY:
689 return parse_array(vic_val_p, iter);
690 case DBUS_TYPE_STRUCT:
691 return parse_struct(vic_val_p, iter);
692 case DBUS_TYPE_DICT_ENTRY:
693 // goto error; /* these are handled from parse_array */
695 case DBUS_TYPE_INVALID:
703 static bool parse_array(union VicVal_t *vic_val_p, DBusMessageIter *iter)
705 DBusMessageIter new_iter;
708 if ((vic_val_p == NULL) || (iter == NULL)) {
709 uim_debug("Err Parameter NG ");
716 element_type = dbus_message_iter_get_element_type(iter);
718 dbus_message_iter_recurse(iter, &new_iter);
720 /* the problem: if the value inside array is a dict entry, the
721 * indexing of elements need to be done with dict keys instead
724 if (element_type == DBUS_TYPE_DICT_ENTRY) {
725 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
727 parse_dict_entry(vic_val_p, &new_iter);
728 dbus_message_iter_next(&new_iter);
733 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
736 // lua_pushinteger(L, i++);
738 parse_value(vic_val_p, &new_iter);
739 dbus_message_iter_next(&new_iter);
741 /* put the values to the table */
742 // lua_settable(L, -3);
749 static bool parse_dict_entry(union VicVal_t *vic_val_p,
750 DBusMessageIter *iter)
752 DBusMessageIter new_iter;
754 if ((vic_val_p == NULL) || (iter == NULL)) {
755 uim_debug("Err Parameter NG ");
759 dbus_message_iter_recurse(iter, &new_iter);
761 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
763 /* key must be elementary, value can be anything */
765 parse_elementary_value(vic_val_p, &new_iter);
766 dbus_message_iter_next(&new_iter);
768 parse_value(vic_val_p, &new_iter);
769 dbus_message_iter_next(&new_iter);
771 /* put the values to the table */
772 // lua_settable(L, -3);
778 static bool parse_struct(union VicVal_t *vic_val_p, DBusMessageIter *iter)
780 DBusMessageIter new_iter;
782 if ((vic_val_p == NULL) || (iter == NULL)) {
783 uim_debug("Err Parameter NG ");
787 /* initialize the table */
790 dbus_message_iter_recurse(iter, &new_iter);
792 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
795 // lua_pushinteger(L, i++);
797 parse_value(vic_val_p, &new_iter);
798 dbus_message_iter_next(&new_iter);
800 /* put the values to the table */
801 // lua_settable(L, -3);
807 /* Read configuration file */
808 static int get_config(void)
818 fp = fopen(CONFIG_FILE, "r");
820 uim_debug("File open error");
824 for (m = 0; k < MAX_PARA_NUM; m++) {
825 if (fgets(buff, sizeof(buff) - 2, fp) != NULL) {
826 tp = strtok(buff, clm);
829 for (j = 0; vic_key_data[j].id != -1; j++) {
830 if (strcmp(tp, vic_key_data[j].name) == 0) {
831 vic_data[k].property = vic_key_data[j].id;
832 strcpy(vic_data[k].name, tp);
833 strcpy(vic_data[k].path_name, strtok(NULL, clm));
834 strcpy(vic_data[k].interface_name,
836 strcpy(vic_data[k].property_name,
838 uim_debug("vic_data[%d].property=%d", k,
839 vic_data[k].property);
840 uim_debug("vic_data[%d].name=%s", k,
842 uim_debug("vic_data[%d].path_name=%s", k,
843 vic_data[k].path_name);
844 uim_debug("vic_data[%d].interface_name=%s", k,
845 vic_data[k].interface_name);
846 uim_debug("vic_data[%d].property_name=%s", k,
847 vic_data[k].property_name);
853 if (vic_key_data[j].id == -1) {
854 uim_debug("Err vicsample_config.txt Line:%d Unregistered"
855 " parameter name", m + 1);
861 ("vicsample_config.txt Line:%d Comment out '#'Discovery",
866 uim_debug("vicsample_config.txt Line:%d Comment out Null line",
871 uim_debug("vicsample_config.txt The end of data reading");
878 if (property_num == 0) {
879 uim_debug("vicsample_config.txt No valid data");
885 static void res_callback(ico_apf_resource_notify_info_t *info,
890 uim_debug("##==> Callbacked evt=%d res=%d id=%d bid=%d appid=%s dev=%s"
891 " user_data=%d", info->state, info->resid, info->id,
892 info->bid, info->appid, info->device, (int) user_data);
893 switch (info->state) {
894 case ICO_APF_RESOURCE_STATE_ACQUIRED:
895 case ICO_APF_RESOURCE_STATE_DEPRIVED:
896 case ICO_APF_RESOURCE_STATE_WAITTING:
897 case ICO_APF_RESOURCE_STATE_RELEASED:
898 if (info->resid == ICO_APF_RESID_INT_SCREEN) {
899 ret = ico_apf_resource_reply_int_screen_mode(info->device,
902 uim_debug("##==> callback reply int_screen(%s,%d,%d,1) = %d",
903 info->device, info->bid, info->id, ret);
905 else if (info->resid == ICO_APF_RESID_ON_SCREEN) {
906 ret = ico_apf_resource_reply_int_screen_mode_disp(info->device,
908 uim_debug("##==> callback reply on_screen(%s,%d,1) = %d",
909 info->device, info->id, ret);
913 ico_apf_resource_reply_screen_mode(info->device, info->id, 1);
914 uim_debug("##==> callback reply screen(%s,%d,1) = %d",
915 info->device, info->id, ret);
924 int main(int argc, char *argv[])
929 char appid[ICO_UXF_MAX_PROCESS_NAME + 1];
933 for (i = 1; i < argc; i++) {
934 if (argv[i][0] == '-') {
935 if (strcasecmp(argv[i], "-basescreen") == 0) {
936 getscreen = 1; /* get base screen */
937 strcpy(sscrntype, "BasicScreen");
939 else if (strcasecmp(argv[i], "-intscreen") == 0) {
940 getscreen = 2; /* get interrupt screen */
941 strcpy(sscrntype, "IntScreen");
943 else if (strcasecmp(argv[i], "-onscreen") == 0) {
944 getscreen = 3; /* get on screen */
945 strcpy(sscrntype, "OnScreen");
950 if (!ecore_evas_init()) {
953 /* Setting the log output */
954 if (ico_apf_get_app_id(0, appid) == ICO_APP_CTL_E_NONE) {
955 ico_apf_log_open(appid);
958 uim_debug("main ENTER");
960 /* Read configuration file */
961 if (get_config() != 0) {
962 uim_debug("Err get_config");
967 /* initialize resource control for Ecore */
968 if (ico_apf_ecore_init(NULL) != ICO_APF_E_NONE) {
969 uim_debug("ico_apf_ecore_init() Error");
970 ecore_evas_shutdown();
974 /* set resource request callback */
975 ico_apf_resource_set_event_cb(res_callback, NULL);
977 /* acquire a right to display a screen */
978 if (getscreen == 1) {
979 ico_apf_resource_get_screen_mode(NULL, 0);
981 else if (getscreen == 2) {
982 ico_apf_resource_get_int_screen_mode(NULL, 0, 0);
985 ico_apf_resource_get_int_screen_mode_disp(NULL, 0);
989 /* this will give you a window with an Evas canvas under the first
990 * engine available */
991 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, "frame=0");
996 ecore_evas_callback_delete_request_set(ee, _on_destroy);
997 ecore_evas_title_set(ee, "Ecore_Evas window sizes example");
998 ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
1001 evas = ecore_evas_get(ee);
1003 /* Background printing */
1004 bg = evas_object_rectangle_add(evas);
1005 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
1006 evas_object_move(bg, 0, 0); /* at canvas' origin */
1007 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
1008 evas_object_show(bg);
1010 evas_object_focus_set(bg, EINA_TRUE);
1012 /* Drawing window */
1013 text = evas_object_text_add(evas);
1014 evas_object_color_set(text, 255, 0, 0, 255);
1015 evas_object_resize(text, 150, 50);
1016 evas_object_text_font_set(text, "Sans", 20);
1017 evas_object_show(text);
1019 /* Button on the output drawing vehicle information */
1020 static Evas_Object *sikaku;
1021 sikaku = evas_object_rectangle_add(evas);
1022 evas_object_color_set(sikaku, 255, 0, 0, 100);
1023 evas_object_move(sikaku, 50, ((int) VTX_EY) + 7);
1024 int hsz = HEIGHT - (int) VTX_EY - 7 - 7;
1025 evas_object_resize(sikaku, 200, hsz);
1026 evas_object_show(sikaku);
1029 static Evas_Object *fix_line[FIX_LINE_NUM];
1031 for (i = 0; i < FIX_LINE_NUM; i++) {
1032 fix_line[i] = evas_object_line_add(evas);
1033 evas_object_color_set(fix_line[i], 55, 55, 55, 255);
1034 evas_object_line_xy_set(fix_line[i], f_vtx[i][0], f_vtx[i][1],
1035 f_vtx[i][2], f_vtx[i][3]);
1036 evas_object_show(fix_line[i]);
1039 /* draw order line */
1040 static Evas_Object *ufix_line[MAX_PARA_NUM - 1];
1042 for (i = 0; i < MAX_PARA_NUM - 1; i++) {
1043 ufix_line[i] = evas_object_line_add(evas);
1044 evas_object_color_set(ufix_line[i], 55, 55, 55, 255);
1045 evas_object_line_xy_set(ufix_line[i],
1046 VTX_SX, VTX_SY + UFIX_LINE_BASE * (i + 1),
1047 VTX_EX, VTX_SY + UFIX_LINE_BASE * (i + 1));
1048 evas_object_show(ufix_line[i]);
1051 /* draw table item */
1052 static Evas_Object *num_text[MAX_PARA_NUM];
1054 static Evas_Object *pname_text2[MAX_PARA_NUM];
1056 for (i = 0; i < MAX_PARA_NUM; i++) {
1057 /* draw table item (No.) */
1058 num_text[i] = evas_object_text_add(evas);
1059 evas_object_color_set(num_text[i], 0, 0, 0, 255);
1060 evas_object_resize(num_text[i], FIX_SEQ_BASE, UFIX_LINE_BASE);
1061 evas_object_text_font_set(num_text[i], "Sans",
1062 (UFIX_LINE_BASE / 3) * 2);
1063 evas_object_show(num_text[i]);
1064 sprintf(str, "%d", i + 1);
1065 evas_object_text_text_set(num_text[i], str);
1066 evas_object_move(num_text[i], VTX_SX + FIX_SEQ_BASE / 4,
1067 VTX_SY + UFIX_LINE_BASE * (i) + UFIX_LINE_BASE / 6);
1069 /* draw table item (Name of vehicle information) */
1070 pname_text2[i] = evas_object_text_add(evas);
1071 evas_object_color_set(pname_text2[i], 0, 0, 0, 255);
1072 evas_object_resize(pname_text2[i], 150, 50);
1073 evas_object_text_font_set(pname_text2[i], "Sans",
1074 (UFIX_LINE_BASE / 3) * 2);
1075 evas_object_show(pname_text2[i]);
1076 evas_object_text_text_set(pname_text2[i], vic_data[i].name);
1077 evas_object_move(pname_text2[i], FIX_SEQ_LINE1 + FIX_SEQ_BASE / 4,
1078 VTX_SY + UFIX_LINE_BASE * (i) + UFIX_LINE_BASE / 6);
1080 /* draw table item (Value of vehicle information) */
1081 vic_val_text[i] = evas_object_text_add(evas);
1082 evas_object_color_set(vic_val_text[i], 0, 0, 0, 255);
1083 evas_object_resize(vic_val_text[i], FIX_SEQ_BASE, UFIX_LINE_BASE);
1084 evas_object_text_font_set(vic_val_text[i], "Sans",
1085 (UFIX_LINE_BASE / 3) * 2);
1086 evas_object_show(vic_val_text[i]);
1087 evas_object_move(vic_val_text[i], FIX_SEQ_LINE2 + FIX_SEQ_BASE / 4,
1088 VTX_SY + UFIX_LINE_BASE * (i) + UFIX_LINE_BASE / 6);
1091 /* entry of the function event callback Vehicle Information */
1092 evas_object_event_callback_add(sikaku, EVAS_CALLBACK_MOUSE_DOWN,
1093 _on_mousedown, vic_val_text);
1095 /* drawing current time */
1096 static Evas_Object *time_text;
1098 time_text = evas_object_text_add(evas);
1099 evas_object_color_set(time_text, 0, 0, 0, 255);
1100 evas_object_resize(time_text, 150, 50);
1101 evas_object_text_font_set(time_text, "Sans", 20);
1102 evas_object_show(time_text);
1103 evas_object_move(time_text, 400, VTX_SY - 22);
1105 /* entry of the function event Interval Timer */
1106 ecore_timer_add(0.1, _timer_cb, time_text);
1108 _canvas_resize_cb(ee);
1109 fprintf(stdout, commands);
1110 ecore_main_loop_begin();
1112 ico_apf_ecore_term();
1114 ecore_evas_free(ee);
1115 ecore_evas_shutdown();
1117 if (NULL != g_connection) {
1118 dbus_connection_unref(g_connection);
1119 g_connection = NULL;
1121 uim_debug("main EXIT");
1125 fprintf(stderr, "You got to have at least one Evas engine built"
1126 " and linked up to ecore-evas for this example to run"
1128 ecore_evas_shutdown();
1129 if (NULL != g_connection) {
1130 dbus_connection_unref(g_connection);
1131 g_connection = NULL;