🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
PilotPlayer.hpp
浏览该文件的文档.
1
7
8#pragma once
9
10#include "AstGlobal.h"
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
37 // ---- 加载 ----
38 bool loadScript(const std::string& filePath);
39 bool loadJson(const std::string& jsonStr);
40
41 // ---- 执行 ----
42 void play(EPlayMode mode = EPlayMode::Sequential);
43 void pause();
44 void resume();
45 void step(); // 单步执行(StepByStep 模式)
46 void stop();
47 bool isPlaying() const { return running_; }
48
49 // ---- 状态 ----
50 int currentStep() const { return currentIndex_; }
51 int totalSteps() const { return static_cast<int>(steps_.size()); }
52 const std::string& lastError() const { return lastError_; }
53 std::string progress() const;
54
55Q_SIGNALS:
56 void stepStarted(int index, const std::string& description);
57 void stepCompleted(int index, const std::string& result);
58 void stepFailed(int index, const std::string& error);
59 void playbackFinished();
60 void playbackPaused();
61
62private:
63 void executeNextStep();
64 void executeStep(int index);
65 void retryStep(int index, int maxRetries = 2);
66 void continuePlayback(); // 延迟继续
67
68 PilotSession* session_;
69 std::vector<RecordStep> steps_;
70 int currentIndex_ = -1;
71 bool running_ = false;
72 bool paused_ = false;
73 std::string lastError_;
74};
75
78AST_NAMESPACE_END
录制步骤数据结构
录制脚本回放器
定义 PilotPlayer.hpp:28
AstUiPilot 对话会话
定义 PilotSession.hpp:40