void * solver_setup_thread_fun( void *data ) #endif { solverpair *sp = ( solverpair * ) data; VSPAEROMgrSingleton* vsmgr = sp->first; VSPAEROScreen *vsscreen = sp->second; if( vsmgr && vsscreen ) { vsscreen->m_SolverSetupThreadIsRunning = true; // EXECUTE SOLVER vsmgr->CreateSetupFile(); // Read setup file vsscreen->ReadSetup(); vsscreen->m_SolverSetupThreadIsRunning = false; vsscreen->GetScreenMgr()->SetUpdateFlag( true ); } return 0; }
void * monitorfun( void *data ) #endif { monitorpair *mp = ( monitorpair * ) data; VSPAEROScreen *vs = mp->first; int id = mp->second; if( vs ) { Fl_Text_Display *display = vs->GetDisplay( id ); ProcessUtil *pu = vs->GetProcess( id ); if( pu && display ) { int bufsize = 1000; char *buf; buf = ( char* ) malloc( sizeof( char ) * ( bufsize + 1 ) ); unsigned long nread = 1; bool runflag = pu->IsRunning(); while( runflag || nread > 0 ) { nread = 0; pu->ReadStdoutPipe( buf, bufsize, &nread ); if( nread > 0 ) { buf[nread] = 0; StringUtil::change_from_to( buf, '\r', '\n' ); Fl::lock(); // Any FL calls must occur between Fl::lock() and Fl::unlock(). vs->AddOutputText( display, buf ); Fl::unlock(); } if( runflag ) { SleepForMilliseconds( 100 ); } runflag = pu->IsRunning(); } #ifdef WIN32 CloseHandle( pu->m_StdoutPipe[0] ); pu->m_StdoutPipe[0] = NULL; #else close( pu->m_StdoutPipe[0] ); pu->m_StdoutPipe[0] = -1; #endif vs->GetScreenMgr()->SetUpdateFlag( true ); free( buf ); } } return 0; }
//==== Message Callbacks ====// void ScreenMgr::MessageCallback( const MessageBase* from, const MessageData& data ) { if ( data.m_String == string( "UpdateAllScreens" ) ) { SetUpdateFlag( true ); } else if ( data.m_String == string( "VSPAEROSolverMessage" ) ) { VSPAEROScreen* scr = ( VSPAEROScreen* ) m_ScreenVec[VSP_VSPAERO_SCREEN]; if ( scr ) { for ( int i = 0; i < (int)data.m_StringVec.size(); i++ ) { scr->AddOutputText( scr->GetDisplay( VSPAERO_SOLVER ), data.m_StringVec[i] ); } } } else if ( data.m_String == string( "FEAMessage" ) ) { StructScreen* scr = ( StructScreen* ) m_ScreenVec[VSP_STRUCT_SCREEN]; if ( scr ) { for ( int i = 0; i < (int)data.m_StringVec.size(); i++ ) { scr->AddOutputText( data.m_StringVec[i] ); } } } else if ( data.m_String == string( "CFDMessage" ) ) { CfdMeshScreen* scr = (CfdMeshScreen*)m_ScreenVec[VSP_CFD_MESH_SCREEN]; if ( scr ) { for ( int i = 0; i < (int)data.m_StringVec.size(); i++ ) { scr->AddOutputText( data.m_StringVec[i] ); } } } else if ( data.m_String == string( "SurfIntersectMessage" ) ) { SurfaceIntersectionScreen* scr = (SurfaceIntersectionScreen*)m_ScreenVec[VSP_SURFACE_INTERSECTION_SCREEN]; if ( scr ) { for ( int i = 0; i < (int)data.m_StringVec.size(); i++ ) { scr->AddOutputText( data.m_StringVec[i] ); } } } else if ( data.m_String == string( "Error" ) ) { const char* msg = data.m_StringVec[0].c_str(); fl_message( "%s", ( char* )msg ); } else if ( data.m_String == string( "CheckCollisionKey" ) ) { SnapTo* snap = VehicleMgr.GetVehicle()->GetSnapToPtr(); if ( snap ) { if ( Fl::event_alt() ) snap->m_CollisionDetection = true; else snap->m_CollisionDetection = false; } } }