Merge branch 'development' into mueller/thermal-update
This commit is contained in:
commit
65f411ace2
@ -1,16 +1,16 @@
|
|||||||
#include "../subsystem/SubsystemBase.h"
|
|
||||||
#include "ControllerBase.h"
|
#include "ControllerBase.h"
|
||||||
|
|
||||||
#include "../subsystem/SubsystemBase.h"
|
#include "../subsystem/SubsystemBase.h"
|
||||||
#include "../ipc/QueueFactory.h"
|
#include "../ipc/QueueFactory.h"
|
||||||
#include "../action/HasActionsIF.h"
|
#include "../action/HasActionsIF.h"
|
||||||
|
|
||||||
ControllerBase::ControllerBase(uint32_t setObjectId, uint32_t parentId,
|
ControllerBase::ControllerBase(object_id_t setObjectId, object_id_t parentId,
|
||||||
size_t commandQueueDepth) :
|
size_t commandQueueDepth) :
|
||||||
SystemObject(setObjectId), parentId(parentId), mode(MODE_OFF), submode(
|
SystemObject(setObjectId), parentId(parentId), mode(MODE_OFF),
|
||||||
SUBMODE_NONE), commandQueue(NULL), modeHelper(
|
submode(SUBMODE_NONE), modeHelper(this),
|
||||||
this), healthHelper(this, setObjectId),hkSwitcher(this),executingTask(NULL) {
|
healthHelper(this, setObjectId) {
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth);
|
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||||
|
commandQueueDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerBase::~ControllerBase() {
|
ControllerBase::~ControllerBase() {
|
||||||
@ -24,9 +24,9 @@ ReturnValue_t ControllerBase::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueId_t parentQueue = 0;
|
MessageQueueId_t parentQueue = 0;
|
||||||
if (parentId != 0) {
|
if (parentId != objects::NO_OBJECT) {
|
||||||
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
||||||
if (parent == NULL) {
|
if (parent == nullptr) {
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
parentQueue = parent->getCommandQueue();
|
parentQueue = parent->getCommandQueue();
|
||||||
@ -44,10 +44,6 @@ ReturnValue_t ControllerBase::initialize() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = hkSwitcher.initialize();
|
|
||||||
if (result != RETURN_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,26 +52,27 @@ MessageQueueId_t ControllerBase::getCommandQueue() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllerBase::handleQueue() {
|
void ControllerBase::handleQueue() {
|
||||||
CommandMessage message;
|
CommandMessage command;
|
||||||
ReturnValue_t result;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
for (result = commandQueue->receiveMessage(&message); result == RETURN_OK;
|
for (result = commandQueue->receiveMessage(&command);
|
||||||
result = commandQueue->receiveMessage(&message)) {
|
result == RETURN_OK;
|
||||||
|
result = commandQueue->receiveMessage(&command)) {
|
||||||
|
|
||||||
result = modeHelper.handleModeCommand(&message);
|
result = modeHelper.handleModeCommand(&command);
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = healthHelper.handleHealthCommand(&message);
|
result = healthHelper.handleHealthCommand(&command);
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result = handleCommandMessage(&message);
|
result = handleCommandMessage(&command);
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
message.setToUnknownCommand();
|
command.setToUnknownCommand();
|
||||||
commandQueue->reply(&message);
|
commandQueue->reply(&command);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -106,7 +103,6 @@ void ControllerBase::announceMode(bool recursive) {
|
|||||||
|
|
||||||
ReturnValue_t ControllerBase::performOperation(uint8_t opCode) {
|
ReturnValue_t ControllerBase::performOperation(uint8_t opCode) {
|
||||||
handleQueue();
|
handleQueue();
|
||||||
hkSwitcher.performOperation();
|
|
||||||
performControlOperation();
|
performControlOperation();
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
@ -135,3 +131,7 @@ void ControllerBase::setTaskIF(PeriodicTaskIF* task_){
|
|||||||
|
|
||||||
void ControllerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) {
|
void ControllerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t ControllerBase::initializeAfterTaskCreation() {
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef CONTROLLERBASE_H_
|
#ifndef FSFW_CONTROLLER_CONTROLLERBASE_H_
|
||||||
#define CONTROLLERBASE_H_
|
#define FSFW_CONTROLLER_CONTROLLERBASE_H_
|
||||||
|
|
||||||
#include "../health/HasHealthIF.h"
|
#include "../health/HasHealthIF.h"
|
||||||
#include "../health/HealthHelper.h"
|
#include "../health/HealthHelper.h"
|
||||||
@ -7,73 +7,88 @@
|
|||||||
#include "../modes/ModeHelper.h"
|
#include "../modes/ModeHelper.h"
|
||||||
#include "../objectmanager/SystemObject.h"
|
#include "../objectmanager/SystemObject.h"
|
||||||
#include "../tasks/ExecutableObjectIF.h"
|
#include "../tasks/ExecutableObjectIF.h"
|
||||||
|
#include "../tasks/PeriodicTaskIF.h"
|
||||||
#include "../datapool/HkSwitchHelper.h"
|
#include "../datapool/HkSwitchHelper.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Generic base class for controller classes
|
||||||
|
* @details
|
||||||
|
* Implements common interfaces for controllers, which generally have
|
||||||
|
* a mode and a health state. This avoids boilerplate code.
|
||||||
|
*/
|
||||||
class ControllerBase: public HasModesIF,
|
class ControllerBase: public HasModesIF,
|
||||||
public HasHealthIF,
|
public HasHealthIF,
|
||||||
public ExecutableObjectIF,
|
public ExecutableObjectIF,
|
||||||
public SystemObject,
|
public SystemObject,
|
||||||
public HasReturnvaluesIF {
|
public HasReturnvaluesIF {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const Mode_t MODE_NORMAL = 2;
|
static const Mode_t MODE_NORMAL = 2;
|
||||||
|
|
||||||
ControllerBase(uint32_t setObjectId, uint32_t parentId,
|
ControllerBase(object_id_t setObjectId, object_id_t parentId,
|
||||||
size_t commandQueueDepth = 3);
|
size_t commandQueueDepth = 3);
|
||||||
virtual ~ControllerBase();
|
virtual ~ControllerBase();
|
||||||
|
|
||||||
ReturnValue_t initialize();
|
/** SystemObject override */
|
||||||
|
virtual ReturnValue_t initialize() override;
|
||||||
|
|
||||||
virtual MessageQueueId_t getCommandQueue() const;
|
virtual MessageQueueId_t getCommandQueue() const override;
|
||||||
|
|
||||||
virtual ReturnValue_t performOperation(uint8_t opCode);
|
/** HasHealthIF overrides */
|
||||||
|
virtual ReturnValue_t setHealth(HealthState health) override;
|
||||||
virtual ReturnValue_t setHealth(HealthState health);
|
virtual HasHealthIF::HealthState getHealth() override;
|
||||||
|
|
||||||
virtual HasHealthIF::HealthState getHealth();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of ExecutableObjectIF function
|
|
||||||
*
|
|
||||||
* Used to setup the reference of the task, that executes this component
|
|
||||||
* @param task_ Pointer to the taskIF of this task
|
|
||||||
*/
|
|
||||||
virtual void setTaskIF(PeriodicTaskIF* task_);
|
|
||||||
|
|
||||||
|
/** ExecutableObjectIF overrides */
|
||||||
|
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||||
|
virtual void setTaskIF(PeriodicTaskIF* task) override;
|
||||||
|
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const uint32_t parentId;
|
|
||||||
|
/**
|
||||||
|
* Implemented by child class. Handle command messages which are not
|
||||||
|
* mode or health messages.
|
||||||
|
* @param message
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t handleCommandMessage(CommandMessage *message) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Periodic helper, implemented by child class.
|
||||||
|
*/
|
||||||
|
virtual void performControlOperation() = 0;
|
||||||
|
|
||||||
|
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||||
|
uint32_t *msToReachTheMode) = 0;
|
||||||
|
|
||||||
|
const object_id_t parentId;
|
||||||
|
|
||||||
Mode_t mode;
|
Mode_t mode;
|
||||||
|
|
||||||
Submode_t submode;
|
Submode_t submode;
|
||||||
|
|
||||||
MessageQueueIF* commandQueue;
|
MessageQueueIF* commandQueue = nullptr;
|
||||||
|
|
||||||
ModeHelper modeHelper;
|
ModeHelper modeHelper;
|
||||||
|
|
||||||
HealthHelper healthHelper;
|
HealthHelper healthHelper;
|
||||||
|
|
||||||
HkSwitchHelper hkSwitcher;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pointer to the task which executes this component, is invalid before setTaskIF was called.
|
* Pointer to the task which executes this component,
|
||||||
|
* is invalid before setTaskIF was called.
|
||||||
*/
|
*/
|
||||||
PeriodicTaskIF* executingTask;
|
PeriodicTaskIF* executingTask = nullptr;
|
||||||
|
|
||||||
void handleQueue();
|
/** Handle mode and health messages */
|
||||||
|
virtual void handleQueue();
|
||||||
|
|
||||||
virtual ReturnValue_t handleCommandMessage(CommandMessage *message) = 0;
|
/** Mode helpers */
|
||||||
virtual void performControlOperation() = 0;
|
|
||||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
|
||||||
uint32_t *msToReachTheMode) = 0;
|
|
||||||
virtual void modeChanged(Mode_t mode, Submode_t submode);
|
virtual void modeChanged(Mode_t mode, Submode_t submode);
|
||||||
virtual void startTransition(Mode_t mode, Submode_t submode);
|
virtual void startTransition(Mode_t mode, Submode_t submode);
|
||||||
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
||||||
virtual void setToExternalControl();
|
virtual void setToExternalControl();
|
||||||
virtual void announceMode(bool recursive);
|
virtual void announceMode(bool recursive);
|
||||||
|
/** HK helpers */
|
||||||
virtual void changeHK(Mode_t mode, Submode_t submode, bool enable);
|
virtual void changeHK(Mode_t mode, Submode_t submode, bool enable);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CONTROLLERBASE_H_ */
|
#endif /* FSFW_CONTROLLER_CONTROLLERBASE_H_ */
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
/**
|
|
||||||
* @file MapPacketExtraction.cpp
|
|
||||||
* @brief This file defines the MapPacketExtraction class.
|
|
||||||
* @date 26.03.2013
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "MapPacketExtraction.h"
|
#include "MapPacketExtraction.h"
|
||||||
#include "../ipc/QueueFactory.h"
|
#include "../ipc/QueueFactory.h"
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||||
@ -12,14 +5,14 @@
|
|||||||
#include "../tmtcpacket/SpacePacketBase.h"
|
#include "../tmtcpacket/SpacePacketBase.h"
|
||||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||||
#include "../tmtcservices/TmTcMessage.h"
|
#include "../tmtcservices/TmTcMessage.h"
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
MapPacketExtraction::MapPacketExtraction(uint8_t setMapId,
|
MapPacketExtraction::MapPacketExtraction(uint8_t setMapId,
|
||||||
object_id_t setPacketDestination) :
|
object_id_t setPacketDestination) :
|
||||||
lastSegmentationFlag(NO_SEGMENTATION), mapId(setMapId), packetLength(0), bufferPosition(
|
lastSegmentationFlag(NO_SEGMENTATION), mapId(setMapId),
|
||||||
packetBuffer), packetDestination(setPacketDestination), packetStore(
|
bufferPosition(packetBuffer), packetDestination(setPacketDestination),
|
||||||
NULL), tcQueueId(MessageQueueIF::NO_QUEUE) {
|
tcQueueId(MessageQueueIF::NO_QUEUE) {
|
||||||
memset(packetBuffer, 0, sizeof(packetBuffer));
|
std::memset(packetBuffer, 0, sizeof(packetBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
|
ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
/**
|
#ifndef FSFW_DATALINKLAYER_MAPPACKETEXTRACTION_H_
|
||||||
* @file MapPacketExtraction.h
|
#define FSFW_DATALINKLAYER_MAPPACKETEXTRACTION_H_
|
||||||
* @brief This file defines the MapPacketExtraction class.
|
|
||||||
* @date 26.03.2013
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MAPPACKETEXTRACTION_H_
|
|
||||||
#define MAPPACKETEXTRACTION_H_
|
|
||||||
|
|
||||||
#include "MapPacketExtractionIF.h"
|
#include "MapPacketExtractionIF.h"
|
||||||
#include "../objectmanager/ObjectManagerIF.h"
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
@ -20,17 +13,19 @@ class StorageManagerIF;
|
|||||||
* The class implements the full MAP Packet Extraction functionality as described in the CCSDS
|
* The class implements the full MAP Packet Extraction functionality as described in the CCSDS
|
||||||
* TC Space Data Link Protocol. It internally stores incomplete segmented packets until they are
|
* TC Space Data Link Protocol. It internally stores incomplete segmented packets until they are
|
||||||
* fully received. All found packets are forwarded to a single distribution entity.
|
* fully received. All found packets are forwarded to a single distribution entity.
|
||||||
|
* @author B. Baetz
|
||||||
*/
|
*/
|
||||||
class MapPacketExtraction: public MapPacketExtractionIF {
|
class MapPacketExtraction: public MapPacketExtractionIF {
|
||||||
private:
|
private:
|
||||||
static const uint32_t MAX_PACKET_SIZE = 4096;
|
static const uint32_t MAX_PACKET_SIZE = 4096;
|
||||||
uint8_t lastSegmentationFlag; //!< The segmentation flag of the last received frame.
|
uint8_t lastSegmentationFlag; //!< The segmentation flag of the last received frame.
|
||||||
uint8_t mapId; //!< MAP ID of this MAP Channel.
|
uint8_t mapId; //!< MAP ID of this MAP Channel.
|
||||||
uint32_t packetLength; //!< Complete length of the current Space Packet.
|
uint32_t packetLength = 0; //!< Complete length of the current Space Packet.
|
||||||
uint8_t* bufferPosition; //!< Position to write to in the internal Packet buffer.
|
uint8_t* bufferPosition; //!< Position to write to in the internal Packet buffer.
|
||||||
uint8_t packetBuffer[MAX_PACKET_SIZE]; //!< The internal Space Packet Buffer.
|
uint8_t packetBuffer[MAX_PACKET_SIZE]; //!< The internal Space Packet Buffer.
|
||||||
object_id_t packetDestination;
|
object_id_t packetDestination;
|
||||||
StorageManagerIF* packetStore; //!< Pointer to the store where full TC packets are stored.
|
//!< Pointer to the store where full TC packets are stored.
|
||||||
|
StorageManagerIF* packetStore = nullptr;
|
||||||
MessageQueueId_t tcQueueId; //!< QueueId to send found packets to the distributor.
|
MessageQueueId_t tcQueueId; //!< QueueId to send found packets to the distributor.
|
||||||
/**
|
/**
|
||||||
* Debug method to print the packet Buffer's content.
|
* Debug method to print the packet Buffer's content.
|
||||||
@ -75,4 +70,4 @@ public:
|
|||||||
uint8_t getMapId() const;
|
uint8_t getMapId() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MAPPACKETEXTRACTION_H_ */
|
#endif /* FSFW_DATALINKLAYER_MAPPACKETEXTRACTION_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user