Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
read_data_by_identifier.h
1#ifndef READ_DATA_BY_IDENTIFIER_H
2#define READ_DATA_BY_IDENTIFIER_H
3
4#include <json/json.h>
5#include "../../ara/diag/routing/uds_service_router.h"
6#include "./curl_wrapper.h"
7#include "./memory_cache.h"
8
9namespace application
10{
11 namespace helper
12 {
15 {
16 private:
17 static const uint8_t cSid{0x22};
18 static const uint16_t cAverageSpeedDid{0xf50d};
19 static const uint16_t cFuelAmountDid{0xf52f};
20 static const uint16_t cExternalTemperatureDid{0xf546};
21 static const uint16_t cAverageFuelConsumptionDid{0xf55e};
22 static const uint16_t cEngineCoolantTemperatureDid{0xf505};
23 static const uint16_t cOdometerValueDid{0xf5a6};
24 static const std::chrono::seconds cCacheLifetime;
25 static const ara::core::InstanceSpecifier cSpecifer;
26
27 const uint8_t cConditionsNotCorrectNrc{0x22};
28 const uint8_t cRequestOutOfRangeNrc{0x31};
29 const bool cCollectJsonComments{false};
30
31 const std::string cResourcesUrl;
32 CurlWrapper *mCurl;
33 Json::Reader mJsonReader;
35
36 static uint16_t getDid(const std::vector<uint8_t> &requestData);
37 static void generateResponse(
38 uint16_t did,
40
41 bool tryGetResourceValue(std::string resourceKey, Json::Value &jsonValue);
42 void getAverageSpeed(ara::diag::OperationOutput &response);
43 void getFuelAmount(ara::diag::OperationOutput &response);
44 void getExternalTemperature(ara::diag::OperationOutput &response);
45 void getAverageFuelConsumption(ara::diag::OperationOutput &response);
46 void getEngineCoolantTemperature(ara::diag::OperationOutput &response);
47 void getOdometerValue(ara::diag::OperationOutput &response);
48
49 public:
54 CurlWrapper *curl,
55 std::string resourcesUrl);
56
57 std::future<ara::diag::OperationOutput> HandleMessage(
58 const std::vector<uint8_t> &requestData,
59 ara::diag::MetaInfo &metaInfo,
60 ara::diag::CancellationHandler &&cancellationHandler) override;
61 };
62 }
63}
64
65#endif
Minimalist C++ wrapper of easy (blocking interface) CURL library for RESTful communication.
Definition: curl_wrapper.h:13
Memory cache helper class with expiration time.
Definition: memory_cache.h:17
UDS to read data at the diagnostic server by passing the data ID (DID)
Definition: read_data_by_identifier.h:15
std::future< ara::diag::OperationOutput > HandleMessage(const std::vector< uint8_t > &requestData, ara::diag::MetaInfo &metaInfo, ara::diag::CancellationHandler &&cancellationHandler) override
Handle an UDS request message.
Definition: read_data_by_identifier.cpp:255
ReadDataByIdentifier(CurlWrapper *curl, std::string resourcesUrl)
Constructor.
Definition: read_data_by_identifier.cpp:19
AUTOSAR shortname-path wrapper.
Definition: instance_specifier.h:14
A wrapper class around a conversation cancellation handler callback.
Definition: cancellation_handler.h:12
Diagnostic metainfo in different context.
Definition: meta_info.h:24
An UDS service to handle a diagnostic request by offering itself to a router.
Definition: routable_uds_service.h:28
AUTOSAR application namespace.
Definition: diag_message_handler.cpp:5
Positive response of a handled UDS request.
Definition: routable_uds_service.h:17