RW shutdown #580
@ -22,6 +22,11 @@ will consitute of a breaking change warranting a new major release:
|
|||||||
when this was due to two devices being marked faulty.
|
when this was due to two devices being marked faulty.
|
||||||
- RW dummy and STR dummy components: Set/Update modes correctly.
|
- RW dummy and STR dummy components: Set/Update modes correctly.
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
- RW shutdown now waits for the speed to be near 0 or for a OFF transition countdown to be expired
|
||||||
|
before going to off.
|
||||||
|
|
||||||
# [v1.43.2] 2023-04-05
|
# [v1.43.2] 2023-04-05
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
@ -30,7 +30,7 @@ void RwHandler::doStartUp() {
|
|||||||
internalState = InternalState::DEFAULT;
|
internalState = InternalState::DEFAULT;
|
||||||
|
|
||||||
if (gpioComIF->pullHigh(enableGpio) != returnvalue::OK) {
|
if (gpioComIF->pullHigh(enableGpio) != returnvalue::OK) {
|
||||||
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high";
|
sif::error << "RW Handler " << rwIdx << ": Failed to pull ENABLE pin high for startup";
|
||||||
}
|
}
|
||||||
updatePeriodicReply(true, rws::REPLY_ID);
|
updatePeriodicReply(true, rws::REPLY_ID);
|
||||||
statusSet.setReportingEnabled(true);
|
statusSet.setReportingEnabled(true);
|
||||||
@ -38,29 +38,34 @@ void RwHandler::doStartUp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RwHandler::doShutDown() {
|
void RwHandler::doShutDown() {
|
||||||
if (gpioComIF->pullLow(enableGpio) != returnvalue::OK) {
|
if (internalState != InternalState::SHUTDOWN) {
|
||||||
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low";
|
internalState = InternalState::SHUTDOWN;
|
||||||
|
commandExecuted = false;
|
||||||
|
offTransitionCountdown.resetTimer();
|
||||||
}
|
}
|
||||||
internalState = InternalState::DEFAULT;
|
if (((internalState == InternalState::SHUTDOWN) and commandExecuted) or
|
||||||
updatePeriodicReply(false, rws::REPLY_ID);
|
offTransitionCountdown.hasTimedOut()) {
|
||||||
{
|
if (gpioComIF->pullLow(enableGpio) != returnvalue::OK) {
|
||||||
PoolReadGuard pg(&statusSet);
|
sif::error << "RW Handler " << rwIdx << ": Failed to pull ENABLE pin low for shutdown";
|
||||||
statusSet.currSpeed = 0.0;
|
}
|
||||||
statusSet.referenceSpeed = 0.0;
|
updatePeriodicReply(false, rws::REPLY_ID);
|
||||||
statusSet.state = 0;
|
{
|
||||||
statusSet.setValidity(false, true);
|
PoolReadGuard pg(&statusSet);
|
||||||
statusSet.setReportingEnabled(false);
|
statusSet.currSpeed = 0.0;
|
||||||
|
statusSet.referenceSpeed = 0.0;
|
||||||
|
statusSet.state = 0;
|
||||||
|
statusSet.setValidity(false, true);
|
||||||
|
statusSet.setReportingEnabled(false);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
PoolReadGuard pg(&tmDataset);
|
||||||
|
tmDataset.setValidity(false, true);
|
||||||
|
}
|
||||||
|
commandExecuted = false;
|
||||||
|
internalState = InternalState::DEFAULT;
|
||||||
|
// The power switch is handled by the assembly, so we can go off here directly.
|
||||||
|
setMode(MODE_OFF);
|
||||||
}
|
}
|
||||||
{
|
|
||||||
PoolReadGuard pg(&tmDataset);
|
|
||||||
tmDataset.setValidity(false, true);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
PoolReadGuard pg(&rwSpeedActuationSet);
|
|
||||||
rwSpeedActuationSet.setRwSpeed(0, 10);
|
|
||||||
}
|
|
||||||
// The power switch is handled by the assembly, so we can go off here directly.
|
|
||||||
setMode(MODE_OFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||||
@ -77,6 +82,14 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||||
|
if (internalState == InternalState::SHUTDOWN) {
|
||||||
|
{
|
||||||
|
PoolReadGuard pg(&rwSpeedActuationSet);
|
||||||
|
rwSpeedActuationSet.setRwSpeed(0, 10);
|
||||||
|
}
|
||||||
|
*id = rws::REQUEST_ID;
|
||||||
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
|
}
|
||||||
return NOTHING_TO_SEND;
|
return NOTHING_TO_SEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,6 +394,11 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) {
|
|||||||
|
|
||||||
statusSet.setValidity(true, true);
|
statusSet.setValidity(true, true);
|
||||||
|
|
||||||
|
if (internalState == InternalState::SHUTDOWN and std::abs(tmDataset.rwCurrSpeed.value) <= 2) {
|
||||||
|
// Finish transition to off.
|
||||||
|
commandExecuted = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (statusSet.state == rws::STATE_ERROR) {
|
if (statusSet.state == rws::STATE_ERROR) {
|
||||||
// Trigger FDIR reaction, first recovery, then faulty if it doesnt fix the issue.
|
// Trigger FDIR reaction, first recovery, then faulty if it doesnt fix the issue.
|
||||||
triggerEvent(DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT, statusSet.state.value, 0);
|
triggerEvent(DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT, statusSet.state.value, 0);
|
||||||
|
@ -75,6 +75,8 @@ class RwHandler : public DeviceHandlerBase {
|
|||||||
GpioIF* gpioComIF = nullptr;
|
GpioIF* gpioComIF = nullptr;
|
||||||
gpioId_t enableGpio = gpio::NO_GPIO;
|
gpioId_t enableGpio = gpio::NO_GPIO;
|
||||||
bool debugMode = false;
|
bool debugMode = false;
|
||||||
|
bool commandExecuted = false;
|
||||||
|
Countdown offTransitionCountdown = Countdown(5000);
|
||||||
|
|
||||||
rws::StatusSet statusSet;
|
rws::StatusSet statusSet;
|
||||||
rws::LastResetSatus lastResetStatusSet;
|
rws::LastResetSatus lastResetStatusSet;
|
||||||
@ -87,27 +89,10 @@ class RwHandler : public DeviceHandlerBase {
|
|||||||
PoolEntry<int32_t> rwSpeed = PoolEntry<int32_t>({0});
|
PoolEntry<int32_t> rwSpeed = PoolEntry<int32_t>({0});
|
||||||
PoolEntry<uint16_t> rampTime = PoolEntry<uint16_t>({10});
|
PoolEntry<uint16_t> rampTime = PoolEntry<uint16_t>({10});
|
||||||
|
|
||||||
enum class InternalState {
|
enum class InternalState { DEFAULT, GET_TM, INIT_RW_CONTROLLER, RESET_MCU, SHUTDOWN };
|
||||||
DEFAULT,
|
|
||||||
GET_TM,
|
|
||||||
INIT_RW_CONTROLLER,
|
|
||||||
RESET_MCU,
|
|
||||||
// GET_RESET_STATUS,
|
|
||||||
// CLEAR_RESET_STATUS,
|
|
||||||
// READ_TEMPERATURE,
|
|
||||||
// SET_SPEED,
|
|
||||||
// GET_RW_SATUS
|
|
||||||
};
|
|
||||||
|
|
||||||
InternalState internalState = InternalState::DEFAULT;
|
InternalState internalState = InternalState::DEFAULT;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function can be used to build commands which do not contain any data apart
|
|
||||||
* from the command id and the CRC.
|
|
||||||
* @param commandId The command id of the command to build.
|
|
||||||
*/
|
|
||||||
// void prepareSimpleCommand(DeviceCommandId_t id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function checks if the receiced speed and ramp time to set are in a valid
|
* @brief This function checks if the receiced speed and ramp time to set are in a valid
|
||||||
* range.
|
* range.
|
||||||
@ -115,13 +100,6 @@ class RwHandler : public DeviceHandlerBase {
|
|||||||
*/
|
*/
|
||||||
ReturnValue_t checkSpeedAndRampTime();
|
ReturnValue_t checkSpeedAndRampTime();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function prepares the set speed command from the dataSet received with
|
|
||||||
* an action message or set in the software.
|
|
||||||
* @return returnvalue::OK if successful, otherwise error code.
|
|
||||||
*/
|
|
||||||
// ReturnValue_t prepareSetSpeedCmd();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function writes the last reset status retrieved with the get last reset status
|
* @brief This function writes the last reset status retrieved with the get last reset status
|
||||||
* command into the reset status dataset.
|
* command into the reset status dataset.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user