Skip to content
Snippets Groups Projects
Unverified Commit 0bcde0bb authored by Martyn Gigg's avatar Martyn Gigg Committed by GitHub
Browse files

Merge pull request #22148 from mantidproject/22112_live_listener_end_time

Save end time in SNS live listener
parents aa9e985d 16ba8fb4
No related branches found
No related tags found
No related merge requests found
......@@ -740,9 +740,8 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::RunStatusPkt &pkt) {
}
} else if (pkt.status() == ADARA::RunStatus::END_RUN) {
// Run has ended: update m_status and set the flag to stop parsing network
// packets. (see comments below for why)
// Run has ended: update m_status, set the end time and set the flag
// to stop parsing network packets. (see comments below for why)
if ((m_status != Running) && (m_status != BeginRun)) {
// Previous status should have been Running or BeginRun. Spit out a
// warning if it's not. (If it's BeginRun, that's fine. It just means
......@@ -752,6 +751,10 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::RunStatusPkt &pkt) {
}
m_status = EndRun;
// Add the run_end property
m_eventBuffer->mutableRun().addProperty(
"run_end", timeFromPacket(pkt).toISO8601String());
// Set the flag to make us stop reading from the network.
// Stopping network reads solves a number of problems:
// 1) We don't need to manage a second buffer in order to keep the events
......@@ -1099,18 +1102,15 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::DeviceDescriptorPkt &pkt) {
prop->setUnits(pvUnits);
}
{
// Note: it's possible for us receive device descriptor packets in
// the middle
// of a run (after the call to initWorkspacePart2), so we really
// do need to
// the lock the mutex here.
// Note: it's possible for us receive device descriptor packets
// in the middle of a run (after the call to initWorkspacePart2),
// so we really do need to the lock the mutex here.
std::lock_guard<std::mutex> scopedLock(m_mutex);
m_eventBuffer->mutableRun().addLogData(prop);
}
// Add the pv id, device id and pv name to the name map so we can
// find the
// name when we process the variable value packets
// find the name when we process the variable value packets
m_nameMap[std::make_pair(pkt.devId(), pvIdNum)] = pvName;
}
}
......@@ -1204,10 +1204,8 @@ void SNSLiveEventDataListener::initWorkspacePart1() {
// down in initWorkspacePart2() when we load the instrument definition.
// We also know we'll need 3 time series properties on the workspace. Create
// them
// now. (We may end up adding values to the pause and scan properties before
// we
// can call initWorkspacePart2().)
// them now. (We may end up adding values to the pause and scan properties
// before we can call initWorkspacePart2().)
Property *prop = new TimeSeriesProperty<int>(PAUSE_PROPERTY);
m_eventBuffer->mutableRun().addLogData(prop);
prop = new TimeSeriesProperty<int>(SCAN_PROPERTY);
......@@ -1236,8 +1234,8 @@ void SNSLiveEventDataListener::initWorkspacePart2() {
loadInst->execute();
m_requiredLogs.clear(); // Clear the list. If we have to initialize the
// workspace again,
m_requiredLogs.clear();
// Clear the list. If we have to initialize the workspace again,
// (at the start of another run, for example), the list will be
// repopulated when we receive the next geometry packet.
......@@ -1258,10 +1256,9 @@ void SNSLiveEventDataListener::initWorkspacePart2() {
true /* bool throwIfMultipleDets */);
// We always want to have at least one value for the the scan index time
// series. We may have
// already gotten a scan start packet by the time we get here and therefor
// don't need to do
// anything. If not, we need to put a 0 into the time series.
// series. We may have already gotten a scan start packet by the time we
// get here and therefor don't need to do anything. If not, we need to put
// a 0 into the time series.
if (m_eventBuffer->mutableRun()
.getTimeSeriesProperty<int>(SCAN_PROPERTY)
->size() == 0) {
......@@ -1297,8 +1294,7 @@ void SNSLiveEventDataListener::initMonitorWorkspace() {
// NOTE: This function does not lock the mutex! The calling function must
// ensure that m_eventBuffer won't change while the function runs (either by
// locking the mutex, or by the simple fact of never calling it once the
// workspace
// has been initialized...)
// workspace has been initialized...)
bool SNSLiveEventDataListener::haveRequiredLogs() {
bool allFound = true;
Run &run = m_eventBuffer->mutableRun();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment