Example #1
0
int main(int argc, char **argv) {
  config_parser_t parser;
  epos_node_t node;

  config_parser_init(&parser,
    "Start EPOS controller in the selected operation mode",
    "Establish the communication with a connected EPOS device and attempt to "
    "start the controller in the selected operation mode. The controller will "
    "be stopped if SIGINT is received. The communication interface depends "
    "on the momentarily selected alternative of the underlying CANopen "
    "library.");
  epos_node_init_config_parse(&node, &parser, 0, argc, argv,
    config_parser_exit_error);  
  config_parser_destroy(&parser);
  
  signal(SIGINT, epos_signaled);

  epos_node_connect(&node);
  error_exit(&node.error);
  
  epos_control_start(&node.control);
  error_exit(&node.error);
  
  while (!quit);
  
  epos_control_stop(&node.control);
  error_exit(&node.error);
  
  epos_node_disconnect(&node);
  error_exit(&node.error);

  epos_node_destroy(&node);
  return 0;
}
Example #2
0
int main(int argc, char **argv) {
  config_parser_t parser;
  epos_node_t node;

  config_parser_init(&parser,
    "Start EPOS controller in homing mode",
    "Establish the communication with a connected EPOS device and attempt to "
    "start the controller in homing mode. The controller will be stopped "
    "if SIGINT is received or the homing operation is completed. The "
    "communication interface depends on the momentarily selected alternative "
    "of the underlying CANopen library.");  
  epos_node_init_config_parse(&node, &parser, 0, argc, argv,
    config_parser_exit_error);
  config_parser_destroy(&parser);
  
  signal(SIGINT, epos_signaled);

  epos_node_connect(&node);
  error_exit(&node.error);

  epos_node_home(&node, 0.0);
  if (node.dev.error.code != EPOS_DEVICE_ERROR_WAIT_TIMEOUT)
    error_exit(&node.error);
  
  while (!quit) {
    if (epos_home_wait(&node, 0.1) != EPOS_DEVICE_ERROR_WAIT_TIMEOUT)
      error_exit(&node.dev.error);
  };
  
  epos_home_stop(&node);
  error_exit(&node.dev.error);
  
  epos_node_disconnect(&node);
  error_exit(&node.error);

  epos_node_destroy(&node);
  return 0;
}
Example #3
0
/**
 * @brief 用text_line全局样式对象初始化text_line对象
 *
 * @param tl text_line指针
 *
 * @return 成功返回0,否则返回-1
 **/
