devicehandler updates

This commit is contained in:
Robin Müller 2020-12-22 12:44:55 +01:00
parent 5ba1932076
commit b28bf35fc3
3 changed files with 45 additions and 36 deletions

View File

@ -928,7 +928,7 @@ void DeviceHandlerBase::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
uint32_t DeviceHandlerBase::getTransitionDelayMs(Mode_t modeFrom, uint32_t DeviceHandlerBase::getTransitionDelayMs(Mode_t modeFrom,
Mode_t modeTo) { Mode_t modeTo) {
return 0; return 5000;
} }
ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) { ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) {
@ -1459,3 +1459,11 @@ DeviceCommandId_t DeviceHandlerBase::getPendingCommand() const {
} }
return DeviceHandlerIF::NO_COMMAND; return DeviceHandlerIF::NO_COMMAND;
} }
void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() {
for(const auto& reply: deviceReplyMap) {
if(reply.second.dataSet != nullptr) {
reply.second.dataSet->setValidity(false, true);
}
}
}

View File

@ -254,9 +254,10 @@ protected:
* *
* @param[out] id the device command id that has been built * @param[out] id the device command id that has been built
* @return * @return
* - @c RETURN_OK to send command after setting #rawPacket and #rawPacketLen. * - @c RETURN_OK to send command after setting #rawPacket and
* - @c NOTHING_TO_SEND when no command is to be sent. * #rawPacketLen.
* - Anything else triggers an even with the returnvalue as a parameter. * - @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; virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0;
@ -273,7 +274,8 @@ protected:
* and filling them in doStartUp(), doShutDown() and doTransition() so no * and filling them in doStartUp(), doShutDown() and doTransition() so no
* modes have to be checked here. * modes have to be checked here.
* *
* #rawPacket and #rawPacketLen must be set by this method to the packet to be sent. * #rawPacket and #rawPacketLen must be set by this method to the
* packet to be sent.
* *
* @param[out] id the device command id built * @param[out] id the device command id built
* @return * @return
@ -284,19 +286,23 @@ protected:
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 command. * @brief Build a device command packet from data supplied by a
* direct command.
* *
* @details * @details
* #rawPacket and #rawPacketLen should be set by this method to the packet to be sent. * #rawPacket and #rawPacketLen should be set by this method to the packet
* The existence of the command in the command map and the command size check * to be sent. The existence of the command in the command map and the
* against 0 are done by the base class. * command size check against 0 are done by the base class.
* *
* @param deviceCommand the command to build, already checked against deviceCommandMap * @param deviceCommand the command to build, already checked against
* deviceCommandMap
* @param commandData pointer to the data from the direct command * @param commandData pointer to the data from the direct command
* @param commandDataLen length of commandData * @param commandDataLen length of commandData
* @return * @return
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen have been set. * - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
* - Anything else triggers an event with the returnvalue as a parameter * have been set.
* - Anything else triggers an event with the
* returnvalue as a parameter
*/ */
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;
@ -681,7 +687,7 @@ protected:
//! The dataset used to access housekeeping data related to the //! The dataset used to access housekeeping data related to the
//! respective device reply. Will point to a dataset held by //! respective device reply. Will point to a dataset held by
//! the child handler (if one is specified) //! the child handler (if one is specified)
LocalPoolDataSetBase* dataSet; LocalPoolDataSetBase* dataSet = nullptr;
//! The command that expects this reply. //! The command that expects this reply.
DeviceCommandMap::iterator command; DeviceCommandMap::iterator command;
}; };
@ -743,6 +749,17 @@ protected:
//!< 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
* 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();
/** /**
* Helper function to get pending command. This is useful for devices * Helper function to get pending command. This is useful for devices
* like SPI sensors to identify the last sent command. * like SPI sensors to identify the last sent command.
@ -785,7 +802,6 @@ protected:
* *
* The submode is left unchanged. * The submode is left unchanged.
* *
*
* @param newMode * @param newMode
*/ */
void setMode(Mode_t newMode); void setMode(Mode_t newMode);
@ -838,8 +854,6 @@ protected:
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom); virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom);
/** /**
* Is the combination of mode and submode valid?
*
* @param mode * @param mode
* @param submode * @param submode
* @return * @return
@ -850,13 +864,10 @@ protected:
Submode_t submode); Submode_t submode);
/** /**
* Get the Rmap 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.
* * @return The communication action to execute in this step
* @return The Rmap action to execute in this step
*/ */
virtual CommunicationAction getComAction(); virtual CommunicationAction getComAction();
/** /**
@ -898,8 +909,8 @@ protected:
* It gets space in the #IPCStore, copies data there, then sends a raw reply * It gets space in the #IPCStore, copies data there, then sends a raw reply
* containing the store address. * containing the store address.
* *
* This method is virtual, as the STR has a different channel to send * This method is virtual, as devices can have different channels to send
* raw replies and overwrites it accordingly. * raw replies
* *
* @param data data to send * @param data data to send
* @param len length of @c data * @param len length of @c data
@ -918,7 +929,7 @@ protected:
void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len); void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len);
/** /**
* notify child about mode change * @brief Notify child about mode change.
*/ */
virtual void modeChanged(void); virtual void modeChanged(void);
@ -950,8 +961,7 @@ protected:
DeviceCommandId_t alternateReplyID = 0); DeviceCommandId_t alternateReplyID = 0);
/** /**
* get the state of the PCDU switches in the datapool * Get the state of the PCDU switches in the local datapool
*
* @return * @return
* - @c PowerSwitchIF::SWITCH_ON if all switches specified * - @c PowerSwitchIF::SWITCH_ON if all switches specified
* by #switches are on * by #switches are on
@ -961,15 +971,6 @@ protected:
*/ */
ReturnValue_t getStateOfSwitches(void); ReturnValue_t getStateOfSwitches(void);
/**
* @brief Set all datapool variables that are update periodically in
* normal mode invalid
* @details TODO: Use local pools
* Child classes should provide an implementation which sets all those
* variables invalid which are set periodically during any normal mode.
*/
virtual void setNormalDatapoolEntriesInvalid() = 0;
/** /**
* build a list of sids and pass it to the #hkSwitcher * build a list of sids and pass it to the #hkSwitcher
*/ */

