This commit is contained in:
parent
7b539e2fa5
commit
dfb1e88f55
@ -105,7 +105,7 @@ ReturnValue_t AcsBoardPolling::sendMessage(CookieIF* cookie, const uint8_t* send
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
auto* req = reinterpret_cast<const acs::Adis1650XRequest*>(sendData);
|
auto* req = reinterpret_cast<const acs::Adis1650XRequest*>(sendData);
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (req->mode != adis.mode) {
|
if (req->mode != adis.mode) {
|
||||||
if (req->mode == acs::SimpleSensorMode::NORMAL) {
|
if (req->mode == acs::SimpleSensorMode::NORMAL) {
|
||||||
adis.type = req->type;
|
adis.type = req->type;
|
||||||
@ -135,7 +135,7 @@ ReturnValue_t AcsBoardPolling::sendMessage(CookieIF* cookie, const uint8_t* send
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
auto* req = reinterpret_cast<const acs::GyroL3gRequest*>(sendData);
|
auto* req = reinterpret_cast<const acs::GyroL3gRequest*>(sendData);
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (req->mode != gyro.mode) {
|
if (req->mode != gyro.mode) {
|
||||||
if (req->mode == acs::SimpleSensorMode::NORMAL) {
|
if (req->mode == acs::SimpleSensorMode::NORMAL) {
|
||||||
std::memcpy(gyro.sensorCfg, req->ctrlRegs, 5);
|
std::memcpy(gyro.sensorCfg, req->ctrlRegs, 5);
|
||||||
@ -154,7 +154,7 @@ ReturnValue_t AcsBoardPolling::sendMessage(CookieIF* cookie, const uint8_t* send
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
auto* req = reinterpret_cast<const acs::MgmLis3Request*>(sendData);
|
auto* req = reinterpret_cast<const acs::MgmLis3Request*>(sendData);
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (req->mode != mgm.mode) {
|
if (req->mode != mgm.mode) {
|
||||||
if (req->mode == acs::SimpleSensorMode::NORMAL) {
|
if (req->mode == acs::SimpleSensorMode::NORMAL) {
|
||||||
mgm.performStartup = true;
|
mgm.performStartup = true;
|
||||||
@ -173,7 +173,7 @@ ReturnValue_t AcsBoardPolling::sendMessage(CookieIF* cookie, const uint8_t* send
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
auto* req = reinterpret_cast<const acs::MgmRm3100Request*>(sendData);
|
auto* req = reinterpret_cast<const acs::MgmRm3100Request*>(sendData);
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (req->mode != mgm.mode) {
|
if (req->mode != mgm.mode) {
|
||||||
if (req->mode == acs::SimpleSensorMode::NORMAL) {
|
if (req->mode == acs::SimpleSensorMode::NORMAL) {
|
||||||
mgm.performStartup = true;
|
mgm.performStartup = true;
|
||||||
@ -218,7 +218,7 @@ ReturnValue_t AcsBoardPolling::sendMessage(CookieIF* cookie, const uint8_t* send
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (state == InternalState::IDLE) {
|
if (state == InternalState::IDLE) {
|
||||||
state = InternalState::BUSY;
|
state = InternalState::BUSY;
|
||||||
semaphore->release();
|
semaphore->release();
|
||||||
@ -238,7 +238,7 @@ ReturnValue_t AcsBoardPolling::readReceivedMessage(CookieIF* cookie, uint8_t** b
|
|||||||
if (spiCookie == nullptr) {
|
if (spiCookie == nullptr) {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
auto handleAdisReply = [&](GyroAdis& gyro) {
|
auto handleAdisReply = [&](GyroAdis& gyro) {
|
||||||
std::memcpy(&gyro.readerReply, &gyro.ownReply, sizeof(acs::Adis1650XReply));
|
std::memcpy(&gyro.readerReply, &gyro.ownReply, sizeof(acs::Adis1650XReply));
|
||||||
*buffer = reinterpret_cast<uint8_t*>(&gyro.readerReply);
|
*buffer = reinterpret_cast<uint8_t*>(&gyro.readerReply);
|
||||||
@ -297,7 +297,7 @@ void AcsBoardPolling::gyroL3gHandler(GyroL3g& l3g) {
|
|||||||
acs::SimpleSensorMode mode;
|
acs::SimpleSensorMode mode;
|
||||||
bool gyroPerformStartup;
|
bool gyroPerformStartup;
|
||||||
{
|
{
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
mode = l3g.mode;
|
mode = l3g.mode;
|
||||||
gyroPerformStartup = l3g.performStartup;
|
gyroPerformStartup = l3g.performStartup;
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ void AcsBoardPolling::gyroL3gHandler(GyroL3g& l3g) {
|
|||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
l3g.replyResult = returnvalue::OK;
|
l3g.replyResult = returnvalue::OK;
|
||||||
}
|
}
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
// Cross check configuration as verification that communication is working
|
// Cross check configuration as verification that communication is working
|
||||||
for (uint8_t idx = 0; idx < 5; idx++) {
|
for (uint8_t idx = 0; idx < 5; idx++) {
|
||||||
if (rawReply[idx + 1] != l3g.sensorCfg[idx]) {
|
if (rawReply[idx + 1] != l3g.sensorCfg[idx]) {
|
||||||
@ -345,7 +345,7 @@ void AcsBoardPolling::gyroL3gHandler(GyroL3g& l3g) {
|
|||||||
l3g.replyResult = returnvalue::FAILED;
|
l3g.replyResult = returnvalue::FAILED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
// The regular read function always returns the full sensor config as well. Use that
|
// The regular read function always returns the full sensor config as well. Use that
|
||||||
// to verify communications.
|
// to verify communications.
|
||||||
for (uint8_t idx = 0; idx < 5; idx++) {
|
for (uint8_t idx = 0; idx < 5; idx++) {
|
||||||
@ -444,7 +444,7 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) {
|
|||||||
bool cdHasTimedOut = false;
|
bool cdHasTimedOut = false;
|
||||||
bool mustPerformStartup = false;
|
bool mustPerformStartup = false;
|
||||||
{
|
{
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
mode = gyro.mode;
|
mode = gyro.mode;
|
||||||
cdHasTimedOut = gyro.countdown.hasTimedOut();
|
cdHasTimedOut = gyro.countdown.hasTimedOut();
|
||||||
mustPerformStartup = gyro.performStartup;
|
mustPerformStartup = gyro.performStartup;
|
||||||
@ -478,7 +478,7 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) {
|
|||||||
gyro.replyResult = returnvalue::FAILED;
|
gyro.replyResult = returnvalue::FAILED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
gyro.ownReply.cfgWasSet = true;
|
gyro.ownReply.cfgWasSet = true;
|
||||||
gyro.ownReply.cfg.diagStat = (rawReply[2] << 8) | rawReply[3];
|
gyro.ownReply.cfg.diagStat = (rawReply[2] << 8) | rawReply[3];
|
||||||
gyro.ownReply.cfg.filterSetting = (rawReply[4] << 8) | rawReply[5];
|
gyro.ownReply.cfg.filterSetting = (rawReply[4] << 8) | rawReply[5];
|
||||||
@ -525,7 +525,7 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
gyro.ownReply.dataWasSet = true;
|
gyro.ownReply.dataWasSet = true;
|
||||||
gyro.ownReply.cfg.diagStat = rawReply[2] << 8 | rawReply[3];
|
gyro.ownReply.cfg.diagStat = rawReply[2] << 8 | rawReply[3];
|
||||||
gyro.ownReply.data.angVelocities[0] = (rawReply[4] << 8) | rawReply[5];
|
gyro.ownReply.data.angVelocities[0] = (rawReply[4] << 8) | rawReply[5];
|
||||||
@ -545,7 +545,7 @@ void AcsBoardPolling::mgmLis3Handler(MgmLis3& mgm) {
|
|||||||
acs::SimpleSensorMode mode;
|
acs::SimpleSensorMode mode;
|
||||||
bool mustPerformStartup = false;
|
bool mustPerformStartup = false;
|
||||||
{
|
{
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
mode = mgm.mode;
|
mode = mgm.mode;
|
||||||
mustPerformStartup = mgm.performStartup;
|
mustPerformStartup = mgm.performStartup;
|
||||||
}
|
}
|
||||||
@ -605,7 +605,7 @@ void AcsBoardPolling::mgmLis3Handler(MgmLis3& mgm) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
mgm.ownReply.dataWasSet = true;
|
mgm.ownReply.dataWasSet = true;
|
||||||
mgm.ownReply.sensitivity = mgmLis3::getSensitivityFactor(mgmLis3::getSensitivity(mgm.cfg[1]));
|
mgm.ownReply.sensitivity = mgmLis3::getSensitivityFactor(mgmLis3::getSensitivity(mgm.cfg[1]));
|
||||||
mgm.ownReply.mgmValuesRaw[0] =
|
mgm.ownReply.mgmValuesRaw[0] =
|
||||||
@ -627,7 +627,7 @@ void AcsBoardPolling::mgmLis3Handler(MgmLis3& mgm) {
|
|||||||
mgm.replyResult = result;
|
mgm.replyResult = result;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
mgm.ownReply.temperatureWasSet = true;
|
mgm.ownReply.temperatureWasSet = true;
|
||||||
mgm.ownReply.temperatureRaw = (rawReply[2] << 8) | rawReply[1];
|
mgm.ownReply.temperatureRaw = (rawReply[2] << 8) | rawReply[1];
|
||||||
}
|
}
|
||||||
@ -638,7 +638,7 @@ void AcsBoardPolling::mgmRm3100Handler(MgmRm3100& mgm) {
|
|||||||
acs::SimpleSensorMode mode;
|
acs::SimpleSensorMode mode;
|
||||||
bool mustPerformStartup = false;
|
bool mustPerformStartup = false;
|
||||||
{
|
{
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
mode = mgm.mode;
|
mode = mgm.mode;
|
||||||
mustPerformStartup = mgm.performStartup;
|
mustPerformStartup = mgm.performStartup;
|
||||||
}
|
}
|
||||||
@ -712,7 +712,7 @@ void AcsBoardPolling::mgmRm3100Handler(MgmRm3100& mgm) {
|
|||||||
mgm.replyResult = result;
|
mgm.replyResult = result;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MutexGuard mg(ipcLock);
|
MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
for (uint8_t idx = 0; idx < 3; idx++) {
|
for (uint8_t idx = 0; idx < 3; idx++) {
|
||||||
// Hardcoded, but note that the gain depends on the cycle count
|
// Hardcoded, but note that the gain depends on the cycle count
|
||||||
// value which is configurable!
|
// value which is configurable!
|
||||||
|
@ -22,6 +22,9 @@ class AcsBoardPolling : public SystemObject,
|
|||||||
private:
|
private:
|
||||||
enum class InternalState { IDLE, BUSY } state = InternalState::IDLE;
|
enum class InternalState { IDLE, BUSY } state = InternalState::IDLE;
|
||||||
MutexIF* ipcLock;
|
MutexIF* ipcLock;
|
||||||
|
static constexpr MutexIF::TimeoutType LOCK_TYPE = MutexIF::TimeoutType::WAITING;
|
||||||
|
static constexpr uint32_t LOCK_TIMEOUT = 20;
|
||||||
|
static constexpr char LOCK_CTX[] = "AcsBoardPolling";
|
||||||
SemaphoreIF* semaphore;
|
SemaphoreIF* semaphore;
|
||||||
std::array<uint8_t, 32> cmdBuf;
|
std::array<uint8_t, 32> cmdBuf;
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ MutexIF* DATARATE_LOCK = nullptr;
|
|||||||
MutexIF* lazyLock();
|
MutexIF* lazyLock();
|
||||||
|
|
||||||
com::Datarate com::getCurrentDatarate() {
|
com::Datarate com::getCurrentDatarate() {
|
||||||
MutexGuard mg(lazyLock());
|
MutexGuard mg(lazyLock(), MutexIF::TimeoutType::WAITING, 20, "com");
|
||||||
return DATARATE_CFG_RAW;
|
return DATARATE_CFG_RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
void com::setCurrentDatarate(com::Datarate newRate) {
|
void com::setCurrentDatarate(com::Datarate newRate) {
|
||||||
MutexGuard mg(lazyLock());
|
MutexGuard mg(lazyLock(), MutexIF::TimeoutType::WAITING, 20, "com");
|
||||||
DATARATE_CFG_RAW = newRate;
|
DATARATE_CFG_RAW = newRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ namespace torquer {
|
|||||||
static constexpr dur_millis_t TORQUE_BUFFER_TIME_MS = 20;
|
static constexpr dur_millis_t TORQUE_BUFFER_TIME_MS = 20;
|
||||||
static constexpr MutexIF::TimeoutType LOCK_TYPE = MutexIF::TimeoutType::WAITING;
|
static constexpr MutexIF::TimeoutType LOCK_TYPE = MutexIF::TimeoutType::WAITING;
|
||||||
static constexpr uint32_t LOCK_TIMEOUT = 20;
|
static constexpr uint32_t LOCK_TIMEOUT = 20;
|
||||||
|
static constexpr char LOCK_CTX[] = "torquer";
|
||||||
|
|
||||||
MutexIF* lazyLock();
|
MutexIF* lazyLock();
|
||||||
extern bool TORQUEING;
|
extern bool TORQUEING;
|
||||||
|
@ -429,7 +429,8 @@ ReturnValue_t AcsController::commandActuators(int16_t xDipole, int16_t yDipole,
|
|||||||
uint16_t rampTime) {
|
uint16_t rampTime) {
|
||||||
{
|
{
|
||||||
PoolReadGuard pg(&dipoleSet);
|
PoolReadGuard pg(&dipoleSet);
|
||||||
MutexGuard mg(torquer::lazyLock(), torquer::LOCK_TYPE, torquer::LOCK_TIMEOUT);
|
MutexGuard mg(torquer::lazyLock(), torquer::LOCK_TYPE, torquer::LOCK_TIMEOUT,
|
||||||
|
torquer::LOCK_CTX);
|
||||||
torquer::NEW_ACTUATION_FLAG = true;
|
torquer::NEW_ACTUATION_FLAG = true;
|
||||||
dipoleSet.setDipoles(xDipole, yDipole, zDipole, dipoleTorqueDuration);
|
dipoleSet.setDipoles(xDipole, yDipole, zDipole, dipoleTorqueDuration);
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@ HeaterHandler::HeaterHandler(object_id_t setObjectId_, GpioIF* gpioInterface_, H
|
|||||||
if (mainLineSwitcher == nullptr) {
|
if (mainLineSwitcher == nullptr) {
|
||||||
throw std::invalid_argument("HeaterHandler::HeaterHandler: Invalid PowerSwitchIF");
|
throw std::invalid_argument("HeaterHandler::HeaterHandler: Invalid PowerSwitchIF");
|
||||||
}
|
}
|
||||||
heaterHealthAndStateMutex = MutexFactory::instance()->createMutex();
|
handlerLock = MutexFactory::instance()->createMutex();
|
||||||
if (heaterHealthAndStateMutex == nullptr) {
|
if (handlerLock == nullptr) {
|
||||||
throw std::runtime_error("HeaterHandler::HeaterHandler: Creating Mutex failed");
|
throw std::runtime_error("HeaterHandler::HeaterHandler: Creating Mutex failed");
|
||||||
}
|
}
|
||||||
auto mqArgs = MqArgs(setObjectId_, static_cast<void*>(this));
|
auto mqArgs = MqArgs(setObjectId_, static_cast<void*>(this));
|
||||||
@ -144,7 +144,7 @@ ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t
|
|||||||
if (action == SwitchAction::SET_SWITCH_ON) {
|
if (action == SwitchAction::SET_SWITCH_ON) {
|
||||||
HasHealthIF::HealthState health;
|
HasHealthIF::HealthState health;
|
||||||
{
|
{
|
||||||
MutexGuard mg(heaterHealthAndStateMutex);
|
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
health = heater.healthDevice->getHealth();
|
health = heater.healthDevice->getHealth();
|
||||||
}
|
}
|
||||||
if (health == HasHealthIF::FAULTY or health == HasHealthIF::PERMANENT_FAULTY or
|
if (health == HasHealthIF::FAULTY or health == HasHealthIF::PERMANENT_FAULTY or
|
||||||
@ -270,7 +270,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) {
|
|||||||
} else {
|
} else {
|
||||||
triggerEvent(HEATER_WENT_ON, heaterIdx, 0);
|
triggerEvent(HEATER_WENT_ON, heaterIdx, 0);
|
||||||
{
|
{
|
||||||
MutexGuard mg(heaterHealthAndStateMutex);
|
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
heater.switchState = ON;
|
heater.switchState = ON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
|
|||||||
triggerEvent(GPIO_PULL_LOW_FAILED, result);
|
triggerEvent(GPIO_PULL_LOW_FAILED, result);
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
MutexGuard mg(heaterHealthAndStateMutex);
|
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
heater.switchState = OFF;
|
heater.switchState = OFF;
|
||||||
}
|
}
|
||||||
triggerEvent(HEATER_WENT_OFF, heaterIdx, 0);
|
triggerEvent(HEATER_WENT_OFF, heaterIdx, 0);
|
||||||
@ -346,7 +346,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers switchNr) const {
|
HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers switchNr) const {
|
||||||
MutexGuard mg(heaterHealthAndStateMutex);
|
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
return heaterVec.at(switchNr).switchState;
|
return heaterVec.at(switchNr).switchState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ object_id_t HeaterHandler::getObjectId() const { return SystemObject::getObjectI
|
|||||||
|
|
||||||
ReturnValue_t HeaterHandler::getAllSwitchStates(std::array<SwitchState, 8>& statesBuf) {
|
ReturnValue_t HeaterHandler::getAllSwitchStates(std::array<SwitchState, 8>& statesBuf) {
|
||||||
{
|
{
|
||||||
MutexGuard mg(heaterHealthAndStateMutex);
|
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (mg.getLockResult() != returnvalue::OK) {
|
if (mg.getLockResult() != returnvalue::OK) {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
@ -409,7 +409,7 @@ ReturnValue_t HeaterHandler::getAllSwitchStates(std::array<SwitchState, 8>& stat
|
|||||||
|
|
||||||
bool HeaterHandler::allSwitchesOff() {
|
bool HeaterHandler::allSwitchesOff() {
|
||||||
bool allSwitchesOrd = false;
|
bool allSwitchesOrd = false;
|
||||||
MutexGuard mg(heaterHealthAndStateMutex);
|
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
/* Or all switches. As soon one switch is on, allSwitchesOrd will be true */
|
/* Or all switches. As soon one switch is on, allSwitchesOrd will be true */
|
||||||
for (power::Switch_t switchNr = 0; switchNr < heater::NUMBER_OF_SWITCHES; switchNr++) {
|
for (power::Switch_t switchNr = 0; switchNr < heater::NUMBER_OF_SWITCHES; switchNr++) {
|
||||||
allSwitchesOrd = allSwitchesOrd || heaterVec.at(switchNr).switchState;
|
allSwitchesOrd = allSwitchesOrd || heaterVec.at(switchNr).switchState;
|
||||||
@ -442,7 +442,7 @@ uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 2000; }
|
|||||||
HasHealthIF::HealthState HeaterHandler::getHealth(heater::Switchers heater) {
|
HasHealthIF::HealthState HeaterHandler::getHealth(heater::Switchers heater) {
|
||||||
auto* healthDev = heaterVec.at(heater).healthDevice;
|
auto* healthDev = heaterVec.at(heater).healthDevice;
|
||||||
if (healthDev != nullptr) {
|
if (healthDev != nullptr) {
|
||||||
MutexGuard mg(heaterHealthAndStateMutex);
|
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
return healthDev->getHealth();
|
return healthDev->getHealth();
|
||||||
}
|
}
|
||||||
return HasHealthIF::HealthState::FAULTY;
|
return HasHealthIF::HealthState::FAULTY;
|
||||||
|
@ -136,7 +136,10 @@ class HeaterHandler : public ExecutableObjectIF,
|
|||||||
|
|
||||||
HeaterMap heaterVec = {};
|
HeaterMap heaterVec = {};
|
||||||
|
|
||||||
MutexIF* heaterHealthAndStateMutex = nullptr;
|
MutexIF* handlerLock = nullptr;
|
||||||
|
static constexpr MutexIF::TimeoutType LOCK_TYPE = MutexIF::TimeoutType::WAITING;
|
||||||
|
static constexpr uint32_t LOCK_TIMEOUT = 20;
|
||||||
|
static constexpr char LOCK_CTX[] = "HeaterHandler";
|
||||||
|
|
||||||
HeaterHelper helper;
|
HeaterHelper helper;
|
||||||
ModeHelper modeHelper;
|
ModeHelper modeHelper;
|
||||||
|
@ -214,7 +214,8 @@ ReturnValue_t ImtqHandler::buildCommandFromCommand(DeviceCommandId_t deviceComma
|
|||||||
<< ", y = " << dipoleSet.yDipole.value << ", z = " << dipoleSet.zDipole.value
|
<< ", y = " << dipoleSet.yDipole.value << ", z = " << dipoleSet.zDipole.value
|
||||||
<< ", duration = " << dipoleSet.currentTorqueDurationMs.value << std::endl;
|
<< ", duration = " << dipoleSet.currentTorqueDurationMs.value << std::endl;
|
||||||
}
|
}
|
||||||
MutexGuard mg(torquer::lazyLock(), torquer::LOCK_TYPE, torquer::LOCK_TIMEOUT);
|
MutexGuard mg(torquer::lazyLock(), torquer::LOCK_TYPE, torquer::LOCK_TIMEOUT,
|
||||||
|
torquer::LOCK_CTX);
|
||||||
torquer::TORQUEING = true;
|
torquer::TORQUEING = true;
|
||||||
torquer::TORQUE_COUNTDOWN.setTimeout(dipoleSet.currentTorqueDurationMs.value);
|
torquer::TORQUE_COUNTDOWN.setTimeout(dipoleSet.currentTorqueDurationMs.value);
|
||||||
rawPacket = commandBuffer;
|
rawPacket = commandBuffer;
|
||||||
|
@ -5,7 +5,7 @@ Stack5VHandler::Stack5VHandler(PowerSwitchIF& switcher) : switcher(switcher) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander, bool updateStates) {
|
ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander, bool updateStates) {
|
||||||
MutexGuard mg(stackLock);
|
MutexGuard mg(stackLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (updateStates) {
|
if (updateStates) {
|
||||||
updateInternalStates();
|
updateInternalStates();
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander, bool updateSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander, bool updateStates) {
|
ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander, bool updateStates) {
|
||||||
MutexGuard mg(stackLock);
|
MutexGuard mg(stackLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (updateStates) {
|
if (updateStates) {
|
||||||
updateInternalStates();
|
updateInternalStates();
|
||||||
}
|
}
|
||||||
@ -55,12 +55,12 @@ ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander, bool updateS
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Stack5VHandler::isSwitchOn() {
|
bool Stack5VHandler::isSwitchOn() {
|
||||||
MutexGuard mg(stackLock);
|
MutexGuard mg(stackLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
return updateInternalStates();
|
return updateInternalStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stack5VHandler::update() {
|
void Stack5VHandler::update() {
|
||||||
MutexGuard mg(stackLock);
|
MutexGuard mg(stackLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||||
updateInternalStates();
|
updateInternalStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,11 @@ class Stack5VHandler {
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static constexpr MutexIF::TimeoutType LOCK_TYPE = MutexIF::TimeoutType::WAITING;
|
||||||
|
static constexpr uint32_t LOCK_TIMEOUT = 20;
|
||||||
|
|
||||||
MutexIF* stackLock;
|
MutexIF* stackLock;
|
||||||
|
static constexpr char LOCK_CTX[] = "Stack5VHandler";
|
||||||
PowerSwitchIF& switcher;
|
PowerSwitchIF& switcher;
|
||||||
bool switchIsOn = false;
|
bool switchIsOn = false;
|
||||||
bool targetState = false;
|
bool targetState = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user