bugfixes and improvements

This commit is contained in:
Robin Müller 2020-12-01 18:29:00 +01:00
parent 3fb3039be5
commit fff928a191
3 changed files with 48 additions and 20 deletions

View File

@ -13,10 +13,11 @@
#include "../ipc/MessageQueueMessage.h" #include "../ipc/MessageQueueMessage.h"
#include "../ipc/QueueFactory.h" #include "../ipc/QueueFactory.h"
#include "../subsystem/SubsystemBase.h" #include "../subsystem/SubsystemBase.h"
#include "../datapoollocal/LocalPoolVariable.h"
#include <iomanip> #include <iomanip>
#include "../datapoollocal/LocalPoolVariable.h"
object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT;
object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT;
@ -57,9 +58,9 @@ void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) {
} }
void DeviceHandlerBase::setThermalStateRequestPoolIds( void DeviceHandlerBase::setThermalStateRequestPoolIds(
gp_id_t thermalStatePoolId, gp_id_t thermalRequestPoolId) { lp_id_t thermalStatePoolId, lp_id_t thermalRequestPoolId) {
this->deviceThermalRequestPoolId = thermalStatePoolId; this->deviceHeaterRequestPoolId = thermalStatePoolId;
this->deviceThermalRequestPoolId = thermalRequestPoolId; this->deviceHeaterRequestPoolId = thermalRequestPoolId;
} }
@ -211,13 +212,17 @@ ReturnValue_t DeviceHandlerBase::initialize() {
fillCommandAndReplyMap(); fillCommandAndReplyMap();
if(deviceHeaterRequestPoolId != localpool::INVALID_LPID) {
//Set temperature target state to NON_OP. //Set temperature target state to NON_OP.
LocalPoolVar<int8_t> thermalRequest(deviceThermalRequestPoolId, nullptr, LocalPoolVar<DeviceHandlerIF::dh_heater_request_t>
heaterRequest(this, deviceHeaterRequestPoolId, nullptr,
pool_rwm_t::VAR_WRITE); pool_rwm_t::VAR_WRITE);
ReturnValue_t result = thermalRequest.read(); result = heaterRequest.read();
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
thermalRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; heaterRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
thermalRequest.commit(PoolVariableIF::VALID); heaterRequest.commit(PoolVariableIF::VALID);
}
} }
return RETURN_OK; return RETURN_OK;
@ -509,10 +514,11 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
Clock::getUptime(&timeoutStart); Clock::getUptime(&timeoutStart);
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
LocalPoolVar<uint8_t> heaterRequest(deviceThermalRequestPoolId, LocalPoolVar<DeviceHandlerIF::dh_heater_request_t>
heaterRequest(this, deviceHeaterRequestPoolId,
nullptr, PoolVariableIF::VAR_READ_WRITE); nullptr, PoolVariableIF::VAR_READ_WRITE);
ReturnValue_t result = heaterRequest.read(); ReturnValue_t result = heaterRequest.read();
if(heaterRequest == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
if (heaterRequest.value != if (heaterRequest.value !=
ThermalComponentIF::STATE_REQUEST_IGNORE) { ThermalComponentIF::STATE_REQUEST_IGNORE) {
heaterRequest.value = ThermalComponentIF:: heaterRequest.value = ThermalComponentIF::
@ -987,7 +993,7 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode,
GlobDataSet mySet; GlobDataSet mySet;
gp_uint8_t thermalState(deviceThermalStatePoolId, &mySet, gp_uint8_t thermalState(deviceThermalStatePoolId, &mySet,
PoolVariableIF::VAR_READ); PoolVariableIF::VAR_READ);
gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet, gp_uint8_t thermalRequest(deviceHeaterRequestPoolId, &mySet,
PoolVariableIF::VAR_READ); PoolVariableIF::VAR_READ);
mySet.read(); mySet.read();
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
@ -1015,7 +1021,7 @@ void DeviceHandlerBase::startTransition(Mode_t commandedMode,
MODE_ON); MODE_ON);
triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode); triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode);
GlobDataSet mySet; GlobDataSet mySet;
gp_int8_t thermalRequest(deviceThermalRequestPoolId, gp_int8_t thermalRequest(deviceHeaterRequestPoolId,
&mySet, PoolVariableIF::VAR_READ_WRITE); &mySet, PoolVariableIF::VAR_READ_WRITE);
mySet.read(); mySet.read();
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
@ -1393,6 +1399,15 @@ void DeviceHandlerBase::performOperationHook() {
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool( ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(
LocalDataPool &localDataPoolMap, LocalDataPool &localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
if(deviceThermalStatePoolId != localpool::INVALID_LPID) {
localDataPoolMap.emplace(deviceThermalStatePoolId,
new PoolEntry<DeviceHandlerIF::dh_thermal_state_t>);
}
if(deviceHeaterRequestPoolId != localpool::INVALID_LPID) {
localDataPoolMap.emplace(deviceHeaterRequestPoolId,
new PoolEntry<DeviceHandlerIF::dh_heater_request_t>);
}
return RETURN_OK; return RETURN_OK;
} }

View File

@ -103,8 +103,18 @@ public:
size_t cmdQueueSize = 20); size_t cmdQueueSize = 20);
void setHkDestination(object_id_t hkDestination); void setHkDestination(object_id_t hkDestination);
void setThermalStateRequestPoolIds(gp_id_t thermalStatePoolId,
gp_id_t thermalRequestPoolId); /**
* If the device handler is controlled by the FSFW thermal building blocks,
* this function should be called. The device handler will then take care
* of creating local pool entries for the device thermal state and device
* heating request. Custom local pool IDs can be assigned as well.
* @param thermalStatePoolId
* @param thermalRequestPoolId
*/
void setThermalStateRequestPoolIds(
lp_id_t thermalStatePoolId = localpool::INVALID_LPID - 1,
lp_id_t thermalRequestPoolId = localpool::INVALID_LPID - 2);
/** /**
* @brief Helper function to ease device handler development. * @brief Helper function to ease device handler development.
* This will instruct the transition to MODE_ON immediately * This will instruct the transition to MODE_ON immediately
@ -220,7 +230,7 @@ protected:
* - If the device does not change the mode, the mode will be changed to * - If the device does not change the mode, the mode will be changed to
* _MODE_POWER_DOWN, when the timeout (from getTransitionDelay()) * _MODE_POWER_DOWN, when the timeout (from getTransitionDelay())
* has passed. * has passed.
* * 0xffffffff
* #transitionFailure can be set to a failure code indicating the reason * #transitionFailure can be set to a failure code indicating the reason
* for a failed transition * for a failed transition
*/ */
@ -699,14 +709,14 @@ protected:
* *
* can be set to PoolVariableIF::NO_PARAMETER to deactivate thermal checking * can be set to PoolVariableIF::NO_PARAMETER to deactivate thermal checking
*/ */
gp_id_t deviceThermalStatePoolId; lp_id_t deviceThermalStatePoolId = localpool::INVALID_LPID;
/** /**
* this is the datapool variable with the thermal request of the device * this is the datapool variable with the thermal request of the device
* *
* can be set to PoolVariableIF::NO_PARAMETER to deactivate thermal checking * can be set to PoolVariableIF::NO_PARAMETER to deactivate thermal checking
*/ */
gp_id_t deviceThermalRequestPoolId; lp_id_t deviceHeaterRequestPoolId = localpool::INVALID_LPID;
/** /**
* Optional Error code. Can be set in doStartUp(), doShutDown() and * Optional Error code. Can be set in doStartUp(), doShutDown() and

View File

@ -26,6 +26,9 @@ public:
static const uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20; static const uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20;
static const uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10; static const uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10;
using dh_heater_request_t = uint8_t;
using dh_thermal_state_t = int8_t;
/** /**
* @brief This is the mode the <strong>device handler</strong> is in. * @brief This is the mode the <strong>device handler</strong> is in.
* *