Skip to content

Commit

Permalink
Set run_start property using most recent packet's time
Browse files Browse the repository at this point in the history
When setting the initial value for the run_start property, use the time
from the most recently received packet instead of the current system
time.  (Doesn't matter too much when using actual live data, but when
replaying old data it makes a lot more sense.)

Refs #6235
  • Loading branch information
rgmiller committed Dec 3, 2012
1 parent 1533f50 commit 1b75aa6
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ namespace DataHandling
// then we can initialize our workspace. Otherwise, we'll just wait.
if (m_instrumentName.size() > 0)
{
initWorkspace();
initWorkspace( pkt);
}
}

Expand All @@ -370,7 +370,7 @@ namespace DataHandling
// we can create our workspace. Otherwise, we'll just wait
if (m_instrumentXML.size() > 0)
{
initWorkspace();
initWorkspace( pkt);
}
}

Expand Down Expand Up @@ -708,7 +708,7 @@ namespace DataHandling
}


void SNSLiveEventDataListener::initWorkspace()
void SNSLiveEventDataListener::initWorkspace(const ADARA::Packet &pkt)
{
// Use the LoadEmptyInstrument algorithm to create a proper workspace
// for whatever beamline we're on
Expand All @@ -735,6 +735,17 @@ namespace DataHandling
prop = new TimeSeriesProperty<int>(SCAN_PROPERTY);
m_buffer->mutableRun().addLogData(prop);

// We must always have a run_start property or the LogManager throws an
// exception. The "real" value will come from a RunStatus packet saying that
// a new run is starting. Until we get one of those packets, we'll just use
// the time from the packet. (In a truely "live" stream, current time would
// also work, but if we're replaying old data, then current time would be
// newer than the timestamps in the data, and that would cause strange time
// values in the sample log.
Kernel::DateAndTime now = timeFromPacket(pkt);
// addProperty() wants the time as an ISO 8601 string
m_buffer->mutableRun().addProperty("run_start", now.toISO8601String());

m_workspaceInitialized = true;
}

Expand Down

0 comments on commit 1b75aa6

Please sign in to comment.