setdest.h File Reference

#include "../../../config.h"
#include "../../../lib/bsd-list.h"

Include dependency graph for setdest.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  Neighbor
class  Node
struct  setdest
class  vector

Defines

#define LIST_FIRST(head)   ((head)->lh_first)
#define LIST_NEXT(elm, field)   ((elm)->field.le_next)

Functions

void ReadInMovementPattern (void)


Define Documentation

#define LIST_FIRST head   )     ((head)->lh_first)
 

Definition at line 9 of file setdest.h.

#define LIST_NEXT elm,
field   )     ((elm)->field.le_next)
 

Definition at line 12 of file setdest.h.

Referenced by Node::Update().


Function Documentation

void ReadInMovementPattern void   ) 
 

Definition at line 176 of file calcdest.cc.

References in_file, LIST_INSERT_HEAD, MAXTIME, NodeList, NODES, out_file, Node::position, vector::X, vector::Y, and vector::Z.

Referenced by main().

00177 {
00178   char buf[256];
00179   u_int n;
00180   double x,y,z,t,s;
00181   struct setdest *setdest;
00182 
00183   while (!feof(in_file)) {
00184 
00185     fgets(buf, sizeof(buf), in_file);
00186     fprintf(out_file, "%s", buf);
00187     if (*buf == '#') continue;
00188     if (*buf == '\n') continue;
00189 
00190     /* check to see if we need data from the line */
00191     if (2 == sscanf(buf,"$node_(%d) set Z_ %lf", &n, &z)) 
00192       {
00193     assert(n < NODES);
00194     NodeList[n].position.Z = z;
00195       }
00196     else if (2 == sscanf(buf,"$node_(%d) set X_ %lf", &n, &x)) 
00197       {
00198     assert(n < NODES);
00199     NodeList[n].position.X = x;
00200       }
00201     else if (2 == sscanf(buf,"$node_(%d) set Y_ %lf", &n, &y)) 
00202       {
00203     assert(n < NODES);
00204     NodeList[n].position.Y = y;
00205       }
00206     else if (5 == sscanf(buf,"$ns_ at %lf \"$node_(%d) setdest %lf %lf %lf\"", 
00207             &t, &n, &x, &y, &s)) 
00208       {
00209     assert(n < NODES);
00210     assert(t <= MAXTIME);
00211     setdest = (struct setdest *)malloc(sizeof(*setdest));
00212     assert(setdest);
00213     setdest->X = x; setdest->Y = y; setdest->Z = 0;
00214     setdest->time = t;
00215     setdest->speed = s;
00216     if (NodeList[n].traj.lh_first 
00217         && t > NodeList[n].traj.lh_first->time)
00218       {
00219         printf("setdest's must be in anti-chronological order in input file!\n");
00220         printf("failed on node %d\n",n);
00221         exit(-1);
00222       }
00223     LIST_INSERT_HEAD(&NodeList[n].traj,setdest,traj);
00224       }
00225     else 
00226       {
00227     printf("unparsable line: '%s'", buf);
00228     continue;
00229       }
00230   }  
00231   fflush(out_file);  
00232 }


Generated on Tue Mar 6 17:00:37 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6