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


Python Driver.read_position方法代码示例

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


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

示例1: main

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import read_position [as 别名]
def main():
	message_handler = MessageHandler()
	driver = Driver()

	#my_id = get IP address on this computer
	my_id = 3
	acknowledge = 4
	run_floor = 0
	run_button = 0
	old_f = None
	old_but = None

	floor_up = [0]*4
	floor_down = [0]*4

	while True:
		
		
		position = driver.read_position()


		

		master_message = message_handler.receive_from_master()
		
		for i in range (0,4):
			if (master_message['master_floor_up'][i] == 0):
				floor_up[i] = 0

			if (master_message['master_floor_down'][i] == 0):
				floor_down[i] = 0
		
		time.sleep(0.1)

		(floor,button) = driver.pop_floor_panel_queue()

		if floor is not None:
			if button == 0:
				floor_up[floor] = 1
			elif button == 1: 
				floor_down[floor] = 1 	

		message_handler.send_to_master(floor_up,floor_down,my_id,position[0],position[1],position[2],master_message['queue_id'])
		

		print floor_up
		print floor_down



		(run_floor,run_button) = message_handler.get_my_master_order()
		
		print run_floor
		print run_button

		if run_floor is not None:
			driver.queue_elevator_run(run_floor,run_button)	
		


		
		
		

		print ['floor_up:'] + master_message['master_floor_up'] + ['floor_down:'] + master_message['master_floor_down'] 
		#print master_message['queue_id']
				


		time.sleep(0.5)

		'''
开发者ID:project6381,项目名称:sigurdoy,代码行数:74,代码来源:stupid_slave.py


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