00001 #include "stage.hh" 00002 using namespace Stg; 00003 00004 unsigned int total = 0; 00005 00006 // inspect the laser data and decide what to do 00007 int Delivery( Model* mod, void* dummy ) 00008 { 00009 (void)dummy; 00010 00011 total++; 00012 00013 printf( "Delivery: %.2f %d %.2f %.2f\n", 00014 mod->GetWorld()->SimTimeNow() / 1e6, 00015 //mod->GetFlagCount(), 00016 total, 00017 // dynamic_cast<WorldGui*>(mod->GetWorld())->EnergyString().c_str() ); 00018 00019 Stg::PowerPack::global_input / 1e3, 00020 Stg::PowerPack::global_dissipated / 1e3 ); 00021 00022 00023 return 0; // run again 00024 } 00025 00026 00027 00028 // Stage calls this when the model starts up 00029 extern "C" int Init( Model* mod ) 00030 { 00031 // mod->AddCallback( Model::CB_UPDATE, (model_callback_t)Update, NULL ); 00032 00033 mod->AddCallback( Model::CB_FLAGINCR, (model_callback_t)Delivery, NULL ); 00034 mod->Subscribe(); 00035 return 0; //ok 00036 } 00037