removed hk switcher for now

This commit is contained in:
Robin Müller 2021-02-03 13:28:31 +01:00
parent 5ac3762dc5
commit a404bc881e
2 changed files with 2188 additions and 2189 deletions

View File

@ -17,16 +17,15 @@ 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;
DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
object_id_t deviceCommunication, CookieIF * comCookie, CookieIF * comCookie, FailureIsolationBase* fdirInstance, size_t cmdQueueSize):
FailureIsolationBase* fdirInstance, size_t cmdQueueSize) :
SystemObject(setObjectId), mode(MODE_OFF), submode(SUBMODE_NONE), SystemObject(setObjectId), mode(MODE_OFF), submode(SUBMODE_NONE),
wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS), wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS),
deviceCommunicationId(deviceCommunication), comCookie(comCookie), deviceCommunicationId(deviceCommunication), comCookie(comCookie),
healthHelper(this,setObjectId), modeHelper(this), parameterHelper(this), healthHelper(this,setObjectId), modeHelper(this), parameterHelper(this),
actionHelper(this, nullptr), poolManager(this, nullptr), actionHelper(this, nullptr), poolManager(this, nullptr),
childTransitionFailure(RETURN_OK), fdirInstance(fdirInstance), childTransitionFailure(RETURN_OK), fdirInstance(fdirInstance),
hkSwitcher(this), defaultFDIRUsed(fdirInstance == nullptr), defaultFDIRUsed(fdirInstance == nullptr),
switchOffWasReported(false), childTransitionDelay(5000), switchOffWasReported(false), childTransitionDelay(5000),
transitionSourceMode(_MODE_POWER_DOWN), transitionSourceMode(_MODE_POWER_DOWN),
transitionSourceSubMode(SUBMODE_NONE) { transitionSourceSubMode(SUBMODE_NONE) {
@ -80,7 +79,6 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
checkSwitchState(); checkSwitchState();
decrementDeviceReplyMap(); decrementDeviceReplyMap();
fdirInstance->checkForFailures(); fdirInstance->checkForFailures();
hkSwitcher.performOperation();
performOperationHook(); performOperationHook();
return RETURN_OK; return RETURN_OK;
} }
@ -506,7 +504,8 @@ void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) {
} }
void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
changeHK(mode, submode, false); /* TODO: This will probably be done by the LocalDataPoolManager now */
//changeHK(mode, submode, false);
submode = newSubmode; submode = newSubmode;
mode = newMode; mode = newMode;
modeChanged(); modeChanged();
@ -529,7 +528,8 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
} }
} }
changeHK(mode, submode, true); /* TODO: This will probably be done by the LocalDataPoolManager now */
//changeHK(mode, submode, true);
} }
void DeviceHandlerBase::setMode(Mode_t newMode) { void DeviceHandlerBase::setMode(Mode_t newMode) {
@ -1379,9 +1379,9 @@ void DeviceHandlerBase::forwardEvent(Event event, uint32_t parameter1,
void DeviceHandlerBase::doOffActivity() { void DeviceHandlerBase::doOffActivity() {
} }
ReturnValue_t DeviceHandlerBase::getParameter(uint8_t domainId, ReturnValue_t DeviceHandlerBase::getParameter(uint8_t domainId, uint8_t uniqueId,
uint8_t uniqueId, ParameterWrapper* parameterWrapper, ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues,
const ParameterWrapper* newValues, uint16_t startAtIndex) { uint16_t startAtIndex) {
ReturnValue_t result = fdirInstance->getParameter(domainId, uniqueId, parameterWrapper, ReturnValue_t result = fdirInstance->getParameter(domainId, uniqueId, parameterWrapper,
newValues, startAtIndex); newValues, startAtIndex);
if (result != INVALID_DOMAIN_ID) { if (result != INVALID_DOMAIN_ID) {
@ -1407,14 +1407,10 @@ bool DeviceHandlerBase::commandIsExecuting(DeviceCommandId_t commandId) {
} }
void DeviceHandlerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) {
}
void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task){ void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task){
executingTask = task; executingTask = task;
} }
// Default implementations empty.
void DeviceHandlerBase::debugInterface(uint8_t positionTracker, void DeviceHandlerBase::debugInterface(uint8_t positionTracker,
object_id_t objectId, uint32_t parameter) {} object_id_t objectId, uint32_t parameter) {}

View File

@ -20,7 +20,6 @@
#include "../action/ActionHelper.h" #include "../action/ActionHelper.h"
#include "../health/HealthHelper.h" #include "../health/HealthHelper.h"
#include "../parameters/ParameterHelper.h" #include "../parameters/ParameterHelper.h"
#include "../datapool/HkSwitchHelper.h"
#include "../datapoollocal/HasLocalDataPoolIF.h" #include "../datapoollocal/HasLocalDataPoolIF.h"
#include "../datapoollocal/LocalDataPoolManager.h" #include "../datapoollocal/LocalDataPoolManager.h"
@ -148,8 +147,7 @@ public:
* 4. Decrements counter for timeout of replies by calling * 4. Decrements counter for timeout of replies by calling
* decrementDeviceReplyMap() * decrementDeviceReplyMap()
* 5. Performs FDIR check for failures * 5. Performs FDIR check for failures
* 6. Calls hkSwitcher.performOperation() * 6. If the device mode is MODE_OFF, return RETURN_OK.
* 7. If the device mode is MODE_OFF, return RETURN_OK.
* Otherwise, perform the Action property and performs depending * Otherwise, perform the Action property and performs depending
* on value specified by input value counter (incremented in PST). * on value specified by input value counter (incremented in PST).
* The child class tells base class what to do by setting this value. * The child class tells base class what to do by setting this value.
@ -248,7 +246,6 @@ protected:
* for a failed transition * for a failed transition
*/ */
virtual void doStartUp() = 0; virtual void doStartUp() = 0;
/** /**
* @brief This is used to let the child class handle the transition * @brief This is used to let the child class handle the transition
* from mode @c _MODE_SHUT_DOWN to @c _MODE_POWER_DOWN * from mode @c _MODE_SHUT_DOWN to @c _MODE_POWER_DOWN
@ -274,6 +271,7 @@ protected:
*/ */
virtual void doShutDown() = 0; virtual void doShutDown() = 0;
/* Command handling */
/** /**
* Build the device command to send for normal mode. * Build the device command to send for normal mode.
* *
@ -294,7 +292,6 @@ protected:
* - Anything else triggers an even with the returnvalue as a parameter. * - Anything else triggers an even with the returnvalue as a parameter.
*/ */
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0; virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0;
/** /**
* Build the device command to send for a transitional mode. * Build the device command to send for a transitional mode.
* *
@ -318,7 +315,6 @@ protected:
* - Anything else triggers an even with the returnvalue as a parameter * - Anything else triggers an even with the returnvalue as a parameter
*/ */
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0; virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0;
/** /**
* @brief Build a device command packet from data supplied by a direct * @brief Build a device command packet from data supplied by a direct
* command (PUS Service 8) * command (PUS Service 8)
@ -347,6 +343,7 @@ protected:
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData, size_t commandDataLen) = 0; const uint8_t * commandData, size_t commandDataLen) = 0;
/* Reply handling */
/** /**
* @brief Scans a buffer for a valid reply. * @brief Scans a buffer for a valid reply.
* @details * @details
@ -382,7 +379,6 @@ protected:
*/ */
virtual ReturnValue_t scanForReply(const uint8_t *start, size_t len, virtual ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) = 0; DeviceCommandId_t *foundId, size_t *foundLen) = 0;
/** /**
* @brief Interpret a reply from the device. * @brief Interpret a reply from the device.
* @details * @details
@ -404,10 +400,19 @@ protected:
*/ */
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) = 0; const uint8_t *packet) = 0;
MessageQueueId_t getCommanderId(DeviceCommandId_t replyId) const;
/** /**
* @brief fill the #DeviceCommandMap and #DeviceReplyMap * Helper function to get pending command. This is useful for devices
* called by the initialize() of the base class * like SPI sensors to identify the last sent command.
* This only returns the command sent in the last SEND_WRITE cycle.
* @return
*/
DeviceCommandId_t getPendingCommand() const;
/* Specifying commands and replies */
/**
* @brief Fill the #DeviceCommandMap and #DeviceReplyMap called by the #initialize
* of the base class
* @details * @details
* This is used to let the base class know which replies are expected. * This is used to let the base class know which replies are expected.
* There are different scenarios regarding this: * There are different scenarios regarding this:
@ -437,7 +442,6 @@ protected:
* handled by returning @c APERIODIC_REPLY in scanForReply(). * handled by returning @c APERIODIC_REPLY in scanForReply().
*/ */
virtual void fillCommandAndReplyMap() = 0; virtual void fillCommandAndReplyMap() = 0;
/** /**
* This is a helper method to facilitate inserting entries in the command map. * This is a helper method to facilitate inserting entries in the command map.
* @param deviceCommand Identifier of the command to add. * @param deviceCommand Identifier of the command to add.
@ -455,7 +459,6 @@ protected:
LocalPoolDataSetBase* replyDataSet = nullptr, LocalPoolDataSetBase* replyDataSet = nullptr,
size_t replyLen = 0, bool periodic = false, size_t replyLen = 0, bool periodic = false,
bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0); bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0);
/** /**
* @brief This is a helper method to insert replies in the reply map. * @brief This is a helper method to insert replies in the reply map.
* @param deviceCommand Identifier of the reply to add. * @param deviceCommand Identifier of the reply to add.
@ -469,7 +472,6 @@ protected:
ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand,
uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet = nullptr, uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet = nullptr,
size_t replyLen = 0, bool periodic = false); size_t replyLen = 0, bool periodic = false);
/** /**
* @brief A simple command to add a command to the commandList. * @brief A simple command to add a command to the commandList.
* @param deviceCommand The command to add * @param deviceCommand The command to add
@ -495,25 +497,14 @@ protected:
ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply, ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply,
uint16_t delayCycles, uint16_t maxDelayCycles, uint16_t delayCycles, uint16_t maxDelayCycles,
bool periodic = false); bool periodic = false);
/**
* @brief Can be used to set the dataset corresponding to a reply ID manually.
* @details
* Used by the local data pool manager.
*/
ReturnValue_t setReplyDataset(DeviceCommandId_t replyId, ReturnValue_t setReplyDataset(DeviceCommandId_t replyId,
LocalPoolDataSetBase* dataset); LocalPoolDataSetBase* dataset);
/**
* @brief Can be implemented by child handler to
* perform debugging
* @details Example: Calling this in performOperation
* to track values like mode.
* @param positionTracker Provide the child handler a way to know
* where the debugInterface was called
* @param objectId Provide the child handler object Id to
* specify actions for spefic devices
* @param parameter Supply a parameter of interest
* Please delete all debugInterface calls in DHB after debugging is finished !
*/
virtual void debugInterface(uint8_t positionTracker = 0,
object_id_t objectId = 0, uint32_t parameter = 0);
/** /**
* Get the time needed to transit from modeFrom to modeTo. * Get the time needed to transit from modeFrom to modeTo.
* *
@ -532,6 +523,73 @@ protected:
*/ */
virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) = 0; virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) = 0;
/* Functions used by the local data pool manager */
/**
* This function is used to initialize the local housekeeping pool
* entries. The default implementation leaves the pool empty.
* @param localDataPoolMap
* @return
*/
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
/**
* @brief Set all datapool variables that are update periodically in
* normal mode invalid
* @details
* The default implementation will set all datasets which have been added
* in #fillCommandAndReplyMap to invalid. It will also set all pool
* variables inside the dataset to invalid. The user can override this
* method optionally.
*/
virtual void setNormalDatapoolEntriesInvalid();
/**
* @brief Get the dataset handle for a given SID.
* @details
* The default implementation will use the deviceCommandMap to look for the corresponding
* dataset handle. The user can override this function if this is not desired.
* @param sid
* @return
*/
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
/* HasModesIF overrides */
virtual void startTransition(Mode_t mode, Submode_t submode) override;
virtual void setToExternalControl() override;
virtual void announceMode(bool recursive) override;
/**
* @brief Set the device handler mode
* @details
* Sets #timeoutStart with every call Also sets #transitionTargetMode if necessary so
* transitional states can be entered from everywhere without breaking the state machine
* (which relies on a correct #transitionTargetMode).
* The submode is left unchanged.
*
* @param newMode
*/
void setMode(Mode_t newMode);
/**
* @overload
* @param submode
*/
void setMode(Mode_t newMode, Submode_t submode);
/**
* @brief Should be implemented properly by child class.
* @param mode
* @param submode
* @return
* - @c RETURN_OK if valid
* - @c RETURN_FAILED if invalid
*/
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
Submode_t submode);
/**
* @brief Notify child about mode change.
* @details
* Can be overriden to be used like a callback.
*/
virtual void modeChanged();
/* Power handling functions */
/** /**
* Return the switches connected to the device. * Return the switches connected to the device.
* *
@ -547,39 +605,48 @@ protected:
uint8_t *numberOfSwitches); uint8_t *numberOfSwitches);
/** /**
* This function is used to initialize the local housekeeping pool * @brief Helper function to report a missed reply
* entries. The default implementation leaves the pool empty. * @details Can be overwritten by children to act on missed replies or to fake reporting Id.
* @param localDataPoolMap * @param id of the missed reply
* @return
*/ */
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, virtual void missedReply(DeviceCommandId_t id);
LocalDataPoolManager& poolManager) override;
/**
* Required for HasLocalDataPoolIF, return a handle to the local pool manager.
* @return
*/
LocalDataPoolManager* getHkManagerHandle() override;
/* Miscellaneous functions */
/** /**
* @brief Hook function for child handlers which is called once per * @brief Hook function for child handlers which is called once per
* performOperation(). Default implementation is empty. * performOperation(). Default implementation is empty.
*/ */
virtual void performOperationHook(); virtual void performOperationHook();
/**
* @brief Can be implemented by child handler to
* perform debugging
* @details Example: Calling this in performOperation
* to track values like mode.
* @param positionTracker Provide the child handler a way to know
* where the debugInterface was called
* @param objectId Provide the child handler object Id to
* specify actions for spefic devices
* @param parameter Supply a parameter of interest
* Please delete all debugInterface calls in DHB after debugging is finished !
*/
virtual void debugInterface(uint8_t positionTracker = 0,
object_id_t objectId = 0, uint32_t parameter = 0);
protected: protected:
/**
* The Returnvalues id of this class, required by HasReturnvaluesIF
*/
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE; static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(0xA0); static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(0xA0);
/* Return codes for scanForReply */ /* Return codes for scanForReply */
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(0xB0); //!< This is used to specify for replies from a device which are not replies to requests //! 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(0xB1); //!< Ignore parts of the received packet static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(0xB0);
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(0xB2); //!< Ignore full received packet //! Ignore parts of the received packet
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(0xB1);
//! Ignore full received packet
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(0xB2);
/* Return codes for command building */ /* Return codes for command building */
static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(0xC0); //!< Return this if no command sending in required //! Return this if no command sending in required
static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(0xC0);
static const ReturnValue_t COMMAND_MAP_ERROR = MAKE_RETURN_CODE(0xC2); static const ReturnValue_t COMMAND_MAP_ERROR = MAKE_RETURN_CODE(0xC2);
// Return codes for getSwitches */ // Return codes for getSwitches */
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(0xD0); static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(0xD0);
@ -589,9 +656,9 @@ protected:
static const MessageQueueId_t NO_COMMANDER = 0; static const MessageQueueId_t NO_COMMANDER = 0;
/** Pointer to the raw packet that will be sent.*/ //! Pointer to the raw packet that will be sent.
uint8_t *rawPacket = nullptr; uint8_t *rawPacket = nullptr;
/** Size of the #rawPacket. */ //! Size of the #rawPacket.
uint32_t rawPacketLen = 0; uint32_t rawPacketLen = 0;
/** /**
@ -740,90 +807,41 @@ protected:
* default class is instantiated. */ * default class is instantiated. */
FailureIsolationBase* fdirInstance; FailureIsolationBase* fdirInstance;
HkSwitchHelper hkSwitcher; //! To correctly delete the default instance.
bool defaultFDIRUsed;
bool defaultFDIRUsed; //!< To correctly delete the default instance. //! Indicates if SWITCH_WENT_OFF was already thrown.
bool switchOffWasReported;
bool switchOffWasReported; //!< Indicates if SWITCH_WENT_OFF was already thrown. /** 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 = nullptr; PeriodicTaskIF* executingTask = nullptr;
//!< Object which switches power on and off. //! Object which switches power on and off.
static object_id_t powerSwitcherId; static object_id_t powerSwitcherId;
//!< Object which receives RAW data by default. //! Object which receives RAW data by default.
static object_id_t rawDataReceiverId; static object_id_t rawDataReceiverId;
//!< Object which may be the root cause of an identified fault. //! Object which may be the root cause of an identified fault.
static object_id_t defaultFdirParentId; static object_id_t defaultFdirParentId;
/** /**
* @brief Set all datapool variables that are update periodically in * @brief Send a reply to a received device handler command.
* normal mode invalid
* @details
* The default implementation will set all datasets which have been added
* in #fillCommandAndReplyMap to invalid. It will also set all pool
* variables inside the dataset to invalid. The user can override this
* method optionally.
*/
virtual void setNormalDatapoolEntriesInvalid();
MessageQueueId_t getCommanderId(DeviceCommandId_t replyId) const;
/**
* Helper function to get pending command. This is useful for devices
* like SPI sensors to identify the last sent command.
* This only returns the command sent in the last SEND_WRITE cycle.
* @return
*/
DeviceCommandId_t getPendingCommand() const;
/**
* Helper function to report a missed reply
*
* Can be overwritten by children to act on missed replies or to fake
* reporting Id.
*
* @param id of the missed reply
*/
virtual void missedReply(DeviceCommandId_t id);
/**
* Send a reply to a received device handler command.
* *
* This also resets #DeviceHandlerCommand to 0. * This also resets #DeviceHandlerCommand to 0.
* *
* @param reply the reply type * @param reply the reply type
* @param parameter parameter for the reply * @param parameter parameter for the reply
*/ */
void replyReturnvalueToCommand(ReturnValue_t status, void replyReturnvalueToCommand(ReturnValue_t status, uint32_t parameter = 0);
uint32_t parameter = 0); /**
* TODO: Whats the difference between this and the upper command?
* @param status
* @param parameter
*/
void replyToCommand(ReturnValue_t status, uint32_t parameter = 0); void replyToCommand(ReturnValue_t status, uint32_t parameter = 0);
/**
* Set the device handler mode
*
* Sets #timeoutStart with every call.
*
* Sets #transitionTargetMode if necessary so transitional states can be
* entered from everywhere without breaking the state machine
* (which relies on a correct #transitionTargetMode).
*
* The submode is left unchanged.
*
* @param newMode
*/
void setMode(Mode_t newMode);
/**
* @overload
* @param submode
*/
void setMode(Mode_t newMode, Submode_t submode);
/** /**
* Do the transition to the main modes (MODE_ON, MODE_NORMAL and MODE_RAW). * Do the transition to the main modes (MODE_ON, MODE_NORMAL and MODE_RAW).
* *
@ -865,16 +883,6 @@ protected:
*/ */
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom); virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom);
/**
* @param mode
* @param submode
* @return
* - @c RETURN_OK if valid
* - @c RETURN_FAILED if invalid
*/
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
Submode_t submode);
/** /**
* Get the communication action for the current step. * Get the communication action for the current step.
* The step number can be read from #pstStep. * The step number can be read from #pstStep.
@ -883,27 +891,28 @@ protected:
virtual CommunicationAction getComAction(); virtual CommunicationAction getComAction();
/** /**
* Build the device command to send for raw mode. * Checks state of switches in conjunction with mode and triggers an event
* * if they don't fit.
* This is only called in @c MODE_RAW. It is for the rare case that in
* raw mode packets are to be sent by the handler itself. It is NOT needed
* for the raw commanding service. Its only current use is in the STR
* handler which gets its raw packets from a different source.
* Also it can be used for transitional commands, to get the device ready
* for @c MODE_RAW
*
* As it is almost never used, there is a default implementation
* returning @c NOTHING_TO_SEND.
*
* #rawPacket and #rawPacketLen must be set by this method to the packet
* to be sent.
*
* @param[out] id the device command id built
* @return
* - @c RETURN_OK when a command is to be sent
* - not @c NOTHING_TO_SEND when no command is to be sent
*/ */
virtual ReturnValue_t buildChildRawCommand(); virtual void checkSwitchState();
/**
* Reserved for the rare case where a device needs to perform additional
* operation cyclically in OFF mode.
*/
virtual void doOffActivity();
/**
* Reserved for the rare case where a device needs to perform additional
* operation cyclically in ON mode.
*/
virtual void doOnActivity();
/**
* Required for HasLocalDataPoolIF, return a handle to the local pool manager.
* @return
*/
LocalDataPoolManager* getHkManagerHandle() override;
/** /**
* Returns the delay cycle count of a reply. * Returns the delay cycle count of a reply.
@ -915,24 +924,6 @@ protected:
*/ */
uint8_t getReplyDelayCycles(DeviceCommandId_t deviceCommand); uint8_t getReplyDelayCycles(DeviceCommandId_t deviceCommand);
/**
* Construct a command reply containing a raw reply.
*
* It gets space in the #IPCStore, copies data there, then sends a raw reply
* containing the store address.
*
* This method is virtual, as devices can have different channels to send
* raw replies
*
* @param data data to send
* @param len length of @c data
* @param sendTo the messageQueueId of the one to send to
* @param isCommand marks the raw data as a command, the message then
* will be of type raw_command
*/
virtual void replyRawData(const uint8_t *data, size_t len,
MessageQueueId_t sendTo, bool isCommand = false);
/** /**
* Calls replyRawData() with #defaultRawReceiver, but checks if wiretapping * Calls replyRawData() with #defaultRawReceiver, but checks if wiretapping
* is active and if so, does not send the data as the wiretapping will have * is active and if so, does not send the data as the wiretapping will have
@ -940,11 +931,6 @@ protected:
*/ */
void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len); void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len);
/**
* @brief Notify child about mode change.
*/
virtual void modeChanged(void);
/** /**
* Enable the reply checking for a command * Enable the reply checking for a command
* *
@ -972,6 +958,45 @@ protected:
uint8_t expectedReplies = 1, bool useAlternateId = false, uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0); DeviceCommandId_t alternateReplyID = 0);
/**
* @brief Build the device command to send for raw mode.
* @details
* This is only called in @c MODE_RAW. It is for the rare case that in
* raw mode packets are to be sent by the handler itself. It is NOT needed
* for the raw commanding service. Its only current use is in the STR
* handler which gets its raw packets from a different source.
* Also it can be used for transitional commands, to get the device ready
* for @c MODE_RAW
*
* As it is almost never used, there is a default implementation
* returning @c NOTHING_TO_SEND.
*
* #rawPacket and #rawPacketLen must be set by this method to the packet
* to be sent.
*
* @param[out] id the device command id built
* @return
* - @c RETURN_OK when a command is to be sent
* - not @c NOTHING_TO_SEND when no command is to be sent
*/
virtual ReturnValue_t buildChildRawCommand();
/**
* @brief Construct a command reply containing a raw reply.
* @details
* It gets space in the #IPCStore, copies data there, then sends a raw reply
* containing the store address. This method is virtual, as devices can have different channels
* to send raw replies
*
* @param data data to send
* @param len length of @c data
* @param sendTo the messageQueueId of the one to send to
* @param isCommand marks the raw data as a command, the message then
* will be of type raw_command
*/
virtual void replyRawData(const uint8_t *data, size_t len,
MessageQueueId_t sendTo, bool isCommand = false);
/** /**
* Get the state of the PCDU switches in the local datapool * Get the state of the PCDU switches in the local datapool
* @return * @return
@ -981,12 +1006,7 @@ protected:
* #switches are off * #switches are off
* - @c PowerSwitchIF::RETURN_FAILED if an error occured * - @c PowerSwitchIF::RETURN_FAILED if an error occured
*/ */
ReturnValue_t getStateOfSwitches(void); ReturnValue_t getStateOfSwitches();
/**
* build a list of sids and pass it to the #hkSwitcher
*/
virtual void changeHK(Mode_t mode, Submode_t submode, bool enable);
/** /**
* Children can overwrite this function to suppress checking of the * Children can overwrite this function to suppress checking of the
@ -1012,11 +1032,6 @@ protected:
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode); uint32_t *msToReachTheMode);
/* HasModesIF overrides */
virtual void startTransition(Mode_t mode, Submode_t submode) override;
virtual void setToExternalControl() override;
virtual void announceMode(bool recursive) override;
virtual ReturnValue_t letChildHandleMessage(CommandMessage *message); virtual ReturnValue_t letChildHandleMessage(CommandMessage *message);
/** /**
@ -1034,23 +1049,6 @@ protected:
*/ */
virtual void forwardEvent(Event event, uint32_t parameter1 = 0, virtual void forwardEvent(Event event, uint32_t parameter1 = 0,
uint32_t parameter2 = 0) const; uint32_t parameter2 = 0) const;
/**
* Checks state of switches in conjunction with mode and triggers an event
* if they don't fit.
*/
virtual void checkSwitchState();
/**
* Reserved for the rare case where a device needs to perform additional
* operation cyclically in OFF mode.
*/
virtual void doOffActivity();
/**
* Reserved for the rare case where a device needs to perform additional
* operation cyclically in ON mode.
*/
virtual void doOnActivity();
/** /**
* Checks if current mode is transitional mode. * Checks if current mode is transitional mode.
@ -1250,14 +1248,12 @@ private:
void setTransition(Mode_t modeTo, Submode_t submodeTo); void setTransition(Mode_t modeTo, Submode_t submodeTo);
/** /**
* calls the right child function for the transitional submodes * Calls the right child function for the transitional submodes
*/ */
void callChildStatemachine(); void callChildStatemachine();
ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message); ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message);
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
virtual dur_millis_t getPeriodicOperationFrequency() const override; virtual dur_millis_t getPeriodicOperationFrequency() const override;
void parseReply(const uint8_t* receivedData, void parseReply(const uint8_t* receivedData,
@ -1266,6 +1262,13 @@ private:
void handleTransitionToOnMode(Mode_t commandedMode, void handleTransitionToOnMode(Mode_t commandedMode,
Submode_t commandedSubmode); Submode_t commandedSubmode);
/**
* Generic internal printer function which also handles printing the object ID.
* @param errorType
* @param functionName
* @param errorCode
* @param errorPrint
*/
void printWarningOrError(sif::OutputTypes errorType, void printWarningOrError(sif::OutputTypes errorType,
const char* functionName, const char* functionName,
ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED,