From d805a977e6ab8238654de674db7ff789fea464ef Mon Sep 17 00:00:00 2001 From: "Ake Hedman, Paradise of the Frog" Date: Wed, 4 Nov 2015 22:39:56 +0100 Subject: [PATCH] Not fully working but still proof of concept node discovery in place. Release time. --- config_examples/variables.xml_distro | 2 +- src/common/rapidxml/rapidxml.hpp | 2 +- src/vscp/common/daemonvscp.cpp | 95 +++++++---- src/vscp/common/knownnodes.cpp | 1 + src/vscp/common/knownnodes.h | 4 + src/vscp/common/version.h | 4 +- src/vscp/common/vscp.h | 12 +- src/vscp/common/vscpmulticast.cpp | 42 +++-- .../drivers/level2/sim/common/simulation.cpp | 2 +- src/vscp/vscpworks/frmmain.cpp | 151 +++++++++++++++--- src/vscp/vscpworks/frmmain.h | 20 ++- 11 files changed, 251 insertions(+), 84 deletions(-) diff --git a/config_examples/variables.xml_distro b/config_examples/variables.xml_distro index 46b6ef7e5..5ec1e608a 100644 --- a/config_examples/variables.xml_distro +++ b/config_examples/variables.xml_distro @@ -40,7 +40,7 @@ SIM1_GUID0 GUID for the node. - FF:FF:FF:FF:FF:FF:FF:F7:03:00:00:00:00:00:00:00 + FF:FF:FF:FF:FF:FF:FF:F7:03:11:22:33:44:55:66:77 diff --git a/src/common/rapidxml/rapidxml.hpp b/src/common/rapidxml/rapidxml.hpp index 4d0f60523..15ecef615 100644 --- a/src/common/rapidxml/rapidxml.hpp +++ b/src/common/rapidxml/rapidxml.hpp @@ -514,7 +514,7 @@ namespace rapidxml Ch * nullstr() { - if (!m_nullstr); + if (!m_nullstr) m_nullstr = allocate_string(""); return m_nullstr; } diff --git a/src/vscp/common/daemonvscp.cpp b/src/vscp/common/daemonvscp.cpp index 043019a29..71f7a0e4d 100644 --- a/src/vscp/common/daemonvscp.cpp +++ b/src/vscp/common/daemonvscp.cpp @@ -278,6 +278,10 @@ void *daemonVSCPThread::Entry() } } + /////////////////////////////////////////////////////////////////////// + // Input queue + /////////////////////////////////////////////////////////////////////// + int rv = pClientItem->m_clientInputQueue.GetCount(); // Wait for incoming event if ( wxSEMA_TIMEOUT == pClientItem->m_semClientInputQueue.WaitTimeout( 100 ) ) continue; @@ -347,7 +351,7 @@ void *daemonVSCPThread::Entry() // New node on-line - collect else if ( ( VSCP_CLASS1_PROTOCOL == pEvent->vscp_class ) && - ( VSCP_TYPE_PROTOCOL_NEW_NODE_ONLINE == pEvent->vscp_type ) ) { + ( VSCP_TYPE_PROTOCOL_NEW_NODE_ONLINE == pEvent->vscp_type ) ) { // Add node to knows nodes or return info if known CNodeInformation *pNode = addNodeIfNotKnown( pEvent ); @@ -363,7 +367,7 @@ void *daemonVSCPThread::Entry() // Level I node heart beat - collect else if ( ( VSCP_CLASS1_INFORMATION == pEvent->vscp_class ) && - ( VSCP_TYPE_INFORMATION_NODE_HEARTBEAT == pEvent->vscp_type ) ) { + ( VSCP_TYPE_INFORMATION_NODE_HEARTBEAT == pEvent->vscp_type ) ) { // Add node to knows nodes or return info if known CNodeInformation *pNode = addNodeIfNotKnown( pEvent ); @@ -415,7 +419,7 @@ void *daemonVSCPThread::Entry() // Level II node heart beat - collect else if ( ( VSCP_CLASS2_INFORMATION == pEvent->vscp_class ) && - ( VSCP_TYPE_INFORMATION_NODE_HEARTBEAT == pEvent->vscp_type ) ) { + ( VSCP_TYPE_INFORMATION_NODE_HEARTBEAT == pEvent->vscp_type ) ) { // Send event on multicast information channel sendMulticastEvent( sock_mc, pEvent, mc_port ); @@ -492,18 +496,20 @@ CNodeInformation * daemonVSCPThread::addNodeIfNotKnown( vscpEvent *pEvent ) m_pCtrlObject->m_knownNodes.m_nodes[ strGUID ] = pNode; m_pCtrlObject->m_mutexKnownNodes.Unlock(); - // Is there a device realted to this node + // Is there a device related to this node m_pCtrlObject->m_mutexDeviceList.Lock(); CDeviceItem *pDeviceItem = m_pCtrlObject->m_deviceList.getDeviceItemFromClientId( pEvent->obid ); if ( NULL != pDeviceItem ) { - // Construct a name if no name set - // 'device.nickname' - if ( pNode->m_strNodeName.IsEmpty() ) { - pNode->m_strNodeName = pDeviceItem->m_strName; - pNode->m_strNodeName += _( "." ); - pNode->m_strNodeName += wxString::Format( _( "%lu" ), pDeviceItem->m_pClientItem->m_clientID ); + pNode->m_level = pDeviceItem->m_driverLevel; + + // Construct a devicename if no devicename set + // 'devicename_clientid' + if ( pNode->m_deviceName.IsEmpty() ) { + pNode->m_deviceName = pDeviceItem->m_strName; + pNode->m_deviceName += _( "_" ); + pNode->m_deviceName += wxString::Format( _( "%lu" ), pDeviceItem->m_pClientItem->m_clientID ); } // Save interface @@ -512,12 +518,12 @@ CNodeInformation * daemonVSCPThread::addNodeIfNotKnown( vscpEvent *pEvent ) // Save Client ID pNode->m_clientID = pEvent->obid; - // We set name fron client id - // 'client|clientid|.nickname' + // We set name from client id + // 'client_clientid_nickname' if ( pNode->m_strNodeName.IsEmpty() ) { - pNode->m_strNodeName = _( "client" ); + pNode->m_strNodeName = _( "client_" ); pNode->m_strNodeName += wxString::Format( _( "%lu" ), pDeviceItem->m_pClientItem->m_clientID ); - pNode->m_strNodeName += _( "." ); + pNode->m_strNodeName += _( "_" ); pNode->m_strNodeName += wxString::Format( _( "%u" ), ( pEvent->GUID[ 14 ] << 8 ) + pEvent->GUID[ 15 ] ); } @@ -541,11 +547,11 @@ CNodeInformation * daemonVSCPThread::addNodeIfNotKnown( vscpEvent *pEvent ) m_pCtrlObject->m_mutexDeviceList.Unlock(); // We set name fron client id - // 'client|clientid|.nickname' + // 'client_clientid_nickname' if ( pNode->m_strNodeName.IsEmpty() ) { - pNode->m_strNodeName = _( "client" ); + pNode->m_strNodeName = _( "client_" ); pNode->m_strNodeName += wxString::Format( _( "%lu" ), pClientItem->m_clientID ); - pNode->m_strNodeName += _( "." ); + pNode->m_strNodeName += _( "_" ); pNode->m_strNodeName += wxString::Format( _( "%u" ), ( pEvent->GUID[ 14 ] << 8 ) + pEvent->GUID[ 15 ] ); } @@ -723,6 +729,16 @@ bool daemonVSCPThread::sendMulticastInformationProxyEvent( int sock, // 28 - n data limited to max 512 - 25 = 487 bytes // len - 2 CRC MSB( Calculated on HEAD + CLASS + TYPE + ADDRESS + SIZE + DATA� ) // len - 1 CRC LSB + // + // Data + // ==================================================================================== + // 0-15 Real GUID for node (not interface GUID) + // 16-31 Reserved + // 32-47 GUID for interface on server the node is connected to. + // 48 Interface Level( 0 == Level I, 1 == Level II ) + // 49-63 Reserved + // 64-127 Real text name of node( if any ).Set to all zero if not available. + // 128-191 Real text name of interface ( if any ).Set to all zero if not available. // Packe type buf[ VSCP_MULTICAST_PACKET0_POS_PKTTYPE ] = SET_VSCP_MULTICAST_TYPE( VSCP_MULTICAST_TYPE_EVENT , VSCP_MULTICAST_ENCRYPTION_NONE ); @@ -754,32 +770,49 @@ bool daemonVSCPThread::sendMulticastInformationProxyEvent( int sock, // Originating GUID - Daemon GUID memcpy( buf + VSCP_MULTICAST_PACKET0_POS_VSCP_GUID, m_pCtrlObject->m_guid.m_id, 16 ); - // Size of payload = 128 bytes + // Size of payload buf[ VSCP_MULTICAST_PACKET0_POS_VSCP_SIZE + 0 ] = 0x00; - buf[ VSCP_MULTICAST_PACKET0_POS_VSCP_SIZE + 1 ] = 0x80; + buf[ VSCP_MULTICAST_PACKET0_POS_VSCP_SIZE + 1 ] = VSCP_MULTICAST_PROXY_HEARTBEAT_DATA_SIZE; - // Real GUID of node - memcpy( buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA, pNode->m_realguid.getGUID(), 16 ); + // Real GUID of node + memcpy( buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA, + pNode->m_realguid.getGUID(), + 16 ); - // Interface GUID of node - memcpy( buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + 32, pNode->m_interfaceguid.getGUID(), 16 ); + // Interface GUID of node + memcpy( buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + VSCP_MULTICAST_PROXY_HEARTBEAT_POS_IFGUID, + pNode->m_interfaceguid.getGUID(), + 16 ); + + buf[ VSCP_MULTICAST_PROXY_HEARTBEAT_POS_IFLEVEL ] = pNode->m_level; // Name of node - memcpy( buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + 64, - pNode->m_deviceName.mbc_str(), - MIN( 64, strlen( pNode->m_deviceName.mbc_str() ) ) ); + memcpy( buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + VSCP_MULTICAST_PROXY_HEARTBEAT_POS_NODENAME, + pNode->m_strNodeName.mbc_str(), + MIN( 64, strlen( pNode->m_strNodeName.mbc_str() ) ) ); + + // Name of interface node is on + memcpy( buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + VSCP_MULTICAST_PROXY_HEARTBEAT_POS_IFNAME, + pNode->m_deviceName.mbc_str(), + MIN( 64, strlen( pNode->m_deviceName.mbc_str() ) ) ); // CRC crcInit(); - crc chksum = crcFast( buf, VSCP_MULTICATS_PACKET0_HEADER_LENGTH + 128 ); + crc chksum = crcFast( buf, + VSCP_MULTICATS_PACKET0_HEADER_LENGTH + + VSCP_MULTICAST_PROXY_HEARTBEAT_DATA_SIZE ); wxUINT32_SWAP_ON_LE( chksum ); - buf[ VSCP_MULTICATS_PACKET0_HEADER_LENGTH + 128 + 0 ] = ( chksum >> 8 ) & 0xff; - buf[ VSCP_MULTICATS_PACKET0_HEADER_LENGTH + 128 + 1 ] = chksum & 0xff; + buf[ VSCP_MULTICATS_PACKET0_HEADER_LENGTH + + VSCP_MULTICAST_PROXY_HEARTBEAT_DATA_SIZE + 0 ] = ( chksum >> 8 ) & 0xff; + buf[ VSCP_MULTICATS_PACKET0_HEADER_LENGTH + + VSCP_MULTICAST_PROXY_HEARTBEAT_DATA_SIZE + 1 ] = chksum & 0xff; - return ( ( VSCP_MULTICATS_PACKET0_HEADER_LENGTH + 128 + 2 ) == + return ( ( VSCP_MULTICATS_PACKET0_HEADER_LENGTH + + VSCP_MULTICAST_PROXY_HEARTBEAT_DATA_SIZE + 2 ) == sendto( sock, (const char *)buf, - VSCP_MULTICATS_PACKET0_HEADER_LENGTH + 128 + 2, + VSCP_MULTICATS_PACKET0_HEADER_LENGTH + + VSCP_MULTICAST_PROXY_HEARTBEAT_DATA_SIZE + 2, 0, ( struct sockaddr * )&mc_addr, sizeof( mc_addr ) ) ); diff --git a/src/vscp/common/knownnodes.cpp b/src/vscp/common/knownnodes.cpp index a943225b0..6a963f8ce 100644 --- a/src/vscp/common/knownnodes.cpp +++ b/src/vscp/common/knownnodes.cpp @@ -140,6 +140,7 @@ CNodeInformation::CNodeInformation() m_strNodeName.Empty(); m_deviceName.Empty(); m_clientID = 0; + m_level = 0; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/vscp/common/knownnodes.h b/src/vscp/common/knownnodes.h index fa2769172..678b5d42f 100644 --- a/src/vscp/common/knownnodes.h +++ b/src/vscp/common/knownnodes.h @@ -138,6 +138,7 @@ class CNodeInformation m_strNodeName = node.m_strNodeName; m_deviceName = node.m_deviceName; m_address = node.m_address; + m_level = node.m_level; return *this; }; @@ -182,6 +183,9 @@ class CNodeInformation // IP/MAC/... address (if any) associated with the node wxString m_address; + // Node level 0=Level I, 1 = Level II + uint8_t m_level; + }; // GUID -> Node info diff --git a/src/vscp/common/version.h b/src/vscp/common/version.h index f5c5ba230..e7405d608 100644 --- a/src/vscp/common/version.h +++ b/src/vscp/common/version.h @@ -29,9 +29,9 @@ #define VSCPD_SUB_VERSION 0 -#define VSCPD_SUB_SUB_VERSION 4 +#define VSCPD_SUB_SUB_VERSION 5 -#define VSCPD_DISPLAY_VERSION "1.1.0.4 Sodium" +#define VSCPD_DISPLAY_VERSION "1.1.0.5 Sodium" #define VSCPD_COPYRIGHT "Copyright (C) 2000-2015, Paradise of the Frog AB, http://www.paradiseofthefrog.com" #define VSCPD_COPYRIGHT_HTML "Copyright (C) 2000-2015, Paradise of the Frog, http://www.paradiseofthefrog.com" diff --git a/src/vscp/common/vscp.h b/src/vscp/common/vscp.h index 55a747d99..d25c0175e 100644 --- a/src/vscp/common/vscp.h +++ b/src/vscp/common/vscp.h @@ -176,8 +176,8 @@ typedef unsigned short uint64_t; #define VSCP_MAX_DATA (512-25) -#define VSCP_LEVEL1 1 -#define VSCP_LEVEL2 2 +#define VSCP_LEVEL1 0 // Changed 151104 Was 1/2 +#define VSCP_LEVEL2 1 #ifdef __cplusplus extern "C" { @@ -399,6 +399,14 @@ typedef VSCPChannelInfo *PVSCPCHANNELINFO; #define GET_VSCP_MULTICAST_PACKET_TYPE( type) ( (type>>4) & 0x0f) #define GET_VSCP_MULTICAST_PACKET_ENCRYPTION( type) ( (type) & 0x0f) +// Multicast proxy CLASS=1026, TYPE=3 http://www.vscp.org/docs/vscpspec/doku.php?id=class2.information#type_3_0x0003_level_ii_proxy_node_heartbeat +#define VSCP_MULTICAST_PROXY_HEARTBEAT_DATA_SIZE 192 +#define VSCP_MULTICAST_PROXY_HEARTBEAT_POS_REALGUID 0 // The real GUID for the node +#define VSCP_MULTICAST_PROXY_HEARTBEAT_POS_IFGUID 32 // GUID for interface node is on +#define VSCP_MULTICAST_PROXY_HEARTBEAT_POS_IFLEVEL 48 // 0=Level I node, 1=Level II node +#define VSCP_MULTICAST_PROXY_HEARTBEAT_POS_NODENAME 64 // Name of node +#define VSCP_MULTICAST_PROXY_HEARTBEAT_POS_IFNAME 128 // Name of interface + // Bootloaders #define VSCP_BOOTLOADER_VSCP 0x00 // VSCP boot loader algorithm #define VSCP_BOOTLOADER_PIC1 0x01 // PIC algorithm 0 diff --git a/src/vscp/common/vscpmulticast.cpp b/src/vscp/common/vscpmulticast.cpp index b0e7bbc27..a7385ca26 100644 --- a/src/vscp/common/vscpmulticast.cpp +++ b/src/vscp/common/vscpmulticast.cpp @@ -250,7 +250,7 @@ void *worksMulticastThread::Entry() break; }*/ - originatingAddress.FromAscii( s ); + originatingAddress = wxString::FromAscii( s ); //free( s ); #else char *s = NULL; @@ -343,25 +343,33 @@ void *worksMulticastThread::Entry() // This will use the correct GUID as originator + // GUID is sending nodes/servers GUID + // For a Level I node connected to a server this is the GUID for the server. cguid guid; - // Interface GUID is used as identifier - guid.getFromArray( ( unsigned const char * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + 32 ); - CNodeInformation *pNode = m_knownNodes.addNode( guid ); + guid.getFromArray( ( unsigned const char * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_GUID ); + + // Interface GUID is the GUID the node uses. This is not the real GUID of a node + // but instead a GUID constructed from the interface the node is on. But this is the + // GUID the node is identified as here so it is used as identifier for the node. + cguid ifguid; + ifguid.getFromArray( ( unsigned const char * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + 32 ); + + CNodeInformation *pNode = m_knownNodes.addNode( ifguid ); if ( NULL != pNode ) { // Not a proxy pNode->m_bProxy = true; // Save the nodes real GUID - guid.getFromArray( ( unsigned const char * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA ); - if ( !guid.isNULL() ) { + cguid realguid; + realguid.getFromArray( ( unsigned const char * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA ); + if ( !realguid.isNULL() ) { pNode->m_realguid = guid; } // Save the nodes interface GUID - guid.getFromArray( ( unsigned const char * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + 32 ); - if ( !guid.isNULL() ) { - pNode->m_interfaceguid = guid; + if ( !ifguid.isNULL() ) { + pNode->m_interfaceguid = ifguid; } // Time for last heatbeat @@ -373,17 +381,23 @@ void *worksMulticastThread::Entry() memcpy( wrkbuf, ( unsigned const char * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + 64, 64 ); pNode->m_strNodeName = wxString::FromUTF8( ( const char * )wrkbuf ); - // Save Name for interface this node is on + // If the node does not have a name give it one + if ( 0 == pNode->m_strNodeName.Length() ) { + wxString wxstr; + guid.toString( wxstr ); + pNode->m_strNodeName = _("Node without name @ "); + pNode->m_strNodeName += wxstr; + pNode->m_strNodeName += _(" IP="); + pNode->m_strNodeName += originatingAddress; + } + + // Save name for interface this node is on // Save the servers address pNode->m_address = originatingAddress; - // Get server GUID - guid.getFromArray( ( uint8_t * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_GUID ); - } - } // Server capabilities else if ( ( VSCP_CLASS2_PROTOCOL == vscp_class ) && diff --git a/src/vscp/drivers/level2/sim/common/simulation.cpp b/src/vscp/drivers/level2/sim/common/simulation.cpp index 2efd0d72d..d0aca6df1 100644 --- a/src/vscp/drivers/level2/sim/common/simulation.cpp +++ b/src/vscp/drivers/level2/sim/common/simulation.cpp @@ -1387,7 +1387,7 @@ CWrkTread::Entry() } - } + } // while return NULL; diff --git a/src/vscp/vscpworks/frmmain.cpp b/src/vscp/vscpworks/frmmain.cpp index b826d110d..de4fcbcff 100644 --- a/src/vscp/vscpworks/frmmain.cpp +++ b/src/vscp/vscpworks/frmmain.cpp @@ -150,15 +150,36 @@ void RenderTimer::Notify() CNodeInformation *pNodeInfo = it->second; if ( NULL != pNodeInfo ) { - nodeClientData *pNode = new nodeClientData( pNodeInfo ); - if ( NULL != pNode ) { - m_pwnd->m_nodeTree->AppendItem( m_pwnd->m_moduleNodeItem, pNodeInfo->m_strNodeName, MDF_EDITOR_SUB_ITEM ); + + if ( !pNodeInfo->m_bUpdated ) { + + nodeClientData *pNode = new nodeClientData( CLIENT_NODE ); + if ( NULL != pNode ) { + + pNode->m_nodeInformation = *pNodeInfo; + + if ( pNodeInfo->m_strNodeName.Length() ) { + m_pwnd->m_nodeTree->AppendItem( m_pwnd->m_moduleNodeItem, + pNodeInfo->m_strNodeName, + MDF_EDITOR_SUB_ITEM, + -1, + pNode ); + } + else { + m_pwnd->m_nodeTree->AppendItem( m_pwnd->m_moduleNodeItem, + _( "Node without name." ), + MDF_EDITOR_SUB_ITEM, + -1, + pNode ); + } + + pNodeInfo->m_bUpdated = true; + + } } } } - - // Update numbers m_nLastKnownNodes = m_multicastThread->m_knownNodes.m_nodes.size(); @@ -176,9 +197,32 @@ void RenderTimer::Notify() CVSCPServerInformation *pNodeInfo = it->second; if ( NULL != pNodeInfo ) { - serverClientData *pServer = new serverClientData( pNodeInfo ); - if ( NULL != pServer ) { - m_pwnd->m_nodeTree->AppendItem( m_pwnd->m_moduleServerItem, pNodeInfo->m_nameOfServer, MDF_EDITOR_SUB_ITEM ); + + if ( !pNodeInfo->m_bUpdated ) { + + nodeClientData *pServer = new nodeClientData( CLIENT_SERVER ); + if ( NULL != pServer ) { + + pServer->m_serverInformation = *pNodeInfo; + + if ( pNodeInfo->m_nameOfServer.Length() ) { + m_pwnd->m_nodeTree->AppendItem( m_pwnd->m_moduleServerItem, + pNodeInfo->m_nameOfServer, + MDF_EDITOR_SUB_ITEM, + -1, + pServer ); + } + else { + m_pwnd->m_nodeTree->AppendItem( m_pwnd->m_moduleServerItem, + _( "Server without name." ), + MDF_EDITOR_SUB_ITEM, + -1, + pServer ); + } + + pNodeInfo->m_bUpdated = true; + + } } } @@ -427,7 +471,7 @@ void frmMain::CreateControls() m_htmlInfoWnd = new wxHtmlWindow; m_htmlInfoWnd->Create( itemPanel, ID_HTMLWINDOW2, wxDefaultPosition, wxSize( -1, 150 ), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL ); - m_htmlInfoWnd->SetPage( _( "

