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 <boost/asio.hpp>
00048 #include "ariba/utility/types/NodeID.h"
00049 #include "ariba/utility/logging/Logging.h"
00050 #include "ariba/utility/system/Timer.h"
00051 #include "ariba/utility/misc/Helper.h"
00052 #include "ariba/utility/misc/KeyMapping.hpp"
00053 #include "ariba/utility/configuration/Configuration.h"
00054
00055 using std::string;
00056 using std::map;
00057 using std::pair;
00058 using std::make_pair;
00059 using std::cout;
00060 using std::ostringstream;
00061 using boost::asio::ip::tcp;
00062 using ariba::utility::NodeID;
00063 using ariba::utility::Configuration;
00064 using ariba::utility::KeyMapping;
00065 using ariba::utility::Timer;
00066
00067 namespace ariba {
00068 namespace utility {
00069
00070 class OvlVis : private boost::noncopyable {
00071 use_logging_h(OvlVis);
00072 public:
00073 static OvlVis& instance() { static OvlVis the_inst; return the_inst; }
00074
00075 typedef enum _NETWORK_ID {
00076 NETWORK_ID_BASE_COMMUNICATION = 1,
00077 NETWORK_ID_BASE_OVERLAY = 2,
00078 NETWORK_ID_EONSON = 3,
00079 NETWORK_ID_MCPO = 4,
00080 NETWORK_ID_CLIO = 5,
00081 NETWORK_ID_VIDEOSTREAM = 6,
00082 NETWORK_ID_GAME = 7,
00083 NETWORK_ID_SECURITY = 8,
00084 } NETWORK_ID;
00085
00086
00087
00088
00089
00093 void visCreate (
00094 NETWORK_ID network,
00095 NodeID& node,
00096 string nodename,
00097 string info
00098 );
00099
00103 void visChangeStatus(
00104 NETWORK_ID network,
00105 NodeID& node,
00106 bool enable,
00107 string info
00108 );
00109
00113 void visConnect (
00114 NETWORK_ID network,
00115 NodeID& srcnode,
00116 NodeID& destnode,
00117 string info
00118 );
00119
00123 void visDisconnect (
00124 NETWORK_ID network,
00125 NodeID& srcnode,
00126 NodeID& destnode,
00127 string info
00128 );
00129
00134 void visFailedConnect (
00135 NETWORK_ID network,
00136 NodeID& srcnode,
00137 NodeID& destnode,
00138 string info
00139 );
00140
00144 void visShutdown (
00145 NETWORK_ID network,
00146 NodeID& node,
00147 string info
00148 );
00149
00150
00151
00152
00153
00157 void visChangeNodeColor (
00158 NETWORK_ID network,
00159 NodeID& node,
00160 unsigned char r,
00161 unsigned char g,
00162 unsigned char b
00163 );
00164
00165 typedef enum _NODE_COLORS {
00166 NODE_COLORS_GREY,
00167 NODE_COLORS_GREEN,
00168 NODE_COLORS_RED,
00169 } NODE_COLORS;
00170
00174 void visChangeNodeColor (
00175 NETWORK_ID network,
00176 NodeID& node,
00177 NODE_COLORS color
00178 );
00179
00185 typedef enum _ICON_ID {
00186 ICON_ID_DEFAULT_NODE = 0,
00187 ICON_ID_PC = 1,
00188 ICON_ID_PC_WORLD = 2,
00189 ICON_ID_FAILURE = 3,
00190 ICON_ID_RED_CROSS = 4,
00191 ICON_ID_CHARACTER_A = 5,
00192 ICON_ID_CHARACTER_W = 6,
00193 ICON_ID_CAMERA = 7,
00194 } ICON_ID;
00195
00199 void visChangeNodeIcon (
00200 NETWORK_ID network,
00201 NodeID& node,
00202 ICON_ID icon
00203 );
00204
00208 void visShowNodeLabel (
00209 NETWORK_ID network,
00210 NodeID& node,
00211 string label
00212 );
00213
00217 void visDeleteNodeLabel (
00218 NETWORK_ID network,
00219 NodeID& node
00220 );
00221
00225 void visShowNodeBubble (
00226 NETWORK_ID network,
00227 NodeID& node,
00228 string label
00229 );
00230
00234 void visDeleteNodeBubble (
00235 NETWORK_ID network,
00236 NodeID& node
00237 );
00238
00242 void visShowShiftedNodeIcon (
00243 NETWORK_ID network,
00244 NodeID& node,
00245 ICON_ID iconID,
00246 unsigned int timeout = 0
00247 );
00248
00252 void visDeleteShiftedNodeIcon (
00253 NETWORK_ID network,
00254 NodeID& node
00255 );
00256
00257
00258
00259
00260
00264 void visChangeLinkWidth (
00265 NETWORK_ID network,
00266 NodeID& srcnode,
00267 NodeID& destnode,
00268 unsigned int width
00269 );
00270
00274 void visChangeLinkColor (
00275 NETWORK_ID network,
00276 NodeID& srcnode,
00277 NodeID& destnode,
00278 unsigned char r,
00279 unsigned char g,
00280 unsigned char b
00281 );
00282
00286 void visChangeLinkColor (
00287 NETWORK_ID network,
00288 NodeID& srcnode,
00289 NodeID& destnode,
00290 NODE_COLORS color
00291 );
00292
00296 void visShowLinkLabel (
00297 NETWORK_ID network,
00298 NodeID& srcnode,
00299 NodeID& destnode,
00300 string label
00301 );
00302
00306 void visDeleteLinkLabel (
00307 NETWORK_ID network,
00308 NodeID& srcnode,
00309 NodeID& destnode
00310 );
00311
00315 void visShowOnLinkIcon (
00316 NETWORK_ID network,
00317 NodeID& srcnode,
00318 NodeID& destnode,
00319 ICON_ID iconID
00320 );
00321
00325 void visDeleteOnLinkIcon (
00326 NETWORK_ID network,
00327 NodeID& srcnode,
00328 NodeID& destnode
00329 );
00330
00334 void visShowLinkBubble (
00335 NETWORK_ID network,
00336 NodeID& srcnode,
00337 NodeID& destnode,
00338 string label
00339 );
00340
00344 void visDeleteLinkBubble (
00345 NETWORK_ID network,
00346 NodeID& srcnode,
00347 NodeID& destnode
00348 );
00349
00350
00351
00352
00353
00357 void visSendMessage (
00358 NETWORK_ID network,
00359 NodeID& startnode,
00360 NodeID& endnode
00361 );
00362
00363
00364
00365 void visCLIOInitMeasurement (
00366 NETWORK_ID network,
00367 unsigned long edgekey,
00368 NodeID& srcnode,
00369 NodeID& destnode,
00370 string info
00371 );
00372
00373 void visCLIOEndMeasurement (
00374 NETWORK_ID network,
00375 unsigned long edgekey,
00376 NodeID& srcnode,
00377 NodeID& destnode,
00378 string info,
00379 string value,
00380 string unit
00381 );
00382
00383
00384
00385 protected:
00386 OvlVis();
00387 ~OvlVis();
00388
00389 private:
00390 void sendMessage( const string msg, NETWORK_ID nid );
00391 void sendSocket( const string msg );
00392
00396 boost::asio::io_service io_service;
00397 tcp::socket socket;
00398 volatile bool socketOpened;
00399
00400 typedef pair<NodeID, NodeID> NodePair;
00401 typedef KeyMapping<NodePair> NetworkLinks;
00402 typedef KeyMapping<NodePair> LinkBubbles;
00403 typedef KeyMapping<NodeID> NodeBubbles;
00404 typedef KeyMapping<NodeID> ShiftedNodeIcons;
00405 typedef KeyMapping<NodePair> OnLinkIcons;
00406
00407 NetworkLinks networkLinks;
00408 LinkBubbles linkBubbles;
00409 NodeBubbles nodeBubbles;
00410 ShiftedNodeIcons shiftedNodeIcons;
00411 OnLinkIcons onLinkIcons;
00412
00413 class TimedoutIcon : public Timer {
00414 private:
00415 NETWORK_ID network;
00416 NodeID node;
00417 unsigned int timeout;
00418 public:
00419 TimedoutIcon(NETWORK_ID _network, NodeID _node, unsigned int _timeout) :
00420 network(_network), node(_node), timeout(_timeout) {
00421 }
00422
00423 virtual ~TimedoutIcon(){
00424 Timer::stop();
00425 }
00426
00427 void startIcon(){
00428 Timer::setInterval( timeout, true );
00429 Timer::start();
00430 }
00431
00432 protected:
00433 virtual void eventFunction(){
00434 OvlVis::instance().visDeleteShiftedNodeIcon( network, node );
00435 delete this;
00436 }
00437 };
00438
00439 };
00440
00441 }}
00442
00443 #endif // OVLVIS_H__