void place_steadystaterwp_node (node_struct * node) { int loc_num; double block_xmin, block_ymin; if (grid == RESTIRICTED_RWP) { loc_num = (int) randomgen (0, omg_param_list[node->type].max_vertices); node->x_pos = (double) vertice_xpos (loc_num, omg_param_list[node->type]); node->y_pos = (double) vertice_ypos (loc_num, omg_param_list[node->type]); //LOG_D(OMG,"location number %d x pos %.2f y pos %.2f \n\n",loc_num,node->x_pos,node->y_pos); } else if (grid == CONNECTED_DOMAIN) { node->block_num = (int) randomgen (0, omg_param_list[node->type].max_block_num); block_xmin = area_minx (node->block_num, omg_param_list[node->type]); block_ymin = area_miny (node->block_num, omg_param_list[node->type]); node->x_pos = (double) ((int) (randomgen (block_xmin, xloc_div + block_xmin) * 100)) / 100; node->y_pos = (double) ((int) (randomgen (block_ymin, yloc_div + block_ymin) * 100)) / 100; } else { node->x_pos = (double) ((int) (randomgen (omg_param_list[node->type].min_x, omg_param_list[node->type].max_x) * 100)) / 100; node->y_pos = (double) ((int) (randomgen (omg_param_list[node->type].min_y, omg_param_list[node->type].max_y) * 100)) / 100; } node->mob->x_from = node->x_pos; node->mob->x_to = node->x_pos; node->mob->y_from = node->y_pos; node->mob->speed = 0.0; node->mob->journey_time = 0.0; LOG_I (OMG, "#[STEADY_RWP] Initial position of node ID: %d type: %d X = %.2f, Y = %.2f\n ", node->id, node->type, node->x_pos, node->y_pos); node_vector_end[node->type] = (node_list *) add_entry (node, node_vector_end[node->type]); if (node_vector[node->type] == NULL) node_vector[node->type] = node_vector_end[node->type]; node_vector_len[node->type]++; //Initial_Node_Vector_len[RWP]++; }
void move_rwp_node (pair_struct * pair, double cur_time) { int loc_num; double distance, journeytime_next; double pr, block_xmin, block_ymin; //LOG_D (OMG, "[RWP] move node: %d\n", node->ID); node_struct *node; node = pair->b; node->mob->x_from = node->mob->x_to; node->mob->y_from = node->mob->y_to; node->x_pos = node->mob->x_to; node->y_pos = node->mob->y_to; node->mobile = 1; if (omg_param_list[node->type].rwp_type == RESTIRICTED_RWP) { do { loc_num = (int) randomgen (0, omg_param_list[node->type].max_vertices); node->mob->x_to = (double) vertice_xpos (loc_num, omg_param_list[node->type]); node->mob->y_to = (double) vertice_ypos (loc_num, omg_param_list[node->type]); } while (node->mob->x_to == node->mob->x_from && node->mob->y_to == node->mob->y_from); distance = fabs (node->mob->x_to - node->mob->x_from) + fabs (node->mob->y_to - node->mob->y_from); /* LOG_D(OMG,"#location number %d x pos to %.2f y pos to %.2f x pos from %.2f y pos from %.2f\n\n",loc_num,node->mob->x_to,node->mob->y_to,node->mob->x_from,node->mob->y_from); */ } else if (omg_param_list[node->type].rwp_type == CONNECTED_DOMAIN) { pr = randomgen (0, 1); if (pr <= 0.50) /*node->block_num = (int) randomgen (0, omg_param_list[node->type].max_block_num); */ node->block_num = (int) next_block (node->block_num, omg_param_list[node->type]); block_xmin = area_minx (node->block_num, omg_param_list[node->type]); block_ymin = area_miny (node->block_num, omg_param_list[node->type]); node->mob->x_to = (double) ((int) (randomgen (block_xmin, xloc_div + block_xmin) * 100)) / 100; node->mob->y_to = (double) ((int) (randomgen (block_ymin, yloc_div + block_ymin) * 100)) / 100; distance = (double) ((int) (sqrtf (pow (node->mob->x_from - node->mob->x_to, 2) + pow (node->mob->y_from - node->mob->y_to, 2)) * 100)) / 100; node->mob->azimuth = atan2 (node->mob->y_to - node->mob->y_from, node->mob->x_to - node->mob->x_from); //radian } else { node->mob->x_to = (double) ((int) (randomgen (omg_param_list[node->type].min_x, omg_param_list[node->type].max_x) * 100)) / 100; node->mob->y_to = (double) ((int) (randomgen (omg_param_list[node->type].min_y, omg_param_list[node->type].max_y) * 100)) / 100; distance = (double) ((int) (sqrtf (pow (node->mob->x_from - node->mob->x_to, 2) + pow (node->mob->y_from - node->mob->y_to, 2)) * 100)) / 100; node->mob->azimuth = atan2 (node->mob->y_to - node->mob->y_from, node->mob->x_to - node->mob->x_from); //radian } node->mob->speed = (double) ((int) (randomgen (omg_param_list[node->type].min_speed, omg_param_list[node->type].max_speed) * 100)) / 100; journeytime_next = (double) ((int) (distance / node->mob->speed * 100)) / 100; //duration to get to dest /* LOG_D (OMG, "#[RWP] %d mob->journey_time_next %.2f distance %.2f speed %.2f\n \n",node->id, journeytime_next, distance,node->mob->speed); */ node->mob->start_journey = cur_time; //LOG_D (OMG, "[RWP] start_journey %.2f\n", node->mob->start_journey); pair->next_event_t = cur_time + journeytime_next; //when to reach the destination // LOG_D (OMG, // "[RWP] reaching the destination at time : start journey + journey_time next =%.2f\n", // pair->a); /* if (node->event_num < 100) { event_sum[node->event_num] += node->mob->speed; events[node->event_num]++; node->event_num++; } */ }