Update from upstream #85
@ -102,6 +102,9 @@ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593
|
|||||||
- Dedicated Version class and constant `fsfw::FSFW_VERSION` containing version information
|
- Dedicated Version class and constant `fsfw::FSFW_VERSION` containing version information
|
||||||
inside `fsfw/version.h`
|
inside `fsfw/version.h`
|
||||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559
|
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559
|
||||||
|
- Added generic PUS TC Scheduler Service 11. It depends on the new added Emebeded Template Library
|
||||||
|
(ETL) dependency.
|
||||||
|
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/594
|
||||||
- Added ETL dependency and improved library dependency management
|
- Added ETL dependency and improved library dependency management
|
||||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/592
|
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/592
|
||||||
- Add a `DummyPowerSwitcher` module which can be useful for test setups when no PCDU is available
|
- Add a `DummyPowerSwitcher` module which can be useful for test setups when no PCDU is available
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
#error Include FIFOBase.h before FIFOBase.tpp!
|
#error Include FIFOBase.h before FIFOBase.tpp!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline FIFOBase<T>::FIFOBase(T* values, const size_t maxCapacity):
|
inline FIFOBase<T>::FIFOBase(T* values, const size_t maxCapacity)
|
||||||
maxCapacity(maxCapacity), values(values){};
|
: maxCapacity(maxCapacity), values(values){};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t FIFOBase<T>::insert(T value) {
|
inline ReturnValue_t FIFOBase<T>::insert(T value) {
|
||||||
if (full()) {
|
if (full()) {
|
||||||
return FULL;
|
return FULL;
|
||||||
@ -21,12 +21,12 @@ inline ReturnValue_t FIFOBase<T>::insert(T value) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t FIFOBase<T>::retrieve(T* value) {
|
inline ReturnValue_t FIFOBase<T>::retrieve(T* value) {
|
||||||
if (empty()) {
|
if (empty()) {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
} else {
|
} else {
|
||||||
if (value == nullptr){
|
if (value == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
*value = values[readIndex];
|
*value = values[readIndex];
|
||||||
@ -36,12 +36,12 @@ inline ReturnValue_t FIFOBase<T>::retrieve(T* value) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t FIFOBase<T>::peek(T* value) {
|
inline ReturnValue_t FIFOBase<T>::peek(T* value) {
|
||||||
if(empty()) {
|
if (empty()) {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
} else {
|
} else {
|
||||||
if (value == nullptr){
|
if (value == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
*value = values[readIndex];
|
*value = values[readIndex];
|
||||||
@ -49,28 +49,28 @@ inline ReturnValue_t FIFOBase<T>::peek(T* value) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t FIFOBase<T>::pop() {
|
inline ReturnValue_t FIFOBase<T>::pop() {
|
||||||
T value;
|
T value;
|
||||||
return this->retrieve(&value);
|
return this->retrieve(&value);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline bool FIFOBase<T>::empty() {
|
inline bool FIFOBase<T>::empty() {
|
||||||
return (currentSize == 0);
|
return (currentSize == 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline bool FIFOBase<T>::full() {
|
inline bool FIFOBase<T>::full() {
|
||||||
return (currentSize == maxCapacity);
|
return (currentSize == maxCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline size_t FIFOBase<T>::size() {
|
inline size_t FIFOBase<T>::size() {
|
||||||
return currentSize;
|
return currentSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline size_t FIFOBase<T>::next(size_t current) {
|
inline size_t FIFOBase<T>::next(size_t current) {
|
||||||
++current;
|
++current;
|
||||||
if (current == maxCapacity) {
|
if (current == maxCapacity) {
|
||||||
@ -79,14 +79,13 @@ inline size_t FIFOBase<T>::next(size_t current) {
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline size_t FIFOBase<T>::getMaxCapacity() const {
|
inline size_t FIFOBase<T>::getMaxCapacity() const {
|
||||||
return maxCapacity;
|
return maxCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
template<typename T>
|
inline void FIFOBase<T>::setContainer(T* data) {
|
||||||
inline void FIFOBase<T>::setContainer(T *data) {
|
|
||||||
this->values = data;
|
this->values = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
#ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_
|
#ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_
|
||||||
#define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_
|
#define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_
|
||||||
|
|
||||||
|
template <typename key_t, typename T, typename KEY_COMPARE>
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t key, T value,
|
||||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t key, T value, Iterator *storedValue) {
|
Iterator *storedValue) {
|
||||||
if (_size == theMap.maxSize()) {
|
if (_size == theMap.maxSize()) {
|
||||||
return MAP_FULL;
|
return MAP_FULL;
|
||||||
}
|
}
|
||||||
size_t position = findNicePlace(key);
|
size_t position = findNicePlace(key);
|
||||||
memmove(static_cast<void*>(&theMap[position + 1]),static_cast<void*>(&theMap[position]),
|
memmove(static_cast<void *>(&theMap[position + 1]), static_cast<void *>(&theMap[position]),
|
||||||
(_size - position) * sizeof(std::pair<key_t,T>));
|
(_size - position) * sizeof(std::pair<key_t, T>));
|
||||||
theMap[position].first = key;
|
theMap[position].first = key;
|
||||||
theMap[position].second = value;
|
theMap[position].second = value;
|
||||||
++_size;
|
++_size;
|
||||||
@ -18,12 +18,12 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t k
|
|||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
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) {
|
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(std::pair<key_t, T> pair) {
|
||||||
return insert(pair.first, pair.second);
|
return insert(pair.first, pair.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
template <typename key_t, typename T, typename KEY_COMPARE>
|
||||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::exists(key_t key) const {
|
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::exists(key_t key) const {
|
||||||
ReturnValue_t result = KEY_DOES_NOT_EXIST;
|
ReturnValue_t result = KEY_DOES_NOT_EXIST;
|
||||||
if (findFirstIndex(key) < _size) {
|
if (findFirstIndex(key) < _size) {
|
||||||
@ -32,7 +32,7 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::exists(key_t k
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
template <typename key_t, typename T, typename KEY_COMPARE>
|
||||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(Iterator *iter) {
|
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(Iterator *iter) {
|
||||||
size_t i;
|
size_t i;
|
||||||
if ((i = findFirstIndex((*iter).value->first)) >= _size) {
|
if ((i = findFirstIndex((*iter).value->first)) >= _size) {
|
||||||
@ -47,7 +47,7 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(Iterator
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
template <typename key_t, typename T, typename KEY_COMPARE>
|
||||||
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(key_t key) {
|
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(key_t key) {
|
||||||
size_t i;
|
size_t i;
|
||||||
if ((i = findFirstIndex(key)) >= _size) {
|
if ((i = findFirstIndex(key)) >= _size) {
|
||||||
@ -60,7 +60,7 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::erase(key_t ke
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
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 {
|
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::find(key_t key, T **value) const {
|
||||||
ReturnValue_t result = exists(key);
|
ReturnValue_t result = exists(key);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -70,8 +70,9 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::find(key_t key
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
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 {
|
inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findFirstIndex(key_t key,
|
||||||
|
size_t startAt) const {
|
||||||
if (startAt >= _size) {
|
if (startAt >= _size) {
|
||||||
return startAt + 1;
|
return startAt + 1;
|
||||||
}
|
}
|
||||||
@ -84,7 +85,7 @@ inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findFirstIndex(key_t
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
template <typename key_t, typename T, typename KEY_COMPARE>
|
||||||
inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findNicePlace(key_t key) const {
|
inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findNicePlace(key_t key) const {
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (i = 0; i < _size; ++i) {
|
for (i = 0; i < _size; ++i) {
|
||||||
@ -95,15 +96,14 @@ inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findNicePlace(key_t k
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename key_t, typename T, typename KEY_COMPARE>
|
template <typename key_t, typename T, typename KEY_COMPARE>
|
||||||
inline void FixedOrderedMultimap<key_t, T, KEY_COMPARE>::removeFromPosition(size_t position) {
|
inline void FixedOrderedMultimap<key_t, T, KEY_COMPARE>::removeFromPosition(size_t position) {
|
||||||
if (_size <= position) {
|
if (_size <= position) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memmove(static_cast<void*>(&theMap[position]), static_cast<void*>(&theMap[position + 1]),
|
memmove(static_cast<void *>(&theMap[position]), static_cast<void *>(&theMap[position + 1]),
|
||||||
(_size - position - 1) * sizeof(std::pair<key_t,T>));
|
(_size - position - 1) * sizeof(std::pair<key_t, T>));
|
||||||
--_size;
|
--_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ */
|
#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ */
|
||||||
|
@ -5,33 +5,31 @@
|
|||||||
#error Include LocalPoolVariable.h before LocalPoolVariable.tpp!
|
#error Include LocalPoolVariable.h before LocalPoolVariable.tpp!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline LocalPoolVariable<T>::LocalPoolVariable(HasLocalDataPoolIF* hkOwner,
|
inline LocalPoolVariable<T>::LocalPoolVariable(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
|
||||||
lp_id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode):
|
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
|
||||||
LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner,
|
inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner, lp_id_t poolId,
|
||||||
lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
|
||||||
LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId, DataSetIF* dataSet,
|
||||||
|
pool_rwm_t setReadWriteMode)
|
||||||
|
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet,
|
||||||
|
setReadWriteMode) {}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId,
|
inline ReturnValue_t LocalPoolVariable<T>::read(MutexIF::TimeoutType timeoutType,
|
||||||
DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
uint32_t timeoutMs) {
|
||||||
LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
|
if (hkManager == nullptr) {
|
||||||
dataSet, setReadWriteMode){}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::read(
|
|
||||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
|
||||||
if(hkManager == nullptr) {
|
|
||||||
return readWithoutLock();
|
return readWithoutLock();
|
||||||
}
|
}
|
||||||
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
|
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
|
||||||
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
|
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = readWithoutLock();
|
result = readWithoutLock();
|
||||||
@ -39,23 +37,21 @@ inline ReturnValue_t LocalPoolVariable<T>::read(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
||||||
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
|
if (readWriteMode == pool_rwm_t::VAR_WRITE) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector",
|
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true,
|
||||||
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
|
targetObjectId, localPoolId);
|
||||||
localPoolId);
|
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolEntry<T>* poolEntry = nullptr;
|
PoolEntry<T>* poolEntry = nullptr;
|
||||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
ReturnValue_t result =
|
||||||
&poolEntry);
|
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||||
if(result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
|
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVariable", result,
|
reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId);
|
||||||
false, ownerObjectId, localPoolId);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,22 +60,22 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid,
|
inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid, MutexIF::TimeoutType timeoutType,
|
||||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
uint32_t timeoutMs) {
|
||||||
this->setValid(setValid);
|
this->setValid(setValid);
|
||||||
return commit(timeoutType, timeoutMs);
|
return commit(timeoutType, timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::commit(
|
inline ReturnValue_t LocalPoolVariable<T>::commit(MutexIF::TimeoutType timeoutType,
|
||||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
uint32_t timeoutMs) {
|
||||||
if(hkManager == nullptr) {
|
if (hkManager == nullptr) {
|
||||||
return commitWithoutLock();
|
return commitWithoutLock();
|
||||||
}
|
}
|
||||||
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
|
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
|
||||||
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
|
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = commitWithoutLock();
|
result = commitWithoutLock();
|
||||||
@ -87,23 +83,21 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
||||||
if(readWriteMode == pool_rwm_t::VAR_READ) {
|
if (readWriteMode == pool_rwm_t::VAR_READ) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector",
|
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false,
|
||||||
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
|
targetObjectId, localPoolId);
|
||||||
localPoolId);
|
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolEntry<T>* poolEntry = nullptr;
|
PoolEntry<T>* poolEntry = nullptr;
|
||||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
ReturnValue_t result =
|
||||||
&poolEntry);
|
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||||
if(result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
|
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVariable", result,
|
reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId);
|
||||||
false, ownerObjectId, localPoolId);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,98 +106,88 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::serialize(uint8_t** buffer,
|
inline ReturnValue_t LocalPoolVariable<T>::serialize(
|
||||||
size_t* size, const size_t max_size,
|
uint8_t** buffer, size_t* size, const size_t max_size,
|
||||||
SerializeIF::Endianness streamEndianness) const {
|
SerializeIF::Endianness streamEndianness) const {
|
||||||
return SerializeAdapter::serialize(&value,
|
return SerializeAdapter::serialize(&value, buffer, size, max_size, streamEndianness);
|
||||||
buffer, size ,max_size, streamEndianness);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline size_t LocalPoolVariable<T>::getSerializedSize() const {
|
inline size_t LocalPoolVariable<T>::getSerializedSize() const {
|
||||||
return SerializeAdapter::getSerializedSize(&value);
|
return SerializeAdapter::getSerializedSize(&value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer,
|
inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
size_t* size, SerializeIF::Endianness streamEndianness) {
|
SerializeIF::Endianness streamEndianness) {
|
||||||
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
|
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline std::ostream& operator<< (std::ostream &out,
|
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVariable<T>& var) {
|
||||||
const LocalPoolVariable<T> &var) {
|
|
||||||
out << var.value;
|
out << var.value;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline LocalPoolVariable<T>::operator T() const {
|
inline LocalPoolVariable<T>::operator T() const {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline LocalPoolVariable<T> & LocalPoolVariable<T>::operator=(
|
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator=(const T& newValue) {
|
||||||
const T& newValue) {
|
|
||||||
value = newValue;
|
value = newValue;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator =(
|
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator=(
|
||||||
const LocalPoolVariable<T>& newPoolVariable) {
|
const LocalPoolVariable<T>& newPoolVariable) {
|
||||||
value = newPoolVariable.value;
|
value = newPoolVariable.value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline bool LocalPoolVariable<T>::operator ==(
|
inline bool LocalPoolVariable<T>::operator==(const LocalPoolVariable<T>& other) const {
|
||||||
const LocalPoolVariable<T> &other) const {
|
|
||||||
return this->value == other.value;
|
return this->value == other.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline bool LocalPoolVariable<T>::operator ==(const T &other) const {
|
inline bool LocalPoolVariable<T>::operator==(const T& other) const {
|
||||||
return this->value == other;
|
return this->value == other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
template<typename T>
|
inline bool LocalPoolVariable<T>::operator!=(const LocalPoolVariable<T>& other) const {
|
||||||
inline bool LocalPoolVariable<T>::operator !=(
|
return not(*this == other);
|
||||||
const LocalPoolVariable<T> &other) const {
|
|
||||||
return not (*this == other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline bool LocalPoolVariable<T>::operator !=(const T &other) const {
|
inline bool LocalPoolVariable<T>::operator!=(const T& other) const {
|
||||||
return not (*this == other);
|
return not(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
template<typename T>
|
inline bool LocalPoolVariable<T>::operator<(const LocalPoolVariable<T>& other) const {
|
||||||
inline bool LocalPoolVariable<T>::operator <(
|
|
||||||
const LocalPoolVariable<T> &other) const {
|
|
||||||
return this->value < other.value;
|
return this->value < other.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline bool LocalPoolVariable<T>::operator <(const T &other) const {
|
inline bool LocalPoolVariable<T>::operator<(const T& other) const {
|
||||||
return this->value < other;
|
return this->value < other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
template<typename T>
|
inline bool LocalPoolVariable<T>::operator>(const LocalPoolVariable<T>& other) const {
|
||||||
inline bool LocalPoolVariable<T>::operator >(
|
return not(*this < other);
|
||||||
const LocalPoolVariable<T> &other) const {
|
|
||||||
return not (*this < other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline bool LocalPoolVariable<T>::operator >(const T &other) const {
|
inline bool LocalPoolVariable<T>::operator>(const T& other) const {
|
||||||
return not (*this < other);
|
return not(*this < other);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */
|
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */
|
||||||
|
@ -5,48 +5,47 @@
|
|||||||
#error Include LocalPoolVector.h before LocalPoolVector.tpp!
|
#error Include LocalPoolVector.h before LocalPoolVector.tpp!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
|
||||||
HasLocalDataPoolIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet,
|
DataSetIF* dataSet,
|
||||||
pool_rwm_t setReadWriteMode):
|
pool_rwm_t setReadWriteMode)
|
||||||
LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner,
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner, lp_id_t poolId,
|
||||||
lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
DataSetIF* dataSet,
|
||||||
LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
pool_rwm_t setReadWriteMode)
|
||||||
|
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet,
|
||||||
DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
pool_rwm_t setReadWriteMode)
|
||||||
LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
|
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet,
|
||||||
dataSet, setReadWriteMode) {}
|
setReadWriteMode) {}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(MutexIF::TimeoutType timeoutType,
|
||||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
uint32_t timeoutMs) {
|
||||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||||
return readWithoutLock();
|
return readWithoutLock();
|
||||||
}
|
}
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
||||||
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
|
if (readWriteMode == pool_rwm_t::VAR_WRITE) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector",
|
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true,
|
||||||
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
|
targetObjectId, localPoolId);
|
||||||
localPoolId);
|
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolEntry<T>* poolEntry = nullptr;
|
PoolEntry<T>* poolEntry = nullptr;
|
||||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
ReturnValue_t result =
|
||||||
&poolEntry);
|
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||||
memset(this->value, 0, vectorSize * sizeof(T));
|
memset(this->value, 0, vectorSize * sizeof(T));
|
||||||
|
|
||||||
if(result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector", result, true, targetObjectId,
|
reportReadCommitError("LocalPoolVector", result, true, targetObjectId, localPoolId);
|
||||||
localPoolId);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
|
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
|
||||||
@ -54,36 +53,35 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
|
||||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
MutexIF::TimeoutType timeoutType,
|
||||||
|
uint32_t timeoutMs) {
|
||||||
this->setValid(valid);
|
this->setValid(valid);
|
||||||
return commit(timeoutType, timeoutMs);
|
return commit(timeoutType, timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(MutexIF::TimeoutType timeoutType,
|
||||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
uint32_t timeoutMs) {
|
||||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||||
return commitWithoutLock();
|
return commitWithoutLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
||||||
if(readWriteMode == pool_rwm_t::VAR_READ) {
|
if (readWriteMode == pool_rwm_t::VAR_READ) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector",
|
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false,
|
||||||
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
|
targetObjectId, localPoolId);
|
||||||
localPoolId);
|
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
}
|
}
|
||||||
PoolEntry<T>* poolEntry = nullptr;
|
PoolEntry<T>* poolEntry = nullptr;
|
||||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
ReturnValue_t result =
|
||||||
&poolEntry);
|
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||||
if(result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector", result, false, targetObjectId,
|
reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId);
|
||||||
localPoolId);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
|
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
|
||||||
@ -91,48 +89,51 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline T& LocalPoolVector<T, vectorSize>::operator [](size_t i) {
|
inline T& LocalPoolVector<T, vectorSize>::operator[](size_t i) {
|
||||||
if(i < vectorSize) {
|
if (i < vectorSize) {
|
||||||
return value[i];
|
return value[i];
|
||||||
}
|
}
|
||||||
// If this happens, I have to set some value. I consider this
|
// If this happens, I have to set some value. I consider this
|
||||||
// a configuration error, but I wont exit here.
|
// a configuration error, but I wont exit here.
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
||||||
" last value!" << std::endl;
|
" last value!"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("LocalPoolVector: Invalid index. Setting or returning"
|
sif::printWarning(
|
||||||
|
"LocalPoolVector: Invalid index. Setting or returning"
|
||||||
" last value!\n");
|
" last value!\n");
|
||||||
#endif
|
#endif
|
||||||
return value[vectorSize - 1];
|
return value[vectorSize - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline const T& LocalPoolVector<T, vectorSize>::operator [](size_t i) const {
|
inline const T& LocalPoolVector<T, vectorSize>::operator[](size_t i) const {
|
||||||
if(i < vectorSize) {
|
if (i < vectorSize) {
|
||||||
return value[i];
|
return value[i];
|
||||||
}
|
}
|
||||||
// If this happens, I have to set some value. I consider this
|
// If this happens, I have to set some value. I consider this
|
||||||
// a configuration error, but I wont exit here.
|
// a configuration error, but I wont exit here.
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
||||||
" last value!" << std::endl;
|
" last value!"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("LocalPoolVector: Invalid index. Setting or returning"
|
sif::printWarning(
|
||||||
|
"LocalPoolVector: Invalid index. Setting or returning"
|
||||||
" last value!\n");
|
" last value!\n");
|
||||||
#endif
|
#endif
|
||||||
return value[vectorSize - 1];
|
return value[vectorSize - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(
|
||||||
size_t* size, size_t maxSize,
|
uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
SerializeIF::Endianness streamEndianness) const {
|
SerializeIF::Endianness streamEndianness) const {
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||||
for (uint16_t i = 0; i < vectorSize; i++) {
|
for (uint16_t i = 0; i < vectorSize; i++) {
|
||||||
result = SerializeAdapter::serialize(&(value[i]), buffer, size,
|
result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness);
|
||||||
maxSize, streamEndianness);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -140,19 +141,17 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
|
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
|
||||||
return vectorSize * SerializeAdapter::getSerializedSize(value);
|
return vectorSize * SerializeAdapter::getSerializedSize(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
|
||||||
const uint8_t** buffer, size_t* size,
|
const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) {
|
||||||
SerializeIF::Endianness streamEndianness) {
|
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||||
for (uint16_t i = 0; i < vectorSize; i++) {
|
for (uint16_t i = 0; i < vectorSize; i++) {
|
||||||
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size,
|
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness);
|
||||||
streamEndianness);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -161,13 +160,12 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
template<typename T, uint16_t vectorSize>
|
template <typename T, uint16_t vectorSize>
|
||||||
inline std::ostream& operator<< (std::ostream &out,
|
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVector<T, vectorSize>& var) {
|
||||||
const LocalPoolVector<T, vectorSize> &var) {
|
|
||||||
out << "Vector: [";
|
out << "Vector: [";
|
||||||
for(int i = 0;i < vectorSize; i++) {
|
for (int i = 0; i < vectorSize; i++) {
|
||||||
out << var.value[i];
|
out << var.value[i];
|
||||||
if(i < vectorSize - 1) {
|
if (i < vectorSize - 1) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
202
src/fsfw/pus/Service11TelecommandScheduling.h
Normal file
202
src/fsfw/pus/Service11TelecommandScheduling.h
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
#ifndef MISSION_PUS_SERVICE11TELECOMMANDSCHEDULING_H_
|
||||||
|
#define MISSION_PUS_SERVICE11TELECOMMANDSCHEDULING_H_
|
||||||
|
|
||||||
|
#include <etl/multimap.h>
|
||||||
|
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||||
|
#include <fsfw/tmtcservices/TmTcMessage.h>
|
||||||
|
|
||||||
|
#include "fsfw/FSFW.h"
|
||||||
|
#include "fsfw/returnvalues/FwClassIds.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: PUS-Service 11 - Telecommand scheduling.
|
||||||
|
* @details:
|
||||||
|
* PUS-Service 11 - Telecommand scheduling.
|
||||||
|
* Full documentation: ECSS-E-ST-70-41C, p. 168:
|
||||||
|
* ST[11] time-based scheduling
|
||||||
|
*
|
||||||
|
* This service provides the capability to command pre-loaded
|
||||||
|
* application processes (telecommands) by releasing them at their
|
||||||
|
* due-time.
|
||||||
|
* References to telecommands are stored together with their due-timepoints
|
||||||
|
* and are released at their corresponding due-time.
|
||||||
|
*
|
||||||
|
* Necessary subservice functionalities are implemented.
|
||||||
|
* Those are:
|
||||||
|
* TC[11,4] activity insertion
|
||||||
|
* TC[11,5] activity deletion
|
||||||
|
* TC[11,6] filter-based activity deletion
|
||||||
|
* TC[11,7] activity time-shift
|
||||||
|
* TC[11,8] filter-based activity time-shift
|
||||||
|
*
|
||||||
|
* Groups are not supported.
|
||||||
|
* This service remains always enabled. Sending a disable-request has no effect.
|
||||||
|
*/
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
class Service11TelecommandScheduling final : public PusServiceBase {
|
||||||
|
public:
|
||||||
|
static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_11;
|
||||||
|
|
||||||
|
static constexpr ReturnValue_t INVALID_TYPE_TIME_WINDOW =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
|
||||||
|
static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
|
||||||
|
static constexpr ReturnValue_t INVALID_RELATIVE_TIME =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
|
||||||
|
|
||||||
|
// The types of PUS-11 subservices
|
||||||
|
enum Subservice : uint8_t {
|
||||||
|
ENABLE_SCHEDULING = 1,
|
||||||
|
DISABLE_SCHEDULING = 2,
|
||||||
|
RESET_SCHEDULING = 3,
|
||||||
|
INSERT_ACTIVITY = 4,
|
||||||
|
DELETE_ACTIVITY = 5,
|
||||||
|
FILTER_DELETE_ACTIVITY = 6,
|
||||||
|
TIMESHIFT_ACTIVITY = 7,
|
||||||
|
FILTER_TIMESHIFT_ACTIVITY = 8,
|
||||||
|
DETAIL_REPORT = 9,
|
||||||
|
TIMEBASE_SCHEDULE_DETAIL_REPORT = 10,
|
||||||
|
TIMESHIFT_ALL_SCHEDULE_ACTIVITIES = 15
|
||||||
|
};
|
||||||
|
|
||||||
|
// The types of time windows for TC[11,6] and TC[11,8], as defined in ECSS-E-ST-70-41C,
|
||||||
|
// requirement 8.11.3c (p. 507)
|
||||||
|
enum TypeOfTimeWindow : uint32_t {
|
||||||
|
SELECT_ALL = 0,
|
||||||
|
FROM_TIMETAG_TO_TIMETAG = 1,
|
||||||
|
FROM_TIMETAG = 2,
|
||||||
|
TO_TIMETAG = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
Service11TelecommandScheduling(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
||||||
|
AcceptsTelecommandsIF* tcRecipient,
|
||||||
|
uint16_t releaseTimeMarginSeconds = DEFAULT_RELEASE_TIME_MARGIN,
|
||||||
|
bool debugMode = false);
|
||||||
|
|
||||||
|
~Service11TelecommandScheduling();
|
||||||
|
|
||||||
|
/** PusServiceBase overrides */
|
||||||
|
ReturnValue_t handleRequest(uint8_t subservice) override;
|
||||||
|
ReturnValue_t performService() override;
|
||||||
|
ReturnValue_t initialize() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct TelecommandStruct {
|
||||||
|
uint64_t requestId;
|
||||||
|
uint32_t seconds;
|
||||||
|
store_address_t storeAddr; // uint16
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr uint16_t DEFAULT_RELEASE_TIME_MARGIN = 5;
|
||||||
|
|
||||||
|
// minimum release time offset to insert into schedule
|
||||||
|
const uint16_t RELEASE_TIME_MARGIN_SECONDS = 5;
|
||||||
|
|
||||||
|
// the maximum amount of stored TCs is defined here
|
||||||
|
static constexpr uint16_t MAX_STORED_TELECOMMANDS = 500;
|
||||||
|
|
||||||
|
bool debugMode = false;
|
||||||
|
StorageManagerIF* tcStore = nullptr;
|
||||||
|
AcceptsTelecommandsIF* tcRecipient = nullptr;
|
||||||
|
MessageQueueId_t recipientMsgQueueId = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The telecommand map uses the exectution time as a Unix time stamp as
|
||||||
|
* the key. This is mapped to a generic telecommand struct.
|
||||||
|
*/
|
||||||
|
using TelecommandMap = etl::multimap<uint32_t, TelecommandStruct, MAX_NUM_TCS>;
|
||||||
|
using TcMapIter = typename TelecommandMap::iterator;
|
||||||
|
|
||||||
|
TelecommandMap telecommandMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Logic to be performed on an incoming TC[11,4].
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
*/
|
||||||
|
ReturnValue_t doInsertActivity(const uint8_t* data, size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Logic to be performed on an incoming TC[11,5].
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
*/
|
||||||
|
ReturnValue_t doDeleteActivity(const uint8_t* data, size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Logic to be performed on an incoming TC[11,6].
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
*/
|
||||||
|
ReturnValue_t doFilterDeleteActivity(const uint8_t* data, size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Logic to be performed on an incoming TC[11,7].
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
*/
|
||||||
|
ReturnValue_t doTimeshiftActivity(const uint8_t* data, size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Logic to be performed on an incoming TC[11,8].
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
*/
|
||||||
|
ReturnValue_t doFilterTimeshiftActivity(const uint8_t* data, size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deserializes a generic type from a payload buffer by using the FSFW
|
||||||
|
* SerializeAdapter Interface.
|
||||||
|
* @param output Output to be deserialized
|
||||||
|
* @param buf Payload buffer (application data)
|
||||||
|
* @param bufsize Remaining size of payload buffer (application data size)
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
ReturnValue_t deserializeViaFsfwInterface(T& output, const uint8_t* buf, size_t bufsize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Extracts the Request ID from the Application Data of a TC by utilizing a ctor of the
|
||||||
|
* class TcPacketPus.
|
||||||
|
* NOTE: This only works if the payload data is a TC (e.g. not for TC[11,5] which does not
|
||||||
|
* send a TC as payload)!
|
||||||
|
* @param data The Application data of the TC (get via getApplicationData()).
|
||||||
|
* @return requestId
|
||||||
|
*/
|
||||||
|
uint64_t getRequestIdFromDataTC(const uint8_t* data) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Extracts the Request ID from the Application Data directly, assuming it is packed
|
||||||
|
* as follows (acc. to ECSS): | source ID (uint32) | apid (uint32) | ssc (uint32) |.
|
||||||
|
* @param data Pointer to first byte described data
|
||||||
|
* @param dataSize Remaining size of data NOTE: non-const, this is modified by the function
|
||||||
|
* @param [out] requestId Request ID
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
*/
|
||||||
|
ReturnValue_t getRequestIdFromData(const uint8_t*& data, size_t& dataSize, uint64_t& requestId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Builds the Request ID from its three elements.
|
||||||
|
* @param sourceId Source ID
|
||||||
|
* @param apid Application Process ID (APID)
|
||||||
|
* @param ssc Source Sequence Count
|
||||||
|
* @return Request ID
|
||||||
|
*/
|
||||||
|
uint64_t buildRequestId(uint32_t sourceId, uint16_t apid, uint16_t ssc) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the filter range for filter TCs from a data packet
|
||||||
|
* @param data TC data
|
||||||
|
* @param dataSize TC data size
|
||||||
|
* @param [out] itBegin Begin of filter range
|
||||||
|
* @param [out] itEnd End of filter range
|
||||||
|
* @return RETURN_OK if successful
|
||||||
|
*/
|
||||||
|
ReturnValue_t getMapFilterFromData(const uint8_t*& data, size_t& size, TcMapIter& itBegin,
|
||||||
|
TcMapIter& itEnd);
|
||||||
|
|
||||||
|
ReturnValue_t handleInvalidData(const char* ctx);
|
||||||
|
/**
|
||||||
|
* @brief Prints content of multimap. Use for simple debugging only.
|
||||||
|
*/
|
||||||
|
void debugPrintMultimapContent(void) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "Service11TelecommandScheduling.tpp"
|
||||||
|
|
||||||
|
#endif /* MISSION_PUS_SERVICE11TELECOMMANDSCHEDULING_H_ */
|
598
src/fsfw/pus/Service11TelecommandScheduling.tpp
Normal file
598
src/fsfw/pus/Service11TelecommandScheduling.tpp
Normal file
@ -0,0 +1,598 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
|
#include <fsfw/serialize/SerializeAdapter.h>
|
||||||
|
#include <fsfw/tmtcservices/AcceptsTelecommandsIF.h>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
static constexpr auto DEF_END = SerializeIF::Endianness::BIG;
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline Service11TelecommandScheduling<MAX_NUM_TCS>::Service11TelecommandScheduling(
|
||||||
|
object_id_t objectId, uint16_t apid, uint8_t serviceId, AcceptsTelecommandsIF *tcRecipient,
|
||||||
|
uint16_t releaseTimeMarginSeconds, bool debugMode)
|
||||||
|
: PusServiceBase(objectId, apid, serviceId),
|
||||||
|
RELEASE_TIME_MARGIN_SECONDS(releaseTimeMarginSeconds),
|
||||||
|
debugMode(debugMode),
|
||||||
|
tcRecipient(tcRecipient) {}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline Service11TelecommandScheduling<MAX_NUM_TCS>::~Service11TelecommandScheduling() {}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleRequest(
|
||||||
|
uint8_t subservice) {
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "PUS11::handleRequest: Handling request " << static_cast<int>(subservice);
|
||||||
|
#else
|
||||||
|
sif::printInfo("PUS11::handleRequest: Handling request %d\n", subservice);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// Get de-serialized Timestamp
|
||||||
|
const uint8_t *data = currentPacket.getApplicationData();
|
||||||
|
size_t size = currentPacket.getApplicationDataSize();
|
||||||
|
if (data == nullptr) {
|
||||||
|
return handleInvalidData("handleRequest");
|
||||||
|
}
|
||||||
|
switch (subservice) {
|
||||||
|
case Subservice::INSERT_ACTIVITY:
|
||||||
|
return doInsertActivity(data, size);
|
||||||
|
case Subservice::DELETE_ACTIVITY:
|
||||||
|
return doDeleteActivity(data, size);
|
||||||
|
case Subservice::FILTER_DELETE_ACTIVITY:
|
||||||
|
return doFilterDeleteActivity(data, size);
|
||||||
|
case Subservice::TIMESHIFT_ACTIVITY:
|
||||||
|
return doTimeshiftActivity(data, size);
|
||||||
|
case Subservice::FILTER_TIMESHIFT_ACTIVITY:
|
||||||
|
return doFilterTimeshiftActivity(data, size);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService() {
|
||||||
|
// DEBUG
|
||||||
|
// DebugPrintMultimapContent();
|
||||||
|
|
||||||
|
// get current time as UNIX timestamp
|
||||||
|
timeval tNow = {};
|
||||||
|
Clock::getClock_timeval(&tNow);
|
||||||
|
|
||||||
|
// NOTE: The iterator is increased in the loop here. Increasing the iterator as for-loop arg
|
||||||
|
// does not work in this case as we are deleting the current element here.
|
||||||
|
for (auto it = telecommandMap.begin(); it != telecommandMap.end();) {
|
||||||
|
if (it->first <= tNow.tv_sec) {
|
||||||
|
// release tc
|
||||||
|
TmTcMessage releaseMsg(it->second.storeAddr);
|
||||||
|
auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false);
|
||||||
|
|
||||||
|
if (sendRet != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return sendRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
telecommandMap.erase(it++);
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "Released TC & erased it from TC map" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("Released TC & erased it from TC map\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::initialize() {
|
||||||
|
ReturnValue_t res = PusServiceBase::initialize();
|
||||||
|
if (res != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||||
|
if (!tcStore) {
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tcRecipient == nullptr) {
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
}
|
||||||
|
recipientMsgQueueId = tcRecipient->getRequestQueue();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivity(
|
||||||
|
const uint8_t *data, size_t size) {
|
||||||
|
uint32_t timestamp = 0;
|
||||||
|
const uint8_t *initData = data;
|
||||||
|
size_t initSz = size;
|
||||||
|
ReturnValue_t result = SerializeAdapter::deSerialize(×tamp, &data, &size, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert possible if sched. time is above margin
|
||||||
|
// (See requirement for Time margin)
|
||||||
|
timeval tNow = {};
|
||||||
|
Clock::getClock_timeval(&tNow);
|
||||||
|
if (timestamp - tNow.tv_sec <= RELEASE_TIME_MARGIN_SECONDS) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "Service11TelecommandScheduling::doInsertActivity: Release time too close to "
|
||||||
|
"current time"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"Service11TelecommandScheduling::doInsertActivity: Release time too close to current "
|
||||||
|
"time\n");
|
||||||
|
#endif
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// store currentPacket and receive the store address
|
||||||
|
store_address_t addr{};
|
||||||
|
if (tcStore->addData(&addr, initData, initSz) != RETURN_OK ||
|
||||||
|
addr.raw == storeId::INVALID_STORE_ADDRESS) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError(
|
||||||
|
"Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed\n");
|
||||||
|
#endif
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert into multimap with new store address
|
||||||
|
TelecommandStruct tc;
|
||||||
|
tc.seconds = timestamp;
|
||||||
|
tc.storeAddr = addr;
|
||||||
|
tc.requestId =
|
||||||
|
getRequestIdFromDataTC(data); // TODO: Missing sanity check of the returned request id
|
||||||
|
|
||||||
|
auto it = telecommandMap.insert(std::pair<uint32_t, TelecommandStruct>(timestamp, tc));
|
||||||
|
if (it == telecommandMap.end()) {
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "PUS11::doInsertActivity: Inserted into Multimap:" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("PUS11::doInsertActivity: Inserted into Multimap:\n");
|
||||||
|
#endif
|
||||||
|
debugPrintMultimapContent();
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doDeleteActivity(
|
||||||
|
const uint8_t *data, size_t size) {
|
||||||
|
// Get request ID
|
||||||
|
uint64_t requestId;
|
||||||
|
ReturnValue_t result = getRequestIdFromData(data, size, requestId);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "PUS11::doDeleteActivity: requestId: " << requestId << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("PUS11::doDeleteActivity: requestId: %d\n", requestId);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
TcMapIter tcToDelete; // handle to the TC to be deleted, can be used if counter is valid
|
||||||
|
int tcToDeleteCount = 0; // counter of all found TCs. Should be 1.
|
||||||
|
|
||||||
|
for (auto it = telecommandMap.begin(); it != telecommandMap.end(); it++) {
|
||||||
|
if (it->second.requestId == requestId) {
|
||||||
|
tcToDelete = it;
|
||||||
|
tcToDeleteCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if 1 explicit TC is found via request ID
|
||||||
|
if (tcToDeleteCount == 0 || tcToDeleteCount > 1) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "Service11TelecommandScheduling::doDeleteActivity: No or more than 1 TC found. "
|
||||||
|
"Cannot explicitly delete TC"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"Service11TelecommandScheduling::doDeleteActivity: No or more than 1 TC found. "
|
||||||
|
"Cannot explicitly delete TC");
|
||||||
|
#endif
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete packet from store
|
||||||
|
if (tcStore->deleteData(tcToDelete->second.storeAddr) != RETURN_OK) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError(
|
||||||
|
"Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store\n");
|
||||||
|
#endif
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
telecommandMap.erase(tcToDelete);
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "PUS11::doDeleteActivity: Deleted TC from map" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("PUS11::doDeleteActivity: Deleted TC from map\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doFilterDeleteActivity(
|
||||||
|
const uint8_t *data, size_t size) {
|
||||||
|
TcMapIter itBegin;
|
||||||
|
TcMapIter itEnd;
|
||||||
|
|
||||||
|
ReturnValue_t result = getMapFilterFromData(data, size, itBegin, itEnd);
|
||||||
|
// get the filter window as map range via dedicated method
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int deletedTCs = 0;
|
||||||
|
for (TcMapIter it = itBegin; it != itEnd; it++) {
|
||||||
|
// delete packet from store
|
||||||
|
if (tcStore->deleteData(it->second.storeAddr) != RETURN_OK) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "Service11TelecommandScheduling::doFilterDeleteActivity: Could not delete TC "
|
||||||
|
"from Store"
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError(
|
||||||
|
"Service11TelecommandScheduling::doFilterDeleteActivity: Could not delete TC from "
|
||||||
|
"Store\n");
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
deletedTCs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Spec says this function erases all elements including itBegin but not itEnd,
|
||||||
|
// see here: https://www.cplusplus.com/reference/map/multimap/erase/
|
||||||
|
// Therefore we need to increase itEnd by 1. (Note that end() returns the "past-the-end" iterator)
|
||||||
|
if (itEnd != telecommandMap.end()) {
|
||||||
|
itEnd++;
|
||||||
|
}
|
||||||
|
|
||||||
|
telecommandMap.erase(itBegin, itEnd);
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "PUS11::doFilterDeleteActivity: Deleted " << deletedTCs << " TCs" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("PUS11::doFilterDeleteActivity: Deleted %d TCs\n", deletedTCs);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doTimeshiftActivity(
|
||||||
|
const uint8_t *data, size_t size) {
|
||||||
|
// Get relative time
|
||||||
|
uint32_t relativeTime = 0;
|
||||||
|
ReturnValue_t result = SerializeAdapter::deSerialize(&relativeTime, &data, &size, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (relativeTime == 0) {
|
||||||
|
return INVALID_RELATIVE_TIME;
|
||||||
|
}
|
||||||
|
// TODO further check sanity of the relative time?
|
||||||
|
|
||||||
|
// Get request ID
|
||||||
|
uint64_t requestId;
|
||||||
|
result = getRequestIdFromData(data, size, requestId);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "PUS11::doTimeshiftActivity: requestId: " << requestId << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("PUS11::doTimeshiftActivity: requestId: %d\n", requestId);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Despite having C++17 ETL multimap has no member function extract :(
|
||||||
|
|
||||||
|
TcMapIter tcToTimeshiftIt;
|
||||||
|
int tcToTimeshiftCount = 0;
|
||||||
|
|
||||||
|
for (auto it = telecommandMap.begin(); it != telecommandMap.end(); it++) {
|
||||||
|
if (it->second.requestId == requestId) {
|
||||||
|
tcToTimeshiftIt = it;
|
||||||
|
tcToTimeshiftCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tcToTimeshiftCount == 0 || tcToTimeshiftCount > 1) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "Service11TelecommandScheduling::doTimeshiftActivity: Either 0 or more than 1 "
|
||||||
|
"TCs found. No explicit timeshifting "
|
||||||
|
"possible"
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
#else
|
||||||
|
sif::printWarning(
|
||||||
|
"Service11TelecommandScheduling::doTimeshiftActivity: Either 0 or more than 1 TCs found. "
|
||||||
|
"No explicit timeshifting possible\n");
|
||||||
|
#endif
|
||||||
|
return TIMESHIFTING_NOT_POSSIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// temporarily hold the item
|
||||||
|
TelecommandStruct tempTc(tcToTimeshiftIt->second);
|
||||||
|
uint32_t tempKey = tcToTimeshiftIt->first + relativeTime;
|
||||||
|
|
||||||
|
// delete old entry from the mm
|
||||||
|
telecommandMap.erase(tcToTimeshiftIt);
|
||||||
|
|
||||||
|
// and then insert it again as new entry
|
||||||
|
telecommandMap.insert(std::make_pair(tempKey, tempTc));
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "PUS11::doTimeshiftActivity: Shifted TC" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("PUS11::doTimeshiftActivity: Shifted TC\n");
|
||||||
|
#endif
|
||||||
|
debugPrintMultimapContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doFilterTimeshiftActivity(
|
||||||
|
const uint8_t *data, size_t size) {
|
||||||
|
// Get relative time
|
||||||
|
uint32_t relativeTime = 0;
|
||||||
|
ReturnValue_t result = SerializeAdapter::deSerialize(&relativeTime, &data, &size, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (relativeTime == 0) {
|
||||||
|
return INVALID_RELATIVE_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do time window
|
||||||
|
TcMapIter itBegin;
|
||||||
|
TcMapIter itEnd;
|
||||||
|
result = getMapFilterFromData(data, size, itBegin, itEnd);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int shiftedItemsCount = 0;
|
||||||
|
for (auto it = itBegin; it != itEnd;) {
|
||||||
|
// temporarily hold the item
|
||||||
|
TelecommandStruct tempTc(it->second);
|
||||||
|
uint32_t tempKey = it->first + relativeTime;
|
||||||
|
|
||||||
|
// delete the old entry from the mm
|
||||||
|
telecommandMap.erase(it++);
|
||||||
|
|
||||||
|
// and then insert it again as new entry
|
||||||
|
telecommandMap.insert(std::make_pair(tempKey, tempTc));
|
||||||
|
shiftedItemsCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "PUS11::doFilterTimeshiftActivity: shiftedItemsCount: " << shiftedItemsCount
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("PUS11::doFilterTimeshiftActivity: shiftedItemsCount: %d\n", shiftedItemsCount);
|
||||||
|
#endif
|
||||||
|
debugPrintMultimapContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shiftedItemsCount > 0) {
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline uint64_t Service11TelecommandScheduling<MAX_NUM_TCS>::getRequestIdFromDataTC(
|
||||||
|
const uint8_t *data) const {
|
||||||
|
TcPacketPus mask(data);
|
||||||
|
|
||||||
|
uint32_t sourceId = mask.getSourceId();
|
||||||
|
uint16_t apid = mask.getAPID();
|
||||||
|
uint16_t sequenceCount = mask.getPacketSequenceCount();
|
||||||
|
|
||||||
|
return buildRequestId(sourceId, apid, sequenceCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getRequestIdFromData(
|
||||||
|
const uint8_t *&data, size_t &dataSize, uint64_t &requestId) {
|
||||||
|
uint32_t srcId = 0;
|
||||||
|
uint16_t apid = 0;
|
||||||
|
uint16_t ssc = 0;
|
||||||
|
|
||||||
|
ReturnValue_t result = SerializeAdapter::deSerialize(&srcId, &data, &dataSize, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::deSerialize(&apid, &data, &dataSize, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::deSerialize(&ssc, &data, &dataSize, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
requestId = buildRequestId(srcId, apid, ssc);
|
||||||
|
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline uint64_t Service11TelecommandScheduling<MAX_NUM_TCS>::buildRequestId(uint32_t sourceId,
|
||||||
|
uint16_t apid,
|
||||||
|
uint16_t ssc) const {
|
||||||
|
uint64_t sourceId64 = static_cast<uint64_t>(sourceId);
|
||||||
|
uint64_t apid64 = static_cast<uint64_t>(apid);
|
||||||
|
uint64_t ssc64 = static_cast<uint64_t>(ssc);
|
||||||
|
|
||||||
|
return (sourceId64 << 32) | (apid64 << 16) | ssc64;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getMapFilterFromData(
|
||||||
|
const uint8_t *&data, size_t &dataSize, TcMapIter &itBegin, TcMapIter &itEnd) {
|
||||||
|
// get filter type first
|
||||||
|
uint32_t typeRaw = 0;
|
||||||
|
ReturnValue_t result = SerializeAdapter::deSerialize(&typeRaw, &data, &dataSize, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeRaw > 3) {
|
||||||
|
return INVALID_TYPE_TIME_WINDOW;
|
||||||
|
}
|
||||||
|
TypeOfTimeWindow type = static_cast<TypeOfTimeWindow>(typeRaw);
|
||||||
|
|
||||||
|
// we now have the type of delete activity - so now we set the range to delete,
|
||||||
|
// according to the type of time window.
|
||||||
|
// NOTE: Blocks are used in this switch-case statement so that timestamps can be
|
||||||
|
// cleanly redefined for each case.
|
||||||
|
switch (type) {
|
||||||
|
case TypeOfTimeWindow::SELECT_ALL: {
|
||||||
|
itBegin = telecommandMap.begin();
|
||||||
|
itEnd = telecommandMap.end();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TypeOfTimeWindow::FROM_TIMETAG: {
|
||||||
|
uint32_t fromTimestamp = 0;
|
||||||
|
result = SerializeAdapter::deSerialize(&fromTimestamp, &data, &dataSize, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
itBegin = telecommandMap.begin();
|
||||||
|
while (itBegin->first < fromTimestamp && itBegin != telecommandMap.end()) {
|
||||||
|
itBegin++;
|
||||||
|
}
|
||||||
|
|
||||||
|
itEnd = telecommandMap.end();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TypeOfTimeWindow::TO_TIMETAG: {
|
||||||
|
uint32_t toTimestamp;
|
||||||
|
result = SerializeAdapter::deSerialize(&toTimestamp, &data, &dataSize, DEF_END);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
itBegin = telecommandMap.begin();
|
||||||
|
itEnd = telecommandMap.begin();
|
||||||
|
while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) {
|
||||||
|
itEnd++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TypeOfTimeWindow::FROM_TIMETAG_TO_TIMETAG: {
|
||||||
|
uint32_t fromTimestamp;
|
||||||
|
uint32_t toTimestamp;
|
||||||
|
|
||||||
|
result = SerializeAdapter::deSerialize(&fromTimestamp, &data, &dataSize,
|
||||||
|
SerializeIF::Endianness::BIG);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::deSerialize(&toTimestamp, &data, &dataSize,
|
||||||
|
SerializeIF::Endianness::BIG);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
itBegin = telecommandMap.begin();
|
||||||
|
itEnd = telecommandMap.begin();
|
||||||
|
|
||||||
|
while (itBegin->first < fromTimestamp && itBegin != telecommandMap.end()) {
|
||||||
|
itBegin++;
|
||||||
|
}
|
||||||
|
while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) {
|
||||||
|
itEnd++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// additional security check, this should never be true
|
||||||
|
if (itBegin->first > itEnd->first) {
|
||||||
|
sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n");
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the map range should now be set according to the sent filter.
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleInvalidData(
|
||||||
|
const char *ctx) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "Service11TelecommandScheduling:: " << ctx << ": Invalid buffer" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("Service11TelecommandScheduling::%s: Invalid buffer\n", ctx);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t MAX_NUM_TCS>
|
||||||
|
inline void Service11TelecommandScheduling<MAX_NUM_TCS>::debugPrintMultimapContent(void) const {
|
||||||
|
#if FSFW_DISABLE_PRINTOUT == 0
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content"
|
||||||
|
<< std::endl;
|
||||||
|
sif::debug << "[" << dit->first << "]: Request ID: " << dit->second.requestId << " | "
|
||||||
|
<< "Store Address: " << dit->second.storeAddr << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content\n");
|
||||||
|
for (auto dit = telecommandMap.begin(); dit != telecommandMap.end(); ++dit) {
|
||||||
|
sif::printDebug("[%d]: Request ID: %d | Store Address: %d\n", dit->first,
|
||||||
|
dit->second.requestId, dit->second.storeAddr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
@ -72,6 +72,7 @@ enum : uint8_t {
|
|||||||
DLE_ENCODER, // DLEE
|
DLE_ENCODER, // DLEE
|
||||||
PUS_SERVICE_3, // PUS3
|
PUS_SERVICE_3, // PUS3
|
||||||
PUS_SERVICE_9, // PUS9
|
PUS_SERVICE_9, // PUS9
|
||||||
|
PUS_SERVICE_11, // PUS11
|
||||||
FILE_SYSTEM, // FILS
|
FILE_SYSTEM, // FILS
|
||||||
LINUX_OSAL, // UXOS
|
LINUX_OSAL, // UXOS
|
||||||
HAL_SPI, // HSPI
|
HAL_SPI, // HSPI
|
||||||
|
Loading…
Reference in New Issue
Block a user