Node information

This area will contain extended information about known (discovered) nodes. This is work in progress sp information is static at the moment." ) ); + m_htmlInfoWnd->SetPage( _( "

Node information

This area will contain extended information about known (discovered) nodes. This is work in progress so information is sparse (and may be wrong) at the moment. Click on a discovered node to display info about it in this area." ) ); itemSizerVertical->Add( m_htmlInfoWnd, 0, wxGROW | wxALL, 5 ); // Connect events and objects @@ -554,20 +598,79 @@ void frmMain::OnPaint( wxPaintEvent& event ) void frmMain::OnTreectrlSelChanged( wxTreeEvent& event ) { - /*wxString strPage; - strPage = _( "

" ); - wxTreeItemId itemID = event.GetItem(); - //MyTreeItemData *item = itemId.IsOk() ? (MyTreeItemData *)GetItemData(itemId) - // : NULL; - if ( itemID.IsOk() ) { - strPage += m_mdfTree->GetItemText( itemID ); - strPage += event.GetLabel(); - } - else { - strPage += _( "????" ); + wxTreeItemId itemId = event.GetItem(); + nodeClientData *item = ( nodeClientData * )m_nodeTree->GetItemData( itemId ); + + if ( item != NULL ) { + + wxString str; + wxString page; + + if ( CLIENT_SERVER == item->m_type ) { + page = _( "

Hi-end Node Information

" ); + } + else if ( CLIENT_NODE == item->m_type ) { + page = _( "

Node information

" ); + + if ( VSCP_LEVEL1 == item->m_nodeInformation.m_level ) { + page += _( "Level: 1
" ); + } + else if ( VSCP_LEVEL2 == item->m_nodeInformation.m_level ) { + page += _( "Level: 2
" ); + } + + page += _( "Last heartbeat: " ); + page += item->m_nodeInformation.m_lastHeartBeat.FormatISODate(); + page += _( " " ); + page += item->m_nodeInformation.m_lastHeartBeat.FormatISOTime(); + page += _( "
" ); + + page += _( "Node name: " ); + if ( item->m_nodeInformation.m_strNodeName.Length() ) { + page += item->m_nodeInformation.m_strNodeName; + } + else { + page += _("No name set."); + } + page += _( "
" ); + + page += _( "Device name: " ); + if ( item->m_nodeInformation.m_deviceName.Length() ) { + page += item->m_nodeInformation.m_deviceName; + } + else { + page += _( "No name set." ); + } + page += _( "
" ); + + page += _( "Received from address: " ); + page += item->m_nodeInformation.m_address; + page += _( "
" ); + + item->m_nodeInformation.m_realguid.toString( str ); + page += _( "GUID: " ); + page += str; + page += _( "
" ); + + item->m_nodeInformation.m_interfaceguid.toString( str ); + page += _( "Interface GUID: " ); + page += str; + page += _( "
" ); + + page += _( "Proxy: " ); + if ( item->m_nodeInformation.m_bProxy ) { + page += _( "Yes" ); + } + else { + page += _( "No" ); + } + page += _( "
" ); + + } + + m_htmlInfoWnd->SetPage( page ); } - strPage += _( "" ); - m_htmlInfoWnd->SetPage( strPage );*/ + event.Skip(); } @@ -601,10 +704,10 @@ void frmMain::addDefaultContent( void ) { m_rootItem = m_nodeTree->AddRoot( _( "VSCP Network neighbourhood" ), MDF_EDITOR_TOP_ITEM ); m_moduleServerItem = m_nodeTree->AppendItem( m_rootItem, _( "High end nodes" ), MDF_EDITOR_MAIN_ITEM ); - m_nodeTree->AppendItem( m_moduleServerItem, _( "Node" ), MDF_EDITOR_SUB_ITEM ); + //m_nodeTree->AppendItem( m_moduleServerItem, _( "Node" ), MDF_EDITOR_SUB_ITEM ); m_moduleNodeItem = m_nodeTree->AppendItem( m_rootItem, _( "Known nodes" ), MDF_EDITOR_MAIN_ITEM ); - m_nodeTree->AppendItem( m_moduleNodeItem, _( "Node" ), MDF_EDITOR_SUB_ITEM ); + //m_nodeTree->AppendItem( m_moduleNodeItem, _( "Node" ), MDF_EDITOR_SUB_ITEM ); //m_moduleItem = m_mdfTree->AppendItem( m_rootItem, _( "WEB interface" ), MDF_EDITOR_MAIN_ITEM ); //m_moduleItem = m_mdfTree->AppendItem( m_rootItem, _( "Level II node" ), MDF_EDITOR_MAIN_ITEM ); diff --git a/src/vscp/vscpworks/frmmain.h b/src/vscp/vscpworks/frmmain.h index 531f74566..232c5ba75 100644 --- a/src/vscp/vscpworks/frmmain.h +++ b/src/vscp/vscpworks/frmmain.h @@ -77,11 +77,16 @@ // Forward declarations class frmMain; +enum clientdatatype { + CLIENT_SERVER = 0, + CLIENT_NODE +}; + /////////////////////////////////////////////////////////////////////////////// // serverClientData // -class serverClientData : public wxTreeItemData +/*class serverClientData : public wxTreeItemData { public: @@ -93,7 +98,7 @@ class serverClientData : public wxTreeItemData }; CVSCPServerInformation m_serverInformation; -}; +};*/ /////////////////////////////////////////////////////////////////////////////// // nodeClientData @@ -104,21 +109,20 @@ class nodeClientData : public wxTreeItemData public: - nodeClientData( CNodeInformation* pnode ) + nodeClientData( clientdatatype type ) : wxTreeItemData() { - m_nodeInformation = *pnode; + m_type = type; }; public: + clientdatatype m_type; + CNodeInformation m_nodeInformation; + CVSCPServerInformation m_serverInformation; }; -//YourTreeClientData *d = new YourTreeClientData(); -//d->SetRefClass( YourClass ); - -//m_treeCtrl->AppendItem( parent_id, wxT( "Hello" ), -1, -1, d ); /////////////////////////////////////////////////////////////////////////////// // RenderTimer