testDevice.py 1.22 KB
from abstract_instrument import abstract_instrument
import numpy, time

#==============================================================================

ALL_VAL_TYPE = "DCV, ACV, DCI, ACI, RES2W, RES4W, FREQ"

#==============================================================================

class testDevice(abstract_instrument):
	def __init__(self, adress="123.456.789.123", vtype="DCV"):
		self.adress = adress
		self.port = 9999
		self.vtype = vtype

	def model(self):
		return 'test device'

	def connect(self):
		print('Connecting to device @%s:%s...' %(self.adress, self.port))
		time.sleep(1)
		print('  --> Ok')

		print(self.model())

		if self.vtype == "DCV":
			print("CONF:VOLT:DC")
		elif self.vtype == "ACV":
			print("CONF:VOLT:AC")
		elif self.vtype == "DCI":
			print("CONF:CURR:DC")
		elif self.vtype == "ACI":
			print("CONF:CURR:AC")
		elif self.vtype == "RES2W":
			print("CONF:RES")
		elif self.vtype == "RES4W":
			print("CONF:FRES")
		elif self.vtype == "FREQ":
			print("CONF:FREQ")
		else:
			print("Wrong -v argument")
			raise

	def getValue(self):
		return str(numpy.random.rand())

	def read(self):
		print('reading')
		return 1

	def disconnect(self):
		print('reset')

	def send(self, command):
		print('send %s'%command)