sean.zhou
2 years ago
107 changed files with 2539 additions and 602 deletions
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
package com.dji.sample.common.util; |
||||
|
||||
import org.springframework.beans.BeansException; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.ApplicationContextAware; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/10 |
||||
*/ |
||||
@Component |
||||
public class SpringBeanUtils implements ApplicationContextAware { |
||||
|
||||
private static ApplicationContext applicationContext; |
||||
|
||||
@Override |
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
||||
SpringBeanUtils.applicationContext = applicationContext; |
||||
} |
||||
|
||||
public static <T> T getBean(Class<T> clazz) { |
||||
return applicationContext.getBean(clazz); |
||||
} |
||||
|
||||
public static Object getBean(String beanName) { |
||||
return applicationContext.getBean(beanName); |
||||
} |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
package com.dji.sample.component.mqtt.handler; |
||||
|
||||
import com.dji.sample.component.mqtt.model.Chan; |
||||
import com.dji.sample.component.mqtt.model.ChannelName; |
||||
import com.dji.sample.component.mqtt.model.CommonTopicReceiver; |
||||
import com.fasterxml.jackson.core.type.TypeReference; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.integration.annotation.ServiceActivator; |
||||
import org.springframework.messaging.Message; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.2 |
||||
* @date 2022/9/9 |
||||
*/ |
||||
@Component |
||||
public class PropertySetReplyHandler { |
||||
|
||||
@Autowired |
||||
private ObjectMapper mapper; |
||||
|
||||
/** |
||||
* Handle the reply message from the pilot side to the on-demand video. |
||||
* @param message reply message |
||||
* @throws IOException |
||||
*/ |
||||
@ServiceActivator(inputChannel = ChannelName.INBOUND_PROPERTY_SET_REPLY) |
||||
public void serviceReply(Message<?> message) throws IOException { |
||||
byte[] payload = (byte[])message.getPayload(); |
||||
|
||||
CommonTopicReceiver receiver = mapper.readValue(payload, new TypeReference<CommonTopicReceiver>() {}); |
||||
Chan<CommonTopicReceiver<?>> chan = Chan.getInstance(); |
||||
// Put the message to the chan object.
|
||||
chan.put(receiver); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
package com.dji.sample.component.mqtt.model; |
||||
|
||||
import com.dji.sample.manage.service.IRequestsConfigService; |
||||
import com.dji.sample.manage.service.impl.ConfigProductServiceImpl; |
||||
import lombok.Getter; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/10 |
||||
*/ |
||||
@Getter |
||||
public enum ConfigScopeEnum { |
||||
|
||||
PRODUCT("product", ConfigProductServiceImpl.class); |
||||
|
||||
String scope; |
||||
|
||||
Class<? extends IRequestsConfigService> clazz; |
||||
|
||||
ConfigScopeEnum(String scope, Class<? extends IRequestsConfigService> clazz) { |
||||
this.scope = scope; |
||||
this.clazz = clazz; |
||||
} |
||||
|
||||
public static Optional<ConfigScopeEnum> find(String scope) { |
||||
return Arrays.stream(ConfigScopeEnum.values()).filter(scopeEnum -> scopeEnum.scope.equals(scope)).findAny(); |
||||
} |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
package com.dji.sample.component.mqtt.model; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.regex.Pattern; |
||||
|
||||
import static com.dji.sample.component.mqtt.model.TopicConst.*; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/28 |
||||
*/ |
||||
@Getter |
||||
public enum DeviceTopicEnum { |
||||
|
||||
STATUS(Pattern.compile("^" + BASIC_PRE + PRODUCT + REGEX_SN + STATUS_SUF + "$"), ChannelName.INBOUND_STATUS), |
||||
|
||||
STATE(Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + STATE_SUF + "$"), ChannelName.INBOUND_STATE), |
||||
|
||||
SERVICE_REPLY(Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + SERVICES_SUF + _REPLY_SUF + "$"), ChannelName.INBOUND_SERVICE_REPLY), |
||||
|
||||
OSD(Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + OSD_SUF + "$"), ChannelName.INBOUND_OSD), |
||||
|
||||
REQUESTS(Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + REQUESTS_SUF + "$"), ChannelName.INBOUND_REQUESTS), |
||||
|
||||
EVENTS(Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + EVENTS_SUF + "$"), ChannelName.INBOUND_EVENTS), |
||||
|
||||
PROPERTY_SET_REPLY(Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + PROPERTY_SUF + SET_SUF + _REPLY_SUF + "$"), ChannelName.INBOUND_PROPERTY_SET_REPLY), |
||||
|
||||
UNKNOWN(null, ChannelName.DEFAULT); |
||||
|
||||
Pattern pattern; |
||||
|
||||
String beanName; |
||||
|
||||
DeviceTopicEnum(Pattern pattern, String beanName) { |
||||
this.pattern = pattern; |
||||
this.beanName = beanName; |
||||
} |
||||
|
||||
public static DeviceTopicEnum find(String topic) { |
||||
return Arrays.stream(DeviceTopicEnum.values()).filter(topicEnum -> topicEnum.pattern.matcher(topic).matches()).findAny().orElse(UNKNOWN); |
||||
} |
||||
} |
@ -1,89 +0,0 @@
@@ -1,89 +0,0 @@
|
||||
package com.dji.sample.component.mqtt.model; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
/** |
||||
* @author sean.zhou |
||||
* @date 2021/11/22 |
||||
* @version 0.1 |
||||
*/ |
||||
public enum ServicesMethodEnum { |
||||
|
||||
LIVE_START_PUSH("live_start_push", false), |
||||
|
||||
LIVE_STOP_PUSH("live_stop_push", false), |
||||
|
||||
LIVE_SET_QUALITY("live_set_quality", false), |
||||
|
||||
FLIGHTTASK_CREATE("flighttask_create", false), |
||||
|
||||
DEBUG_MODE_OPEN("debug_mode_open", false), |
||||
|
||||
DEBUG_MODE_CLOSE("debug_mode_close", false), |
||||
|
||||
SUPPLEMENT_LIGHT_OPEN("supplement_light_open", false), |
||||
|
||||
SUPPLEMENT_LIGHT_CLOSE("supplement_light_close", false), |
||||
|
||||
RETURN_HOME("return_home", false), |
||||
|
||||
SDR_WORKMODE_SWITCH("sdr_workmode_switch", false), |
||||
|
||||
DEVICE_REBOOT("device_reboot", true), |
||||
|
||||
DRONE_OPEN("drone_open", true), |
||||
|
||||
DRONE_CLOSE("drone_close", true), |
||||
|
||||
DEVICE_CHECK("device_check", true), |
||||
|
||||
DRONE_FORMAT("drone_format", true), |
||||
|
||||
DEVICE_FORMAT("device_format", true), |
||||
|
||||
COVER_OPEN("cover_open", true), |
||||
|
||||
COVER_CLOSE("cover_close", true), |
||||
|
||||
PUTTER_OPEN("putter_open", true), |
||||
|
||||
PUTTER_CLOSE("putter_close", true), |
||||
|
||||
CHARGE_OPEN("charge_open", true), |
||||
|
||||
CHARGE_CLOSE("charge_close", true), |
||||
|
||||
OTA_CREATE("ota_create", true), |
||||
|
||||
FILE_UPLOAD_LIST("fileupload_list", false), |
||||
|
||||
FILE_UPLOAD_START("fileupload_start", true), |
||||
|
||||
FILE_UPLOAD_UPDATE("fileupload_update", false), |
||||
|
||||
UNKNOWN("unknown", false); |
||||
|
||||
private String method; |
||||
|
||||
private Boolean progress; |
||||
|
||||
ServicesMethodEnum(String method, Boolean progress) { |
||||
this.method = method; |
||||
this.progress = progress; |
||||
} |
||||
|
||||
public static ServicesMethodEnum find(String method) { |
||||
return Arrays.stream(ServicesMethodEnum.values()) |
||||
.filter(methodEnum -> methodEnum.method.equals(method)) |
||||
.findAny() |
||||
.orElse(UNKNOWN); |
||||
} |
||||
|
||||
public String getMethod() { |
||||
return method; |
||||
} |
||||
|
||||
public Boolean getProgress() { |
||||
return progress; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
package com.dji.sample.component.mqtt.model; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/28 |
||||
*/ |
||||
@Data |
||||
public class SetReply { |
||||
|
||||
private Integer result; |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
package com.dji.sample.component.mqtt.model; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/28 |
||||
*/ |
||||
@Getter |
||||
public enum SetReplyStatusResultEnum { |
||||
|
||||
SUCCESS(0, "success"), |
||||
|
||||
FAILED(1, "failed"), |
||||
|
||||
TIMEOUT(2, "timeout"), |
||||
|
||||
UNKNOWN(-1, "unknown"); |
||||
|
||||
int val; |
||||
|
||||
String desc; |
||||
|
||||
SetReplyStatusResultEnum(int val, String desc) { |
||||
this.val = val; |
||||
this.desc = desc; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
package com.dji.sample.control.model.dto; |
||||
|
||||
import com.dji.sample.control.model.enums.BatteryStoreModeEnum; |
||||
import com.dji.sample.manage.model.receiver.BasicDeviceProperty; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/14 |
||||
*/ |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class BatteryStoreMode extends BasicDeviceProperty { |
||||
|
||||
private Integer value; |
||||
|
||||
@Override |
||||
public boolean valid() { |
||||
return Objects.nonNull(value) && BatteryStoreModeEnum.find(value).isPresent(); |
||||
} |
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
package com.dji.sample.control.model.enums; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/14 |
||||
*/ |
||||
@Getter |
||||
public enum BatteryStoreModeEnum { |
||||
|
||||
PLAN(1), |
||||
|
||||
EMERGENCY(2); |
||||
|
||||
Integer mode; |
||||
|
||||
BatteryStoreModeEnum(Integer mode) { |
||||
this.mode = mode; |
||||
} |
||||
|
||||
public static Optional<BatteryStoreModeEnum> find(int mode) { |
||||
return Arrays.stream(BatteryStoreModeEnum.values()).filter(modeEnum -> modeEnum.mode == mode).findAny(); |
||||
} |
||||
} |
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
package com.dji.sample.control.model.enums; |
||||
|
||||
import com.dji.sample.control.model.dto.BatteryStoreMode; |
||||
import com.dji.sample.manage.model.enums.StateSwitchReceiver; |
||||
import com.dji.sample.manage.model.receiver.BasicDeviceProperty; |
||||
import lombok.Getter; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/14 |
||||
*/ |
||||
@Getter |
||||
public enum RemoteControlMethodEnum { |
||||
|
||||
DEBUG_MODE_OPEN("debug_mode_open", false, null), |
||||
|
||||
DEBUG_MODE_CLOSE("debug_mode_close", false, null), |
||||
|
||||
SUPPLEMENT_LIGHT_OPEN("supplement_light_open", false, null), |
||||
|
||||
SUPPLEMENT_LIGHT_CLOSE("supplement_light_close", false, null), |
||||
|
||||
RETURN_HOME("return_home", false, null), |
||||
|
||||
SDR_WORKMODE_SWITCH("sdr_workmode_switch", false, null), |
||||
|
||||
DEVICE_REBOOT("device_reboot", true, null), |
||||
|
||||
DRONE_OPEN("drone_open", true, null), |
||||
|
||||
DRONE_CLOSE("drone_close", true, null), |
||||
|
||||
DEVICE_CHECK("device_check", true, null), |
||||
|
||||
DRONE_FORMAT("drone_format", true, null), |
||||
|
||||
DEVICE_FORMAT("device_format", true, null), |
||||
|
||||
COVER_OPEN("cover_open", true, null), |
||||
|
||||
COVER_CLOSE("cover_close", true, null), |
||||
|
||||
PUTTER_OPEN("putter_open", true, null), |
||||
|
||||
PUTTER_CLOSE("putter_close", true, null), |
||||
|
||||
CHARGE_OPEN("charge_open", true, null), |
||||
|
||||
CHARGE_CLOSE("charge_close", true, null), |
||||
|
||||
BATTERY_MAINTENANCE_SWITCH("battery_maintenance_switch", true, StateSwitchReceiver.class), |
||||
|
||||
ALARM_STATE_SWITCH("alarm_state_switch", true, StateSwitchReceiver.class), |
||||
|
||||
BATTERY_STORE_MODE_SWITCH("battery_store_mode_switch", true, BatteryStoreMode.class), |
||||
|
||||
UNKNOWN("unknown", false, null); |
||||
|
||||
private String method; |
||||
|
||||
private Boolean progress; |
||||
|
||||
private Class<? extends BasicDeviceProperty> clazz; |
||||
|
||||
RemoteControlMethodEnum(String method, Boolean progress, Class<? extends BasicDeviceProperty> clazz) { |
||||
this.method = method; |
||||
this.progress = progress; |
||||
this.clazz = clazz; |
||||
} |
||||
|
||||
public static RemoteControlMethodEnum find(String method) { |
||||
return Arrays.stream(RemoteControlMethodEnum.values()) |
||||
.filter(methodEnum -> methodEnum.method.equals(method)) |
||||
.findAny() |
||||
.orElse(UNKNOWN); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package com.dji.sample.control.model.param; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/14 |
||||
*/ |
||||
@Data |
||||
public class RemoteDebugParam { |
||||
|
||||
private Integer action; |
||||
|
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
package com.dji.sample.manage.model.common; |
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/10 |
||||
*/ |
||||
@Component |
||||
@ConfigurationProperties("ntp.server") |
||||
public class NtpServerProperties { |
||||
|
||||
public static String host; |
||||
|
||||
public void setHost(String host) { |
||||
NtpServerProperties.host = host; |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
package com.dji.sample.manage.model.dto; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/10 |
||||
*/ |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class NtpServerDTO { |
||||
|
||||
private String ntpServerHost; |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
package com.dji.sample.manage.model.enums; |
||||
|
||||
import com.dji.sample.manage.model.receiver.BasicDeviceProperty; |
||||
import com.dji.sample.manage.model.receiver.DistanceLimitStatusReceiver; |
||||
import com.dji.sample.manage.model.receiver.HeightLimitReceiver; |
||||
import com.dji.sample.manage.model.receiver.ObstacleAvoidanceReceiver; |
||||
import lombok.Getter; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/27 |
||||
*/ |
||||
@Getter |
||||
public enum DeviceSetPropertyEnum { |
||||
|
||||
NIGHT_LIGHTS_STATE("night_lights_state", StateSwitchReceiver.class), |
||||
|
||||
HEIGHT_LIMIT("height_limit", HeightLimitReceiver.class), |
||||
|
||||
DISTANCE_LIMIT_STATUS("distance_limit_status", DistanceLimitStatusReceiver.class), |
||||
|
||||
OBSTACLE_AVOIDANCE("obstacle_avoidance", ObstacleAvoidanceReceiver.class); |
||||
|
||||
|
||||
String property; |
||||
|
||||
Class<? extends BasicDeviceProperty> clazz; |
||||
|
||||
DeviceSetPropertyEnum(String property, Class<? extends BasicDeviceProperty> clazz) { |
||||
this.property = property; |
||||
this.clazz = clazz; |
||||
} |
||||
|
||||
public static Optional<DeviceSetPropertyEnum> find(String property) { |
||||
return Arrays.stream(DeviceSetPropertyEnum.values()).filter(propertyEnum -> propertyEnum.property.equals(property)).findAny(); |
||||
} |
||||
} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
package com.dji.sample.manage.model.enums; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/14 |
||||
*/ |
||||
@Getter |
||||
public enum FirmwareMethodEnum { |
||||
|
||||
OTA_CREATE("ota_create"); |
||||
|
||||
private String method; |
||||
|
||||
FirmwareMethodEnum(String method) { |
||||
this.method = method; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
package com.dji.sample.manage.model.enums; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/14 |
||||
*/ |
||||
@Getter |
||||
public enum LiveStreamMethodEnum { |
||||
|
||||
LIVE_START_PUSH("live_start_push"), |
||||
|
||||
LIVE_STOP_PUSH("live_stop_push"), |
||||
|
||||
LIVE_SET_QUALITY("live_set_quality"), |
||||
|
||||
LIVE_LENS_CHANGE("live_lens_change"), |
||||
|
||||
UNKNOWN("unknown"); |
||||
|
||||
private String method; |
||||
|
||||
LiveStreamMethodEnum(String method) { |
||||
this.method = method; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
package com.dji.sample.manage.model.enums; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/14 |
||||
*/ |
||||
@Getter |
||||
public enum LogsFileMethodEnum { |
||||
|
||||
FILE_UPLOAD_LIST("fileupload_list"), |
||||
|
||||
FILE_UPLOAD_START("fileupload_start"), |
||||
|
||||
FILE_UPLOAD_UPDATE("fileupload_update"), |
||||
|
||||
UNKNOWN("unknown"); |
||||
|
||||
private String method; |
||||
|
||||
LogsFileMethodEnum(String method) { |
||||
this.method = method; |
||||
} |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
package com.dji.sample.manage.model.enums; |
||||
|
||||
import com.dji.sample.manage.model.receiver.BasicDeviceProperty; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/28 |
||||
*/ |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class StateSwitchReceiver extends BasicDeviceProperty { |
||||
|
||||
public static final int DISABLE = 0; |
||||
|
||||
public static final int ENABLE = 1; |
||||
|
||||
private Integer value; |
||||
|
||||
@Override |
||||
public boolean valid() { |
||||
return Objects.nonNull(this.value) && (this.value == DISABLE || this.value == ENABLE); |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/3 |
||||
*/ |
||||
@Data |
||||
public class BackupBatteryReceiver { |
||||
|
||||
private Integer voltage; |
||||
|
||||
private Float temperature; |
||||
|
||||
@JsonProperty("switch") |
||||
private Integer batterySwitch; |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/27 |
||||
*/ |
||||
@Data |
||||
public class BasicDeviceProperty { |
||||
|
||||
public boolean valid() { |
||||
return false; |
||||
} |
||||
|
||||
public boolean canPublish(String fieldName, OsdSubDeviceReceiver osd) { |
||||
return valid(); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/3 |
||||
*/ |
||||
@Data |
||||
public class DeviceMaintainStatusReceiver { |
||||
|
||||
private List<MaintainStatusReceiver> maintainStatusArray; |
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import com.dji.sample.manage.model.enums.StateSwitchReceiver; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* The state of the drone's limited distance |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/27 |
||||
*/ |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class DistanceLimitStatusReceiver extends BasicDeviceProperty { |
||||
|
||||
private Integer state; |
||||
|
||||
private Integer distanceLimit; |
||||
|
||||
private static final int DISTANCE_MAX = 8000; |
||||
|
||||
private static final int DISTANCE_MIN = 15; |
||||
|
||||
@Override |
||||
public boolean valid() { |
||||
boolean valid = Objects.nonNull(state) || Objects.nonNull(distanceLimit); |
||||
if (Objects.nonNull(state)) { |
||||
valid = new StateSwitchReceiver(this.state).valid(); |
||||
} |
||||
if (Objects.nonNull(distanceLimit)) { |
||||
valid &= distanceLimit >= DISTANCE_MIN && distanceLimit <= DISTANCE_MAX; |
||||
} |
||||
return valid; |
||||
} |
||||
|
||||
@Override |
||||
public boolean canPublish(String fieldName, OsdSubDeviceReceiver osd) { |
||||
DistanceLimitStatusReceiver distanceLimitStatus = osd.getDistanceLimitStatus(); |
||||
switch (fieldName) { |
||||
case "state": |
||||
return Objects.isNull(distanceLimitStatus.getState()) || |
||||
Objects.nonNull(distanceLimitStatus.getState()) && |
||||
distanceLimitStatus.getState().intValue() != this.state; |
||||
case "distance_limit": |
||||
return Objects.isNull(distanceLimitStatus.getDistanceLimit()) || |
||||
Objects.nonNull(distanceLimitStatus.getDistanceLimit()) && |
||||
distanceLimitStatus.getDistanceLimit().intValue() != this.distanceLimit; |
||||
default: |
||||
throw new RuntimeException("Property " + fieldName + " does not exist."); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/3 |
||||
*/ |
||||
@Data |
||||
public class DockWirelessLinkReceiver { |
||||
|
||||
@JsonProperty("4g_freq_band") |
||||
private Float fourGFreqBand; |
||||
|
||||
@JsonProperty("4g_gnd_quality") |
||||
private Integer fourGGndQuality; |
||||
|
||||
@JsonProperty("4g_link_state") |
||||
private Integer fourGLinkState; |
||||
|
||||
@JsonProperty("4g_quality") |
||||
private Integer fourGQuality; |
||||
|
||||
@JsonProperty("4g_uav_quality") |
||||
private Integer fourGUavQuality; |
||||
|
||||
private Integer dongleNumber; |
||||
|
||||
private Integer linkWorkmode; |
||||
|
||||
private Float sdrFreqBand; |
||||
|
||||
private Integer sdrLinkState; |
||||
|
||||
private Integer sdrQuality; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.4 |
||||
* @date 2022/11/3 |
||||
*/ |
||||
@Data |
||||
public class DroneBatteryMaintenanceInfoReceiver { |
||||
|
||||
private Integer maintenanceState; |
||||
|
||||
private Long maintenanceTimeLeft; |
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/28 |
||||
*/ |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class HeightLimitReceiver extends BasicDeviceProperty { |
||||
|
||||
private static final int HEIGHT_LIMIT_MAX = 1500; |
||||
|
||||
private static final int HEIGHT_LIMIT_MIN = 20; |
||||
|
||||
private Integer value; |
||||
|
||||
@Override |
||||
public boolean valid() { |
||||
return Objects.nonNull(this.value) && this.value >= HEIGHT_LIMIT_MIN && this.value <= HEIGHT_LIMIT_MAX; |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/3 |
||||
*/ |
||||
@Data |
||||
public class MaintainStatusReceiver { |
||||
|
||||
private Integer state; |
||||
|
||||
private Integer lastMaintainType; |
||||
|
||||
private Long lastMaintainTime; |
||||
|
||||
private Long lastMaintainWorkSorties; |
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import com.dji.sample.manage.model.enums.StateSwitchReceiver; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/27 |
||||
*/ |
||||
@Data |
||||
public class ObstacleAvoidanceReceiver extends BasicDeviceProperty { |
||||
|
||||
private Integer horizon; |
||||
|
||||
private Integer upside; |
||||
|
||||
private Integer downside; |
||||
|
||||
@Override |
||||
public boolean valid() { |
||||
boolean valid = Objects.nonNull(this.horizon) || Objects.nonNull(this.upside) || Objects.nonNull(this.downside); |
||||
|
||||
StateSwitchReceiver stateSwitch = new StateSwitchReceiver(); |
||||
if (Objects.nonNull(this.horizon)) { |
||||
stateSwitch.setValue(this.horizon); |
||||
valid = stateSwitch.valid(); |
||||
} |
||||
if (Objects.nonNull(this.upside)) { |
||||
stateSwitch.setValue(this.upside); |
||||
valid &= stateSwitch.valid(); |
||||
} |
||||
if (Objects.nonNull(this.downside)) { |
||||
stateSwitch.setValue(this.downside); |
||||
valid &= stateSwitch.valid(); |
||||
} |
||||
return valid; |
||||
} |
||||
|
||||
@Override |
||||
public boolean canPublish(String fieldName, OsdSubDeviceReceiver osd) { |
||||
ObstacleAvoidanceReceiver obstacleAvoidance = osd.getObstacleAvoidance(); |
||||
switch (fieldName) { |
||||
case "horizon": |
||||
return Objects.isNull(obstacleAvoidance.getHorizon()) || |
||||
Objects.nonNull(obstacleAvoidance.getHorizon()) && |
||||
obstacleAvoidance.getHorizon().intValue() != this.horizon; |
||||
case "upside": |
||||
return Objects.isNull(obstacleAvoidance.getUpside()) || |
||||
Objects.nonNull(obstacleAvoidance.getUpside()) && |
||||
obstacleAvoidance.getUpside().intValue() != this.upside; |
||||
case "downside": |
||||
return Objects.isNull(obstacleAvoidance.getDownside()) || |
||||
Objects.nonNull(obstacleAvoidance.getDownside()) && |
||||
obstacleAvoidance.getDownside().intValue() != this.downside; |
||||
default: |
||||
throw new RuntimeException("Property " + fieldName + " does not exist."); |
||||
} |
||||
} |
||||
} |
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.1 |
||||
* @date 2022/6/17 |
||||
*/ |
||||
@Data |
||||
public class OsdDockTransmissionReceiver { |
||||
|
||||
private Integer flighttaskStepCode; |
||||
|
||||
private DockMediaFileDetailReceiver mediaFileDetail; |
||||
|
||||
private DockSdrReceiver sdr; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package com.dji.sample.manage.model.receiver; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/10 |
||||
*/ |
||||
@Data |
||||
public class RequestConfigReceiver { |
||||
|
||||
private String configType; |
||||
|
||||
private String configScope; |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package com.dji.sample.manage.service; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/10 |
||||
*/ |
||||
public interface IRequestsConfigService { |
||||
|
||||
/** |
||||
* Get the parameters required by config method. |
||||
* @return |
||||
*/ |
||||
Object getConfig(); |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
package com.dji.sample.manage.service.impl; |
||||
|
||||
import com.dji.sample.manage.model.common.NtpServerProperties; |
||||
import com.dji.sample.manage.model.dto.NtpServerDTO; |
||||
import com.dji.sample.manage.service.IRequestsConfigService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/10 |
||||
*/ |
||||
@Service |
||||
public class ConfigProductServiceImpl implements IRequestsConfigService { |
||||
|
||||
@Override |
||||
public Object getConfig() { |
||||
return new NtpServerDTO(NtpServerProperties.host); |
||||
} |
||||
} |
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
package com.dji.sample.manage.service.impl; |
||||
|
||||
import com.dji.sample.common.util.SpringBeanUtils; |
||||
import com.dji.sample.component.mqtt.model.*; |
||||
import com.dji.sample.component.mqtt.service.IMessageSenderService; |
||||
import com.dji.sample.manage.model.receiver.RequestConfigReceiver; |
||||
import com.dji.sample.manage.service.IRequestsConfigService; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.integration.annotation.ServiceActivator; |
||||
import org.springframework.integration.mqtt.support.MqttHeaders; |
||||
import org.springframework.messaging.MessageHeaders; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/10 |
||||
*/ |
||||
@Service |
||||
public class RequestConfigContext { |
||||
|
||||
@Autowired |
||||
private IMessageSenderService messageSenderService; |
||||
|
||||
@Autowired |
||||
private ObjectMapper objectMapper; |
||||
|
||||
|
||||
/** |
||||
* Handles the config method of the requests topic. |
||||
* @param receiver |
||||
* @param headers |
||||
*/ |
||||
@ServiceActivator(inputChannel = ChannelName.INBOUND_REQUESTS_CONFIG, outputChannel = ChannelName.OUTBOUND) |
||||
void handleConfig(CommonTopicReceiver receiver, MessageHeaders headers) { |
||||
RequestConfigReceiver configReceiver = objectMapper.convertValue(receiver.getData(), RequestConfigReceiver.class); |
||||
Optional<ConfigScopeEnum> scopeEnumOpt = ConfigScopeEnum.find(configReceiver.getConfigScope()); |
||||
String topic = headers.get(MqttHeaders.RECEIVED_TOPIC) + TopicConst._REPLY_SUF; |
||||
CommonTopicResponse.CommonTopicResponseBuilder<Object> build = CommonTopicResponse.builder() |
||||
.tid(receiver.getTid()) |
||||
.bid(receiver.getBid()) |
||||
.timestamp(System.currentTimeMillis()) |
||||
.method(receiver.getMethod()); |
||||
if (scopeEnumOpt.isEmpty()) { |
||||
messageSenderService.publish(topic, build.build()); |
||||
return; |
||||
} |
||||
|
||||
IRequestsConfigService requestsConfigService = SpringBeanUtils.getBean(scopeEnumOpt.get().getClazz()); |
||||
build.data(requestsConfigService.getConfig()); |
||||
messageSenderService.publish(topic, build.build()); |
||||
} |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
package com.dji.sample.wayline.model.dto; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/10/27 |
||||
*/ |
||||
public class KmzFileProperties { |
||||
|
||||
private KmzFileProperties() { |
||||
|
||||
} |
||||
|
||||
public static final String WAYLINE_FILE_SUFFIX = ".kmz"; |
||||
|
||||
public static final String FILE_DIR_FIRST = "wpmz"; |
||||
|
||||
public static final String FILE_DIR_SECOND_RES = "res"; |
||||
|
||||
public static final String FILE_DIR_SECOND_TEMPLATE = "template.kml"; |
||||
|
||||
public static final String FILE_DIR_SECOND_WAYLINES = "waylines.wpml"; |
||||
|
||||
public static final String TAG_WPML_PREFIX = "wpml:"; |
||||
|
||||
public static final String TAG_DRONE_INFO = "droneInfo"; |
||||
|
||||
public static final String TAG_DRONE_ENUM_VALUE = "droneEnumValue"; |
||||
|
||||
public static final String TAG_DRONE_SUB_ENUM_VALUE = "droneSubEnumValue"; |
||||
|
||||
public static final String TAG_PAYLOAD_INFO = "payloadInfo"; |
||||
|
||||
public static final String TAG_PAYLOAD_ENUM_VALUE = "payloadEnumValue"; |
||||
|
||||
public static final String TAG_PAYLOAD_SUB_ENUM_VALUE = "payloadSubEnumValue"; |
||||
|
||||
public static final String TAG_TEMPLATE_ID = "templateId"; |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
package com.dji.sample.wayline.model.enums; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/9/26 |
||||
*/ |
||||
@Getter |
||||
public enum WaylineJobStatusEnum { |
||||
|
||||
PENDING(1, false), |
||||
|
||||
IN_PROGRESS(2, false), |
||||
|
||||
SUCCESS(3, true), |
||||
|
||||
CANCEL(4, true), |
||||
|
||||
FAILED(5, true), |
||||
|
||||
UNKNOWN(6, true); |
||||
|
||||
int val; |
||||
|
||||
Boolean end; |
||||
|
||||
WaylineJobStatusEnum(int val, boolean end) { |
||||
this.end = end; |
||||
this.val = val; |
||||
} |
||||
|
||||
public static WaylineJobStatusEnum find(int val) { |
||||
return Arrays.stream(WaylineJobStatusEnum.values()).filter(statue -> statue.val == val).findAny().orElse(UNKNOWN); |
||||
} |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
package com.dji.sample.wayline.model.enums; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/11/14 |
||||
*/ |
||||
@Getter |
||||
public enum WaylineMethodEnum { |
||||
|
||||
FLIGHT_TASK_PREPARE("flighttask_prepare"), |
||||
|
||||
FLIGHT_TASK_EXECUTE("flighttask_execute"), |
||||
|
||||
FLIGHT_TASK_CANCEL("flighttask_undo"); |
||||
|
||||
private String method; |
||||
|
||||
WaylineMethodEnum(String method) { |
||||
this.method = method; |
||||
} |
||||
} |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
package com.dji.sample.wayline.model.enums; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/9/26 |
||||
*/ |
||||
@Getter |
||||
public enum WaylineTaskTypeEnum { |
||||
|
||||
IMMEDIATE(0), |
||||
|
||||
TIMED(1); |
||||
|
||||
int val; |
||||
|
||||
WaylineTaskTypeEnum(int val) { |
||||
this.val = val; |
||||
} |
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
package com.dji.sample.wayline.model.enums; |
||||
|
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* @author sean |
||||
* @version 1.3 |
||||
* @date 2022/9/26 |
||||
*/ |
||||
@Getter |
||||
public enum WaylineTemplateTypeEnum { |
||||
|
||||
WAYPOINT(0), |
||||
|
||||
MAPPING_2D(1), |
||||
|
||||
MAPPING_3D(2), |
||||
|
||||
MAPPING_STRIP(4); |
||||
|
||||
int val; |
||||
|
||||
WaylineTemplateTypeEnum(int val) { |
||||
this.val = val; |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue