eVolve.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "eVolve.h"
00019
00020 #include "config.h"
00021 #include "localInitData.h"
00022
00023 #include <stdlib.h>
00024
00025 using namespace std;
00026
00027 namespace eVolve
00028 {
00029
00030 EVolve::EVolve( const LocalInitData& initData )
00031 : _initData( initData )
00032 {}
00033
00034 int EVolve::run()
00035 {
00036
00037 eq::ServerPtr server = new eq::Server;
00038 if( !connectServer( server ))
00039 {
00040 EQERROR << "Can't open server" << endl;
00041 return EXIT_FAILURE;
00042 }
00043
00044
00045 eq::ConfigParams configParams;
00046 Config* config = static_cast<Config*>(server->chooseConfig( configParams ));
00047
00048 if( !config )
00049 {
00050 EQERROR << "No matching config on server" << endl;
00051 disconnectServer( server );
00052 return EXIT_FAILURE;
00053 }
00054
00055
00056 eq::base::Clock clock;
00057
00058 config->setInitData( _initData );
00059 if( !config->init( ))
00060 {
00061 EQERROR << "Config initialization failed: "
00062 << config->getErrorMessage() << endl;
00063 server->releaseConfig( config );
00064 disconnectServer( server );
00065 return EXIT_FAILURE;
00066 }
00067
00068 EQLOG( LOG_STATS ) << "Config init took " << clock.getTimef() << " ms"
00069 << endl;
00070
00071
00072 uint32_t maxFrames = _initData.getMaxFrames();
00073
00074 clock.reset();
00075 while( config->isRunning( ) && maxFrames-- )
00076 {
00077 config->startFrame();
00078 config->finishFrame();
00079 }
00080 const uint32_t frame = config->finishAllFrames();
00081 const float time = clock.getTimef();
00082 EQLOG( LOG_STATS ) << "Rendering took " << time << " ms (" << frame
00083 << " frames @ " << ( frame / time * 1000.f) << " FPS)"
00084 << endl;
00085
00086
00087 clock.reset();
00088 config->exit();
00089 EQLOG( LOG_STATS ) << "Exit took " << clock.getTimef() << " ms" <<endl;
00090
00091
00092 server->releaseConfig( config );
00093 if( !disconnectServer( server ))
00094 EQERROR << "Client::disconnectServer failed" << endl;
00095 server = 0;
00096
00097 return EXIT_SUCCESS;
00098 }
00099
00100 bool EVolve::clientLoop()
00101 {
00102 if( !_initData.isResident( ))
00103 return eq::Client::clientLoop();
00104
00105
00106 while( true )
00107 {
00108 if( !eq::Client::clientLoop( ))
00109 return false;
00110 EQINFO << "One configuration run successfully executed" << endl;
00111 }
00112 return true;
00113 }
00114 }