Update FSFW from Upstream #27
@ -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
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#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) {
|
||||||
@ -84,7 +84,6 @@ 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,9 +1,9 @@
|
|||||||
#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, Iterator *storedValue) {
|
inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::insert(key_t key, T value,
|
||||||
|
Iterator *storedValue) {
|
||||||
if (_size == theMap.maxSize()) {
|
if (_size == theMap.maxSize()) {
|
||||||
return MAP_FULL;
|
return MAP_FULL;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,8 @@ inline ReturnValue_t FixedOrderedMultimap<key_t, T, KEY_COMPARE>::find(key_t key
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -105,5 +106,4 @@ inline void FixedOrderedMultimap<key_t, T, KEY_COMPARE>::removeFromPosition(size
|
|||||||
--_size;
|
--_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ */
|
#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ */
|
||||||
|
@ -6,26 +6,24 @@
|
|||||||
#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>
|
template <typename T>
|
||||||
inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId,
|
inline LocalPoolVariable<T>::LocalPoolVariable(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>
|
template <typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::read(
|
inline ReturnValue_t LocalPoolVariable<T>::read(MutexIF::TimeoutType timeoutType,
|
||||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
uint32_t timeoutMs) {
|
||||||
if (hkManager == nullptr) {
|
if (hkManager == nullptr) {
|
||||||
return readWithoutLock();
|
return readWithoutLock();
|
||||||
}
|
}
|
||||||
@ -43,19 +41,17 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,15 +61,15 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
@ -91,19 +87,17 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,11 +107,10 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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>
|
||||||
@ -126,15 +119,14 @@ inline size_t LocalPoolVariable<T>::getSerializedSize() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -146,8 +138,7 @@ inline LocalPoolVariable<T>::operator T() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -160,8 +151,7 @@ inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator =(
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,10 +160,8 @@ 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 !=(
|
inline bool LocalPoolVariable<T>::operator!=(const LocalPoolVariable<T>& other) const {
|
||||||
const LocalPoolVariable<T> &other) const {
|
|
||||||
return not(*this == other);
|
return not(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,10 +170,8 @@ 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 <(
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,10 +180,8 @@ 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 >(
|
inline bool LocalPoolVariable<T>::operator>(const LocalPoolVariable<T>& other) const {
|
||||||
const LocalPoolVariable<T> &other) const {
|
|
||||||
return not(*this < other);
|
return not(*this < other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,25 +6,26 @@
|
|||||||
#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();
|
||||||
}
|
}
|
||||||
@ -32,21 +33,19 @@ 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());
|
||||||
@ -56,14 +55,15 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
|||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
@ -72,18 +72,16 @@ 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());
|
||||||
@ -100,9 +98,11 @@ inline T& LocalPoolVector<T, vectorSize>::operator [](size_t i) {
|
|||||||
// 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];
|
||||||
@ -117,22 +117,23 @@ inline const T& LocalPoolVector<T, vectorSize>::operator [](size_t i) const {
|
|||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -147,12 +148,10 @@ inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -162,8 +161,7 @@ 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];
|
||||||
|
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