cisst-saw
Loading...
Searching...
No Matches
mtsCollectorState.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Min Yang Jung, Anton Deguet
6 Created on: 2009-03-20
7
8 (C) Copyright 2009-2025 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19#ifndef _mtsCollectorState_h
20#define _mtsCollectorState_h
21
26
27#include <string>
28
29// Always include last
31
42{
44 friend class mtsStateTable;
45
47
50 typedef struct {
51 std::string Name;
52 unsigned int ID;
53 } SignalElement;
54
55 typedef std::vector<SignalElement> RegisteredSignalElementType;
56 RegisteredSignalElementType RegisteredSignalElements;
57
59 size_t OffsetForNextRead;
60
62 ptrdiff_t LastReadIndex;
63
65 size_t TableHistoryLength;
66
68 size_t SamplingInterval;
69
71 mtsComponent * TargetComponent;
72 mtsStateTable * TargetStateTable;
73
75 void Run(void) override;
76
78 void Initialize(void);
79
80 // documented in base class
81 virtual std::string GetDefaultOutputName(void) override;
82
83 mtsFunctionWrite StateTableStartCollection;
84 mtsFunctionWrite StateTableStopCollection;
85
88 bool IsRegisteredSignal(const std::string & signalName) const;
89
91 bool AddSignalElement(const std::string & signalName, const unsigned int signalID);
92
94 bool FetchStateTableData(const mtsStateTable * table,
95 const size_t startIdx,
96 const size_t endIdx);
97
99 void PrintHeader(const CollectorFileFormat & fileFormat);
100
102 void MarkHeaderEnd(std::ostream & logFile);
103
105 static bool IsHeaderEndMark(const char * buffer);
106
109 void BatchReadyHandler(const mtsStateTable::IndexRange & range);
110
114 void CollectionStartedHandler(void);
115
119 void CollectionStoppedHandler(const size_t & count);
120
124 void ProgressHandler(const size_t & count);
125
127 void BatchCollect(const mtsStateTable::IndexRange & range);
128
129public:
131 mtsCollectorState(const std::string & collectorName);
132
134 mtsCollectorState(const std::string & targetComponentName,
135 const std::string & targetStateTableName,
136 const CollectorFileFormat fileFormat);
137
139
144 bool SetStateTable(const std::string & componentName,
145 const std::string & stateTableName = "");
146
148 bool AddSignal(const std::string & signalName = "");
149
153 void SetSamplingInterval(const size_t samplingInterval) {
154 SamplingInterval = (samplingInterval > 0 ? samplingInterval : 1);
155 }
156
161 bool Connect(void) override;
162
165 bool Disconnect(void);
166
168 static bool ConvertBinaryToText(const std::string sourceBinaryLogFileName,
169 const std::string targetPlainTextLogFileName,
170 const char delimiter = ',');
171
177 void StartCollection(const double & delayInSeconds) override;
178 void StopCollection(const double & delayInSeconds) override;
180};
181
183
184#endif // _mtsCollectorState_h
mtsCollectorBase(const std::string &collectorName, const CollectorFileFormat fileFormat)
CollectorFileFormat
Definition mtsCollectorBase.h:51
Definition mtsCollectorState.h:42
void StopCollection(const double &delayInSeconds) override
mtsCollectorState(const std::string &targetComponentName, const std::string &targetStateTableName, const CollectorFileFormat fileFormat)
mtsCollectorState(const std::string &collectorName)
void SetSamplingInterval(const size_t samplingInterval)
Definition mtsCollectorState.h:153
bool SetStateTable(const std::string &componentName, const std::string &stateTableName="")
friend class mtsCollectorStateTest
Definition mtsCollectorState.h:43
void StartCollection(const double &delayInSeconds) override
bool Disconnect(void)
bool AddSignal(const std::string &signalName="")
static bool ConvertBinaryToText(const std::string sourceBinaryLogFileName, const std::string targetPlainTextLogFileName, const char delimiter=',')
friend class mtsStateTable
Definition mtsCollectorState.h:44
bool Connect(void) override
Definition mtsComponent.h:150
std::string Name
Definition mtsComponent.h:159
Definition mtsFunctionWrite.h:37
Definition mtsStateTable.h:81
Definition mtsStateTable.h:67
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
const int CMN_NO_DYNAMIC_CREATION
Definition cmnClassRegisterMacros.h:325
#define CISST_EXPORT
Definition cmnExportMacros.h:50
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
A data collection tool.
Defines a command with no argument.
Rules of exporting.
Defines the state data table.
Defines a periodic task.