Mantid
Loading...
Searching...
No Matches
ILiveListener.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX-License-Identifier: GPL-3.0+
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/DllConfig.h"
16#include <Poco/Net/SocketAddress.h>
17#include <optional>
18#include <string>
19
20namespace Mantid {
21namespace API {
22//----------------------------------------------------------------------
23// Forward declaration
24//----------------------------------------------------------------------
25class Workspace;
26
30enum class ListenerState {
32 Connected,
33 ReadWait,
34 Error
35};
36
42class MANTID_API_DLL ILiveListener : public Kernel::PropertyManager {
43public:
44 //----------------------------------------------------------------------
45 // Static properties
46 //----------------------------------------------------------------------
47
49 virtual std::string name() const = 0;
51 virtual bool supportsHistory() const = 0;
53 virtual bool buffersEvents() const = 0;
54
55 //----------------------------------------------------------------------
56 // Actions
57 //----------------------------------------------------------------------
58
63 virtual bool connect(const Poco::Net::SocketAddress &address) = 0;
64
79 virtual void start(Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) = 0;
80
96 virtual std::shared_ptr<Workspace> extractData() = 0;
97
98 //----------------------------------------------------------------------
99 // State information
100 //----------------------------------------------------------------------
101
105 virtual bool isConnected() = 0;
106
116 virtual bool dataReset() = 0;
117
128 enum RunStatus { NoRun = 0, JoiningRun = 1, BeginRun = 2, Running = 3, EndRun = 4 };
129
130 // ----- Pure state queries (no side effects, all const) -----------------
131
138 virtual RunStatus runState() const { return NoRun; }
139
144 virtual bool isPaused() const { return false; }
145
150 virtual ListenerState listenerState() const = 0;
151
158 virtual std::optional<RunStatus> lastTransition() const { return std::nullopt; }
159
161 virtual int runNumber() const = 0;
162
166 virtual void setSpectra(const std::vector<specnum_t> &specList) = 0;
167
171 virtual void setAlgorithm(const class IAlgorithm &callingAlgorithm) = 0;
172};
173
175using ILiveListener_sptr = std::shared_ptr<ILiveListener>;
176
177} // namespace API
178} // namespace Mantid
IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:45
ILiveListener is the interface implemented by classes which connect directly to instrument data acqui...
virtual bool supportsHistory() const =0
Does this listener support requests for (recent) past data.
RunStatus
The possible run statuses (initial list taken from SNS SMS protocol) Values are assigned in transitio...
virtual std::string name() const =0
The name of this listener.
virtual bool isPaused() const
Whether the current run has been paused by a DAS annotation.
virtual bool connect(const Poco::Net::SocketAddress &address)=0
Connect to the specified address and start listening/buffering.
virtual int runNumber() const =0
Returns the run number of the current run.
virtual void setSpectra(const std::vector< specnum_t > &specList)=0
Sets a list of spectra to be extracted.
virtual ListenerState listenerState() const =0
Listener connection / health.
virtual std::shared_ptr< Workspace > extractData()=0
Get the data that's been buffered since the last call to this method (or since start() was called).
virtual bool buffersEvents() const =0
Does this listener buffer events (true) or histogram data (false)
virtual void start(Types::Core::DateAndTime startTime=Types::Core::DateAndTime())=0
Commence the collection of data from the DAS.
virtual bool isConnected()=0
Has the connection to the DAS been established? Could also be used to check for a continued connectio...
virtual bool dataReset()=0
Indicates that a reset (or period change?) signal has been received from the DAS.
virtual RunStatus runState() const
Current DAS run state (NoRun / JoiningRun / BeginRun / Running / EndRun), as last reported by the bac...
virtual void setAlgorithm(const class IAlgorithm &callingAlgorithm)=0
Allow listener to see calling algorithm.
virtual std::optional< RunStatus > lastTransition() const
The run-state transition (if any) that the most recent extractData() call consumed.
Property manager helper class.
std::shared_ptr< ILiveListener > ILiveListener_sptr
Shared pointer to an ILiveListener.
ListenerState
Listener connection / health, independent of the DAS run state.
@ Connected
Connected and reading.
@ Error
Background thread reported an exception.
@ ReadWait
Connected but paused at a run boundary (back-pressure)
@ Disconnected
Not connected to the DAS.
Helper class which provides the Collimation Length for SANS instruments.