Compare commits
641 Commits
mueller/de
...
ASTP_0.0.1
Author | SHA1 | Date | |
---|---|---|---|
64b6edab6f | |||
3bd144e6f4 | |||
4764f6ba54 | |||
a2c28198ed | |||
4241c00448 | |||
4406c6eb86 | |||
ce629dfd83 | |||
293d34147e | |||
9bfba41875 | |||
5a20ec583b | |||
d3a7f86ea2 | |||
227ec25e89 | |||
6489246c4b | |||
273ddf9061 | |||
5b5f2f3e1d | |||
51443d7a68 | |||
8aef4b9b99 | |||
752601e85f | |||
0075ae53b3 | |||
520409822e | |||
030f1beb93 | |||
2a4b4f2114 | |||
bb7709fea1 | |||
bc58213482 | |||
136f04a5c6 | |||
37fc22a117 | |||
bc81b5893c | |||
3eefcd3a2d | |||
210d2de11e | |||
83568e11d1 | |||
113397c6c6 | |||
3cd0f8f5f0 | |||
edecb7882b | |||
cc51d9ace9 | |||
3067259a9b | |||
7d83767c2b | |||
59c200254d | |||
2f993cf39a | |||
6bedc9b805 | |||
652dc00cc9 | |||
719aab2a26 | |||
470196a044 | |||
9c9facf4a1 | |||
cf46aebf32 | |||
449a08c92c | |||
a7e06c11fd | |||
0c15a90399 | |||
bcbc61ccba | |||
9221d0ca7c | |||
a7bc69b0ac | |||
77fd2cb871 | |||
093d3562b6 | |||
2761ee8109 | |||
52d3dbfd20 | |||
963c333365 | |||
b441f5242f | |||
508f31a359 | |||
5d0f96c3a1 | |||
82a2f3ec61 | |||
a5cf510ae9 | |||
a0d4c77d94 | |||
0b855c5b55 | |||
38830dfc17 | |||
11a351a202 | |||
51c5b05f03 | |||
de5e62a9c8 | |||
3098f34eb0 | |||
e35aebcd0a | |||
af4c6f1d45 | |||
9b5e940965 | |||
f5b0589f79 | |||
567cbd39ef | |||
78896323b6 | |||
ba036805de | |||
9af5855ece | |||
64c341b5f6 | |||
27e0b9cf38 | |||
4dd79b3495 | |||
64ec4835f3 | |||
4229e256d1 | |||
352296d200 | |||
4557a2eb36 | |||
edb2d3848d | |||
096643971b | |||
56da648026 | |||
38135a3d53 | |||
3c1415a4bd | |||
08496c378e | |||
af18f6c94c | |||
5a8431e82b | |||
97f6dace26 | |||
c8fd698b3a | |||
50151310dc | |||
53e98df37d | |||
cb71a18277 | |||
546db47db4 | |||
ce322ed121 | |||
744d3a2346 | |||
c89a24a248 | |||
6651622a16 | |||
410094ed28 | |||
8b21324815 | |||
f40b432e43 | |||
67dd153511 | |||
342a70d109 | |||
6cce062d62 | |||
29a796ebdb | |||
ede00dfdcc | |||
e4d323683d | |||
4d4300cee6 | |||
1940a2acf0 | |||
279682351a | |||
247c9f2947 | |||
482b77ff05 | |||
72b9adb684 | |||
865ea3386c | |||
c677358343 | |||
7821cc2870 | |||
756df4f37f | |||
0b1b9c11eb | |||
ddacc66b1f | |||
fa67f82462 | |||
407df913d3 | |||
b29376bd71 | |||
3580ec0e09 | |||
12369d8d4b | |||
6b2df54204 | |||
8cea7b05db | |||
17548605ec | |||
829be0f082 | |||
17ea3127a7 | |||
ea8ef8b874 | |||
54af54927b | |||
9bf0026b8a | |||
335e146735 | |||
6776ca86eb | |||
f172c07876 | |||
0a9a8cf867 | |||
f1bc9972f3 | |||
7c7b3de14f | |||
587f87d270 | |||
cd2cb410e4 | |||
b292c5c927 | |||
4f91db2ff8 | |||
c86d654fdf | |||
1f3a10b375 | |||
b8261854cb | |||
89c4370d91 | |||
565859a6f4 | |||
1f994d9933 | |||
5342dc4bc8 | |||
a5a850eb41 | |||
c77bded505 | |||
acc03d3e8b | |||
d647c63da3 | |||
ea13008aa2 | |||
7c3f99ed2d | |||
2344efb3ac | |||
236a833d0b | |||
6c4ec713f3 | |||
b2a7859549 | |||
8178be9dc5 | |||
adf528fce9 | |||
6efdf170f4 | |||
a14558ef1f | |||
77a9a190aa | |||
a0098e8b17 | |||
fcabf93af3 | |||
ab9858b0c7 | |||
823bae1a2a | |||
2f61bd0a0f | |||
aeeef53508 | |||
8d8e918aeb | |||
ecc4bdf11a | |||
5340b9c58e | |||
659671e1df | |||
5fc583117d | |||
86a1ae4a8a | |||
195bf6b89f | |||
f5ded3fa4b | |||
e104cd18e6 | |||
71f2f34aab | |||
6c0bb23ed6 | |||
303fcec9f6 | |||
f73f798a4d | |||
4fce0377a9 | |||
4eef7bfc01 | |||
17d5de15c9 | |||
cdadf48f38 | |||
896302c506 | |||
1bdccedabe | |||
db5890c15a | |||
72f924813d | |||
dffda771ac | |||
06f5b816e4 | |||
3d830a9e20 | |||
13b30f8de6 | |||
e71020d631 | |||
046eec6c18 | |||
47c21cfc6c | |||
00f89bb193 | |||
6879045ef3 | |||
c9005783b2 | |||
4010d8d960 | |||
a3235ced17 | |||
d3ce6d147e | |||
ce983953ff | |||
a71528551a | |||
6a5268f5b0 | |||
392d0299a9 | |||
8ade9e33c1 | |||
37c605c4fb | |||
ea29b272bf | |||
e55f8f583d | |||
d6e82f64e7 | |||
a700f6a96d | |||
6c86cf88f3 | |||
352ce13fb3 | |||
1ed1b7ea06 | |||
a58e47623f | |||
622c7a5a0d | |||
bed4e7affa | |||
1ff85c88b2 | |||
cef84b13d9 | |||
6f965c74ac | |||
b2677ae040 | |||
dae79f30d7 | |||
c01d904552 | |||
7dbb73b7d8 | |||
9f7dad31eb | |||
21cbb19410 | |||
170217e2e8 | |||
bf5e7241b6 | |||
291a62eeb9 | |||
945f49bbe9 | |||
183b6a4193 | |||
75bdf96799 | |||
6d2266f7d0 | |||
9d4c2b90f3 | |||
7b57f372bf | |||
bf5688c8d8 | |||
a0bc6b3c1f | |||
eec022f801 | |||
20279169ed | |||
2edc7fd096 | |||
13b68f10a0 | |||
496251bd68 | |||
22d9b77165 | |||
40558835c7 | |||
842c21684a | |||
d1fb512c1f | |||
59f72d1031 | |||
978d7514a4 | |||
2f73841580 | |||
74a4c98ca7 | |||
0bc3807c18 | |||
d0f912f32b | |||
b681a76f29 | |||
ed80768c66 | |||
de840dcf8d | |||
e0d9a080c5 | |||
59e4b95b62 | |||
ab0f4d8c87 | |||
98333b92ef | |||
87fb17f39a | |||
8652f2f13f | |||
cea748676e | |||
74b9aef36b | |||
7dc3a7ecbd | |||
4248e4000c | |||
b2777faf66 | |||
9faa8d3896 | |||
8f2c8c838e | |||
66383f78c6 | |||
522433e1b5 | |||
156f44c268 | |||
56c6f971e1 | |||
33de6851eb | |||
f575c923d7 | |||
40d83fe603 | |||
bb896faeb4 | |||
3aa9ab2048 | |||
580669d49d | |||
90b3ebd390 | |||
1791b5af57 | |||
108f897102 | |||
9aaa5721af | |||
ade9c32ff3 | |||
da4f6cf447 | |||
4587fbb76d | |||
af53bf6643 | |||
d8c5c4d85d | |||
17583f605d | |||
5e974877fe | |||
447b69bf03 | |||
37cf7566f9 | |||
0d8200e856 | |||
7851a71a8e | |||
721793a058 | |||
8ea0a38658 | |||
6062192bf0 | |||
85f21b0516 | |||
386f347574 | |||
56ff2aef26 | |||
ad8c6f3528 | |||
0f0ddfc375 | |||
96f2b68a22 | |||
53723b0795 | |||
b0a816490e | |||
963015513f | |||
85d6e81881 | |||
b31bee4fda | |||
ae426c50ba | |||
a5c6be9dd9 | |||
21346e40a5 | |||
589b95d28b | |||
d38e13f9d3 | |||
3fcbb988ae | |||
e96ab12312 | |||
f3d42de399 | |||
db697f16de | |||
42bfedd36c | |||
9061d6d67e | |||
c375e838b8 | |||
d77d370c8a | |||
21094c4926 | |||
51cf13428b | |||
b4ca42f1fb | |||
bff08a69fa | |||
4f5b233505 | |||
9334a705f8 | |||
2c6a239d5e | |||
fbd75f947a | |||
4c17ef7be5 | |||
4f48ed9756 | |||
6362de5bc0 | |||
d83573cefc | |||
8048195f63 | |||
853bd75fec | |||
d807ea3afe | |||
036a022e66 | |||
489d8f1903 | |||
be0cf56994 | |||
bbd81c2d6a | |||
e7444912d5 | |||
b8d638cb69 | |||
1635f16bc0 | |||
c63baf70a1 | |||
0da6456bad | |||
db2a31aef4 | |||
de46cf5b08 | |||
a364f36f38 | |||
2d76c744c5 | |||
d1f8040599 | |||
e24e080f31 | |||
dab10d761a | |||
976fd54f5e | |||
d87cf0a612 | |||
b3af2b5fbc | |||
fb36c55419 | |||
5dd08877a5 | |||
0258ce62f0 | |||
b65789824c | |||
278053a342 | |||
2a28114b49 | |||
67b11c0535 | |||
6c42189371 | |||
2439ac455b | |||
a9975f5aef | |||
ba01b4578c | |||
234fbcbf41 | |||
f7223abaa3 | |||
902cd4d210 | |||
a1155686c5 | |||
c6dbce7446 | |||
1a62158f33 | |||
328c1b7195 | |||
ed21ec6c78 | |||
84308c74d9 | |||
d4d96a128e | |||
e83de82481 | |||
62eb327df6 | |||
dbac6e139b | |||
06400fa7bb | |||
3e67701933 | |||
e105be229a | |||
d885dddee8 | |||
a53b9dc3db | |||
a6b2b4dd93 | |||
a3b80288e1 | |||
91d5277a94 | |||
975fb9832b | |||
4bdac1e017 | |||
381914886d | |||
0eb4c3817e | |||
4d7d48e8ca | |||
b8754fbc16 | |||
92c7369276 | |||
04532b8f6b | |||
5eaf6cfd1f | |||
7ad5274803 | |||
ab9f58438f | |||
4da21d2c38 | |||
b3d08cd40b | |||
d5accd16ba | |||
03b2ca679d | |||
75f6cacd10 | |||
b32ea6e316 | |||
5308cb6237 | |||
4f3869de8d | |||
b522b3c29c | |||
02cfa8bcd5 | |||
96c421b72c | |||
f85e4eb22f | |||
66bc60f176 | |||
695a4e7842 | |||
f068df9028 | |||
636e5fb888 | |||
77927363ce | |||
5d87650833 | |||
e949637271 | |||
4a80872c3c | |||
a9e5b54238 | |||
e77c294360 | |||
7059d5f158 | |||
b07b19327c | |||
4abdc436fb | |||
d644a40e14 | |||
a4d9c761a7 | |||
cc5c944c84 | |||
f645fe6607 | |||
c0ed474373 | |||
f12c56c75f | |||
7a5c70e753 | |||
478b88d7a2 | |||
b54d63edcb | |||
aec557a8c0 | |||
6c0defed5e | |||
3ec7162832 | |||
b4978e7df3 | |||
543e2f7d5d | |||
053f75968b | |||
b87a8ba086 | |||
2362b1d165 | |||
ce4d010b5c | |||
eb503ae030 | |||
795b1e5245 | |||
54112acf62 | |||
c4c607776c | |||
8f2d5a5528 | |||
2a74c8d150 | |||
dfe3658a85 | |||
386b153ede | |||
df4fb17a45 | |||
0fedad6da0 | |||
3be253efd6 | |||
73db79a3fe | |||
7723ee13b3 | |||
073f168b95 | |||
aacda3afc2 | |||
64022212f9 | |||
4530b19548 | |||
89d3fe5095 | |||
66cf2d3559 | |||
02be87aa03 | |||
76f145ddcf | |||
281f13e27b | |||
df850116ff | |||
a8f2cf910b | |||
2748a8b93b | |||
561becf6aa | |||
f13e7b4255 | |||
3f9d9b8770 | |||
9465c8f2b2 | |||
d9ee6d0d90 | |||
1ae79ab99d | |||
6903a761ff | |||
af52d1ffda | |||
7571bc3728 | |||
9fbf0d1d94 | |||
3001911d69 | |||
9a06cb846c | |||
e0a2d09716 | |||
9c29253337 | |||
de98dd0871 | |||
fb0a3d22db | |||
ba4eac65cc | |||
7d2c48fb33 | |||
c8595c3442 | |||
857d61ea13 | |||
825bf62d79 | |||
9245b14569 | |||
6ebe523e50 | |||
f863849a75 | |||
b5d6d5a178 | |||
c0332a80a7 | |||
043710ee56 | |||
fddf31121d | |||
7e0cf49723 | |||
d0419467a7 | |||
1235e38556 | |||
8c150fd40d | |||
a1d1d42e88 | |||
a414be23bf | |||
02de6c41ec | |||
74dea921e0 | |||
ab4c65c87a | |||
49a36d6fdc | |||
a4626aeac0 | |||
84d99a6f04 | |||
b7612bee37 | |||
5210bce64d | |||
26b63d63b9 | |||
1b4c4de3fa | |||
1b8f134029 | |||
5b4e49e966 | |||
180d997b03 | |||
a2c8b3f75b | |||
31f398cec9 | |||
e59022dd43 | |||
c63665c257 | |||
49d4b6ebc7 | |||
549ad97bd3 | |||
111f9dce7d | |||
9e0a905096 | |||
d5dedce294 | |||
287a83c54c | |||
3d89bc83e5 | |||
4a2ef6d97f | |||
b484e4d5ad | |||
7dbab61ab7 | |||
e535bc1427 | |||
18105e2d16 | |||
ebc11bd777 | |||
3d4daa51d5 | |||
e963aca02a | |||
8c722feafb | |||
6b4fa0cc04 | |||
e61fdd0d5e | |||
944226c2ed | |||
a0f41d3238 | |||
20f7217501 | |||
11e23420f2 | |||
3905b72b08 | |||
90a3e2b8c5 | |||
54825dca6b | |||
caeb2f9dd6 | |||
7b3fddfd42 | |||
9d90348175 | |||
9102eec4ab | |||
c42b5283af | |||
ea9288d848 | |||
6ac36cec15 | |||
d58fc5c6f7 | |||
be6060ec94 | |||
f36da8a79c | |||
2e08037e75 | |||
a0ff1e0019 | |||
d8bf1931cc | |||
2198406714 | |||
4213e2e081 | |||
0449c63225 | |||
35fe41361b | |||
802004107b | |||
a9c8bea857 | |||
5df88eb73b | |||
dc4db6e031 | |||
6b03a1c03d | |||
c9bc022941 | |||
36f7cf2caf | |||
646e86ea85 | |||
aca0c94c51 | |||
a0834204da | |||
538962d0c2 | |||
d7e157d908 | |||
3a2dc5eeb6 | |||
85d24b9dfe | |||
97b01f837c | |||
6b2b788308 | |||
65d71b1c65 | |||
d795892d57 | |||
5f76b03f3a | |||
e9166ec4c7 | |||
2fccc4fef7 | |||
8f6c3b50af | |||
b699c8b2b3 | |||
991385de65 | |||
ec212d9fcf | |||
f654c4b33e | |||
d1b9ab5126 | |||
f826ada774 | |||
a682ca97d2 | |||
a589be7c74 | |||
4c59b043e1 | |||
c8b92a8828 | |||
952fc7303a | |||
eb4880f603 | |||
86a6b2fee0 | |||
b5567e8aae | |||
20abb810f2 | |||
ad37848039 | |||
03e9362825 | |||
fbf804cdca | |||
9bcc4c0e3c | |||
869700e6f5 | |||
56340bb8b6 | |||
a6a3180196 | |||
3d175f603c | |||
1d99a99bbd | |||
8e3f99a350 | |||
e20244b0ce | |||
d4f69633f0 | |||
43a7274129 | |||
f871f75e1c | |||
023af149df | |||
a3f379e149 | |||
acf037614f | |||
ab17e28405 | |||
a993223f6e | |||
d83181cb0f | |||
8af5a32f1d | |||
896e7f15dc | |||
2eba865564 | |||
8f563b7b21 | |||
73183b39ef | |||
6c9f157d2c | |||
b4c6a04d4a | |||
adb80a68fc | |||
f829d063ce | |||
d909fcb6a1 | |||
f388bd374c | |||
ca10020f19 | |||
331b36fe18 | |||
730c715120 | |||
7bc29fc2d5 | |||
483a47d353 | |||
7bc7e06277 | |||
4819bad402 | |||
1c967d4739 | |||
eb5832180b | |||
1fb87db82e |
0
.gitmodules
vendored
Normal file
0
.gitmodules
vendored
Normal file
12
FSFWVersion.h
Normal file
12
FSFWVersion.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef FSFW_DEFAULTCFG_VERSION_H_
|
||||
#define FSFW_DEFAULTCFG_VERSION_H_
|
||||
|
||||
const char* const FSFW_VERSION_NAME = "ASTP";
|
||||
|
||||
#define FSFW_VERSION 0
|
||||
#define FSFW_SUBVERSION 0
|
||||
#define FSFW_REVISION 1
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_DEFAULTCFG_VERSION_H_ */
|
2
NOTICE
2
NOTICE
@ -4,6 +4,8 @@ The initial version of the Flight Software Framework was developed during
|
||||
the Flying Laptop Project by the Universität Stuttgart in coorporation
|
||||
with Airbus Defence and Space GmbH.
|
||||
|
||||
The supreme FSFW Logo was designed by Markus Koller and Luise Trilsbach.
|
||||
|
||||
Copyrights in the Flight Software Framework are retained by their contributors.
|
||||
No copyright assignment is required to contribute to the Flight Software Framework.
|
||||
|
||||
|
159
README.md
Normal file
159
README.md
Normal file
@ -0,0 +1,159 @@
|
||||

