Add get and set and notification support to the fields in the configuration#405
Conversation
65d3943 to
7c3e519
Compare
7c3e519 to
4ccfdb8
Compare
4ccfdb8 to
eef7275
Compare
| class LolaFieldInstanceDeployment | ||
| { | ||
| public: | ||
| using SampleSlotCountType = std::uint16_t; |
There was a problem hiding this comment.
These aliases are part of LolaEventInstanceDeployment so should be removed. If you need them here, then you should access them via LolaEventInstanceDeployment.
There was a problem hiding this comment.
- I have removed -
using SampleSlotCountType = std::uint16_t; using SubscriberCountType = std::uint8_t; using TracingSlotSizeType = std::uint8_t;
and updated with the "LolaEventInstanceDeployment". example like below -
void SetNumberOfSampleSlots(LolaEventInstanceDeployment::SampleSlotCountType number_of_sample_slots) noexcept;
| "type": "string", | ||
| "title": "Service Instance Specifier", | ||
| "description": "Represents the InstanceSpecifier value. This is itself an AUTOSAR short-name-path (representing a port prototype of a software component instance). For comfort reasons, we allow also the usage of abbreviated short-name-paths (short-name-paths with a number of components starting from root being removed) in case they are still unique within an executable (this json/configuration is a per executable config!). From AUTOSAR concept perspective an executable contains a 'root sw-component', which itself can be a nested composition of AdaptiveApplicationSwComponentTypes). Because of this 'compositing feature' it could be the case, that the direct short-name of a port prototype isn’t unique within the composition making up the executable. In reality however the port names are 95% unique and forcing the usage of lengthy short-name-paths can be annoying! So this translates to the following rules:\n1. A config file with two “instanceSpecifiers”, where one is only a trailing substring of the other is INVALID!\n2. If user code makes a resolve/lookup providing an 'instanceSpecifier' in the form of an abbreviated short-name-path, which turns out NOT being unique with respect to the config, this is a hard programming/configuration fault, which shall lead to an abort." | ||
| "description": "Represents the InstanceSpecifier value. This is itself an AUTOSAR short-name-path (representing a port prototype of a software component instance). For comfort reasons, we allow also the usage of abbreviated short-name-paths (short-name-paths with a number of components starting from root being removed) in case they are still unique within an executable (this json/configuration is a per executable config!). From AUTOSAR concept perspective an executable contains a 'root sw-component', which itself can be a nested composition of AdaptiveApplicationSwComponentTypes). Because of this 'compositing feature' it could be the case, that the direct short-name of a port prototype isn\u2019t unique within the composition making up the executable. In reality however the port names are 95% unique and forcing the usage of lengthy short-name-paths can be annoying! So this translates to the following rules:\n1. A config file with two \u201cinstanceSpecifiers\u201d, where one is only a trailing substring of the other is INVALID!\n2. If user code makes a resolve/lookup providing an 'instanceSpecifier' in the form of an abbreviated short-name-path, which turns out NOT being unique with respect to the config, this is a hard programming/configuration fault, which shall lead to an abort." |
|
|
||
| const auto& service_instance_map = [service_element_type, &lola_service_instance_deployment]() { | ||
| if (service_element_type == ServiceElementType::EVENT) | ||
| const auto service_element_name = service_element.service_element_name.data(); |
There was a problem hiding this comment.
To minimize the duplicated code, maybe we can change the lambda to be get_number_of_tracing_slots which accepts auto service_elements_map (which can be events_ or fields_) and do the map lookup within the lambda?
There was a problem hiding this comment.
Updated to lambda that takes service_elements_map (which can be events_ or fields_) to avoid the duplicated code.
| EXPECT_EQ(secondDeploymentInfo.fields_.at("CurrentTemperatureFrontLeft") | ||
| .lola_event_instance_deployment_.max_concurrent_allocations_.value(), | ||
| 1); | ||
| EXPECT_FALSE(secondDeploymentInfo.fields_.at("CurrentTemperatureFrontLeft").use_get_if_available_); |
There was a problem hiding this comment.
The values should be changed so that they're true. Makes it more likely to catch if we're not correctly parsing the value (since defualt is false).
There was a problem hiding this comment.
Done. And updated the mw_com_config.json file also accordingly
| {static} + CreateFromJson(json_object : const score::json::Object&) : LolaFieldInstanceDeployment | ||
| + Serialize() const : score::json::Object | ||
| -- | ||
| <u>Type Aliases:</u> |
There was a problem hiding this comment.
Aliases should be removed since they're part of the event deployment.
| + is_set_configured: bool | ||
| + is_get_configured: bool | ||
| {static} + constexpr serializationVersion : std::uint32_t | ||
| + max_subscribers_ : std::optional<SubscriberCountType> |
There was a problem hiding this comment.
We now compose a LolaEventInstanceDeployment.
There was a problem hiding this comment.
Done. I have removed the max_subscribers_, max_concurrent_allocations_, enforce_max_samples_
and updated with LolaEventInstanceDeployment.
| // coverity[autosar_cpp14_m11_0_1_violation] | ||
| LolaEventInstanceDeployment lola_event_instance_deployment_; | ||
| // coverity[autosar_cpp14_m11_0_1_violation] | ||
| bool use_get_if_available_; |
There was a problem hiding this comment.
Should be an optional because it's mandatory on proxy side and not used on skeleton side. Doesn't make sense to have a value on skeleton side.
eef7275 to
b89ebe4
Compare
7287d32 to
70409f5
Compare
| kDefaultLolaInstanceId, | ||
| {}, | ||
| {{test::kFooEventName, LolaFieldInstanceDeployment{test::kMaxSlots, 10U, 1U, true, 0}}}, | ||
| {{test::kFooEventName, |
There was a problem hiding this comment.
hm - unexpected to me ... why don't you use kFooFieldName here?
There was a problem hiding this comment.
Updated with kFooFieldName
| kDefaultLolaInstanceId, | ||
| {}, | ||
| {{test::kFooEventName, LolaFieldInstanceDeployment{test::kMaxSlots, 10U, 1U, true, 0}}}, | ||
| {{test::kFooEventName, |
There was a problem hiding this comment.
see above ... why not kFooFieldName?
|
|
||
| lola_field_inst_depls.push_back( | ||
| {test::kFooEventName, LolaFieldInstanceDeployment{number_of_slots, 10U, 1U, true, 0}}); | ||
| {test::kFooEventName, |
There was a problem hiding this comment.
see above ... kFooFieldName ?
| LolaEventInstanceDeployment{number_of_slots, 10U, 1U, true, 0}, false, false}}); | ||
| lola_field_inst_depls.push_back( | ||
| {test::kDumbEventName, LolaFieldInstanceDeployment{number_of_slots, 10U, 1U, true, 0}}); | ||
| {test::kDumbEventName, |
There was a problem hiding this comment.
see above ... kDumbFieldName ?
| } | ||
|
|
||
| TEST_F(LolaFieldInstanceDeploymentFixture, UseSetIfAvailableIsTrueAfterRoundTripSerialisation) | ||
| INSTANTIATE_TEST_SUITE_P(UseGetIfAvailable, LolaFieldInstanceDeploymentUseGetParamFixture, ::testing::Values(true)); |
There was a problem hiding this comment.
Hm? You are only instantiating the parametrized test with true here? Shouldn't you do:
INSTANTIATE_TEST_SUITE_P(UseGetIfAvailable, LolaFieldInstanceDeploymentUseGetParamFixture, ::testing::Values(true, false)); or
INSTANTIATE_TEST_SUITE_P(UseGetIfAvailable, LolaFieldInstanceDeploymentUseGetParamFixture, ::testing::Bool());
... and I think you still have a lot duplication and don't exploit parametrized-tests fully!
Your parametrization should consist of bool-pairs (1st element is enableGet, 2nd element is enableSet).
So your testing-values should be:
std::pair<bool, bool>{true, true}
std::pair<bool, bool>{true, false}
std::pair<bool, bool>{false, true}
std::pair<bool, bool>{false, false}
There was a problem hiding this comment.
I would even go one step further and make it something like:
enum class Getter
{
ENABLED,
DISABLED
};
std::pair<Getter, Setter>{Getter::ENABLED, Setter::ENABLED};
std::pair<Getter, Setter>{Getter::ENABLED, Setter::DISABLED};
| namespace detail | ||
| { | ||
|
|
||
| template <typename LolaServiceElementInstanceDeployment> |
There was a problem hiding this comment.
This pre-decl seems unneeded? Just shift the definition in line 50 below the GetSkeletonEventProperties() func template beginning in line 57?
There was a problem hiding this comment.
OK. I guess our plumbing code now is "a mess"!?
CreateSkeletonServiceElement and the template arg element_type imply, that this func-template can deal with all the element types (Event/Field/Method). But this is dead-wrong! If you look at the code (namely line 119), where explicitly event-properties are set up ... it is obvious, that we woud get compile-time errors, when trying to instantiate this func-template for a METHOD. (Right now we are obviously NOT doing it - the plumbing code for methods doesn't use this.)
Bottom line:
- at least rename the func-template to
CreateSkeletonEventOrField() - since we still might need the template arg
element_type, we shouldstatic_asserthere, that it is either FIELD or EVENT. - eventually shift the whole code from
skeleton_service_element_binding_factory_impl.htoskeleton_event_binding_factory_impl.h... and "re-use" the functionality from there in case of a FIELD.skeleton_service_element_binding_factory_impl.hcan then be removed ...
There was a problem hiding this comment.
From memory, Krishna has a pr somewhere making a similar change. But I agree that it should be CreateSkeletonEventOrField for the moment. In the future, I don't have a strong preference about having skeleton_service_element_binding_factory_impl (although renamed) or calling the event function directly from the field factory.
| if (service_element_type == ServiceElementType::FIELD) | ||
| const auto service_element_name = service_element.service_element_name.data(); | ||
| const auto get_number_of_tracing_slots = | ||
| [&](const auto& service_elements_map) noexcept -> LolaEventInstanceDeployment::TracingSlotSizeType { |
There was a problem hiding this comment.
Nitpicky ;) - You don't need to (globally) capture here (this you should typically avoid) ... why not hand over service_element_name as a call-arg to the lambda?
70409f5 to
b4d8a2a
Compare
6ee5667 to
5457da1
Compare
| lola_service_element_instance_deployment.enforce_max_samples_}; | ||
| } | ||
|
|
||
| inline lola::SkeletonEventProperties GetSkeletonEventProperties( |
There was a problem hiding this comment.
Why have this intermediate function?
There was a problem hiding this comment.
removed the inline function and directly updated the GetSkeletonEventProperties
There was a problem hiding this comment.
From memory, Krishna has a pr somewhere making a similar change. But I agree that it should be CreateSkeletonEventOrField for the moment. In the future, I don't have a strong preference about having skeleton_service_element_binding_factory_impl (although renamed) or calling the event function directly from the field factory.
- Introduce dedicated LolaFieldInstanceDeployment class replacing the former LolaEventInstanceDeployment type alias, adding field-specific members use_get_if_available_ and use_set_if_available_. - Fix mw_com_config_schema.json: move useGetIfAvailable and useSetIfAvailable into the field "properties" object so they are correctly validated when additionalProperties is false. Issue: SWP-250429
- Update config_parser.cpp to read optional field values useGetIfAvailable/useSetIfAvailable - Fix existing unit test of loloa field instance deployment. Issue: SWP-250429
Update existing tests which refer LolaFieldInstanceDeployment to support additional optional useGetIfAvailable and useSetIfAvailable Issue: SWP-250429
- Add tests to verfiy behaviour of option field values useGetIfAvailable/useSetIfAvailable Issue: SWP-250429
- Update ReadMe and UML diagram to refelct updated changes optional field values useGetIfAvailable/useSetIfAvailable Issue: SWP-250429
- Remove the redundant unit tests and update the exsiting test for default field setter/getter value - Update the default values of useGetIfAvailable/useSetIfAvailable from default false to true - Update the plant UML diagram to retain only necessary information Issue: SWP-250429
… LolaEventInstanceDeployment members - Delegate GetNumberOfSampleSlots(), GetNumberOfTracingSlots(), and SetNumberOfSampleSlots() to the inner lola_event_instance_deployment_ member - Delegate CreateFromJson() event parsing and Serialize() event part to LolaEventInstanceDeployment - Add a non-template GetSkeletonEventProperties() overload in skeleton_service_element_binding_factory_impl.h that delegates to the event deployment overload - Update all call sites: config_parser.cpp, configuration_test_resources.cpp, and all affected test files
0677f55 to
0f14d65
Compare
Add useGetIfAvailable/useSetIfAvailable to LoLa field deployment
Issue: SWP-250429