FuelCellData.java 3.93 KB
package com.bsth.entity;
import com.bsth.socket.protocol.Message0203;
import org.springframework.beans.BeanUtils;


public class FuelCellData extends Data{

    /**
     * 信息类型
     * 默认应该为0x03
     */
    private byte infoType;

    /**
     * 电池电压 0-20000
     * 分辨率0.1v
     * 0xff 0xfe 异常
     * 0xff 0xff 无效
     */
    private short voltage;

    /**
     * 电池电流 0-20000
     * 分辨率0.1v
     * 0xff 0xfe 异常
     * 0xff 0xff 无效
     */
    private short current;

    /**
     * 燃料消耗率 0-60000
     * 分辨率0.01kg/100km
     * 0xff 0xfe 异常
     * 0xff 0xff 无效
     */
    private short fuelConsumeRate;

    /**
     * 电池温度探针数量 0-65531
     * n
     * 0xff 0xfe 异常
     * 0xff 0xff 无效
     */
    private short tempProbeQuantity;

    /**
     * 累计里程 0-240
     * 分辨率1℃ 偏移量-40 n*1
     * 0xff 0xff 0xff 0xfe 异常
     * 0xff 0xff 0xff 0xff 无效
     */
    private byte[] temps;

    /**
     * 氢系统中最高温度值 0-2400
     * 分辨率0.1℃ 偏移量-400
     * 0xff 0xfe 异常
     * 0xff 0xff 无效
     */
    private short hydrogenMaxTemp;

    /**
     * 氢系统最高温度探针代号 1-252
     * 0xfe 异常
     * 0xff 无效
     */
    private byte maxTempSensorCode;

    /**
     * 氢气最大浓度 0-60000
     * 分辨率1mg/kg
     * 0xFF 0xFE 异常
     * 0xFF 0xFF 无效
     */
    private short hydrogenMaxConcentration;

    /**
     * 氢气最大浓度传感器代号 1-252
     * 0xfe 异常
     * 0xff 无效
     */
    private byte maxConcentrationSensorCode;

    /**
     * 氢气最高压力 0-1000
     * 分辨率0.1MPa
     * 0xFF 0xFE 异常
     * 0xFF 0xFF 无效
     */
    private short hydrogenMaxPressure;

    /**
     * 氢气最大浓度传感器代号 1-252
     * 0xfe 异常
     * 0xff 无效
     */
    private byte maxPressureSensorCode;

    /**
     * dc-dc状态
     * 0x01 工作
     * 0x02 断开
     * 0xFE 异常
     * 0xFF 无效
     */
    private byte dcState;

    public FuelCellData(Message0203 message0203){
        BeanUtils.copyProperties(message0203, this);
        this.infoType  &= (short) 0xFF;
        this.voltage &= (short) 0xFF;
        this.current &= (short) 0xFF;
        this.fuelConsumeRate  &= (short) 0xFF;
        this.tempProbeQuantity  &= (short) 0xFF;
        for (int i = 0; i < temps.length; i++) {
            this.temps[i] -= 40; }
        this.hydrogenMaxTemp  &= (short) 0xFF;
        this.hydrogenMaxTemp -=40;
        this.maxTempSensorCode &= (short) 0xFF;
        this.hydrogenMaxConcentration  &= (short) 0xFF;
        this.maxConcentrationSensorCode &= (short) 0xFF;
        this.hydrogenMaxPressure  &= (short) 0xFF;
        this.maxPressureSensorCode  &= (short) 0xFF;
        this.dcState  &= (short) 0xFF;
    }



    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(" 信息类型: ").append(String.format("%02x", infoType))
                .append(" 电池电压: ").append(voltage)
                .append(" 电池电流: ").append(current)
                .append(" 燃料消耗率: ").append(fuelConsumeRate)
                .append(" 电池温度探针数量: ").append(tempProbeQuantity)
                .append(" 氢系统最高温度值: ").append(hydrogenMaxTemp)
                .append(" 氢系统最高温度探针代号: ").append(maxTempSensorCode)
                .append(" 氢气最大浓度: ").append(hydrogenMaxConcentration)
                .append(" 氢气最大浓度传感器代号: ").append(maxConcentrationSensorCode)
                .append(" 氢气最高压力: ").append(hydrogenMaxPressure)
                .append(" 氢气最高压力传感器代号: ").append(maxPressureSensorCode)
                .append(" dc-dc状态: ").append(dcState);

        return sb.toString();
    }




    @Override
    public String getType() {
        return "FuelCell_data";
    }
}