package net.northking.cctp.upperComputer.driver.agent.command.data;

import java.io.DataInput;
import java.io.IOException;

/**
 * 电池数据
 * <br>
 * 含有一些厂商的特殊数据
 */
public class BatteryData {
    public static final int INVALID_VALUE = Integer.MIN_VALUE;

    private String technology = "";
    private int iconSmall = INVALID_VALUE;
    private int maxChargingVoltage = INVALID_VALUE;
    private int wirelessDeviatedChgType = INVALID_VALUE;
    private int health = INVALID_VALUE;

    //oppo framework only
    private int notifyCode = INVALID_VALUE;
    private int maxChargingCurrent = INVALID_VALUE;

    //oppo framework only
    private int phoneTemp = INVALID_VALUE;

    //oppo framework only
    private int flashTemp = INVALID_VALUE;
    private int status = INVALID_VALUE;
    private int plugged = INVALID_VALUE;
    private boolean present = false;
    private int seq = INVALID_VALUE;
    private int chargeCounter = INVALID_VALUE;
    private int level = INVALID_VALUE;
    private int scale = INVALID_VALUE;
    int temperature = INVALID_VALUE;
    private int batteryNowVoltageType = INVALID_VALUE;
    private int voltage = INVALID_VALUE;

    //oppo framework only
    private int batteryMinVoltageType = INVALID_VALUE;

    //oppo framework only
    private int batteryChargeBalanceType = INVALID_VALUE;

    //oppo framework only
    private int batteryQuietThermType = INVALID_VALUE;

    //oppo framework only
    private int otgOnline = INVALID_VALUE;
    private int invalidCharger = INVALID_VALUE;

    //oppo framework only
    private int environmentTempType = INVALID_VALUE;

    //oppo framework only
    private int wirelessReverseChgType = INVALID_VALUE;
    private boolean batteryLow = false;

    public BatteryData(DataInput input) throws IOException {
        byte[] technologyByteArray = new byte[input.readInt()];
        input.readFully(technologyByteArray);
        technology = new String(technologyByteArray);
        iconSmall = input.readInt();
        maxChargingVoltage = input.readInt();
        wirelessDeviatedChgType = input.readInt();
        health = input.readInt();
        notifyCode = input.readInt();
        maxChargingCurrent = input.readInt();
        phoneTemp = input.readInt();
        flashTemp = input.readInt();
        status = input.readInt();
        plugged = input.readInt();
        seq = input.readInt();
        chargeCounter = input.readInt();
        level = input.readInt();
        scale = input.readInt();
        temperature = input.readInt();
        batteryNowVoltageType = input.readInt();
        voltage = input.readInt();
        batteryMinVoltageType = input.readInt();
        batteryChargeBalanceType = input.readInt();
        batteryQuietThermType = input.readInt();
        otgOnline = input.readInt();
        invalidCharger = input.readInt();
        environmentTempType = input.readInt();
        wirelessReverseChgType = input.readInt();
        int booleanIntValue = input.readInt();
        present = (booleanIntValue & 1) > 0;
        batteryLow = (booleanIntValue & 2) > 0;
    }

    public String getTechnology() {
        return technology;
    }

    public int getIconSmall() {
        return iconSmall;
    }

    public int getMaxChargingVoltage() {
        return maxChargingVoltage;
    }

    public int getWirelessDeviatedChgType() {
        return wirelessDeviatedChgType;
    }

    public int getHealth() {
        return health;
    }

    public int getNotifyCode() {
        return notifyCode;
    }

    public int getMaxChargingCurrent() {
        return maxChargingCurrent;
    }

    public int getPhoneTemp() {
        return phoneTemp;
    }

    public int getFlashTemp() {
        return flashTemp;
    }

    public int getStatus() {
        return status;
    }

    public int getPlugged() {
        return plugged;
    }

    public boolean isPresent() {
        return present;
    }

    public int getSeq() {
        return seq;
    }

    public int getChargeCounter() {
        return chargeCounter;
    }

    public int getLevel() {
        return level;
    }

    public int getScale() {
        return scale;
    }

    public int getTemperature() {
        return temperature;
    }

    public int getBatteryNowVoltageType() {
        return batteryNowVoltageType;
    }

    public int getVoltage() {
        return voltage;
    }

    public int getBatteryMinVoltageType() {
        return batteryMinVoltageType;
    }

    public int getBatteryChargeBalanceType() {
        return batteryChargeBalanceType;
    }

    public int getBatteryQuietThermType() {
        return batteryQuietThermType;
    }

    public int getOtgOnline() {
        return otgOnline;
    }

    public int getInvalidCharger() {
        return invalidCharger;
    }

    public int getEnvironmentTempType() {
        return environmentTempType;
    }

    public int getWirelessReverseChgType() {
        return wirelessReverseChgType;
    }

    public boolean isBatteryLow() {
        return batteryLow;
    }

    @Override
    public String toString() {
        return "BatteryData{" +
                "technology='" + technology + '\'' +
                ", iconSmall=" + iconSmall +
                ", maxChargingVoltage=" + maxChargingVoltage +
                ", wirelessDeviatedChgType=" + wirelessDeviatedChgType +
                ", health=" + health +
                ", notifyCode=" + notifyCode +
                ", maxChargingCurrent=" + maxChargingCurrent +
                ", phoneTemp=" + phoneTemp +
                ", flashTemp=" + flashTemp +
                ", status=" + status +
                ", plugged=" + plugged +
                ", present=" + present +
                ", seq=" + seq +
                ", chargeCounter=" + chargeCounter +
                ", level=" + level +
                ", scale=" + scale +
                ", temperature=" + temperature +
                ", batteryNowVoltageType=" + batteryNowVoltageType +
                ", voltage=" + voltage +
                ", batteryMinVoltageType=" + batteryMinVoltageType +
                ", batteryChargeBalanceType=" + batteryChargeBalanceType +
                ", batteryQuietThermType=" + batteryQuietThermType +
                ", otgOnline=" + otgOnline +
                ", invalidCharger=" + invalidCharger +
                ", environmentTempType=" + environmentTempType +
                ", wirelessReverseChgType=" + wirelessReverseChgType +
                ", batteryLow=" + batteryLow +
                '}';
    }
}
