def __init__(self, serial_name):
""" Initialize the power supply.
Each children an here define non-default values for his specific case
Input : serial_name, String, is the serial port name (e.g. COM2)
"""
self.name = "Generic Power Supply"
self.port = serial_name
self.baudrate = 9600 # Default baud rate
""" Possible baudrate values :
50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200,
230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000
"""
self.timeout = 1 # Default timeout, seconds
self.parity = serial.PARITY_NONE # Default parity
""" Possible parities :
PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE
"""
self.stopbits = serial.STOPBITS_ONE # Default stop bits
""" Possible stopbits :
STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO
"""
self.bytesize = serial.EIGHTBITS
""" Possible bytesizes :
FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS
"""
self.ser = serial.Serial(self.port, self.baudrate, self.bytesize, self.parity, self.stopbits, timeout=self.timeout) # serial port
self.max_voltage = 0.0 # Volts
self.max_current = 0.0 # Amps
self.max_power = 0.0 # Watts
评论列表
文章目录