package com.imdroid.beidou.data.vo.device;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.imdroid.secapi.dto.GnssDevice;
import com.imdroid.secapi.dto.GnssStatusJoin;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * @author LiGang
 * @date 2023/10/13 21:50
 */
@Setter
@Getter
public class DeviceStatusVO {

    private Long id;

    private String deviceId;

    private String name;

    private String location;

    private String pictures;

    private String tenantName;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime latestDataTime;

    private Float roll;
    private Float pitch;
    private Float yaw;
    private Integer rssi;
    private Integer voltage;
    private Float temperature;
    private Float humidity;
    private Integer txbytes;
    private Integer rxbytes;
    private Integer b562bytes;
    private Integer d3xxbytes;
    private Integer satelliteinview;
    private Integer satelliteinuse;

     private Short dtuState;


    public DeviceStatusVO() {

    }

    public DeviceStatusVO(GnssDevice gnssDevice, GnssStatusJoin gnssStatus) {
        this.id = gnssDevice.getId();
        this.deviceId = gnssDevice.getDeviceid();
        this.name = gnssDevice.getName();
        this.pictures = gnssDevice.getPictures();
        this.tenantName = gnssDevice.getTenantname();

        if (gnssStatus != null) {
            this.latestDataTime = gnssStatus.getUpdatetime();
            this.location = gnssStatus.getLocation();
            this.roll = gnssStatus.getRoll();
            this.pitch = gnssStatus.getPitch();
            this.yaw = gnssStatus.getYaw();
            this.rssi = gnssStatus.getRssi();
            this.voltage = gnssStatus.getVoltage();
            this.temperature = gnssStatus.getTemperature();
            this.humidity = gnssStatus.getHumidity();
            this.txbytes = gnssStatus.getTxbytes();
            this.rxbytes = gnssStatus.getRxbytes();
            this.d3xxbytes = gnssStatus.getD3xxbytes();
            this.b562bytes = gnssStatus.getB562bytes();
            this.satelliteinuse = gnssStatus.getSatelliteinuse();
            this.dtuState = gnssStatus.getState();
        }
    }
}
