🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
PilotPlayer.hpp
浏览该文件的文档.
1
7
8#pragma once
9
10#include "AstGlobal.h"
11#include "AstUiPilot/RecordStep.hpp"
12#include <QObject>
13#include <vector>
14#include <string>
15
16AST_NAMESPACE_BEGIN
17
18class PilotSession;
19
27class AST_UIPILOT_API PilotPlayer : public QObject
28{
29 Q_OBJECT
30
31public:
32 enum class EPlayMode { Sequential, StepByStep };
33
34 explicit PilotPlayer(PilotSession* session, QObject* parent = nullptr);
35 ~PilotPlayer() override;
36 PilotPlayer(const PilotPlayer&) = delete;
37 PilotPlayer& operator=(const PilotPlayer&) = delete;
38
39 // ---- 加载 ----
40 bool loadScript(const std::string& filePath);
41 bool loadJson(const std::string& jsonStr);
42
43 // ---- 执行 ----
44 void play(EPlayMode mode = EPlayMode::Sequential);
45 void pause();
46 void resume();
47 void step(); // 单步执行(StepByStep 模式)
48 void stop();
49 bool isPlaying() const { return running_; }
50
51 // ---- 状态 ----
52 int currentStep() const { return currentIndex_; }
53 int totalSteps() const { return static_cast<int>(steps_.size()); }
54 const std::string& lastError() const { return lastError_; }
55 std::string progress() const;
56
57Q_SIGNALS:
58 void stepStarted(int index, const std::string& description);
59 void stepCompleted(int index, const std::string& result);
60 void stepFailed(int index, const std::string& error);
61 void playbackFinished();
62 void playbackPaused();
63
64private:
65 void executeNextStep();
66 void executeStep(int index);
67 void retryStep(int index, int maxRetries = 2);
68 void continuePlayback(); // 延迟继续
69
70 PilotSession* session_;
71 std::vector<RecordStep> steps_{};
72 int currentIndex_ = -1;
73 bool running_ = false;
74 bool paused_ = false;
75 std::string lastError_{};
76};
77
80AST_NAMESPACE_END
录制脚本回放器
定义 PilotPlayer.hpp:28
AstUiPilot 对话会话
定义 PilotSession.hpp:40