static si_t text_line_init_with_default_style(struct text_line * tl)
{
    char tmp_str[TMP_ARRAY_SIZE] = {'\0'};
    si_t tmp_int = -1;
    /* text_line全局样式对象指针 */
    struct text_line_style * style = &text_line_default_style;

    /* 如果text_line全局样式对象尚未加载配置 */
    if(!style->flag)
    {
        struct config_parser parser;

        /* 初始化配置处理器 */
        if(config_parser_init(TEXT_LINE_STYLE_FILE, &parser) != 0)
        {
            EGUI_PRINT_ERROR("fail to init text_line style from config file %s.", TEXT_LINE_STYLE_FILE);

            return -1;
        }

        /* 从配置读取各项配置,赋予style指针 */
        config_parser_get_int(&parser, "area_x", &(style->area_x));
        config_parser_get_int(&parser, "area_y", &(style->area_y));
        config_parser_get_int(&parser, "area_width", &(style->area_width));
        config_parser_get_int(&parser, "area_height", &(style->area_height));

        config_parser_get_int(&parser, "border_size", &(style->border_size));

        config_parser_get_int(&parser, "maximum_width", &(style->maximum_width));
        config_parser_get_int(&parser, "minimum_width", &(style->minimum_width));
        config_parser_get_int(&parser, "maximum_height", &(style->maximum_height));
        config_parser_get_int(&parser, "minimum_height", &(style->minimum_height));

        config_parser_get_str(&parser, "cursor", tmp_str);
        if((tmp_int = get_cursor_enum_from_str(tmp_str)) >= 0)
        {
            style->cursor = tmp_int;
        }

        config_parser_get_int(&parser, "back_color_r", &(style->back_color_r));
        config_parser_get_int(&parser, "back_color_g", &(style->back_color_g));
        config_parser_get_int(&parser, "back_color_b", &(style->back_color_b));
        config_parser_get_int(&parser, "back_color_a", &(style->back_color_a));

        config_parser_get_int(&parser, "fore_color_r", &(style->fore_color_r));
        config_parser_get_int(&parser, "fore_color_g", &(style->fore_color_g));
        config_parser_get_int(&parser, "fore_color_b", &(style->fore_color_b));
        config_parser_get_int(&parser, "fore_color_a", &(style->fore_color_a));

        config_parser_get_int(&parser, "frame_color_r", &(style->frame_color_r));
        config_parser_get_int(&parser, "frame_color_g", &(style->frame_color_g));
        config_parser_get_int(&parser, "frame_color_b", &(style->frame_color_b));
        config_parser_get_int(&parser, "frame_color_a", &(style->frame_color_a));

        tmp_int = -1;
        memset(tmp_str, 0, TMP_ARRAY_SIZE);
        config_parser_get_str(&parser, "font", tmp_str);
        if((tmp_int = get_font_enum_from_str(tmp_str)) >= 0)
        {
            style->font = tmp_int;
        }

        /* 退出配置处理器 */
        config_parser_exit(&parser);
        style->flag = 1;
    }

    /* 用text_line默认样式初始化text_line各样式属性 */
    tl->area.x = style->area_x;
    tl->area.y = style->area_y;
    tl->area.width = style->area_width;
    tl->area.height = style->area_height;

    tl->border_size = style->border_size;

    tl->maximum_width = style->maximum_width;
    tl->minimum_width = style->minimum_width;
    tl->maximum_height = style->maximum_height;
    tl->minimum_height = style->minimum_height;

    tl->cursor = style->cursor;

    tl->back_color.r = style->back_color_r;
    tl->back_color.g = style->back_color_g;
    tl->back_color.b = style->back_color_b;
    tl->back_color.a = style->back_color_a;

    tl->fore_color.r = style->fore_color_r;
    tl->fore_color.g = style->fore_color_g;
    tl->fore_color.b = style->fore_color_b;
    tl->fore_color.a = style->fore_color_a;

    tl->frame_color.r = style->frame_color_r;
    tl->frame_color.g = style->frame_color_g;
    tl->frame_color.b = style->frame_color_b;
    tl->frame_color.a = style->frame_color_a;

    tl->font = style->font;

    return 0;
}
Example #4
0
static int load_config(const char *config)
{
	struct config_parser *cp;
	char *value;
	int i;

	if (!config || strlen(config) == 0)
		cp = config_parser_init(TBOOT_CONFIG);
	else
		cp = config_parser_init(config);

	if (!cp)
		goto err;

	/* init config with default values */
	tboot_config = hashmapCreate(array_size(tc_keys), strhash, strcompare);
	if (!tboot_config)
		goto err;

	for (i = 0; tc_keys[i]; i++)
		hashmapPut(tboot_config, (void *)tc_keys[i], (void *)tc_values[i]);

	/* parse config file */
	value = config_parser_get(cp, UI_CONF_KEY);
	if (value)
		tboot_config_set(UI_CONF_KEY, value);

	value = config_parser_get(cp, DISK_CONFIG_KEY);
	if (value)
		tboot_config_set(DISK_CONFIG_KEY, value);

	value = config_parser_get(cp, PUSH_DIR_KEY);
	if (value)
		tboot_config_set(PUSH_DIR_KEY, value);

	value = config_parser_get(cp, ROOTFS_KEY);
	if (value)
		tboot_config_set(ROOTFS_KEY, value);

	value = config_parser_get(cp, ENABLE_NFS_KEY);
	if (value)
		tboot_config_set(ENABLE_NFS_KEY, value);

	value = config_parser_get(cp, NFSURL_KEY);
	if (value)
		tboot_config_set(NFSURL_KEY, value);

	value = config_parser_get(cp, DISK_FORCE_KEY);
	if (value)
		tboot_config_set(DISK_FORCE_KEY, value);

	value = config_parser_get(cp, BAT_THRESHOLD_KEY);
	if (value)
		tboot_config_set(BAT_THRESHOLD_KEY, value);

	value = config_parser_get(cp, LCD_DIM_TIMEOUT_KEY);
	if (value)
		tboot_config_set(LCD_DIM_TIMEOUT_KEY, value);

	value = config_parser_get(cp, LCD_OFF_TIMEOUT_KEY);
	if (value)
		tboot_config_set(LCD_OFF_TIMEOUT_KEY, value);

	value = config_parser_get(cp, LCD_DIM_BRIGHTNESS_KEY);
	if (value)
		tboot_config_set(LCD_DIM_BRIGHTNESS_KEY, value);

	config_parser_free(cp);
	tboot_config_dump();
	return 0;

err:
	if (cp)
		config_parser_free(cp);
	if (tboot_config)
		hashmapFree(tboot_config);
	return -1;
}