NetAnim: Support Pause & Resume Animation

This commit is contained in:
John Abraham
2011-09-03 22:29:56 -04:00
parent cb6eeb3b19
commit 304359acf0
2 changed files with 18 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ int main (int argc, char *argv[])
}
// Uncomment the below statement to generate Animation trace in XML
// anim.SetXMLOutput ();
anim.SetXMLOutput ();
anim.StartAnimation ();
// Set up the acutal simulation

View File

@@ -92,6 +92,7 @@ bool AnimationInterface::SetOutputFile (const std::string& fn)
}
if (fn == "")
{
m_fHandle = STDOUT_FILENO;
OutputFileSet = true;
return true;
}
@@ -343,13 +344,21 @@ void AnimationInterface::StopAnimation ()
{ // Terminate the anim element
WriteN (m_fHandle, GetXMLClose ("anim"));
}
close (m_fHandle);
m_fHandle = 0;
if (m_fHandle != STDOUT_FILENO)
{
close (m_fHandle);
}
OutputFileSet = false;
m_fHandle = -1;
}
}
int AnimationInterface::WriteN (int h, const std::string& st)
{
if (h < 0)
{
return 0;
}
if (m_writeCallback)
{
m_writeCallback (st.c_str ());
@@ -422,7 +431,12 @@ void AnimationInterface::RecalcTopoBounds (Vector v)
}
int AnimationInterface::WriteN (int h, const char* data, uint32_t count)
{ // Write count bytes to h from data
{
if (h < 0)
{
return 0;
}
// Write count bytes to h from data
uint32_t nLeft = count;
const char* p = data;
uint32_t written = 0;