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


Python Resources.get_mobile_robot_name方法代码示例

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


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

示例1: mobile_status

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

    robot_id = m_status['robot_id']
    resource_handler.get_mobile_robot(robot_id).alive = True
    robot_name = Resources.get_mobile_robot_name(robot_id)
    order = resource_handler.get_mobile_robot(robot_id).bound_to_order
    if not resource_handler.resources.has_key(m_status['position']):
        print(robot_name + ' is at unknown position ' + m_status['position'])
        command = dict(command='COMMAND_WAIT')
    elif order != 0:
        print robot_name, ' is working on order #', resource_handler.resources[robot_name].bound_to_order.order['order_id']

        if m_status['state'] == 'STATE_FREE' or m_status['state'] == 'STATE_WORKING':
            command = resource_handler.get_command_m(robot_name, m_status, dispenser, finish_order, log_name)

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

        elif m_status['state'] == 'STATE_ERROR':
            command = dict(command='COMMAND_ABORT')

        else:
            command = dict(command='COMMAND_ABORT')
    else:
        if m_status['state'] == 'STATE_FREE' or m_status['state'] == 'STATE_WORKING':
            print robot_name, ' is available\n'

            new_order = resource_handler.get_order(robot_name, m_status, order_queue)
            print new_order
            if new_order != 0:
                print ' ', new_order.status, ' ', new_order.allocated_cell, ' ', new_order.allocated_robot
            command = 0
            if new_order != 0:
                command = resource_handler.get_command_m(robot_name, m_status, dispenser, finish_order, log_name)
                print command
            else:
                command = resource_handler.get_return_to_station_command(m_status)

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

        #elif m_status['state'] == 'STATE_WORKING':  # This shouldn't happen
        #    print robot_name, ' is working\n'
        #    command = dict(command='COMMAND_ABORT')

        elif m_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,代码行数:72,代码来源:Server.py


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