🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
EventDetector.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstMath/ODEEventDetector.hpp"
25#include "AstUtil/ObjectNamed.hpp"
26
27AST_NAMESPACE_BEGIN
28
29
30class SpacecraftState;
31
32class ODEEventDetector;
33
37class AST_CORE_API EventDetector: public ObjectNamed
38{
39public:
41 AST_OBJECT(EventDetector)
42 AST_PROPERT(active)
43 AST_PROPERT(repeatCount)
44 AST_PROPERT(threshold)
45 AST_PROPERT(goal)
46 EventDetector() = default;
47 virtual ~EventDetector() = default;
48
53 virtual double getDifference(const SpacecraftState& state, double t) const{return getValue(state, t) - goal_;}
54
59 virtual double getValue(const SpacecraftState& state, double t) const = 0;
60
63 virtual bool isAngle() const {return false;}
64public:
65
69 ODEEventDetector* newODEEventDetector() const;
70
71public: // rtti 暂时不支持枚举类型
72
73 EDirection direction() const {return direction_;}
74 void setDirection(EDirection dir) {direction_ = dir;}
75
76PROPERTIES:
77
78 bool active() const {return active_;}
79 void setActive(bool active) {active_ = active;}
80
81 int repeatCount() const {return repeatCount_;}
82 void setRepeatCount(int count) {repeatCount_ = count;}
83
84
85 double threshold() const {return threshold_;}
86 void setThreshold(double threshold) {threshold_ = threshold;}
87
88 double goal() const {return goal_;}
89 void setGoal(double goal) {goal_ = goal;}
90
91private:
92 bool active_{true};
93 int repeatCount_{1};
94 EDirection direction_{EDirection::eBoth};
95 double threshold_{1e-10};
96 double goal_{0.0};
97};
98
99
102template<typename Func>
104{
105public:
106 explicit EventDetectorGeneric(Func func)
107 : func_(std::move(func))
108 {}
109
110 double getValue(const SpacecraftState& state, double t) const override {
111 return func_(state, t);
112 }
113
114private:
115 Func func_;
116};
117
118
119AST_NAMESPACE_END
泛型事件检测器
定义 EventDetector.hpp:104
double getValue(const SpacecraftState &state, double t) const override
获取事件检测开关函数的值
定义 EventDetector.hpp:110
事件检测基类 事件检测基类,用于检测事件是否发生。 参考orekit的EventDetector类
定义 EventDetector.hpp:38
virtual double getValue(const SpacecraftState &state, double t) const =0
获取事件检测开关函数的值
virtual bool isAngle() const
是否为角度事件检测器
定义 EventDetector.hpp:63
virtual double getDifference(const SpacecraftState &state, double t) const
获取事件检测开关函数与目标值的差值
定义 EventDetector.hpp:53
ODE积分的事件检测器
定义 ODEEventDetector.hpp:36
EDirection
事件检测开关函数的条件
定义 ODEEventDetector.hpp:40
命名对象
定义 ObjectNamed.hpp:36
航天器状态,包含轨道状态、质量、面积、阻力系数、光压、密度、压力、温度等属性
定义 SpacecraftState.hpp:38