Example #1
0
def startTest(threads, conn):
	thr_index = getFreeThreads(threads)
	if thr_index == None:
		msg = {'item': 'waiting', 'result': 'The connection has reached its limit'}
		print msg
		my_websocket.send_data(conn, json.dumps(msg))
		conn.close()
		return
	threads[thr_index] = threading.Thread(target = thread_func,
									args = (portS+thr_index, portC+thr_index, conn))
	print '[%d] thread can use, start' % thr_index
	threads[thr_index].start()
Example #2
0
def startTest(threads, conn):
    thr_index = getFreeThreads(threads)
    if thr_index == None:
        msg = {
            'item': 'waiting',
            'result': 'The connection has reached its limit'
        }
        print msg
        my_websocket.send_data(conn, json.dumps(msg))
        conn.close()
        return
    threads[thr_index] = threading.Thread(target=thread_func,
                                          args=(portS + thr_index,
                                                portC + thr_index, conn))
    print '[%d] thread can use, start' % thr_index
    threads[thr_index].start()
Example #3
0
    def testPowerMeter(self, socket_udp, dev_info, dev_id, dev_index, conn):
        cmd = "reqPowerMeter"
        dev_type = "recorder"
        outputInfo("*** Test PowerMeter")
        if not dev_info or not dev_info.has_key(dev_type):
            return False

        cnt_error = 0
        value_left_bak = '0'
        value_right_bak = '0'
        stat = {
            "dev_id": dev_id,
            "dev_index": dev_index,
            "item": 'pm_data',
            "result": None
        }
        for i in range(num_pm_test):
            data = self.testBase(socket_udp, (dev_info[dev_type], port_udp_to), dev_type, \
              dev_id, cmd)
            if not data or not data.has_key('value_left') or not data.has_key(
                    'value_right'):
                outputInfo("Error: near power meter")
                # cnt_error += 1
                # continue
                cnt_error = num_pm_test
                break
            if data['value_left'] == "-inf" or data['value_right'] == "-inf":
                cnt_error += 1
                continue

            value_left = data['value_left']
            value_right = data['value_right']
            if value_left == value_left_bak or value_right == value_left_bak:
                cnt_error += 1
            value_left_bak = value_left
            value_right_bak = value_right

            stat['result'] = (value_left, value_right)
            my_websocket.send_data(conn, json.dumps(stat))

            time.sleep(time_pm_interval)

        if cnt_error > (num_pm_test / 2):
            return False
        return True
Example #4
0
	def testPowerMeter(self, socket_udp, dev_info, dev_id, dev_index, conn):
		cmd = "reqPowerMeter"
		dev_type = "recorder"
		outputInfo("*** Test PowerMeter")
		if not dev_info or not dev_info.has_key(dev_type):
			return False

		cnt_error = 0
		value_left_bak = '0'
		value_right_bak = '0'
		stat = {"dev_id":dev_id, "dev_index":dev_index, "item": 'pm_data', "result": None}
		for i in range(num_pm_test):
			data = self.testBase(socket_udp, (dev_info[dev_type], port_udp_to), dev_type, \
					dev_id, cmd)
			if not data or not data.has_key('value_left') or not data.has_key('value_right'):
				outputInfo("Error: near power meter")
				# cnt_error += 1
				# continue
				cnt_error = num_pm_test
				break
			if data['value_left'] == "-inf" or data['value_right'] == "-inf":
				cnt_error += 1
				continue

			value_left = data['value_left']
			value_right = data['value_right']
			if value_left == value_left_bak or value_right == value_left_bak:
				cnt_error += 1
			value_left_bak = value_left
			value_right_bak = value_right

			stat['result'] = (value_left, value_right)
			my_websocket.send_data(conn, json.dumps(stat))

			time.sleep(time_pm_interval)

		if cnt_error > (num_pm_test / 2):
			return False
		return True
Example #5
0
	def testOneDevice(self, socket_broadcast, socket_udp, dev_index, dev_id, conn):
		res = True
		stat = {"dev_id":dev_id, "dev_index":dev_index, "item": '', "result": 'T'}

		stat['item'] = 'flag'
		stat['result'] = 'start'
		my_websocket.send_data(conn, json.dumps(stat))

		dev_info = getDeviceInfo(socket_broadcast, dev_id)
		if not verifyDeviceInfo(dev_info):
			res = False
			stat['result'] = 'F'
		else:
			stat['result'] = 'T'
		stat['item'] = 'ScanIP'
		my_websocket.send_data(conn, json.dumps(stat))

		if not self.testMixture(socket_udp, dev_info, dev_index, dev_id):
			res = False
			stat['result'] = 'F'
		else:
			stat['result'] = 'T'
		stat['item'] = 'Mixture'
		my_websocket.send_data(conn, json.dumps(stat))

		if not self.testStatus(socket_udp, dev_info, dev_id):
			res = False
			stat['result'] = 'F'
		else:
			stat['result'] = 'T'
		stat['item'] = 'Status'
		my_websocket.send_data(conn, json.dumps(stat))

		if not self.testGain(socket_udp, dev_info, dev_index, dev_id):
			res = False
			stat['result'] = 'F'
		else:
			stat['result'] = 'T'
		stat['item'] = 'Gain'
		my_websocket.send_data(conn, json.dumps(stat))

		if not self.testPowerMeter(socket_udp, dev_info, dev_id, dev_index, conn):
			res = False
			stat['result'] = 'F'
		else:
			stat['result'] = 'T'
		stat['item'] = 'PowerMeter'
		my_websocket.send_data(conn, json.dumps(stat))

		if not self.testReverbSW(socket_udp, dev_info, dev_id):
			res = False
			stat['result'] = 'F'
		else:
			stat['result'] = 'T'
		stat['item'] = 'ReverbSW'
		my_websocket.send_data(conn, json.dumps(stat))

		if not res:
				stat['result'] = 'F'
		else:
			stat['result'] = 'T'
		stat['item'] = 'Total'
		my_websocket.send_data(conn, json.dumps(stat))

		return res
Example #6
0
    def testOneDevice(self, socket_broadcast, socket_udp, dev_index, dev_id,
                      conn):
        res = True
        stat = {
            "dev_id": dev_id,
            "dev_index": dev_index,
            "item": '',
            "result": 'T'
        }

        stat['item'] = 'flag'
        stat['result'] = 'start'
        my_websocket.send_data(conn, json.dumps(stat))

        dev_info = getDeviceInfo(socket_broadcast, dev_id)
        if not verifyDeviceInfo(dev_info):
            res = False
            stat['result'] = 'F'
        else:
            stat['result'] = 'T'
        stat['item'] = 'ScanIP'
        my_websocket.send_data(conn, json.dumps(stat))

        if not self.testMixture(socket_udp, dev_info, dev_index, dev_id):
            res = False
            stat['result'] = 'F'
        else:
            stat['result'] = 'T'
        stat['item'] = 'Mixture'
        my_websocket.send_data(conn, json.dumps(stat))

        if not self.testStatus(socket_udp, dev_info, dev_id):
            res = False
            stat['result'] = 'F'
        else:
            stat['result'] = 'T'
        stat['item'] = 'Status'
        my_websocket.send_data(conn, json.dumps(stat))

        if not self.testGain(socket_udp, dev_info, dev_index, dev_id):
            res = False
            stat['result'] = 'F'
        else:
            stat['result'] = 'T'
        stat['item'] = 'Gain'
        my_websocket.send_data(conn, json.dumps(stat))

        if not self.testPowerMeter(socket_udp, dev_info, dev_id, dev_index,
                                   conn):
            res = False
            stat['result'] = 'F'
        else:
            stat['result'] = 'T'
        stat['item'] = 'PowerMeter'
        my_websocket.send_data(conn, json.dumps(stat))

        if not self.testReverbSW(socket_udp, dev_info, dev_id):
            res = False
            stat['result'] = 'F'
        else:
            stat['result'] = 'T'
        stat['item'] = 'ReverbSW'
        my_websocket.send_data(conn, json.dumps(stat))

        if not res:
            stat['result'] = 'F'
        else:
            stat['result'] = 'T'
        stat['item'] = 'Total'
        my_websocket.send_data(conn, json.dumps(stat))

        return res