class Device: def __init__(self, device): self._GeneralCommands = { GeneralCommand.GetDeviceInformation: None, GeneralCommand.SetVoltage: None, GeneralCommand.GetVoltage: None, GeneralCommand.SetCurrent: None, GeneralCommand.GetCurrent: None, GeneralCommand.SelectChannel: None, GeneralCommand.SetOutput: None, } self.__device = Communication(device) def __SelectChannel(self, channel): self.__device.Write( self._GeneralCommands[GeneralCommand.SelectChannel] % channel) def SetVoltage(self, channel, voltage): self.__SelectChannel(channel) self.__device.Write(self._GeneralCommands[GeneralCommand.SetVoltage] % voltage) def GetVoltage(self, channel): self.__SelectChannel(channel) self.__device.Write(self._GeneralCommands[GeneralCommand.GetVoltage]) val = self.__device.Read( self._GeneralCommands[GeneralCommand.GetVoltage].length) print "val=" + str(val) def SetCurrent(self, channel, current): pass def GetCurrent(self, channel): pass def SetOutput(self, channel, state): self.__SelectChannel(channel) self.__device.Write(self._GeneralCommands[GeneralCommand.SetOutput] % state)