static.c 4.31 KB
Newer Older
1
/*******************************************************************************
nikaeinn's avatar
nikaeinn committed
2 3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

nikaeinn's avatar
nikaeinn committed
5 6 7 8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
9 10


nikaeinn's avatar
nikaeinn committed
11 12 13 14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
15

nikaeinn's avatar
nikaeinn committed
16 17 18 19
    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
    included in this distribution in the file called "COPYING". If not,
    see <http://www.gnu.org/licenses/>.
20 21

  Contact Information
nikaeinn's avatar
nikaeinn committed
22 23
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
nikaeinn's avatar
nikaeinn committed
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27 28 29 30

*******************************************************************************/

/*! \file rwalk.c
31
* \brief static  mobility generator
32
* \author  M. Mahersi, N. Nikaein, J. Harri
33 34 35
* \date 2011
* \version 0.1
* \company Eurecom
36
* \email:
37 38 39 40 41 42 43
* \note
* \warning
*/

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#include "static.h"


void
start_static_generator (omg_global_param omg_param_list)
{

  int id;
  static int n_id = 0;
  node_struct *node = NULL;
  mobility_struct *mobility = NULL;

  srand (omg_param_list.seed + STATIC);

  LOG_I (OMG, "Static mobility model for %d %d nodes\n", omg_param_list.nodes,
59 60 61 62 63 64 65 66 67 68 69 70 71 72
         omg_param_list.nodes_type);

  for (id = n_id; id < (omg_param_list.nodes + n_id); id++) {

    node = create_node ();
    mobility = create_mobility ();

    node->id = id;
    node->type = omg_param_list.nodes_type;
    node->mob = mobility;
    node->generator = STATIC;
    place_static_node (node); //initial positions
  }

73 74
  n_id += omg_param_list.nodes;

75 76 77 78

}


79 80 81 82

void
place_static_node (node_struct * node)
{
83 84 85 86 87 88 89
  if (omg_param_list[node->type].user_fixed && node->type == eNB) {
    if (omg_param_list[node->type].fixed_x <=
        omg_param_list[node->type].max_x
        && omg_param_list[node->type].fixed_x >=
        omg_param_list[node->type].min_x)
      node->x_pos = omg_param_list[node->type].fixed_x;
    else
90
      node->x_pos =
91 92 93 94 95 96 97 98 99 100 101 102 103 104
        (double) ((int)
                  (randomgen
                   (omg_param_list[node->type].min_x,
                    omg_param_list[node->type].max_x) * 100)) / 100;

    node->mob->x_from = node->x_pos;
    node->mob->x_to = node->x_pos;

    if (omg_param_list[node->type].fixed_y <=
        omg_param_list[node->type].max_y
        && omg_param_list[node->type].fixed_y >=
        omg_param_list[node->type].min_y)
      node->y_pos = omg_param_list[node->type].fixed_y;
    else
105
      node->y_pos =
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
        (double) ((int)
                  (randomgen
                   (omg_param_list[node->type].min_y,
                    omg_param_list[node->type].max_y) * 100)) / 100;

    node->mob->y_from = node->y_pos;
    node->mob->y_to = node->y_pos;
  } else {

    node->x_pos =
      (double) ((int)
                (randomgen
                 (omg_param_list[node->type].min_x,
                  omg_param_list[node->type].max_x) * 100)) / 100;
    node->mob->x_from = node->x_pos;
    node->mob->x_to = node->x_pos;
    node->y_pos =
      (double) ((int)
                (randomgen
                 (omg_param_list[node->type].min_y,
                  omg_param_list[node->type].max_y) * 100)) / 100;
    node->mob->y_from = node->y_pos;
    node->mob->y_to = node->y_pos;
  }
130

131 132 133
  node->mob->speed = 0.0;
  node->mob->journey_time = 0.0;

134
  LOG_I (OMG,
gauthier's avatar
gauthier committed
135 136
         "[STATIC] Initial position of node ID: %d type(%d: %s):  (X = %.2f, Y = %.2f) speed = 0.0\n",
         node->id, node->type, (node->type==eNB)?"eNB":(node->type==UE)?"UE":"Relay", node->x_pos, node->y_pos);
137

138 139 140 141 142 143 144 145
  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]++;
}