View File

@ -131,7 +131,7 @@ public:
// Standard codes used in interpretDeviceReply // Standard codes used in interpretDeviceReply
static const ReturnValue_t DEVICE_DID_NOT_EXECUTE = MAKE_RETURN_CODE(0xC0); //the device reported, that it did not execute the command static const ReturnValue_t DEVICE_DID_NOT_EXECUTE = MAKE_RETURN_CODE(0xC0); //the device reported, that it did not execute the command
static const ReturnValue_t DEVICE_REPORTED_ERROR = MAKE_RETURN_CODE(0xC1); static const ReturnValue_t DEVICE_REPORTED_ERROR = MAKE_RETURN_CODE(0xC1);
static const ReturnValue_t UNKNOW_DEVICE_REPLY = MAKE_RETURN_CODE(0xC2); //the deviceCommandId reported by scanforReply is unknown static const ReturnValue_t UNKNOWN_DEVICE_REPLY = MAKE_RETURN_CODE(0xC2); //the deviceCommandId reported by scanforReply is unknown
static const ReturnValue_t DEVICE_REPLY_INVALID = MAKE_RETURN_CODE(0xC3); //syntax etc is correct but still not ok, eg parameters where none are expected static const ReturnValue_t DEVICE_REPLY_INVALID = MAKE_RETURN_CODE(0xC3); //syntax etc is correct but still not ok, eg parameters where none are expected
// Standard codes used in buildCommandFromCommand // Standard codes used in buildCommandFromCommand