解读java代码_求解读一段JAVA代码(解析数据结果的)

package com.pmi.reader.data.battery_info;

import android.annotation.TargetApi;

import android.bluetooth.BluetoothGattCharacteristic;

import android.util.Log;

import com.pmi.reader.data.CharacteristicData;

import com.pmi.reader.helpers.BinaryHelper;

@TargetApi(18)

public class BatteryInformation

extends CharacteristicData

{

private static final String TAG = BatteryInformation.class.getSimpleName();

private Integer chargerBatteryLevel;

private Integer chargerBatteryTemperature;

private Integer chargerBatteryVoltage;

private int flags;

private Integer holder1BatteryLevel;

private Integer holder1BatteryTemperature;

private Integer holder1BatteryVoltage;

private Integer holder2BatteryLevel;

private Integer holder2BatteryTemperature;

private Integer holder2BatteryVoltage;

public BatteryInformation(BluetoothGattCharacteristic paramBluetoothGattCharacteristic)

{

Log.d(TAG, BinaryHelper.arrayToHexString(paramBluetoothGattCharacteristic.getValue()));

this.flags = paramBluetoothGattCharacteristic.getIntValue(18, 0).intValue();

int j = 0 + 2;

int i = j;

if (isFlag(0))

{

this.chargerBatteryLevel = paramBluetoothGattCharacteristic.getIntValue(17, j);

i = j + 1;

}

j = i;

if (isFlag(1))

{

this.chargerBatteryTemperature = paramBluetoothGattCharacteristic.getIntValue(17, i);

j = i + 1;

}

i = j;

if (isFlag(2))

{

this.chargerBatteryVoltage = paramBluetoothGattCharacteristic.getIntValue(18, j);

i = j + 2;

}

j = i;

if (isFlag(3))

{

this.holder1BatteryLevel = paramBluetoothGattCharacteristic.getIntValue(17, i);

j = i + 1;

}

i = j;

if (isFlag(4))

{

this.holder1BatteryTemperature = paramBluetoothGattCharacteristic.getIntValue(17, j);

i = j + 1;

}

j = i;

if (isFlag(5))

{

this.holder1BatteryVoltage = paramBluetoothGattCharacteristic.getIntValue(18, i);

j = i + 2;

}

i = j;

if (isFlag(6))

{

this.holder2BatteryLevel = paramBluetoothGattCharacteristic.getIntValue(17, j);

i = j + 1;

}

j = i;

if (isFlag(7))

{

this.holder2BatteryTemperature = paramBluetoothGattCharacteristic.getIntValue(17, i);

j = i + 1;

}

if (isFlag(8)) {

this.holder2BatteryVoltage = paramBluetoothGattCharacteristic.getIntValue(18, j);

}

}

public Integer getChargerBatteryLevel()

{

return this.chargerBatteryLevel;

}

public Integer getChargerBatteryTemperature()

{

return this.chargerBatteryTemperature;

}

public Integer getChargerBatteryVoltage()

{

return this.chargerBatteryVoltage;

}

public int getFlags()

{

return this.flags;

}

public Integer getHolder1BatteryLevel()

{

return this.holder1BatteryLevel;

}

public Integer getHolder1BatteryTemperature()

{

return this.holder1BatteryTemperature;

}

public Integer getHolder1BatteryVoltage()

{

return this.holder1BatteryVoltage;

}

public Integer getHolder2BatteryLevel()

{

return this.holder2BatteryLevel;

}

public Integer getHolder2BatteryTemperature()

{

return this.holder2BatteryTemperature;

}

public Integer getHolder2BatteryVoltage()

{

return this.holder2BatteryVoltage;

}

public boolean isFlag(int paramInt)

{

return isFlag(this.flags, paramInt);

}

public String toString()

{

return "BatteryInformation{\n flags (binary)=" + Integer.toBinaryString(this.flags) + ",\n chargerBatteryLevel=" + this.chargerBatteryLevel + ",\n chargerBatteryTemperature=" + this.chargerBatteryTemperature + ",\n chargerBatteryVoltage=" + this.chargerBatteryVoltage + ",\n holder1BatteryLevel=" + this.holder1BatteryLevel + ",\n holder1BatteryTemperature=" + this.holder1BatteryTemperature + ",\n holder1BatteryVoltage=" + this.holder1BatteryVoltage + ",\n holder2BatteryLevel=" + this.holder2BatteryLevel + ",\n holder2BatteryTemperature=" + this.holder2BatteryTemperature + ",\n holder2BatteryVoltage=" + this.holder2BatteryVoltage + "\n}";

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值