Mantid
Loading...
Searching...
No Matches
LogParser.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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 "MantidKernel/DllConfig.h"
13
14#ifndef Q_MOC_RUN
15#include <memory>
16#endif
17
18#include <map>
19#include <sstream>
20
21namespace Mantid {
22namespace Types {
23namespace Core {
24class DateAndTime;
25}
26} // namespace Types
27namespace Kernel {
28
29//-------------------------------------------------------------------------
30// Forward declarations
31//-------------------------------------------------------------------------
32class TimeROI;
33class Property;
34template <typename T> class TimeSeriesProperty;
35
42class MANTID_KERNEL_DLL LogParser {
43public:
45 static const std::string currentPeriodLogName() { return "current_period"; }
47 static const std::string statusLogName() { return "running"; }
49 static const std::string currentPeriodLogName(const int period);
51 static const std::string periodsLogName() { return "periods"; }
52
56 static Kernel::Property *createLogProperty(const std::string &logFName, const std::string &name);
58 static bool isICPEventLogNewStyle(const std::multimap<Types::Core::DateAndTime, std::string> &logm);
59
60public:
62 LogParser(const Kernel::Property *log);
63
65 int nPeriods() const { return m_nOfPeriods; }
66
69 Kernel::TimeSeriesProperty<bool> *createPeriodLog(int period) const;
70
72 Kernel::Property *createCurrentPeriodLog(const int &period) const;
73
75 Kernel::Property *createAllPeriodsLog() const;
76
78 Kernel::TimeSeriesProperty<bool> *createRunningLog() const;
79
80private:
82 void parseOldStyleCommands(const std::multimap<Types::Core::DateAndTime, std::string> &logm,
84
86 void parseNewStyleCommands(const std::multimap<Types::Core::DateAndTime, std::string> &logm,
88
90 enum class commands { NONE = 0, BEGIN, END, CHANGE_PERIOD, ABORT };
91
94 using CommandMap = std::map<std::string, commands>;
95
97 std::shared_ptr<Kernel::TimeSeriesProperty<int>> m_periods;
98
100 std::shared_ptr<Kernel::TimeSeriesProperty<bool>> m_status;
101
104
106 CommandMap createCommandMap(bool newStyle) const;
107
109 void tryParsePeriod(const std::string &scom, const Types::Core::DateAndTime &time, std::istringstream &idata,
110 Kernel::TimeSeriesProperty<int> *const periods);
111};
112
114MANTID_KERNEL_DLL double timeMean(const Kernel::Property *p, const TimeROI *roi = nullptr);
115
116} // namespace Kernel
117} // namespace Mantid
std::string name
Definition Run.cpp:60
LogParser parses the instrument log files to select records corresponding to 'RUNNING' instrument sta...
Definition LogParser.h:42
std::shared_ptr< Kernel::TimeSeriesProperty< bool > > m_status
TimeSeriesProperty<bool> containing running status. Created by LogParser.
Definition LogParser.h:100
static const std::string statusLogName()
Returns the name of the log created that defines the status during a run.
Definition LogParser.h:47
int nPeriods() const
Number of periods.
Definition LogParser.h:65
std::map< std::string, commands > CommandMap
Typedef for a map of string commands to an enum of strongly typed commands.
Definition LogParser.h:94
static const std::string currentPeriodLogName()
Returns the name of the log that contains the current period number.
Definition LogParser.h:45
commands
Available commands.
Definition LogParser.h:90
void parseNewStyleCommands(const std::multimap< Types::Core::DateAndTime, std::string > &logm, Kernel::TimeSeriesProperty< int > *periods, Kernel::TimeSeriesProperty< bool > *status)
Parse the icp event log with new style commands.
std::shared_ptr< Kernel::TimeSeriesProperty< int > > m_periods
TimeSeriesProperty<int> containing data periods. Created by LogParser.
Definition LogParser.h:97
static const std::string periodsLogName()
Returns the name of the log that contains all of the periods.
Definition LogParser.h:51
void parseOldStyleCommands(const std::multimap< Types::Core::DateAndTime, std::string > &logm, Kernel::TimeSeriesProperty< int > *periods, Kernel::TimeSeriesProperty< bool > *status)
Parse the icp event log with old style commands.
int m_nOfPeriods
Number of periods.
Definition LogParser.h:103
Base class for properties.
Definition Property.h:94
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
A specialised Property class for holding a series of time-value pairs.
MANTID_KERNEL_DLL double timeMean(const Kernel::Property *p, const TimeROI *roi=nullptr)
Returns the mean value if the property is TimeSeriesProperty<double>
Helper class which provides the Collimation Length for SANS instruments.