Skip to content

Commit

Permalink
committed appcasting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerb committed Jul 1, 2014
1 parent 7268882 commit 7f8daa8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 31 additions & 2 deletions Core/libMOOS/Thirdparty/AppCasting/AppCastingMOOSApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ AppCastingMOOSApp::AppCastingMOOSApp()
m_start_time = 0;
m_time_warp = 1;

m_last_iterate_time = 0;
m_last_report_time = 0;
m_last_report_time_appcast = 0;
m_iterate_start_time = 0;
m_term_report_interval = 0.4;

m_term_reporting = true;
Expand All @@ -54,6 +56,23 @@ bool AppCastingMOOSApp::Iterate()
{
m_iteration++;
m_curr_time = MOOSTime();

// Handle the construction of the ITER_GAP
if(m_last_iterate_time != 0) {
double app_freq = GetAppFreq();
if(app_freq > 0) {
double app_gap = 1.0 / app_freq;
double iter_gap = m_curr_time - m_last_iterate_time;
string app_name = MOOSToUpper((const string&)(m_sMOOSName));
string var = app_name + "_ITER_GAP";
Notify(var, (iter_gap / app_gap));
}
}
m_last_iterate_time = m_curr_time;

// Prepare the front end of calculating the ITER_LEN
m_iterate_start_time = m_curr_time;

return(true);
}

Expand All @@ -64,6 +83,15 @@ void AppCastingMOOSApp::PostReport(const string& directive)
{
m_ac.setIteration(m_iteration);

double app_freq = GetAppFreq();
if(app_freq > 0) {
double app_gap = 1.0 / app_freq;
double iter_len = MOOSTime() - m_iterate_start_time;
string app_name = MOOSToUpper((const string&)(m_sMOOSName));
string var = app_name + "_ITER_LEN";
Notify(var, (iter_len / app_gap));
}

if(m_time_warp <= 0)
return;

Expand Down Expand Up @@ -153,12 +181,13 @@ bool AppCastingMOOSApp::OnStartUpDirectives(string directives)
MOOSTrimWhiteSpace(directive);
string left = MOOSChomp(directive, "=");
string right = directive;

MOOSTrimWhiteSpace(left);
MOOSTrimWhiteSpace(right);
if(MOOSStrCmp(left, "must_have_moosblock"))
must_have_moosblock = MOOSStrCmp(right, "true");
if(MOOSStrCmp(left, "must_have_community"))
must_have_moosblock = MOOSStrCmp(right, "true");
must_have_community = MOOSStrCmp(right, "true");
else if(MOOSStrCmp(left, "alt_config_block_name"))
alt_config_block_name = right;
}
Expand All @@ -177,7 +206,7 @@ bool AppCastingMOOSApp::OnStartUpDirectives(string directives)
// developer decide how to interpret a return of false.
if(!m_MissionReader.GetValue("COMMUNITY", m_host_community)) {
if(must_have_community) {
reportConfigWarning("Community/Vehicle name not found in mission file");
reportConfigWarning("XCommunity/Vehicle name not found in mission file");
return_value = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class AppCastingMOOSApp : public CMOOSApp
double m_curr_time;
double m_start_time;
double m_time_warp;
double m_last_iterate_time;
double m_iterate_start_time;
double m_last_report_time;
double m_term_report_interval;
bool m_term_reporting;
Expand Down

0 comments on commit 7f8daa8

Please sign in to comment.