Refactor switch state handling in CustomRobot::processOacCmd method. Updated logic to store the toggled state in a variable before passing it to SwitchSet, improving code clarity and maintainability.
This commit is contained in:
@@ -271,7 +271,8 @@ bool CustomRobot::processOacCmd(const std::string& cmd, const nlohmann::json& me
|
|||||||
}
|
}
|
||||||
LOG_INFO("Current switch state: " + std::string(currentEnable ? "true" : "false"));
|
LOG_INFO("Current switch state: " + std::string(currentEnable ? "true" : "false"));
|
||||||
// switch to opposite state
|
// switch to opposite state
|
||||||
return controller_->SwitchSet(!currentEnable);
|
bool enable = !currentEnable;
|
||||||
|
return controller_->SwitchSet(enable);
|
||||||
|
|
||||||
} else if (cmd == "SwitchGet") {
|
} else if (cmd == "SwitchGet") {
|
||||||
bool enable = false;
|
bool enable = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user