修改日志采用日志框架打印
This commit is contained in:
parent
a0eccffb45
commit
ef057bb526
7
pom.xml
7
pom.xml
|
|
@ -64,5 +64,12 @@
|
|||
<version>3.14.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public class AirportMachineConfig {
|
|||
@Bean(name = "airportStateMachineFactory")
|
||||
public StateMachineFactory<AirportState, AirportEvent> stateMachineFactory(
|
||||
PlatformStrategyFactory platformStrategyFactory) throws Exception {
|
||||
|
||||
return new StateMachineFactory<AirportState, AirportEvent>() {
|
||||
@Override
|
||||
public StateMachine<AirportState, AirportEvent> getStateMachine() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.platform.strategy.PlatformListener;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
|
|
@ -14,30 +16,30 @@ import org.springframework.statemachine.transition.Transition;
|
|||
* 提供基础的状态变化监听功能,各平台可以继承并定制
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public abstract class DefaultAirportListener implements PlatformListener<AirportState, AirportEvent> {
|
||||
|
||||
|
||||
@Override
|
||||
public void stateChanged(State<AirportState, AirportEvent> from, State<AirportState, AirportEvent> to) {
|
||||
if (from != null && to != null) {
|
||||
System.out.println(String.format("[%s] 状态变化: %s -> %s",
|
||||
getName(), from.getId(), to.getId()));
|
||||
log.debug("[{}] 状态变化: {} -> {}", getName(), from.getId(), to.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateEntered(State<AirportState, AirportEvent> state) {
|
||||
System.out.println(String.format("[%s] 进入状态: %s", getName(), state.getId()));
|
||||
log.debug("[{}] 进入状态: {}", getName(), state.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateExited(State<AirportState, AirportEvent> state) {
|
||||
System.out.println(String.format("[%s] 退出状态: %s", getName(), state.getId()));
|
||||
log.debug("[{}] 退出状态: {}", getName(), state.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventNotAccepted(Message<AirportEvent> event) {
|
||||
System.out.println(String.format("[%s] 事件未被接受: %s", getName(), event.getPayload()));
|
||||
log.warn("[{}] 事件未被接受: {}", getName(), event.getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -48,41 +50,41 @@ public abstract class DefaultAirportListener implements PlatformListener<Airport
|
|||
@Override
|
||||
public void transitionStarted(Transition<AirportState, AirportEvent> transition) {
|
||||
if (transition.getSource() != null && transition.getTarget() != null) {
|
||||
System.out.println(String.format("[%s] 转换开始: %s -> %s",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId()));
|
||||
log.debug("[{}] 转换开始: {} -> {}",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transitionEnded(Transition<AirportState, AirportEvent> transition) {
|
||||
if (transition.getSource() != null && transition.getTarget() != null) {
|
||||
System.out.println(String.format("[%s] 转换结束: %s -> %s",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId()));
|
||||
log.debug("[{}] 转换结束: {} -> {}",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineStarted(StateMachine<AirportState, AirportEvent> stateMachine) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[%s] 状态机启动: %s", getName(), machineId));
|
||||
log.info("[{}] 状态机启动: {}", getName(), machineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineStopped(StateMachine<AirportState, AirportEvent> stateMachine) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[%s] 状态机停止: %s", getName(), machineId));
|
||||
log.info("[{}] 状态机停止: {}", getName(), machineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineError(StateMachine<AirportState, AirportEvent> stateMachine, Exception exception) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.err.println(String.format("[%s] 状态机错误: %s, 异常: %s",
|
||||
getName(), machineId, exception.getMessage()));
|
||||
log.error("[{}] 状态机错误: {}, 异常信息: {}",
|
||||
getName(), machineId, exception.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendedStateChanged(Object key, Object value) {
|
||||
System.out.println(String.format("[%s] 扩展状态变化: %s = %s", getName(), key, value));
|
||||
log.info("[{}] 扩展状态变化: {} = {}", getName(), key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.platform.strategy.PlatformListener;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
|
|
@ -13,35 +15,29 @@ import org.springframework.statemachine.transition.Transition;
|
|||
* 默认舱门状态监听器
|
||||
* 提供基础的状态变化监听功能,各平台可以继承并定制
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public abstract class DefaultCoverListener implements PlatformListener<CoverState, CoverEvent> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "DefaultCoverListener";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(State<CoverState, CoverEvent> from, State<CoverState, CoverEvent> to) {
|
||||
if (from != null && to != null) {
|
||||
System.out.println(String.format("[%s] 状态变化: %s -> %s",
|
||||
getName(), from.getId(), to.getId()));
|
||||
log.debug("[{}] 状态变化: {} -> {}", getName(), from.getId(), to.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateEntered(State<CoverState, CoverEvent> state) {
|
||||
System.out.println(String.format("[%s] 进入状态: %s", getName(), state.getId()));
|
||||
log.debug("[{}] 进入状态: {}", getName(), state.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateExited(State<CoverState, CoverEvent> state) {
|
||||
System.out.println(String.format("[%s] 退出状态: %s", getName(), state.getId()));
|
||||
log.debug("[{}] 退出状态: {}", getName(), state.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventNotAccepted(Message<CoverEvent> event) {
|
||||
System.out.println(String.format("[%s] 事件未被接受: %s", getName(), event.getPayload()));
|
||||
log.warn("[{}] 事件未被接受: {}", getName(), event.getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -52,41 +48,41 @@ public abstract class DefaultCoverListener implements PlatformListener<CoverStat
|
|||
@Override
|
||||
public void transitionStarted(Transition<CoverState, CoverEvent> transition) {
|
||||
if (transition.getSource() != null && transition.getTarget() != null) {
|
||||
System.out.println(String.format("[%s] 转换开始: %s -> %s",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId()));
|
||||
log.debug("[{}] 转换开始: {} -> {}",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transitionEnded(Transition<CoverState, CoverEvent> transition) {
|
||||
if (transition.getSource() != null && transition.getTarget() != null) {
|
||||
System.out.println(String.format("[%s] 转换结束: %s -> %s",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId()));
|
||||
log.debug("[{}] 转换结束: {} -> {}",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineStarted(StateMachine<CoverState, CoverEvent> stateMachine) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[%s] 状态机启动: %s", getName(), machineId));
|
||||
log.info("[{}] 状态机启动: {}", getName(), machineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineStopped(StateMachine<CoverState, CoverEvent> stateMachine) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[%s] 状态机停止: %s", getName(), machineId));
|
||||
log.info("[{}] 状态机停止: {}", getName(), machineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineError(StateMachine<CoverState, CoverEvent> stateMachine, Exception exception) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.err.println(String.format("[%s] 状态机错误: %s, 异常: %s",
|
||||
getName(), machineId, exception.getMessage()));
|
||||
log.error("[{}] 状态机错误: {}, 异常信息: {}",
|
||||
getName(), machineId, exception.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendedStateChanged(Object key, Object value) {
|
||||
System.out.println(String.format("[%s] 扩展状态变化: %s = %s", getName(), key, value));
|
||||
log.info("[{}] 扩展状态变化: {} = {}", getName(), key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
package com.tuoheng.machine.listener;
|
||||
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.platform.strategy.PlatformListener;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
|
|
@ -13,29 +17,30 @@ import org.springframework.statemachine.transition.Transition;
|
|||
* 默认DRC状态监听器
|
||||
* 提供基础的状态变化监听功能,各平台可以继承并定制
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class DefaultDrcListener implements PlatformListener<DrcState, DrcEvent> {
|
||||
|
||||
|
||||
@Override
|
||||
public void stateChanged(State<DrcState, DrcEvent> from, State<DrcState, DrcEvent> to) {
|
||||
if (from != null && to != null) {
|
||||
System.out.println(String.format("[%s] 状态变化: %s -> %s",
|
||||
getName(), from.getId(), to.getId()));
|
||||
log.debug("[{}] 状态变化: {} -> {}", getName(), from.getId(), to.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateEntered(State<DrcState, DrcEvent> state) {
|
||||
System.out.println(String.format("[%s] 进入状态: %s", getName(), state.getId()));
|
||||
log.debug("[{}] 进入状态: {}", getName(), state.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateExited(State<DrcState, DrcEvent> state) {
|
||||
System.out.println(String.format("[%s] 退出状态: %s", getName(), state.getId()));
|
||||
log.debug("[{}] 退出状态: {}", getName(), state.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventNotAccepted(Message<DrcEvent> event) {
|
||||
System.out.println(String.format("[%s] 事件未被接受: %s", getName(), event.getPayload()));
|
||||
log.warn("[{}] 事件未被接受: {}", getName(), event.getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -46,41 +51,41 @@ public abstract class DefaultDrcListener implements PlatformListener<DrcState, D
|
|||
@Override
|
||||
public void transitionStarted(Transition<DrcState, DrcEvent> transition) {
|
||||
if (transition.getSource() != null && transition.getTarget() != null) {
|
||||
System.out.println(String.format("[%s] 转换开始: %s -> %s",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId()));
|
||||
log.debug("[{}] 转换开始: {} -> {}",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transitionEnded(Transition<DrcState, DrcEvent> transition) {
|
||||
if (transition.getSource() != null && transition.getTarget() != null) {
|
||||
System.out.println(String.format("[%s] 转换结束: %s -> %s",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId()));
|
||||
log.debug("[{}] 转换结束: {} -> {}",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineStarted(StateMachine<DrcState, DrcEvent> stateMachine) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[%s] 状态机启动: %s", getName(), machineId));
|
||||
log.info("[{}] 状态机启动: {}", getName(), machineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineStopped(StateMachine<DrcState, DrcEvent> stateMachine) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[%s] 状态机停止: %s", getName(), machineId));
|
||||
log.info("[{}] 状态机停止: {}", getName(), machineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineError(StateMachine<DrcState, DrcEvent> stateMachine, Exception exception) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.err.println(String.format("[%s] 状态机错误: %s, 异常: %s",
|
||||
getName(), machineId, exception.getMessage()));
|
||||
log.error("[{}] 状态机错误: {}, 异常信息: {}",
|
||||
getName(), machineId, exception.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendedStateChanged(Object key, Object value) {
|
||||
System.out.println(String.format("[%s] 扩展状态变化: %s = %s", getName(), key, value));
|
||||
log.info("[{}] 扩展状态变化: {} = {}", getName(), key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
package com.tuoheng.machine.listener;
|
||||
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.platform.strategy.PlatformListener;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
|
|
@ -13,29 +17,29 @@ import org.springframework.statemachine.transition.Transition;
|
|||
* 默认无人机状态监听器
|
||||
* 提供基础的状态变化监听功能,各平台可以继承并定制
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class DefaultDroneListener implements PlatformListener<DroneState, DroneEvent> {
|
||||
|
||||
@Override
|
||||
public void stateChanged(State<DroneState, DroneEvent> from, State<DroneState, DroneEvent> to) {
|
||||
if (from != null && to != null) {
|
||||
System.out.println(String.format("[%s] 状态变化: %s -> %s",
|
||||
getName(), from.getId(), to.getId()));
|
||||
log.debug("[{}] 状态变化: {} -> {}", getName(), from.getId(), to.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateEntered(State<DroneState, DroneEvent> state) {
|
||||
System.out.println(String.format("[%s] 进入状态: %s", getName(), state.getId()));
|
||||
log.debug("[{}] 进入状态: {}", getName(), state.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateExited(State<DroneState, DroneEvent> state) {
|
||||
System.out.println(String.format("[%s] 退出状态: %s", getName(), state.getId()));
|
||||
log.debug("[{}] 退出状态: {}", getName(), state.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventNotAccepted(Message<DroneEvent> event) {
|
||||
System.out.println(String.format("[%s] 事件未被接受: %s", getName(), event.getPayload()));
|
||||
log.warn("[{}] 事件未被接受: {}", getName(), event.getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -46,41 +50,41 @@ public abstract class DefaultDroneListener implements PlatformListener<DroneStat
|
|||
@Override
|
||||
public void transitionStarted(Transition<DroneState, DroneEvent> transition) {
|
||||
if (transition.getSource() != null && transition.getTarget() != null) {
|
||||
System.out.println(String.format("[%s] 转换开始: %s -> %s",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId()));
|
||||
log.debug("[{}] 转换开始: {} -> {}",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transitionEnded(Transition<DroneState, DroneEvent> transition) {
|
||||
if (transition.getSource() != null && transition.getTarget() != null) {
|
||||
System.out.println(String.format("[%s] 转换结束: %s -> %s",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId()));
|
||||
log.debug("[{}] 转换结束: {} -> {}",
|
||||
getName(), transition.getSource().getId(), transition.getTarget().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineStarted(StateMachine<DroneState, DroneEvent> stateMachine) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[%s] 状态机启动: %s", getName(), machineId));
|
||||
log.info("[{}] 状态机启动: {}", getName(), machineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineStopped(StateMachine<DroneState, DroneEvent> stateMachine) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[%s] 状态机停止: %s", getName(), machineId));
|
||||
log.info("[{}] 状态机停止: {}", getName(), machineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateMachineError(StateMachine<DroneState, DroneEvent> stateMachine, Exception exception) {
|
||||
String machineId = (String) stateMachine.getExtendedState().getVariables().get("machineId");
|
||||
System.err.println(String.format("[%s] 状态机错误: %s, 异常: %s",
|
||||
getName(), machineId, exception.getMessage()));
|
||||
log.error("[{}] 状态机错误: {}, 异常信息: {}",
|
||||
getName(), machineId, exception.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendedStateChanged(Object key, Object value) {
|
||||
System.out.println(String.format("[%s] 扩展状态变化: %s = %s", getName(), key, value));
|
||||
log.info("[{}] 扩展状态变化: {} = {}", getName(), key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.manager;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
|
|
@ -19,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
* 机巢系统管理器抽象类
|
||||
* 提供通用的业务编排能力,具体实现可按需扩展
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class AbstractAirportSystemManager implements AirportSystemManager {
|
||||
|
||||
/**
|
||||
|
|
@ -68,28 +71,28 @@ public abstract class AbstractAirportSystemManager implements AirportSystemManag
|
|||
AirportState currentState = airportService.getCurrentState(airportSn);
|
||||
|
||||
if (currentState == null) {
|
||||
System.out.println(String.format("同步机巢状态失败 - 机巢: %s, 状态机不存在", airportSn));
|
||||
log.error("同步机巢状态失败 - 机巢: {}, 状态机不存在", airportSn);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentState != AirportState.UNKNOWN) {
|
||||
System.out.println(String.format("同步机巢状态跳过 - 机巢: %s, 当前状态: %s (非UNKNOWN状态,无需同步)",
|
||||
airportSn, currentState));
|
||||
log.debug("同步机巢状态跳过 - 机巢: {}, 当前状态: {} (非UNKNOWN状态,无需同步)",
|
||||
airportSn, currentState);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 根据目标状态发送相应的事件
|
||||
AirportEvent event = getAirportEventForState(targetState);
|
||||
if (event == null) {
|
||||
System.out.println(String.format("同步机巢状态失败 - 机巢: %s, 无法为目标状态 %s 找到对应事件",
|
||||
airportSn, targetState));
|
||||
log.error("同步机巢状态失败 - 机巢: {}, 无法为目标状态 {} 找到对应事件",
|
||||
airportSn, targetState);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = airportService.sendEvent(airportSn, event);
|
||||
if (result) {
|
||||
System.out.println(String.format("同步机巢状态成功 - 机巢: %s, 从 UNKNOWN 同步到 %s",
|
||||
airportSn, targetState));
|
||||
log.info("同步机巢状态成功 - 机巢: {}, 从 UNKNOWN 同步到 {}",
|
||||
airportSn, targetState);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -106,28 +109,28 @@ public abstract class AbstractAirportSystemManager implements AirportSystemManag
|
|||
CoverState currentState = coverService.getCurrentState(airportSn);
|
||||
|
||||
if (currentState == null) {
|
||||
System.out.println(String.format("同步舱门状态失败 - 机巢: %s, 状态机不存在", airportSn));
|
||||
log.error("同步舱门状态失败 - 机巢: {}, 状态机不存在", airportSn);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentState != CoverState.UNKNOWN) {
|
||||
System.out.println(String.format("同步舱门状态跳过 - 机巢: %s, 当前状态: %s (非UNKNOWN状态,无需同步)",
|
||||
airportSn, currentState));
|
||||
log.debug("同步舱门状态跳过 - 机巢: {}, 当前状态: {} (非UNKNOWN状态,无需同步)",
|
||||
airportSn, currentState);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 根据目标状态发送相应的事件
|
||||
CoverEvent event = getCoverEventForState(targetState);
|
||||
if (event == null) {
|
||||
System.out.println(String.format("同步舱门状态失败 - 机巢: %s, 无法为目标状态 %s 找到对应事件",
|
||||
airportSn, targetState));
|
||||
log.error("同步舱门状态失败 - 机巢: {}, 无法为目标状态 {} 找到对应事件",
|
||||
airportSn, targetState);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = coverService.sendEvent(airportSn, event);
|
||||
if (result) {
|
||||
System.out.println(String.format("同步舱门状态成功 - 机巢: %s, 从 UNKNOWN 同步到 %s",
|
||||
airportSn, targetState));
|
||||
log.info("同步舱门状态成功 - 机巢: {}, 从 UNKNOWN 同步到 {}",
|
||||
airportSn, targetState);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -195,28 +198,28 @@ public abstract class AbstractAirportSystemManager implements AirportSystemManag
|
|||
DroneState currentState = droneService.getCurrentState(droneSn);
|
||||
|
||||
if (currentState == null) {
|
||||
System.out.println(String.format("同步无人机状态失败 - 无人机: %s, 状态机不存在", droneSn));
|
||||
log.error("同步无人机状态失败 - 无人机: {}, 状态机不存在", droneSn);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentState != DroneState.UNKNOWN) {
|
||||
System.out.println(String.format("同步无人机状态跳过 - 无人机: %s, 当前状态: %s (非UNKNOWN状态,无需同步)",
|
||||
droneSn, currentState));
|
||||
log.debug("同步无人机状态跳过 - 无人机: {}, 当前状态: {} (非UNKNOWN状态,无需同步)",
|
||||
droneSn, currentState);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 根据目标状态发送相应的事件
|
||||
DroneEvent event = getDroneEventForState(targetState);
|
||||
if (event == null) {
|
||||
System.out.println(String.format("同步无人机状态失败 - 无人机: %s, 无法为目标状态 %s 找到对应事件",
|
||||
droneSn, targetState));
|
||||
log.error("同步无人机状态失败 - 无人机: {}, 无法为目标状态 {} 找到对应事件",
|
||||
droneSn, targetState);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = droneService.sendEvent(droneSn, event);
|
||||
if (result) {
|
||||
System.out.println(String.format("同步无人机状态成功 - 无人机: %s, 从 UNKNOWN 同步到 %s",
|
||||
droneSn, targetState));
|
||||
log.info("同步无人机状态成功 - 无人机: {}, 从 UNKNOWN 同步到 {}",
|
||||
droneSn, targetState);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -233,28 +236,28 @@ public abstract class AbstractAirportSystemManager implements AirportSystemManag
|
|||
DrcState currentState = drcService.getCurrentState(airportSn);
|
||||
|
||||
if (currentState == null) {
|
||||
System.out.println(String.format("同步DRC状态失败 - 机巢: %s, 状态机不存在", airportSn));
|
||||
log.error("同步DRC状态失败 - 机巢: {}, 状态机不存在", airportSn);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentState != DrcState.UNKNOWN) {
|
||||
System.out.println(String.format("同步DRC状态跳过 - 机巢: %s, 当前状态: %s (非UNKNOWN状态,无需同步)",
|
||||
airportSn, currentState));
|
||||
log.debug("同步DRC状态跳过 - 机巢: {}, 当前状态: {} (非UNKNOWN状态,无需同步)",
|
||||
airportSn, currentState);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 根据目标状态发送相应的事件
|
||||
DrcEvent event = getDrcEventForState(targetState);
|
||||
if (event == null) {
|
||||
System.out.println(String.format("同步DRC状态失败 - 机巢: %s, 无法为目标状态 %s 找到对应事件",
|
||||
airportSn, targetState));
|
||||
log.error("同步DRC状态失败 - 机巢: {}, 无法为目标状态 {} 找到对应事件",
|
||||
airportSn, targetState);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = drcService.sendEvent(airportSn, event);
|
||||
if (result) {
|
||||
System.out.println(String.format("同步DRC状态成功 - 机巢: %s, 从 UNKNOWN 同步到 %s",
|
||||
airportSn, targetState));
|
||||
log.info("同步DRC状态成功 - 机巢: {}, 从 UNKNOWN 同步到 {}",
|
||||
airportSn, targetState);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.manager;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tuoheng.machine.manager.factory;
|
|||
import com.tuoheng.machine.manager.AirportSystemManager;
|
||||
import com.tuoheng.machine.platform.PlatformType;
|
||||
import com.tuoheng.machine.repository.AirportPlatformRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* 机巢系统管理器工厂
|
||||
* 根据机巢SN从数据库查询平台类型,返回对应的系统管理器
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AirportSystemManagerFactory {
|
||||
|
||||
|
|
@ -35,8 +37,8 @@ public class AirportSystemManagerFactory {
|
|||
public void registerManagers(List<AirportSystemManager> managers) {
|
||||
for (AirportSystemManager manager : managers) {
|
||||
managerMap.put(manager.getPlatformType(), manager);
|
||||
System.out.println(String.format("注册系统管理器: %s -> %s",
|
||||
manager.getPlatformType().getName(), manager.getClass().getSimpleName()));
|
||||
log.info("注册系统管理器: {} -> {}",
|
||||
manager.getPlatformType().getName(), manager.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.tuoheng.machine.platform.strategy.AirportPlatformStrategy;
|
|||
import com.tuoheng.machine.platform.strategy.CoverPlatformStrategy;
|
||||
import com.tuoheng.machine.platform.strategy.DronePlatformStrategy;
|
||||
import com.tuoheng.machine.platform.strategy.DrcPlatformStrategy;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* 平台策略工厂
|
||||
* 根据机巢/无人机SN从数据库查询平台类型,返回对应的平台策略
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PlatformStrategyFactory {
|
||||
|
||||
|
|
@ -65,29 +67,29 @@ public class PlatformStrategyFactory {
|
|||
// 注册机巢策略
|
||||
for (AirportPlatformStrategy strategy : airportStrategies) {
|
||||
airportStrategyMap.put(strategy.getPlatformType(), strategy);
|
||||
System.out.println(String.format("注册机巢平台策略: %s -> %s",
|
||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName()));
|
||||
log.info("注册机巢平台策略: {} -> {}",
|
||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
// 注册舱门策略
|
||||
for (CoverPlatformStrategy strategy : coverStrategies) {
|
||||
coverStrategyMap.put(strategy.getPlatformType(), strategy);
|
||||
System.out.println(String.format("注册舱门平台策略: %s -> %s",
|
||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName()));
|
||||
log.info("注册舱门平台策略: {} -> {}",
|
||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
// 注册无人机策略
|
||||
for (DronePlatformStrategy strategy : droneStrategies) {
|
||||
droneStrategyMap.put(strategy.getPlatformType(), strategy);
|
||||
System.out.println(String.format("注册无人机平台策略: %s -> %s",
|
||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName()));
|
||||
log.info("注册无人机平台策略: {} -> {}",
|
||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
// 注册DRC策略
|
||||
for (DrcPlatformStrategy strategy : drcStrategies) {
|
||||
drcStrategyMap.put(strategy.getPlatformType(), strategy);
|
||||
System.out.println(String.format("注册DRC平台策略: %s -> %s",
|
||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName()));
|
||||
log.info("注册DRC平台策略: {} -> {}",
|
||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ import com.tuoheng.machine.manager.AbstractAirportSystemManager;
|
|||
import com.tuoheng.machine.platform.PlatformType;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 大疆平台机巢系统管理器实现
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DjiAirportSystemManager extends AbstractAirportSystemManager {
|
||||
|
||||
@Override
|
||||
|
|
@ -41,7 +43,7 @@ public class DjiAirportSystemManager extends AbstractAirportSystemManager {
|
|||
@Override
|
||||
public boolean openDebugMode(String airportSn) {
|
||||
if (!airportService.isInState(airportSn, AirportState.ONLINE)) {
|
||||
System.out.println("机巢未在线,无法开启调试模式");
|
||||
log.warn("机巢未在线,无法开启调试模式");
|
||||
return false;
|
||||
}
|
||||
return airportService.sendEvent(airportSn, AirportEvent.DEBUG_MODE_OPEN);
|
||||
|
|
@ -55,11 +57,11 @@ public class DjiAirportSystemManager extends AbstractAirportSystemManager {
|
|||
@Override
|
||||
public boolean openCover(String airportSn) {
|
||||
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
|
||||
System.out.println("必须在调试模式下才能开舱");
|
||||
log.warn("机巢: {} 必须在调试模式下才能开舱", airportSn);
|
||||
return false;
|
||||
}
|
||||
if (coverService.isInState(airportSn, CoverState.OPENED)) {
|
||||
System.out.println("舱门已经打开");
|
||||
log.info("舱门已经打开");
|
||||
return false;
|
||||
}
|
||||
return coverService.sendEvent(airportSn, CoverEvent.OPEN);
|
||||
|
|
@ -73,11 +75,11 @@ public class DjiAirportSystemManager extends AbstractAirportSystemManager {
|
|||
@Override
|
||||
public boolean closeCover(String airportSn) {
|
||||
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
|
||||
System.out.println("必须在调试模式下才能关舱");
|
||||
log.warn("必须在调试模式下才能关舱");
|
||||
return false;
|
||||
}
|
||||
if (coverService.isInState(airportSn, CoverState.CLOSED)) {
|
||||
System.out.println("舱门已经关闭");
|
||||
log.info("机巢: {} 舱门已经关闭", airportSn);
|
||||
return false;
|
||||
}
|
||||
return coverService.sendEvent(airportSn, CoverEvent.CLOSE);
|
||||
|
|
@ -91,7 +93,7 @@ public class DjiAirportSystemManager extends AbstractAirportSystemManager {
|
|||
@Override
|
||||
public boolean rebootAirport(String airportSn) {
|
||||
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
|
||||
System.out.println("必须在调试模式下才能重启");
|
||||
log.warn("必须在调试模式下才能重启");
|
||||
return false;
|
||||
}
|
||||
return airportService.sendEvent(airportSn, AirportEvent.AIRPORT_REBOOT);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.debug.CloseDebugModeAction;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCloseDebugModeAction extends CloseDebugModeAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiCloseDebugModeAction extends CloseDebugModeAction {
|
|||
@Override
|
||||
public void execute(StateContext<AirportState, AirportEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 关闭调试模式: %s", machineId));
|
||||
log.info("[DJI] 关闭调试模式: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.airport.OfflineAction;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiOfflineAction extends OfflineAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiOfflineAction extends OfflineAction {
|
|||
@Override
|
||||
public void execute(StateContext<AirportState, AirportEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 机巢离线: %s", machineId));
|
||||
log.info("[DJI] 机巢离线: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.airport.OnlineAction;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiOnlineAction extends OnlineAction {
|
||||
|
||||
|
|
@ -17,7 +20,7 @@ public class DjiOnlineAction extends OnlineAction {
|
|||
@Override
|
||||
public void execute(StateContext<AirportState, AirportEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 机巢上线: %s", machineId));
|
||||
log.info("[DJI] 机巢上线: %s", machineId);
|
||||
// DJI平台特定的上线逻辑
|
||||
// 例如:初始化DJI SDK连接、注册设备等
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.debug.OpenDebugModeAction;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiOpenDebugModeAction extends OpenDebugModeAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiOpenDebugModeAction extends OpenDebugModeAction {
|
|||
@Override
|
||||
public void execute(StateContext<AirportState, AirportEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 开启调试模式: %s", machineId));
|
||||
log.info("[DJI] 开启调试模式: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.reboot.RebootAction;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiRebootAction extends RebootAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiRebootAction extends RebootAction {
|
|||
@Override
|
||||
public void execute(StateContext<AirportState, AirportEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 机巢重启: %s", machineId));
|
||||
log.info("[DJI] 机巢重启: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.reboot.RebootCompletedAction;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiRebootCompletedAction extends RebootCompletedAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiRebootCompletedAction extends RebootCompletedAction {
|
|||
@Override
|
||||
public void execute(StateContext<AirportState, AirportEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 重启完成: %s", machineId));
|
||||
log.info("[DJI] 重启完成: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.cover.CloseCoverAction;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCloseCoverAction extends CloseCoverAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiCloseCoverAction extends CloseCoverAction {
|
|||
@Override
|
||||
public void execute(StateContext<CoverState, CoverEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 开始关舱: %s", machineId));
|
||||
log.info("[DJI] 开始关舱: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.cover.CoverClosedAction;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCoverClosedAction extends CoverClosedAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiCoverClosedAction extends CoverClosedAction {
|
|||
@Override
|
||||
public void execute(StateContext<CoverState, CoverEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 舱门已关闭: %s", machineId));
|
||||
log.info("[DJI] 舱门已关闭: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.platform.strategy.PlatformAction;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCoverErrorAction implements PlatformAction<CoverState, CoverEvent> {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiCoverErrorAction implements PlatformAction<CoverState, CoverEven
|
|||
@Override
|
||||
public void execute(StateContext<CoverState, CoverEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 舱门错误: %s", machineId));
|
||||
log.info("[DJI] 舱门错误: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.cover.CoverOpenedAction;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCoverOpenedAction extends CoverOpenedAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiCoverOpenedAction extends CoverOpenedAction {
|
|||
@Override
|
||||
public void execute(StateContext<CoverState, CoverEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 舱门已打开: %s", machineId));
|
||||
log.info("[DJI] 舱门已打开: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.platform.strategy.PlatformAction;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCoverResetAction implements PlatformAction<CoverState, CoverEvent> {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiCoverResetAction implements PlatformAction<CoverState, CoverEven
|
|||
@Override
|
||||
public void execute(StateContext<CoverState, CoverEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 舱门重置: %s", machineId));
|
||||
log.info("[DJI] 舱门重置: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.cover.OpenCoverAction;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiOpenCoverAction extends OpenCoverAction {
|
||||
|
||||
|
|
@ -17,7 +20,7 @@ public class DjiOpenCoverAction extends OpenCoverAction {
|
|||
@Override
|
||||
public void execute(StateContext<CoverState, CoverEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 开始开舱: %s", machineId));
|
||||
log.info("[DJI] 开始开舱: %s", machineId);
|
||||
// DJI平台特定的开舱逻辑
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drc;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drc.EnterAction;
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiEnterAction extends EnterAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiEnterAction extends EnterAction {
|
|||
@Override
|
||||
public void execute(StateContext<DrcState, DrcEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 进入DRC模式: %s", machineId));
|
||||
log.info("[DJI] 进入DRC模式: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drc;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drc.EnteredAction;
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiEnteredAction extends EnteredAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiEnteredAction extends EnteredAction {
|
|||
@Override
|
||||
public void execute(StateContext<DrcState, DrcEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 已进入DRC模式: %s", machineId));
|
||||
log.info("[DJI] 已进入DRC模式: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drc;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drc.ExitAction;
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiExitAction extends ExitAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiExitAction extends ExitAction {
|
|||
@Override
|
||||
public void execute(StateContext<DrcState, DrcEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 退出DRC模式: %s", machineId));
|
||||
log.info("[DJI] 退出DRC模式: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drc;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drc.ExitedAction;
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiExitedAction extends ExitedAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiExitedAction extends ExitedAction {
|
|||
@Override
|
||||
public void execute(StateContext<DrcState, DrcEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 已退出DRC模式: %s", machineId));
|
||||
log.info("[DJI] 已退出DRC模式: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.ArriveAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiArriveAction extends ArriveAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiArriveAction extends ArriveAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机到达目的地: %s", machineId));
|
||||
log.info("[DJI] 无人机到达目的地: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.CancelPointAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCancelPointAction extends CancelPointAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiCancelPointAction extends CancelPointAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机取消指点: %s", machineId));
|
||||
log.info("[DJI] 无人机取消指点: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.OfflineAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiDroneOfflineAction extends OfflineAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiDroneOfflineAction extends OfflineAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机离线: %s", machineId));
|
||||
log.info("[DJI] 无人机离线: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.EmergencyStopAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiEmergencyStopAction extends EmergencyStopAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiEmergencyStopAction extends EmergencyStopAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机急停: %s", machineId));
|
||||
log.info("[DJI] 无人机急停: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.PointFlyingCompletedAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiPointFlyingCompletedAction extends PointFlyingCompletedAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiPointFlyingCompletedAction extends PointFlyingCompletedAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机指点飞行完成: %s", machineId));
|
||||
log.info("[DJI] 无人机指点飞行完成: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.PointPrepareCompletedAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiPointPrepareCompletedAction extends PointPrepareCompletedAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiPointPrepareCompletedAction extends PointPrepareCompletedAction
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机指点准备完成: %s", machineId));
|
||||
log.info("[DJI] 无人机指点准备完成: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.PointToFlyingAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiPointToFlyingAction extends PointToFlyingAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiPointToFlyingAction extends PointToFlyingAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机从指点返回飞行: %s", machineId));
|
||||
log.info("[DJI] 无人机从指点返回飞行: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.PointToReturnAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiPointToReturnAction extends PointToReturnAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiPointToReturnAction extends PointToReturnAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机从指点开始返航: %s", machineId));
|
||||
log.info("[DJI] 无人机从指点开始返航: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.PrepareCompletedAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiPrepareCompletedAction extends PrepareCompletedAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiPrepareCompletedAction extends PrepareCompletedAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机准备完成: %s", machineId));
|
||||
log.info("[DJI] 无人机准备完成: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.ResumeFlyingAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiResumeFlyingAction extends ResumeFlyingAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiResumeFlyingAction extends ResumeFlyingAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机恢复飞行: %s", machineId));
|
||||
log.info("[DJI] 无人机恢复飞行: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.ResumeReturnAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiResumeReturnAction extends ResumeReturnAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiResumeReturnAction extends ResumeReturnAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机恢复返航: %s", machineId));
|
||||
log.info("[DJI] 无人机恢复返航: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.ReturnCompletedAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiReturnCompletedAction extends ReturnCompletedAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiReturnCompletedAction extends ReturnCompletedAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机返航完成: %s", machineId));
|
||||
log.info("[DJI] 无人机返航完成: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.ReturnEmergencyStopAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiReturnEmergencyStopAction extends ReturnEmergencyStopAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiReturnEmergencyStopAction extends ReturnEmergencyStopAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机返航急停: %s", machineId));
|
||||
log.info("[DJI] 无人机返航急停: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.StartFlyingAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiStartFlyingAction extends StartFlyingAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiStartFlyingAction extends StartFlyingAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机开始飞行: %s", machineId));
|
||||
log.info("[DJI] 无人机开始飞行: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.StartPointingAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiStartPointingAction extends StartPointingAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiStartPointingAction extends StartPointingAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机开始指点操作: %s", machineId));
|
||||
log.info("[DJI] 无人机开始指点操作: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.StartPrepareAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiStartPrepareAction extends StartPrepareAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiStartPrepareAction extends StartPrepareAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机开始准备: %s", machineId));
|
||||
log.info("[DJI] 无人机开始准备: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.action.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.action.drone.StartReturnAction;
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiStartReturnAction extends StartReturnAction {
|
||||
|
||||
|
|
@ -17,6 +20,6 @@ public class DjiStartReturnAction extends StartReturnAction {
|
|||
@Override
|
||||
public void execute(StateContext<DroneState, DroneEvent> context) {
|
||||
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
|
||||
System.out.println(String.format("[DJI] 无人机开始返航: %s", machineId));
|
||||
log.info("[DJI] 无人机开始返航: %s", machineId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.debug.CanCloseDebugModeGuard;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCanCloseDebugModeGuard extends CanCloseDebugModeGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiCanCloseDebugModeGuard extends CanCloseDebugModeGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
|
||||
System.out.println("[DJI] 检查是否可以关闭调试模式");
|
||||
log.info("[DJI] 检查是否可以关闭调试模式");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.airport.CanOfflineGuard;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCanOfflineGuard extends CanOfflineGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiCanOfflineGuard extends CanOfflineGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
|
||||
System.out.println("[DJI] 检查机巢是否可以离线");
|
||||
log.info("[DJI] 检查机巢是否可以离线");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.airport.CanOnlineGuard;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
|
|
@ -9,6 +11,7 @@ import org.springframework.stereotype.Component;
|
|||
/**
|
||||
* DJI平台 - 机巢上线Guard
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCanOnlineGuard extends CanOnlineGuard {
|
||||
|
||||
|
|
@ -20,7 +23,7 @@ public class DjiCanOnlineGuard extends CanOnlineGuard {
|
|||
@Override
|
||||
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
|
||||
// DJI平台特定的上线检查逻辑
|
||||
System.out.println("[DJI] 检查机巢是否可以上线");
|
||||
log.info("[DJI] 检查机巢是否可以上线");
|
||||
// 这里可以添加DJI平台特定的检查逻辑,例如:
|
||||
// - 检查DJI设备连接状态
|
||||
// - 检查DJI固件版本
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.debug.IsDebugModeGuard;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiIsDebugModeGuard extends IsDebugModeGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiIsDebugModeGuard extends IsDebugModeGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
|
||||
System.out.println("[DJI] 检查是否处于调试模式");
|
||||
log.info("[DJI] 检查是否处于调试模式");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.debug.IsNotDebugModeGuard;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiIsNotDebugModeGuard extends IsNotDebugModeGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiIsNotDebugModeGuard extends IsNotDebugModeGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
|
||||
System.out.println("[DJI] 检查是否不在调试模式");
|
||||
log.info("[DJI] 检查是否不在调试模式");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.airport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.reboot.IsRebootCompletedGuard;
|
||||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiIsRebootCompletedGuard extends IsRebootCompletedGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiIsRebootCompletedGuard extends IsRebootCompletedGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
|
||||
System.out.println("[DJI] 检查重启是否完成");
|
||||
log.info("[DJI] 检查重启是否完成");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.cover.CanCloseCoverGuard;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCanCloseCoverGuard extends CanCloseCoverGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiCanCloseCoverGuard extends CanCloseCoverGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<CoverState, CoverEvent> context) {
|
||||
System.out.println("[DJI] 检查舱门是否可以关闭");
|
||||
log.info("[DJI] 检查舱门是否可以关闭");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.cover.CanOpenCoverGuard;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCanOpenCoverGuard extends CanOpenCoverGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiCanOpenCoverGuard extends CanOpenCoverGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<CoverState, CoverEvent> context) {
|
||||
System.out.println("[DJI] 检查舱门是否可以打开");
|
||||
log.info("[DJI] 检查舱门是否可以打开");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.cover.IsCoverClosedGuard;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiIsCoverClosedGuard extends IsCoverClosedGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiIsCoverClosedGuard extends IsCoverClosedGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<CoverState, CoverEvent> context) {
|
||||
System.out.println("[DJI] 检查舱门是否已关闭");
|
||||
log.info("[DJI] 检查舱门是否已关闭");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.cover;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.guard.cover.IsCoverOpenedGuard;
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiIsCoverOpenedGuard extends IsCoverOpenedGuard {
|
||||
|
||||
|
|
@ -16,7 +19,7 @@ public class DjiIsCoverOpenedGuard extends IsCoverOpenedGuard {
|
|||
|
||||
@Override
|
||||
public boolean evaluate(StateContext<CoverState, CoverEvent> context) {
|
||||
System.out.println("[DJI] 检查舱门是否已打开");
|
||||
log.info("[DJI] 检查舱门是否已打开");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.drc;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.guard.drc.CanEnterGuard;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
|
|
@ -9,6 +11,7 @@ import org.springframework.stereotype.Component;
|
|||
/**
|
||||
* DJI平台:检查是否可以进入DRC模式
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCanEnterGuard extends CanEnterGuard {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.drc;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.guard.drc.CanExitGuard;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
|
|
@ -9,6 +11,7 @@ import org.springframework.stereotype.Component;
|
|||
/**
|
||||
* DJI平台:检查是否可以退出DRC模式
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCanExitGuard extends CanExitGuard {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.platform.impl.dji.guard.drone;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.guard.drone.CanPointGuard;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
|
|
@ -10,6 +12,7 @@ import org.springframework.stereotype.Component;
|
|||
* DJI平台:检查无人机是否可以进行指点操作
|
||||
* 注意:返航中不可以指点
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DjiCanPointGuard extends CanPointGuard {
|
||||
|
||||
|
|
@ -24,7 +27,7 @@ public class DjiCanPointGuard extends CanPointGuard {
|
|||
|
||||
// 返航中不能指点
|
||||
if (currentState == DroneState.RETURNING) {
|
||||
System.out.println("[DJI] 返航中不能进行指点操作");
|
||||
log.info("[DJI] 返航中不能进行指点操作");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tuoheng.machine.repository;
|
||||
|
||||
import com.tuoheng.machine.platform.PlatformType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -10,6 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* 机巢平台映射仓储
|
||||
* 模拟数据库查询,存储机巢SN到平台类型的映射关系
|
||||
*/
|
||||
@Slf4j
|
||||
@Repository
|
||||
public class AirportPlatformRepository {
|
||||
|
||||
|
|
@ -49,7 +51,7 @@ public class AirportPlatformRepository {
|
|||
*/
|
||||
public void savePlatformMapping(String airportSn, PlatformType platformType) {
|
||||
airportPlatformMap.put(airportSn, platformType);
|
||||
System.out.println(String.format("保存平台映射: %s -> %s", airportSn, platformType.getName()));
|
||||
log.info("保存平台映射: {} -> {}", airportSn, platformType.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,7 +61,7 @@ public class AirportPlatformRepository {
|
|||
*/
|
||||
public void deletePlatformMapping(String airportSn) {
|
||||
airportPlatformMap.remove(airportSn);
|
||||
System.out.println(String.format("删除平台映射: %s", airportSn));
|
||||
log.info("删除平台映射: {}", airportSn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tuoheng.machine.service;
|
|||
import com.tuoheng.machine.events.AirportEvent;
|
||||
import com.tuoheng.machine.redis.RedisStateStore;
|
||||
import com.tuoheng.machine.status.AirportState;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
import org.springframework.statemachine.config.StateMachineFactory;
|
||||
|
|
@ -15,6 +16,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* 机巢状态机管理器
|
||||
* 负责管理多个机巢的状态机实例
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AirportMachineService {
|
||||
|
||||
|
|
@ -45,7 +47,7 @@ public class AirportMachineService {
|
|||
// 不从 Redis 恢复旧状态,等待第一次心跳同步真实状态
|
||||
// 这样可以避免服务器重启期间丢失心跳导致的状态不一致问题
|
||||
stateMachine.start();
|
||||
System.out.println(String.format("创建并启动状态机: %s, 初始状态: UNKNOWN (等待心跳同步)", id));
|
||||
log.info("创建并启动状态机: {}, 初始状态: UNKNOWN (等待心跳同步)", id);
|
||||
return stateMachine;
|
||||
});
|
||||
}
|
||||
|
|
@ -69,7 +71,7 @@ public class AirportMachineService {
|
|||
public AirportState getCurrentState(String airportSn) {
|
||||
StateMachine<AirportState, AirportEvent> stateMachine = stateMachineMap.get(airportSn);
|
||||
if (stateMachine == null) {
|
||||
System.out.println("状态机不存在: " + airportSn);
|
||||
log.warn("状态机不存在: {}", airportSn);
|
||||
return null;
|
||||
}
|
||||
return stateMachine.getState().getId();
|
||||
|
|
@ -112,11 +114,11 @@ public class AirportMachineService {
|
|||
if (result) {
|
||||
// 持久化最新状态
|
||||
redisStateStore.saveAirportState(airportSn, stateMachine.getState().getId());
|
||||
System.out.println(String.format("事件发送成功 - 机巢: %s, 事件: %s, 当前状态: %s",
|
||||
airportSn, event, getCurrentStates(airportSn)));
|
||||
log.info("事件发送成功 - 机巢: {}, 事件: {}, 当前状态: {}",
|
||||
airportSn, event, getCurrentStates(airportSn));
|
||||
} else {
|
||||
System.out.println(String.format("事件发送失败 - 机巢: %s, 事件: %s, 当前状态: %s",
|
||||
airportSn, event, getCurrentStates(airportSn)));
|
||||
log.warn("事件发送失败 - 机巢: {}, 事件: {}, 当前状态: {}",
|
||||
airportSn, event, getCurrentStates(airportSn));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -131,7 +133,7 @@ public class AirportMachineService {
|
|||
StateMachine<AirportState, AirportEvent> stateMachine = stateMachineMap.remove(airportSn);
|
||||
if (stateMachine != null) {
|
||||
stateMachine.stop();
|
||||
System.out.println("停止并移除状态机: " + airportSn);
|
||||
log.info("停止并移除状态机: {}", airportSn);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,6 +188,6 @@ public class AirportMachineService {
|
|||
public void restartStateMachine(String airportSn) {
|
||||
removeStateMachine(airportSn);
|
||||
getOrCreateStateMachine(airportSn);
|
||||
System.out.println("重启状态机: " + airportSn);
|
||||
log.info("重启状态机: {}", airportSn);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.CoverEvent;
|
||||
import com.tuoheng.machine.redis.RedisStateStore;
|
||||
import com.tuoheng.machine.status.CoverState;
|
||||
|
|
@ -14,6 +16,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
/**
|
||||
* 舱门状态机管理器
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CoverMachineService {
|
||||
|
||||
|
|
@ -32,7 +35,7 @@ public class CoverMachineService {
|
|||
// 不从 Redis 恢复旧状态,等待第一次心跳同步真实状态
|
||||
// 这样可以避免服务器重启期间丢失心跳导致的状态不一致问题
|
||||
stateMachine.start();
|
||||
System.out.println(String.format("创建并启动舱门状态机: %s, 初始状态: UNKNOWN (等待心跳同步)", id));
|
||||
log.info("创建并启动舱门状态机: %s, 初始状态: UNKNOWN (等待心跳同步)", id);
|
||||
return stateMachine;
|
||||
});
|
||||
}
|
||||
|
|
@ -52,11 +55,11 @@ public class CoverMachineService {
|
|||
if (result) {
|
||||
// 持久化最新状态
|
||||
redisStateStore.saveCoverState(airportSn, stateMachine.getState().getId());
|
||||
System.out.println(String.format("舱门事件发送成功 - 机巢: %s, 事件: %s, 当前状态: %s",
|
||||
airportSn, event, getCurrentState(airportSn)));
|
||||
log.info("舱门事件发送成功 - 机巢: {}, 事件: {}, 当前状态: {}",
|
||||
airportSn, event, getCurrentState(airportSn));
|
||||
} else {
|
||||
System.out.println(String.format("舱门事件发送失败 - 机巢: %s, 事件: %s, 当前状态: %s",
|
||||
airportSn, event, getCurrentState(airportSn)));
|
||||
log.error("舱门事件发送失败 - 机巢: {}, 事件: {}, 当前状态: {}",
|
||||
airportSn, event, getCurrentState(airportSn));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -74,7 +77,7 @@ public class CoverMachineService {
|
|||
StateMachine<CoverState, CoverEvent> stateMachine = stateMachineMap.remove(airportSn);
|
||||
if (stateMachine != null) {
|
||||
stateMachine.stop();
|
||||
System.out.println("停止并移除舱门状态机: " + airportSn);
|
||||
log.info("停止并移除舱门状态机: {}", airportSn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.DrcEvent;
|
||||
import com.tuoheng.machine.redis.RedisStateStore;
|
||||
import com.tuoheng.machine.status.DrcState;
|
||||
|
|
@ -15,6 +17,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* DRC状态机管理器
|
||||
* 负责管理多个机巢的DRC状态机实例
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DrcMachineService {
|
||||
|
||||
|
|
@ -45,7 +48,7 @@ public class DrcMachineService {
|
|||
// 不从 Redis 恢复旧状态,等待第一次心跳同步真实状态
|
||||
// 这样可以避免服务器重启期间丢失心跳导致的状态不一致问题
|
||||
stateMachine.start();
|
||||
System.out.println(String.format("创建并启动DRC状态机: %s, 初始状态: UNKNOWN (等待心跳同步)", id));
|
||||
log.info("创建并启动DRC状态机: %s, 初始状态: UNKNOWN (等待心跳同步)", id);
|
||||
return stateMachine;
|
||||
});
|
||||
}
|
||||
|
|
@ -69,7 +72,7 @@ public class DrcMachineService {
|
|||
public DrcState getCurrentState(String airportSn) {
|
||||
StateMachine<DrcState, DrcEvent> stateMachine = stateMachineMap.get(airportSn);
|
||||
if (stateMachine == null) {
|
||||
System.out.println("DRC状态机不存在: " + airportSn);
|
||||
log.info("DRC状态机不存在: {}", airportSn);
|
||||
return null;
|
||||
}
|
||||
return stateMachine.getState().getId();
|
||||
|
|
@ -112,11 +115,11 @@ public class DrcMachineService {
|
|||
if (result) {
|
||||
// 持久化最新状态
|
||||
redisStateStore.saveDrcState(airportSn, stateMachine.getState().getId());
|
||||
System.out.println(String.format("DRC事件发送成功 - 机巢: %s, 事件: %s, 当前状态: %s",
|
||||
airportSn, event, getCurrentStates(airportSn)));
|
||||
log.info("DRC事件发送成功 - 机巢: {}, 事件: {}, 当前状态: {}",
|
||||
airportSn, event, getCurrentStates(airportSn));
|
||||
} else {
|
||||
System.out.println(String.format("DRC事件发送失败 - 机巢: %s, 事件: %s, 当前状态: %s",
|
||||
airportSn, event, getCurrentStates(airportSn)));
|
||||
log.error("DRC事件发送失败 - 机巢: {}, 事件: {}, 当前状态: {}",
|
||||
airportSn, event, getCurrentStates(airportSn));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -131,7 +134,7 @@ public class DrcMachineService {
|
|||
StateMachine<DrcState, DrcEvent> stateMachine = stateMachineMap.remove(airportSn);
|
||||
if (stateMachine != null) {
|
||||
stateMachine.stop();
|
||||
System.out.println("停止并移除DRC状态机: " + airportSn);
|
||||
log.info("停止并移除DRC状态机: {}", airportSn);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,6 +189,6 @@ public class DrcMachineService {
|
|||
public void restartStateMachine(String airportSn) {
|
||||
removeStateMachine(airportSn);
|
||||
getOrCreateStateMachine(airportSn);
|
||||
System.out.println("重启DRC状态机: " + airportSn);
|
||||
log.info("重启DRC状态机: {}", airportSn);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tuoheng.machine.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.tuoheng.machine.events.DroneEvent;
|
||||
import com.tuoheng.machine.redis.RedisStateStore;
|
||||
import com.tuoheng.machine.status.DroneState;
|
||||
|
|
@ -15,6 +17,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* 无人机状态机管理器
|
||||
* 负责管理多个无人机的状态机实例
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DroneMachineService {
|
||||
|
||||
|
|
@ -45,7 +48,7 @@ public class DroneMachineService {
|
|||
// 不从 Redis 恢复旧状态,等待第一次心跳同步真实状态
|
||||
// 这样可以避免服务器重启期间丢失心跳导致的状态不一致问题
|
||||
stateMachine.start();
|
||||
System.out.println(String.format("创建并启动状态机: %s, 初始状态: UNKNOWN (等待心跳同步)", id));
|
||||
log.info("创建并启动状态机: %s, 初始状态: UNKNOWN (等待心跳同步)", id);
|
||||
return stateMachine;
|
||||
});
|
||||
}
|
||||
|
|
@ -69,7 +72,7 @@ public class DroneMachineService {
|
|||
public DroneState getCurrentState(String droneSn) {
|
||||
StateMachine<DroneState, DroneEvent> stateMachine = stateMachineMap.get(droneSn);
|
||||
if (stateMachine == null) {
|
||||
System.out.println("状态机不存在: " + droneSn);
|
||||
log.info("状态机不存在: {}", droneSn);
|
||||
return null;
|
||||
}
|
||||
return stateMachine.getState().getId();
|
||||
|
|
@ -112,11 +115,11 @@ public class DroneMachineService {
|
|||
if (result) {
|
||||
// 持久化最新状态
|
||||
redisStateStore.saveDroneState(droneSn, stateMachine.getState().getId());
|
||||
System.out.println(String.format("事件发送成功 - 无人机: %s, 事件: %s, 当前状态: %s",
|
||||
droneSn, event, getCurrentStates(droneSn)));
|
||||
log.info("事件发送成功 - 无人机: {}, 事件: {}, 当前状态: {}",
|
||||
droneSn, event, getCurrentStates(droneSn));
|
||||
} else {
|
||||
System.out.println(String.format("事件发送失败 - 无人机: %s, 事件: %s, 当前状态: %s",
|
||||
droneSn, event, getCurrentStates(droneSn)));
|
||||
log.error("事件发送失败 - 无人机: {}, 事件: {}, 当前状态: {}",
|
||||
droneSn, event, getCurrentStates(droneSn));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -131,7 +134,7 @@ public class DroneMachineService {
|
|||
StateMachine<DroneState, DroneEvent> stateMachine = stateMachineMap.remove(droneSn);
|
||||
if (stateMachine != null) {
|
||||
stateMachine.stop();
|
||||
System.out.println("停止并移除状态机: " + droneSn);
|
||||
log.info("停止并移除状态机: {}", droneSn);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,6 +189,6 @@ public class DroneMachineService {
|
|||
public void restartStateMachine(String droneSn) {
|
||||
removeStateMachine(droneSn);
|
||||
getOrCreateStateMachine(droneSn);
|
||||
System.out.println("重启状态机: " + droneSn);
|
||||
log.info("重启状态机: {}", droneSn);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue