/**
 * nm_setting_vlan_add_priority:
 * @setting: the #NMSettingVlan
 * @map: the type of priority map
 * @from: the priority to map to @to
 * @to: the priority to map @from to
 *
 * Adds a priority mapping to the #NMSettingVlan:ingress_priority_map or
 * #NMSettingVlan:egress_priority_map properties of the setting. If @from is
 * already in the given priority map, this function will overwrite the
 * existing entry with the new @to.
 *
 * If @map is #NM_VLAN_INGRESS_MAP then @from is the incoming 802.1q VLAN
 * Priority Code Point (PCP) value, and @to is the Linux SKB priority value.
 *
 * If @map is #NM_VLAN_EGRESS_MAP then @from is the Linux SKB priority value and
 * @to is the outgoing 802.1q VLAN Priority Code Point (PCP) value.
 *
 * Returns: TRUE if the new priority mapping was successfully added to the
 * list, FALSE if error
 */
gboolean
nm_setting_vlan_add_priority (NMSettingVlan *setting,
                              NMVlanPriorityMap map,
                              guint32 from,
                              guint32 to)
{
	GSList *list = NULL, *iter = NULL;
	PriorityMap *item;

	g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
	g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);

	list = get_map (setting, map);
	for (iter = list; iter; iter = g_slist_next (iter)) {
		item = iter->data;
		if (item->from == from) {
			item->to = to;
			return TRUE;
		}
	}

	item = g_malloc0 (sizeof (PriorityMap));
	item->from = from;
	item->to = to;
	set_map (setting, map, g_slist_append (list, item));

	return TRUE;
}
/**
 * nm_setting_vlan_add_priority:
 * @setting: the #NMSettingVlan
 * @map: the type of priority map
 * @from: the priority to map to @to
 * @to: the priority to map @from to
 *
 * Adds a priority mapping to the #NMSettingVlan:ingress_priority_map or
 * #NMSettingVlan:egress_priority_map properties of the setting. If @from is
 * already in the given priority map, this function will overwrite the
 * existing entry with the new @to.
 *
 * If @map is #NM_VLAN_INGRESS_MAP then @from is the incoming 802.1q VLAN
 * Priority Code Point (PCP) value, and @to is the Linux SKB priority value.
 *
 * If @map is #NM_VLAN_EGRESS_MAP then @from is the Linux SKB priority value and
 * @to is the outgoing 802.1q VLAN Priority Code Point (PCP) value.
 *
 * Returns: %TRUE if the new priority mapping was successfully added to the
 * list, %FALSE if error
 */
gboolean
nm_setting_vlan_add_priority (NMSettingVlan *setting,
                              NMVlanPriorityMap map,
                              guint32 from,
                              guint32 to)
{
	GSList *list = NULL;
	NMVlanQosMapping *item;

	g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
	g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);

	list = get_map (setting, map);
	if (check_replace_duplicate_priority (list, from, to)) {
		if (map == NM_VLAN_INGRESS_MAP)
			g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP);
		else
			g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP);
		return TRUE;
	}

	item = g_malloc0 (sizeof (NMVlanQosMapping));
	item->from = from;
	item->to = to;
	set_map (setting, map, g_slist_insert_sorted (list, item, prio_map_compare));

	return TRUE;
}
/**
 * nm_setting_vlan_add_priority_str:
 * @setting: the #NMSettingVlan
 * @map: the type of priority map
 * @str: the string which contains a priority map, like "3:7"
 *
 * Adds a priority map entry into either the #NMSettingVlan:ingress_priority_map
 * or the #NMSettingVlan:egress_priority_map properties.  The priority map maps
 * the Linux SKB priorities to 802.1p priorities.
 *
 * Returns: TRUE if the entry was successfully added to the list, or it
 * overwrote the old value, FALSE if error
 */
gboolean
nm_setting_vlan_add_priority_str (NMSettingVlan *setting,
                                  NMVlanPriorityMap map,
                                  const char *str)
{
	NMSettingVlanPrivate *priv = NULL;
	GSList *list = NULL, *iter = NULL;
	PriorityMap *item = NULL;

	g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
	g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
	g_return_val_if_fail (str && str[0], FALSE);

	priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
	list = get_map (setting, map);

	item = priority_map_new_from_str (map, str);
	g_return_val_if_fail (item != NULL, FALSE);

	/* Duplicates get replaced */
	for (iter = list; iter; iter = g_slist_next (iter)) {
		PriorityMap *p = iter->data;

		if (p->from == item->from) {
			p->to = item->to;
			g_free (item);
			return TRUE;
		}
	}

	set_map (setting, map, g_slist_append (list, item));
	return TRUE;
}
Ejemplo n.º 4
0
/*没有优惠的商品结算
*@parm: store 库存商品
*@parm: products 购物车中不享受优惠的商品
*@parm: saveing 节省总计
*@parm: consume 消费总计*/
void settle_product(struct set_t *store, struct set_t *products,\
			 float *saveing, float *consume)
{
	if (products) {
		set_map(products, settle_product_print, (void *)store, consume, saveing);
	}	
}
/**
 * nm_setting_vlan_add_priority_str:
 * @setting: the #NMSettingVlan
 * @map: the type of priority map
 * @str: the string which contains a priority map, like "3:7"
 *
 * Adds a priority map entry into either the #NMSettingVlan:ingress_priority_map
 * or the #NMSettingVlan:egress_priority_map properties.  The priority map maps
 * the Linux SKB priorities to 802.1p priorities.
 *
 * Returns: %TRUE if the entry was successfully added to the list, or it
 * overwrote the old value, %FALSE if error
 */
gboolean
nm_setting_vlan_add_priority_str (NMSettingVlan *setting,
                                  NMVlanPriorityMap map,
                                  const char *str)
{
	GSList *list = NULL;
	NMVlanQosMapping *item = NULL;

	g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
	g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
	g_return_val_if_fail (str && str[0], FALSE);

	list = get_map (setting, map);

	item = priority_map_new_from_str (map, str);
	if (!item)
		g_return_val_if_reached (FALSE);

	/* Duplicates get replaced */
	if (check_replace_duplicate_priority (list, item->from, item->to)) {
		g_free (item);
		if (map == NM_VLAN_INGRESS_MAP)
			g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP);
		else
			g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP);
		return TRUE;
	}

	set_map (setting, map, g_slist_insert_sorted (list, item, prio_map_compare));
	return TRUE;
}
Ejemplo n.º 6
0
 void set_jvms(JVMState* jvms)       {
     set_map(jvms->map());
     assert(jvms == this->jvms(), "sanity");
     _sp = jvms->sp();
     _bci = jvms->bci();
     _method = jvms->has_method() ? jvms->method() : NULL;
 }
Ejemplo n.º 7
0
void DAG_graph::add_node(Quaternion * code){
	DAG_node * left = NULL;
	DAG_node * right= NULL;
	if(code->src1!=NULL){
		left = find_node(code->src1);
		set_map(code->src1, left);
	}
	if(code->src2!=NULL){
		right = find_node(code->src2);
		set_map(code->src2, right);	
	}

	if(code->opcode==Quaternion::ASSIGN){
		set_map(code->dst, left);
	}else{
		DAG_node * node = find_node(code->opcode,code->dst, left, right);
		set_map(code->dst, node);
	}	
}
Ejemplo n.º 8
0
void blockOopClass::remap(Map* newMap, frame* newHome) {
  LOG_EVENT3("remapping block %#lx from %#lx/%#lx...",
             this, map(), scope(true));
  LOG_EVENT2("...to %#lx/%#lx", newMap, newHome);
  set_map(newMap);
  setScope(newHome->block_scope_of_home_frame());
  // debugging aid: set block's hash (almost all blocks have an uninitialized
  // hash value, so if a block has a hash it's likely to be a remapped block)
  identity_hash();
}
Ejemplo n.º 9
0
/*只享受折扣的商品结算
*@parm: store商品库存
*@parm: discount_set 购买的折扣商品
*@parm: double_set 购买的多重优惠的商品
*@parm: saveing 节省金额总计
**/
void settle_discount(struct set_t *store, struct set_t *discount_set,\
			struct set_t *double_set, float *saveing, float *consume)
{

	struct set_t *discounts;
	int i;

	discounts = NULL;
	if(double_set) { //去除享受多重优惠的商品
		discounts = set_minus(discount_set, double_set);
	}
	
	if(discounts) { //去除享受多重优惠的商品
		set_map(discounts, settle_discount_print, (void *)store, consume, saveing);
		set_free(&discounts);
	}else if(discount_set){
		set_map(discount_set, settle_discount_print, (void *)store, consume, saveing);	
	}
}
gboolean
_nm_setting_vlan_set_priorities (NMSettingVlan *setting,
                                 NMVlanPriorityMap map,
                                 const NMVlanQosMapping *qos_map,
                                 guint n_qos_map)
{
	gboolean has_changes = FALSE;
	GSList *map_prev, *map_new;
	guint i;
	gint64 from_last;

	map_prev = get_map (setting, map);

	if (n_qos_map != g_slist_length (map_prev))
		has_changes = TRUE;
	else {
		const GSList *iter;

		iter = map_prev;
		for (i = 0; i < n_qos_map; i++, iter = iter->next) {
			const NMVlanQosMapping *m = iter->data;

			if (   m->from != qos_map[i].from
			    || m->to != qos_map[i].to) {
				has_changes = TRUE;
				break;
			}
		}
	}

	if (!has_changes)
		return FALSE;

	map_new = NULL;
	from_last = G_MAXINT64;
	for (i = n_qos_map; i > 0;) {
		const NMVlanQosMapping *m = &qos_map[--i];
		NMVlanQosMapping *item;

		/* We require the array to be presorted. */
		if (m->from >= from_last)
			g_return_val_if_reached (FALSE);
		from_last = m->from;

		item = g_malloc0 (sizeof (NMVlanQosMapping));
		item->from = m->from;
		item->to = m->to;
		map_new = g_slist_prepend (map_new, item);
	}

	g_slist_free_full (map_prev, g_free);
	set_map (setting, map, map_new);

	return TRUE;
}
Ejemplo n.º 11
0
void* __fastcall Detour_LoadMap_KlingonHonorGuard(void *This, void *edx, const void *URL, void *Pending, void *SomeChar)
{
	wchar_t *map = *((wchar_t **)URL + 7);
	set_map(map);

	g_status = STATUS_LOADING_MAP;
	void *level = g_oLoadMap_KlingonHonorGuard(This, URL, Pending, SomeChar);
	g_status = STATUS_NONE;

	return level;
}
Ejemplo n.º 12
0
void memOopClass::set_canonical_map(Map* new_map) {
  // check if there is an existing equivalent map.
  // if so, set the map to that instead of the current map.

  // Note that we don't check if the map has dependents.
  // If it does, we rely on garbage collection for cleaning up.

  set_map(new_map->should_canonicalize()
          ? (Map*) (Memory->map_table->canonical_map((slotsMapDeps*)new_map))
          : new_map);
}
Ejemplo n.º 13
0
/*只享受买二送一优惠商品结算
*@parm: store商品库存
*@parm: free_one_set 购买的买二送一商品
*@parm: double_set 购买的多重优惠的商品
*@parm: saveing 节省金额总计
**/
void settle_free_one(struct set_t *store, struct set_t *free_one_set,\
				struct set_t *double_set, float *saveing,\
							float *consume)
{
	struct set_t *free_ones;
	int i;

	free_ones = NULL;
	if(double_set) { //去除享受多重优惠的商品
		free_ones = set_minus(free_one_set, double_set);
	}
	
	if(free_ones) { //去除享受多重优惠的商品
		set_map(free_ones, settle_free_one_print, (void *)store, consume, saveing);
		set_free(&free_ones);
	}else if(free_one_set){
		set_map(free_one_set, settle_free_one_print, (void *)store, consume, saveing);	
	}

}
Ejemplo n.º 14
0
/**
 * nm_setting_vlan_clear_priorities:
 * @map: the type of priority map
 * @setting: the #NMSettingVlan
 *
 * Clear all the entires from #NMSettingVlan:ingress_priority_map or
 * #NMSettingVlan:egress_priority_map properties.
 */
void
nm_setting_vlan_clear_priorities (NMSettingVlan *setting, NMVlanPriorityMap map)
{
	GSList *list = NULL;

	g_return_if_fail (NM_IS_SETTING_VLAN (setting));
	g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP);

	list = get_map (setting, map);
	nm_utils_slist_free (list, g_free);
	set_map (setting, map, NULL);
}
Ejemplo n.º 15
0
int exec_thread( unsigned int cpu_id, struct thread *t, 
				 unsigned int milliseconds )
{
	assert( t != NULL );
	
	set_fpu_trap();
	
	set_map( t->process->map );

	cpu[ cpu_id ].sched.running = 1;			// Marked as running before
	cpu[ cpu_id ].sched.current_thread = t;		// Mark the thread.
	
	release_spinlock( &(cpu[ cpu_id ].sched.lock_scheduler) ); 
			// Other CPU's can register their need to mess with this CPU's tables.
	

					
		do
		{
		  	sysenter_set_esp( t->stack_kernel );
	
			cpu[ cpu_id ].system_tss->esp0 = t->stack_kernel;
			cpu[ cpu_id ].system_tss->esp  = t->stack;
			cpu[ cpu_id ].system_tss->cr3  = (uint32_t)t->process->map;

			set_apic_distance( cpu_id, milliseconds );
	
			stats_time( cpu_id, &(cpu[ cpu_id ].st_schedulerTime) ); // Scheduler time.

			t->stack = __switch_thread( t->stack );

			stats_time_start( &(cpu[ cpu_id ].st_schedulerTime) ); // Scheduler
		   
		} while ( cpu[cpu_id].sched.locked == 1 ); // in case...

	// If math was used....
	if ( t->math_state > 0 ) save_fpu( t );
	
	cpu[ cpu_id ].sched.current_thread = NULL;
	cpu[ cpu_id ].sched.running = 0;
			// WARNING: Don't use the *t pointer anymore after this.

			// Synchronization point occurs here. Table messing. 

	acquire_spinlock( &(cpu[cpu_id].sched.lock_scheduler) );

	
	return 0;
}
Ejemplo n.º 16
0
static Cmdret conf_mapping(List *args, Cmdarg *ca)
{
  if (strlen(ca->cmdline->line) < strlen("map ") + 3)
    return NORET;
  char *line = ca->cmdline->line + strlen("map ");
  if (!line)
    return NORET;
  char *from = strdup(line);
  char *to = strchr(from, ' ');
  *to = '\0';
  log_msg("CONFIG", "%s -> %s", from, to);
  set_map(from, to+1);
  free(from);
  return NORET;
}
Ejemplo n.º 17
0
/**
 * nm_setting_vlan_remove_priority:
 * @map: the type of priority map
 * @setting: the #NMSettingVlan
 * @idx: the zero-based index of the priority map to remove
 *
 * Removes the priority map at index @idx from the
 * #NMSettingVlan:ingress_priority_map or #NMSettingVlan:egress_priority_map
 * properties.
 */
void
nm_setting_vlan_remove_priority (NMSettingVlan *setting,
                                 NMVlanPriorityMap map,
                                 guint32 idx)
{
	GSList *list = NULL, *item = NULL;

	g_return_if_fail (NM_IS_SETTING_VLAN (setting));
	g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP);

	list = get_map (setting, map);
	g_return_if_fail (idx < g_slist_length (list));

	item = g_slist_nth_data (list, idx);
	priority_map_free ((PriorityMap *) item);
	set_map (setting, map, g_slist_delete_link (list, item));
}
Ejemplo n.º 18
0
Archivo: gui.c Proyecto: hrl/AVL
void _gui_sns_tag_common_show(Set *tag_set) {
    /*
     * show tags' information
     *
     * */
    GtkListStore *liststore=NULL;
    _gui_create_list_store(&liststore, TAG_ALL);

    _Gui_sns_pipe *_pipe=NULL;
    _gui_sns_pipe_init(&_pipe);
    _pipe->liststore = &liststore;

    int result;
    result = set_map(tag_set, _pipe, _gui_sns_tag_insert_into_column);
    if(result != GUI_OP_SUCCESS) gui_show_message("查询失败", GTK_MESSAGE_WARNING);

    gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(liststore));
    _gui_create_column(TAG_ALL);

    _gui_sns_pipe_del(&_pipe);
}
/**
 * nm_setting_vlan_remove_priority_by_value:
 * @setting: the #NMSettingVlan
 * @map: the type of priority map
 * @from: the priority to map to @to
 * @to: the priority to map @from to
 *
 * Removes the priority map @form:@to from the #NMSettingVlan:ingress_priority_map
 * or #NMSettingVlan:egress_priority_map (according to @map argument)
 * properties.
 *
 * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
 */
gboolean
nm_setting_vlan_remove_priority_by_value (NMSettingVlan *setting,
                                          NMVlanPriorityMap map,
                                          guint32 from,
                                          guint32 to)
{
	GSList *list = NULL, *iter = NULL;
	NMVlanQosMapping *item;

	g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
	g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);

	list = get_map (setting, map);
	for (iter = list; iter; iter = g_slist_next (iter)) {
		item = iter->data;
		if (item->from == from && item->to == to) {
			priority_map_free ((NMVlanQosMapping *) (iter->data));
			set_map (setting, map, g_slist_delete_link (list, iter));
			return TRUE;
		}
	}
	return FALSE;
}
Ejemplo n.º 20
0
void cfg::log_entry::from_default()
{
	set_map({});
}
Ejemplo n.º 21
0
Pathfinder::Pathfinder(Generic_map m)
{
  allow_diag = true;
  set_map(m);
}
Ejemplo n.º 22
0
void set_gid_map(pid_t pid, int inside_id, int outside_id, int len) {
    char file[256];
    sprintf(file, "/proc/%d/gid_map", pid);
    set_map(file, inside_id, outside_id, len);
}
Ejemplo n.º 23
0
Archivo: fcc.c Proyecto: 8l/FUZIX
int main(int argc, const char *argv[]) {
  const char *p;
  char *t;
  int i;
  int ret;
  char buf[128];
  
  for(i = 1; i < argc; i++) {
    p = argv[i];
    if (*p != '-')
      add_source(p);
    else {
      switch(p[1]) {
        case 'V':
          verbose = 1;
          break;
        /* What are we doing */
        case 'c':
          mode = MODE_OBJ;
          break;
        case 'E':
          mode = MODE_CPP;
          break;
        case 'S':
          mode = MODE_ASM;
          break;
        case 'v':
          printf("fcc: front end to sdcc\n");
          add_argument("sdcc");
          add_argument("-v");
          do_command();
          exit(0);
        case 'D':
          add_macro(p);
          break;
        case 'l':
          add_library(p+2);
          break;
        case 'L':
          if (p[2] == 0)
            add_library_path(argv[++i]);
          else
            add_library_path(p+2);
          break;
        case 'I':
          if (p[2] == 0)
            add_include_path(argv[++i]);
          else
            add_include_path(p+2);
          break;
        case 'o':
          if (p[2] == 0)
            set_target(argv[++i]);
          else
            set_target(p + 2);
          break;
        case 'O':
          set_optimize(p + 2);
          break;
        case 'm':
          if (p[2] == 0)
            set_cpu(argv[++i]);
          else
            set_cpu(p + 2);
          break;
        case 'M':
          if (p[2] == 0)
            set_map(argv[++i]);
          else
            set_map(p + 2);
          break;
        case 't':
          if (p[2] == 0)
            set_platform(argv[++i]);
          else
            set_platform(p + 2);
          break;
        case 'g':
          debug = 1;
          break;
        default:
          if (strcmp(p, "-Werror") == 0)
            werror = 1;
          else if (strcmp(p, "-funsigned-char") == 0)
            unschar = 1;
          else if (strcmp(p, "--pedantic") == 0)
            pedantic = 1;
          else if (strcmp(p, "--nostdio") == 0)
            nostdio = 1;
          else {
            fprintf(stderr, "fcc: Unknown option '%s'.\n", p);
            exit(1);
          }
      }
    }
  }
  add_include_path(FCC_DIR "/include/");
  add_library_path(FCC_DIR "/lib/");
  snprintf(buf, sizeof(buf), "c%s", platform);
  add_library(buf);

  if (mode == MODE_OBJ) {
    while (srchead) {
      build_command();
      ret = do_command();
      if (ret)
        break;
      if (mode == MODE_OBJ && target) {
        char *orel = filebasename(rebuildname("", srchead->p, "rel"));
        if (rename(orel, target) == -1) {
          fprintf(stderr, "Unable to rename %s to %s.\n", orel, target);
          perror(srchead->p);
          exit(1);
        }
      }
      srchead = srchead->next;
      argp = 0;
    }
  } else {
      build_command();
      ret = do_command();
  }  
  if (mode != MODE_LINK || ret)
    exit(ret);
  argp = 0;
  add_argument("makebin");
  add_argument("-p");
  add_argument("-s");
  add_argument("65535");
  add_argument(target);
  add_argument(t = rebuildname("", target, "bin"));
  ret = do_command();
  if (ret)
    exit(ret);
  argp = 0;
  add_argument(FCC_DIR "/bin/binman");
  snprintf(buf, sizeof(buf), "%x", progbase);
  add_argument(buf);
  add_argument(t);
  add_argument(rebuildname("", target, "map"));
  add_argument(target);
  ret = do_command();
  exit(ret);
}
Ejemplo n.º 24
0
int astar_test_main()
{
	astar_t * as;
	int x0, y0, x1, y1;
	int result;

	srand(time(NULL));

	// Initialise the map.
	map_init();

	// Allocate an A* context.
	as = astar_new (WIDTH, HEIGHT, get_map_cost, NULL);

	// Set the map origin. This allows us to look for a route in
	// an area smaller than the full game map (by setting the
	// origin to the origin of that area, and giving astar_new() a
	// width and height smaller than the full map's. It's
	// mandatory to set this, even if it's just zero. If you don't set it,
	// the algorithm will fail with an ASTAR_ORIGIN_NOT_SET error.

	astar_set_origin (as, 0, 0);

	// By setting the steering penalty, you penalise direction
	// changes. This can lead in more direct routes, but it can also make
	// the algorithm work harder to find a route. The default pre-bundled
	// value for this cost is 5 (5 less than the cost of moving in the four
	// cardinal directions). Set it to zero, and the route can meander
	// more.

	// astar_set_steering_penalty (as, 5);

	// If you have a preference for movement in the cardinal directions
	// only, assign a high cost to the other four directions. If the only
	// way to get from A to B is to move dianogally, a diagonal move will
	// still be used though.

	// astar_set_cost (as, DIR_NE, 100);
	// astar_set_cost (as, DIR_NW, 100);
	// astar_set_cost (as, DIR_SW, 100);
	// astar_set_cost (as, DIR_SE, 100);

	// Instead, if you want to only route using the four cardinal
	// directions, say this:

	// astar_set_movement_mode (as, DIR_CARDINAL);
	// astar_set_movement_mode (as, DIR_8WAY); // This is the default.

	// Starting near the upper left corner of the map.
	x0 = 2;
	y0 = 1;

	// Destination near the lower right corner.
	x1 = WIDTH - 3;
	y1 = HEIGHT - 1;

	// Look for a route.
	result = astar_run (as, x0, y0, x1, y1);

	// What's the result?
	printf ("Route from (%d, %d) to (%d, %d). Result: %s (%d)\n",
		as->x0, as->y0,
		as->x1, as->y1,
		as->str_result, result);

	// Do we have a route? We don't care if the route is partial
	// or full here. If you need a full route, you must ensure the return
	// value of astar_run is ASTAR_FOUND. If it isn't, and
	// astar_have_route() returns non-zero, there's a (possibly partial)
	// route.

	if (astar_have_route (as)) {
		direction_t * directions, * dir;
		uint32_t i, num_steps;
		int x, y;

		num_steps = astar_get_directions (as, &directions);

		if (result == ASTAR_FOUND) {
			printf ("We have a route. It has %d step(s).\n", num_steps);
		} else {
			printf ("The best compromise route has %d step(s).\n", num_steps);
		}

		// The directions start at our (x0, y0) and give us
		// step-by-step directions (e.g. N, E, NE, N) to
		// either our (x1, y1) in the case of a full route, or
		// the best compromise.
		x = x0;
		y = y0;
		dir = directions;
		for (i = 0; i < num_steps; i++, dir++) {

			// Convince ourselves that A* never made us go through walls.
			assert (get_map (x, y) != MAP_WALL);

			// Mark the route on the map.
			set_map (x, y, MAP_ROUTE);

			// Get the next (x, y) co-ordinates of the map.
			x += astar_get_dx (as, *dir);
			y += astar_get_dy (as, *dir);
		}

		// Mark the starting and ending squares on the map. Do this last.
		set_map (x0, y0, MAP_START);
		set_map (x1, y1, MAP_END);

		// VERY IMPORTANT: MEMORY LEAKS OTHERWISE!
		astar_free_directions (directions);
	}

	// Print the map.
	map_print();

	// Dellocate the A* algorithm context.
	astar_destroy (as);
        return 0;
}
Ejemplo n.º 25
0
int main(int argc, char *argv[])
{

    struct GModule *module;
    struct Option *input, *vect;

    struct Cell_head window;
    int bot, right, t0, b0, l0, r0, clear = 0;
    double Rw_l, Rscr_wl;
    char *map_name = NULL, *v_name = NULL, *s_name = NULL;

    /* Initialize the GIS calls */
    G_gisinit(argv[0]);

    /* must run in a term window */
    G_putenv("GRASS_UI_TERM", "1");

    module = G_define_module();
    module->keywords = _("raster, landscape structure analysis, patch index");
    module->description =
	_("Interactive tool used to setup the sampling and analysis framework "
	 "that will be used by the other r.le programs.");

    input = G_define_standard_option(G_OPT_R_MAP);
    input->description = _("Raster map to use to setup sampling");

    vect = G_define_standard_option(G_OPT_V_INPUT);
    vect->key = "vect";
    vect->description = _("Vector map to overlay");
    vect->required = NO;

    if (G_parser(argc, argv))
	exit(EXIT_FAILURE);


    setbuf(stdout, NULL);	/* unbuffered */
    setbuf(stderr, NULL);

    G_sleep_on_error(1);	/* error messages get lost on clear screen */


    map_name = input->answer;
    v_name = vect->answer;
    s_name = NULL;		/* sites not used in GRASS 6 */

    /* setup the r.le.para directory */
    get_pwd();

    /* query for the map to be setup */
    if (R_open_driver() != 0)
	G_fatal_error("No graphics device selected");

    /* setup the current window for display & clear screen */
    D_setup(1);

    Rw_l = (double)G_window_cols() / G_window_rows();
    /*R_open_driver(); */
    /* R_font("romant"); */
    G_get_set_window(&window);
    t0 = R_screen_top();
    b0 = R_screen_bot();
    l0 = R_screen_left();
    r0 = R_screen_rite();
    Rscr_wl = (double)(r0 - l0) / (b0 - t0);

    if (Rscr_wl > Rw_l) {
	bot = b0;
	right = l0 + (b0 - t0) * Rw_l;
    }

    else {
	right = r0;
	bot = t0 + (r0 - l0) / Rw_l;
    }
    D_new_window("a", t0, bot, l0, right);
    D_set_cur_wind("a");
    D_show_window(D_translate_color("green"));
    D_setup(clear);
    R_close_driver();

    /* invoke the setup modules */
    set_map(map_name, v_name, s_name, window, t0, bot, l0, right);

    return (EXIT_SUCCESS);
}
Ejemplo n.º 26
0
 bool restart_map()
 {
     return set_map(curr_map_id);
 }
