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:
2025-09-09 14:33:33 +08:00
parent 67b1a7fe80
commit 2de8f53ae2

View File

@@ -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;