package cn.lihongjie.coal.emDeviceData.dto;

import cn.lihongjie.coal.base.dto.OrgCommonDto;
import cn.lihongjie.coal.emDevice.dto.EmDeviceDto;

import lombok.Data;

import org.hibernate.annotations.Comment;

import java.time.LocalDateTime;

@Data
public class EmDeviceDataDto extends OrgCommonDto {

    private EmDeviceDto device;

    private LocalDateTime time;

    @Comment("Pm2.5")
    private Double pm25;

    @Comment("Pm10")
    private Double pm10;

    @Comment("噪声")
    private Double noise;

    @Comment("温度")
    private Double tem;

    @Comment("湿度")
    private Double hum;

    @Comment("风力")
    private Double wp;

    @Comment("风速")
    private Double ws;

    @Comment("八风向")
    private Double wd8;

    @Comment("风向")
    private Double wd360;

    @Comment("悬浮微粒")
    private Double tsp;

    @Comment("大气压")
    private Double atm;

    @Comment("光照")
    private Double lux;

    @Comment("一氧化碳")
    private Double co;

    @Comment("二氧化硫")
    private Double so2;

    @Comment("二氧化氮")
    private Double no2;

    @Comment("臭氧")
    private Double o3;

    private Long alterMask;

    public int getAlterStatus(String code) {
        if (alterMask == null) alterMask = 0L;
        int ans = 0;
        switch (code) {
            case "pm25" -> ans = (int) ((alterMask >>> 0) & 0b11);
            case "pm10" -> ans = (int) ((alterMask >>> 2) & 0b11);
            case "noise" -> ans = (int) ((alterMask >>> 4) & 0b11);
            case "tem" -> ans = (int) ((alterMask >>> 6) & 0b11);
            case "hum" -> ans = (int) ((alterMask >>> 8) & 0b11);
            case "wp" -> ans = (int) ((alterMask >>> 10) & 0b11);
            case "ws" -> ans = (int) ((alterMask >>> 12) & 0b11);
            case "wd8" -> ans = (int) ((alterMask >>> 14) & 0b11);
            case "wd360" -> ans = (int) ((alterMask >>> 16) & 0b11);
            case "tsp" -> ans = (int) ((alterMask >>> 18) & 0b11);
            case "atm" -> ans = (int) ((alterMask >>> 20) & 0b11);
            case "lux" -> ans = (int) ((alterMask >>> 22) & 0b11);
            case "co" -> ans = (int) ((alterMask >>> 24) & 0b11);
            case "so2" -> ans = (int) ((alterMask >>> 26) & 0b11);
            case "no2" -> ans = (int) ((alterMask >>> 28) & 0b11);
            case "o3" -> ans = (int) ((alterMask >>> 30) & 0b11);
        }

        return ans;
    }

    public int getPm25Alter() {
        return this.getAlterStatus("pm25");
    }

    public int getPm10Alter() {
        return this.getAlterStatus("pm10");
    }

    public int getNoiseAlter() {
        return this.getAlterStatus("noise");
    }

    public int getTemAlter() {
        return this.getAlterStatus("tem");
    }

    public int getHumAlter() {
        return this.getAlterStatus("hum");
    }

    public int getWpAlter() {
        return this.getAlterStatus("wp");
    }

    public int getWsAlter() {
        return this.getAlterStatus("ws");
    }

    public int getWd8Alter() {
        return this.getAlterStatus("wd8");
    }

    public int getWd360Alter() {
        return this.getAlterStatus("wd360");
    }

    public int getTspAlter() {
        return this.getAlterStatus("tsp");
    }

    public int getAtmAlter() {
        return this.getAlterStatus("atm");
    }

    public int getLuxAlter() {
        return this.getAlterStatus("lux");
    }

    public int getCoAlter() {
        return this.getAlterStatus("co");
    }

    public int getSo2Alter() {
        return this.getAlterStatus("so2");
    }

    public int getNo2Alter() {
        return this.getAlterStatus("no2");
    }

    public int getO3Alter() {
        return this.getAlterStatus("o3");
    }
}
