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 Property;
33template <typename T> class TimeSeriesProperty;
34
41class MANTID_KERNEL_DLL LogParser {
42public:
44 static const std::string currentPeriodLogName() { return "current_period"; }
46 static const std::string statusLogName() { return "running"; }
48 static const std::string currentPeriodLogName(const int period);
50 static const std::string periodsLogName() { return "periods"; }
51
55 static Kernel::Property *createLogProperty(const std::string &logFName, const std::string &name);
57 static bool isICPEventLogNewStyle(const std::multimap<Types::Core::DateAndTime, std::string> &logm);
58
59public:
61 LogParser(const Kernel::Property *log);
62
64 int nPeriods() const { return m_nOfPeriods; }
65
68 Kernel::TimeSeriesProperty<bool> *createPeriodLog(int period) const;
69
71 Kernel::Property *createCurrentPeriodLog(const int &period) const;
72
74 Kernel::Property *createAllPeriodsLog() const;
75
77 Kernel::TimeSeriesProperty<bool> *createRunningLog() const;
78
79private:
81 void parseOldStyleCommands(const std::multimap<Types::Core::DateAndTime, std::string> &logm,
83
85 void parseNewStyleCommands(const std::multimap<Types::Core::DateAndTime, std::string> &logm,
87
89 enum class commands { NONE = 0, BEGIN, END, CHANGE_PERIOD, ABORT };
90
93 using CommandMap = std::map<std::string, commands>;
94
96 std::shared_ptr<Kernel::Property> m_periods;
97
99 std::shared_ptr<Kernel::TimeSeriesProperty<bool>> m_status;
100
103
105 CommandMap createCommandMap(bool newStyle) const;
106
108 void tryParsePeriod(const std::string &scom, const Types::Core::DateAndTime &time, std::istringstream &idata,
109 Kernel::TimeSeriesProperty<int> *const periods);
110};
111
113MANTID_KERNEL_DLL double timeMean(const Kernel::Property *p);
114
115} // namespace Kernel
116} // namespace Mantid
LogParser parses the instrument log files to select records corresponding to 'RUNNING' instrument sta...
Definition: LogParser.h:41
std::shared_ptr< Kernel::TimeSeriesProperty< bool > > m_status
TimeSeriesProperty<bool> containing running status. Created by LogParser.
Definition: LogParser.h:99
static const std::string statusLogName()
Returns the name of the log created that defines the status during a run.
Definition: LogParser.h:46
int nPeriods() const
Number of periods.
Definition: LogParser.h:64
std::map< std::string, commands > CommandMap
Typedef for a map of string commands to an enum of strongly typed commands.
Definition: LogParser.h:93
std::shared_ptr< Kernel::Property > m_periods
TimeSeriesProperty<int> containing data periods. Created by LogParser.
Definition: LogParser.h:96
static const std::string currentPeriodLogName()
Returns the name of the log that contains the current period number.
Definition: LogParser.h:44
commands
Available commands.
Definition: LogParser.h:89
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.
static const std::string periodsLogName()
Returns the name of the log that contains all of the periods.
Definition: LogParser.h:50
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:102
Base class for properties.
Definition: Property.h:94
A specialised Property class for holding a series of time-value pairs.
MANTID_KERNEL_DLL double timeMean(const Kernel::Property *p)
Returns the mean value if the property is TimeSeriesProperty<double>
Definition: LogParser.cpp:312
Helper class which provides the Collimation Length for SANS instruments.