The robot checks how much charge is left in the battery by querying the IBS. If the charge left returned by the IBS is greater than 10%, the robot turns on the cleaning system and turns off the recharging LED. When the charge left is equal to or less than 10%, the robot turns on the recharging LED and turns off the cleaning system.
The communication with the IBS happens via the IC2 protocol. To get the charge left as read from the IBS, access the instance variable CleaningRobot.ibs and then the method IBS.get_charge_left(self) -> int (which returns the charge left in the battery, expressed as a percentage value). Note that the IBS has already been configured in the constructor of the CleaningRobot class.
The recharge LED is connected to pin 12 (BOARD mode), while the cleaning system is connected to pin 13 (BOARD mode). The communication with the LED or the cleaning system happens via the GPIO.output(channel, value) function where channel is the pin and value is False | True. Note that the LED and the cleaning system have already been configured in the constructor of the CleaningRobot class.
Finally, to keep track of the statuses (i.e., on vs off) of the LED and the cleaning system, use the boolean instance variables SmartRoom.recharge_led_on and SmartRoom.cleaning_system_on, respectively.
Requirement:
- Implement
CleaningRobot.manage_cleaning_system(self) -> None to manage the behavior related to the cleaning system (and recharging LED).
Tip:
- If you need to verify that more calls to the same function (or method) have taken place with certain arguments, use
Mock.assert_has_calls(calls, any_order).
The robot checks how much charge is left in the battery by querying the IBS. If the charge left returned by the IBS is greater than 10%, the robot turns on the cleaning system and turns off the recharging LED. When the charge left is equal to or less than 10%, the robot turns on the recharging LED and turns off the cleaning system.
The communication with the IBS happens via the IC2 protocol. To get the charge left as read from the IBS, access the instance variable
CleaningRobot.ibsand then the methodIBS.get_charge_left(self) -> int(which returns the charge left in the battery, expressed as a percentage value). Note that the IBS has already been configured in the constructor of theCleaningRobotclass.The recharge LED is connected to pin 12 (BOARD mode), while the cleaning system is connected to pin 13 (BOARD mode). The communication with the LED or the cleaning system happens via the
GPIO.output(channel, value)function wherechannelis the pin andvalueisFalse | True. Note that the LED and the cleaning system have already been configured in the constructor of theCleaningRobotclass.Finally, to keep track of the statuses (i.e., on vs off) of the LED and the cleaning system, use the boolean instance variables
SmartRoom.recharge_led_onandSmartRoom.cleaning_system_on, respectively.Requirement:
CleaningRobot.manage_cleaning_system(self) -> Noneto manage the behavior related to the cleaning system (and recharging LED).Tip:
Mock.assert_has_calls(calls, any_order).