Task IF refactoring #636

Merged
gaisser merged 34 commits from mueller/task-if-refactoring into development 2022-06-20 16:08:03 +02:00
Owner

These changes were tested on all OSALs. The FreeRTOS and RTEMS updates wered tested in the FSFW example for the STM32H7. The Linux changes were tested in the EIVE fork.
The hosted changes were tested in the hosted FSFW example.

Also, some other general improvements/notes:

There seems to be a concensus that virtual functions should not have default arguments. See https://google.github.io/styleguide/cppguide.html#Default_Arguments

The defaults for arguments in a virtual function call are determined by the static type of the target object, and there's no guarantee that all overrides of a given function declare the same defaults.

and this stack overflow post https://www.google.com/search?channel=fs&client=ubuntu&q=default+arguments+on+virtual+or+override+methods+are+prohibited .

Also, clang-tidy recommends adding [[nodiscard]] to all constant getters.
For me, this seems to be a reasonable action. It can prevent missed returnvalue checks and useless getter function calls. If someone decides to actively ignore a returnvalue, they can explicitely cast the function call to void to avoid the warning.

Also, it might be a good idea to compile the FreeRTOS and RTEMS OSALs in the CI/CD as well. It should be possible to create a docker container which has all necessary tools pre-installed.

Refactoring general task code

  • There was a lot of duplicate/boilerplate code inside the individual task IF OSAL implementations. Remove it by introducing base classes PeriodicTaskBase and FixedTimeslotTaskBase.
  • A lot of clang-tidy improvements

Refactor PeriodicTaskIF

  • Convert virtual ReturnValue_t addComponent(object_id_t object) to virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode = 0), allowing to pass the operation code passed to performOperation. Update API taking an ExecutableObjectIF accordingly

Refactor FixedTimeslotTaskIF

  • Add additional addSlot function which takes an ExecutableObjectIF pointer and its Object ID

Refactor FixedSequenceSlot

  • Introduce typedef CustomCheckFunc for ReturnValue_t (*customCheckFunction)(const SlotList&).
  • Convert ReturnValue_t (*customCheckFunction)(const SlotList&) to ReturnValue_t (*customCheckFunction)(const SlotList&, void*), allowing arbitrary user arguments
    for the custom checker

Linux OSAL

  • Use composition instead of inheritance for the PeriodicPosixTask and make the PosixTask a member of the class
These changes were tested on all OSALs. The FreeRTOS and RTEMS updates wered tested in the FSFW example for the STM32H7. The Linux changes were tested in the EIVE fork. The hosted changes were tested in the hosted FSFW example. Also, some other general improvements/notes: There seems to be a concensus that virtual functions should not have default arguments. See https://google.github.io/styleguide/cppguide.html#Default_Arguments ``` The defaults for arguments in a virtual function call are determined by the static type of the target object, and there's no guarantee that all overrides of a given function declare the same defaults. ``` and this stack overflow post https://www.google.com/search?channel=fs&client=ubuntu&q=default+arguments+on+virtual+or+override+methods+are+prohibited . Also, `clang-tidy` recommends adding `[[nodiscard]]` to all constant getters. For me, this seems to be a reasonable action. It can prevent missed returnvalue checks and useless getter function calls. If someone decides to actively ignore a returnvalue, they can explicitely cast the function call to void to avoid the warning. Also, it might be a good idea to compile the FreeRTOS and RTEMS OSALs in the CI/CD as well. It should be possible to create a docker container which has all necessary tools pre-installed. ## Refactoring general task code - There was a lot of duplicate/boilerplate code inside the individual task IF OSAL implementations. Remove it by introducing base classes `PeriodicTaskBase` and `FixedTimeslotTaskBase`. - A lot of `clang-tidy` improvements ## Refactor PeriodicTaskIF - Convert `virtual ReturnValue_t addComponent(object_id_t object)` to `virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode = 0)`, allowing to pass the operation code passed to `performOperation`. Update API taking an `ExecutableObjectIF` accordingly ## Refactor FixedTimeslotTaskIF - Add additional `addSlot` function which takes an `ExecutableObjectIF` pointer and its Object ID ## Refactor FixedSequenceSlot - Introduce typedef `CustomCheckFunc` for `ReturnValue_t (*customCheckFunction)(const SlotList&)`. - Convert `ReturnValue_t (*customCheckFunction)(const SlotList&)` to `ReturnValue_t (*customCheckFunction)(const SlotList&, void*)`, allowing arbitrary user arguments for the custom checker ## Linux OSAL - Use composition instead of inheritance for the `PeriodicPosixTask` and make the `PosixTask` a member of the class
muellerr added 10 commits 2022-05-30 10:48:19 +02:00
fsfw/fsfw/pipeline/pr-development There was a failure building this commit Details
7b3de87364
removed some changes which belong in separate PR
fsfw/fsfw/pipeline/pr-development There was a failure building this commit Details
d504589c3c
Merge remote-tracking branch 'upstream/development' into mueller/task-if-refactoring
fsfw/fsfw/pipeline/pr-development There was a failure building this commit Details
e87b5a0207
new base class for periodic tasks
fsfw/fsfw/pipeline/pr-development There was a failure building this commit Details
b47eb0a7ff
minor bugfix
fsfw/fsfw/pipeline/pr-development There was a failure building this commit Details
1886da0d3f
refactoring host osal
fsfw/fsfw/pipeline/head There was a failure building this commit Details
64e7d4bb5e
continued refactoring
fsfw/fsfw/pipeline/head There was a failure building this commit Details
08f1ebf9fc
continued refactoring
fsfw/fsfw/pipeline/head There was a failure building this commit Details
3a16290707
refactored and tested hosted and linux task IF
muellerr added this to the v5.0.0 milestone 2022-05-30 10:49:52 +02:00
muellerr changed title from Task IF refactoring to WIP: Task IF refactoring 2022-05-30 10:50:50 +02:00
muellerr changed title from WIP: Task IF refactoring to Task IF refactoring 2022-05-30 11:41:36 +02:00
muellerr changed title from Task IF refactoring to WIP: Task IF refactoring 2022-05-30 12:13:35 +02:00
muellerr changed title from WIP: Task IF refactoring to Task IF refactoring 2022-05-30 12:23:07 +02:00
muellerr requested review from mohr 2022-05-30 12:23:14 +02:00
muellerr requested review from gaisser 2022-05-30 12:23:14 +02:00
muellerr force-pushed mueller/task-if-refactoring from 6546be5013 to ad53b48fcb 2022-06-08 12:12:15 +02:00 Compare
muellerr added 1 commit 2022-06-08 17:33:36 +02:00
muellerr added 1 commit 2022-06-08 17:36:34 +02:00
fsfw/fsfw/pipeline/pr-development This commit looks good Details
a0ee86ace8
use override instead of virtual as recommended
muellerr added the
Refactor
label 2022-06-13 10:59:15 +02:00
mohr requested changes 2022-06-13 11:24:28 +02:00
mohr left a comment
Owner