Ejemplo n.º 27
0
void Carmen_Thread::register_handlers() {

    carmen_map_t map;


    carmen_map_get_gridmap(&map);
    set_map(&map);

    emit_map_changed_signal(map);

    carmen_map_subscribe_gridmap_update_message(
        NULL,
        (carmen_handler_t)map_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_grid_mapping_subscribe_message(NULL,
                                          (carmen_handler_t)grid_map_handler,
                                          CARMEN_SUBSCRIBE_LATEST);

    carmen_localize_ackerman_subscribe_globalpos_message(
        NULL,
        (carmen_handler_t)globalpos_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_simulator_ackerman_subscribe_truepos_message(
        NULL,
        (carmen_handler_t)truepos_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_simulator_subscribe_truepos_message(
        NULL,
        (carmen_handler_t)truepos_handler_diff,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_localize_ackerman_subscribe_particle_message(
        NULL,
        (carmen_handler_t)particle_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_localize_subscribe_globalpos_message(
        NULL,
        (carmen_handler_t)globalpos_handler_diff,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_laser_subscribe_frontlaser_message(
        NULL,
        (carmen_handler_t)laser_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_localize_ackerman_subscribe_sensor_message(
        NULL,
        (carmen_handler_t)localize_laser_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_navigator_ackerman_subscribe_plan_message(
        NULL,
        (carmen_handler_t)plan_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_navigator_subscribe_plan_message(
        NULL,
        (carmen_handler_t)plan_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_navigator_ackerman_subscribe_status_message(
        NULL,
        (carmen_handler_t) navigator_status_handler,
        CARMEN_SUBSCRIBE_LATEST);

    IPC_setMsgQueueLength(CARMEN_GRID_MAPPING_MESSAGE_NAME, 1);

    carmen_rrt_planner_subscribe_robot_tree_message(
        NULL,
        (carmen_handler_t)rrt_planner_robot_tree_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_rrt_planner_subscribe_goal_tree_message(
        NULL,
        (carmen_handler_t)rrt_planner_goal_tree_handler,
        CARMEN_SUBSCRIBE_LATEST);

    carmen_rrt_planner_subscribe_status_message(
        NULL,
        (carmen_handler_t)rrt_status_handler,
        CARMEN_SUBSCRIBE_LATEST);
}
Ejemplo n.º 28
0
 // Set _map to NULL, signalling a stop to further bytecode execution.
 // Preserve the map intact for future use, and return it back to the caller.
 SafePointNode* stop() { SafePointNode* m = map(); set_map(NULL); return m; }
Ejemplo n.º 29
0
void XServo::construct() {
    set_min_max_pwm(DEFAULT_MIN_PWM, DEFAULT_MAX_PWM);
    set_map(DEFAULT_MIN_MAP, DEFAULT_MAX_MAP);
}