package http.vo.response;

/**
 * 可控制设备
 *
 * @author ReiChin_
 */
public class LotDeviceVo {

    public static final String LOT_OFF = "4";
    public static final String LOT_ON = "3";

    // 设备不在线
    public static final String SWITCH_ENUM_NO_ONLINE = "NO_ONLINE";
    // 开关打开
    public static final String SWITCH_ENUM_ON = "ON";
    // 开关关闭
    public static final String SWITCH_ENUM_OFF = "OFF";

    // 空调设备
    public static final String HARDWARE_AIR = "airConditioner";

    public String id;
    public String hardwareNo; // 设备编号
    public String hardwareName; // 设备名称
    public String schoolId; // 学校
    public String schoolName;
    public String buildId; // 楼栋
    public String buildName;
    public String floorId; // 楼层
    public String floorName;
    public String subjectId; // 实验室
    public String subjectName;
    public String room; // 房间
    public String icon;
    public String exceptionIcon;
    public String hardwareTypeId;
    public String hardwareTypeKey;
    public String hardwareTypeName;
    public String deviceId;
    public String deviceNo;
    public String deviceTypeKey;
    public String attributeId;
    public String reservedOne;
    public String reservedTwo;
    public String reservedThree;
    public boolean operatingState;
    public boolean online;
    public boolean state; // 设备状态 ture表示开，false表示关
    public String remark;
    public String createTime;

    /**
     * 当前设备是否在线
     */
    public boolean isOnline() {
        return online || HARDWARE_AIR.equals(hardwareTypeKey);
    }

    /**
     * 当前设备是否处于开状态
     */
    public boolean isSwitchOn() {
        return HARDWARE_AIR.equals(hardwareTypeKey) ? !isAirOff() : operatingState;
    }

    private boolean isAirOff() {
        return null == reservedThree || reservedThree.isEmpty() || "0".equals(reservedThree);
    }

}
