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 #ifndef OVLVIS_H__
00040 #define OVLVIS_H__
00041
00042 #include <sstream>
00043 #include <iostream>
00044 #include <string>
00045 #include <map>
00046 #include <boost/utility.hpp>
00047 #include "ariba/utility/system/Timer.h"
00048 #include "ariba/utility/misc/Helper.h"
00049 #include "ariba/utility/misc/KeyMapping.hpp"
00050 #include "ariba/utility/visual/ServerVis.h"
00051
00052 using std::string;
00053 using std::map;
00054 using std::pair;
00055 using std::make_pair;
00056 using std::cout;
00057 using std::ostringstream;
00058 using ariba::utility::KeyMapping;
00059 using ariba::utility::Timer;
00060
00061 namespace ariba {
00062 namespace utility {
00063
00064 class OvlVis : public ServerVis, private boost::noncopyable {
00065 use_logging_h(OvlVis);
00066 public:
00067 static OvlVis& instance() { static OvlVis the_inst; return the_inst; }
00068
00069
00070
00071
00072
00076 void visCreate (
00077 NETWORK_ID network,
00078 NodeID& node,
00079 string nodename,
00080 string info
00081 );
00082
00086 void visChangeStatus(
00087 NETWORK_ID network,
00088 NodeID& node,
00089 bool enable,
00090 string info
00091 );
00092
00096 void visConnect (
00097 NETWORK_ID network,
00098 NodeID& srcnode,
00099 NodeID& destnode,
00100 string info
00101 );
00102
00106 void visDisconnect (
00107 NETWORK_ID network,
00108 NodeID& srcnode,
00109 NodeID& destnode,
00110 string info
00111 );
00112
00117 void visFailedConnect (
00118 NETWORK_ID network,
00119 NodeID& srcnode,
00120 NodeID& destnode,
00121 string info
00122 );
00123
00127 void visShutdown (
00128 NETWORK_ID network,
00129 NodeID& node,
00130 string info
00131 );
00132
00133
00134
00135
00136
00140 void visChangeNodeColor (
00141 NETWORK_ID network,
00142 NodeID& node,
00143 unsigned char r,
00144 unsigned char g,
00145 unsigned char b
00146 );
00147
00151 void visChangeNodeColor (
00152 NETWORK_ID network,
00153 NodeID& node,
00154 NODE_COLORS color
00155 );
00156
00162 typedef enum _ICON_ID {
00163 ICON_ID_DEFAULT_NODE = 0,
00164 ICON_ID_PC = 1,
00165 ICON_ID_PC_WORLD = 2,
00166 ICON_ID_FAILURE = 3,
00167 ICON_ID_RED_CROSS = 4,
00168 ICON_ID_CHARACTER_A = 5,
00169 ICON_ID_CHARACTER_W = 6,
00170 ICON_ID_CAMERA = 7,
00171 } ICON_ID;
00172
00176 void visChangeNodeIcon (
00177 NETWORK_ID network,
00178 NodeID& node,
00179 ICON_ID icon
00180 );
00181
00185 void visShowNodeLabel (
00186 NETWORK_ID network,
00187 NodeID& node,
00188 string label
00189 );
00190
00194 void visDeleteNodeLabel (
00195 NETWORK_ID network,
00196 NodeID& node
00197 );
00198
00202 void visShowNodeBubble (
00203 NETWORK_ID network,
00204 NodeID& node,
00205 string label
00206 );
00207
00211 void visDeleteNodeBubble (
00212 NETWORK_ID network,
00213 NodeID& node
00214 );
00215
00219 void visShowShiftedNodeIcon (
00220 NETWORK_ID network,
00221 NodeID& node,
00222 ICON_ID iconID,
00223 unsigned int timeout = 0
00224 );
00225
00229 void visDeleteShiftedNodeIcon (
00230 NETWORK_ID network,
00231 NodeID& node
00232 );
00233
00234
00235
00236
00237
00241 void visChangeLinkWidth (
00242 NETWORK_ID network,
00243 NodeID& srcnode,
00244 NodeID& destnode,
00245 unsigned int width
00246 );
00247
00251 void visChangeLinkColor (
00252 NETWORK_ID network,
00253 NodeID& srcnode,
00254 NodeID& destnode,
00255 unsigned char r,
00256 unsigned char g,
00257 unsigned char b
00258 );
00259
00263 void visChangeLinkColor (
00264 NETWORK_ID network,
00265 NodeID& srcnode,
00266 NodeID& destnode,
00267 NODE_COLORS color
00268 );
00269
00273 void visShowLinkLabel (
00274 NETWORK_ID network,
00275 NodeID& srcnode,
00276 NodeID& destnode,
00277 string label
00278 );
00279
00283 void visDeleteLinkLabel (
00284 NETWORK_ID network,
00285 NodeID& srcnode,
00286 NodeID& destnode
00287 );
00288
00292 void visShowOnLinkIcon (
00293 NETWORK_ID network,
00294 NodeID& srcnode,
00295 NodeID& destnode,
00296 ICON_ID iconID
00297 );
00298
00302 void visDeleteOnLinkIcon (
00303 NETWORK_ID network,
00304 NodeID& srcnode,
00305 NodeID& destnode
00306 );
00307
00311 void visShowLinkBubble (
00312 NETWORK_ID network,
00313 NodeID& srcnode,
00314 NodeID& destnode,
00315 string label
00316 );
00317
00321 void visDeleteLinkBubble (
00322 NETWORK_ID network,
00323 NodeID& srcnode,
00324 NodeID& destnode
00325 );
00326
00327
00328
00329
00330
00334 void visSendMessage (
00335 NETWORK_ID network,
00336 NodeID& startnode,
00337 NodeID& endnode
00338 );
00339
00340
00341
00342 void visCLIOInitMeasurement (
00343 NETWORK_ID network,
00344 unsigned long edgekey,
00345 NodeID& srcnode,
00346 NodeID& destnode,
00347 string info
00348 );
00349
00350 void visCLIOEndMeasurement (
00351 NETWORK_ID network,
00352 unsigned long edgekey,
00353 NodeID& srcnode,
00354 NodeID& destnode,
00355 string info,
00356 string value,
00357 string unit
00358 );
00359
00360
00361
00362 protected:
00363 OvlVis();
00364 virtual ~OvlVis();
00365
00366 private:
00367 void sendMessage( const string msg, NETWORK_ID nid );
00368
00369 typedef pair<NodeID, NodeID> NodePair;
00370 typedef KeyMapping<NodePair> NetworkLinks;
00371 typedef KeyMapping<NodePair> LinkBubbles;
00372 typedef KeyMapping<NodeID> NodeBubbles;
00373 typedef KeyMapping<NodeID> ShiftedNodeIcons;
00374 typedef KeyMapping<NodePair> OnLinkIcons;
00375
00376 NetworkLinks networkLinks;
00377 LinkBubbles linkBubbles;
00378 NodeBubbles nodeBubbles;
00379 ShiftedNodeIcons shiftedNodeIcons;
00380 OnLinkIcons onLinkIcons;
00381
00382 class TimedoutIcon : public Timer {
00383 private:
00384 NETWORK_ID network;
00385 NodeID node;
00386 unsigned int timeout;
00387 public:
00388 TimedoutIcon(NETWORK_ID _network, NodeID _node, unsigned int _timeout) :
00389 network(_network), node(_node), timeout(_timeout) {
00390 }
00391
00392 virtual ~TimedoutIcon(){
00393 Timer::stop();
00394 }
00395
00396 void startIcon(){
00397 Timer::setInterval( timeout, true );
00398 Timer::start();
00399 }
00400
00401 protected:
00402 virtual void eventFunction(){
00403 OvlVis::instance().visDeleteShiftedNodeIcon( network, node );
00404 delete this;
00405 }
00406 };
00407
00408 };
00409
00410 }}
00411
00412 #endif // OVLVIS_H__