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


Python Arduino.get_is_door_open方法代码示例

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


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

示例1: main

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import get_is_door_open [as 别名]
def main():
	network_clients_sh = path.join(path.dirname(__file__), 'networkClientsInNetwork.sh')
	config_path = path.join(path.dirname(__file__), 'config.json')
	print config_path
	print network_clients_sh
	with open(config_path) as config_fh:
		config = json.load(config_fh)

	args = get_args()
	is_live_run = args["productive_system"]

	base_url = config["URL"]
	security_token = config["KEY"]
	port = config["TTY"]

	poster = Poster()
	if is_live_run:
		cprint("Live run!", color="magenta")
		delay = 300
	else:
		cprint("Test run!", color="green")
		delay = 3

	arduino = Arduino(port=port)
	arduino.start()
	time.sleep(15)

	network_clients_count = None

	while True:
		is_door_open = arduino.get_is_door_open()
		temperature = arduino.get_temperature()
		recieved = arduino.get_last_recieved()

		nmap = subprocess.Popen(network_clients_sh, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
		network_clients_count = int(nmap.stdout.readlines()[0])

		poster.post_door_state(base_url, is_door_open, security_token)
		poster.post_temperature(base_url, str(temperature), security_token)
		poster.post_clients(base_url, str(network_clients_count), security_token)

		cprint(str(datetime.datetime.now().strftime('%G-%b-%d-%H:%M:%S')), color="red")
		cprint("Nmap " + str(network_clients_count), color="blue")
		cprint("Tür offen: " + str(is_door_open), color="yellow")
		cprint("Temperatur: " + str(temperature), color="cyan")
		print recieved
		print ("\n")

		time.sleep(delay)
开发者ID:jupishamburg,项目名称:LGSStatus,代码行数:51,代码来源:run.py


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