Skip to content

Commit

Permalink
Update examples to VSS release 4 (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
BjoernAtBosch authored Aug 6, 2024
1 parent e626bac commit fe0e1c0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 31 deletions.
25 changes: 6 additions & 19 deletions examples/example_model/vehicle/Cabin/Cabin.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,13 @@ class Cabin : public ParentClass {
public:
RowType(const std::string& name, ParentClass* parent)
: ParentClass(name, parent)
, Pos1("Pos1", this)
, Pos2("Pos2", this)
, Pos3("Pos3", this) {}
, DriverSide("DriverSide", this)
, Middle("Middle", this)
, PassengerSide("PassengerSide", this) {}

vehicle::cabin::Seat& Pos(int index) {
if (index == 1) {
return Pos1;
}
if (index == 2) {
return Pos2;
}
if (index == 3) {
return Pos3;
}
throw std::runtime_error("Given value is outside of allowed range [1;3]!");
}

vehicle::cabin::Seat Pos1;
vehicle::cabin::Seat Pos2;
vehicle::cabin::Seat Pos3;
vehicle::cabin::Seat DriverSide;
vehicle::cabin::Seat Middle;
vehicle::cabin::Seat PassengerSide;
};

explicit SeatCollection(ParentClass* parent)
Expand Down
4 changes: 2 additions & 2 deletions examples/seat-adjuster/AppManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
{
"type": "vehicle-signal-interface",
"config": {
"src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v3.0/vss_rel_3.0.json",
"src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v4.0/vss_rel_4.0.json",
"datapoints": {
"required": [
{
"path": "Vehicle.Cabin.Seat.Row1.Pos1.Position",
"path": "Vehicle.Cabin.Seat.Row1.DriverSide.Position",
"access": "write"
},
{
Expand Down
7 changes: 4 additions & 3 deletions examples/seat-adjuster/src/SeatAdjusterApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ void SeatAdjusterApp::onStart() {
velocitas::logger().info("Subscribe for data points!");

subscribeDataPoints(
velocitas::QueryBuilder::select(m_vehicleModel->Cabin.Seat.Row1.Pos1.Position).build())
velocitas::QueryBuilder::select(m_vehicleModel->Cabin.Seat.Row1.DriverSide.Position)
.build())
->onItem([this](auto&& item) { onSeatPositionChanged(std::forward<decltype(item)>(item)); })
->onError(
[this](auto&& status) { onErrorDatapoint(std::forward<decltype(status)>(status)); });
Expand Down Expand Up @@ -80,7 +81,7 @@ void SeatAdjusterApp::onSetPositionRequestReceived(const std::string& data) {
nlohmann::json respData({{JSON_FIELD_REQUEST_ID, requestId}, {JSON_FIELD_RESULT, {}}});
const auto vehicleSpeed = m_vehicleModel->Speed.get()->await().value();
if (vehicleSpeed == 0) {
m_vehicleModel->Cabin.Seat.Row1.Pos1.Position.set(desiredSeatPosition)->await();
m_vehicleModel->Cabin.Seat.Row1.DriverSide.Position.set(desiredSeatPosition)->await();

respData[JSON_FIELD_RESULT][JSON_FIELD_STATUS] = STATUS_OK;
respData[JSON_FIELD_RESULT][JSON_FIELD_MESSAGE] =
Expand All @@ -101,7 +102,7 @@ void SeatAdjusterApp::onSeatPositionChanged(const velocitas::DataPointReply& dat
nlohmann::json jsonResponse;
try {
const auto seatPositionValue =
dataPoints.get(m_vehicleModel->Cabin.Seat.Row1.Pos1.Position)->value();
dataPoints.get(m_vehicleModel->Cabin.Seat.Row1.DriverSide.Position)->value();
jsonResponse[JSON_FIELD_POSITION] = seatPositionValue;
} catch (std::exception& exception) {
velocitas::logger().warn("Unable to get Current Seat Position, Exception: {}",
Expand Down
6 changes: 3 additions & 3 deletions examples/set-data-points/AppManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
{
"type": "vehicle-signal-interface",
"config": {
"src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v3.0/vss_rel_3.0.json",
"src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v4.0/vss_rel_4.0.json",
"datapoints": {
"required": [
{
"path": "Vehicle.Cabin.Seat.Row1.Pos1.Position",
"path": "Vehicle.Cabin.Seat.Row1.DriverSide.Position",
"access": "write"
},
{
"path": "Vehicle.Cabin.Seat.Row1.Pos2.Position",
"path": "Vehicle.Cabin.Seat.Row1.PassengerSide.Position",
"access": "write"
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/set-data-points/src/SetDataPointsApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class SetDataPointsApp : public velocitas::VehicleApp {
velocitas::logger().info("Setting batch of data points ...");

auto result = Vehicle.setMany()
.add(Vehicle.Cabin.Seat.Row1.Pos1.Position, 1000)
.add(Vehicle.Cabin.Seat.Row1.Pos2.Position, 1000)
.add(Vehicle.Cabin.Seat.Row1.DriverSide.Position, 1000)
.add(Vehicle.Cabin.Seat.Row1.PassengerSide.Position, 1000)
.apply()
->await();

Expand Down
2 changes: 1 addition & 1 deletion sdk/proto/sdv/databroker/v1/broker.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ message SubscribeReply {

message GetMetadataRequest {
// Request metadata for a list of data points referenced by their names.
// e.g. "Vehicle.Cabin.Seat.Row1.Pos1.Position" or "Vehicle.Speed".
// e.g. "Vehicle.Cabin.Seat.Row1.DriverSide.Position" or "Vehicle.Speed".
//
// If no names are provided, metadata for all known data points will be
// returned.
Expand Down
2 changes: 1 addition & 1 deletion sdk/proto/sdv/databroker/v1/collector.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ message RegisterDatapointsRequest {

message RegistrationMetadata {
// Name of the data point
// (e.g. "Vehicle.Cabin.Seat.Row1.Pos1.Position" or "Vehicle.Speed")
// (e.g. "Vehicle.Cabin.Seat.Row1.DriverSide.Position" or "Vehicle.Speed")
string name = 1;
DataType data_type = 2;
string description = 3;
Expand Down

0 comments on commit fe0e1c0

Please sign in to comment.