Example #1
0
def testStart():
	global cnt_test
	global cnt_error
	global device_id

	socket_broadcast = getBroadcastSocket(host, portS)
	socket_udp = getUDPSocket(host, portC)
	dev_id = device_id
	value_left = None
	value_right = None
	while True:
		cnt_test += 1
		outputInfo ("[%02d] device ID : %s   %s"
		% (cnt_test, dev_id, time.strftime("%Y-%m-%d %H:%M:%S", \
			time.localtime())))
		result = testOneDevice(socket_broadcast, socket_udp, cnt_test, dev_id)
		dev_info = None
		if result:
			dev_info = result["dev_info"]
			value_left = result["res_powermater"]["value_left"]
			value_right = result["res_powermater"]["value_right"]
		else:
			cnt_error += 1
		printInerface.printTitle(cnt_test)
		printInerface.printInfo(value_left, value_right)

		time.sleep(time_interval)
Example #2
0
def testStart():
    global cnt_test
    global cnt_error
    socket_broadcast = getBroadcastSocket(host, portS)
    socket_udp = getUDPSocket(host, portC)
    dev_id = devices_id[0]
    value_left = None
    value_right = None
    while True:
        cnt_test += 1
        outputInfo ("[%02d] device ID : %s   %s"
        % (cnt_test, dev_id, time.strftime("%Y-%m-%d %H:%M:%S", \
         time.localtime())))
        result = testOneDevice(socket_broadcast, socket_udp, cnt_test, dev_id)
        dev_info = None
        if result:
            dev_info = result["dev_info"]
            value_left = result["res_powermater"]["value_left"]
            value_right = result["res_powermater"]["value_right"]
        else:
            cnt_error += 1
        printInerface.printTitle(dev_id, time_interval, cnt_error, cnt_test)
        printInerface.printInfo(value_left, value_right)

        time.sleep(time_interval)
Example #3
0
def scan():
	devs_id = loadDeviceID(file_deviceid)
	if not devs_id:
		outputInfo("Error: No device id.")
		return None
	printInerface.init(len(devs_id), time_interval)
	printInerface.printOutput("Start Test!")
	# return 
	socket_broadcast = getBroadcastSocket(host, portS)
	# socket_udp = getUDPSocket(host, portC)
	cnt_test = 0
	dict_devinfo = {}
	for dev_id in devs_id:
		dict_devinfo[dev_id] = None

	while True:
		cnt_test += 1
		printInerface.printTitle(len(devs_id), time_interval, cnt_test)
		for index, dev_id in enumerate(devs_id):
			outputInfo ("[%02d] device ID : %s   %s"
			% (cnt_test, dev_id, time.strftime("%Y-%m-%d %H:%M:%S", \
				time.localtime())))
			dev_info = getDeviceInfo(socket_broadcast, dev_id)
			state = verifyDeviceInfo(dev_info, dict_devinfo[dev_id])
			printInerface.printInfo(dev_id, devinfoToStr(dev_info), index, state)
			dict_devinfo[dev_id] = dev_info
			time.sleep(0.01)

		time.sleep(time_interval)