__init__.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:pyirobot 作者: cseelye 项目源码 文件源码
def SetSchedule(self, newSchedule):
        """
        Set the cleaning schedule for this robot.
        The easiest way to use this function is to call GetSchedule, modify
        the result, and use that as the input to this function

        Args:
            schedule:   the schedule to set (dict)
        """
        # Sort calendar day names into the order the robot expects
        days = {}
        for cal_idx, dayname in enumerate(calendar.day_name):
            idx = cal_idx + 1 if cal_idx < 6 else 0
            days[idx] = dayname

        sched = collections.OrderedDict([
            ("cycle", []),
            ("h", []),
            ("m", [])
        ])
        for idx in sorted(days):
            dayname = days[idx]
            if newSchedule[dayname]["clean"]:
                sched["cycle"].append("start")
            else:
                sched["cycle"].append("none")
            sched["h"].append(newSchedule[dayname]["startTime"].hour)
            sched["m"].append(newSchedule[dayname]["startTime"].minute)

        self._PostToRobot("set", ["week", sched])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号