Update from upstream #85
@ -1,9 +1,9 @@
|
||||
#include "MgmLIS3MDLHandler.h"
|
||||
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
|
||||
MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCommunication,
|
||||
CookieIF *comCookie, uint32_t transitionDelay)
|
||||
: DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
||||
|
@ -24,9 +24,7 @@ void UartCookie::setParityEven() { parity = Parity::EVEN; }
|
||||
|
||||
Parity UartCookie::getParity() const { return parity; }
|
||||
|
||||
void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) {
|
||||
bitsPerWord = bitsPerWord_;
|
||||
}
|
||||
void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; }
|
||||
|
||||
BitsPerWord UartCookie::getBitsPerWord() const { return bitsPerWord; }
|
||||
|
||||
|
@ -3,6 +3,6 @@ if [[ ! -f README.md ]]; then
|
||||
cd ..
|
||||
fi
|
||||
|
||||
find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
||||
find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
||||
find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
||||
find ./src -iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp | xargs clang-format --style=file -i
|
||||
find ./hal -iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp | xargs clang-format --style=file -i
|
||||
find ./tests -iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp | xargs clang-format --style=file -i
|
||||
|
@ -5,11 +5,11 @@
|
||||
#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 FIFOBase<T>::FIFOBase(T* values, const size_t maxCapacity)
|
||||
: maxCapacity(maxCapacity), values(values){};
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline ReturnValue_t FIFOBase<T>::insert(T value) {
|
||||
if (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) {
|
||||
if (empty()) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
if (value == nullptr){
|
||||
if (value == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*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) {
|
||||
if(empty()) {
|
||||
if (empty()) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
if (value == nullptr){
|
||||
if (value == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*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() {
|
||||
T value;
|
||||
return this->retrieve(&value);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline bool FIFOBase<T>::empty() {
|
||||
return (currentSize == 0);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline bool FIFOBase<T>::full() {
|
||||
return (currentSize == maxCapacity);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline size_t FIFOBase<T>::size() {
|
||||
return currentSize;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline size_t FIFOBase<T>::next(size_t current) {
|
||||
++current;
|
||||
if (current == maxCapacity) {
|
||||
@ -79,14 +79,13 @@ inline size_t FIFOBase<T>::next(size_t current) {
|
||||
return current;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline size_t FIFOBase<T>::getMaxCapacity() const {
|
||||
return maxCapacity;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline void FIFOBase<T>::setContainer(T *data) {
|
||||
template <typename T>
|
||||
inline void FIFOBase<T>::setContainer(T* data) {
|
||||
this->values = data;
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
#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) {
|
||||
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>));
|
||||
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;
|
||||
@ -18,12 +18,12 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t k
|
||||
}
|
||||
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) {
|
||||
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 {
|
||||
ReturnValue_t result = KEY_DOES_NOT_EXIST;
|
||||
if (findFirstIndex(key) < _size) {
|
||||
@ -32,7 +32,7 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::exists(key_t k
|
||||
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) {
|
||||
size_t i;
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
size_t i;
|
||||
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;
|
||||
}
|
||||
|
||||
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 {
|
||||
ReturnValue_t result = exists(key);
|
||||
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;
|
||||
}
|
||||
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
@ -84,7 +85,7 @@ inline size_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::findFirstIndex(key_t
|
||||
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 {
|
||||
size_t i = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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>));
|
||||
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_ */
|
||||
|
@ -5,33 +5,31 @@
|
||||
#error Include LocalPoolVariable.h before LocalPoolVariable.tpp!
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
inline LocalPoolVariable<T>::LocalPoolVariable(HasLocalDataPoolIF* hkOwner,
|
||||
lp_id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||
template <typename T>
|
||||
inline LocalPoolVariable<T>::LocalPoolVariable(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
|
||||
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
|
||||
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||
|
||||
template<typename T>
|
||||
inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner,
|
||||
lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||
template <typename T>
|
||||
inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner, lp_id_t poolId,
|
||||
DataSetIF* dataSet, pool_rwm_t 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>
|
||||
inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId,
|
||||
DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
|
||||
dataSet, setReadWriteMode){}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::read(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
if(hkManager == nullptr) {
|
||||
template <typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::read(MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
if (hkManager == nullptr) {
|
||||
return readWithoutLock();
|
||||
}
|
||||
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
|
||||
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = readWithoutLock();
|
||||
@ -39,23 +37,21 @@ inline ReturnValue_t LocalPoolVariable<T>::read(
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
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();
|
||||
reportReadCommitError("LocalPoolVector",
|
||||
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
|
||||
localPoolId);
|
||||
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true,
|
||||
targetObjectId, localPoolId);
|
||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||
}
|
||||
|
||||
PoolEntry<T>* poolEntry = nullptr;
|
||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
||||
&poolEntry);
|
||||
if(result != RETURN_OK) {
|
||||
ReturnValue_t result =
|
||||
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||
if (result != RETURN_OK) {
|
||||
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
|
||||
reportReadCommitError("LocalPoolVariable", result,
|
||||
false, ownerObjectId, localPoolId);
|
||||
reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -64,22 +60,22 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid,
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
template <typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid, MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
this->setValid(setValid);
|
||||
return commit(timeoutType, timeoutMs);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::commit(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
if(hkManager == nullptr) {
|
||||
template <typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::commit(MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
if (hkManager == nullptr) {
|
||||
return commitWithoutLock();
|
||||
}
|
||||
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
|
||||
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = commitWithoutLock();
|
||||
@ -87,23 +83,21 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
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();
|
||||
reportReadCommitError("LocalPoolVector",
|
||||
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
|
||||
localPoolId);
|
||||
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false,
|
||||
targetObjectId, localPoolId);
|
||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||
}
|
||||
|
||||
PoolEntry<T>* poolEntry = nullptr;
|
||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
||||
&poolEntry);
|
||||
if(result != RETURN_OK) {
|
||||
ReturnValue_t result =
|
||||
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||
if (result != RETURN_OK) {
|
||||
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
|
||||
reportReadCommitError("LocalPoolVariable", result,
|
||||
false, ownerObjectId, localPoolId);
|
||||
reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -112,98 +106,88 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::serialize(uint8_t** buffer,
|
||||
size_t* size, const size_t max_size,
|
||||
template <typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::serialize(
|
||||
uint8_t** buffer, size_t* size, const size_t max_size,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
return SerializeAdapter::serialize(&value,
|
||||
buffer, size ,max_size, streamEndianness);
|
||||
return SerializeAdapter::serialize(&value, buffer, size, max_size, streamEndianness);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline size_t LocalPoolVariable<T>::getSerializedSize() const {
|
||||
return SerializeAdapter::getSerializedSize(&value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer,
|
||||
size_t* size, SerializeIF::Endianness streamEndianness) {
|
||||
template <typename T>
|
||||
inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer, size_t* size,
|
||||
SerializeIF::Endianness streamEndianness) {
|
||||
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
template<typename T>
|
||||
inline std::ostream& operator<< (std::ostream &out,
|
||||
const LocalPoolVariable<T> &var) {
|
||||
template <typename T>
|
||||
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVariable<T>& var) {
|
||||
out << var.value;
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline LocalPoolVariable<T>::operator T() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline LocalPoolVariable<T> & LocalPoolVariable<T>::operator=(
|
||||
const T& newValue) {
|
||||
template <typename T>
|
||||
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator=(const T& newValue) {
|
||||
value = newValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator =(
|
||||
template <typename T>
|
||||
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator=(
|
||||
const LocalPoolVariable<T>& newPoolVariable) {
|
||||
value = newPoolVariable.value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool LocalPoolVariable<T>::operator ==(
|
||||
const LocalPoolVariable<T> &other) const {
|
||||
template <typename T>
|
||||
inline bool LocalPoolVariable<T>::operator==(const LocalPoolVariable<T>& other) const {
|
||||
return this->value == other.value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool LocalPoolVariable<T>::operator ==(const T &other) const {
|
||||
template <typename T>
|
||||
inline bool LocalPoolVariable<T>::operator==(const T& other) const {
|
||||
return this->value == other;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline bool LocalPoolVariable<T>::operator !=(
|
||||
const LocalPoolVariable<T> &other) const {
|
||||
return not (*this == other);
|
||||
template <typename T>
|
||||
inline bool LocalPoolVariable<T>::operator!=(const LocalPoolVariable<T>& other) const {
|
||||
return not(*this == other);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool LocalPoolVariable<T>::operator !=(const T &other) const {
|
||||
return not (*this == other);
|
||||
template <typename T>
|
||||
inline bool LocalPoolVariable<T>::operator!=(const T& other) const {
|
||||
return not(*this == other);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline bool LocalPoolVariable<T>::operator <(
|
||||
const LocalPoolVariable<T> &other) const {
|
||||
template <typename T>
|
||||
inline bool LocalPoolVariable<T>::operator<(const LocalPoolVariable<T>& other) const {
|
||||
return this->value < other.value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool LocalPoolVariable<T>::operator <(const T &other) const {
|
||||
template <typename T>
|
||||
inline bool LocalPoolVariable<T>::operator<(const T& other) const {
|
||||
return this->value < other;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline bool LocalPoolVariable<T>::operator >(
|
||||
const LocalPoolVariable<T> &other) const {
|
||||
return not (*this < other);
|
||||
template <typename T>
|
||||
inline bool LocalPoolVariable<T>::operator>(const LocalPoolVariable<T>& other) const {
|
||||
return not(*this < other);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool LocalPoolVariable<T>::operator >(const T &other) const {
|
||||
return not (*this < other);
|
||||
template <typename T>
|
||||
inline bool LocalPoolVariable<T>::operator>(const T& other) const {
|
||||
return not(*this < other);
|
||||
}
|
||||
|
||||
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */
|
||||
|
@ -5,48 +5,47 @@
|
||||
#error Include LocalPoolVector.h before LocalPoolVector.tpp!
|
||||
#endif
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(
|
||||
HasLocalDataPoolIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
|
||||
DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode)
|
||||
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner,
|
||||
lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner, lp_id_t poolId,
|
||||
DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode)
|
||||
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
|
||||
DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
|
||||
dataSet, setReadWriteMode) {}
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode)
|
||||
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet,
|
||||
setReadWriteMode) {}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
return readWithoutLock();
|
||||
}
|
||||
template<typename T, uint16_t vectorSize>
|
||||
template <typename T, uint16_t vectorSize>
|
||||
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();
|
||||
reportReadCommitError("LocalPoolVector",
|
||||
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
|
||||
localPoolId);
|
||||
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true,
|
||||
targetObjectId, localPoolId);
|
||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||
}
|
||||
|
||||
PoolEntry<T>* poolEntry = nullptr;
|
||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
||||
&poolEntry);
|
||||
ReturnValue_t result =
|
||||
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||
memset(this->value, 0, vectorSize * sizeof(T));
|
||||
|
||||
if(result != RETURN_OK) {
|
||||
if (result != RETURN_OK) {
|
||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||
reportReadCommitError("LocalPoolVector", result, true, targetObjectId,
|
||||
localPoolId);
|
||||
reportReadCommitError("LocalPoolVector", result, true, targetObjectId, localPoolId);
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
|
||||
@ -54,36 +53,35 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
this->setValid(valid);
|
||||
return commit(timeoutType, timeoutMs);
|
||||
}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
return commitWithoutLock();
|
||||
}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
template <typename T, uint16_t vectorSize>
|
||||
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();
|
||||
reportReadCommitError("LocalPoolVector",
|
||||
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
|
||||
localPoolId);
|
||||
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false,
|
||||
targetObjectId, localPoolId);
|
||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||
}
|
||||
PoolEntry<T>* poolEntry = nullptr;
|
||||
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
||||
&poolEntry);
|
||||
if(result != RETURN_OK) {
|
||||
ReturnValue_t result =
|
||||
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||
if (result != RETURN_OK) {
|
||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||
reportReadCommitError("LocalPoolVector", result, false, targetObjectId,
|
||||
localPoolId);
|
||||
reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId);
|
||||
return result;
|
||||
}
|
||||
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
|
||||
@ -91,48 +89,51 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline T& LocalPoolVector<T, vectorSize>::operator [](size_t i) {
|
||||
if(i < vectorSize) {
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline T& LocalPoolVector<T, vectorSize>::operator[](size_t i) {
|
||||
if (i < vectorSize) {
|
||||
return value[i];
|
||||
}
|
||||
// If this happens, I have to set some value. I consider this
|
||||
// a configuration error, but I wont exit here.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
||||
" last value!" << std::endl;
|
||||
" last value!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalPoolVector: Invalid index. Setting or returning"
|
||||
sif::printWarning(
|
||||
"LocalPoolVector: Invalid index. Setting or returning"
|
||||
" last value!\n");
|
||||
#endif
|
||||
return value[vectorSize - 1];
|
||||
}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline const T& LocalPoolVector<T, vectorSize>::operator [](size_t i) const {
|
||||
if(i < vectorSize) {
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline const T& LocalPoolVector<T, vectorSize>::operator[](size_t i) const {
|
||||
if (i < vectorSize) {
|
||||
return value[i];
|
||||
}
|
||||
// If this happens, I have to set some value. I consider this
|
||||
// a configuration error, but I wont exit here.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
||||
" last value!" << std::endl;
|
||||
" last value!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalPoolVector: Invalid index. Setting or returning"
|
||||
sif::printWarning(
|
||||
"LocalPoolVector: Invalid index. Setting or returning"
|
||||
" last value!\n");
|
||||
#endif
|
||||
return value[vectorSize - 1];
|
||||
}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
|
||||
size_t* size, size_t maxSize,
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(
|
||||
uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
for (uint16_t i = 0; i < vectorSize; i++) {
|
||||
result = SerializeAdapter::serialize(&(value[i]), buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
break;
|
||||
}
|
||||
@ -140,19 +141,17 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
|
||||
return vectorSize * SerializeAdapter::getSerializedSize(value);
|
||||
}
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
|
||||
const uint8_t** buffer, size_t* size,
|
||||
SerializeIF::Endianness streamEndianness) {
|
||||
const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
for (uint16_t i = 0; i < vectorSize; i++) {
|
||||
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size,
|
||||
streamEndianness);
|
||||
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
break;
|
||||
}
|
||||
@ -161,13 +160,12 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline std::ostream& operator<< (std::ostream &out,
|
||||
const LocalPoolVector<T, vectorSize> &var) {
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVector<T, vectorSize>& var) {
|
||||
out << "Vector: [";
|
||||
for(int i = 0;i < vectorSize; i++) {
|
||||
for (int i = 0; i < vectorSize; i++) {
|
||||
out << var.value[i];
|
||||
if(i < vectorSize - 1) {
|
||||
if (i < vectorSize - 1) {
|
||||
out << ", ";
|
||||
}
|
||||
}
|
||||
|
@ -59,14 +59,13 @@ class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF {
|
||||
*/
|
||||
ReturnValue_t addComponent(object_id_t object) override;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Adds an object to the list of objects to be executed.
|
||||
* The objects are executed in the order added.
|
||||
* @param object pointer to the object to add.
|
||||
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
|
||||
*/
|
||||
ReturnValue_t addComponent(ExecutableObjectIF* object) override;
|
||||
|
||||
ReturnValue_t addComponent(ExecutableObjectIF *object) override;
|
||||
|
||||
uint32_t getPeriodMs() const override;
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include "version.h"
|
||||
#include "fsfw/FSFWVersion.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "fsfw/FSFWVersion.h"
|
||||
|
||||
#ifdef major
|
||||
#undef major
|
||||
#endif
|
||||
|
@ -29,7 +29,7 @@ class Version {
|
||||
}
|
||||
|
||||
friend bool operator>(const Version& v1, const Version& v2) {
|
||||
return not (v1 < v2) and not (v1 == v2);
|
||||
return not(v1 < v2) and not(v1 == v2);
|
||||
}
|
||||
|
||||
friend bool operator<=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 < v2)); }
|
||||
|
@ -17,15 +17,15 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") {
|
||||
fsfw::Version v1 = fsfw::Version(1, 1, 1);
|
||||
fsfw::Version v2 = fsfw::Version(1, 1, 1);
|
||||
REQUIRE(v1 == v2);
|
||||
REQUIRE(not (v1 < v2));
|
||||
REQUIRE(not (v1 > v2));
|
||||
REQUIRE(not(v1 < v2));
|
||||
REQUIRE(not(v1 > v2));
|
||||
REQUIRE(v1 <= v2);
|
||||
REQUIRE(v1 >= v2);
|
||||
v1.revision -= 1;
|
||||
REQUIRE(v1 != v2);
|
||||
REQUIRE(not (v1 == v2));
|
||||
REQUIRE(not (v1 > v2));
|
||||
REQUIRE(not (v1 >= v2));
|
||||
REQUIRE(not(v1 == v2));
|
||||
REQUIRE(not(v1 > v2));
|
||||
REQUIRE(not(v1 >= v2));
|
||||
REQUIRE(v1 < v2);
|
||||
REQUIRE(v1 <= v2);
|
||||
v1.revision += 1;
|
||||
@ -33,60 +33,60 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") {
|
||||
REQUIRE(v1 != v2);
|
||||
REQUIRE(v1 < v2);
|
||||
REQUIRE(v1 <= v2);
|
||||
REQUIRE(not (v1 == v2));
|
||||
REQUIRE(not (v1 > v2));
|
||||
REQUIRE(not (v1 >= v2));
|
||||
REQUIRE(not(v1 == v2));
|
||||
REQUIRE(not(v1 > v2));
|
||||
REQUIRE(not(v1 >= v2));
|
||||
v1.minor += 1;
|
||||
v1.major -= 1;
|
||||
REQUIRE(v1 != v2);
|
||||
REQUIRE(v1 < v2);
|
||||
REQUIRE(v1 <= v2);
|
||||
REQUIRE(not (v1 == v2));
|
||||
REQUIRE(not (v1 > v2));
|
||||
REQUIRE(not (v1 >= v2));
|
||||
REQUIRE(not(v1 == v2));
|
||||
REQUIRE(not(v1 > v2));
|
||||
REQUIRE(not(v1 >= v2));
|
||||
v1.major += 1;
|
||||
REQUIRE(v1 == v2);
|
||||
REQUIRE(v1 <= v2);
|
||||
REQUIRE(v1 >= v2);
|
||||
REQUIRE(not (v1 != v2));
|
||||
REQUIRE(not (v1 > v2));
|
||||
REQUIRE(not (v1 < v2));
|
||||
REQUIRE(not(v1 != v2));
|
||||
REQUIRE(not(v1 > v2));
|
||||
REQUIRE(not(v1 < v2));
|
||||
v1.major += 1;
|
||||
v1.minor -= 1;
|
||||
REQUIRE(v1 != v2);
|
||||
REQUIRE(v1 > v2);
|
||||
REQUIRE(v1 >= v2);
|
||||
REQUIRE(not (v1 == v2));
|
||||
REQUIRE(not (v1 < v2));
|
||||
REQUIRE(not (v1 <= v2));
|
||||
REQUIRE(not(v1 == v2));
|
||||
REQUIRE(not(v1 < v2));
|
||||
REQUIRE(not(v1 <= v2));
|
||||
v1.major -= 1;
|
||||
v1.minor += 2;
|
||||
v1.revision -= 1;
|
||||
REQUIRE(v1 != v2);
|
||||
REQUIRE(v1 > v2);
|
||||
REQUIRE(v1 >= v2);
|
||||
REQUIRE(not (v1 == v2));
|
||||
REQUIRE(not (v1 < v2));
|
||||
REQUIRE(not (v1 <= v2));
|
||||
REQUIRE(not(v1 == v2));
|
||||
REQUIRE(not(v1 < v2));
|
||||
REQUIRE(not(v1 <= v2));
|
||||
v1.minor -= 1;
|
||||
v1.revision += 2;
|
||||
REQUIRE(v1 != v2);
|
||||
REQUIRE(v1 > v2);
|
||||
REQUIRE(v1 >= v2);
|
||||
REQUIRE(not (v1 == v2));
|
||||
REQUIRE(not (v1 < v2));
|
||||
REQUIRE(not (v1 <= v2));
|
||||
REQUIRE(not(v1 == v2));
|
||||
REQUIRE(not(v1 < v2));
|
||||
REQUIRE(not(v1 <= v2));
|
||||
v1.revision -= 1;
|
||||
REQUIRE(v1 == v2);
|
||||
REQUIRE(v1 <= v2);
|
||||
REQUIRE(v1 >= v2);
|
||||
REQUIRE(not (v1 != v2));
|
||||
REQUIRE(not(v1 != v2));
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "v" << fsfw::FSFW_VERSION << std::endl;
|
||||
#endif
|
||||
char verString[10] = {};
|
||||
fsfw::FSFW_VERSION.getVersion(verString, sizeof(verString));
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
printf("v%s\n",verString);
|
||||
printf("v%s\n", verString);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user