package com.zsc.edu.gateway.modules.iot.tsl.entity;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.zsc.edu.gateway.common.enums.IState;
import lombok.*;


/**
 * @author Yao
 * &#064;desciption  参数
 */
@Setter
@Getter
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@TableName("iot_param")
@JsonInclude
public class Param extends BaseParam {
    /**
     * 数据类型
     */
    private DataType dataType;

    /**
     * 单位
     */
    private String uint;

    /**
     * 输入输出类型
     */
    private Type type;

    /**
     * 联表的类型
     */
    private ForeignType foreignType;

    /**
     * 联表的id
     */
    private Long foreignId;

    /**
     * 对比类型
     */
    private CompareType compareType;

    /**
     * 默认数值
     */
    private Double defaultValue;

    public enum Type implements IEnum<String>, IState<Type> {
        /**
         * 物模型输入
         */
        INPUT("INPUT", "Input"),
        /**
         * 物模型输出
         */
        OUTPUT("OUTPUT", "Output"),
        /**
         * 读写属性
         */
        RW("RW", "Read Write");

        private final String value;
        private final String description;

        Type(String value, String description) {
            this.value = value;
            this.description = description;
        }

        @Override
        public String getValue() {
            return value;
        }

        @Override
        public String toString() {
            return this.description;
        }
    }

    public enum ForeignType implements IEnum<Integer>, IState<ForeignType> {
        /**
         * 事件
         */
        EVENT(1, "Event"),
        /**
         * 服务
         */
        SERVE(2, "Serve"),
        /**
         * 产品
         */
        PRODUCT(3, "Product");

        private final int value;
        private final String description;

        ForeignType(int value, String description) {
            this.value = value;
            this.description = description;
        }

        @Override
        public Integer getValue() {
            return value;
        }

        @Override
        public String toString() {
            return this.description;
        }
    }

    public enum CompareType implements IEnum<String>, IState<CompareType> {
        /**
         * 大于
         */
        GT("GT", "GT"),
        /**
         * 小于
         */
        LT("LT", "LT"),
        /**
         * 等于
         */
        EQ("EQ", "EQ");
        private final String value;
        private final String description;

        CompareType(String value, String description) {
            this.value = value;
            this.description = description;
        }

        @Override
        public String getValue() {
            return value;
        }

        @Override
        public String toString() {
            return this.description;
        }
    }
}
