• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/indep-utils/cmu-scen-gen/setdest/setdest.h

00001 #ifndef __setdest_h__
00002 #define __setdest_h__
00003 
00004 /*#include <sys/queue.h>*/
00005 #include "../../../config.h"
00006 #include "../../../lib/bsd-list.h"
00007 
00008 #ifndef LIST_FIRST
00009 #define LIST_FIRST(head)        ((head)->lh_first)
00010 #endif
00011 #ifndef LIST_NEXT
00012 #define LIST_NEXT(elm, field)   ((elm)->field.le_next)
00013 #endif
00014 
00015 void ReadInMovementPattern(void);
00016 
00017 class vector {
00018 public:
00019         vector(double x = 0.0, double y = 0.0, double z = 0.0) {
00020                 X = x; Y = y; Z = z;
00021         }
00022         double length() {
00023                 return sqrt(X*X + Y*Y + Z*Z);
00024         }
00025 
00026         inline void operator=(const vector a) {
00027                 X = a.X;
00028                 Y = a.Y;
00029                 Z = a.Z;
00030         }
00031         inline void operator+=(const vector a) {
00032                 X += a.X;
00033                 Y += a.Y;
00034                 Z += a.Z;
00035         }
00036         inline int operator==(const vector a) {
00037                 return (X == a.X && Y == a.Y && Z == a.Z);
00038         }
00039         inline int operator!=(const vector a) {
00040                 return (X != a.X || Y != a.Y || Z != a.Z);
00041         }
00042         inline vector operator-(const vector a) {
00043                 return vector(X-a.X, Y-a.Y, Z-a.Z);
00044         }
00045         friend inline vector operator*(const double a, const vector b) {
00046                 return vector(a*b.X, a*b.Y, a*b.Z);
00047         }
00048         friend inline vector operator/(const vector a, const double b) {
00049                 return vector(a.X/b, a.Y/b, a.Z/b);
00050         }
00051 
00052         double X;
00053         double Y;
00054         double Z;
00055 };
00056 
00057 
00058 class Neighbor {
00059 public:
00060         u_int32_t       index;                  // index into NodeList
00061         u_int32_t       reachable;              // != 0 --> reachable.
00062         double          time_transition;        // next change
00063 
00064 };
00065 
00066 struct setdest {
00067   double time;
00068   double X, Y, Z;
00069   double speed;
00070   LIST_ENTRY(setdest)   traj;
00071 };
00072 
00073 class Node {
00074   friend void ReadInMovementPattern(void);
00075 public:
00076         Node(void);
00077         void    Update(void);
00078         void    UpdateNeighbors(void);
00079         void    Dump(void);
00080 
00081         double          time_arrival;           // time of arrival at dest
00082         double          time_transition;        // min of all neighbor times
00083 
00084         // # of optimal route changes for this node
00085         int             route_changes;
00086         int             link_changes;
00087 
00088 private:
00089         void    RandomPosition(void);
00090         void    RandomDestination(void);
00091         void    RandomSpeed(void);
00092 
00093         u_int32_t       index;                  // unique node identifier
00094         u_int32_t       first_trip;             // 1 if first trip, 0 otherwise. (by J. Yoon)
00095 
00096         vector          position;               // current position
00097         vector          destination;            // destination
00098         vector          direction;              // computed from pos and dest
00099 
00100         double          speed;
00101         double          time_update;            // when pos last updated
00102 
00103         static u_int32_t        NodeIndex;
00104 
00105         LIST_HEAD(traj, setdest) traj;
00106 
00107 public:
00108         // An array of NODES neighbors.
00109         Neighbor        *neighbor;
00110 };
00111 
00112 #endif /* __setdest_h__ */

Generated on Tue Aug 10 2010 16:16:07 for ns-2.33 by  doxygen 1.7.1