Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emilio Corigliano
Skyward Boardcore
Commits
465b406e
Commit
465b406e
authored
3 years ago
by
Alberto Nidasio
Browse files
Options
Downloads
Patches
Plain Diff
[Deserializer] Fixed automatic log deconding of multiple files
parent
73ad9878
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
scripts/logdecoder/logdecoder.cpp
+4
-8
4 additions, 8 deletions
scripts/logdecoder/logdecoder.cpp
src/shared/logger/Deserializer.h
+13
-9
13 additions, 9 deletions
src/shared/logger/Deserializer.h
src/shared/logger/LogTypes.h
+0
-1
0 additions, 1 deletion
src/shared/logger/LogTypes.h
with
17 additions
and
18 deletions
scripts/logdecoder/logdecoder.cpp
+
4
−
8
View file @
465b406e
...
@@ -64,19 +64,15 @@ bool deserializeAll()
...
@@ -64,19 +64,15 @@ bool deserializeAll()
{
{
for
(
int
i
=
0
;
i
<
100
;
i
++
)
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
{
char
fn
[
10
];
char
nextName
[
11
];
char
fnext
[
11
];
sprintf
(
nextName
,
"log%02d.dat"
,
i
);
sprintf
(
fn
,
"log%02d"
,
i
);
sprintf
(
fnext
,
"log%02d.dat"
,
i
);
struct
stat
st
;
struct
stat
st
;
if
(
stat
(
f
next
,
&
st
)
!=
0
)
if
(
stat
(
next
Name
,
&
st
)
!=
0
)
continue
;
// File not found
continue
;
// File not found
// File found
// File found
if
(
!
deserialize
(
string
(
fn
)))
if
(
!
deserialize
(
string
(
nextName
)))
{
return
false
;
return
false
;
}
}
}
return
true
;
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/shared/logger/Deserializer.h
+
13
−
9
View file @
465b406e
...
@@ -99,7 +99,7 @@ private:
...
@@ -99,7 +99,7 @@ private:
bool
closed
=
false
;
bool
closed
=
false
;
std
::
vector
<
std
::
ofstream
*>
fileStreams
;
std
::
map
<
std
::
string
,
std
::
ofstream
*>
fileStreams
;
tscpp
::
TypePoolStream
tps
;
tscpp
::
TypePoolStream
tps
;
std
::
string
logFilename
;
std
::
string
logFilename
;
...
@@ -130,14 +130,18 @@ void Deserializer::registerType()
...
@@ -130,14 +130,18 @@ void Deserializer::registerType()
template
<
typename
T
>
template
<
typename
T
>
void
Deserializer
::
printType
(
T
&
t
,
std
::
string
path
,
std
::
string
prefix
)
void
Deserializer
::
printType
(
T
&
t
,
std
::
string
path
,
std
::
string
prefix
)
{
{
static
std
::
ofstream
*
stream
=
nullptr
;
std
::
string
demangledTypeName
=
tscpp
::
demangle
(
typeid
(
T
).
name
());
static
std
::
ofstream
*
stream
;
try
{
stream
=
fileStreams
.
at
(
demangledTypeName
);
}
// If not already initialize, open the file and write the header
// If not already initialize, open the file and write the header
if
(
stream
==
nullptr
)
catch
(
std
::
out_of_range
e
)
{
{
stream
=
new
std
::
ofstream
();
stream
=
new
std
::
ofstream
();
std
::
string
filename
=
std
::
string
filename
=
path
+
prefix
+
"_"
+
demangledTypeName
+
".csv"
;
path
+
prefix
+
"_"
+
tscpp
::
demangle
(
typeid
(
T
).
name
())
+
".csv"
;
std
::
cout
<<
"Creating file "
+
filename
<<
std
::
endl
;
std
::
cout
<<
"Creating file "
+
filename
<<
std
::
endl
;
stream
->
open
(
filename
);
stream
->
open
(
filename
);
...
@@ -152,7 +156,7 @@ void Deserializer::printType(T& t, std::string path, std::string prefix)
...
@@ -152,7 +156,7 @@ void Deserializer::printType(T& t, std::string path, std::string prefix)
*
stream
<<
T
::
header
();
*
stream
<<
T
::
header
();
// Add the file to the vector such that it will be closed
// Add the file to the vector such that it will be closed
fileStreams
.
push_back
(
stream
);
fileStreams
.
emplace
(
demangledTypeName
,
stream
);
}
}
// Print data into the file if it is open
// Print data into the file if it is open
...
@@ -222,8 +226,8 @@ void Deserializer::close()
...
@@ -222,8 +226,8 @@ void Deserializer::close()
closed
=
true
;
closed
=
true
;
for
(
auto
it
=
fileStreams
.
begin
();
it
!=
fileStreams
.
end
();
it
++
)
for
(
auto
it
=
fileStreams
.
begin
();
it
!=
fileStreams
.
end
();
it
++
)
{
{
(
*
it
)
->
close
();
it
->
second
->
close
();
delete
*
it
;
delete
it
->
second
;
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/shared/logger/LogTypes.h
+
0
−
1
View file @
465b406e
...
@@ -101,7 +101,6 @@ void registerTypes(Deserializer& ds)
...
@@ -101,7 +101,6 @@ void registerTypes(Deserializer& ds)
ds
.
registerType
<
VN100Data
>
();
ds
.
registerType
<
VN100Data
>
();
ds
.
registerType
<
BatteryVoltageSensorData
>
();
ds
.
registerType
<
BatteryVoltageSensorData
>
();
ds
.
registerType
<
CurrentSensorData
>
();
ds
.
registerType
<
CurrentSensorData
>
();
ds
.
registerType
<
LoadCellData
>
();
ds
.
registerType
<
MPXHZ6130AData
>
();
ds
.
registerType
<
MPXHZ6130AData
>
();
ds
.
registerType
<
HSCMAND015PAData
>
();
ds
.
registerType
<
HSCMAND015PAData
>
();
ds
.
registerType
<
HSCMRNN030PAData
>
();
ds
.
registerType
<
HSCMRNN030PAData
>
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment