示例#1
0
	def get_port_counter(self, unit, module, port_number, counter_name):
		"""Get a port counter value
		
		:param unit: the unit (generator) number as a string to be selected
		:param module: the module (network card) number as a string to be selected
		:param port_number: the port number as a string to be selected
		:param counter_name: the counter that needs to be checked

		"""
		self.select = port.select(unit, module, port_number)
		self.send_msg(self.select)
		self.counter = port.read(counter_name)
		data = self.send_recv_msg(self.counter)
		datasplit = str.split(data, ',')
		counter_value = datasplit[1]
		print('requested counter field = ' + counter_value)
		return int(counter_value)
示例#2
0
	def test_port_counter(self, unit, module, port_number, counter_name, val1, val2):
		"""Get the port counter values and test if its between the expected range
		
		:param unit: the unit (generator) number as a string to be selected
		:param module: the module (network card) number as a string to be selected
		:param port_number: the port number as a string to be selected
		:param counter_name: the counter that needs to be checked
		:param val1: the value where the range starts
		:param val2: the value where the range ends

		"""
		self.select = port.select(unit, module, port_number)
		self.send_msg(self.select)
		self.counter = port.read(counter_name)
		data = self.send_recv_msg(self.counter)
		datasplit = str.split(data, ',')
		counter_value = datasplit[1]
		if int(counter_value) < val1 or int(counter_value) > val2:
			print('out of range, result = ' + counter_value)
			return False
		else:
			#print('in range, requested counter field = ' + counter_value)
			return True