Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hochautomatisiertes-Fahren
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Philipp Badenhoop
Hochautomatisiertes-Fahren
Commits
011ebae8
Commit
011ebae8
authored
7 years ago
by
Hoop77
Browse files
Options
Downloads
Patches
Plain Diff
updated json names to snake-case
parent
0390ca3c
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PlatoonProtocol/include/PlatoonMessage.h
+21
-8
21 additions, 8 deletions
PlatoonProtocol/include/PlatoonMessage.h
with
21 additions
and
8 deletions
PlatoonProtocol/include/PlatoonMessage.h
+
21
−
8
View file @
011ebae8
...
...
@@ -36,6 +36,16 @@ inline bool isStandardMessageType(MessageType messageType)
}
namespace
jsonNames
{
constexpr
char
VEHICLE_ID
[]
=
"vehicle_id"
;
constexpr
char
PLATOON_ID
[]
=
"platoon_id"
;
constexpr
char
PLATOON_SPEED
[]
=
"ps"
;
constexpr
char
INNER_PLATOON_DISTANCE
[]
=
"ips"
;
}
struct
PlatoonMessage
{
static
constexpr
std
::
size_t
MAX_SIZE
=
256
;
...
...
@@ -116,13 +126,14 @@ struct Encoder<platoonProtocol::PlatoonMessage>
data
[
i
]
=
numDataBytes
[
i
];
using
json
=
nlohmann
::
json
;
auto
j
=
json
{{
"vehicleId"
,
message
.
vehicleId
},
{
"platoonId"
,
message
.
platoonId
}};
using
namespace
jsonNames
;
auto
j
=
json
{{
VEHICLE_ID
,
message
.
vehicleId
},
{
PLATOON_ID
,
message
.
platoonId
}};
if
(
messageType
==
messageTypes
::
LV_BROADCAST
)
{
j
[
"ps"
]
=
message
.
platoonSpeed
;
j
[
"ipd"
]
=
message
.
innerPlatoonDistance
;
j
[
PLATOON_SPEED
]
=
message
.
platoonSpeed
;
j
[
INNER_PLATOON_DISTANCE
]
=
message
.
innerPlatoonDistance
;
}
data
.
append
(
j
.
dump
());
...
...
@@ -150,13 +161,15 @@ struct Decoder<platoonProtocol::PlatoonMessage>
throw
0
;
message
.
messageType
=
messageType
;
message
.
vehicleId
=
j
.
at
(
"vehicleId"
).
get
<
VehicleId
>
();
message
.
platoonId
=
j
.
at
(
"platoonId"
).
get
<
PlatoonId
>
();
using
namespace
jsonNames
;
message
.
vehicleId
=
j
.
at
(
VEHICLE_ID
).
get
<
VehicleId
>
();
message
.
platoonId
=
j
.
at
(
PLATOON_ID
).
get
<
PlatoonId
>
();
if
(
messageType
==
messageTypes
::
LV_BROADCAST
)
{
message
.
platoonSpeed
=
j
.
at
(
"ps"
).
get
<
PlatoonSpeed
>
();
message
.
innerPlatoonDistance
=
j
.
at
(
"ipd"
).
get
<
InnerPlatoonDistance
>
();
message
.
platoonSpeed
=
j
.
at
(
PLATOON_SPEED
).
get
<
PlatoonSpeed
>
();
message
.
innerPlatoonDistance
=
j
.
at
(
INNER_PLATOON_DISTANCE
).
get
<
InnerPlatoonDistance
>
();
}
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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