296 lines
12 KiB
Java
296 lines
12 KiB
Java
package com.aros.apron.manager;
|
|
|
|
import static com.aros.apron.tools.Utils.getIDJIErrorMsg;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import com.aros.apron.base.BaseManager;
|
|
import com.aros.apron.entity.MessageDown;
|
|
import com.aros.apron.entity.PayloadInfo;
|
|
import com.aros.apron.entity.Synchronizedstatus;
|
|
import com.aros.apron.tools.LogUtil;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import dji.sdk.keyvalue.key.GimbalKey;
|
|
import dji.sdk.keyvalue.key.KeyTools;
|
|
import dji.sdk.keyvalue.value.common.EmptyMsg;
|
|
import dji.sdk.keyvalue.value.payload.WidgetType;
|
|
import dji.sdk.keyvalue.value.payload.WidgetValue;
|
|
import dji.v5.common.callback.CommonCallbacks;
|
|
import dji.v5.common.error.IDJIError;
|
|
import dji.v5.manager.KeyManager;
|
|
import dji.v5.manager.aircraft.payload.PayloadCenter;
|
|
import dji.v5.manager.aircraft.payload.PayloadIndexType;
|
|
import dji.v5.manager.interfaces.IPayloadManager;
|
|
|
|
/**
|
|
*夜航灯设置
|
|
*
|
|
*/
|
|
|
|
public class PayloadlightManager extends BaseManager {
|
|
private String TAG = this.getClass().getSimpleName();
|
|
private boolean issettrue=false;
|
|
private PayloadlightManager() {
|
|
}
|
|
|
|
private static class PayloadlightManagerHolder {
|
|
private static final PayloadlightManager INSTANCE = new PayloadlightManager();
|
|
}
|
|
|
|
public static PayloadlightManager getInstance() {
|
|
return PayloadlightManagerHolder.INSTANCE;
|
|
}
|
|
Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
IPayloadManager iPayloadManager;
|
|
public void setindex(int index){
|
|
if(index==1){
|
|
iPayloadManager = payloadManager.get(PayloadIndexType.PORT_1);
|
|
}else if(index==2){
|
|
iPayloadManager = payloadManager.get(PayloadIndexType.PORT_2);
|
|
}else if(index==3){
|
|
iPayloadManager = payloadManager.get(PayloadIndexType.PORT_3);
|
|
}else if(index==4){
|
|
iPayloadManager = payloadManager.get(PayloadIndexType.PORT_4);
|
|
}
|
|
}
|
|
|
|
public void drc_light_brightness_set(MessageDown message){
|
|
if(message!=null){
|
|
//索引
|
|
if(issettrue=false){
|
|
setindex(message.getData().getPsdk_index());
|
|
issettrue=true;
|
|
}
|
|
|
|
WidgetValue widgetValue=new WidgetValue();
|
|
widgetValue.setValue(message.getData().getBrightness());
|
|
widgetValue.setIndex(3);
|
|
widgetValue.setType(WidgetType.RANGE);
|
|
|
|
|
|
iPayloadManager.setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
@Override
|
|
public void onSuccess() {
|
|
LogUtil.log(TAG,"亮度设置成功");
|
|
sendMsg2Server(message);
|
|
Synchronizedstatus.setLight_brightnessrunning(false);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"亮度设置失败");
|
|
sendFailMsg2Server(message, "亮度设置失败:" + getIDJIErrorMsg(idjiError));
|
|
Synchronizedstatus.setLight_brightnessrunning(false);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
public void drc_light_mode_set(MessageDown message){
|
|
if(message!=null){
|
|
//索引
|
|
if(issettrue=false){
|
|
setindex(message.getData().getPsdk_index());
|
|
issettrue=true;
|
|
}
|
|
|
|
WidgetValue widgetValue=new WidgetValue();
|
|
|
|
|
|
if(message.getData().getMode()==0){
|
|
|
|
//关闭
|
|
widgetValue.setValue(0);
|
|
widgetValue.setIndex(2);
|
|
widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
iPayloadManager.setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
@Override
|
|
public void onSuccess() {
|
|
LogUtil.log(TAG,"探照灯关闭成功");
|
|
sendMsg2Server(message);
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"探照灯关闭失败");
|
|
sendFailMsg2Server(message, "探照灯关闭失败:" + getIDJIErrorMsg(idjiError));
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
}else if(message.getData().getMode()==1){
|
|
|
|
|
|
|
|
|
|
//打开
|
|
widgetValue.setValue(1);
|
|
widgetValue.setIndex(3);
|
|
widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
iPayloadManager.setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
@Override
|
|
public void onSuccess() {
|
|
LogUtil.log(TAG,"探照灯打开成功");
|
|
|
|
WidgetValue widgetValue1=new WidgetValue();
|
|
widgetValue1.setValue(0);
|
|
widgetValue1.setIndex(0);
|
|
widgetValue1.setType(WidgetType.SWITCH);
|
|
iPayloadManager.setWidgetValue(widgetValue1, new CommonCallbacks.CompletionCallback() {
|
|
@Override
|
|
public void onSuccess() {
|
|
LogUtil.log(TAG,"关闭爆闪模式成功");
|
|
WidgetValue widgetValue2=new WidgetValue();
|
|
widgetValue2.setValue(2);
|
|
widgetValue2.setIndex(2);
|
|
widgetValue2.setType(WidgetType.RANGE);
|
|
iPayloadManager.setWidgetValue(widgetValue2, new CommonCallbacks.CompletionCallback() {
|
|
@Override
|
|
public void onSuccess() {
|
|
LogUtil.log(TAG,"设置亮度全开");
|
|
sendMsg2Server(message);
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"设置亮度全开失败");
|
|
sendMsg2Server(message);
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"关闭爆闪模式失败");
|
|
sendMsg2Server(message);
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"探照灯打开失败");
|
|
sendMsg2Server(message);
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
}else{
|
|
//爆闪
|
|
widgetValue.setValue(1);
|
|
widgetValue.setIndex(3);
|
|
widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
iPayloadManager.setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
@Override
|
|
public void onSuccess() {
|
|
LogUtil.log(TAG,"探照灯打开成功");
|
|
WidgetValue widgetValue1=new WidgetValue();
|
|
widgetValue1.setValue(1);
|
|
widgetValue1.setIndex(0);
|
|
widgetValue1.setType(WidgetType.SWITCH);
|
|
iPayloadManager.setWidgetValue(widgetValue1, new CommonCallbacks.CompletionCallback() {
|
|
@Override
|
|
public void onSuccess() {
|
|
LogUtil.log(TAG,"爆闪模式打开成功");
|
|
|
|
WidgetValue widgetValue2=new WidgetValue();
|
|
widgetValue2.setValue(2);
|
|
widgetValue2.setIndex(2);
|
|
widgetValue2.setType(WidgetType.RANGE);
|
|
iPayloadManager.setWidgetValue(widgetValue2, new CommonCallbacks.CompletionCallback() {
|
|
@Override
|
|
public void onSuccess() {
|
|
LogUtil.log(TAG,"设置亮度全开");
|
|
sendMsg2Server(message);
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"设置亮度全开失败");
|
|
sendFailMsg2Server(message, "设置亮度全开失败:" + getIDJIErrorMsg(idjiError));
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"爆闪模式打开失败");
|
|
sendFailMsg2Server(message, "爆闪模式打开失败:" + getIDJIErrorMsg(idjiError));
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"探照灯打开失败");
|
|
sendFailMsg2Server(message, "探照灯打开失败:" + getIDJIErrorMsg(idjiError));
|
|
Synchronizedstatus.setDrc_light_mode_set(false);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
public void drc_light_calibration(MessageDown message){
|
|
if(message!=null) {
|
|
//索引
|
|
if (issettrue = false) {
|
|
setindex(message.getData().getPsdk_index());
|
|
issettrue = true;
|
|
}
|
|
KeyManager.getInstance().performAction(KeyTools.createKey(GimbalKey.KeyLightGimbalCalibrate), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() {
|
|
@Override
|
|
public void onSuccess(EmptyMsg emptyMsg) {
|
|
LogUtil.log(TAG,"启动校准");
|
|
sendMsg2Server(message);
|
|
Synchronizedstatus.setDrc_light_calibration(false);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
LogUtil.log(TAG,"启动校准失败");
|
|
sendFailMsg2Server(message, "启动校准失败:" + getIDJIErrorMsg(idjiError));
|
|
Synchronizedstatus.setDrc_light_calibration(false);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public void drc_light_fine_tuning_set(){
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|