6 files modified
2 files added
| | |
| | | deviceService.devicePropertySet(workspaceId, dockSn, propertyEnumOpt.get(), param.get(property)); |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 红外设置方法 |
| | | * @param workspaceId |
| | | * @param dockSn |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @PutMapping("/{workspace_id}/devices/{device_sn}/property2") |
| | | public ResponseResult devicePropertySet2(@PathVariable("workspace_id") String workspaceId, |
| | | @PathVariable("device_sn") String dockSn, |
| | | @RequestBody JsonNode param) { |
| | | if (param.size() != 1) { |
| | | return ResponseResult.error(CommonErrorEnum.ILLEGAL_ARGUMENT); |
| | | } |
| | | int result = deviceService.devicePropertySet(workspaceId, dockSn, param); |
| | | return ResponseResult.success().getCode() == result ?ResponseResult.success():ResponseResult.error(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | RTH_ALTITUDE("rth_altitude", RthAltitudeReceiver.class), |
| | | |
| | | OUT_OF_CONTROL_ACTION("out_of_control_action", OutOfControlActionReceiver.class); |
| | | OUT_OF_CONTROL_ACTION("out_of_control_action", OutOfControlActionReceiver.class), |
| | | |
| | | THERMAL_CURRENT_PALETTE_STYLE("thermal_current_palette_style", ThermalCurrentPaletteStyleReceiver.class); |
| | | |
| | | String property; |
| | | |
| New file |
| | |
| | | package com.dji.sample.manage.model.enums; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * @author sean |
| | | * @version 1.7 |
| | | * @date 2023/6/30 |
| | | */ |
| | | public enum ThermalPaletteStyleEnum { |
| | | |
| | | WHITE_HOT(0), |
| | | |
| | | BLACK_HOT(1), |
| | | |
| | | RED_HOT(2), |
| | | |
| | | GREEN_HOT(3), |
| | | |
| | | FUSION(4), |
| | | |
| | | RAINBOW(5), |
| | | |
| | | IRONBOW1(6), |
| | | |
| | | IRONBOW2(7), |
| | | |
| | | ICE_FIRE(8), |
| | | |
| | | SEPIA(9), |
| | | |
| | | GLOWBOW(10), |
| | | |
| | | COLOR1(11), |
| | | |
| | | COLOR2(12), |
| | | |
| | | RAIN(13), |
| | | |
| | | HOT_SPOT(14), |
| | | |
| | | RAINBOW2(15), |
| | | |
| | | GRAY(16), |
| | | |
| | | METAL(17), |
| | | |
| | | COLD_SPOT(18), |
| | | ; |
| | | |
| | | private final int style; |
| | | |
| | | ThermalPaletteStyleEnum(int style) { |
| | | this.style = style; |
| | | } |
| | | |
| | | @JsonValue |
| | | public int getStyle() { |
| | | return style; |
| | | } |
| | | |
| | | @JsonCreator |
| | | public static ThermalPaletteStyleEnum find(int style) { |
| | | return Arrays.stream(values()).filter(styleEnum -> styleEnum.style == style).findAny() |
| | | // .orElseThrow(() -> new CloudSDKException(ThermalPaletteStyleEnum.class, style)); |
| | | .orElseThrow(() -> new IllegalArgumentException("Invalid enum value: " + style)); |
| | | } |
| | | |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | public boolean canPublish(OsdSubDeviceReceiver osd) { |
| | | return valid(); |
| | | } |
| | | |
| | | public boolean canPublish(String fieldName, OsdSubDeviceReceiver osd) { |
| | | return valid(); |
| | | } |
| | |
| | | |
| | | private Integer heightLimit; |
| | | |
| | | private Integer thermalCurrentPaletteStyle; |
| | | |
| | | private DistanceLimitStatusReceiver distanceLimitStatus; |
| | | |
| | | private ObstacleAvoidanceReceiver obstacleAvoidance; |
| New file |
| | |
| | | package com.dji.sample.manage.model.receiver; |
| | | |
| | | import com.dji.sample.manage.model.enums.DroneRcLostActionEnum; |
| | | import com.dji.sample.manage.model.enums.ThermalPaletteStyleEnum; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author sean |
| | | * @version 1.4 |
| | | * @date 2023/3/3 |
| | | */ |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @Data |
| | | @AllArgsConstructor |
| | | public class ThermalCurrentPaletteStyleReceiver extends BasicDeviceProperty { |
| | | |
| | | @NotNull |
| | | @Valid |
| | | private String payloadIndex; |
| | | |
| | | @NotNull |
| | | private ThermalPaletteStyleEnum thermalCurrentPaletteStyle; |
| | | |
| | | public ThermalCurrentPaletteStyleReceiver() { |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ThermalCurrentPaletteStyleSet{" + |
| | | "payloadIndex=" + payloadIndex + |
| | | ", thermalCurrentPaletteStyle=" + thermalCurrentPaletteStyle + |
| | | '}'; |
| | | } |
| | | |
| | | @JsonValue |
| | | public Map<String, Object> toMap() { |
| | | return Map.of(payloadIndex.toString(), Map.of("thermal_current_palette_style", thermalCurrentPaletteStyle.getStyle())); |
| | | } |
| | | |
| | | } |
| | |
| | | void devicePropertySet(String workspaceId, String dockSn, DeviceSetPropertyEnum propertyEnum, JsonNode param); |
| | | |
| | | /** |
| | | * Set the property parameters of the drone. |
| | | * @param workspaceId |
| | | * @param dockSn |
| | | * @param param |
| | | * @return |
| | | */ |
| | | int devicePropertySet(String workspaceId, String dockSn, JsonNode param); |
| | | |
| | | /** |
| | | * Set one property parameters of the drone. |
| | | * @param topic |
| | | * @param propertyEnum |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int devicePropertySet(String workspaceId, String dockSn, JsonNode value) { |
| | | |
| | | Optional<DeviceDTO> dockOpt = deviceRedisService.getDeviceOnline(dockSn); |
| | | if (dockOpt.isEmpty()) { |
| | | throw new RuntimeException("机场离线"); |
| | | } |
| | | String childSn = dockOpt.get().getChildDeviceSn(); |
| | | boolean deviceOnline = deviceRedisService.checkDeviceOnline(childSn); |
| | | Optional<OsdSubDeviceReceiver> osdOpt = deviceRedisService.getDeviceOsd(childSn, OsdSubDeviceReceiver.class); |
| | | if (!deviceOnline || osdOpt.isEmpty()) { |
| | | throw new RuntimeException("设备离线"); |
| | | } |
| | | |
| | | |
| | | String topic = THING_MODEL_PRE + PRODUCT + dockSn + PROPERTY_SUF + SET_SUF; |
| | | |
| | | Map reply = messageSender.publishWithReply( |
| | | Map.class, topic, |
| | | CommonTopicResponse.builder() |
| | | .bid(UUID.randomUUID().toString()) |
| | | .tid(UUID.randomUUID().toString()) |
| | | .timestamp(System.currentTimeMillis()) |
| | | .data(value) |
| | | .build()); |
| | | |
| | | |
| | | SetReply setReply = objectMapper.convertValue(reply, SetReply.class); |
| | | if (SetReplyStatusResultEnum.SUCCESS.getVal() != setReply.getResult()) { |
| | | throw new RuntimeException("设置失败" + reply + "; 错误码: " + setReply.getResult()); |
| | | } |
| | | |
| | | return ResponseResult.success().getCode(); |
| | | } |
| | | |
| | | @Override |
| | | public void deviceOnePropertySet(String topic, DeviceSetPropertyEnum propertyEnum, Map.Entry<String, Object> value) { |
| | | if (Objects.isNull(value) || Objects.isNull(value.getValue())) { |
| | | throw new IllegalArgumentException(CommonErrorEnum.ILLEGAL_ARGUMENT.getErrorMsg()); |