1
0
Fork 0

Die if I/O Channel config fails for any reason.

Add an I/O Shutdown function call that explicitely closes all the open channels.
This commit is contained in:
curt 2000-10-04 20:50:38 +00:00
parent 3dde95059d
commit df31c5893e
4 changed files with 31 additions and 8 deletions

View file

@ -210,7 +210,8 @@ void fgIOInit() {
p->open();
global_io_list.push_back( p );
if ( !p->is_enabled() ) {
FG_LOG( FG_IO, FG_INFO, "I/O Channel config failed." );
FG_LOG( FG_IO, FG_ALERT, "I/O Channel config failed." );
exit(-1);
}
} else {
FG_LOG( FG_IO, FG_INFO, "I/O Channel parse failed." );
@ -253,3 +254,20 @@ void fgIOProcess() {
}
}
}
// shutdown all I/O connections
void fgIOShutdownAll() {
FGProtocol *p;
// cout << "processing I/O channels" << endl;
for ( int i = 0; i < (int)global_io_list.size(); ++i ) {
// cout << " channel = " << i << endl;
p = global_io_list[i];
if ( p->is_enabled() ) {
p->close();
}
}
}

View file

@ -36,4 +36,8 @@ void fgIOInit();
void fgIOProcess();
// shutdown all I/O connections
void fgIOShutdownAll();
#endif // _FG_IO_HXX

View file

@ -399,7 +399,7 @@ void GLUTkey(unsigned char k, int x, int y) {
// fclose( fg_DebugOutput );
// }
FG_LOG( FG_INPUT, FG_ALERT,
"Program exiting normally at user request." );
"Program exit requested." );
ConfirmExitDialog();
return;
}

View file

@ -962,7 +962,8 @@ static void fgMainLoop( void ) {
double rpm_factor = cur_fdm_state->get_engine(0)->get_RPM() /
2500.0;
cout << "rpm = " << cur_fdm_state->get_engine(0)->get_RPM() << endl;
// cout << "rpm = " << cur_fdm_state->get_engine(0)->get_RPM()
// << endl;
double pitch = 0.3 + rpm_factor * 3.0;
@ -970,19 +971,19 @@ static void fgMainLoop( void ) {
// and sounds bad to boot. :-)
if (pitch < 0.7) { pitch = 0.7; }
if (pitch > 5.0) { pitch = 5.0; }
cout << "pitch = " << pitch << endl;
// cout << "pitch = " << pitch << endl;
double mp_factor =
cur_fdm_state->get_engine(0)->get_Manifold_Pressure() / 28;
cout << "mp = "
<< cur_fdm_state->get_engine(0)->get_Manifold_Pressure()
<< endl;
// cout << "mp = "
// << cur_fdm_state->get_engine(0)->get_Manifold_Pressure()
// << endl;
double volume = mp_factor;
if ( volume < 0.3 ) { volume = 0.3; }
if ( volume > 2.0 ) { volume = 2.0; }
cout << "volume = " << volume << endl;
// cout << "volume = " << volume << endl;
pitch_envelope.setStep ( 0, 0.01, pitch );
volume_envelope.setStep ( 0, 0.01, volume );