当前位置: 首页>>代码示例>>Python>>正文


Python Resources.get_cell_robot_name方法代码示例

本文整理汇总了Python中Resources.get_cell_robot_name方法的典型用法代码示例。如果您正苦于以下问题:Python Resources.get_cell_robot_name方法的具体用法?Python Resources.get_cell_robot_name怎么用?Python Resources.get_cell_robot_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Resources的用法示例。


在下文中一共展示了Resources.get_cell_robot_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cell_status

# 需要导入模块: import Resources [as 别名]
# 或者: from Resources import get_cell_robot_name [as 别名]
def cell_status(c_status):
    log_write(str(datetime.datetime.today()) + '\n')
    log_write("  Message from cell:\n")
    for k, v in c_status.items():
        if k != 'version_id' and k != 'time':
            print k, ' = ', v
            log_write("    " + str(k) + " = " + str(v) + '\n')

    # Save state information
    cell_id = c_status['robot_id']
    resource_handler.get_cell_robot(cell_id).alive = True
    robot_name = Resources.get_cell_robot_name(cell_id)
    order = resource_handler.get_cell_robot(cell_id).bound_to_order
    if order != 0:
        print robot_name, ' is working on order #', order.order['order_id']
        if c_status['state'] == 'STATE_FREE':
            command = resource_handler.get_command_c_free(robot_name, c_status)

            if command == 0:
                command = {
                    'command': 'COMMAND_WAIT'
                }
                print robot_name, ' is waiting\n'

        elif c_status['state'] == 'STATE_SORTING':
            print robot_name, ' is sorting\n'
            command = resource_handler.get_command_c_sorting(robot_name)
            if command == 0:
                command = {
                    'command': 'COMMAND_WAIT'
                }
                print robot_name, ' is waiting\n'

        elif c_status['state'] == 'STATE_ORDERSORTED':
            print robot_name, ' is done sorting\n'
            command = resource_handler.get_command_c_done_sorting(robot_name)
            if command == 0:
                command = {
                    'command': 'COMMAND_WAIT'
                }
                print robot_name, ' is waiting\n'

        elif c_status['state'] == 'STATE_OUTOFBRICKS':
            print robot_name, ' is out of bricks\n'
            command = resource_handler.get_command_c_out_of_bricks(robot_name)
            if command == 0:
                command = {
                    'command': 'COMMAND_WAIT'
                }
                print robot_name, ' is waiting\n'

        elif c_status['state'] == 'STATE_LOADING':
            print robot_name, ' is loading bricks\n'
            command = resource_handler.get_command_c_loading_bricks(robot_name)
            if command == 0:
                command = {
                    'command': 'COMMAND_WAIT'
                }
                print robot_name, ' is waiting\n'

        elif c_status['state'] == 'STATE_ERROR':
            print robot_name, ' has encountered an error! ABORTING...\n'
            command = dict(command='COMMAND_ABORT')

        else:
            print robot_name, ': Error in states! ABORTING...\n'
            command = dict(command='COMMAND_ABORT')
    else:
        if c_status['state'] == 'STATE_FREE':

            command = {
                'command': 'COMMAND_WAIT'
            }
            print robot_name, ' is waiting\n'

        elif c_status['state'] == 'STATE_ORDERSORTED':  # shouldn't happen
            print robot_name, ': Error in states! ABORTING...\n'
            command = dict(command='COMMAND_ABORT')

        elif c_status['state'] == 'STATE_LOADING':  # shouldn't happen
            print robot_name, ': Error in states! ABORTING...\n'
            command = dict(command='COMMAND_ABORT')

        elif c_status['state'] == 'STATE_ERROR':
            print robot_name, ' has encountered an error! ABORTING...\n'
            command = dict(command='COMMAND_ABORT')

        else:
            print robot_name, ': Error in states! ABORTING...\n'
            command = dict(command='COMMAND_ABORT')

    log_write("  Returning command:\n")
    for k, v in command.items():
        log_write("    " + str(k) + " = " + str(v) + '\n')
    return command
开发者ID:Prier,项目名称:mes-server,代码行数:97,代码来源:Server.py


注:本文中的Resources.get_cell_robot_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。