DeviceHandlerBase: All Refactoring #44

Merged
mohr merged 56 commits from KSat/fsfw:mueller_DeviceHandlerBase_AllRefactoring into master 2020-07-03 11:48:56 +02:00
3 changed files with 32 additions and 20 deletions
Showing only changes of commit 62644bdfc9 - Show all commits

View File

@ -1054,7 +1054,7 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(
if (result == RETURN_OK) {
replyReturnvalueToCommand(RETURN_OK);
} else {
replyReturnvalueToCommand(CANT_SWITCH_IOBOARD);
replyReturnvalueToCommand(CANT_SWITCH_IO_ADDRESS);
}
}
return RETURN_OK;

View File

@ -445,7 +445,13 @@ protected:
*/
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
/**
* These returnvalues can be returned from abstract functions
* to alter the behaviour of DHB.For error values, refer to
* DeviceHandlerIF.h returnvalues.
*/
static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(4);
// Returnvalues for scanForReply()
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(5); //!< This is used to specify for replies from a device which are not replies to requests
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(6); //!< Ignore parts of the received packet
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(7); //!< Ignore full received packet

View File

@ -2,13 +2,15 @@
#define DEVICEHANDLERIF_H_
#include <framework/action/HasActionsIF.h>
#include <framework/devicehandlers/DeviceHandlerMessage.h>
#include <framework/events/Event.h>
#include <framework/modes/HasModesIF.h>
#include <framework/ipc/MessageQueueSenderIF.h>
#include <framework/devicehandlers/DeviceHandlerMessage.h>
#include <framework/events/Event.h>
/**
* This is the Interface used to communicate with a device handler.
* @brief This is the Interface used to communicate with a device handler.
* @details Includes all expected return values, events and modes.
*
*/
class DeviceHandlerIF {
@ -22,15 +24,17 @@ public:
*
* @details The mode of the device handler must not be confused with the mode the device is in.
* The mode of the device itself is transparent to the user but related to the mode of the handler.
* MODE_ON and MODE_OFF are included in hasModesIF.h
*/
// MODE_ON = 0, //!< The device is powered and ready to perform operations. In this mode, no commands are sent by the device handler itself, but direct commands van be commanded and will be interpreted
// MODE_OFF = 1, //!< The device is powered off. The only command accepted in this mode is a mode change to on.
// MODE_ON = 0, //!< The device is powered and ready to perform operations. In this mode, no commands are sent by the device handler itself, but direct commands van be commanded and will be interpreted
// MODE_OFF = 1, //!< The device is powered off. The only command accepted in this mode is a mode change to on.
static const Mode_t MODE_NORMAL = 2; //!< The device is powered on and the device handler periodically sends commands. The commands to be sent are selected by the handler according to the submode.
static const Mode_t MODE_RAW = 3; //!< The device is powered on and ready to perform operations. In this mode, raw commands can be sent. The device handler will send all replies received from the command back to the commanding object.
static const Mode_t MODE_ERROR_ON = 4; //!4< The device is shut down but the switch could not be turned off, so the device still is powered. In this mode, only a mode change to @c MODE_OFF can be commanded, which tries to switch off the device again.
static const Mode_t _MODE_START_UP = TRANSITION_MODE_CHILD_ACTION_MASK | 5; //!< This is a transitional state which can not be commanded. The device handler performs all commands to get the device in a state ready to perform commands. When this is completed, the mode changes to @c MODE_ON.
static const Mode_t _MODE_SHUT_DOWN = TRANSITION_MODE_CHILD_ACTION_MASK | 6; //!< This is a transitional state which can not be commanded. The device handler performs all actions and commands to get the device shut down. When the device is off, the mode changes to @c MODE_OFF.
static const Mode_t _MODE_TO_ON = TRANSITION_MODE_CHILD_ACTION_MASK | HasModesIF::MODE_ON;
static const Mode_t _MODE_TO_ON = TRANSITION_MODE_CHILD_ACTION_MASK | HasModesIF::MODE_ON; //!< It is possible to set the mode to _MODE_TO_ON to use the to on transition if available.
static const Mode_t _MODE_TO_RAW = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_RAW;
static const Mode_t _MODE_TO_NORMAL = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_NORMAL;
static const Mode_t _MODE_POWER_DOWN = TRANSITION_MODE_BASE_ACTION_MASK | 1; //!< This is a transitional state which can not be commanded. The device is shut down and ready to be switched off. After the command to set the switch off has been sent, the mode changes to @c MODE_WAIT_OFF
@ -53,11 +57,12 @@ public:
static const Event MONITORING_AMBIGUOUS = MAKE_EVENT(10, SEVERITY::HIGH);
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
// Standard error codes when handling or building commands.
static const ReturnValue_t NO_COMMAND_DATA = MAKE_RETURN_CODE(0xA0);
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1);
static const ReturnValue_t COMMAND_ALREADY_SENT = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t COMMAND_WAS_NOT_SENT = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t CANT_SWITCH_IOBOARD = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t CANT_SWITCH_IO_ADDRESS = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t WRONG_MODE_FOR_COMMAND = MAKE_RETURN_CODE(0xA5);
static const ReturnValue_t TIMEOUT = MAKE_RETURN_CODE(0xA6);
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(0xA7);
@ -65,35 +70,35 @@ public:
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xA9);
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAA);
//standard codes used in scan for reply
// static const ReturnValue_t TOO_SHORT = MAKE_RETURN_CODE(0xB1);
// Standard error codes used in scan for reply
//static const ReturnValue_t TOO_SHORT = MAKE_RETURN_CODE(0xB1);
static const ReturnValue_t CHECKSUM_ERROR = MAKE_RETURN_CODE(0xB2);
static const ReturnValue_t LENGTH_MISSMATCH = MAKE_RETURN_CODE(0xB3);
static const ReturnValue_t INVALID_DATA = MAKE_RETURN_CODE(0xB4);
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0xB5);
//standard codes used in interpret device reply
// Standard error codes used in interpret device reply
static const ReturnValue_t DEVICE_DID_NOT_EXECUTE = MAKE_RETURN_CODE(0xC1); //the device reported, that it did not execute the command
static const ReturnValue_t DEVICE_REPORTED_ERROR = MAKE_RETURN_CODE(0xC2);
static const ReturnValue_t UNKNOW_DEVICE_REPLY = MAKE_RETURN_CODE(0xC3); //the deviceCommandId reported by scanforReply is unknown
static const ReturnValue_t DEVICE_REPLY_INVALID = MAKE_RETURN_CODE(0xC4); //syntax etc is correct but still not ok, eg parameters where none are expected
//Standard codes used in buildCommandFromCommand
// Standard error codes used in buildCommandFromCommand
static const ReturnValue_t INVALID_COMMAND_PARAMETER = MAKE_RETURN_CODE(
0xD0);
static const ReturnValue_t INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS =
MAKE_RETURN_CODE(0xD1);
/**
* Communication action which will be executed.
* Communication action that will be executed.
*
* This is used by the child class to tell the base class what to do.
*/
enum CommunicationAction_t {
SEND_WRITE,//!< RMAP send write
GET_WRITE, //!< RMAP get write
SEND_READ, //!< RMAP send read
GET_READ, //!< RMAP get read
enum CommunicationAction_t: uint8_t {
SEND_WRITE,//!< Send write
GET_WRITE, //!< Get write
SEND_READ, //!< Send read
GET_READ, //!< Get read
NOTHING //!< Do nothing.
};
@ -105,8 +110,9 @@ public:
/**
* This MessageQueue is used to command the device handler.
*
* To command a device handler, a DeviceHandlerCommandMessage can be sent to this Queue.
* The handler replies with a DeviceHandlerCommandMessage containing the DeviceHandlerCommand_t reply.
* To command a device handler, a DeviceHandlerCommandMessage can be
* sent to this Queue. The handler replies with a
* DeviceHandlerCommandMessage containing the DeviceHandlerCommand_t reply.
*
* @return the id of the MessageQueue
*/