🛰️航天仿真算法库 SpaceAST 0.4.0
载入中...
搜索中...
未找到
SpiceAPI.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include <mutex>
25#include <vector>
26#include <string>
27#include <array>
28#include <cstdint>
29#include <map>
30
31AST_NAMESPACE_BEGIN
32
45class AST_CORE_API SpiceAPI
46{
47public:
48 // 函数索引
49 enum{
50 ifurnsh = 0,
51 ispkgeo,
52 ispkssb,
53 ispklef,
54 ispkuef,
55 iktotal,
56 ibodc2n,
57 ierract,
58 ifailed,
59 ireset,
60 ikclear,
61 numfunctions,
62 };
63 using funcarray = std::array<void*, numfunctions>;
64
67 static SpiceAPI* Instance();
68
70 SpiceAPI() = default;
71
73 explicit SpiceAPI(bool shouldLoadDynamicLib);
74
75 ~SpiceAPI();
76
80 errc_t load(StringView libpath);
81
86 errc_t tryload(const std::vector<std::string>& libpaths);
87
90 errc_t unload();
91
94 bool isLoaded() const { return library_ != nullptr; }
95public: // 包装函数
96
100 errc_t furnsh(const char* file);
101
110 errc_t spkgeo(
111 int targ,
112 double et,
113 const char * ref,
114 int obs,
115 double state[6],
116 double * lt
117 );
118
119
125 errc_t spkssb(
126 int targ,
127 double et,
128 const char *ref,
129 double starg[6]
130 );
131
132
138 errc_t spklef(const char* filename, int* handle);
139
144 errc_t spkuef(int handle);
145
150 errc_t ktotal(const char * kind, int* count);
151 int ktotal(const char * kind){
152 int count = 0;
153 ktotal(kind, &count);
154 return count;
155 }
156
158 void bodc2n(int code,
159 int namlen,
160 char * name,
161 bool * found);
162 errc_t bodc2n(int code, std::string& name);
163
166 bool failed();
167
169 void reset();
170
173 void erract(const char* operation, int lenout, char* action);
174
176 void kclear();
177protected:
178 errc_t checkerror();
179
186 void makeSpicePath(StringView path, std::string& spicePath);
187
188 A_DISABLE_COPY(SpiceAPI);
189protected:
190 void* library_{nullptr};
191 std::vector<uint32_t> spk_handles_{};
192 funcarray functions_{};
193 std::mutex mutex_{};
194};
195
196
197
200AST_NAMESPACE_END
Spice API
定义 SpiceAPI.hpp:46
SpiceAPI()=default
默认构造函数
bool isLoaded() const
检查是否加载了库
定义 SpiceAPI.hpp:94
errc_t spkssb(CelestialBody *targ, const TimePoint &et, Axes *ref, CartState &starg)
计算天体相对于太阳系质心的位置速度( S/P Kernel, solar system barycenter)
定义 SpiceZpr.cpp:1459