添加枚举
This commit is contained in:
parent
85f39feac1
commit
8cc7a6d4a7
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.device.domain.model.thingsboard.constants;
|
package com.ruoyi.device.domain.model.thingsboard.constants;
|
||||||
|
|
||||||
import com.ruoyi.device.domain.model.thingsboard.AttributeKey;
|
import com.ruoyi.device.domain.model.thingsboard.AttributeKey;
|
||||||
|
import com.ruoyi.device.domain.model.thingsboard.TelemetryKey;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -11,26 +12,9 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class DeviceAttributes {
|
public class DeviceAttributes {
|
||||||
|
|
||||||
// 连接器类型 - String
|
/**
|
||||||
public static final AttributeKey<String> CONNECTOR_TYPE = AttributeKey.of(
|
* 公用服务端属性
|
||||||
"connectorType",
|
*/
|
||||||
String.class,
|
|
||||||
value -> value != null ? value.toString() : null
|
|
||||||
);
|
|
||||||
|
|
||||||
// 连接器名称 - String
|
|
||||||
public static final AttributeKey<String> CONNECTOR_NAME = AttributeKey.of(
|
|
||||||
"connectorName",
|
|
||||||
String.class,
|
|
||||||
value -> value != null ? value.toString() : null
|
|
||||||
);
|
|
||||||
|
|
||||||
// 网关 - String
|
|
||||||
public static final AttributeKey<String> GATEWAY = AttributeKey.of(
|
|
||||||
"gateway",
|
|
||||||
String.class,
|
|
||||||
value -> value != null ? value.toString() : null
|
|
||||||
);
|
|
||||||
|
|
||||||
// 最后连接时间 - Long
|
// 最后连接时间 - Long
|
||||||
public static final AttributeKey<Long> LAST_CONNECT_TIME = AttributeKey.of(
|
public static final AttributeKey<Long> LAST_CONNECT_TIME = AttributeKey.of(
|
||||||
|
|
@ -84,6 +68,27 @@ public class DeviceAttributes {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公用客户端属性 (无需配置)
|
||||||
|
*/
|
||||||
|
// 连接器类型 - String
|
||||||
|
public static final AttributeKey<String> CONNECTOR_TYPE = AttributeKey.of(
|
||||||
|
"connectorType",
|
||||||
|
String.class,
|
||||||
|
value -> value != null ? value.toString() : null
|
||||||
|
);
|
||||||
|
|
||||||
|
// 连接器名称 - String
|
||||||
|
public static final AttributeKey<String> CONNECTOR_NAME = AttributeKey.of(
|
||||||
|
"connectorName",
|
||||||
|
String.class,
|
||||||
|
value -> value != null ? value.toString() : null
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公用客户端属性 (需要配置)
|
||||||
|
*/
|
||||||
|
|
||||||
// 机场SN号 - String
|
// 机场SN号 - String
|
||||||
public static final AttributeKey<String> DOCK_SN = AttributeKey.of(
|
public static final AttributeKey<String> DOCK_SN = AttributeKey.of(
|
||||||
"dock_sn",
|
"dock_sn",
|
||||||
|
|
@ -91,13 +96,59 @@ public class DeviceAttributes {
|
||||||
value -> value != null ? value.toString() : null
|
value -> value != null ? value.toString() : null
|
||||||
);
|
);
|
||||||
|
|
||||||
// 子设备SN号 - String
|
/**
|
||||||
|
* 机场 {"0":"空闲中","1":"现场调试","2":"远程调试","3":"固件升级中","4":"作业中","5":"待标定"}
|
||||||
|
* 无人机 {"0":"待机","1":"起飞准备","2":"起飞准备完毕","3":"手动飞行","4":"自动起飞","5":"航线飞行","6":"全景拍照","7":"智能跟随","8":"ADS-B 躲避","9":"自动返航","10":"自动降落","11":"强制降落","12":"三桨叶降落","13":"升级中","14":"未连接","15":"APAS","16":"虚拟摇杆状态","17":"指令飞行","18":"空中 RTK 收敛模式","19":"机场选址中","20":"POI环绕"}
|
||||||
|
*/
|
||||||
|
public static final AttributeKey<Integer> MODE_CODE = AttributeKey.of(
|
||||||
|
"mode_code",
|
||||||
|
Integer.class,
|
||||||
|
value -> {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (value instanceof Number) {
|
||||||
|
return ((Number) value).intValue();
|
||||||
|
}
|
||||||
|
return Integer.parseInt(value.toString());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机场特有属性
|
||||||
|
*/
|
||||||
|
// 无人机SN号 - String
|
||||||
public static final AttributeKey<String> SUB_DEVICE_SN = AttributeKey.of(
|
public static final AttributeKey<String> SUB_DEVICE_SN = AttributeKey.of(
|
||||||
"sub_device.device_sn",
|
"sub_device.device_sn",
|
||||||
String.class,
|
String.class,
|
||||||
value -> value != null ? value.toString() : null
|
value -> value != null ? value.toString() : null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// // 空调状态 - Integer
|
||||||
|
// public static final TelemetryKey<Integer> AIR_CONDITIONER_STATE = TelemetryKey.of(
|
||||||
|
// "air_conditioner.air_conditioner_state",
|
||||||
|
// Integer.class,
|
||||||
|
// value -> {
|
||||||
|
// if (value == null) return null;
|
||||||
|
// if (value instanceof Number) {
|
||||||
|
// return ((Number) value).intValue();
|
||||||
|
// }
|
||||||
|
// return Integer.parseInt(value.toString());
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
//
|
||||||
|
// // 网关 - String
|
||||||
|
// public static final AttributeKey<String> GATEWAY = AttributeKey.of(
|
||||||
|
// "gateway",
|
||||||
|
// String.class,
|
||||||
|
// value -> value != null ? value.toString() : null
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private DeviceAttributes() {
|
private DeviceAttributes() {
|
||||||
// 工具类,禁止实例化
|
// 工具类,禁止实例化
|
||||||
}
|
}
|
||||||
|
|
@ -111,13 +162,14 @@ public class DeviceAttributes {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
CONNECTOR_TYPE,
|
CONNECTOR_TYPE,
|
||||||
CONNECTOR_NAME,
|
CONNECTOR_NAME,
|
||||||
GATEWAY,
|
// GATEWAY,
|
||||||
LAST_CONNECT_TIME,
|
LAST_CONNECT_TIME,
|
||||||
ACTIVE,
|
ACTIVE,
|
||||||
LAST_ACTIVITY_TIME,
|
LAST_ACTIVITY_TIME,
|
||||||
LAST_DISCONNECT_TIME,
|
LAST_DISCONNECT_TIME,
|
||||||
DOCK_SN,
|
DOCK_SN,
|
||||||
SUB_DEVICE_SN
|
SUB_DEVICE_SN,
|
||||||
|
MODE_CODE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.device.domain.model.thingsboard.constants;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.ruoyi.device.domain.model.thingsboard.AttributeKey;
|
||||||
import com.ruoyi.device.domain.model.thingsboard.TelemetryKey;
|
import com.ruoyi.device.domain.model.thingsboard.TelemetryKey;
|
||||||
import com.ruoyi.device.domain.model.thingsboard.attributes.psdk.PsdkDevice;
|
import com.ruoyi.device.domain.model.thingsboard.attributes.psdk.PsdkDevice;
|
||||||
|
|
||||||
|
|
@ -18,8 +19,98 @@ public class DeviceTelemetry {
|
||||||
// Jackson ObjectMapper 用于 JSON 解析
|
// Jackson ObjectMapper 用于 JSON 解析
|
||||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无人机独状态
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 飞行次数
|
||||||
|
*/
|
||||||
|
public static final TelemetryKey<Integer> Total_Flight_Sorties = TelemetryKey.of(
|
||||||
|
"total_flight_sorties",
|
||||||
|
Integer.class,
|
||||||
|
value -> {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (value instanceof Number) {
|
||||||
|
return ((Number) value).intValue();
|
||||||
|
}
|
||||||
|
return Integer.parseInt(value.toString());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机场独有状态
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 任务作业状态
|
||||||
|
* {"0":"作业准备中","1":"飞行作业中","2":"作业后状态恢复","3":"自定义飞行区更新中","4":"地形障碍物更新中","5":"任务空闲","255":"飞行器异常","256":"未知状态"}
|
||||||
|
*/
|
||||||
|
public static final TelemetryKey<Integer> FlightTask_Step_Code = TelemetryKey.of(
|
||||||
|
"flighttask_step_code",
|
||||||
|
Integer.class,
|
||||||
|
value -> {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (value instanceof Number) {
|
||||||
|
return ((Number) value).intValue();
|
||||||
|
}
|
||||||
|
return Integer.parseInt(value.toString());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无人机是否在舱
|
||||||
|
* {"0":"舱外","1":"舱内"}
|
||||||
|
*/
|
||||||
|
public static final TelemetryKey<Integer> Drone_In_Dock = TelemetryKey.of(
|
||||||
|
"drone_in_dock",
|
||||||
|
Integer.class,
|
||||||
|
value -> {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (value instanceof Number) {
|
||||||
|
return ((Number) value).intValue();
|
||||||
|
}
|
||||||
|
return Integer.parseInt(value.toString());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无人机是否开机状态
|
||||||
|
* {"0":"关机","1":"开机"}
|
||||||
|
*/
|
||||||
|
public static final TelemetryKey<Integer> Sub_Device_Online_Status = TelemetryKey.of(
|
||||||
|
"sub_device.device_online_status",
|
||||||
|
Integer.class,
|
||||||
|
value -> {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (value instanceof Number) {
|
||||||
|
return ((Number) value).intValue();
|
||||||
|
}
|
||||||
|
return Integer.parseInt(value.toString());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无人机充电状态
|
||||||
|
* {"0":"空闲","1":"充电中"}
|
||||||
|
*/
|
||||||
|
public static final TelemetryKey<Integer> Drone_Charge_State_State = TelemetryKey.of(
|
||||||
|
"drone_charge_state.state",
|
||||||
|
Integer.class,
|
||||||
|
value -> {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (value instanceof Number) {
|
||||||
|
return ((Number) value).intValue();
|
||||||
|
}
|
||||||
|
return Integer.parseInt(value.toString());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// 空调状态 - Integer
|
// 空调状态 - Integer
|
||||||
|
/**
|
||||||
|
* {"0":"空闲模式(无制冷、制热、除湿等)","1":"制冷模式","2":"制热模式","3":"除湿模式","4":"制冷退出模式","5":"制热退出模式","6":"除湿退出模式","7":"制冷准备模式","8":"制热准备模式","9":"除湿准备模式"10":"风冷准备中"11":"风冷中"12":"风冷退出中"13":"除雾准备中"14":"除雾中"15":"除雾退出中"}
|
||||||
|
*/
|
||||||
public static final TelemetryKey<Integer> AIR_CONDITIONER_STATE = TelemetryKey.of(
|
public static final TelemetryKey<Integer> AIR_CONDITIONER_STATE = TelemetryKey.of(
|
||||||
"air_conditioner.air_conditioner_state",
|
"air_conditioner.air_conditioner_state",
|
||||||
Integer.class,
|
Integer.class,
|
||||||
|
|
@ -32,6 +123,10 @@ public class DeviceTelemetry {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 以下尚未划分
|
||||||
|
*/
|
||||||
// 温度 - Double
|
// 温度 - Double
|
||||||
public static final TelemetryKey<Double> TEMPERATURE = TelemetryKey.of(
|
public static final TelemetryKey<Double> TEMPERATURE = TelemetryKey.of(
|
||||||
"temperature",
|
"temperature",
|
||||||
|
|
@ -117,7 +212,10 @@ public class DeviceTelemetry {
|
||||||
AIR_CONDITIONER_STATE,
|
AIR_CONDITIONER_STATE,
|
||||||
TEMPERATURE,
|
TEMPERATURE,
|
||||||
HUMIDITY,
|
HUMIDITY,
|
||||||
PSDK_WIDGET_VALUES
|
PSDK_WIDGET_VALUES,
|
||||||
|
FlightTask_Step_Code,
|
||||||
|
Sub_Device_Online_Status,
|
||||||
|
Total_Flight_Sorties
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue