-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSystemDebugging.h
More file actions
206 lines (170 loc) · 4.74 KB
/
SystemDebugging.h
File metadata and controls
206 lines (170 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
This file is part of the DSP-Crowd project
https://www.dsp-crowd.com
Author(s):
- Johannes Natter, office@dsp-crowd.com
File created on 12.05.2019
Copyright (C) 2019, Johannes Natter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef SYSTEM_DEBUGGING_H
#define SYSTEM_DEBUGGING_H
#include <string>
#include <list>
#include <queue>
#include <time.h>
#include "Processing.h"
#include "TcpListening.h"
#include "TcpTransfering.h"
#include "SystemCommanding.h"
enum PeerType {
PeerProc = 0,
PeerLog,
PeerCmd,
};
struct SystemDebuggingPeer
{
enum PeerType type;
std::string typeDesc;
Processing *pProc;
};
class SystemDebugging : public Processing
{
public:
static SystemDebugging *create(Processing *pTreeRoot)
{
return new (std::nothrow) SystemDebugging(pTreeRoot);
}
void listenLocalSet();
void portStartSet(uint16_t port);
bool ready();
static void levelLogSet(int lvl);
protected:
virtual ~SystemDebugging() {}
private:
SystemDebugging(Processing *pTreeRoot);
SystemDebugging()
: Processing("")
, mpTreeRoot(NULL)
, mpLstProc(NULL)
, mpLstLog(NULL)
, mpLstCmd(NULL)
, mpLstCmdAuto(NULL)
, mPeerList()
, mProcTree("")
, mListenLocal(false)
, mProcTreeChanged(false)
, mProcTreePeerAdded(false)
, mPeerLogOnceConnected(false)
, mUpdateMs(0)
, mProcTreeChangedTime(0)
, mPortStart(0)
{
mState = 0;
}
SystemDebugging(const SystemDebugging &)
: Processing("")
, mpTreeRoot(NULL)
, mpLstProc(NULL)
, mpLstLog(NULL)
, mpLstCmd(NULL)
, mpLstCmdAuto(NULL)
, mPeerList()
, mProcTree("")
, mListenLocal(false)
, mProcTreeChanged(false)
, mProcTreePeerAdded(false)
, mPeerLogOnceConnected(false)
, mUpdateMs(0)
, mProcTreeChangedTime(0)
, mPortStart(0)
{
mState = 0;
}
SystemDebugging &operator=(const SystemDebugging &)
{
mpTreeRoot = NULL;
mpLstProc = NULL;
mpLstLog = NULL;
mpLstCmd = NULL;
mpLstCmdAuto = NULL;
mPeerList.clear();
mProcTree = "";
mListenLocal = false;
mProcTreeChanged = false;
mProcTreePeerAdded = false;
mPeerLogOnceConnected = false;
mUpdateMs = 0;
mProcTreeChangedTime = 0;
mPortStart = 0;
mState = 0;
return *this;
}
/*
* Naming of functions: objectVerb()
* Example: peerAdd()
*/
/* member functions */
Success process();
Success listenersStart();
void peerListUpdate();
void commandAutoProcess();
bool disconnectRequestedCheck(TcpTransfering *pTrans);
void peerCheck();
void peerAdd(TcpListening *pListener, enum PeerType peerType, const char *pTypeDesc);
void processTreeSend();
#if CONFIG_PROC_HAVE_LOG
void logEntriesSend();
#endif
void processInfo(char *pBuf, char *pBufEnd);
/* member variables */
Processing *mpTreeRoot;
TcpListening *mpLstProc;
TcpListening *mpLstLog;
TcpListening *mpLstCmd;
TcpListening *mpLstCmdAuto;
std::list<struct SystemDebuggingPeer> mPeerList;
std::string mProcTree;
bool mListenLocal;
bool mProcTreeChanged;
bool mProcTreePeerAdded;
bool mPeerLogOnceConnected;
uint32_t mUpdateMs;
uint32_t mProcTreeChangedTime;
uint16_t mPortStart;
/* static functions */
static void cmdLevelLogSet(char *pArgs, char *pBuf, char *pBufEnd);
static void cmdLevelLogSysSet(char *pArgs, char *pBuf, char *pBufEnd);
static void procTreeDetailedToggle(char *pArgs, char *pBuf, char *pBufEnd);
static void procTreeColoredToggle(char *pArgs, char *pBuf, char *pBufEnd);
static void entryLogEnqueue(
const int severity,
#if CONFIG_PROC_LOG_HAVE_CHRONO
const char *pTimeAbs,
const std::chrono::system_clock::time_point &tLogged,
#endif
const char *pTimeCnt,
const char *pWhere,
const char *pSeverity,
const char *pWhatUser);
/* static variables */
static std::queue<std::string> qLogEntries;
static int levelLog;
/* constants */
static const size_t maxPeers;
};
#endif