1
0
Fork 0

Simplified to use the delta_time_sec that is passed to the update() routine

rather than calculating a separate delta_t and using that.
This commit is contained in:
curt 2002-12-14 14:39:56 +00:00
parent 51c5b9bf09
commit 0e69acaff7

View file

@ -250,34 +250,28 @@ FGIO::update( double delta_time_sec )
{ {
// cout << "processing I/O channels" << endl; // cout << "processing I/O channels" << endl;
static int inited = 0; // SGTimeStamp current_time;
int interval; // current_time.stamp();
static SGTimeStamp last; // static SGTimeStamp start_time = current_time;
SGTimeStamp current; // double elapsed_time = (current_time - start_time) / 1000000.0;
// cout << " Elapsed time = " << elapsed_time << endl;
if ( ! inited ) {
inited = 1;
last.stamp();
interval = 0;
} else {
current.stamp();
interval = current - last;
last = current;
}
typedef vector< FGProtocol* > container; typedef vector< FGProtocol* > container;
container::iterator i = io_channels.begin(); container::iterator i = io_channels.begin();
container::iterator end = io_channels.end(); container::iterator end = io_channels.end();
for (; i != end; ++i ) for (; i != end; ++i ) {
{
FGProtocol* p = *i; FGProtocol* p = *i;
if ( p->is_enabled() ) { if ( p->is_enabled() ) {
p->dec_count_down( interval ); p->dec_count_down( delta_time_sec );
while ( p->get_count_down() < 0 ) { double dt = 1 / p->get_hz();
while ( p->get_count_down() < 0.33 * dt ) {
p->process(); p->process();
p->dec_count_down(int( -1000000.0 / p->get_hz())); p->inc_count_down( dt );
p->inc_count();
} }
// double ave = elapsed_time / p->get_count();
// cout << " ave rate = " << ave << endl;
} }
} }
} }