00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef _GEAR_SENDER_HH_
00044 #define _GEAR_SENDER_HH_
00045
00046 #ifdef HAVE_CONFIG_H
00047 #include "config.h"
00048 #endif // HAVE_CONFIG_H
00049
00050 #include "gear_common.hh"
00051
00052 class GearSenderReceive;
00053 class GearSenderApp;
00054
00055 #define SEND_DATA_INTERVAL 5
00056
00057 #ifdef NS_DIFFUSION
00058 class GearSendDataTimer : public TimerHandler {
00059 public:
00060 GearSendDataTimer(GearSenderApp *a) : TimerHandler() { a_ = a; }
00061 void expire(Event *e);
00062 protected:
00063 GearSenderApp *a_;
00064 };
00065 #endif //NS_DIFFUSION
00066
00067 class GearSenderApp : public DiffApp {
00068 public:
00069 #ifdef NS_DIFFUSION
00070 GearSenderApp();
00071 int command(int argc, const char*const* argv);
00072 void send();
00073 #else
00074 GearSenderApp(int argc, char **argv);
00075 #endif // NS_DIFFUSION
00076
00077 virtual ~GearSenderApp()
00078 {
00079
00080 };
00081
00082 void run();
00083 void recv(NRAttrVec *data, NR::handle my_handle);
00084
00085 private:
00086
00087 GearSenderReceive *mr_;
00088 handle subHandle_;
00089 handle pubHandle_;
00090
00091
00092 bool using_points_;
00093 bool using_push_;
00094 int num_subscriptions_;
00095 int last_seq_sent_;
00096 float lat_min_;
00097 float lat_max_;
00098 float long_min_;
00099 float long_max_;
00100 float lat_pt_;
00101 float long_pt_;
00102 NRAttrVec data_attr_;
00103 NRSimpleAttribute<void *> *timeAttr_;
00104 NRSimpleAttribute<int> *counterAttr_;
00105 EventTime *lastEventTime_;
00106
00107 handle setupSubscription();
00108 handle setupPublication();
00109 void parseCommandLine(int argc, char **argv);
00110 void readGeographicCoordinates();
00111 void usage(char *s);
00112 #ifdef NS_DIFFUSION
00113 GearSendDataTimer sdt_;
00114 #endif // NS_DIFFUSION
00115 };
00116
00117 class GearSenderReceive : public NR::Callback {
00118 public:
00119 GearSenderReceive(GearSenderApp *app) : app_(app) {};
00120 void recv(NRAttrVec *data, NR::handle my_handle);
00121
00122 GearSenderApp *app_;
00123 };
00124
00125 #endif // !_GEAR_SENDER_HH_