Changeset 183 for osgVisual


Ignore:
Timestamp:
Jan 7, 2011, 5:41:45 PM (13 years ago)
Author:
Torben Dannhauer
Message:

XML configuration now works also with dataIO cluster

Location:
osgVisual/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/CMakeLists.txt

    r181 r183  
    195195
    196196# Module cluster
     197SET(SOURCES
     198        ${SOURCES}
     199        include/cluster/dataIO_cluster.h
     200        include/cluster/dataIO_clusterDummy.h
     201        src/cluster/dataIO_clusterDummy.cpp
     202)
    197203SET(USE_CLUSTER_ASIO_TCP_IOSTREAM OFF CACHE BOOL "Enable to use the Boost ASIO TCP iostream implementation for the cluster interface")
    198204SET(USE_CLUSTER_ENET ON CACHE BOOL "Enable to use the ENet reliable UDP library implementation for the cluster interface")
     
    200206                SET(SOURCES
    201207                        ${SOURCES}
    202                         include/cluster/dataIO_cluster.h
    203208                        include/cluster/dataIO_clusterAsioTcpIostream.h
    204209                        src/cluster/dataIO_clusterAsioTcpIostream.cpp
     
    218223                SET(SOURCES
    219224                        ${SOURCES}
    220                         include/cluster/dataIO_cluster.h
    221225                        include/cluster/dataIO_clusterENet.h
    222226                        src/cluster/dataIO_clusterENet.cpp
     
    242246                        include/cluster/enet/win32.h
    243247                )
    244                 ADD_DEFINITIONS( "-DUSE_CLUSTER_ENET" )
    245                
    246 ENDIF()
    247 
    248 IF(NOT USE_CLUSTER_ASIO_TCP_IOSTREAM AND NOT USE_CLUSTER_ENET)
    249                 SET(SOURCES
    250                         ${SOURCES}
    251                         include/cluster/dataIO_cluster.h
    252                         include/cluster/dataIO_clusterDummy.h
    253                         src/cluster/dataIO_clusterDummy.cpp
    254                 )
    255                 ADD_DEFINITIONS( "-DUSE_CLUSTER_DUMMY" )
    256 ENDIF()
     248                ADD_DEFINITIONS( "-DUSE_CLUSTER_ENET" )
     249ENDIF()
     250
     251
    257252
    258253
     
    260255SET(SOURCES
    261256        ${SOURCES}
     257        include/extLink/dataIO_extLinkDummy.h
     258        src/extLink/dataIO_extLinkDummy.cpp
    262259        include/extLink/dataIO_extLink.h
    263260        include/extLink/manip_extLink.h
     
    277274                #Linking: VCL uses #pragma to link, no need for linking configuration in CMAKE
    278275        ELSE(USE_EXTLINK_VCL)
    279                 SET(SOURCES
    280                         ${SOURCES}
    281                         include/extLink/dataIO_extLinkDummy.h
    282                         src/extLink/dataIO_extLinkDummy.cpp
    283                 )
    284276                UNSET(EXTLINK_VCL_INCLUDE_DIR CACHE)
    285                 ADD_DEFINITIONS( "-DUSE_EXTLINK_DUMMY" )
    286277        ENDIF(USE_EXTLINK_VCL)
    287278ELSE(WIN32)
    288279        UNSET(EXTLINK_VCL_INCLUDE_DIR CACHE)
    289         SET(SOURCES
    290                 ${SOURCES}
    291                 include/extLink/dataIO_extLinkDummy.h
    292                 src/extLink/dataIO_extLinkDummy.cpp
    293         )
    294         ADD_DEFINITIONS( "-DUSE_EXTLINK_DUMMY" )
     280
     281
    295282ENDIF(WIN32)
    296283
  • osgVisual/trunk/bin/osgVisualConfig.xml

    r160 r183  
    1616    <!-- optional: <blendmap filename="blendmap.png"></blendmap> to set blendmap independend from channel map -->
    1717  </module>
     18 
    1819  <module name="sky_silverlining" enabled="yes"></module>
     20
    1921  <module name="vista2d" enabled="yes">
    2022    <vista2d filename="D:\osgVisual\osgVisual\bin\altimeterSimple.v" paintBackground="no" position_x="1" position_y="1" zoom="1.0" playanimation="yes"></vista2d>
    2123  </module>
     24
    2225  <module name="dataio" enabled="yes">
    2326    <!-- XML configuration of the module "dataIO"
     27        The parameter "enabled" is ignored, because dataIO is mandatory for the visual system to place object etc.
     28       
    2429        Available clusterroles:
    2530        master: This role recieves all relevant information via the extLink implementation and sends it via cluster implementation to the slave nodes.
    2631        slave: This role recieves all relevant rendering information via the cluster implementation.
    27         standalone: This role recieves all relevant data via the extLink and renders it. No cluster functionality is used.
     32        standalone: This role recieves all relevant data via the extLink and renders it. No cluster functionality is used.   
    2833    -->
    2934    <dataio clusterrole="standalone"></dataio>
    30     <cluster implementation="enet" master_ip="10.10.10.10" port="1234" use_zlib_compressor="yes" ></cluster>
     35    <cluster implementation="enet" hardsync="yes" master_ip="10.10.10.10" port="1234" use_zlib_compressor="yes" ></cluster>
    3136    <extlink implementation="vcl" filename="osgVisual.xml"></extlink>
    3237  </module>
  • osgVisual/trunk/include/cluster/dataIO_cluster.h

    r89 r183  
    2222
    2323#include "dataIO_transportContainer.h"
     24
     25// XML Parser
     26#include <stdio.h>
     27#include <libxml/parser.h>
     28#include <libxml/tree.h>
    2429
    2530
     
    4853         *
    4954         */
    50         dataIO_cluster() {}
     55        dataIO_cluster():hardSync(false) {}
    5156
    5257        /**
     
    6166         *
    6267         */
    63         virtual void init( osg::ArgumentParser& arguments_, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ ) = 0;
     68        virtual bool init( xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_) = 0;
    6469
    65         void enableHardSync(bool hardSync_){hardSync=hardSync_;};
     70        virtual bool processXMLConfiguration(xmlNode* clusterConfig_) = 0;
    6671       
    6772        bool isHardSyncEnabled(){return hardSync;};
     
    127132        int port;
    128133        bool hardSync;
     134        bool compressionEnabled; // to indicate if OSGs compression alorithm should be used.
    129135
    130136        /**
  • osgVisual/trunk/include/cluster/dataIO_clusterDummy.h

    r59 r183  
    3838        virtual ~dataIO_clusterDummy(void);
    3939
    40         void init( osg::ArgumentParser& arguments_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ );
     40        bool init(xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_);
     41        bool processXMLConfiguration(xmlNode* clusterConfig_);
    4142        void shutdown();
    4243
    4344        void init();
    44         bool sendTO_OBJvaluesToSlaves();
     45        bool sendTO_OBJvaluesToSlaves(osg::Matrixd viewMatrix_);
    4546        bool readTO_OBJvaluesFromMaster();
    4647        void reportAsReadyToSwap();
  • osgVisual/trunk/include/cluster/dataIO_clusterENet.h

    r89 r183  
    4444        virtual ~dataIO_clusterENet(void);
    4545
    46         void init( osg::ArgumentParser& arguments_, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ );
     46        bool init(xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_);
     47        bool processXMLConfiguration(xmlNode* clusterConfig_);
    4748        void shutdown();
    4849
  • osgVisual/trunk/include/dataIO/visual_dataIO.h

    r160 r183  
    2626
    2727// Cluster
     28#include <dataIO_clusterDummy.h>
    2829#ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
    2930        #include <dataIO_clusterAsioTcpIostream.h>
     
    3233        #include <dataIO_clusterENet.h>
    3334#endif
    34 #ifdef USE_CLUSTER_DUMMY
    35         #include <dataIO_clusterDummy.h>
    36 #endif
     35       
     36
    3737
    3838
    3939//ExtLink
    40 #ifdef USE_EXTLINK_DUMMY
    41         #include <dataIO_extLinkDummy.h>
    42 #endif
     40#include <dataIO_extLinkDummy.h>
    4341#ifdef USE_EXTLINK_VCL
    4442        #include <dataIO_extLinkVCL.h>
     
    135133         * @return : True if parsing was successful.
    136134         */
    137         bool processXMLConfiguration();
     135        bool processXMLConfiguration(xmlNode* extLinkConfig_);
    138136
    139137        /**
  • osgVisual/trunk/src/cluster/dataIO_clusterDummy.cpp

    r59 r183  
    2929}
    3030
    31 void dataIO_clusterDummy::init( osg::ArgumentParser& arguments_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ )
     31bool dataIO_clusterDummy::init(xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_)
    3232{
    3333        sendContainer = sendContainer_;
    3434        OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy init();" << std::endl;
     35        return true;
     36}
     37
     38bool dataIO_clusterDummy::processXMLConfiguration(xmlNode* clusterConfig_)
     39{
     40        OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy processXMLConfiguration();" << std::endl;
     41        return true;
    3542}
    3643
     
    4047}
    4148
    42 bool dataIO_clusterDummy::sendTO_OBJvaluesToSlaves()
     49bool dataIO_clusterDummy::sendTO_OBJvaluesToSlaves(osg::Matrixd viewMatrix_)
    4350{
    4451        OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy sendTO_OBJvaluesToSlaves()" << std::endl;
  • osgVisual/trunk/src/cluster/dataIO_clusterENet.cpp

    r88 r183  
    3535
    3636
    37 void dataIO_clusterENet::init( osg::ArgumentParser& arguments_, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ )
    38 {
     37bool dataIO_clusterENet::init(xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_)
     38{
     39        if (!configurationNode || !processXMLConfiguration(configurationNode))
     40                return false;
     41
    3942        OSG_NOTIFY( osg::ALWAYS ) << "clusterENet init();" << std::endl;
    4043       
     
    5659                writeOptionString = "Ascii";
    5760        }
    58         if (compressionEnabled_)
     61        if (compressionEnabled)
    5962                writeOptionString+=" Compressor=zlib";
    6063        readOptions = new osgDB::Options( readOptionString.c_str() );
     
    7780        if(clusterMode == SLAVE)
    7881        {
    79                 // Get the server IP
    80                 if(!arguments_.read("--server",serverToConnect, port))
    81                 {
    82                         // try server discovery
    83                         //discoverServer(serverToConnect,port);
    84                         /* todo : implement a udp server discovery based on ASIO */
    85                 }
    86 
    8782                // Init ENet
    8883                enet_impl->init(dataIO_clusterENet_implementation::CLIENT, port);
     
    105100                        initialized = false;
    106101                        std::cout << "Finally failed to establish connection to server " << serverToConnect << std::endl;
    107                         exit(-1);
     102                        return false;
    108103                }
    109104        }       // IF SLAVE END
     105
     106        return true;
     107}
     108
     109bool dataIO_clusterENet::processXMLConfiguration(xmlNode* clusterConfig_)
     110{
     111                                // Extract cluster role
     112                                xmlAttr  *attr = clusterConfig_->properties;
     113                                while ( attr )
     114                                {
     115                                        std::string attr_name=reinterpret_cast<const char*>(attr->name);
     116                                        std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     117                                        if( attr_name == "implementation" )
     118                                        {
     119                                                if(attr_value != "enet")
     120                                                {
     121                                                        OSG_NOTIFY( osg::ALWAYS ) << "WARNING: Cluster configuration does not match the 'enet' implementation, falling back to clusterDummy" << std::endl;
     122                                                        return false;
     123                                                }
     124                                        }
     125                                        if( attr_name == "hardsync" )
     126                                        {
     127                                                if(attr_value == "yes")
     128                                                        hardSync = true;
     129                                                else
     130                                                        hardSync = false;
     131                                        }
     132                                        if( attr_name == "master_ip" )
     133                                        {
     134                                                serverToConnect = attr_value;
     135                                        }
     136                                        if( attr_name == "port" )
     137                                        {
     138                                                std::istringstream i(attr_value);
     139                                                if (!(i >> port))
     140                                                {
     141                                                        OSG_NOTIFY( osg::ALWAYS ) << "WARNING: Cluster configuration : Invalid port number '" << attr_value << "', falling back to clusterDummy" << std::endl;
     142                                                        return false;
     143                                                }
     144                                        }
     145                                        if( attr_name == "use_zlib_compressor" )
     146                                        {
     147                                                if(attr_value == "yes")
     148                                                        compressionEnabled = true;
     149                                                else
     150                                                        compressionEnabled = false;
     151                                        }
     152                                        attr = attr->next;
     153                                }       // WHILE attrib END
     154
     155        return true;
    110156}
    111157
  • osgVisual/trunk/src/dataIO/visual_dataIO.cpp

    r160 r183  
    4949void visual_dataIO::init(osgViewer::Viewer* viewer_, osg::ArgumentParser& arguments_, std::string configFileName)
    5050{
    51         OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO initialize.." << std::endl;
     51        OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO initialize..";
    5252
    5353        // Init variables
     
    5656        // Process XML configuration
    5757        this->configFileName = configFileName;
    58         if(!processXMLConfiguration())
     58        xmlNode *extLinkConfig=NULL;
     59        if(!processXMLConfiguration(extLinkConfig))
    5960                OSG_FATAL << "ERROR: visual_dataIO::init() - Failed to initialize dataIO via XML configuration!";
    60 
    61 
    62         // Create Cluster.
    63         #ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
    64                 cluster = new dataIO_clusterAsioTcpIostream();
    65         #endif
    66         #ifdef USE_CLUSTER_ENET
    67                 cluster = new dataIO_clusterENet();
    68                 cluster->enableHardSync( false );       /** \todo : rebuild this structure in cluster.h and move it this way to a general implementation. */
    69         #endif
    70         #ifdef USE_CLUSTER_DUMMY
    71                 cluster = new dataIO_clusterDummy();
    72         #endif
    73         if(cluster.valid())
    74                 //cluster->init(arguments_, clusterMode, slotContainer, true, false);
    75                 cluster->init(arguments_, viewer_, clusterMode, slotContainer, false, false);
    7661
    7762        // Create extLink.
     
    8570
    8671       
    87 
    8872        // Install callbacks to perform DataIO activities every frame:
    8973        //// EventCallback at the absolute beginning of the frame
     
    9781}
    9882
    99 bool visual_dataIO::processXMLConfiguration()
     83bool visual_dataIO::processXMLConfiguration(xmlNode* extLinkConfig_)
    10084{
    10185        // Init XML
     
    10387        bool disabled;
    10488        xmlNode* config = util::getModuleXMLConfig( configFileName, "dataio", tmpDoc, disabled );
     89        xmlNode* clusterConfig = NULL;
    10590
    10691        if( disabled)
    10792                OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file. dataIO can't be disabled. Ignoring." << std::endl;
     93        else
     94                OSG_NOTIFY( osg::ALWAYS ) << std::endl;
    10895
    10996        // extract configuration values
     
    152139                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "cluster")
    153140                        {
    154                                 // Check Attributes to determine if the dummy implementation or any other implementation must be instantiated
    155 
    156                                 // Pass XML attributes to cluster to analyse and configure it by cluster itself
     141                                // Pass cluster configuration to the used cluster implementation.
     142                                // The implementation will use the configuration if it matches, otherwise falls back to dummy cluster
     143                                clusterConfig = cur_node;
    157144                        }
    158145
     
    166153
    167154                }       // FOR all nodes END
     155
     156
     157
     158                // Create Cluster.
     159                #ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
     160                        cluster = new dataIO_clusterAsioTcpIostream();
     161                #endif
     162                #ifdef USE_CLUSTER_ENET
     163                        cluster = new dataIO_clusterENet();
     164                #endif
     165                if( !cluster.valid() || !clusterConfig || !cluster->init(clusterConfig, viewer, clusterMode, slotContainer, false) )
     166                {
     167                        cluster = new dataIO_clusterDummy();
     168                        cluster->init(clusterConfig, viewer, clusterMode, slotContainer, false);
     169                }
     170
     171
    168172
    169173                // clean up
     
    176180                return false;
    177181        }
    178 
    179182        return true;
    180183}
  • osgVisual/trunk/src/sky_Silverlining/visual_skySilverLining.cpp

    r182 r183  
    2121visual_skySilverLining::visual_skySilverLining(osgViewer::Viewer* viewer_, std::string configFileName, bool& disabled)
    2222{
    23         OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_skySilverlining...";
     23        OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_skySilverlining..." << std::endl;
    2424
    2525        atmosphereInitialized = false;
     
    4141        if( disabled)
    4242                OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file." << std::endl;
    43         else
    44                 OSG_NOTIFY( osg::ALWAYS ) << std::endl;
     43 
    4544        if(config)
    4645                xmlFreeDoc(tmpDoc); xmlCleanupParser();
Note: See TracChangeset for help on using the changeset viewer.