🛰️航天仿真算法库 SpaceAST 0.3.1
载入中...
搜索中...
未找到
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
30AST_NAMESPACE_BEGIN
31
44class AST_CORE_API SpiceAPI
45{
46public:
47 // 函数索引
48 enum{
49 ifurnsh = 0,
50 ispkgeo,
51 ispkssb,
52 ispklef,
53 ispkuef,
54 iktotal,
55 ibodc2n,
56 ierract,
57 ifailed,
58 ireset,
59 ikclear,
60 numfunctions,
61 };
62 using funcarray = std::array<void*, numfunctions>;
63
66 static SpiceAPI* Instance();
67
69 SpiceAPI() = default;
70
72 explicit SpiceAPI(bool shouldLoadDynamicLib);
73
74 ~SpiceAPI();
75
79 errc_t load(StringView libpath);
80
85 errc_t tryload(const std::vector<std::string>& libpaths);
86
89 errc_t unload();
90
93 bool isLoaded() const { return library_ != nullptr; }
94public: // 包装函数
95
99 errc_t furnsh(const char* file);
100
109 errc_t spkgeo(
110 int targ,
111 double et,
112 const char * ref,
113 int obs,
114 double state[6],
115 double * lt
116 );
117
118
124 errc_t spkssb(
125 int targ,
126 double et,
127 const char *ref,
128 double starg[6]
129 );
130
131
137 errc_t spklef(const char* filename, int* handle);
138
143 errc_t spkuef(int handle);
144
149 errc_t ktotal(const char * kind, int* count);
150 int ktotal(const char * kind){
151 int count = 0;
152 ktotal(kind, &count);
153 return count;
154 }
155
157 void bodc2n(int code,
158 int namlen,
159 char * name,
160 bool * found);
161 errc_t bodc2n(int code, std::string& name);
162
165 bool failed();
166
168 void reset();
169
172 void erract(const char* operation, int lenout, char* action);
173
175 void kclear();
176protected:
177 errc_t checkerror();
178 A_DISABLE_COPY(SpiceAPI);
179protected:
180 void* library_{nullptr};
181 std::vector<uint32_t> spk_handles_{};
182 funcarray functions_{};
183 std::mutex mutex_{};
184};
185
186
187
190AST_NAMESPACE_END
Spice API
定义 SpiceAPI.hpp:45
SpiceAPI()=default
默认构造函数
bool isLoaded() const
检查是否加载了库
定义 SpiceAPI.hpp:93
errc_t spkssb(CelestialBody *targ, const TimePoint &et, Axes *ref, CartState &starg)
计算天体相对于太阳系质心的位置速度( S/P Kernel, solar system barycenter)
定义 SpiceZpr.cpp:1375