...
This commit is contained in:
@@ -151,15 +151,9 @@ public:
|
||||
double mjd{51544.5}; // J2000.0
|
||||
};
|
||||
|
||||
// typedef MccAngle coord_t;
|
||||
|
||||
// typedef MccAngle sideral_time_t;
|
||||
// typedef MccAngle pa_t;
|
||||
// typedef MccAngle eo_t;
|
||||
|
||||
|
||||
/* use of the same type fro representation of celestial and geodetic coordinates, celestial angles (e.g. P.A.),
|
||||
* sideral time */
|
||||
/* use of the same type for representation of celestial and geodetic coordinates, celestial angles (e.g. P.A.),
|
||||
* and sideral time */
|
||||
typedef AngleT coord_t;
|
||||
|
||||
typedef AngleT sideral_time_t;
|
||||
@@ -173,40 +167,51 @@ public:
|
||||
|
||||
MccMountAstromEngineERFA() = default;
|
||||
|
||||
MccMountAstromEngineERFA(engine_state_t state) : _currentState(std::move(state)) {}
|
||||
|
||||
MccMountAstromEngineERFA(MccMountAstromEngineERFA&&) = default;
|
||||
MccMountAstromEngineERFA& operator=(MccMountAstromEngineERFA&&) = default;
|
||||
MccMountAstromEngineERFA(engine_state_t state) : _currentState(std::move(state)), _stateMutex(new std::mutex) {}
|
||||
|
||||
MccMountAstromEngineERFA(const MccMountAstromEngineERFA&) = delete;
|
||||
MccMountAstromEngineERFA& operator=(const MccMountAstromEngineERFA&) = delete;
|
||||
|
||||
MccMountAstromEngineERFA(MccMountAstromEngineERFA&& other)
|
||||
: _currentState(std::move(other._currentState)), _stateMutex(std::move(other._stateMutex)) {};
|
||||
|
||||
MccMountAstromEngineERFA& operator=(MccMountAstromEngineERFA&& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
_currentState = std::move(other._currentState);
|
||||
_stateMutex = std::move(other._stateMutex);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
virtual ~MccMountAstromEngineERFA() = default;
|
||||
|
||||
void setState(engine_state_t state)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
_currentState = std::move(state);
|
||||
}
|
||||
|
||||
engine_state_t getState() const
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
return _currentState;
|
||||
}
|
||||
|
||||
void updateMeteo(meteo_t meteo)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
_currentState.meteo = std::move(meteo);
|
||||
}
|
||||
|
||||
error_t updateLeapSeconds(std::derived_from<std::basic_istream<char>> auto& stream, char comment_sym = '#')
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
if (!_currentState._leapSeconds.load(stream, comment_sym)) {
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_UPDATE_LEAPSECONDS;
|
||||
@@ -218,7 +223,7 @@ public:
|
||||
|
||||
error_t updateLeapSeconds(traits::mcc_input_char_range auto const& filename, char comment_sym = '#')
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
if (!_currentState._leapSeconds.load(filename, comment_sym)) {
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_UPDATE_LEAPSECONDS;
|
||||
@@ -230,7 +235,7 @@ public:
|
||||
|
||||
error_t updateBulletinA(std::derived_from<std::basic_istream<char>> auto& stream, char comment_sym = '*')
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
if (!_currentState._bulletinA.load(stream, comment_sym)) {
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_UPDATE_BULLETINA;
|
||||
@@ -242,7 +247,7 @@ public:
|
||||
|
||||
error_t updateBulletinA(traits::mcc_input_char_range auto const& filename, char comment_sym = '*')
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
if (!_currentState._bulletinA.load(filename, comment_sym)) {
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_UPDATE_BULLETINA;
|
||||
@@ -299,7 +304,7 @@ public:
|
||||
|
||||
error_t terrestrialTime(juldate_t juldate, juldate_t& tt)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
using real_days_t = std::chrono::duration<double, std::ratio<86400>>;
|
||||
|
||||
@@ -320,7 +325,7 @@ public:
|
||||
|
||||
error_t apparentSiderTime(juldate_t juldate, sideral_time_t& gst, bool islocal = false)
|
||||
{
|
||||
// std::lock_guard lock{_stateMutex};
|
||||
// std::lock_guard lock{*_stateMutex};
|
||||
|
||||
using real_days_t = std::chrono::duration<double, std::ratio<86400>>;
|
||||
|
||||
@@ -328,7 +333,7 @@ public:
|
||||
// double tt = juldate.mjd;
|
||||
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
auto dut1 = _currentState._bulletinA.DUT1(juldate.mjd);
|
||||
|
||||
@@ -384,7 +389,7 @@ public:
|
||||
|
||||
error_t refraction(refract_result_t& refr)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
eraRefco(_currentState.meteo.pressure, _currentState.meteo.temperature, _currentState.meteo.humidity,
|
||||
_currentState.wavelength, &refr.refa, &refr.refb);
|
||||
@@ -417,7 +422,7 @@ public:
|
||||
coord_t& alt,
|
||||
eo_t& eo)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
auto dut1 = _currentState._bulletinA.DUT1(juldate.mjd);
|
||||
|
||||
@@ -459,7 +464,7 @@ public:
|
||||
|
||||
error_t obs2icrs(MccCoordPairKind coord_kind, coord_t x, coord_t y, juldate_t juldate, coord_t ra, coord_t dec)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
auto dut1 = _currentState._bulletinA.DUT1(juldate.mjd);
|
||||
|
||||
@@ -516,7 +521,7 @@ public:
|
||||
|
||||
error_t hadec2azalt(coord_t ha, coord_t dec, coord_t& az, coord_t& alt)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
double r_az, r_alt;
|
||||
eraHd2ae(ha, dec, _currentState.lat, &r_az, &r_alt);
|
||||
@@ -529,7 +534,7 @@ public:
|
||||
|
||||
error_t azalt2hadec(coord_t az, coord_t alt, coord_t& ha, coord_t& dec)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
double r_ha, r_dec;
|
||||
|
||||
@@ -544,7 +549,7 @@ public:
|
||||
|
||||
error_t hadec2pa(coord_t ha, coord_t dec, pa_t& pa)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
pa = eraHd2pa(ha, dec, _currentState.lat);
|
||||
|
||||
@@ -566,7 +571,7 @@ public:
|
||||
protected:
|
||||
engine_state_t _currentState{};
|
||||
|
||||
mutable std::mutex _stateMutex;
|
||||
std::unique_ptr<std::mutex> _stateMutex;
|
||||
};
|
||||
|
||||
} // namespace mcc::astrom::erfa
|
||||
|
||||
Reference in New Issue
Block a user