more refactoring
This commit is contained in:
parent
ea41514553
commit
bfb0234d41
@ -2,62 +2,107 @@
|
||||
#define DEVICECOMMUNICATIONIF_H_
|
||||
|
||||
#include <framework/devicehandlers/Cookie.h>
|
||||
#include <framework/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
/**
|
||||
* @defgroup interfaces Interfaces
|
||||
* @brief Interfaces for flight software objects
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup communication comm
|
||||
* @brief Communication software components.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This is an interface to decouple device communication from
|
||||
* the device handler to allow reuse of these components.
|
||||
* @details
|
||||
* Documentation: Dissertation Baetz p.138
|
||||
* It works with the assumption that received data
|
||||
* is polled by a component. There are four generic steps of device communication:
|
||||
*
|
||||
* 1. Send data to a device
|
||||
* 2. Get acknowledgement for sending
|
||||
* 3. Request reading data from a device
|
||||
* 4. Read received data
|
||||
*
|
||||
* To identify different connection over a single interface can return
|
||||
* so-called cookies to components.
|
||||
* The CommunicationMessage message type can be used to extend the functionality of the
|
||||
* ComIF if a separate polling task is required.
|
||||
* @ingroup interfaces
|
||||
* @ingroup comm
|
||||
*/
|
||||
class DeviceCommunicationIF: public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF;
|
||||
|
||||
static const ReturnValue_t INVALID_COOKIE_TYPE = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x04);
|
||||
static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x05);
|
||||
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x06);
|
||||
static const ReturnValue_t CANT_CHANGE_REPLY_LEN = MAKE_RETURN_CODE(0x07);
|
||||
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x04);
|
||||
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x05);
|
||||
|
||||
virtual ~DeviceCommunicationIF() {
|
||||
|
||||
}
|
||||
|
||||
virtual ReturnValue_t open(Cookie **cookie, uint32_t address,
|
||||
uint32_t maxReplyLen) = 0;
|
||||
virtual ~DeviceCommunicationIF() {}
|
||||
|
||||
/**
|
||||
* Use an existing cookie to open a connection to a new DeviceCommunication.
|
||||
* The previous connection must not be closed.
|
||||
* If the returnvalue is not RETURN_OK, the cookie is unchanged and
|
||||
* can be used with the previous connection.
|
||||
*
|
||||
* @brief Device specific initialization, using the cookie.
|
||||
* @details
|
||||
* The cookie is already prepared in the factory. If the communication
|
||||
* interface needs to be set up in some way and requires cookie information,
|
||||
* this can be performed in this function, which is called on device handler
|
||||
* initialization.
|
||||
* @param cookie
|
||||
* @param address
|
||||
* @param maxReplyLen
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t reOpen(Cookie *cookie, uint32_t address,
|
||||
uint32_t maxReplyLen) = 0;
|
||||
virtual ReturnValue_t initializeInterface(CookieIF * cookie) = 0;
|
||||
|
||||
virtual void close(Cookie *cookie) = 0;
|
||||
/**
|
||||
* Called by DHB in the SEND_WRITE doSendWrite().
|
||||
* This function is used to send data to the physical device
|
||||
* by implementing and calling related drivers or wrapper functions.
|
||||
* @param cookie
|
||||
* @param data
|
||||
* @param len
|
||||
* @return -@c RETURN_OK for successfull send
|
||||
* - Everything else triggers sending failed event with
|
||||
* returnvalue as parameter 1
|
||||
*/
|
||||
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
|
||||
size_t sendLen) = 0;
|
||||
|
||||
//SHOULDDO can data be const?
|
||||
virtual ReturnValue_t sendMessage(Cookie *cookie, uint8_t *data,
|
||||
uint32_t len) = 0;
|
||||
/**
|
||||
* Called by DHB in the GET_WRITE doGetWrite().
|
||||
* Get send confirmation that the data in sendMessage() was sent successfully.
|
||||
* @param cookie
|
||||
* @return -@c RETURN_OK if data was sent successfull
|
||||
* - Everything else triggers sending failed event with
|
||||
* returnvalue as parameter 1
|
||||
*/
|
||||
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;
|
||||
|
||||
virtual ReturnValue_t getSendSuccess(Cookie *cookie) = 0;
|
||||
|
||||
virtual ReturnValue_t requestReceiveMessage(Cookie *cookie) = 0;
|
||||
|
||||
virtual ReturnValue_t readReceivedMessage(Cookie *cookie, uint8_t **buffer,
|
||||
uint32_t *size) = 0;
|
||||
|
||||
virtual ReturnValue_t setAddress(Cookie *cookie, uint32_t address) = 0;
|
||||
|
||||
virtual uint32_t getAddress(Cookie *cookie) = 0;
|
||||
|
||||
virtual ReturnValue_t setParameter(Cookie *cookie, uint32_t parameter) = 0;
|
||||
|
||||
virtual uint32_t getParameter(Cookie *cookie) = 0;
|
||||
/**
|
||||
* Called by DHB in the SEND_WRITE doSendRead().
|
||||
* Request a reply.
|
||||
* @param cookie
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) = 0;
|
||||
|
||||
/**
|
||||
* Called by DHB in the GET_WRITE doGetRead().
|
||||
* This function is used to receive data from the physical device
|
||||
* by implementing and calling related drivers or wrapper functions.
|
||||
* @param cookie
|
||||
* @param data
|
||||
* @param len
|
||||
* @return @c RETURN_OK for successfull receive
|
||||
* - Everything else triggers receiving failed with
|
||||
* returnvalue as parameter 1
|
||||
*/
|
||||
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||
size_t *size) = 0;
|
||||
};
|
||||
|
||||
#endif /* DEVICECOMMUNICATIONIF_H_ */
|
||||
|
@ -102,11 +102,10 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
// result = communicationInterface->open(&cookie, logicalAddress,
|
||||
// maxDeviceReplyLen, comParameter1, comParameter2);
|
||||
// if (result != RETURN_OK) {
|
||||
// return result;
|
||||
// }
|
||||
result = communicationInterface->initializeInterface(comCookie);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (IPCStore == NULL) {
|
||||
@ -811,9 +810,9 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(
|
||||
iter = deviceReplyMap.find(command->first);
|
||||
}
|
||||
if (iter != deviceReplyMap.end()) {
|
||||
DeviceReplyInfo *info = &(iter->second);
|
||||
info->delayCycles = info->maxDelayCycles;
|
||||
info->command = command;
|
||||
DeviceReplyInfo & info = iter->second;
|
||||
info.delayCycles = info.maxDelayCycles;
|
||||
info.command = command;
|
||||
command->second.expectedReplies = expectedReplies;
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
@ -1056,7 +1055,7 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(
|
||||
if (result == RETURN_OK) {
|
||||
replyReturnvalueToCommand(RETURN_OK);
|
||||
} else {
|
||||
replyReturnvalueToCommand(CANT_SWITCH_IOBOARD);
|
||||
replyReturnvalueToCommand(CANT_SWITCH_ADDRESS);
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
@ -1138,11 +1137,15 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data,
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size) {
|
||||
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result = acceptExternalDeviceCommands();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
if(size == 0) {
|
||||
return NO_COMMAND_DATA;
|
||||
}
|
||||
|
||||
DeviceCommandMap::iterator iter = deviceCommandMap.find(actionId);
|
||||
if (iter == deviceCommandMap.end()) {
|
||||
result = COMMAND_NOT_SUPPORTED;
|
||||
@ -1161,7 +1164,7 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId,
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::buildInternalCommand(void) {
|
||||
//Neither Raw nor Direct could build a command
|
||||
// Neither Raw nor Direct could build a command
|
||||
ReturnValue_t result = NOTHING_TO_SEND;
|
||||
DeviceCommandId_t deviceCommandId = NO_COMMAND_ID;
|
||||
if (mode == MODE_NORMAL) {
|
||||
@ -1179,12 +1182,13 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == NOTHING_TO_SEND) {
|
||||
return;
|
||||
}
|
||||
if (result == RETURN_OK) {
|
||||
DeviceCommandMap::iterator iter = deviceCommandMap.find(
|
||||
deviceCommandId);
|
||||
DeviceCommandMap::iterator iter =
|
||||
deviceCommandMap.find(deviceCommandId);
|
||||
if (iter == deviceCommandMap.end()) {
|
||||
result = COMMAND_NOT_SUPPORTED;
|
||||
} else if (iter->second.isExecuting) {
|
||||
@ -1199,6 +1203,7 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
||||
cookieInfo.state = COOKIE_WRITE_READY;
|
||||
}
|
||||
}
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
triggerEvent(DEVICE_BUILDING_COMMAND_FAILED, result, deviceCommandId);
|
||||
}
|
||||
|
@ -69,6 +69,12 @@ class StorageManagerIF;
|
||||
*
|
||||
* Other important virtual methods with a default implementation
|
||||
* are the getTransitionDelayMs() function and the getSwitches() function.
|
||||
* Please ensure that getSwitches() returns DeviceHandlerIF::NO_SWITCHES if
|
||||
* power switches are not implemented yet. Otherwise, the device handler will
|
||||
* not transition to MODE_ON, even if setMode(MODE_ON) is called.
|
||||
* If a transition to MODE_ON is desired without commanding, override the
|
||||
* intialize() function and call setMode(_MODE_START_UP) before calling
|
||||
* DeviceHandlerBase::initialize().
|
||||
*
|
||||
* @ingroup devices
|
||||
*/
|
||||
@ -191,8 +197,9 @@ protected:
|
||||
*
|
||||
* @param[out] id the device command id that has been built
|
||||
* @return
|
||||
* - @c RETURN_OK when a command is to be sent
|
||||
* - not @c RETURN_OK when no command is to be sent
|
||||
* - @c RETURN_OK to send command after setting #rawPacket and #rawPacketLen.
|
||||
* - @c NOTHING_TO_SEND when no command is to be sent.
|
||||
* - Anything else triggers an even with the returnvalue as a parameter.
|
||||
*/
|
||||
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0;
|
||||
|
||||
@ -210,21 +217,25 @@ protected:
|
||||
* @param[out] id the device command id built
|
||||
* @return
|
||||
* - @c RETURN_OK when a command is to be sent
|
||||
* - not @c RETURN_OK when no command is to be sent
|
||||
* - @c NOTHING_TO_SEND when no command is to be sent
|
||||
* - Anything else triggers an even with the returnvalue as a parameter
|
||||
*/
|
||||
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0;
|
||||
|
||||
/**
|
||||
* Build a device command packet from data supplied by a direct command.
|
||||
* @brief Build a device command packet from data supplied by a direct command.
|
||||
*
|
||||
* @details
|
||||
* #rawPacket and #rawPacketLen should be set by this method to the packet to be sent.
|
||||
* The existence of the command in the command map and the command size check
|
||||
* against 0 are done by the base class.
|
||||
*
|
||||
* @param deviceCommand the command to build, already checked against deviceCommandMap
|
||||
* @param commandData pointer to the data from the direct command
|
||||
* @param commandDataLen length of commandData
|
||||
* @return
|
||||
* - @c RETURN_OK when #rawPacket is valid
|
||||
* - @c RETURN_FAILED when #rawPacket is invalid and no data should be sent
|
||||
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen have been set.
|
||||
* - Anything else triggers an event with the returnvalue as a parameter
|
||||
*/
|
||||
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t * commandData, size_t commandDataLen) = 0;
|
||||
@ -349,7 +360,7 @@ protected:
|
||||
* @param[out] numberOfSwitches length of returned array
|
||||
* @return
|
||||
* - @c RETURN_OK if the parameters were set
|
||||
* - @c RETURN_FAILED if no switches exist
|
||||
* - @c NO_SWITCH or any other returnvalue if no switches exist
|
||||
*/
|
||||
virtual ReturnValue_t getSwitches(const uint8_t **switches,
|
||||
uint8_t *numberOfSwitches);
|
||||
@ -360,14 +371,29 @@ protected:
|
||||
*/
|
||||
virtual void performOperationHook();
|
||||
|
||||
/**
|
||||
* The Returnvalues id of this class, required by HasReturnvaluesIF
|
||||
*/
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @param parentQueueId
|
||||
*/
|
||||
virtual void setParentQueue(MessageQueueId_t parentQueueId);
|
||||
|
||||
/**
|
||||
* This function call handles the execution of external commands as required
|
||||
* by the HasActionIF.
|
||||
* @param actionId
|
||||
* @param commandedBy
|
||||
* @param data
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size);
|
||||
MessageQueueId_t commandedBy, const uint8_t* data, size_t size);
|
||||
|
||||
Mode_t getTransitionSourceMode() const;
|
||||
Submode_t getTransitionSourceSubMode() const;
|
||||
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
||||
@ -386,21 +412,6 @@ public:
|
||||
virtual MessageQueueId_t getCommandQueue(void) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The Returnvalues id of this class, required by HasReturnvaluesIF
|
||||
*/
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
|
||||
|
||||
static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(4);
|
||||
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
|
||||
// static const ReturnValue_t ONE_SWITCH = MAKE_RETURN_CODE(8);
|
||||
// static const ReturnValue_t TWO_SWITCHES = MAKE_RETURN_CODE(9);
|
||||
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(10);
|
||||
static const ReturnValue_t COMMAND_MAP_ERROR = MAKE_RETURN_CODE(11);
|
||||
static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(12);
|
||||
|
||||
//Mode handling error Codes
|
||||
static const ReturnValue_t CHILD_TIMEOUT = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t SWITCH_FAILED = MAKE_RETURN_CODE(0xE2);
|
||||
@ -453,7 +464,7 @@ protected:
|
||||
* indicates either that all raw messages to and from the device should be sent to #theOneWhoWantsToReadRawTraffic
|
||||
* or that all device TM should be downlinked to #theOneWhoWantsToReadRawTraffic
|
||||
*/
|
||||
enum WiretappingMode {
|
||||
enum WiretappingMode: uint8_t {
|
||||
OFF = 0, RAW = 1, TM = 2
|
||||
} wiretappingMode;
|
||||
|
||||
|
@ -8,7 +8,13 @@
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
|
||||
/**
|
||||
* This is the Interface used to communicate with a device handler.
|
||||
* @brief Physical address type
|
||||
*/
|
||||
typedef uint32_t address_t;
|
||||
|
||||
/**
|
||||
* @brief This is the Interface used to communicate with a device handler.
|
||||
* @details Includes all expected return values, events and modes.
|
||||
*
|
||||
*/
|
||||
class DeviceHandlerIF {
|
||||
@ -22,80 +28,95 @@ 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.
|
||||
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_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
|
||||
static const Mode_t _MODE_POWER_ON = TRANSITION_MODE_BASE_ACTION_MASK | 2; //!< This is a transitional state which can not be commanded. The device will be switched on in this state. After the command to set the switch on has been sent, the mode changes to @c MODE_WAIT_ON
|
||||
static const Mode_t _MODE_WAIT_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 3; //!< This is a transitional state which can not be commanded. The switch has been commanded off and the handler waits for it to be off. When the switch is off, the mode changes to @c MODE_OFF.
|
||||
static const Mode_t _MODE_WAIT_ON = TRANSITION_MODE_BASE_ACTION_MASK | 4; //!< This is a transitional state which can not be commanded. The switch has been commanded on and the handler waits for it to be on. When the switch is on, the mode changes to @c MODE_TO_ON.
|
||||
static const Mode_t _MODE_SWITCH_IS_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 5; //!< This is a transitional state which can not be commanded. The switch has been commanded off and is off now. This state is only to do an RMAP cycle once more where the doSendRead() function will set the mode to MODE_OFF. The reason to do this is to get rid of stuck packets in the IO Board
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CDH;
|
||||
static const Event DEVICE_BUILDING_COMMAND_FAILED = MAKE_EVENT(0, SEVERITY::LOW);
|
||||
static const Event DEVICE_SENDING_COMMAND_FAILED = MAKE_EVENT(1, SEVERITY::LOW);
|
||||
static const Event DEVICE_REQUESTING_REPLY_FAILED = MAKE_EVENT(2, SEVERITY::LOW);
|
||||
static const Event DEVICE_READING_REPLY_FAILED = MAKE_EVENT(3, SEVERITY::LOW);
|
||||
static const Event DEVICE_INTERPRETING_REPLY_FAILED = MAKE_EVENT(4, SEVERITY::LOW);
|
||||
static const Event DEVICE_MISSED_REPLY = MAKE_EVENT(5, SEVERITY::LOW);
|
||||
static const Event DEVICE_UNKNOWN_REPLY = MAKE_EVENT(6, SEVERITY::LOW);
|
||||
static const Event DEVICE_UNREQUESTED_REPLY = MAKE_EVENT(7, SEVERITY::LOW);
|
||||
static const Event INVALID_DEVICE_COMMAND = MAKE_EVENT(8, SEVERITY::LOW); //!< Indicates a SW bug in child class.
|
||||
static const Event MONITORING_LIMIT_EXCEEDED = MAKE_EVENT(9, SEVERITY::LOW);
|
||||
static const Event MONITORING_AMBIGUOUS = MAKE_EVENT(10, SEVERITY::HIGH);
|
||||
// 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; //!< 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
|
||||
static const Mode_t _MODE_POWER_ON = TRANSITION_MODE_BASE_ACTION_MASK | 2; //!< This is a transitional state which can not be commanded. The device will be switched on in this state. After the command to set the switch on has been sent, the mode changes to @c MODE_WAIT_ON
|
||||
static const Mode_t _MODE_WAIT_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 3; //!< This is a transitional state which can not be commanded. The switch has been commanded off and the handler waits for it to be off. When the switch is off, the mode changes to @c MODE_OFF.
|
||||
static const Mode_t _MODE_WAIT_ON = TRANSITION_MODE_BASE_ACTION_MASK | 4; //!< This is a transitional state which can not be commanded. The switch has been commanded on and the handler waits for it to be on. When the switch is on, the mode changes to @c MODE_TO_ON.
|
||||
static const Mode_t _MODE_SWITCH_IS_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 5; //!< This is a transitional state which can not be commanded. The switch has been commanded off and is off now. This state is only to do an RMAP cycle once more where the doSendRead() function will set the mode to MODE_OFF. The reason to do this is to get rid of stuck packets in the IO Board
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
|
||||
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 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);
|
||||
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA8); //!< Used to indicate that this is a command-only command.
|
||||
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xA9);
|
||||
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAA);
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CDH;
|
||||
static const Event DEVICE_BUILDING_COMMAND_FAILED = MAKE_EVENT(0, SEVERITY::LOW);
|
||||
static const Event DEVICE_SENDING_COMMAND_FAILED = MAKE_EVENT(1, SEVERITY::LOW);
|
||||
static const Event DEVICE_REQUESTING_REPLY_FAILED = MAKE_EVENT(2, SEVERITY::LOW);
|
||||
static const Event DEVICE_READING_REPLY_FAILED = MAKE_EVENT(3, SEVERITY::LOW);
|
||||
static const Event DEVICE_INTERPRETING_REPLY_FAILED = MAKE_EVENT(4, SEVERITY::LOW);
|
||||
static const Event DEVICE_MISSED_REPLY = MAKE_EVENT(5, SEVERITY::LOW);
|
||||
static const Event DEVICE_UNKNOWN_REPLY = MAKE_EVENT(6, SEVERITY::LOW);
|
||||
static const Event DEVICE_UNREQUESTED_REPLY = MAKE_EVENT(7, SEVERITY::LOW);
|
||||
static const Event INVALID_DEVICE_COMMAND = MAKE_EVENT(8, SEVERITY::LOW); //!< Indicates a SW bug in child class.
|
||||
static const Event MONITORING_LIMIT_EXCEEDED = MAKE_EVENT(9, SEVERITY::LOW);
|
||||
static const Event MONITORING_AMBIGUOUS = MAKE_EVENT(10, SEVERITY::HIGH);
|
||||
|
||||
//standard 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);
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
|
||||
|
||||
//standard 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 when building commands.
|
||||
static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(0xA0); //!< Return this if no command sending in required
|
||||
// Mostly used for internal handling.
|
||||
static const ReturnValue_t NO_COMMAND_DATA = MAKE_RETURN_CODE(0xA2); //!< If the command size is 0. Checked in DHB
|
||||
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA3); //!< Used to indicate that this is a command-only command.
|
||||
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA4); //!< Command ID not in commandMap. Checked in DHB
|
||||
static const ReturnValue_t COMMAND_ALREADY_SENT = MAKE_RETURN_CODE(0xA5); //!< Command was already executed. Checked in DHB
|
||||
static const ReturnValue_t COMMAND_WAS_NOT_SENT = MAKE_RETURN_CODE(0xA6);
|
||||
static const ReturnValue_t CANT_SWITCH_ADDRESS = MAKE_RETURN_CODE(0xA7);
|
||||
static const ReturnValue_t WRONG_MODE_FOR_COMMAND = MAKE_RETURN_CODE(0xA8);
|
||||
static const ReturnValue_t TIMEOUT = MAKE_RETURN_CODE(0xA9);
|
||||
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(0xAA);
|
||||
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xAB);
|
||||
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAC);
|
||||
|
||||
//Standard 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);
|
||||
// Standard codes used in scanForReply
|
||||
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(0xB1); //!< This is used to specify for replies from a device which are not replies to requests
|
||||
static const ReturnValue_t LENGTH_MISSMATCH = MAKE_RETURN_CODE(0xB2);
|
||||
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(0xB3); //!< Ignore parts of the received packet
|
||||
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(0xB4); //!< Ignore full received packet
|
||||
static const ReturnValue_t CHECKSUM_ERROR = MAKE_RETURN_CODE(0xB5);
|
||||
static const ReturnValue_t INVALID_DATA = MAKE_RETURN_CODE(0xB6);
|
||||
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0xB7);
|
||||
|
||||
// Standard codes used in interpretDeviceReply
|
||||
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
|
||||
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);
|
||||
|
||||
// Standard codes used in getSwitches
|
||||
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(0xE1); //!< Return in getSwitches() to specify there are no switches
|
||||
|
||||
// static const ReturnValue_t ONE_SWITCH = MAKE_RETURN_CODE(8);
|
||||
// static const ReturnValue_t TWO_SWITCHES = MAKE_RETURN_CODE(9);
|
||||
// where is this used?
|
||||
// static const ReturnValue_t COMMAND_MAP_ERROR = MAKE_RETURN_CODE(11);
|
||||
|
||||
/**
|
||||
* Communication action that will be executed.
|
||||
*
|
||||
* This is used by the child class to tell the base class what to do.
|
||||
*/
|
||||
enum CommunicationAction_t: uint8_t {
|
||||
SEND_WRITE,//!< Send write
|
||||
GET_WRITE, //!< Get write
|
||||
SEND_READ, //!< Send read
|
||||
GET_READ, //!< Get read
|
||||
NOTHING //!< Do nothing.
|
||||
};
|
||||
|
||||
/**
|
||||
* RMAP Action that will be executed.
|
||||
*
|
||||
* This is used by the child class to tell the base class what to do.
|
||||
*/
|
||||
enum RmapAction_t {
|
||||
SEND_WRITE,//!< RMAP send write
|
||||
GET_WRITE, //!< RMAP get write
|
||||
SEND_READ, //!< RMAP send read
|
||||
GET_READ, //!< RMAP get read
|
||||
NOTHING //!< Do nothing.
|
||||
};
|
||||
/**
|
||||
* Default Destructor
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user