package com.yfd.platform.component.iec104.enums;

import lombok.Getter;

/**
 *
* @ClassName: TypeIdentifierEnum   类型标识
* @author YDL
* @date 2020年5月13日
 */
public enum TypeIdentifierEnum {

	/**
	 * 单点 摇信 1
	 */
	onePointTeleindication(0x01, 1),
	/**
	 * 双点 摇信 2
	 */
	twoPointTeleindication(0x03, 1),
	/**
	 * 测量值 归一化值 遥测 9
	 */
	normalizedTelemetry(0x09,2),
	/**
	 * 测量值  标度化值 遥测 11
	 */
	scaledTelemetry(0x0B, 2),
	/**
	 * 测量值 短浮点数 遥测   Short floating point  13
	 */
	shortFloatingPointTelemetry(0x0D, 4),

	/**
	 * 摇信带时标 单点 30
	 */
	onePointTimeTeleindication(0x1E, 1),
	/**
	 * 摇信带时标 双点 31
	 */
	twoPointTimeTeleindication(0x1F, 1),
	/**
	 * 测量值 归一化值 带时标 遥测 9
	 */
	normalizedTimeTelemetry(0x22,2),
	/**
	 * 测量值  标度化值 带时标 遥测 11
	 */
	scaledTimeTelemetry(0x23, 2),
	/**
	 * 测量值 短浮点数 带时标 遥测   Short floating point  13
	 */
	shortFloatingPointTimeTelemetry(0x24, 4),
	/**
	 * 单命令 遥控 45
	 */
	onePointTelecontrol(0x2D, 1),
	/**
	 * 双命令遥控 46
	 */
	twoPointTelecontrol(0x2E, 1),
	/**
	 * 归一化值 遥调  48
	 *
	 */
	normalizedTeleadjustment(0x30,2),
	/**
	 * 标度化值 遥调  49
	 */
	scaledTeleadjustment(0x31, 2),
	/**
	 * 短浮点数 遥调 50
	 */
	shortFloatingPointTeleadjustment(0x32, 4),

	/**
	 * 读单个参数
	 */
	readOneParameter(0x66, 4),
	/**
	 * 读多个参数
	 */
	readMultipleParameter(0x84, 4),

	/**
	 * 预置多个个参数
	 */
	prefabActivationMultipleParameter(0x88, 4),
	/**
	 * 初始化结束
	 */
	initEnd(0x46, 0),
	/**
	 * 召唤命令
	 */
	generalCall(0x64, 0),
	/**
	 * 时钟同步
	 */
	timeSynchronization(0x67, 0),
	/**
	 * 复位进程
	 */
	resetPprocess(0x69, 0);

	@Getter
	private byte value;
	@Getter
	private int messageLength;

	TypeIdentifierEnum(int value, int messageLength) {
		this.value = (byte) value;
		this.messageLength = messageLength;
	}
	public static TypeIdentifierEnum getTypeIdentifierEnum(byte value) {
		for (TypeIdentifierEnum type : TypeIdentifierEnum.values()) {
			if (type.getValue() == value) {
				return type;
			}
		}
		return null;
	}


	public static boolean isTelemetry(TypeIdentifierEnum typeIdentifierEnum) {
		return TypeIdentifierEnum.normalizedTelemetry == typeIdentifierEnum
				||TypeIdentifierEnum.scaledTelemetry == typeIdentifierEnum
				||TypeIdentifierEnum.shortFloatingPointTelemetry == typeIdentifierEnum
				||TypeIdentifierEnum.normalizedTimeTelemetry == typeIdentifierEnum
				||TypeIdentifierEnum.scaledTimeTelemetry == typeIdentifierEnum
				||TypeIdentifierEnum.shortFloatingPointTimeTelemetry == typeIdentifierEnum;
	}
}