I would prefer a bitmore vocal name for dlmFunc_.

As you can see from me nitpicking naming conventions, no bigger issues from my side ;)

I would prefer a bitmore vocal name for `dlmFunc_`. As you can see from me nitpicking naming conventions, no bigger issues from my side ;)
@ -52,3 +47,1 @@
uint32_t getPeriodMs() const override;
ReturnValue_t checkSequence() const override;
static uint32_t MISSED_DEADLINE_COUNT;
Owner

what is the reasoning to make the static variable namw CAPS? For me CAPS is used for static constexpr constants, which do not change during runtime, while the static member does change.

Also, is it useful to move this into the base class?

what is the reasoning to make the static variable namw CAPS? For me CAPS is used for `static constexpr` constants, which do not change during runtime, while the static member does change. Also, is it useful to move this into the base class?
Author
Owner

dlmFunc_ is ok in my opinion, the purpose in encoded inside the very long typename TaskDeadlineMissedFunction

`dlmFunc_` is ok in my opinion, the purpose in encoded inside the very long typename `TaskDeadlineMissedFunction`
Author
Owner

Removed the statics in all OSAL. The way they are used does not make a lot of sense and the usage of the static is not thread-safe either.

Removed the statics in all OSAL. The way they are used does not make a lot of sense and the usage of the static is not thread-safe either.
mohr marked this conversation as resolved
gaisser refused to review 2022-06-13 14:11:33 +02:00
muellerr added 1 commit 2022-06-13 14:24:00 +02:00
fsfw/fsfw/pipeline/pr-development This commit looks good Details
a682bbe400
remove static missed deadline
muellerr added 1 commit 2022-06-20 09:40:33 +02:00
fsfw/fsfw/pipeline/pr-development This commit looks good Details
d47a908117
Merge branch 'development' into mueller/task-if-refactoring
mohr approved these changes 2022-06-20 11:41:05 +02:00
mohr left a comment
Owner

LGTM

LGTM
muellerr added 1 commit 2022-06-20 14:25:49 +02:00
fsfw/fsfw/pipeline/pr-development This commit looks good Details
4b33aa8262
bump ETL version
Owner

Does not build on Linux. Will be fixed asap

Does not build on Linux. Will be fixed asap
gaisser added 2 commits 2022-06-20 15:12:11 +02:00
Owner

Linux OSAL builds now.

Linux OSAL builds now.
gaisser added a new dependency 2022-06-20 15:45:29 +02:00
gaisser approved these changes 2022-06-20 16:04:08 +02:00
gaisser left a comment
Owner

LGTMT

LGTMT
gaisser merged commit c3aaab4b93 into development 2022-06-20 16:08:03 +02:00
gaisser deleted branch mueller/task-if-refactoring 2022-06-20 16:08:06 +02:00
Sign in to join this conversation.
No description provided.