|
||||
# Flight Software Framework (FSFW)
|
||||
|
||||
The Flight Software Framework is a C++ Object Oriented Framework for unmanned,
|
||||
automated systems like Satellites.
|
||||
|
||||
The initial version of the Flight Software Framework was developed during
|
||||
the Flying Laptop Project by the University of Stuttgart in cooperation
|
||||
with Airbus Defence and Space GmbH.
|
||||
|
||||
## Intended Use
|
||||
|
||||
The framework is designed for systems, which communicate with external devices, perform control loops, receive telecommands and send telemetry, and need to maintain a high level of availability.
|
||||
Therefore, a mode and health system provides control over the states of the software and the controlled devices.
|
||||
In addition, a simple mechanism of event based fault detection, isolation and recovery is implemented as well.
|
||||
|
||||
The recommended hardware is a microprocessor with more than 2 MB of RAM and 1 MB of non-volatile Memory.
|
||||
For reference, current Applications use a Cobham Gaisler UT699 (LEON3FT), a ISISPACE IOBC or a Zynq-7020 SoC.
|
||||
|
||||
|
||||
## Structure
|
||||
|
||||
The general structure is driven by the usage of interfaces provided by objects. The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be widely available, even with older compilers.
|
||||
The FSFW uses dynamic allocation during the initialization but provides static containers during runtime.
|
||||
This simplifies the instantiation of objects and allows the usage of some standard containers.
|
||||
Dynamic Allocation after initialization is discouraged and different solutions are provided in the FSFW to achieve that.
|
||||
The fsfw uses Run-time type information.
|
||||
Exceptions are not allowed.
|
||||
|
||||
### Failure Handling
|
||||
|
||||
Functions should return a defined ReturnValue_t to signal to the caller that something is gone wrong.
|
||||
Returnvalues must be unique. For this the function HasReturnvaluesIF::makeReturnCode or the Macro MAKE_RETURN can be used.
|
||||
The CLASS_ID is a unique id for that type of object. See returnvalues/FwClassIds.
|
||||
|
||||
### OSAL
|
||||
The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS. A independent OSAL called "host" is currently not finished. This aims to be running on windows as well.
|
||||
The OSAL provides periodic tasks, message queues, clocks and Semaphores as well as Mutexes.
|
||||
|
||||
### Core Components
|
||||
|
||||
Clock:
|
||||
* This is a class of static functions that can be used at anytime
|
||||
* Leap Seconds must be set if any time conversions from UTC to other times is used
|
||||
|
||||
ObjectManager (must be created):
|
||||
|
||||
* The component which handles all references. All SystemObjects register at this component.
|
||||
* Any SystemObject needs to have a unique ObjectId. Those can be managed like objects::framework_objects.
|
||||
* A reference to an object can be get by calling the following function. T must be the specific Interface you want to call.
|
||||
A nullptr check of the returning Pointer must be done. This function is based on Run-time type information.
|
||||
|
||||
``` c++
|
||||
template <typename T> T* ObjectManagerIF::get( object_id_t id )
|
||||
|
||||
```
|
||||
* A typical way to create all objects on startup is a handing a static produce function to the ObjectManager on creation.
|
||||
By calling objectManager->initialize() the produce function will be called and all SystemObjects will be initialized afterwards.
|
||||
|
||||
Event Manager:
|
||||
|
||||
* Component which allows routing of events
|
||||
* Other objects can subscribe to specific events, ranges of events or all events of an object.
|
||||
* Subscriptions can be done during runtime but should be done during initialization
|
||||
* Amounts of allowed subscriptions must be configured by setting this parameters:
|
||||
|
||||
``` c++
|
||||
namespace fsfwconfig {
|
||||
//! Configure the allocated pool sizes for the event manager.
|
||||
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
|
||||
static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120;
|
||||
static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Health Table:
|
||||
|
||||
* A component which holds every health state
|
||||
* Provides a thread safe way to access all health states without the need of message exchanges
|
||||
|
||||
Stores
|
||||
|
||||
* The message based communication can only exchange a few bytes of information inside the message itself. Therefore, additional information can be exchanged with Stores. With this, only the store address must be exchanged in the message.
|
||||
* Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC Store is used. For outgoing TM a TM store is used.
|
||||
* All of them should use the Thread Safe Class storagemanager/PoolManager
|
||||
|
||||
Tasks
|
||||
|
||||
There are two different types of tasks:
|
||||
* The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the insertion to the Tasks.
|
||||
* FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for DeviceHandlers, where polling should be in a defined order. An example can be found in defaultcfg/fsfwconfig/pollingSequence
|
||||
|
||||
|
||||
### Static Ids in the framework
|
||||
|
||||
Some parts of the framework use a static routing address for communication.
|
||||
An example setup of ids can be found in the example config in "defaultcft/fsfwconfig/objects/Factory::setStaticFrameworkObjectIds()".
|
||||
|
||||
### Events
|
||||
|
||||
Events are tied to objects. EventIds can be generated by calling the Macro MAKE_EVENT. This works analog to the returnvalues.
|
||||
Every object that needs own EventIds has to get a unique SUBSYSTEM_ID.
|
||||
Every SystemObject can call triggerEvent from the parent class.
|
||||
Therefore, event messages contain the specific EventId and the objectId of the object that has triggered.
|
||||
|
||||
### Internal Communication
|
||||
|
||||
Components communicate mostly over Message through Queues.
|
||||
Those queues are created by calling the singleton QueueFactory::instance()->create().
|
||||
|
||||
### External Communication
|
||||
|
||||
The external communication with the mission control system is mostly up to the user implementation.
|
||||
The FSFW provides PUS Services which can be used to but don't need to be used.
|
||||
The services can be seen as a conversion from a TC to a message based communication and back.
|
||||
|
||||
#### CCSDS Frames, CCSDS Space Packets and PUS
|
||||
|
||||
If the communication is based on CCSDS Frames and Space Packets, several classes can be used to distributed the packets to the corresponding services. Those can be found in tcdistribution.
|
||||
If Space Packets are used, a timestamper must be created.
|
||||
An example can be found in the timemanager folder, this uses CCSDSTime::CDS_short.
|
||||
|
||||
#### DeviceHandling
|
||||
|
||||
DeviceHandlers are a core component of the FSFW.
|
||||
The idea is, to have a software counterpart of every physical device to provide a simple mode, health and commanding interface.
|
||||
By separating the underlying Communication Interface with DeviceCommunicationIF, a DH can be tested on different hardware.
|
||||
The DH has mechanisms to monitor the communication with the physical device which allow for FDIR reaction.
|
||||
A standard FDIR component for the DH will be created automatically but can be overwritten by the user.
|
||||
|
||||
#### Modes, Health
|
||||
|
||||
The two interfaces HasModesIF and HasHealthIF provide access for commanding and monitoring of components.
|
||||
On-board Mode Management is implement in hierarchy system.
|
||||
DeviceHandlers and Controllers are the lowest part of the hierarchy.
|
||||
The next layer are Assemblies. Those assemblies act as a component which handle redundancies of handlers.
|
||||
Assemblies share a common core with the next level which are the Subsystems.
|
||||
|
||||
Those Assemblies are intended to act as auto-generated components from a database which describes the subsystem modes.
|
||||
The definitions contain transition and target tables which contain the DH, Assembly and Controller Modes to be commanded.
|
||||
Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a switch into any higher AOCS mode might first turn on the sensors, than the actuators and the controller as last component.
|
||||
The target table is used to describe the state that is checked continuously by the subsystem.
|
||||
All of this allows System Modes to be generated as Subsystem object as well from the same database.
|
||||
This System contains list of subsystem modes in the transition and target tables.
|
||||
Therefore, it allows a modular system to create system modes and easy commanding of those, because only the highest components must be commanded.
|
||||
|
||||
The health state represents if the component is able to perform its tasks.
|
||||
This can be used to signal the system to avoid using this component instead of a redundant one.
|
||||
The on-board FDIR uses the health state for isolation and recovery.
|
||||
|
||||
## Example config
|
||||
|
||||
A example config can be found in defaultcfg/fsfwconfig.
|
||||
|
||||
## Unit Tests
|
||||
|
||||
Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include catch2 itself.
|
||||
See README.md in the unittest Folder.
|
@ -1,9 +1,12 @@
|
||||
#include <framework/action/ActionHelper.h>
|
||||
#include <framework/action/HasActionsIF.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include "ActionHelper.h"
|
||||
#include "HasActionsIF.h"
|
||||
|
||||
ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) :
|
||||
owner(setOwner), queueToUse(useThisQueue), ipcStore(nullptr) {
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
ActionHelper::ActionHelper(HasActionsIF* setOwner,
|
||||
MessageQueueIF* useThisQueue) :
|
||||
owner(setOwner), queueToUse(useThisQueue) {
|
||||
}
|
||||
|
||||
ActionHelper::~ActionHelper() {
|
||||
@ -32,13 +35,15 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
|
||||
void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo,
|
||||
ActionId_t commandId, ReturnValue_t result) {
|
||||
CommandMessage reply;
|
||||
ActionMessage::setStepReply(&reply, commandId, step + STEP_OFFSET, result);
|
||||
queueToUse->sendMessage(reportTo, &reply);
|
||||
}
|
||||
|
||||
void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
|
||||
void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId,
|
||||
ReturnValue_t result) {
|
||||
CommandMessage reply;
|
||||
ActionMessage::setCompletionReply(&reply, commandId, result);
|
||||
queueToUse->sendMessage(reportTo, &reply);
|
||||
@ -48,8 +53,8 @@ void ActionHelper::setQueueToUse(MessageQueueIF* queue) {
|
||||
queueToUse = queue;
|
||||
}
|
||||
|
||||
void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
|
||||
store_address_t dataAddress) {
|
||||
void ActionHelper::prepareExecution(MessageQueueId_t commandedBy,
|
||||
ActionId_t actionId, store_address_t dataAddress) {
|
||||
const uint8_t* dataPtr = NULL;
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size);
|
||||
@ -61,6 +66,11 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
|
||||
}
|
||||
result = owner->executeAction(actionId, commandedBy, dataPtr, size);
|
||||
ipcStore->deleteData(dataAddress);
|
||||
if(result == HasActionsIF::EXECUTION_FINISHED) {
|
||||
CommandMessage reply;
|
||||
ActionMessage::setCompletionReply(&reply, actionId, result);
|
||||
queueToUse->sendMessage(commandedBy, &reply);
|
||||
}
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
CommandMessage reply;
|
||||
ActionMessage::setStepReply(&reply, actionId, 0, result);
|
||||
@ -85,22 +95,28 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
result = data->serialize(&dataPtr, &size, maxSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
ipcStore->deleteData(storeAddress);
|
||||
return result;
|
||||
}
|
||||
//We don't need to report the objectId, as we receive REQUESTED data before the completion success message.
|
||||
//True aperiodic replies need to be reported with another dedicated message.
|
||||
// We don't need to report the objectId, as we receive REQUESTED data
|
||||
// before the completion success message.
|
||||
// True aperiodic replies need to be reported with
|
||||
// another dedicated message.
|
||||
ActionMessage::setDataReply(&reply, replyId, storeAddress);
|
||||
|
||||
//TODO Service Implementation sucks at the moment
|
||||
if (hideSender){
|
||||
// If the sender needs to be hidden, for example to handle packet
|
||||
// as unrequested reply, this will be done here.
|
||||
if (hideSender) {
|
||||
result = MessageQueueSenderIF::sendMessage(reportTo, &reply);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = queueToUse->sendMessage(reportTo, &reply);
|
||||
}
|
||||
if ( result != HasReturnvaluesIF::RETURN_OK){
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK){
|
||||
ipcStore->deleteData(storeAddress);
|
||||
}
|
||||
return result;
|
||||
@ -108,3 +124,39 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
||||
|
||||
void ActionHelper::resetHelper() {
|
||||
}
|
||||
|
||||
ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
||||
ActionId_t replyId, const uint8_t *data, size_t dataSize,
|
||||
bool hideSender) {
|
||||
CommandMessage reply;
|
||||
store_address_t storeAddress;
|
||||
ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
ipcStore->deleteData(storeAddress);
|
||||
return result;
|
||||
}
|
||||
|
||||
// We don't need to report the objectId, as we receive REQUESTED data
|
||||
// before the completion success message.
|
||||
// True aperiodic replies need to be reported with
|
||||
// another dedicated message.
|
||||
ActionMessage::setDataReply(&reply, replyId, storeAddress);
|
||||
|
||||
// If the sender needs to be hidden, for example to handle packet
|
||||
// as unrequested reply, this will be done here.
|
||||
if (hideSender) {
|
||||
result = MessageQueueSenderIF::sendMessage(reportTo, &reply);
|
||||
}
|
||||
else {
|
||||
result = queueToUse->sendMessage(reportTo, &reply);
|
||||
}
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK){
|
||||
ipcStore->deleteData(storeAddress);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
#ifndef ACTIONHELPER_H_
|
||||
#define ACTIONHELPER_H_
|
||||
#ifndef FSFW_ACTION_ACTIONHELPER_H_
|
||||
#define FSFW_ACTION_ACTIONHELPER_H_
|
||||
|
||||
#include <framework/action/ActionMessage.h>
|
||||
#include <framework/serialize/SerializeIF.h>
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
#include "ActionMessage.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
/**
|
||||
* \brief Action Helper is a helper class which handles action messages
|
||||
* @brief Action Helper is a helper class which handles action messages
|
||||
*
|
||||
* Components which use the HasActionIF this helper can be used to handle the action messages.
|
||||
* It does handle step messages as well as other answers to action calls. It uses the executeAction function
|
||||
* of its owner as callback. The call of the initialize function is mandatory and it needs a valid messageQueueIF pointer!
|
||||
* Components which use the HasActionIF this helper can be used to handle
|
||||
* the action messages.
|
||||
* It does handle step messages as well as other answers to action calls.
|
||||
* It uses the executeAction function of its owner as callback.
|
||||
* The call of the initialize function is mandatory and needs a
|
||||
* valid MessageQueueIF pointer!
|
||||
*/
|
||||
class HasActionsIF;
|
||||
|
||||
@ -18,7 +21,8 @@ public:
|
||||
/**
|
||||
* Constructor of the action helper
|
||||
* @param setOwner Pointer to the owner of the interface
|
||||
* @param useThisQueue messageQueue to be used, can be set during initialize function as well.
|
||||
* @param useThisQueue messageQueue to be used, can be set during
|
||||
* initialize function as well.
|
||||
*/
|
||||
ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue);
|
||||
|
||||
@ -26,28 +30,36 @@ public:
|
||||
/**
|
||||
* Function to be called from the owner with a new command message
|
||||
*
|
||||
* If the message is a valid action message the helper will use the executeAction function from HasActionsIF.
|
||||
* If the message is invalid or the callback fails a message reply will be send to the sender of the message automatically.
|
||||
* If the message is a valid action message the helper will use the
|
||||
* executeAction function from HasActionsIF.
|
||||
* If the message is invalid or the callback fails a message reply will be
|
||||
* send to the sender of the message automatically.
|
||||
*
|
||||
* @param command Pointer to a command message received by the owner
|
||||
* @return HasReturnvaluesIF::RETURN_OK if the message is a action message, CommandMessage::UNKNOW_COMMAND if this message ID is unkown
|
||||
* @return HasReturnvaluesIF::RETURN_OK if the message is a action message,
|
||||
* CommandMessage::UNKNOW_COMMAND if this message ID is unkown
|
||||
*/
|
||||
ReturnValue_t handleActionMessage(CommandMessage* command);
|
||||
/**
|
||||
* Helper initialize function. Must be called before use of any other helper function
|
||||
* @param queueToUse_ Pointer to the messageQueue to be used, optional if queue was set in constructor
|
||||
* Helper initialize function. Must be called before use of any other
|
||||
* helper function
|
||||
* @param queueToUse_ Pointer to the messageQueue to be used, optional
|
||||
* if queue was set in constructor
|
||||
* @return Returns RETURN_OK if successful
|
||||
*/
|
||||
ReturnValue_t initialize(MessageQueueIF* queueToUse_ = nullptr);
|
||||
/**
|
||||
* Function to be called from the owner to send a step message. Success or failure will be determined by the result value.
|
||||
* Function to be called from the owner to send a step message.
|
||||
* Success or failure will be determined by the result value.
|
||||
*
|
||||
* @param step Number of steps already done
|
||||
* @param reportTo The messageQueueId to report the step message to
|
||||
* @param commandId ID of the executed command
|
||||
* @param result Result of the execution
|
||||
*/
|
||||
void step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
void step(uint8_t step, MessageQueueId_t reportTo,
|
||||
ActionId_t commandId,
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
/**
|
||||
* Function to be called by the owner to send a action completion message
|
||||
*
|
||||
@ -55,39 +67,59 @@ public:
|
||||
* @param commandId ID of the executed command
|
||||
* @param result Result of the execution
|
||||
*/
|
||||
void finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
void finish(MessageQueueId_t reportTo, ActionId_t commandId,
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
/**
|
||||
* Function to be called by the owner if an action does report data
|
||||
*
|
||||
* @param reportTo MessageQueueId_t to report the action completion message to
|
||||
* Function to be called by the owner if an action does report data.
|
||||
* Takes a SerializeIF* pointer and serializes it into the IPC store.
|
||||
* @param reportTo MessageQueueId_t to report the action completion
|
||||
* message to
|
||||
* @param replyId ID of the executed command
|
||||
* @param data Pointer to the data
|
||||
* @return Returns RETURN_OK if successful, otherwise failure code
|
||||
*/
|
||||
ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, SerializeIF* data, bool hideSender = false);
|
||||
ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId,
|
||||
SerializeIF* data, bool hideSender = false);
|
||||
/**
|
||||
* Function to be called by the owner if an action does report data.
|
||||
* Takes the raw data and writes it into the IPC store.
|
||||
* @param reportTo MessageQueueId_t to report the action completion
|
||||
* message to
|
||||
* @param replyId ID of the executed command
|
||||
* @param data Pointer to the data
|
||||
* @return Returns RETURN_OK if successful, otherwise failure code
|
||||
*/
|
||||
ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId,
|
||||
const uint8_t* data, size_t dataSize, bool hideSender = false);
|
||||
/**
|
||||
* Function to setup the MessageQueueIF* of the helper. Can be used to set the messageQueueIF* if
|
||||
* message queue is unavailable at construction and initialize but must be setup before first call of other functions.
|
||||
* Function to setup the MessageQueueIF* of the helper. Can be used to
|
||||
* set the MessageQueueIF* if message queue is unavailable at construction
|
||||
* and initialize but must be setup before first call of other functions.
|
||||
* @param queue Queue to be used by the helper
|
||||
*/
|
||||
void setQueueToUse(MessageQueueIF *queue);
|
||||
protected:
|
||||
static const uint8_t STEP_OFFSET = 1;//!< Increase of value of this per step
|
||||
//!< Increase of value of this per step
|
||||
static const uint8_t STEP_OFFSET = 1;
|
||||
HasActionsIF* owner;//!< Pointer to the owner
|
||||
MessageQueueIF* queueToUse;//!< Queue to be used as response sender, has to be set with
|
||||
StorageManagerIF* ipcStore;//!< Pointer to an IPC Store, initialized during construction or initialize(MessageQueueIF* queueToUse_) or with setQueueToUse(MessageQueueIF *queue)
|
||||
//! Queue to be used as response sender, has to be set in ctor or with
|
||||
//! setQueueToUse
|
||||
MessageQueueIF* queueToUse;
|
||||
//! Pointer to an IPC Store, initialized during construction or
|
||||
StorageManagerIF* ipcStore = nullptr;
|
||||
|
||||
/**
|
||||
*Internal function called by handleActionMessage(CommandMessage* command)
|
||||
*
|
||||
* Internal function called by handleActionMessage
|
||||
* @param commandedBy MessageQueueID of Commander
|
||||
* @param actionId ID of action to be done
|
||||
* @param dataAddress Address of additional data in IPC Store
|
||||
*/
|
||||
virtual void prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId, store_address_t dataAddress);
|
||||
virtual void prepareExecution(MessageQueueId_t commandedBy,
|
||||
ActionId_t actionId, store_address_t dataAddress);
|
||||
/**
|
||||
*
|
||||
* @brief Default implementation is empty.
|
||||
*/
|
||||
virtual void resetHelper();
|
||||
};
|
||||
|
||||
#endif /* ACTIONHELPER_H_ */
|
||||
#endif /* FSFW_ACTION_ACTIONHELPER_H_ */
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <framework/action/ActionMessage.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include "ActionMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
ActionMessage::ActionMessage() {
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
#ifndef ACTIONMESSAGE_H_
|
||||
#define ACTIONMESSAGE_H_
|
||||
#ifndef FSFW_ACTION_ACTIONMESSAGE_H_
|
||||
#define FSFW_ACTION_ACTIONMESSAGE_H_
|
||||
|
||||
#include <framework/ipc/CommandMessage.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
typedef uint32_t ActionId_t;
|
||||
|
||||
class ActionMessage {
|
||||
private:
|
||||
ActionMessage();
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = MESSAGE_TYPE::ACTION;
|
||||
static const uint8_t MESSAGE_ID = messagetypes::ACTION;
|
||||
static const Command_t EXECUTE_ACTION = MAKE_COMMAND_ID(1);
|
||||
static const Command_t STEP_SUCCESS = MAKE_COMMAND_ID(2);
|
||||
static const Command_t STEP_FAILED = MAKE_COMMAND_ID(3);
|
||||
@ -18,15 +18,19 @@ public:
|
||||
static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(5);
|
||||
static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(6);
|
||||
virtual ~ActionMessage();
|
||||
static void setCommand(CommandMessage* message, ActionId_t fid, store_address_t parameters);
|
||||
static void setCommand(CommandMessage* message, ActionId_t fid,
|
||||
store_address_t parameters);
|
||||
static ActionId_t getActionId(const CommandMessage* message );
|
||||
static store_address_t getStoreId(const CommandMessage* message );
|
||||
static void setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
static void setStepReply(CommandMessage* message, ActionId_t fid,
|
||||
uint8_t step, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
static uint8_t getStep(const CommandMessage* message );
|
||||
static ReturnValue_t getReturnCode(const CommandMessage* message );
|
||||
static void setDataReply(CommandMessage* message, ActionId_t actionId, store_address_t data);
|
||||
static void setCompletionReply(CommandMessage* message, ActionId_t fid, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
static void setDataReply(CommandMessage* message, ActionId_t actionId,
|
||||
store_address_t data);
|
||||
static void setCompletionReply(CommandMessage* message, ActionId_t fid,
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK);
|
||||
static void clear(CommandMessage* message);
|
||||
};
|
||||
|
||||
#endif /* ACTIONMESSAGE_H_ */
|
||||
#endif /* FSFW_ACTION_ACTIONMESSAGE_H_ */
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <framework/action/ActionMessage.h>
|
||||
#include <framework/action/CommandActionHelper.h>
|
||||
#include <framework/action/CommandsActionsIF.h>
|
||||
#include <framework/action/HasActionsIF.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include "ActionMessage.h"
|
||||
#include "CommandActionHelper.h"
|
||||
#include "CommandsActionsIF.h"
|
||||
#include "HasActionsIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
CommandActionHelper::CommandActionHelper(CommandsActionsIF *setOwner) :
|
||||
owner(setOwner), queueToUse(NULL), ipcStore(
|
||||
|
@ -1,12 +1,12 @@
|
||||
#ifndef COMMANDACTIONHELPER_H_
|
||||
#define COMMANDACTIONHELPER_H_
|
||||
|
||||
#include <framework/action/ActionMessage.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/serialize/SerializeIF.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
#include "ActionMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
|
||||
class CommandsActionsIF;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef COMMANDSACTIONSIF_H_
|
||||
#define COMMANDSACTIONSIF_H_
|
||||
#ifndef FSFW_ACTION_COMMANDSACTIONSIF_H_
|
||||
#define FSFW_ACTION_COMMANDSACTIONSIF_H_
|
||||
|
||||
#include <framework/action/CommandActionHelper.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
#include "CommandActionHelper.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
|
||||
/**
|
||||
* Interface to separate commanding actions of other objects.
|
||||
@ -24,11 +24,14 @@ public:
|
||||
virtual MessageQueueIF* getCommandQueuePtr() = 0;
|
||||
protected:
|
||||
virtual void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) = 0;
|
||||
virtual void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) = 0;
|
||||
virtual void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) = 0;
|
||||
virtual void stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) = 0;
|
||||
virtual void dataReceived(ActionId_t actionId, const uint8_t* data,
|
||||
uint32_t size) = 0;
|
||||
virtual void completionSuccessfulReceived(ActionId_t actionId) = 0;
|
||||
virtual void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) = 0;
|
||||
virtual void completionFailedReceived(ActionId_t actionId,
|
||||
ReturnValue_t returnCode) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* COMMANDSACTIONSIF_H_ */
|
||||
#endif /* FSFW_ACTION_COMMANDSACTIONSIF_H_ */
|
||||
|
@ -1,11 +1,12 @@
|
||||
#ifndef FRAMEWORK_ACTION_HASACTIONSIF_H_
|
||||
#define FRAMEWORK_ACTION_HASACTIONSIF_H_
|
||||
#ifndef FSFW_ACTION_HASACTIONSIF_H_
|
||||
#define FSFW_ACTION_HASACTIONSIF_H_
|
||||
|
||||
#include "ActionHelper.h"
|
||||
#include "ActionMessage.h"
|
||||
#include "SimpleActionHelper.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
|
||||
#include <framework/action/ActionHelper.h>
|
||||
#include <framework/action/ActionMessage.h>
|
||||
#include <framework/action/SimpleActionHelper.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
/**
|
||||
* @brief
|
||||
* Interface for component which uses actions
|
||||
@ -47,14 +48,16 @@ public:
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
/**
|
||||
* Execute or initialize the execution of a certain function.
|
||||
* Returning #EXECUTION_FINISHED or a failure code, nothing else needs to
|
||||
* be done. When needing more steps, return RETURN_OK and issue steps and
|
||||
* completion manually.
|
||||
* One "step failed" or completion report must be issued!
|
||||
* The ActionHelpers will execute this function and behave differently
|
||||
* depending on the returnvalue.
|
||||
*
|
||||
* @return
|
||||
* -@c EXECUTION_FINISHED Finish reply will be generated
|
||||
* -@c Not RETURN_OK Step failure reply will be generated
|
||||
*/
|
||||
virtual ReturnValue_t executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_ACTION_HASACTIONSIF_H_ */
|
||||
#endif /* FSFW_ACTION_HASACTIONSIF_H_ */
|
||||
|
@ -1,16 +1,17 @@
|
||||
#include <framework/action/HasActionsIF.h>
|
||||
#include <framework/action/SimpleActionHelper.h>
|
||||
#include "HasActionsIF.h"
|
||||
#include "SimpleActionHelper.h"
|
||||
|
||||
SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner,
|
||||
MessageQueueIF* useThisQueue) :
|
||||
ActionHelper(setOwner, useThisQueue), isExecuting(false), lastCommander(
|
||||
0), lastAction(0), stepCount(0) {
|
||||
ActionHelper(setOwner, useThisQueue), isExecuting(false) {
|
||||
}
|
||||
|
||||
SimpleActionHelper::~SimpleActionHelper() {
|
||||
}
|
||||
|
||||
void SimpleActionHelper::step(ReturnValue_t result) {
|
||||
//STEP_OFFESET is subtracted to compensate for adding offset in base method, which is not necessary here.
|
||||
// STEP_OFFESET is subtracted to compensate for adding offset in base
|
||||
// method, which is not necessary here.
|
||||
ActionHelper::step(stepCount - STEP_OFFSET, lastCommander, lastAction,
|
||||
result);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
|
@ -1,8 +1,13 @@
|
||||
#ifndef SIMPLEACTIONHELPER_H_
|
||||
#define SIMPLEACTIONHELPER_H_
|
||||
#ifndef FSFW_ACTION_SIMPLEACTIONHELPER_H_
|
||||
#define FSFW_ACTION_SIMPLEACTIONHELPER_H_
|
||||
|
||||
#include <framework/action/ActionHelper.h>
|
||||
#include "ActionHelper.h"
|
||||
|
||||
/**
|
||||
* @brief This is an action helper which is only able to service one action
|
||||
* at a time but remembers last commander and last action which
|
||||
* simplifies usage
|
||||
*/
|
||||
class SimpleActionHelper: public ActionHelper {
|
||||
public:
|
||||
SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue);
|
||||
@ -12,13 +17,14 @@ public:
|
||||
ReturnValue_t reportData(SerializeIF* data);
|
||||
|
||||
protected:
|
||||
void prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId, store_address_t dataAddress);
|
||||
virtual void resetHelper();
|
||||
void prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
|
||||
store_address_t dataAddress);
|
||||
virtual void resetHelper();
|
||||
private:
|
||||
bool isExecuting;
|
||||
MessageQueueId_t lastCommander;
|
||||
ActionId_t lastAction;
|
||||
uint8_t stepCount;
|
||||
MessageQueueId_t lastCommander = MessageQueueIF::NO_QUEUE;
|
||||
ActionId_t lastAction = 0;
|
||||
uint8_t stepCount = 0;
|
||||
};
|
||||
|
||||
#endif /* SIMPLEACTIONHELPER_H_ */
|
||||
|
@ -1,15 +1,15 @@
|
||||
#ifndef ARRAYLIST_H_
|
||||
#define ARRAYLIST_H_
|
||||
#ifndef FSFW_CONTAINER_ARRAYLIST_H_
|
||||
#define FSFW_CONTAINER_ARRAYLIST_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/serialize/SerializeAdapter.h>
|
||||
#include <framework/serialize/SerializeIF.h>
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
|
||||
/**
|
||||
* A List that stores its values in an array.
|
||||
*
|
||||
* The backend is an array that can be allocated by the class itself or supplied via ctor.
|
||||
*
|
||||
* @brief A List that stores its values in an array.
|
||||
* @details
|
||||
* The underlying storage is an array that can be allocated by the class
|
||||
* itself or supplied via ctor.
|
||||
*
|
||||
* @ingroup container
|
||||
*/
|
||||
@ -20,6 +20,53 @@ public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::ARRAY_LIST;
|
||||
static const ReturnValue_t FULL = MAKE_RETURN_CODE(0x01);
|
||||
|
||||
/**
|
||||
* This is the allocating constructor.
|
||||
* It allocates an array of the specified size.
|
||||
* @param maxSize
|
||||
*/
|
||||
ArrayList(count_t maxSize) :
|
||||
size(0), maxSize_(maxSize), allocated(true) {
|
||||
entries = new T[maxSize];
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the non-allocating constructor
|
||||
*
|
||||
* It expects a pointer to an array of a certain size and initializes
|
||||
* itself to it.
|
||||
*
|
||||
* @param storage the array to use as backend
|
||||
* @param maxSize size of storage
|
||||
* @param size size of data already present in storage
|
||||
*/
|
||||
ArrayList(T *storage, count_t maxSize, count_t size = 0) :
|
||||
size(size), entries(storage), maxSize_(maxSize), allocated(false) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copying is forbiden by declaring copy ctor and copy assignment deleted
|
||||
* It is too ambigous in this case.
|
||||
* (Allocate a new backend? Use the same? What to do in an modifying call?)
|
||||
*/
|
||||
ArrayList(const ArrayList& other) = delete;
|
||||
const ArrayList& operator=(const ArrayList& other) = delete;
|
||||
|
||||
/**
|
||||
* Number of Elements stored in this List
|
||||
*/
|
||||
count_t size;
|
||||
|
||||
|
||||
/**
|
||||
* Destructor, if the allocating constructor was used, it deletes the array.
|
||||
*/
|
||||
virtual ~ArrayList() {
|
||||
if (allocated) {
|
||||
delete[] entries;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An Iterator to go trough an ArrayList
|
||||
*
|
||||
@ -31,10 +78,7 @@ public:
|
||||
/**
|
||||
* Empty ctor, points to NULL
|
||||
*/
|
||||
Iterator() :
|
||||
value(0) {
|
||||
|
||||
}
|
||||
Iterator(): value(0) {}
|
||||
|
||||
/**
|
||||
* Initializes the Iterator to point to an element
|
||||
@ -72,7 +116,11 @@ public:
|
||||
return tmp;
|
||||
}
|
||||
|
||||
T operator*() {
|
||||
T& operator*() {
|
||||
return *value;
|
||||
}
|
||||
|
||||
const T& operator*() const {
|
||||
return *value;
|
||||
}
|
||||
|
||||
@ -80,59 +128,19 @@ public:
|
||||
return value;
|
||||
}
|
||||
|
||||
const T *operator->() const{
|
||||
const T *operator->() const {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
//SHOULDDO this should be implemented as non-member
|
||||
bool operator==(const typename ArrayList<T, count_t>::Iterator& other) const{
|
||||
return (value == other.value);
|
||||
}
|
||||
|
||||
//SHOULDDO this should be implemented as non-member
|
||||
bool operator!=(const typename ArrayList<T, count_t>::Iterator& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
* Number of Elements stored in this List
|
||||
*/
|
||||
count_t size;
|
||||
|
||||
/**
|
||||
* This is the allocating constructor;
|
||||
*
|
||||
* It allocates an array of the specified size.
|
||||
*
|
||||
* @param maxSize
|
||||
*/
|
||||
ArrayList(count_t maxSize) :
|
||||
size(0), maxSize_(maxSize), allocated(true) {
|
||||
entries = new T[maxSize];
|
||||
friend bool operator==(const ArrayList::Iterator& lhs,
|
||||
const ArrayList::Iterator& rhs) {
|
||||
return (lhs.value == rhs.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the non-allocating constructor
|
||||
*
|
||||
* It expects a pointer to an array of a certain size and initializes itself to it.
|
||||
*
|
||||
* @param storage the array to use as backend
|
||||
* @param maxSize size of storage
|
||||
* @param size size of data already present in storage
|
||||
*/
|
||||
ArrayList(T *storage, count_t maxSize, count_t size = 0) :
|
||||
size(size), entries(storage), maxSize_(maxSize), allocated(false) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor, if the allocating constructor was used, it deletes the array.
|
||||
*/
|
||||
virtual ~ArrayList() {
|
||||
if (allocated) {
|
||||
delete[] entries;
|
||||
}
|
||||
friend bool operator!=(const ArrayList::Iterator& lhs,
|
||||
const ArrayList::Iterator& rhs) {
|
||||
return not (lhs.value == rhs.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +196,7 @@ public:
|
||||
*
|
||||
* @return maximum number of elements
|
||||
*/
|
||||
uint32_t maxSize() const {
|
||||
size_t maxSize() const {
|
||||
return this->maxSize_;
|
||||
}
|
||||
|
||||
@ -223,19 +231,7 @@ public:
|
||||
count_t remaining() {
|
||||
return (maxSize_ - size);
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* This is the copy constructor
|
||||
*
|
||||
* It is private, as copying is too ambigous in this case. (Allocate a new backend? Use the same?
|
||||
* What to do in an modifying call?)
|
||||
*
|
||||
* @param other
|
||||
*/
|
||||
ArrayList(const ArrayList& other) :
|
||||
size(other.size), entries(other.entries), maxSize_(other.maxSize_), allocated(
|
||||
false) {
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* pointer to the array in which the entries are stored
|
||||
@ -244,12 +240,14 @@ protected:
|
||||
/**
|
||||
* remembering the maximum size
|
||||
*/
|
||||
uint32_t maxSize_;
|
||||
size_t maxSize_;
|
||||
|
||||
/**
|
||||
* true if the array was allocated and needs to be deleted in the destructor.
|
||||
*/
|
||||
bool allocated;
|
||||
|
||||
};
|
||||
#endif /* ARRAYLIST_H_ */
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_CONTAINER_ARRAYLIST_H_ */
|
||||
|
55
container/DynamicFIFO.h
Normal file
55
container/DynamicFIFO.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef FSFW_CONTAINER_DYNAMICFIFO_H_
|
||||
#define FSFW_CONTAINER_DYNAMICFIFO_H_
|
||||
|
||||
#include "FIFOBase.h"
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @brief Simple First-In-First-Out data structure. The maximum size
|
||||
* can be set in the constructor.
|
||||
* @details
|
||||
* The maximum capacity can be determined at run-time, so this container
|
||||
* performs dynamic memory allocation!
|
||||
* The public interface of FIFOBase exposes the user interface for the FIFO.
|
||||
* @tparam T Entry Type
|
||||
* @tparam capacity Maximum capacity
|
||||
*/
|
||||
template<typename T>
|
||||
class DynamicFIFO: public FIFOBase<T> {
|
||||
public:
|
||||
DynamicFIFO(size_t maxCapacity): FIFOBase<T>(nullptr, maxCapacity),
|
||||
fifoVector(maxCapacity) {
|
||||
// trying to pass the pointer of the uninitialized vector
|
||||
// to the FIFOBase constructor directly lead to a super evil bug.
|
||||
// So we do it like this now.
|
||||
this->setContainer(fifoVector.data());
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Custom copy constructor which prevents setting the
|
||||
* underlying pointer wrong. This function allocates memory!
|
||||
* @details This is a very heavy operation so try to avoid this!
|
||||
*
|
||||
*/
|
||||
DynamicFIFO(const DynamicFIFO& other): FIFOBase<T>(other),
|
||||
fifoVector(other.maxCapacity) {
|
||||
this->fifoVector = other.fifoVector;
|
||||
this->setContainer(fifoVector.data());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Custom assignment operator
|
||||
* @details This is a very heavy operation so try to avoid this!
|
||||
* @param other DyamicFIFO to copy from
|
||||
*/
|
||||
DynamicFIFO& operator=(const DynamicFIFO& other){
|
||||
FIFOBase<T>::operator=(other);
|
||||
this->fifoVector = other.fifoVector;
|
||||
this->setContainer(fifoVector.data());
|
||||
return *this;
|
||||
}
|
||||
private:
|
||||
std::vector<T> fifoVector;
|
||||
};
|
||||
|
||||
#endif /* FSFW_CONTAINER_DYNAMICFIFO_H_ */
|
103
container/FIFO.h
103
container/FIFO.h
@ -1,82 +1,47 @@
|
||||
#ifndef FIFO_H_
|
||||
#define FIFO_H_
|
||||
#ifndef FSFW_CONTAINER_FIFO_H_
|
||||
#define FSFW_CONTAINER_FIFO_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "FIFOBase.h"
|
||||
#include <array>
|
||||
|
||||
/**
|
||||
* @brief Simple First-In-First-Out data structure
|
||||
* @brief Simple First-In-First-Out data structure with size fixed at
|
||||
* compile time
|
||||
* @details
|
||||
* Performs no dynamic memory allocation.
|
||||
* The public interface of FIFOBase exposes the user interface for the FIFO.
|
||||
* @tparam T Entry Type
|
||||
* @tparam capacity Maximum capacity
|
||||
*/
|
||||
template<typename T, uint8_t capacity>
|
||||
class FIFO {
|
||||
private:
|
||||
uint8_t readIndex, writeIndex, currentSize;
|
||||
T data[capacity];
|
||||
|
||||
uint8_t next(uint8_t current) {
|
||||
++current;
|
||||
if (current == capacity) {
|
||||
current = 0;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
template<typename T, size_t capacity>
|
||||
class FIFO: public FIFOBase<T> {
|
||||
public:
|
||||
FIFO() :
|
||||
readIndex(0), writeIndex(0), currentSize(0) {
|
||||
FIFO(): FIFOBase<T>(nullptr, capacity) {
|
||||
this->setContainer(fifoArray.data());
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Custom copy constructor to set pointer correctly.
|
||||
* @param other
|
||||
*/
|
||||
FIFO(const FIFO& other): FIFOBase<T>(other) {
|
||||
this->fifoArray = other.fifoArray;
|
||||
this->setContainer(fifoArray.data());
|
||||
}
|
||||
|
||||
bool empty() {
|
||||
return (currentSize == 0);
|
||||
/**
|
||||
* @brief Custom assignment operator
|
||||
* @param other
|
||||
*/
|
||||
FIFO& operator=(const FIFO& other){
|
||||
FIFOBase<T>::operator=(other);
|
||||
this->fifoArray = other.fifoArray;
|
||||
this->setContainer(fifoArray.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool full() {
|
||||
return (currentSize == capacity);
|
||||
}
|
||||
|
||||
uint8_t size(){
|
||||
return currentSize;
|
||||
}
|
||||
|
||||
ReturnValue_t insert(T value) {
|
||||
if (full()) {
|
||||
return FULL;
|
||||
} else {
|
||||
data[writeIndex] = value;
|
||||
writeIndex = next(writeIndex);
|
||||
++currentSize;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t retrieve(T *value) {
|
||||
if (empty()) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
*value = data[readIndex];
|
||||
readIndex = next(readIndex);
|
||||
--currentSize;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t peek(T * value) {
|
||||
if(empty()) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
*value = data[readIndex];
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t pop() {
|
||||
T value;
|
||||
return this->retrieve(&value);
|
||||
}
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::FIFO_CLASS;
|
||||
static const ReturnValue_t FULL = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(2);
|
||||
private:
|
||||
std::array<T, capacity> fifoArray;
|
||||
};
|
||||
|
||||
#endif /* FIFO_H_ */
|
||||
#endif /* FSFW_CONTAINER_FIFO_H_ */
|
||||
|
79
container/FIFOBase.h
Normal file
79
container/FIFOBase.h
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef FSFW_CONTAINER_FIFOBASE_H_
|
||||
#define FSFW_CONTAINER_FIFOBASE_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
template <typename T>
|
||||
class FIFOBase {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::FIFO_CLASS;
|
||||
static const ReturnValue_t FULL = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(2);
|
||||
|
||||
/** Default ctor, takes pointer to first entry of underlying container
|
||||
* and maximum capacity */
|
||||
FIFOBase(T* values, const size_t maxCapacity);
|
||||
|
||||
/**
|
||||
* Insert value into FIFO
|
||||
* @param value
|
||||
* @return RETURN_OK on success, FULL if full
|
||||
*/
|
||||
ReturnValue_t insert(T value);
|
||||
/**
|
||||
* Retrieve item from FIFO. This removes the item from the FIFO.
|
||||
* @param value Must point to a valid T
|
||||
* @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed
|
||||
*/
|
||||
ReturnValue_t retrieve(T *value);
|
||||
/**
|
||||
* Retrieve item from FIFO without removing it from FIFO.
|
||||
* @param value Must point to a valid T
|
||||
* @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed
|
||||
*/
|
||||
ReturnValue_t peek(T * value);
|
||||
/**
|
||||
* Remove item from FIFO.
|
||||
* @return RETURN_OK on success, EMPTY if empty
|
||||
*/
|
||||
ReturnValue_t pop();
|
||||
|
||||
/***
|
||||
* Check if FIFO is empty
|
||||
* @return True if empty, False if not
|
||||
*/
|
||||
bool empty();
|
||||
/***
|
||||
* Check if FIFO is Full
|
||||
* @return True if full, False if not
|
||||
*/
|
||||
bool full();
|
||||
/***
|
||||
* Current used size (elements) used
|
||||
* @return size_t in elements
|
||||
*/
|
||||
size_t size();
|
||||
/***
|
||||
* Get maximal capacity of fifo
|
||||
* @return size_t with max capacity of this fifo
|
||||
*/
|
||||
size_t getMaxCapacity() const;
|
||||
|
||||
protected:
|
||||
void setContainer(T* data);
|
||||
size_t maxCapacity = 0;
|
||||
|
||||
T* values;
|
||||
|
||||
size_t readIndex = 0;
|
||||
size_t writeIndex = 0;
|
||||
size_t currentSize = 0;
|
||||
|
||||
size_t next(size_t current);
|
||||
};
|
||||
|
||||
#include "FIFOBase.tpp"
|
||||
|
||||
#endif /* FSFW_CONTAINER_FIFOBASE_H_ */
|
93
container/FIFOBase.tpp
Normal file
93
container/FIFOBase.tpp
Normal file
@ -0,0 +1,93 @@
|
||||
#ifndef FSFW_CONTAINER_FIFOBASE_TPP_
|
||||
#define FSFW_CONTAINER_FIFOBASE_TPP_
|
||||
|
||||
#ifndef FSFW_CONTAINER_FIFOBASE_H_
|
||||
#error Include FIFOBase.h before FIFOBase.tpp!
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
inline FIFOBase<T>::FIFOBase(T* values, const size_t maxCapacity):
|
||||
maxCapacity(maxCapacity), values(values){};
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t FIFOBase<T>::insert(T value) {
|
||||
if (full()) {
|
||||
return FULL;
|
||||
} else {
|
||||
values[writeIndex] = value;
|
||||
writeIndex = next(writeIndex);
|
||||
++currentSize;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t FIFOBase<T>::retrieve(T* value) {
|
||||
if (empty()) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
if (value == nullptr){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*value = values[readIndex];
|
||||
readIndex = next(readIndex);
|
||||
--currentSize;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t FIFOBase<T>::peek(T* value) {
|
||||
if(empty()) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
if (value == nullptr){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*value = values[readIndex];
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t FIFOBase<T>::pop() {
|
||||
T value;
|
||||
return this->retrieve(&value);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline bool FIFOBase<T>::empty() {
|
||||
return (currentSize == 0);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline bool FIFOBase<T>::full() {
|
||||
return (currentSize == maxCapacity);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline size_t FIFOBase<T>::size() {
|
||||
return currentSize;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline size_t FIFOBase<T>::next(size_t current) {
|
||||
++current;
|
||||
if (current == maxCapacity) {
|
||||
current = 0;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline size_t FIFOBase<T>::getMaxCapacity() const {
|
||||
return maxCapacity;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline void FIFOBase<T>::setContainer(T *data) {
|
||||
this->values = data;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,12 +1,14 @@
|
||||
#ifndef FIXEDARRAYLIST_H_
|
||||
#define FIXEDARRAYLIST_H_
|
||||
|
||||
#include <framework/container/ArrayList.h>
|
||||
#include "ArrayList.h"
|
||||
#include <cmath>
|
||||
/**
|
||||
* \ingroup container
|
||||
*/
|
||||
template<typename T, uint32_t MAX_SIZE, typename count_t = uint8_t>
|
||||
template<typename T, size_t MAX_SIZE, typename count_t = uint8_t>
|
||||
class FixedArrayList: public ArrayList<T, count_t> {
|
||||
static_assert(MAX_SIZE <= (pow(2,sizeof(count_t)*8)-1), "count_t is not large enough to hold MAX_SIZE");
|
||||
private:
|
||||
T data[MAX_SIZE];
|
||||
public:
|
||||
@ -18,11 +20,13 @@ public:
|
||||
ArrayList<T, count_t>(data, MAX_SIZE) {
|
||||
memcpy(this->data, other.data, sizeof(this->data));
|
||||
this->entries = data;
|
||||
this->size = other.size;
|
||||
}
|
||||
|
||||
FixedArrayList& operator=(FixedArrayList other) {
|
||||
memcpy(this->data, other.data, sizeof(this->data));
|
||||
this->entries = data;
|
||||
this->size = other.size;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,27 @@
|
||||
#ifndef FIXEDMAP_H_
|
||||
#define FIXEDMAP_H_
|
||||
#ifndef FSFW_CONTAINER_FIXEDMAP_H_
|
||||
#define FSFW_CONTAINER_FIXEDMAP_H_
|
||||
|
||||
#include <framework/container/ArrayList.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "ArrayList.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* \ingroup container
|
||||
* @brief Map implementation for maps with a pre-defined size.
|
||||
* @details
|
||||
* Can be initialized with desired maximum size.
|
||||
* Iterator is used to access <key,value> pair and iterate through map entries.
|
||||
* Complexity O(n).
|
||||
* @warning Iterators return a non-const key_t in the pair.
|
||||
* @warning A User is not allowed to change the key, otherwise the map is corrupted.
|
||||
* @ingroup container
|
||||
*/
|
||||
template<typename key_t, typename T>
|
||||
class FixedMap: public SerializeIF {
|
||||
static_assert (std::is_trivially_copyable<T>::value or
|
||||
std::is_base_of<SerializeIF, T>::value,
|
||||
"Types used in FixedMap must either be trivial copy-able or a "
|
||||
"derived class from SerializeIF to be serialize-able");
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP;
|
||||
static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01);
|
||||
@ -47,17 +59,18 @@ public:
|
||||
Iterator(std::pair<key_t, T> *pair) :
|
||||
ArrayList<std::pair<key_t, T>, uint32_t>::Iterator(pair) {
|
||||
}
|
||||
|
||||
T operator*() {
|
||||
return ArrayList<std::pair<key_t, T>, uint32_t>::Iterator::value->second;
|
||||
}
|
||||
|
||||
T *operator->() {
|
||||
return &ArrayList<std::pair<key_t, T>, uint32_t>::Iterator::value->second;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
friend bool operator==(const typename FixedMap::Iterator& lhs,
|
||||
const typename FixedMap::Iterator& rhs) {
|
||||
return (lhs.value == rhs.value);
|
||||
}
|
||||
|
||||
friend bool operator!=(const typename FixedMap::Iterator& lhs,
|
||||
const typename FixedMap::Iterator& rhs) {
|
||||
return not (lhs.value == rhs.value);
|
||||
}
|
||||
|
||||
Iterator begin() const {
|
||||
return Iterator(&theMap[0]);
|
||||
}
|
||||
@ -70,7 +83,7 @@ public:
|
||||
return _size;
|
||||
}
|
||||
|
||||
ReturnValue_t insert(key_t key, T value, Iterator *storedValue = NULL) {
|
||||
ReturnValue_t insert(key_t key, T value, Iterator *storedValue = nullptr) {
|
||||
if (exists(key) == HasReturnvaluesIF::RETURN_OK) {
|
||||
return KEY_ALREADY_EXISTS;
|
||||
}
|
||||
@ -79,7 +92,7 @@ public:
|
||||
}
|
||||
theMap[_size].first = key;
|
||||
theMap[_size].second = value;
|
||||
if (storedValue != NULL) {
|
||||
if (storedValue != nullptr) {
|
||||
*storedValue = Iterator(&theMap[_size]);
|
||||
}
|
||||
++_size;
|
||||
@ -87,7 +100,7 @@ public:
|
||||
}
|
||||
|
||||
ReturnValue_t insert(std::pair<key_t, T> pair) {
|
||||
return insert(pair.fist, pair.second);
|
||||
return insert(pair.first, pair.second);
|
||||
}
|
||||
|
||||
ReturnValue_t exists(key_t key) const {
|
||||
@ -140,6 +153,24 @@ public:
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
bool empty() {
|
||||
if(_size == 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool full() {
|
||||
if(_size >= theMap.maxSize()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_size = 0;
|
||||
}
|
||||
@ -196,4 +227,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif /* FIXEDMAP_H_ */
|
||||
#endif /* FSFW_CONTAINER_FIXEDMAP_H_ */
|
||||
|
@ -1,181 +1,206 @@
|
||||
#ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_
|
||||
#define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_
|
||||
#ifndef FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_
|
||||
#define FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_
|
||||
|
||||
#include <framework/container/ArrayList.h>
|
||||
#include "ArrayList.h"
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
|
||||
/**
|
||||
* @brief An associative container which allows multiple entries of the same key.
|
||||
* @details
|
||||
* Same keys are ordered by KEY_COMPARE function which is std::less<key_t> > by default.
|
||||
*
|
||||
* It uses the ArrayList, so technically this is not a real map, it is an array of pairs
|
||||
* of type key_t, T. It is ordered by key_t as FixedMap but allows same keys. Thus it has a linear
|
||||
* complexity O(n). As long as the number of entries remains low, this
|
||||
* should not be an issue.
|
||||
* The number of insertion and deletion operation should be minimized
|
||||
* as those incur extensive memory move operations (the underlying container
|
||||
* is not node based).
|
||||
*
|
||||
* Its of fixed size so no allocations are performed after the construction.
|
||||
*
|
||||
* The maximum size is given as first parameter of the constructor.
|
||||
*
|
||||
* It provides an iterator to do list iterations.
|
||||
*
|
||||
* The type T must have a copy constructor if it is not trivial copy-able.
|
||||
*
|
||||
* @warning Iterators return a non-const key_t in the pair.
|
||||
* @warning A User is not allowed to change the key, otherwise the map is corrupted.
|
||||
*
|
||||
* \ingroup container
|
||||
*/
|
||||
template<typename key_t, typename T, typename KEY_COMPARE = std::less<key_t>>
|
||||
class FixedOrderedMultimap {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP;
|
||||
static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03);
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MULTIMAP;
|
||||
static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x02);
|
||||
|
||||
private:
|
||||
typedef KEY_COMPARE compare;
|
||||
compare myComp;
|
||||
ArrayList<std::pair<key_t, T>, uint32_t> theMap;
|
||||
uint32_t _size;
|
||||
/***
|
||||
* Constructor which needs a size_t for the maximum allowed size
|
||||
*
|
||||
* Can not be resized during runtime
|
||||
*
|
||||
* Allocates memory at construction
|
||||
* @param maxSize size_t of Maximum allowed size
|
||||
*/
|
||||
FixedOrderedMultimap(size_t maxSize):theMap(maxSize), _size(0){
|
||||
}
|
||||
|
||||
uint32_t findFirstIndex(key_t key, uint32_t startAt = 0) const {
|
||||
if (startAt >= _size) {
|
||||
return startAt + 1;
|
||||
}
|
||||
uint32_t i = startAt;
|
||||
for (i = startAt; i < _size; ++i) {
|
||||
if (theMap[i].first == key) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
uint32_t findNicePlace(key_t key) const {
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < _size; ++i) {
|
||||
if (myComp(key, theMap[i].first)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void removeFromPosition(uint32_t position) {
|
||||
if (_size <= position) {
|
||||
return;
|
||||
}
|
||||
memmove(&theMap[position], &theMap[position + 1],
|
||||
(_size - position - 1) * sizeof(std::pair<key_t,T>));
|
||||
--_size;
|
||||
}
|
||||
public:
|
||||
FixedOrderedMultimap(uint32_t maxSize) :
|
||||
theMap(maxSize), _size(0) {
|
||||
}
|
||||
/***
|
||||
* Virtual destructor frees Memory by deleting its member
|
||||
*/
|
||||
virtual ~FixedOrderedMultimap() {
|
||||
}
|
||||
|
||||
class Iterator: public ArrayList<std::pair<key_t, T>, uint32_t>::Iterator {
|
||||
/***
|
||||
* Special iterator for FixedOrderedMultimap
|
||||
*/
|
||||
class Iterator: public ArrayList<std::pair<key_t, T>, size_t>::Iterator {
|
||||
public:
|
||||
Iterator() :
|
||||
ArrayList<std::pair<key_t, T>, uint32_t>::Iterator() {
|
||||
ArrayList<std::pair<key_t, T>, size_t>::Iterator() {
|
||||
}
|
||||
|
||||
Iterator(std::pair<key_t, T> *pair) :
|
||||
ArrayList<std::pair<key_t, T>, uint32_t>::Iterator(pair) {
|
||||
ArrayList<std::pair<key_t, T>, size_t>::Iterator(pair) {
|
||||
}
|
||||
|
||||
T operator*() {
|
||||
return ArrayList<std::pair<key_t, T>, uint32_t>::Iterator::value->second;
|
||||
}
|
||||
|
||||
T *operator->() {
|
||||
return &ArrayList<std::pair<key_t, T>, uint32_t>::Iterator::value->second;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/***
|
||||
* Returns an iterator pointing to the first element
|
||||
* @return Iterator pointing to first element
|
||||
*/
|
||||
Iterator begin() const {
|
||||
return Iterator(&theMap[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator pointing to one element past the end
|
||||
* @return Iterator pointing to one element past the end
|
||||
*/
|
||||
Iterator end() const {
|
||||
return Iterator(&theMap[_size]);
|
||||
}
|
||||
|
||||
uint32_t size() const {
|
||||
/***
|
||||
* Returns the current size of the map (not maximum size!)
|
||||
* @return Current size
|
||||
*/
|
||||
size_t size() const{
|
||||
return _size;
|
||||
}
|
||||
|
||||
ReturnValue_t insert(key_t key, T value, Iterator *storedValue = NULL) {
|
||||
if (_size == theMap.maxSize()) {
|
||||
return MAP_FULL;
|
||||
}
|
||||
uint32_t position = findNicePlace(key);
|
||||
memmove(&theMap[position + 1], &theMap[position],
|
||||
(_size - position) * sizeof(std::pair<key_t,T>));
|
||||
theMap[position].first = key;
|
||||
theMap[position].second = value;
|
||||
++_size;
|
||||
if (storedValue != NULL) {
|
||||
*storedValue = Iterator(&theMap[position]);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
/**
|
||||
* Clears the map, does not deallocate any memory
|
||||
*/
|
||||
void clear(){
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
ReturnValue_t insert(std::pair<key_t, T> pair) {
|
||||
return insert(pair.fist, pair.second);
|
||||
/**
|
||||
* Returns the maximum size of the map
|
||||
* @return Maximum size of the map
|
||||
*/
|
||||
size_t maxSize() const{
|
||||
return theMap.maxSize();
|
||||
}
|
||||
|
||||
ReturnValue_t exists(key_t key) const {
|
||||
ReturnValue_t result = KEY_DOES_NOT_EXIST;
|
||||
if (findFirstIndex(key) < _size) {
|
||||
result = HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/***
|
||||
* Used to insert a key and value separately.
|
||||
*
|
||||
* @param[in] key Key of the new element
|
||||
* @param[in] value Value of the new element
|
||||
* @param[in/out] (optional) storedValue On success this points to the new value, otherwise a nullptr
|
||||
* @return RETURN_OK if insert was successful, MAP_FULL if no space is available
|
||||
*/
|
||||
ReturnValue_t insert(key_t key, T value, Iterator *storedValue = nullptr);
|
||||
|
||||
ReturnValue_t erase(Iterator *iter) {
|
||||
uint32_t i;
|
||||
if ((i = findFirstIndex((*iter).value->first)) >= _size) {
|
||||
return KEY_DOES_NOT_EXIST;
|
||||
}
|
||||
removeFromPosition(i);
|
||||
if (*iter != begin()) {
|
||||
(*iter)--;
|
||||
} else {
|
||||
*iter = begin();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
/***
|
||||
* Used to insert new pair instead of single values
|
||||
*
|
||||
* @param pair Pair to be inserted
|
||||
* @return RETURN_OK if insert was successful, MAP_FULL if no space is available
|
||||
*/
|
||||
ReturnValue_t insert(std::pair<key_t, T> pair);
|
||||
|
||||
ReturnValue_t erase(key_t key) {
|
||||
uint32_t i;
|
||||
if ((i = findFirstIndex(key)) >= _size) {
|
||||
return KEY_DOES_NOT_EXIST;
|
||||
}
|
||||
do {
|
||||
removeFromPosition(i);
|
||||
i = findFirstIndex(key, i);
|
||||
} while (i < _size);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
/***
|
||||
* Can be used to check if a certain key is in the map
|
||||
* @param key Key to be checked
|
||||
* @return RETURN_OK if the key exists KEY_DOES_NOT_EXIST otherwise
|
||||
*/
|
||||
ReturnValue_t exists(key_t key) const;
|
||||
|
||||
//This is potentially unsafe
|
||||
// T *findValue(key_t key) const {
|
||||
// return &theMap[findFirstIndex(key)].second;
|
||||
// }
|
||||
/***
|
||||
* Used to delete the element in the iterator
|
||||
*
|
||||
* The iterator will point to the element before or begin(),
|
||||
* but never to one element in front of the map.
|
||||
*
|
||||
* @warning The iterator needs to be valid and dereferenceable
|
||||
* @param[in/out] iter Pointer to iterator to the element that needs to be ereased
|
||||
* @return RETURN_OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this
|
||||
*/
|
||||
ReturnValue_t erase(Iterator *iter);
|
||||
|
||||
/***
|
||||
* Used to erase by key
|
||||
* @param key Key to be erased
|
||||
* @return RETURN_OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this
|
||||
*/
|
||||
ReturnValue_t erase(key_t key);
|
||||
|
||||
Iterator find(key_t key) const {
|
||||
/***
|
||||
* Find returns the first appearance of the key
|
||||
*
|
||||
* If the key does not exist, it points to end()
|
||||
*
|
||||
* @param key Key to search for
|
||||
* @return Iterator pointing to the first entry of key
|
||||
*/
|
||||
Iterator find(key_t key) const{
|
||||
ReturnValue_t result = exists(key);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return end();
|
||||
}
|
||||
return Iterator(&theMap[findFirstIndex(key)]);
|
||||
};
|
||||
|
||||
/***
|
||||
* Finds first entry of the given key and returns a
|
||||
* pointer to the value
|
||||
*
|
||||
* @param key Key to search for
|
||||
* @param value Found value
|
||||
* @return RETURN_OK if it points to the value,
|
||||
* KEY_DOES_NOT_EXIST if the key is not in the map
|
||||
*/
|
||||
ReturnValue_t find(key_t key, T **value) const;
|
||||
|
||||
friend bool operator==(const typename FixedOrderedMultimap::Iterator& lhs,
|
||||
const typename FixedOrderedMultimap::Iterator& rhs) {
|
||||
return (lhs.value == rhs.value);
|
||||
}
|
||||
|
||||
ReturnValue_t find(key_t key, T **value) const {
|
||||
ReturnValue_t result = exists(key);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
*value = &theMap[findFirstIndex(key)].second;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
friend bool operator!=(const typename FixedOrderedMultimap::Iterator& lhs,
|
||||
const typename FixedOrderedMultimap::Iterator& rhs) {
|
||||
return not (lhs.value == rhs.value);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_size = 0;
|
||||
}
|
||||
private:
|
||||
typedef KEY_COMPARE compare;
|
||||
compare myComp;
|
||||
ArrayList<std::pair<key_t, T>, size_t> theMap;
|
||||
size_t _size;
|
||||
|
||||
uint32_t maxSize() const {
|
||||
return theMap.maxSize();
|
||||
}
|
||||
size_t findFirstIndex(key_t key, size_t startAt = 0) const;
|
||||
|
||||
size_t findNicePlace(key_t key) const;
|
||||
|
||||
void removeFromPosition(size_t position);
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_ */
|
||||
#include "FixedOrderedMultimap.tpp"
|
||||
|
||||
#endif /* FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ */
|
||||
|
109
container/FixedOrderedMultimap.tpp
Normal file
109
container/FixedOrderedMultimap.tpp
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_
|
||||
#define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_
|
||||
|
||||
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t key, T value, Iterator *storedValue) {
|
||||
if (_size == theMap.maxSize()) {
|
||||
return MAP_FULL;
|
||||
}
|
||||
size_t position = findNicePlace(key);
|
||||
memmove(static_cast<void*>(&theMap[position + 1]),static_cast<void*>(&theMap[position]),
|
||||
(_size - position) * sizeof(std::pair<key_t,T>));
|
||||
theMap[position].first = key;
|
||||
theMap[position].second = value;
|
||||
++_size;
|
||||
if (storedValue != nullptr) {
|
||||
*storedValue = Iterator(&theMap[position]);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(std::pair<key_t, T> pair) {
|
||||
return insert(pair.first, pair.second);
|
||||
}
|
||||
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::exists(key_t key) const {
|
||||
ReturnValue_t result = KEY_DOES_NOT_EXIST;
|
||||
if (findFirstIndex(key) < _size) {
|
||||
result = HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(Iterator *iter) {
|
||||
size_t i;
|
||||
if ((i = findFirstIndex((*iter).value->first)) >= _size) {
|
||||
return KEY_DOES_NOT_EXIST;
|
||||
}
|
||||
removeFromPosition(i);
|
||||
if (*iter != begin()) {
|
||||
(*iter)--;
|
||||
} else {
|
||||
*iter = begin();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(key_t key) {
|
||||
size_t i;
|
||||
if ((i = findFirstIndex(key)) >= _size) {
|
||||
return KEY_DOES_NOT_EXIST;
|
||||
}
|
||||
do {
|
||||
removeFromPosition(i);
|
||||
i = findFirstIndex(key, i);
|
||||
} while (i < _size);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::find(key_t key, T **value) const {
|
||||
ReturnValue_t result = exists(key);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
*value = &theMap[findFirstIndex(key)].second;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findFirstIndex(key_t key, size_t startAt) const {
|
||||
if (startAt >= _size) {
|
||||
return startAt + 1;
|
||||
}
|
||||
size_t i = startAt;
|
||||
for (i = startAt; i < _size; ++i) {
|
||||
if (theMap[i].first == key) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findNicePlace(key_t key) const {
|
||||
size_t i = 0;
|
||||
for (i = 0; i < _size; ++i) {
|
||||
if (myComp(key, theMap[i].first)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
||||
inline void FixedOrderedMultimap<key_t, T, KEY_COMPARE>::removeFromPosition(size_t position) {
|
||||
if (_size <= position) {
|
||||
return;
|
||||
}
|
||||
memmove(static_cast<void*>(&theMap[position]), static_cast<void*>(&theMap[position + 1]),
|
||||
(_size - position - 1) * sizeof(std::pair<key_t,T>));
|
||||
--_size;
|
||||
}
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ */
|
@ -1,8 +1,8 @@
|
||||
#ifndef FRAMEWORK_CONTAINER_HYBRIDITERATOR_H_
|
||||
#define FRAMEWORK_CONTAINER_HYBRIDITERATOR_H_
|
||||
|
||||
#include <framework/container/ArrayList.h>
|
||||
#include <framework/container/SinglyLinkedList.h>
|
||||
#include "ArrayList.h"
|
||||
#include "SinglyLinkedList.h"
|
||||
|
||||
template<typename T, typename count_t = uint8_t>
|
||||
class HybridIterator: public LinkedElement<T>::Iterator,
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef FRAMEWORK_CONTAINER_INDEXEDRINGMEMORY_H_
|
||||
#define FRAMEWORK_CONTAINER_INDEXEDRINGMEMORY_H_
|
||||
|
||||
#include <framework/container/ArrayList.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/serialize/SerialArrayListAdapter.h>
|
||||
#include "ArrayList.h"
|
||||
#include "../globalfunctions/CRC.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serialize/SerialArrayListAdapter.h"
|
||||
#include <cmath>
|
||||
|
||||
template<typename T>
|
||||
|
@ -1,41 +0,0 @@
|
||||
#ifndef ISDERIVEDFROM_H_
|
||||
#define ISDERIVEDFROM_H_
|
||||
|
||||
template<typename D, typename B>
|
||||
class IsDerivedFrom {
|
||||
class No {
|
||||
};
|
||||
class Yes {
|
||||
No no[3];
|
||||
};
|
||||
|
||||
static Yes Test(B*); // declared, but not defined
|
||||
static No Test(... ); // declared, but not defined
|
||||
|
||||
public:
|
||||
enum {
|
||||
Is = sizeof(Test(static_cast<D*>(0))) == sizeof(Yes)
|
||||
};
|
||||
};
|
||||
|
||||
template<typename, typename>
|
||||
struct is_same {
|
||||
static bool const value = false;
|
||||
};
|
||||
|
||||
template<typename A>
|
||||
struct is_same<A, A> {
|
||||
static bool const value = true;
|
||||
};
|
||||
|
||||
|
||||
template<bool C, typename T = void>
|
||||
struct enable_if {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct enable_if<false, T> { };
|
||||
|
||||
|
||||
#endif /* ISDERIVEDFROM_H_ */
|
@ -1,28 +1,64 @@
|
||||
#ifndef FRAMEWORK_CONTAINER_PLACEMENTFACTORY_H_
|
||||
#define FRAMEWORK_CONTAINER_PLACEMENTFACTORY_H_
|
||||
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include <utility>
|
||||
|
||||
/**
|
||||
* The Placement Factory is used to create objects at runtime in a specific pool.
|
||||
* In general, this should be avoided and it should only be used if you know what you are doing.
|
||||
* You are not allowed to use this container with a type that allocates memory internally like ArrayList.
|
||||
*
|
||||
* Also, you have to check the returned pointer in generate against nullptr!
|
||||
*
|
||||
* A backend of Type StorageManagerIF must be given as a place to store the new objects.
|
||||
* Therefore ThreadSafety is only provided by your StorageManager Implementation.
|
||||
*
|
||||
* Objects must be destroyed by the user with "destroy"! Otherwise the pool will not be cleared.
|
||||
*
|
||||
* The concept is based on the placement new operator.
|
||||
*
|
||||
* @warning Do not use with any Type that allocates memory internally!
|
||||
* @ingroup container
|
||||
*/
|
||||
class PlacementFactory {
|
||||
public:
|
||||
PlacementFactory(StorageManagerIF* backend) :
|
||||
dataBackend(backend) {
|
||||
}
|
||||
|
||||
/***
|
||||
* Generates an object of type T in the backend storage.
|
||||
*
|
||||
* @warning Do not use with any Type that allocates memory internally!
|
||||
*
|
||||
* @tparam T Type of Object
|
||||
* @param args Constructor Arguments to be passed
|
||||
* @return A pointer to the new object or a nullptr in case of failure
|
||||
*/
|
||||
template<typename T, typename ... Args>
|
||||
T* generate(Args&&... args) {
|
||||
store_address_t tempId;
|
||||
uint8_t* pData = NULL;
|
||||
uint8_t* pData = nullptr;
|
||||
ReturnValue_t result = dataBackend->getFreeElement(&tempId, sizeof(T),
|
||||
&pData);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
T* temp = new (pData) T(std::forward<Args>(args)...);
|
||||
return temp;
|
||||
}
|
||||
/***
|
||||
* Function to destroy the object allocated with generate and free space in backend.
|
||||
* This must be called by the user.
|
||||
*
|
||||
* @param thisElement Element to be destroyed
|
||||
* @return RETURN_OK if the element was destroyed, different errors on failure
|
||||
*/
|
||||
template<typename T>
|
||||
ReturnValue_t destroy(T* thisElement) {
|
||||
if (thisElement == nullptr){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
//Need to call destructor first, in case something was allocated by the object (shouldn't do that, however).
|
||||
thisElement->~T();
|
||||
uint8_t* pointer = (uint8_t*) (thisElement);
|
||||
|
@ -1,96 +1,113 @@
|
||||
#ifndef FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_
|
||||
#define FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_
|
||||
#ifndef FSFW_CONTAINER_RINGBUFFERBASE_H_
|
||||
#define FSFW_CONTAINER_RINGBUFFERBASE_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include <cstddef>
|
||||
|
||||
template<uint8_t N_READ_PTRS = 1>
|
||||
class RingBufferBase {
|
||||
public:
|
||||
RingBufferBase(uint32_t startAddress, uint32_t size, bool overwriteOld) :
|
||||
start(startAddress), write(startAddress), size(size), overwriteOld(overwriteOld) {
|
||||
RingBufferBase(size_t startAddress, const size_t size, bool overwriteOld) :
|
||||
start(startAddress), write(startAddress), size(size),
|
||||
overwriteOld(overwriteOld) {
|
||||
for (uint8_t count = 0; count < N_READ_PTRS; count++) {
|
||||
read[count] = startAddress;
|
||||
}
|
||||
}
|
||||
ReturnValue_t readData(uint32_t amount, uint8_t n = 0) {
|
||||
if (availableReadData(n) >= amount) {
|
||||
incrementRead(amount, n);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
ReturnValue_t writeData(uint32_t amount) {
|
||||
if (availableWriteSpace() >= amount || overwriteOld) {
|
||||
incrementWrite(amount);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
uint32_t availableReadData(uint8_t n = 0) const {
|
||||
return ((write + size) - read[n]) % size;
|
||||
}
|
||||
uint32_t availableWriteSpace(uint8_t n = 0) const {
|
||||
//One less to avoid ambiguous full/empty problem.
|
||||
return (((read[n] + size) - write - 1) % size);
|
||||
}
|
||||
|
||||
virtual ~RingBufferBase() {}
|
||||
|
||||
bool isFull(uint8_t n = 0) {
|
||||
return (availableWriteSpace(n) == 0);
|
||||
}
|
||||
bool isEmpty(uint8_t n = 0) {
|
||||
return (availableReadData(n) == 0);
|
||||
return (getAvailableReadData(n) == 0);
|
||||
}
|
||||
virtual ~RingBufferBase() {
|
||||
|
||||
size_t getAvailableReadData(uint8_t n = 0) const {
|
||||
return ((write + size) - read[n]) % size;
|
||||
}
|
||||
uint32_t getRead(uint8_t n = 0) const {
|
||||
return read[n];
|
||||
size_t availableWriteSpace(uint8_t n = 0) const {
|
||||
//One less to avoid ambiguous full/empty problem.
|
||||
return (((read[n] + size) - write - 1) % size);
|
||||
}
|
||||
void setRead(uint32_t read, uint8_t n = 0) {
|
||||
if (read >= start && read < (start+size)) {
|
||||
this->read[n] = read;
|
||||
}
|
||||
|
||||
bool overwritesOld() const {
|
||||
return overwriteOld;
|
||||
}
|
||||
uint32_t getWrite() const {
|
||||
return write;
|
||||
}
|
||||
void setWrite(uint32_t write) {
|
||||
this->write = write;
|
||||
|
||||
size_t getMaxSize() const {
|
||||
return size - 1;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
write = start;
|
||||
for (uint8_t count = 0; count < N_READ_PTRS; count++) {
|
||||
read[count] = start;
|
||||
}
|
||||
}
|
||||
uint32_t writeTillWrap() {
|
||||
|
||||
size_t writeTillWrap() {
|
||||
return (start + size) - write;
|
||||
}
|
||||
uint32_t readTillWrap(uint8_t n = 0) {
|
||||
|
||||
size_t readTillWrap(uint8_t n = 0) {
|
||||
return (start + size) - read[n];
|
||||
}
|
||||
uint32_t getStart() const {
|
||||
|
||||
size_t getStart() const {
|
||||
return start;
|
||||
}
|
||||
bool overwritesOld() const {
|
||||
return overwriteOld;
|
||||
}
|
||||
uint32_t maxSize() const {
|
||||
return size - 1;
|
||||
}
|
||||
|
||||
protected:
|
||||
const uint32_t start;
|
||||
uint32_t write;
|
||||
uint32_t read[N_READ_PTRS];
|
||||
const uint32_t size;
|
||||
const size_t start;
|
||||
size_t write;
|
||||
size_t read[N_READ_PTRS];
|
||||
const size_t size;
|
||||
const bool overwriteOld;
|
||||
|
||||
void incrementWrite(uint32_t amount) {
|
||||
write = ((write + amount - start) % size) + start;
|
||||
}
|
||||
void incrementRead(uint32_t amount, uint8_t n = 0) {
|
||||
read[n] = ((read[n] + amount - start) % size) + start;
|
||||
}
|
||||
|
||||
ReturnValue_t readData(uint32_t amount, uint8_t n = 0) {
|
||||
if (getAvailableReadData(n) >= amount) {
|
||||
incrementRead(amount, n);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t writeData(uint32_t amount) {
|
||||
if (availableWriteSpace() >= amount or overwriteOld) {
|
||||
incrementWrite(amount);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
size_t getRead(uint8_t n = 0) const {
|
||||
return read[n];
|
||||
}
|
||||
|
||||
void setRead(uint32_t read, uint8_t n = 0) {
|
||||
if (read >= start && read < (start+size)) {
|
||||
this->read[n] = read;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getWrite() const {
|
||||
return write;
|
||||
}
|
||||
|
||||
void setWrite(uint32_t write) {
|
||||
this->write = write;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_ */
|
||||
#endif /* FSFW_CONTAINER_RINGBUFFERBASE_H_ */
|
||||
|
@ -1,79 +0,0 @@
|
||||
|
||||
#include <iostream>
|
||||
#include "SimpleRingBuffer.h"
|
||||
|
||||
|
||||
int main() {
|
||||
using namespace std;
|
||||
SimpleRingBuffer buffer(64, false);
|
||||
uint8_t data[8] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
|
||||
ReturnValue_t result = buffer.writeData(data, 8);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "writeData failed." << endl;
|
||||
}
|
||||
result = buffer.writeData(data, 8);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "writeData failed." << endl;
|
||||
}
|
||||
uint8_t buffer2[47] = {0};
|
||||
for (uint8_t count = 0; count<sizeof(buffer2); count++) {
|
||||
buffer2[count] = count;
|
||||
}
|
||||
result = buffer.writeData(buffer2, sizeof(buffer2));
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "writeData failed." << endl;
|
||||
}
|
||||
result = buffer.writeData(buffer2, sizeof(buffer2));
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "writeData failed." << endl;
|
||||
}
|
||||
uint8_t readBuffer[64] = {0};
|
||||
uint32_t writtenData = 0;
|
||||
result = buffer.readData(readBuffer, 12, true, &writtenData);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "readData failed." << endl;
|
||||
} else {
|
||||
cout << "Read data: " << writtenData << endl;
|
||||
for (uint32_t count = 0; count < writtenData; count++) {
|
||||
cout << hex << (uint16_t)readBuffer[count] << " ";
|
||||
}
|
||||
cout << dec << endl;
|
||||
}
|
||||
|
||||
result = buffer.readData(readBuffer, 60, true, &writtenData);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "readData failed." << endl;
|
||||
} else {
|
||||
cout << "Read data: " << writtenData << endl;
|
||||
for (uint32_t count = 0; count < writtenData; count++) {
|
||||
cout << hex << (uint16_t)readBuffer[count] << " ";
|
||||
}
|
||||
cout << dec << endl;
|
||||
}
|
||||
result = buffer.writeData(data, sizeof(data));
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "writeData failed." << endl;
|
||||
}
|
||||
result = buffer.readData(readBuffer, 60, true, &writtenData);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "readData failed." << endl;
|
||||
} else {
|
||||
cout << "Read data: " << writtenData << endl;
|
||||
for (uint32_t count = 0; count < writtenData; count++) {
|
||||
cout << hex << (uint16_t)readBuffer[count] << " ";
|
||||
}
|
||||
cout << dec << endl;
|
||||
}
|
||||
result = buffer.writeData(readBuffer, sizeof(readBuffer));
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "writeData failed." << endl;
|
||||
}
|
||||
result = buffer.writeData(readBuffer, sizeof(readBuffer)-1);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
cout << "writeData failed." << endl;
|
||||
} else {
|
||||
cout << "write done." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
55
container/SharedRingBuffer.cpp
Normal file
55
container/SharedRingBuffer.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "SharedRingBuffer.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
#include "../ipc/MutexHelper.h"
|
||||
|
||||
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes):
|
||||
SystemObject(objectId), SimpleRingBuffer(size, overwriteOld,
|
||||
maxExcessBytes) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
|
||||
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
||||
const size_t size, bool overwriteOld, size_t maxExcessBytes):
|
||||
SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld,
|
||||
maxExcessBytes) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
|
||||
void SharedRingBuffer::setToUseReceiveSizeFIFO(size_t fifoDepth) {
|
||||
this->fifoDepth = fifoDepth;
|
||||
}
|
||||
|
||||
ReturnValue_t SharedRingBuffer::lockRingBufferMutex(
|
||||
MutexIF::TimeoutType timeoutType, dur_millis_t timeout) {
|
||||
return mutex->lockMutex(timeoutType, timeout);
|
||||
}
|
||||
|
||||
ReturnValue_t SharedRingBuffer::unlockRingBufferMutex() {
|
||||
return mutex->unlockMutex();
|
||||
}
|
||||
|
||||
|
||||
|
||||
MutexIF* SharedRingBuffer::getMutexHandle() const {
|
||||
return mutex;
|
||||
}
|
||||
|
||||
ReturnValue_t SharedRingBuffer::initialize() {
|
||||
if(fifoDepth > 0) {
|
||||
receiveSizesFIFO = new DynamicFIFO<size_t>(fifoDepth);
|
||||
}
|
||||
return SystemObject::initialize();
|
||||
}
|
||||
|
||||
DynamicFIFO<size_t>* SharedRingBuffer::getReceiveSizesFIFO() {
|
||||
if(receiveSizesFIFO == nullptr) {
|
||||
// Configuration error.
|
||||
sif::warning << "SharedRingBuffer::getReceiveSizesFIFO: Ring buffer"
|
||||
<< " was not configured to have sizes FIFO, returning nullptr!"
|
||||
<< std::endl;
|
||||
}
|
||||
return receiveSizesFIFO;
|
||||
}
|
92
container/SharedRingBuffer.h
Normal file
92
container/SharedRingBuffer.h
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef FSFW_CONTAINER_SHAREDRINGBUFFER_H_
|
||||
#define FSFW_CONTAINER_SHAREDRINGBUFFER_H_
|
||||
|
||||
#include "SimpleRingBuffer.h"
|
||||
#include "DynamicFIFO.h"
|
||||
#include "../ipc/MutexIF.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../timemanager/Clock.h"
|
||||
|
||||
/**
|
||||
* @brief Ring buffer which can be shared among multiple objects
|
||||
* @details
|
||||
* This class offers a mutex to perform thread-safe operation on the ring
|
||||
* buffer. It is still up to the developer to actually perform the lock
|
||||
* and unlock operations.
|
||||
*/
|
||||
class SharedRingBuffer: public SystemObject,
|
||||
public SimpleRingBuffer {
|
||||
public:
|
||||
/**
|
||||
* This constructor allocates a new internal buffer with the supplied size.
|
||||
* @param size
|
||||
* @param overwriteOld
|
||||
* If the ring buffer is overflowing at a write operartion, the oldest data
|
||||
* will be overwritten.
|
||||
*/
|
||||
SharedRingBuffer(object_id_t objectId, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes);
|
||||
|
||||
/**
|
||||
* @brief This function can be used to add an optional FIFO to the class
|
||||
* @details
|
||||
* This FIFO will be allocated in the initialize function (and will
|
||||
* have a fixed maximum size after that). It can be used to store
|
||||
* values like packet sizes, for example for a shared ring buffer
|
||||
* used by producer/consumer tasks.
|
||||
*/
|
||||
void setToUseReceiveSizeFIFO(size_t fifoDepth);
|
||||
|
||||
/**
|
||||
* This constructor takes an external buffer with the specified size.
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param overwriteOld
|
||||
* If the ring buffer is overflowing at a write operartion, the oldest data
|
||||
* will be overwritten.
|
||||
*/
|
||||
SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes);
|
||||
|
||||
/**
|
||||
* Unless a read-only constant value is read, all operations on the
|
||||
* shared ring buffer should be protected by calling this function.
|
||||
* @param timeoutType
|
||||
* @param timeout
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t lockRingBufferMutex(MutexIF::TimeoutType timeoutType,
|
||||
dur_millis_t timeout);
|
||||
/**
|
||||
* Any locked mutex also has to be unlocked, otherwise, access to the
|
||||
* shared ring buffer will be blocked.
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t unlockRingBufferMutex();
|
||||
|
||||
/**
|
||||
* The mutex handle can be accessed directly, for example to perform
|
||||
* the lock with the #MutexHelper for a RAII compliant lock operation.
|
||||
* @return
|
||||
*/
|
||||
MutexIF* getMutexHandle() const;
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
/**
|
||||
* If the shared ring buffer was configured to have a sizes FIFO, a handle
|
||||
* to that FIFO can be retrieved with this function.
|
||||
* Do not forget to protect access with a lock if required!
|
||||
* @return
|
||||
*/
|
||||
DynamicFIFO<size_t>* getReceiveSizesFIFO();
|
||||
private:
|
||||
MutexIF* mutex = nullptr;
|
||||
|
||||
size_t fifoDepth = 0;
|
||||
DynamicFIFO<size_t>* receiveSizesFIFO = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_CONTAINER_SHAREDRINGBUFFER_H_ */
|
@ -1,22 +1,69 @@
|
||||
#include <framework/container/SimpleRingBuffer.h>
|
||||
#include <string.h>
|
||||
#include "SimpleRingBuffer.h"
|
||||
#include <cstring>
|
||||
|
||||
SimpleRingBuffer::SimpleRingBuffer(uint32_t size, bool overwriteOld) :
|
||||
RingBufferBase<>(0, size, overwriteOld), buffer(NULL) {
|
||||
buffer = new uint8_t[size];
|
||||
SimpleRingBuffer::SimpleRingBuffer(const size_t size, bool overwriteOld,
|
||||
size_t maxExcessBytes) :
|
||||
RingBufferBase<>(0, size, overwriteOld),
|
||||
maxExcessBytes(maxExcessBytes) {
|
||||
if(maxExcessBytes > size) {
|
||||
this->maxExcessBytes = size;
|
||||
}
|
||||
else {
|
||||
this->maxExcessBytes = maxExcessBytes;
|
||||
}
|
||||
buffer = new uint8_t[size + maxExcessBytes];
|
||||
}
|
||||
|
||||
SimpleRingBuffer::SimpleRingBuffer(uint8_t *buffer, const size_t size,
|
||||
bool overwriteOld, size_t maxExcessBytes):
|
||||
RingBufferBase<>(0, size, overwriteOld), buffer(buffer) {
|
||||
if(maxExcessBytes > size) {
|
||||
this->maxExcessBytes = size;
|
||||
}
|
||||
else {
|
||||
this->maxExcessBytes = maxExcessBytes;
|
||||
}
|
||||
}
|
||||
|
||||
SimpleRingBuffer::~SimpleRingBuffer() {
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
ReturnValue_t SimpleRingBuffer::getFreeElement(uint8_t **writePointer,
|
||||
size_t amount) {
|
||||
if (availableWriteSpace() >= amount or overwriteOld) {
|
||||
size_t amountTillWrap = writeTillWrap();
|
||||
if (amountTillWrap < amount) {
|
||||
if((amount - amountTillWrap + excessBytes) > maxExcessBytes) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
excessBytes = amount - amountTillWrap;
|
||||
}
|
||||
*writePointer = &buffer[write];
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleRingBuffer::confirmBytesWritten(size_t amount) {
|
||||
if(getExcessBytes() > 0) {
|
||||
moveExcessBytesToStart();
|
||||
}
|
||||
incrementWrite(amount);
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data,
|
||||
uint32_t amount) {
|
||||
if (availableWriteSpace() >= amount || overwriteOld) {
|
||||
uint32_t amountTillWrap = writeTillWrap();
|
||||
size_t amount) {
|
||||
if (availableWriteSpace() >= amount or overwriteOld) {
|
||||
size_t amountTillWrap = writeTillWrap();
|
||||
if (amountTillWrap >= amount) {
|
||||
// remaining size in buffer is sufficient to fit full amount.
|
||||
memcpy(&buffer[write], data, amount);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
memcpy(&buffer[write], data, amountTillWrap);
|
||||
memcpy(buffer, data + amountTillWrap, amount - amountTillWrap);
|
||||
}
|
||||
@ -27,18 +74,19 @@ ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data,
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, uint32_t amount,
|
||||
bool readRemaining, uint32_t* trueAmount) {
|
||||
uint32_t availableData = availableReadData(READ_PTR);
|
||||
uint32_t amountTillWrap = readTillWrap(READ_PTR);
|
||||
ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, size_t amount,
|
||||
bool incrementReadPtr, bool readRemaining, size_t* trueAmount) {
|
||||
size_t availableData = getAvailableReadData(READ_PTR);
|
||||
size_t amountTillWrap = readTillWrap(READ_PTR);
|
||||
if (availableData < amount) {
|
||||
if (readRemaining) {
|
||||
// more data available than amount specified.
|
||||
amount = availableData;
|
||||
} else {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
if (trueAmount != NULL) {
|
||||
if (trueAmount != nullptr) {
|
||||
*trueAmount = amount;
|
||||
}
|
||||
if (amountTillWrap >= amount) {
|
||||
@ -47,12 +95,27 @@ ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, uint32_t amount,
|
||||
memcpy(data, &buffer[read[READ_PTR]], amountTillWrap);
|
||||
memcpy(data + amountTillWrap, buffer, amount - amountTillWrap);
|
||||
}
|
||||
|
||||
if(incrementReadPtr) {
|
||||
deleteData(amount, readRemaining);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SimpleRingBuffer::deleteData(uint32_t amount,
|
||||
bool deleteRemaining, uint32_t* trueAmount) {
|
||||
uint32_t availableData = availableReadData(READ_PTR);
|
||||
size_t SimpleRingBuffer::getExcessBytes() const {
|
||||
return excessBytes;
|
||||
}
|
||||
|
||||
void SimpleRingBuffer::moveExcessBytesToStart() {
|
||||
if(excessBytes > 0) {
|
||||
std::memcpy(buffer, &buffer[size], excessBytes);
|
||||
excessBytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SimpleRingBuffer::deleteData(size_t amount,
|
||||
bool deleteRemaining, size_t* trueAmount) {
|
||||
size_t availableData = getAvailableReadData(READ_PTR);
|
||||
if (availableData < amount) {
|
||||
if (deleteRemaining) {
|
||||
amount = availableData;
|
||||
@ -60,7 +123,7 @@ ReturnValue_t SimpleRingBuffer::deleteData(uint32_t amount,
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
if (trueAmount != NULL) {
|
||||
if (trueAmount != nullptr) {
|
||||
*trueAmount = amount;
|
||||
}
|
||||
incrementRead(amount, READ_PTR);
|
||||
|
@ -1,21 +1,129 @@
|
||||
#ifndef FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_
|
||||
#define FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_
|
||||
#ifndef FSFW_CONTAINER_SIMPLERINGBUFFER_H_
|
||||
#define FSFW_CONTAINER_SIMPLERINGBUFFER_H_
|
||||
|
||||
#include <framework/container/RingBufferBase.h>
|
||||
#include <stddef.h>
|
||||
#include "RingBufferBase.h"
|
||||
#include <cstddef>
|
||||
|
||||
/**
|
||||
* @brief Circular buffer implementation, useful for buffering
|
||||
* into data streams.
|
||||
* @details
|
||||
* Note that the deleteData() has to be called to increment the read pointer.
|
||||
* This class allocated dynamically, so
|
||||
* @ingroup containers
|
||||
*/
|
||||
class SimpleRingBuffer: public RingBufferBase<> {
|
||||
public:
|
||||
SimpleRingBuffer(uint32_t size, bool overwriteOld);
|
||||
/**
|
||||
* This constructor allocates a new internal buffer with the supplied size.
|
||||
*
|
||||
* @param size
|
||||
* @param overwriteOld If the ring buffer is overflowing at a write
|
||||
* operation, the oldest data will be overwritten.
|
||||
* @param maxExcessBytes These additional bytes will be allocated in addtion
|
||||
* to the specified size to accomodate contiguous write operations
|
||||
* with getFreeElement.
|
||||
*
|
||||
*/
|
||||
SimpleRingBuffer(const size_t size, bool overwriteOld,
|
||||
size_t maxExcessBytes = 0);
|
||||
/**
|
||||
* This constructor takes an external buffer with the specified size.
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param overwriteOld
|
||||
* If the ring buffer is overflowing at a write operartion, the oldest data
|
||||
* will be overwritten.
|
||||
* @param maxExcessBytes
|
||||
* If the buffer can accomodate additional bytes for contigous write
|
||||
* operations with getFreeElement, this is the maximum allowed additional
|
||||
* size
|
||||
*/
|
||||
SimpleRingBuffer(uint8_t* buffer, const size_t size, bool overwriteOld,
|
||||
size_t maxExcessBytes = 0);
|
||||
|
||||
virtual ~SimpleRingBuffer();
|
||||
ReturnValue_t writeData(const uint8_t* data, uint32_t amount);
|
||||
ReturnValue_t readData(uint8_t* data, uint32_t amount, bool readRemaining = false, uint32_t* trueAmount = NULL);
|
||||
ReturnValue_t deleteData(uint32_t amount, bool deleteRemaining = false, uint32_t* trueAmount = NULL);
|
||||
|
||||
/**
|
||||
* Write to circular buffer and increment write pointer by amount.
|
||||
* @param data
|
||||
* @param amount
|
||||
* @return -@c RETURN_OK if write operation was successfull
|
||||
* -@c RETURN_FAILED if
|
||||
*/
|
||||
ReturnValue_t writeData(const uint8_t* data, size_t amount);
|
||||
|
||||
/**
|
||||
* Returns a pointer to a free element. If the remaining buffer is
|
||||
* not large enough, the data will be written past the actual size
|
||||
* and the amount of excess bytes will be cached. This function
|
||||
* does not increment the write pointer!
|
||||
* @param writePointer Pointer to a pointer which can be used to write
|
||||
* contiguous blocks into the ring buffer
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t getFreeElement(uint8_t** writePointer, size_t amount);
|
||||
|
||||
/**
|
||||
* This increments the write pointer and also copies the excess bytes
|
||||
* to the beginning. It should be called if the write operation
|
||||
* conducted after calling getFreeElement() was performed.
|
||||
* @return
|
||||
*/
|
||||
void confirmBytesWritten(size_t amount);
|
||||
|
||||
virtual size_t getExcessBytes() const;
|
||||
/**
|
||||
* Helper functions which moves any excess bytes to the start
|
||||
* of the ring buffer.
|
||||
* @return
|
||||
*/
|
||||
virtual void moveExcessBytesToStart();
|
||||
|
||||
/**
|
||||
* Read from circular buffer at read pointer.
|
||||
* @param data
|
||||
* @param amount
|
||||
* @param incrementReadPtr
|
||||
* If this is set to true, the read pointer will be incremented.
|
||||
* If readRemaining is set to true, the read pointer will be incremented
|
||||
* accordingly.
|
||||
* @param readRemaining
|
||||
* If this is set to true, the data will be read even if the amount
|
||||
* specified exceeds the read data available.
|
||||
* @param trueAmount [out]
|
||||
* If readRemaining was set to true, the true amount read will be assigned
|
||||
* to the passed value.
|
||||
* @return
|
||||
* - @c RETURN_OK if data was read successfully
|
||||
* - @c RETURN_FAILED if not enough data was available and readRemaining
|
||||
* was set to false.
|
||||
*/
|
||||
ReturnValue_t readData(uint8_t* data, size_t amount,
|
||||
bool incrementReadPtr = false, bool readRemaining = false,
|
||||
size_t* trueAmount = nullptr);
|
||||
|
||||
/**
|
||||
* Delete data by incrementing read pointer.
|
||||
* @param amount
|
||||
* @param deleteRemaining
|
||||
* If the amount specified is larger than the remaing size to read and this
|
||||
* is set to true, the remaining amount will be deleted as well
|
||||
* @param trueAmount [out]
|
||||
* If deleteRemaining was set to true, the amount deleted will be assigned
|
||||
* to the passed value.
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t deleteData(size_t amount, bool deleteRemaining = false,
|
||||
size_t* trueAmount = nullptr);
|
||||
|
||||
private:
|
||||
// static const uint8_t TEMP_READ_PTR = 1;
|
||||
static const uint8_t READ_PTR = 0;
|
||||
uint8_t* buffer;
|
||||
uint8_t* buffer = nullptr;
|
||||
size_t maxExcessBytes;
|
||||
size_t excessBytes = 0;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_ */
|
||||
#endif /* FSFW_CONTAINER_SIMPLERINGBUFFER_H_ */
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
#ifndef SINGLYLINKEDLIST_H_
|
||||
#define SINGLYLINKEDLIST_H_
|
||||
#ifndef FRAMEWORK_CONTAINER_SINGLYLINKEDLIST_H_
|
||||
#define FRAMEWORK_CONTAINER_SINGLYLINKEDLIST_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
/**
|
||||
* \ingroup container
|
||||
* @brief Linked list data structure,
|
||||
* each entry has a pointer to the next entry (singly)
|
||||
* @ingroup container
|
||||
*/
|
||||
template<typename T>
|
||||
class LinkedElement {
|
||||
@ -12,11 +15,8 @@ public:
|
||||
T *value;
|
||||
class Iterator {
|
||||
public:
|
||||
LinkedElement<T> *value;
|
||||
Iterator() :
|
||||
value(NULL) {
|
||||
|
||||
}
|
||||
LinkedElement<T> *value = nullptr;
|
||||
Iterator() {}
|
||||
|
||||
Iterator(LinkedElement<T> *element) :
|
||||
value(element) {
|
||||
@ -45,12 +45,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
LinkedElement(T* setElement, LinkedElement<T>* setNext = NULL) : value(setElement),
|
||||
next(setNext) {
|
||||
}
|
||||
virtual ~LinkedElement(){
|
||||
LinkedElement(T* setElement, LinkedElement<T>* setNext = nullptr):
|
||||
value(setElement), next(setNext) {}
|
||||
|
||||
virtual ~LinkedElement(){}
|
||||
|
||||
}
|
||||
virtual LinkedElement* getNext() const {
|
||||
return next;
|
||||
}
|
||||
@ -58,11 +57,16 @@ public:
|
||||
virtual void setNext(LinkedElement* next) {
|
||||
this->next = next;
|
||||
}
|
||||
|
||||
virtual void setEnd() {
|
||||
this->next = nullptr;
|
||||
}
|
||||
|
||||
LinkedElement* begin() {
|
||||
return this;
|
||||
}
|
||||
LinkedElement* end() {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
private:
|
||||
LinkedElement *next;
|
||||
@ -71,37 +75,80 @@ private:
|
||||
template<typename T>
|
||||
class SinglyLinkedList {
|
||||
public:
|
||||
SinglyLinkedList() :
|
||||
start(NULL) {
|
||||
}
|
||||
using ElementIterator = typename LinkedElement<T>::Iterator;
|
||||
|
||||
SinglyLinkedList() {}
|
||||
|
||||
SinglyLinkedList(ElementIterator start) :
|
||||
start(start.value) {}
|
||||
|
||||
SinglyLinkedList(typename LinkedElement<T>::Iterator start) :
|
||||
start(start.value) {
|
||||
}
|
||||
SinglyLinkedList(LinkedElement<T>* startElement) :
|
||||
start(startElement) {
|
||||
}
|
||||
typename LinkedElement<T>::Iterator begin() const {
|
||||
return LinkedElement<T>::Iterator::Iterator(start);
|
||||
}
|
||||
typename LinkedElement<T>::Iterator::Iterator end() const {
|
||||
return LinkedElement<T>::Iterator::Iterator();
|
||||
start(startElement) {}
|
||||
|
||||
ElementIterator begin() const {
|
||||
return ElementIterator::Iterator(start);
|
||||
}
|
||||
|
||||
uint32_t getSize() const {
|
||||
uint32_t size = 0;
|
||||
/** Returns iterator to nulltr */
|
||||
ElementIterator end() const {
|
||||
return ElementIterator::Iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element in singly linked list.
|
||||
* @return
|
||||
*/
|
||||
ElementIterator back() const {
|
||||
LinkedElement<T> *element = start;
|
||||
while (element->getNext() != nullptr) {
|
||||
element = element->getNext();
|
||||
}
|
||||
return ElementIterator::Iterator(element);
|
||||
}
|
||||
|
||||
size_t getSize() const {
|
||||
size_t size = 0;
|
||||
LinkedElement<T> *element = start;
|
||||
while (element != NULL) {
|
||||
while (element != nullptr) {
|
||||
size++;
|
||||
element = element->getNext();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
void setStart(LinkedElement<T>* setStart) {
|
||||
start = setStart;
|
||||
void setStart(LinkedElement<T>* firstElement) {
|
||||
start = firstElement;
|
||||
}
|
||||
|
||||
void setNext(LinkedElement<T>* currentElement,
|
||||
LinkedElement<T>* nextElement) {
|
||||
currentElement->setNext(nextElement);
|
||||
}
|
||||
|
||||
void setLast(LinkedElement<T>* lastElement) {
|
||||
lastElement->setEnd();
|
||||
}
|
||||
|
||||
void insertElement(LinkedElement<T>* element, size_t position) {
|
||||
LinkedElement<T> *currentElement = start;
|
||||
for(size_t count = 0; count < position; count++) {
|
||||
if(currentElement == nullptr) {
|
||||
return;
|
||||
}
|
||||
currentElement = currentElement->getNext();
|
||||
}
|
||||
LinkedElement<T>* elementAfterCurrent = currentElement->next;
|
||||
currentElement->setNext(element);
|
||||
if(elementAfterCurrent != nullptr) {
|
||||
element->setNext(elementAfterCurrent);
|
||||
}
|
||||
}
|
||||
|
||||
void insertBack(LinkedElement<T>* lastElement) {
|
||||
back().value->setNext(lastElement);
|
||||
}
|
||||
|
||||
protected:
|
||||
LinkedElement<T> *start;
|
||||
LinkedElement<T> *start = nullptr;
|
||||
};
|
||||
|
||||
#endif /* SINGLYLINKEDLIST_H_ */
|
||||
|
@ -1,365 +0,0 @@
|
||||
#include "FixedArrayList.h"
|
||||
#include "SinglyLinkedList.h"
|
||||
#include "HybridIterator.h"
|
||||
|
||||
#include "FixedMap.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
|
||||
class Packet: public SinglyLinkedList {
|
||||
public:
|
||||
SinglyLinkedList::Element<uint32_t> element1;
|
||||
SinglyLinkedList::Element<uint32_t> element2;
|
||||
|
||||
Packet() {
|
||||
this->start = &element1;
|
||||
element1.next = &element2;
|
||||
}
|
||||
};
|
||||
|
||||
class Packet2: public SinglyLinkedList {
|
||||
public:
|
||||
SinglyLinkedList::Element<uint32_t> element1;
|
||||
SinglyLinkedList::Element<FixedArrayList<FixedArrayList<uint8_t, 5>, 2>> element2;
|
||||
SinglyLinkedList::Element<uint32_t> element3;
|
||||
|
||||
Packet2() {
|
||||
this->start = &element1;
|
||||
element1.next = &element2;
|
||||
element2.next = &element3;
|
||||
}
|
||||
};
|
||||
|
||||
class Packet3: public SinglyLinkedList {
|
||||
public:
|
||||
SinglyLinkedList::TypedElement<uint32_t> element1;
|
||||
SinglyLinkedList::TypedElement<uint32_t> element2;
|
||||
|
||||
Packet3() {
|
||||
this->start = &element1;
|
||||
element1.next = &element2;
|
||||
}
|
||||
};
|
||||
|
||||
void arrayList() {
|
||||
puts("** Array List **");
|
||||
FixedArrayList<uint32_t, 10, uint32_t> list;
|
||||
FixedArrayList<uint32_t, 10, uint32_t> list2;
|
||||
|
||||
list.size = 2;
|
||||
|
||||
list[0] = 0xcafecafe;
|
||||
|
||||
list[1] = 0x12345678;
|
||||
|
||||
uint8_t buffer[100];
|
||||
uint8_t *pointer = buffer;
|
||||
uint32_t size = 0;
|
||||
uint32_t maxSize = 100;
|
||||
uint32_t i;
|
||||
int32_t size2;
|
||||
|
||||
printf("printsize: %i\n", list.getPrintSize());
|
||||
|
||||
list.print(&pointer, &size, 100, true);
|
||||
|
||||
printf("buffer(%i):", size);
|
||||
for (i = 0; i < size; ++i) {
|
||||
printf("%02x", buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
pointer = buffer;
|
||||
|
||||
size2 = size;
|
||||
|
||||
printf("list2 read: %x\n", list2.read(&pointer, &size2, true));
|
||||
|
||||
printf("list2(%i):", list2.size);
|
||||
for (ArrayList<uint32_t, uint32_t>::Iterator iter = list2.begin();
|
||||
iter != list2.end(); iter++) {
|
||||
printf("0x%04x ", *iter);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
HybridIterator<uint32_t, uint32_t> hiter(list.begin(),list.end());
|
||||
|
||||
printf("hybrid1: 0x%04x\n", *(hiter++));
|
||||
printf("hybrid2: 0x%04x\n", *hiter);
|
||||
|
||||
}
|
||||
|
||||
void allocatingList() {
|
||||
puts("** Allocating List **");
|
||||
ArrayList<uint8_t> myList(3), myList2(2);
|
||||
myList[0] = 0xab;
|
||||
myList[1] = 0xcd;
|
||||
myList.size = 2;
|
||||
|
||||
uint8_t buffer[100];
|
||||
uint8_t *pointer = buffer;
|
||||
uint32_t size = 0;
|
||||
uint32_t maxSize = 100;
|
||||
uint32_t i;
|
||||
int32_t size2;
|
||||
|
||||
myList.print(&pointer, &size, 100, true);
|
||||
|
||||
pointer = buffer;
|
||||
size2 = size;
|
||||
|
||||
printf("Read %x\n", myList2.read(&pointer, &size2, true));
|
||||
|
||||
printf("%x,%x\n", myList2[0], myList2[1]);
|
||||
|
||||
}
|
||||
|
||||
void linkedList() {
|
||||
puts("** Linked List **");
|
||||
uint8_t buffer[100];
|
||||
uint8_t *pointer = buffer;
|
||||
uint32_t size = 0;
|
||||
uint32_t maxSize = 100;
|
||||
uint32_t i;
|
||||
int32_t size2;
|
||||
|
||||
Packet myPacket;
|
||||
myPacket.element1.entry = 0x12345678;
|
||||
myPacket.element2.entry = 0x9abcdef0;
|
||||
|
||||
pointer = buffer;
|
||||
size = 0;
|
||||
ReturnValue_t result = myPacket.print(&pointer, &size, 100, true);
|
||||
|
||||
printf("result %02x\n", result);
|
||||
|
||||
printf("printsize: %i\n", myPacket.getPrintSize());
|
||||
|
||||
printf("buffer(%i):", size);
|
||||
for (i = 0; i < size; ++i) {
|
||||
printf("%02x", buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
Packet3 myPacket3;
|
||||
|
||||
myPacket3.element1.entry = 0x12345678;
|
||||
myPacket3.element2.entry = 0xabcdeff;
|
||||
|
||||
SinglyLinkedList::TypedIterator<uint32_t> titer(&myPacket3.element1);
|
||||
|
||||
printf("0x%04x\n", *titer);
|
||||
|
||||
HybridIterator<uint32_t, uint32_t> hiter(&myPacket3.element1);
|
||||
|
||||
printf("hybrid1: 0x%04x\n", *hiter);
|
||||
hiter++;
|
||||
printf("hybrid2: 0x%04x\n", *hiter);
|
||||
}
|
||||
|
||||
void complex() {
|
||||
puts("** complex **");
|
||||
uint8_t buffer[100];
|
||||
uint8_t *pointer = buffer;
|
||||
uint32_t size = 0;
|
||||
uint32_t maxSize = 100;
|
||||
uint32_t i;
|
||||
int32_t size2 = size;
|
||||
|
||||
Packet myPacket2;
|
||||
|
||||
size2 = size;
|
||||
pointer = buffer;
|
||||
|
||||
myPacket2.read(&pointer, &size2, true);
|
||||
|
||||
printf("packet: 0x%04x, 0x%04x\n", myPacket2.element1.entry,
|
||||
myPacket2.element2.entry);
|
||||
|
||||
buffer[0] = 0x12;
|
||||
buffer[1] = 0x34;
|
||||
buffer[2] = 0x56;
|
||||
buffer[3] = 0x78;
|
||||
buffer[4] = 0x2;
|
||||
buffer[5] = 0x3;
|
||||
buffer[6] = 0xab;
|
||||
buffer[7] = 0xcd;
|
||||
buffer[8] = 0xef;
|
||||
buffer[9] = 0x2;
|
||||
buffer[10] = 0x11;
|
||||
buffer[11] = 0x22;
|
||||
buffer[12] = 0xca;
|
||||
buffer[13] = 0xfe;
|
||||
buffer[14] = 0x5a;
|
||||
buffer[15] = 0xfe;
|
||||
|
||||
pointer = buffer;
|
||||
size2 = 23;
|
||||
|
||||
Packet2 p2;
|
||||
|
||||
ReturnValue_t result = p2.read(&pointer, &size2, true);
|
||||
printf("result is %02x\n", result);
|
||||
|
||||
printf("%04x; %i: %i: %x %x %x; %i: %x %x;; %04x\n", p2.element1.entry,
|
||||
p2.element2.entry.size, p2.element2.entry[0].size,
|
||||
p2.element2.entry[0][0], p2.element2.entry[0][1],
|
||||
p2.element2.entry[0][2], p2.element2.entry[1].size,
|
||||
p2.element2.entry[1][0], p2.element2.entry[1][1],
|
||||
p2.element3.entry);
|
||||
|
||||
}
|
||||
*/
|
||||
struct Test {
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
};
|
||||
|
||||
template<typename key_t, typename T>
|
||||
void printMap(FixedMap<key_t, T> *map) {
|
||||
typename FixedMap<key_t, T>::Iterator iter;
|
||||
printf("Map (%i): ", map->getSize());
|
||||
for (iter = map->begin(); iter != map->end(); ++iter) {
|
||||
printf("%x:%08x,%08x ", iter.value->first, (*iter).a, (*iter).b);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void map() {
|
||||
puts("** Map **");
|
||||
typename FixedMap<T, Test>::Iterator iter;
|
||||
ReturnValue_t result;
|
||||
FixedMap<T, Test> myMap(5);
|
||||
|
||||
printMap<T, Test>(&myMap);
|
||||
|
||||
Test a;
|
||||
a.a = 0x01234567;
|
||||
a.b = 0xabcdef89;
|
||||
|
||||
myMap.insert(1, a);
|
||||
printMap<T, Test>(&myMap);
|
||||
|
||||
a.a = 0;
|
||||
|
||||
myMap.insert(2, a);
|
||||
printMap<T, Test>(&myMap);
|
||||
|
||||
printf("2 exists: %x\n", myMap.exists(0x02));
|
||||
|
||||
printf("ff exists: %x\n", myMap.exists(0xff));
|
||||
|
||||
a.a = 1;
|
||||
printf("insert 0x2: %x\n", myMap.insert(2, a));
|
||||
|
||||
result = myMap.insert(0xff, a);
|
||||
a.a = 0x44;
|
||||
result = myMap.insert(0xab, a);
|
||||
result = myMap.insert(0xa, a);
|
||||
|
||||
printMap<T, Test>(&myMap);
|
||||
|
||||
printf("insert 0x5: %x\n", myMap.insert(5, a));
|
||||
|
||||
printf("erase 0xfe: %x\n", myMap.erase(0xfe));
|
||||
|
||||
printf("erase 0x2: %x\n", myMap.erase(0x2));
|
||||
|
||||
printMap<T, Test>(&myMap);
|
||||
|
||||
printf("erase 0xab: %x\n", myMap.erase(0xab));
|
||||
printMap<T, Test>(&myMap);
|
||||
|
||||
printf("insert 0x5: %x\n", myMap.insert(5, a));
|
||||
printMap<T, Test>(&myMap);
|
||||
|
||||
iter = myMap.begin();
|
||||
++iter;
|
||||
++iter;
|
||||
++iter;
|
||||
|
||||
printf("iter: %i: %x,%x\n",iter.value->first, iter->a, iter->b);
|
||||
|
||||
myMap.erase(&iter);
|
||||
|
||||
printf("iter: %i: %x,%x\n",iter.value->first, iter->a, iter->b);
|
||||
printMap<T, Test>(&myMap);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void mapPrint() {
|
||||
puts("** Map Print **");
|
||||
FixedMap<uint16_t, Packet2> myMap(5);
|
||||
Packet2 myPacket;
|
||||
myPacket.element1.entry = 0x12345678;
|
||||
|
||||
myPacket.element2.entry[0][0] = 0xab;
|
||||
myPacket.element2.entry[0][1] = 0xcd;
|
||||
myPacket.element2.entry[0].size = 2;
|
||||
myPacket.element2.entry.size = 1;
|
||||
|
||||
myPacket.element3.entry = 0xabcdef90;
|
||||
|
||||
myMap.insert(0x1234, myPacket);
|
||||
|
||||
uint8_t buffer[100];
|
||||
uint32_t size = 0, i;
|
||||
uint8_t *pointer = buffer;
|
||||
|
||||
printf("printsize: %i\n", myMap.getPrintSize());
|
||||
|
||||
SerializeAdapter<FixedMap<uint16_t, Packet2>>::print(&myMap, &pointer,
|
||||
&size, 100, false);
|
||||
|
||||
printf("buffer(%i):", size);
|
||||
for (i = 0; i < size; ++i) {
|
||||
printf("%02x", buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
int32_t size2 = size;
|
||||
pointer = buffer;
|
||||
|
||||
FixedMap<uint16_t, Packet2> myMap2(5);
|
||||
|
||||
ReturnValue_t result = SerializeAdapter<FixedMap<uint16_t, Packet2>>::read(
|
||||
&myMap2, &pointer, &size2, false);
|
||||
|
||||
Packet2 *myPacket2 = myMap2.find(0x1234);
|
||||
|
||||
printf("Map (%i): Packet2: %x, Array (%i): Array (%i): %x, %x; %x\n",
|
||||
myMap2.getSize(), myPacket2->element1.entry,
|
||||
myPacket2->element2.entry.size, myPacket2->element2.entry[0].size,
|
||||
myPacket2->element2.entry[0][0], myPacket2->element2.entry[0][1],
|
||||
myPacket2->element3.entry);
|
||||
|
||||
}
|
||||
|
||||
void empty() {
|
||||
puts("** Empty **");
|
||||
ArrayList<uint32_t> list(0);
|
||||
printf("%p %p\n", list.front(), list.back());
|
||||
}
|
||||
*/
|
||||
|
||||
int main(void) {
|
||||
|
||||
// arrayList();
|
||||
// linkedList();
|
||||
// allocatingList();
|
||||
// complex();
|
||||
|
||||
map<uint32_t>();
|
||||
//
|
||||
// mapPrint();
|
||||
|
||||
// empty();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,117 +1,117 @@
|
||||
#ifndef _sgp4unit_
|
||||
#define _sgp4unit_
|
||||
/* ----------------------------------------------------------------
|
||||
*
|
||||
* sgp4unit.h
|
||||
*
|
||||
* this file contains the sgp4 procedures for analytical propagation
|
||||
* of a satellite. the code was originally released in the 1980 and 1986
|
||||
* spacetrack papers. a detailed discussion of the theory and history
|
||||
* may be found in the 2006 aiaa paper by vallado, crawford, hujsak,
|
||||
* and kelso.
|
||||
*
|
||||
* companion code for
|
||||
* fundamentals of astrodynamics and applications
|
||||
* 2007
|
||||
* by david vallado
|
||||
*
|
||||
* (w) 719-573-2600, email dvallado@agi.com
|
||||
*
|
||||
* current :
|
||||
* 20 apr 07 david vallado
|
||||
* misc fixes for constants
|
||||
* changes :
|
||||
* 11 aug 06 david vallado
|
||||
* chg lyddane choice back to strn3, constants, misc doc
|
||||
* 15 dec 05 david vallado
|
||||
* misc fixes
|
||||
* 26 jul 05 david vallado
|
||||
* fixes for paper
|
||||
* note that each fix is preceded by a
|
||||
* comment with "sgp4fix" and an explanation of
|
||||
* what was changed
|
||||
* 10 aug 04 david vallado
|
||||
* 2nd printing baseline working
|
||||
* 14 may 01 david vallado
|
||||
* 2nd edition baseline
|
||||
* 80 norad
|
||||
* original baseline
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// -------------------------- structure declarations ----------------------------
|
||||
typedef enum
|
||||
{
|
||||
wgs72old,
|
||||
wgs72,
|
||||
wgs84
|
||||
} gravconsttype;
|
||||
|
||||
typedef struct elsetrec
|
||||
{
|
||||
long int satnum;
|
||||
int epochyr, epochtynumrev;
|
||||
int error;
|
||||
char init, method;
|
||||
|
||||
/* Near Earth */
|
||||
int isimp;
|
||||
double aycof , con41 , cc1 , cc4 , cc5 , d2 , d3 , d4 ,
|
||||
delmo , eta , argpdot, omgcof , sinmao , t , t2cof, t3cof ,
|
||||
t4cof , t5cof , x1mth2 , x7thm1 , mdot , nodedot, xlcof , xmcof ,
|
||||
nodecf;
|
||||
|
||||
/* Deep Space */
|
||||
int irez;
|
||||
double d2201 , d2211 , d3210 , d3222 , d4410 , d4422 , d5220 , d5232 ,
|
||||
d5421 , d5433 , dedt , del1 , del2 , del3 , didt , dmdt ,
|
||||
dnodt , domdt , e3 , ee2 , peo , pgho , pho , pinco ,
|
||||
plo , se2 , se3 , sgh2 , sgh3 , sgh4 , sh2 , sh3 ,
|
||||
si2 , si3 , sl2 , sl3 , sl4 , gsto , xfact , xgh2 ,
|
||||
xgh3 , xgh4 , xh2 , xh3 , xi2 , xi3 , xl2 , xl3 ,
|
||||
xl4 , xlamo , zmol , zmos , atime , xli , xni;
|
||||
|
||||
double a , altp , alta , epochdays, jdsatepoch , nddot , ndot ,
|
||||
bstar , rcse , inclo , nodeo , ecco , argpo , mo ,
|
||||
no;
|
||||
} elsetrec;
|
||||
|
||||
// --------------------------- function declarations ----------------------------
|
||||
int sgp4init
|
||||
(
|
||||
gravconsttype whichconst, const int satn, const double epoch,
|
||||
const double xbstar, const double xecco, const double xargpo,
|
||||
const double xinclo, const double xmo, const double xno,
|
||||
const double xnodeo,
|
||||
elsetrec& satrec
|
||||
);
|
||||
|
||||
int sgp4
|
||||
(
|
||||
gravconsttype whichconst,
|
||||
elsetrec& satrec, double tsince,
|
||||
double r[], double v[]
|
||||
);
|
||||
|
||||
double gstime
|
||||
(
|
||||
double
|
||||
);
|
||||
|
||||
void getgravconst
|
||||
(
|
||||
gravconsttype,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _sgp4unit_
|
||||
#define _sgp4unit_
|
||||
/* ----------------------------------------------------------------
|
||||
*
|
||||
* sgp4unit.h
|
||||
*
|
||||
* this file contains the sgp4 procedures for analytical propagation
|
||||
* of a satellite. the code was originally released in the 1980 and 1986
|
||||
* spacetrack papers. a detailed discussion of the theory and history
|
||||
* may be found in the 2006 aiaa paper by vallado, crawford, hujsak,
|
||||
* and kelso.
|
||||
*
|
||||
* companion code for
|
||||
* fundamentals of astrodynamics and applications
|
||||
* 2007
|
||||
* by david vallado
|
||||
*
|
||||
* (w) 719-573-2600, email dvallado@agi.com
|
||||
*
|
||||
* current :
|
||||
* 20 apr 07 david vallado
|
||||
* misc fixes for constants
|
||||
* changes :
|
||||
* 11 aug 06 david vallado
|
||||
* chg lyddane choice back to strn3, constants, misc doc
|
||||
* 15 dec 05 david vallado
|
||||
* misc fixes
|
||||
* 26 jul 05 david vallado
|
||||
* fixes for paper
|
||||
* note that each fix is preceded by a
|
||||
* comment with "sgp4fix" and an explanation of
|
||||
* what was changed
|
||||
* 10 aug 04 david vallado
|
||||
* 2nd printing baseline working
|
||||
* 14 may 01 david vallado
|
||||
* 2nd edition baseline
|
||||
* 80 norad
|
||||
* original baseline
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// -------------------------- structure declarations ----------------------------
|
||||
typedef enum
|
||||
{
|
||||
wgs72old,
|
||||
wgs72,
|
||||
wgs84
|
||||
} gravconsttype;
|
||||
|
||||
typedef struct elsetrec
|
||||
{
|
||||
long int satnum;
|
||||
int epochyr, epochtynumrev;
|
||||
int error;
|
||||
char init, method;
|
||||
|
||||
/* Near Earth */
|
||||
int isimp;
|
||||
double aycof , con41 , cc1 , cc4 , cc5 , d2 , d3 , d4 ,
|
||||
delmo , eta , argpdot, omgcof , sinmao , t , t2cof, t3cof ,
|
||||
t4cof , t5cof , x1mth2 , x7thm1 , mdot , nodedot, xlcof , xmcof ,
|
||||
nodecf;
|
||||
|
||||
/* Deep Space */
|
||||
int irez;
|
||||
double d2201 , d2211 , d3210 , d3222 , d4410 , d4422 , d5220 , d5232 ,
|
||||
d5421 , d5433 , dedt , del1 , del2 , del3 , didt , dmdt ,
|
||||
dnodt , domdt , e3 , ee2 , peo , pgho , pho , pinco ,
|
||||
plo , se2 , se3 , sgh2 , sgh3 , sgh4 , sh2 , sh3 ,
|
||||
si2 , si3 , sl2 , sl3 , sl4 , gsto , xfact , xgh2 ,
|
||||
xgh3 , xgh4 , xh2 , xh3 , xi2 , xi3 , xl2 , xl3 ,
|
||||
xl4 , xlamo , zmol , zmos , atime , xli , xni;
|
||||
|
||||
double a , altp , alta , epochdays, jdsatepoch , nddot , ndot ,
|
||||
bstar , rcse , inclo , nodeo , ecco , argpo , mo ,
|
||||
no;
|
||||
} elsetrec;
|
||||
|
||||
// --------------------------- function declarations ----------------------------
|
||||
int sgp4init
|
||||
(
|
||||
gravconsttype whichconst, const int satn, const double epoch,
|
||||
const double xbstar, const double xecco, const double xargpo,
|
||||
const double xinclo, const double xmo, const double xno,
|
||||
const double xnodeo,
|
||||
elsetrec& satrec
|
||||
);
|
||||
|
||||
int sgp4
|
||||
(
|
||||
gravconsttype whichconst,
|
||||
elsetrec& satrec, double tsince,
|
||||
double r[], double v[]
|
||||
);
|
||||
|
||||
double gstime
|
||||
(
|
||||
double
|
||||
);
|
||||
|
||||
void getgravconst
|
||||
(
|
||||
gravconsttype,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&,
|
||||
double&
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <framework/subsystem/SubsystemBase.h>
|
||||
#include <framework/controller/ControllerBase.h>
|
||||
#include <framework/subsystem/SubsystemBase.h>
|
||||
#include <framework/ipc/QueueFactory.h>
|
||||
#include <framework/action/HasActionsIF.h>
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
#include "ControllerBase.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../action/HasActionsIF.h"
|
||||
|
||||
ControllerBase::ControllerBase(uint32_t setObjectId, uint32_t parentId,
|
||||
size_t commandQueueDepth) :
|
||||
|
@ -1,13 +1,13 @@
|
||||
#ifndef CONTROLLERBASE_H_
|
||||
#define CONTROLLERBASE_H_
|
||||
|
||||
#include <framework/health/HasHealthIF.h>
|
||||
#include <framework/health/HealthHelper.h>
|
||||
#include <framework/modes/HasModesIF.h>
|
||||
#include <framework/modes/ModeHelper.h>
|
||||
#include <framework/objectmanager/SystemObject.h>
|
||||
#include <framework/tasks/ExecutableObjectIF.h>
|
||||
#include <framework/datapool/HkSwitchHelper.h>
|
||||
#include "../health/HasHealthIF.h"
|
||||
#include "../health/HealthHelper.h"
|
||||
#include "../modes/HasModesIF.h"
|
||||
#include "../modes/ModeHelper.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../tasks/ExecutableObjectIF.h"
|
||||
#include "../datapool/HkSwitchHelper.h"
|
||||
|
||||
|
||||
class ControllerBase: public HasModesIF,
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <framework/coordinates/CoordinateTransformations.h>
|
||||
#include <framework/globalfunctions/constants.h>
|
||||
#include <framework/globalfunctions/math/MatrixOperations.h>
|
||||
#include <framework/globalfunctions/math/VectorOperations.h>
|
||||
#include "CoordinateTransformations.h"
|
||||
#include "../globalfunctions/constants.h"
|
||||
#include "../globalfunctions/math/MatrixOperations.h"
|
||||
#include "../globalfunctions/math/VectorOperations.h"
|
||||
#include <stddef.h>
|
||||
#include <cmath>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef COORDINATETRANSFORMATIONS_H_
|
||||
#define COORDINATETRANSFORMATIONS_H_
|
||||
|
||||
#include <framework/timemanager/Clock.h>
|
||||
#include "../timemanager/Clock.h"
|
||||
#include <cstring>
|
||||
|
||||
class CoordinateTransformations {
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define FRAMEWORK_COORDINATES_JGM3MODEL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <framework/coordinates/CoordinateTransformations.h>
|
||||
#include <framework/globalfunctions/math/VectorOperations.h>
|
||||
#include <framework/globalfunctions/timevalOperations.h>
|
||||
#include <framework/globalfunctions/constants.h>
|
||||
#include "CoordinateTransformations.h"
|
||||
#include "../globalfunctions/math/VectorOperations.h"
|
||||
#include "../globalfunctions/timevalOperations.h"
|
||||
#include "../globalfunctions/constants.h"
|
||||
#include <memory.h>
|
||||
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include <framework/coordinates/CoordinateTransformations.h>
|
||||
#include <framework/coordinates/Sgp4Propagator.h>
|
||||
#include <framework/globalfunctions/constants.h>
|
||||
#include <framework/globalfunctions/math/MatrixOperations.h>
|
||||
#include <framework/globalfunctions/math/VectorOperations.h>
|
||||
#include <framework/globalfunctions/timevalOperations.h>
|
||||
#include "CoordinateTransformations.h"
|
||||
#include "Sgp4Propagator.h"
|
||||
#include "../globalfunctions/constants.h"
|
||||
#include "../globalfunctions/math/MatrixOperations.h"
|
||||
#include "../globalfunctions/math/VectorOperations.h"
|
||||
#include "../globalfunctions/timevalOperations.h"
|
||||
#include <cstring>
|
||||
Sgp4Propagator::Sgp4Propagator() :
|
||||
initialized(false), epoch({0, 0}), whichconst(wgs84) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "../contrib/sgp4/sgp4unit.h"
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class Sgp4Propagator {
|
||||
public:
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef BCFRAME_H_
|
||||
#define BCFRAME_H_
|
||||
|
||||
#include <framework/datalinklayer/CCSDSReturnValuesIF.h>
|
||||
#include "CCSDSReturnValuesIF.h"
|
||||
|
||||
/**
|
||||
* Small helper class to identify a BcFrame.
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef CCSDSRETURNVALUESIF_H_
|
||||
#define CCSDSRETURNVALUESIF_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
/**
|
||||
* This is a helper class to collect special return values that come up during CCSDS Handling.
|
||||
* @ingroup ccsds_handling
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
|
||||
|
||||
#include <framework/datalinklayer/Clcw.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "Clcw.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
Clcw::Clcw() {
|
||||
content.raw = 0;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef CLCW_H_
|
||||
#define CLCW_H_
|
||||
|
||||
#include <framework/datalinklayer/ClcwIF.h>
|
||||
#include "ClcwIF.h"
|
||||
/**
|
||||
* Small helper method to handle the Clcw values.
|
||||
* It has a content struct that manages the register and can be set externally.
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <framework/datalinklayer/DataLinkLayer.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "DataLinkLayer.h"
|
||||
#include "../globalfunctions/CRC.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
DataLinkLayer::DataLinkLayer(uint8_t* set_frame_buffer, ClcwIF* setClcw,
|
||||
uint8_t set_start_sequence_length, uint16_t set_scid) :
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef DATALINKLAYER_H_
|
||||
#define DATALINKLAYER_H_
|
||||
|
||||
#include <framework/datalinklayer/CCSDSReturnValuesIF.h>
|
||||
#include <framework/datalinklayer/ClcwIF.h>
|
||||
#include <framework/datalinklayer/TcTransferFrame.h>
|
||||
#include <framework/datalinklayer/VirtualChannelReceptionIF.h>
|
||||
#include <framework/events/Event.h>
|
||||
#include "CCSDSReturnValuesIF.h"
|
||||
#include "ClcwIF.h"
|
||||
#include "TcTransferFrame.h"
|
||||
#include "VirtualChannelReceptionIF.h"
|
||||
#include "../events/Event.h"
|
||||
#include <map>
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FARM1STATEIF_H_
|
||||
#define FARM1STATEIF_H_
|
||||
|
||||
#include <framework/datalinklayer/CCSDSReturnValuesIF.h>
|
||||
#include "CCSDSReturnValuesIF.h"
|
||||
class VirtualChannelReception;
|
||||
class TcTransferFrame;
|
||||
class ClcwIF;
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
|
||||
|
||||
#include <framework/datalinklayer/ClcwIF.h>
|
||||
#include <framework/datalinklayer/Farm1StateLockout.h>
|
||||
#include <framework/datalinklayer/TcTransferFrame.h>
|
||||
#include <framework/datalinklayer/VirtualChannelReception.h>
|
||||
#include "ClcwIF.h"
|
||||
#include "Farm1StateLockout.h"
|
||||
#include "TcTransferFrame.h"
|
||||
#include "VirtualChannelReception.h"
|
||||
Farm1StateLockout::Farm1StateLockout(VirtualChannelReception* setMyVC) : myVC(setMyVC) {
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FARM1STATELOCKOUT_H_
|
||||
#define FARM1STATELOCKOUT_H_
|
||||
|
||||
#include <framework/datalinklayer/Farm1StateIF.h>
|
||||
#include "Farm1StateIF.h"
|
||||
|
||||
/**
|
||||
* This class represents the FARM-1 "Lockout" State.
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
|
||||
|
||||
#include <framework/datalinklayer/ClcwIF.h>
|
||||
#include <framework/datalinklayer/Farm1StateOpen.h>
|
||||
#include <framework/datalinklayer/TcTransferFrame.h>
|
||||
#include <framework/datalinklayer/VirtualChannelReception.h>
|
||||
#include "ClcwIF.h"
|
||||
#include "Farm1StateOpen.h"
|
||||
#include "TcTransferFrame.h"
|
||||
#include "VirtualChannelReception.h"
|
||||
|
||||
Farm1StateOpen::Farm1StateOpen(VirtualChannelReception* setMyVC) : myVC(setMyVC) {
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FARM1STATEOPEN_H_
|
||||
#define FARM1STATEOPEN_H_
|
||||
|
||||
#include <framework/datalinklayer/Farm1StateIF.h>
|
||||
#include "Farm1StateIF.h"
|
||||
|
||||
/**
|
||||
* This class represents the FARM-1 "Open" State.
|
||||
|
@ -6,10 +6,10 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <framework/datalinklayer/ClcwIF.h>
|
||||
#include <framework/datalinklayer/Farm1StateWait.h>
|
||||
#include <framework/datalinklayer/TcTransferFrame.h>
|
||||
#include <framework/datalinklayer/VirtualChannelReception.h>
|
||||
#include "ClcwIF.h"
|
||||
#include "Farm1StateWait.h"
|
||||
#include "TcTransferFrame.h"
|
||||
#include "VirtualChannelReception.h"
|
||||
|
||||
Farm1StateWait::Farm1StateWait(VirtualChannelReception* setMyVC) : myVC(setMyVC) {
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FARM1STATEWAIT_H_
|
||||
#define FARM1STATEWAIT_H_
|
||||
|
||||
#include <framework/datalinklayer/Farm1StateIF.h>
|
||||
#include "Farm1StateIF.h"
|
||||
|
||||
/**
|
||||
* This class represents the FARM-1 "Wait" State.
|
||||
|
@ -5,20 +5,20 @@
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
#include <framework/datalinklayer/MapPacketExtraction.h>
|
||||
#include <framework/ipc/QueueFactory.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include <framework/tmtcpacket/SpacePacketBase.h>
|
||||
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
|
||||
#include <framework/tmtcservices/TmTcMessage.h>
|
||||
#include "MapPacketExtraction.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../tmtcpacket/SpacePacketBase.h"
|
||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||
#include "../tmtcservices/TmTcMessage.h"
|
||||
#include <string.h>
|
||||
|
||||
MapPacketExtraction::MapPacketExtraction(uint8_t setMapId,
|
||||
object_id_t setPacketDestination) :
|
||||
lastSegmentationFlag(NO_SEGMENTATION), mapId(setMapId), packetLength(0), bufferPosition(
|
||||
packetBuffer), packetDestination(setPacketDestination), packetStore(
|
||||
NULL), tcQueueId(MessageQueueSenderIF::NO_QUEUE) {
|
||||
NULL), tcQueueId(MessageQueueIF::NO_QUEUE) {
|
||||
memset(packetBuffer, 0, sizeof(packetBuffer));
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
#ifndef MAPPACKETEXTRACTION_H_
|
||||
#define MAPPACKETEXTRACTION_H_
|
||||
|
||||
#include <framework/datalinklayer/MapPacketExtractionIF.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include "MapPacketExtractionIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
class StorageManagerIF;
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
#ifndef MAPPACKETEXTRACTIONIF_H_
|
||||
#define MAPPACKETEXTRACTIONIF_H_
|
||||
|
||||
#include <framework/datalinklayer/CCSDSReturnValuesIF.h>
|
||||
#include <framework/datalinklayer/TcTransferFrame.h>
|
||||
#include "CCSDSReturnValuesIF.h"
|
||||
#include "TcTransferFrame.h"
|
||||
|
||||
/**
|
||||
* This is the interface for MAP Packet Extraction classes.
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
|
||||
|
||||
#include <framework/datalinklayer/TcTransferFrame.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "TcTransferFrame.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
TcTransferFrame::TcTransferFrame() {
|
||||
frame = NULL;
|
||||
|
@ -5,9 +5,9 @@
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
#include <framework/datalinklayer/TcTransferFrameLocal.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "TcTransferFrameLocal.h"
|
||||
#include "../globalfunctions/CRC.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include <string.h>
|
||||
|
||||
TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uint16_t scid,
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef TCTRANSFERFRAMELOCAL_H_
|
||||
#define TCTRANSFERFRAMELOCAL_H_
|
||||
|
||||
#include <framework/datalinklayer/TcTransferFrame.h>
|
||||
#include "TcTransferFrame.h"
|
||||
|
||||
/**
|
||||
* This is a helper class to locally create TC Transfer Frames.
|
||||
|
@ -5,9 +5,9 @@
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
#include <framework/datalinklayer/BCFrame.h>
|
||||
#include <framework/datalinklayer/VirtualChannelReception.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "BCFrame.h"
|
||||
#include "VirtualChannelReception.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
VirtualChannelReception::VirtualChannelReception(uint8_t setChannelId,
|
||||
uint8_t setSlidingWindowWidth) :
|
||||
|
@ -8,14 +8,14 @@
|
||||
#ifndef VIRTUALCHANNELRECEPTION_H_
|
||||
#define VIRTUALCHANNELRECEPTION_H_
|
||||
|
||||
#include <framework/datalinklayer/CCSDSReturnValuesIF.h>
|
||||
#include <framework/datalinklayer/Clcw.h>
|
||||
#include <framework/datalinklayer/Farm1StateIF.h>
|
||||
#include <framework/datalinklayer/Farm1StateLockout.h>
|
||||
#include <framework/datalinklayer/Farm1StateOpen.h>
|
||||
#include <framework/datalinklayer/Farm1StateWait.h>
|
||||
#include <framework/datalinklayer/MapPacketExtractionIF.h>
|
||||
#include <framework/datalinklayer/VirtualChannelReceptionIF.h>
|
||||
#include "CCSDSReturnValuesIF.h"
|
||||
#include "Clcw.h"
|
||||
#include "Farm1StateIF.h"
|
||||
#include "Farm1StateLockout.h"
|
||||
#include "Farm1StateOpen.h"
|
||||
#include "Farm1StateWait.h"
|
||||
#include "MapPacketExtractionIF.h"
|
||||
#include "VirtualChannelReceptionIF.h"
|
||||
#include <map>
|
||||
/**
|
||||
* Implementation of a TC Virtual Channel.
|
||||
|
@ -8,9 +8,9 @@
|
||||
#ifndef VIRTUALCHANNELRECEPTIONIF_H_
|
||||
#define VIRTUALCHANNELRECEPTIONIF_H_
|
||||
|
||||
#include <framework/datalinklayer/ClcwIF.h>
|
||||
#include <framework/datalinklayer/TcTransferFrame.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "ClcwIF.h"
|
||||
#include "TcTransferFrame.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
/**
|
||||
* This is the interface for Virtual Channel reception classes.
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <framework/datapool/ControllerSet.h>
|
||||
#include "ControllerSet.h"
|
||||
|
||||
ControllerSet::ControllerSet() {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef CONTROLLERSET_H_
|
||||
#define CONTROLLERSET_H_
|
||||
|
||||
#include <framework/datapool/DataSet.h>
|
||||
#include "DataSet.h"
|
||||
|
||||
class ControllerSet :public DataSet {
|
||||
public:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <framework/datapool/DataPool.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/ipc/MutexFactory.h>
|
||||
#include "DataPool.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
|
||||
DataPool::DataPool( void ( *initFunction )( std::map<uint32_t, PoolEntryIF*>* pool_map ) ) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
@ -61,7 +61,7 @@ ReturnValue_t DataPool::freeDataPoolLock() {
|
||||
}
|
||||
|
||||
ReturnValue_t DataPool::lockDataPool() {
|
||||
ReturnValue_t status = mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
||||
ReturnValue_t status = mutex->lockMutex(MutexIF::BLOCKING);
|
||||
if ( status != RETURN_OK ) {
|
||||
sif::error << "DataPool::DataPool: lock of mutex failed with error code: " << status << std::endl;
|
||||
}
|
||||
|
@ -11,9 +11,9 @@
|
||||
#ifndef DATAPOOL_H_
|
||||
#define DATAPOOL_H_
|
||||
|
||||
#include <framework/datapool/PoolEntry.h>
|
||||
#include <framework/globalfunctions/Type.h>
|
||||
#include <framework/ipc/MutexIF.h>
|
||||
#include "PoolEntry.h"
|
||||
#include "../globalfunctions/Type.h"
|
||||
#include "../ipc/MutexIF.h"
|
||||
#include <map>
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include <framework/datapool/DataPool.h>
|
||||
#include <framework/datapool/DataPoolAdmin.h>
|
||||
#include <framework/datapool/DataSet.h>
|
||||
#include <framework/datapool/PoolRawAccess.h>
|
||||
#include <framework/ipc/CommandMessage.h>
|
||||
#include <framework/ipc/QueueFactory.h>
|
||||
#include <framework/parameters/ParameterMessage.h>
|
||||
#include "DataPool.h"
|
||||
#include "DataPoolAdmin.h"
|
||||
#include "DataSet.h"
|
||||
#include "PoolRawAccess.h"
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../parameters/ParameterMessage.h"
|
||||
|
||||
DataPoolAdmin::DataPoolAdmin(object_id_t objectId) :
|
||||
SystemObject(objectId), storage(NULL), commandQueue(NULL), memoryHelper(
|
||||
|
@ -1,15 +1,15 @@
|
||||
#ifndef DATAPOOLADMIN_H_
|
||||
#define DATAPOOLADMIN_H_
|
||||
|
||||
#include <framework/memory/MemoryHelper.h>
|
||||
#include <framework/action/HasActionsIF.h>
|
||||
#include <framework/action/SimpleActionHelper.h>
|
||||
#include <framework/objectmanager/SystemObject.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/tasks/ExecutableObjectIF.h>
|
||||
#include <framework/parameters/ReceivesParameterMessagesIF.h>
|
||||
#include <framework/datapool/DataPoolParameterWrapper.h>
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
#include "../memory/MemoryHelper.h"
|
||||
#include "../action/HasActionsIF.h"
|
||||
#include "../action/SimpleActionHelper.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../tasks/ExecutableObjectIF.h"
|
||||
#include "../parameters/ReceivesParameterMessagesIF.h"
|
||||
#include "DataPoolParameterWrapper.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
|
||||
class DataPoolAdmin: public HasActionsIF,
|
||||
public ExecutableObjectIF,
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "DataPoolParameterWrapper.h"
|
||||
|
||||
//for returncodes
|
||||
#include <framework/parameters/HasParametersIF.h>
|
||||
#include "../parameters/HasParametersIF.h"
|
||||
|
||||
#include <framework/datapool/DataSet.h>
|
||||
#include <framework/datapool/PoolRawAccess.h>
|
||||
#include "DataSet.h"
|
||||
#include "PoolRawAccess.h"
|
||||
|
||||
DataPoolParameterWrapper::DataPoolParameterWrapper() :
|
||||
type(Type::UNKNOWN_TYPE), rows(0), columns(0), poolId(
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef DATAPOOLPARAMETERWRAPPER_H_
|
||||
#define DATAPOOLPARAMETERWRAPPER_H_
|
||||
|
||||
#include <framework/globalfunctions/Type.h>
|
||||
#include <framework/parameters/ParameterWrapper.h>
|
||||
#include "../globalfunctions/Type.h"
|
||||
#include "../parameters/ParameterWrapper.h"
|
||||
|
||||
class DataPoolParameterWrapper: public SerializeIF {
|
||||
public:
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <framework/datapool/DataSet.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "DataSet.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
DataSet::DataSet() :
|
||||
fill_count(0), state(DATA_SET_UNINITIALISED) {
|
||||
|
@ -12,13 +12,13 @@
|
||||
#ifndef DATASET_H_
|
||||
#define DATASET_H_
|
||||
|
||||
#include <framework/datapool/DataPool.h>
|
||||
#include <framework/datapool/DataSetIF.h>
|
||||
#include <framework/datapool/PoolRawAccess.h>
|
||||
#include <framework/datapool/PoolVariable.h>
|
||||
#include <framework/datapool/PoolVarList.h>
|
||||
#include <framework/datapool/PoolVector.h>
|
||||
#include <framework/serialize/SerializeAdapter.h>
|
||||
#include "DataPool.h"
|
||||
#include "DataSetIF.h"
|
||||
#include "PoolRawAccess.h"
|
||||
#include "PoolVariable.h"
|
||||
#include "PoolVarList.h"
|
||||
#include "PoolVector.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
/**
|
||||
* \brief The DataSet class manages a set of locally checked out variables.
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <framework/datapool/HkSwitchHelper.h>
|
||||
#include "HkSwitchHelper.h"
|
||||
//#include <mission/tmtcservices/HKService_03.h>
|
||||
#include <framework/ipc/QueueFactory.h>
|
||||
#include "../ipc/QueueFactory.h"
|
||||
|
||||
HkSwitchHelper::HkSwitchHelper(EventReportingProxyIF* eventProxy) :
|
||||
commandActionHelper(this), eventProxy(eventProxy) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef FRAMEWORK_DATAPOOL_HKSWITCHHELPER_H_
|
||||
#define FRAMEWORK_DATAPOOL_HKSWITCHHELPER_H_
|
||||
|
||||
#include <framework/tasks/ExecutableObjectIF.h>
|
||||
#include <framework/action/CommandsActionsIF.h>
|
||||
#include <framework/events/EventReportingProxyIF.h>
|
||||
#include "../tasks/ExecutableObjectIF.h"
|
||||
#include "../action/CommandsActionsIF.h"
|
||||
#include "../events/EventReportingProxyIF.h"
|
||||
|
||||
//TODO this class violations separation between mission and framework
|
||||
//but it is only a transitional solution until the Datapool is
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef PIDREADER_H_
|
||||
#define PIDREADER_H_
|
||||
#include <framework/datapool/DataPool.h>
|
||||
#include <framework/datapool/DataSetIF.h>
|
||||
#include <framework/datapool/PoolEntry.h>
|
||||
#include <framework/datapool/PoolVariableIF.h>
|
||||
#include <framework/serialize/SerializeAdapter.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "DataPool.h"
|
||||
#include "DataSetIF.h"
|
||||
#include "PoolEntry.h"
|
||||
#include "PoolVariableIF.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
template<typename U, uint8_t n_var> class PIDReaderList;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef FRAMEWORK_DATAPOOL_PIDREADERLIST_H_
|
||||
#define FRAMEWORK_DATAPOOL_PIDREADERLIST_H_
|
||||
|
||||
#include <framework/datapool/PIDReader.h>
|
||||
#include <framework/datapool/PoolVariableIF.h>
|
||||
#include "PIDReader.h"
|
||||
#include "PoolVariableIF.h"
|
||||
template <class T, uint8_t n_var>
|
||||
class PIDReaderList {
|
||||
private:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <framework/datapool/PoolEntry.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/globalfunctions/arrayprinter.h>
|
||||
#include "PoolEntry.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../globalfunctions/arrayprinter.h"
|
||||
#include <cstring>
|
||||
|
||||
template <typename T>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FRAMEWORK_DATAPOOL_POOLENTRY_H_
|
||||
#define FRAMEWORK_DATAPOOL_POOLENTRY_H_
|
||||
|
||||
#include <framework/datapool/PoolEntryIF.h>
|
||||
#include "PoolEntryIF.h"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FRAMEWORK_DATAPOOL_POOLENTRYIF_H_
|
||||
#define FRAMEWORK_DATAPOOL_POOLENTRYIF_H_
|
||||
|
||||
#include <framework/globalfunctions/Type.h>
|
||||
#include "../globalfunctions/Type.h"
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <framework/datapool/DataPool.h>
|
||||
#include <framework/datapool/PoolEntryIF.h>
|
||||
#include <framework/datapool/PoolRawAccess.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/serialize/EndianConverter.h>
|
||||
#include "DataPool.h"
|
||||
#include "PoolEntryIF.h"
|
||||
#include "PoolRawAccess.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serialize/EndianConverter.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef POOLRAWACCESS_H_
|
||||
#define POOLRAWACCESS_H_
|
||||
|
||||
#include <framework/datapool/DataSetIF.h>
|
||||
#include <framework/datapool/PoolVariableIF.h>
|
||||
#include "DataSetIF.h"
|
||||
#include "PoolVariableIF.h"
|
||||
|
||||
/**
|
||||
* This class allows accessing Data Pool variables as raw bytes.
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef POOLVARLIST_H_
|
||||
#define POOLVARLIST_H_
|
||||
|
||||
#include <framework/datapool/PoolVariable.h>
|
||||
#include <framework/datapool/PoolVariableIF.h>
|
||||
#include "PoolVariable.h"
|
||||
#include "PoolVariableIF.h"
|
||||
template <class T, uint8_t n_var>
|
||||
class PoolVarList {
|
||||
private:
|
||||
|
@ -11,11 +11,11 @@
|
||||
#ifndef POOLVARIABLE_H_
|
||||
#define POOLVARIABLE_H_
|
||||
|
||||
#include <framework/datapool/DataSetIF.h>
|
||||
#include <framework/datapool/PoolEntry.h>
|
||||
#include <framework/datapool/PoolVariableIF.h>
|
||||
#include <framework/serialize/SerializeAdapter.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "DataSetIF.h"
|
||||
#include "PoolEntry.h"
|
||||
#include "PoolVariableIF.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
template<typename T, uint8_t n_var> class PoolVarList;
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
#ifndef POOLVARIABLEIF_H_
|
||||
#define POOLVARIABLEIF_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/serialize/SerializeIF.h>
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
|
||||
/**
|
||||
* \brief This interface is used to control local data pool variable representations.
|
||||
|
@ -11,11 +11,11 @@
|
||||
#ifndef POOLVECTOR_H_
|
||||
#define POOLVECTOR_H_
|
||||
|
||||
#include <framework/datapool/DataSetIF.h>
|
||||
#include <framework/datapool/PoolEntry.h>
|
||||
#include <framework/datapool/PoolVariableIF.h>
|
||||
#include <framework/serialize/SerializeAdapter.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "DataSetIF.h"
|
||||
#include "PoolEntry.h"
|
||||
#include "PoolVariableIF.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
/**
|
||||
* \brief This is the access class for array-type data pool entries.
|
||||
|
6
defaultcfg/README.md
Normal file
6
defaultcfg/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# How to setup configuration folder for FSFW
|
||||
|
||||
It is recommended to copy the content of the defaultcfg folder
|
||||
into a config folder which is in the same directory as the Flight
|
||||
Software Framework submodule. After that, the config.mk folder should be
|
||||
included by the primary Makefile with CURRENTPATH set correctly.
|
55
defaultcfg/fsfwconfig/FSFWConfig.h
Normal file
55
defaultcfg/fsfwconfig/FSFWConfig.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef CONFIG_FSFWCONFIG_H_
|
||||
#define CONFIG_FSFWCONFIG_H_
|
||||
|
||||
#include <FSFWVersion.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
//! Used to determine whether C++ ostreams are used
|
||||
//! Those can lead to code bloat.
|
||||
#define FSFW_CPP_OSTREAM_ENABLED 1
|
||||
|
||||
//! Reduced printout to further decrese code size
|
||||
//! Be careful, this also turns off most diagnostic prinouts!
|
||||
#define FSFW_REDUCED_PRINTOUT 0
|
||||
|
||||
//! Can be used to enable debugging printouts for developing the FSFW
|
||||
#define FSFW_DEBUGGING 0
|
||||
|
||||
//! Defines the FIFO depth of each commanding service base which
|
||||
//! also determines how many commands a CSB service can handle in one cycle
|
||||
//! simulataneously. This will increase the required RAM for
|
||||
//! each CSB service !
|
||||
#define FSFW_CSB_FIFO_DEPTH 6
|
||||
|
||||
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
|
||||
//! additional output which requires the translation files translateObjects
|
||||
//! and translateEvents (and their compiled source files)
|
||||
#define FSFW_OBJ_EVENT_TRANSLATION 0
|
||||
|
||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||
#define FSFW_DEBUG_OUTPUT 1
|
||||
//! Specify whether info events are printed too.
|
||||
#define FSFW_DEBUG_INFO 1
|
||||
#include <translateObjects.h>
|
||||
#include <translateEvents.h>
|
||||
#else
|
||||
#define FSFW_DEBUG_OUTPUT 0
|
||||
#endif
|
||||
|
||||
//! When using the newlib nano library, C99 support for stdio facilities
|
||||
//! will not be provided. This define should be set to 1 if this is the case.
|
||||
#define FSFW_NO_C99_IO 1
|
||||
|
||||
namespace fsfwconfig {
|
||||
//! Default timestamp size. The default timestamp will be an eight byte CDC
|
||||
//! short timestamp.
|
||||
static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8;
|
||||
|
||||
//! Configure the allocated pool sizes for the event manager.
|
||||
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
|
||||
static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120;
|
||||
static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FSFWCONFIG_H_ */
|
16
defaultcfg/fsfwconfig/OBSWConfig.h
Normal file
16
defaultcfg/fsfwconfig/OBSWConfig.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef CONFIG_OBSWCONFIG_H_
|
||||
#define CONFIG_OBSWCONFIG_H_
|
||||
|
||||
#include "OBSWVersion.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace config {
|
||||
#endif
|
||||
|
||||
/* Add mission configuration flags here */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_OBSWCONFIG_H_ */
|
9
defaultcfg/fsfwconfig/OBSWVersion.h
Normal file
9
defaultcfg/fsfwconfig/OBSWVersion.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef CONFIG_VERSION_H_
|
||||
#define CONFIG_VERSION_H_
|
||||
|
||||
/* OBSW versioning can be specified in this file */
|
||||
|
||||
#define OBSW_VERSION 0
|
||||
#define OBSW_SUBVERSION 0
|
||||
|
||||
#endif /* CONFIG_VERSION_H_ */
|
5
defaultcfg/fsfwconfig/devices/logicalAddresses.cpp
Normal file
5
defaultcfg/fsfwconfig/devices/logicalAddresses.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "logicalAddresses.h"
|
||||
|
||||
|
||||
|
||||
|
18
defaultcfg/fsfwconfig/devices/logicalAddresses.h
Normal file
18
defaultcfg/fsfwconfig/devices/logicalAddresses.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef CONFIG_DEVICES_LOGICALADDRESSES_H_
|
||||
#define CONFIG_DEVICES_LOGICALADDRESSES_H_
|
||||
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include "../objects/systemObjectList.h"
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* Can be used for addresses for physical devices like I2C adresses.
|
||||
*/
|
||||
namespace addresses {
|
||||
/* Logical addresses have uint32_t datatype */
|
||||
enum logicalAddresses: address_t {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_DEVICES_LOGICALADDRESSES_H_ */
|
4
defaultcfg/fsfwconfig/devices/powerSwitcherList.cpp
Normal file
4
defaultcfg/fsfwconfig/devices/powerSwitcherList.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
#include "powerSwitcherList.h"
|
||||
|
||||
|
||||
|
12
defaultcfg/fsfwconfig/devices/powerSwitcherList.h
Normal file
12
defaultcfg/fsfwconfig/devices/powerSwitcherList.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef CONFIG_DEVICES_POWERSWITCHERLIST_H_
|
||||
#define CONFIG_DEVICES_POWERSWITCHERLIST_H_
|
||||
|
||||
namespace switches {
|
||||
/* Switches are uint8_t datatype and go from 0 to 255 */
|
||||
enum switcherList {
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_DEVICES_POWERSWITCHERLIST_H_ */
|
18
defaultcfg/fsfwconfig/events/subsystemIdRanges.h
Normal file
18
defaultcfg/fsfwconfig/events/subsystemIdRanges.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_
|
||||
#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <fsfw/events/fwSubsystemIdRanges.h>
|
||||
|
||||
/**
|
||||
* @brief Custom subsystem IDs can be added here
|
||||
* @details
|
||||
* Subsystem IDs are used to create unique events.
|
||||
*/
|
||||
namespace SUBSYSTEM_ID {
|
||||
enum: uint8_t {
|
||||
SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE,
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */
|
15
defaultcfg/fsfwconfig/fsfwconfig.mk
Normal file
15
defaultcfg/fsfwconfig/fsfwconfig.mk
Normal file
@ -0,0 +1,15 @@
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/ipc/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/tmtc/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/devices/*.cpp)
|
||||
|
||||
INCLUDES += $(CURRENTPATH)
|
||||
INCLUDES += $(CURRENTPATH)/objects
|
||||
INCLUDES += $(CURRENTPATH)/returnvalues
|
||||
INCLUDES += $(CURRENTPATH)/tmtc
|
||||
INCLUDES += $(CURRENTPATH)/events
|
||||
INCLUDES += $(CURRENTPATH)/devices
|
||||
INCLUDES += $(CURRENTPATH)/pollingsequence
|
||||
INCLUDES += $(CURRENTPATH)/ipc
|
12
defaultcfg/fsfwconfig/ipc/missionMessageTypes.cpp
Normal file
12
defaultcfg/fsfwconfig/ipc/missionMessageTypes.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "missionMessageTypes.h"
|
||||
|
||||
#include <fsfw/ipc/CommandMessageIF.h>
|
||||
|
||||
void messagetypes::clearMissionMessage(CommandMessage* message) {
|
||||
switch(message->getMessageType()) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user