本文整理汇总了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