00001 #include "SimProgressBar.h" 00002 00003 #include <iostream> 00004 00005 using std::cout; 00006 00007 SimProgressBar::SimProgressBar(const Time &simtime) 00008 : simulationTime(simtime.in_sec()) 00009 { 00010 00011 } 00012 00013 SimProgressBar::~SimProgressBar() 00014 { 00015 } 00016 00017 void SimProgressBar::changeSimulationTime(const Time & simtime) 00018 { 00019 simulationTime = simtime.in_sec(); 00020 } 00021 00022 int SimProgressBar::reset( double dt ) 00023 { 00024 prev_progress = 0; 00025 return 0; 00026 } 00027 00028 int SimProgressBar::advance(AdvanceInfo const & ai) 00029 { 00030 double progress = ai.t.in_sec() / simulationTime; 00031 int perc_progress = int( progress * 100 ); 00032 int perc_prev_progress = int( prev_progress * 100 ); 00033 for (int i = perc_prev_progress + 1 ; i <= perc_progress; ++i) 00034 { 00035 if ( ! (i % 10) ) { 00036 cout << i << "%" ; 00037 cout.flush(); 00038 } 00039 else { 00040 cout << "."; 00041 cout.flush(); 00042 } 00043 } 00044 00045 prev_progress = progress; 00046 return 0; 00047 } 00048 00049 double SimProgressBar::getAnalogOutput(analog_port_id_t) const 00050 { 00051 return prev_progress; 00052 }