def config2_cmd(self, command): ps.gom_logger.debug("Running config2_cmd with command=%s", command) if command not in [1, 2]: ps.gom_logger.error("Invalid Input: command must be 1 or 2") raise PowerInputError("Invalid Input: command must be 1 or 2") else: self.write(CMD_CONFIG2_CMD, [command])
def config_cmd(self, command): ps.gom_logger.debug("Running config_cmd: restoring default config") if command != 1: ps.gom_logger.error("Invalid input: command must be 1") raise PowerInputError("Invalid Input: command must be 1") else: self.write(CMD_CONFIG_CMD, [command])
def set_pv_auto(self, mode): ps.gom_logger.debug("Setting solar cell power tracking to mode %i", mode) if mode not in [0, 1, 2]: raise PowerInputError("Invalid Input: mode must be 0, 1 or 2") else: self.write(CMD_SET_PV_AUTO, [mode])
def set_heater(self, command, heater, mode): ps.gom_logger.debug("Setting heater %i to mode %i", heater, mode) if command != 0 or heater not in [0, 1, 2] and mode not in [0, 1]: ps.gom_logger.error( "Invalid Input: command must be 0,heater must be 0, 1 or 2, and mode must be 0 or 1" ) raise PowerInputError("""Invalid Input: command must be 0, heater must be 0, 1 or 2, and mode must be 0 or 1""") else: self.write(CMD_SET_HEATER, [command, heater, mode]) return self.read(2)
def set_pv_volt(self, volt1, volt2, volt3): ps.gom_logger.debug("Setting PV voltage: %s, %s, %s", volt1, volt2, volt3) if volt1 > MAX_PV_VOLTAGE or volt2 > MAX_PV_VOLTAGE or volt3 > MAX_PV_VOLTAGE: ps.gom_logger.error( "PV volt is attempting to be set above MAX_PV_VOLTAGE") raise PowerInputError( "Invalid Input: voltages must be below %i mV" % MAX_PV_VOLTAGE) else: v = bytearray(6) v[0:2] = ps.toBytes(volt1, 2) v[2:4] = ps.toBytes(volt2, 2) v[4:] = ps.toBytes(volt3, 2) self.write(CMD_SET_PV_VOLT, list(v))
def set_single_output(self, channel, value, delay): ps.gom_logger.debug( "Setting single channel %s output to value %s after delay %s", channel, value, delay, ) if value not in [0, 1]: raise PowerInputError("Invalid Input: value must be 0 or 1") else: channel_num = GomOutputs[channel].value d = ps.toBytes(delay, 2) self.write(CMD_SET_SINGLE_OUTPUT, [channel_num, value] + list(d))