...
This commit is contained in:
parent
e7c2826b5c
commit
464c262e08
@ -123,13 +123,19 @@ set(CNTR_PROTO_LIB comm_proto)
|
|||||||
add_library(${CNTR_PROTO_LIB} STATIC ${CNTR_PROTO_LIB_SRC})
|
add_library(${CNTR_PROTO_LIB} STATIC ${CNTR_PROTO_LIB_SRC})
|
||||||
|
|
||||||
|
|
||||||
set(MCC_LIBRARY_SRC mcc_mount_concepts.h mcc_mount.h mcc_mount_coord.h mcc_mount_events_states.h mcc_finite_state_machine.h
|
set(MCC_LIBRARY_SRC mcc_mount_concepts.h mcc_fsm_mount.h mcc_mount_coord.h mcc_mount_events_states.h mcc_finite_state_machine.h
|
||||||
mcc_mount_pec.h mcc_mount_pz.h mcc_traits.h mcc_mount_telemetry.h mcc_mount_config.h mcc_mount_astro_erfa.h mcc_astrom_iers.h mcc_astrom_iers_default.h mcc_utils.h)
|
mcc_mount_pec.h mcc_mount_pz.h mcc_traits.h mcc_mount_telemetry.h mcc_mount_config.h mcc_mount_astro_erfa.h mcc_astrom_iers.h mcc_astrom_iers_default.h
|
||||||
|
mcc_utils.h mcc_spdlog.h)
|
||||||
set(MCC_LIBRARY mcc)
|
set(MCC_LIBRARY mcc)
|
||||||
add_library(${MCC_LIBRARY} INTERFACE ${MCC_LIBRARY_SRC})
|
add_library(${MCC_LIBRARY} INTERFACE ${MCC_LIBRARY_SRC})
|
||||||
target_compile_features(${MCC_LIBRARY} INTERFACE cxx_std_23)
|
target_compile_features(${MCC_LIBRARY} INTERFACE cxx_std_23)
|
||||||
target_include_directories(${MCC_LIBRARY} INTERFACE ${FITPACK_INCLUDE_DIR})
|
target_include_directories(${MCC_LIBRARY} INTERFACE ${FITPACK_INCLUDE_DIR})
|
||||||
|
|
||||||
|
|
||||||
|
set(ASIBFM700_LIB_SRC asibfm700_hardware.h asibfm700_hardware.cpp)
|
||||||
|
set(ASIBFM700_LIB asibfm700)
|
||||||
|
add_library(${ASIBFM700_LIB} STATIC ${ASIBFM700_LIB_SRC})
|
||||||
|
|
||||||
# set(MOUNT_SERVER_APP_SRC mount.h mount_state.h mount_server.cpp comm_server.h comm_server_endpoint.h comm_server_configfile.h mount_astrom.h
|
# set(MOUNT_SERVER_APP_SRC mount.h mount_state.h mount_server.cpp comm_server.h comm_server_endpoint.h comm_server_configfile.h mount_astrom.h
|
||||||
# mount_astrom_default.h mcc_coord.h mount_pz.h mcc_fsm.h mcc_fsm_utils.h mcc_finite_state_machine.h mcc_mount_events_states.h)
|
# mount_astrom_default.h mcc_coord.h mount_pz.h mcc_fsm.h mcc_fsm_utils.h mcc_finite_state_machine.h mcc_mount_events_states.h)
|
||||||
# set(MOUNT_SERVER_APP mount_server)
|
# set(MOUNT_SERVER_APP mount_server)
|
||||||
|
|||||||
138
cxx/asibfm700_hardware.cpp
Normal file
138
cxx/asibfm700_hardware.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
#include "asibfm700_hardware.h"
|
||||||
|
|
||||||
|
using namespace asibfm700;
|
||||||
|
|
||||||
|
|
||||||
|
/* error category implementation */
|
||||||
|
|
||||||
|
const char* AsibFM700HardwareErrorCategory::name() const noexcept
|
||||||
|
{
|
||||||
|
return "ASTROSIB FM700 MOUNT HARDWARE ERROR CATEGORY";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string AsibFM700HardwareErrorCategory::message(int ec) const
|
||||||
|
{
|
||||||
|
AsibFM700HardwareErrorCode code = static_cast<AsibFM700HardwareErrorCode>(ec);
|
||||||
|
|
||||||
|
std::string msg;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
case AsibFM700HardwareErrorCode::ERROR_OK:
|
||||||
|
msg = "OK";
|
||||||
|
case asibfm700::AsibFM700HardwareErrorCode::ERROR_FATAL:
|
||||||
|
msg = "fatal hardware error";
|
||||||
|
case AsibFM700HardwareErrorCode::ERROR_BADFORMAT:
|
||||||
|
msg = "wrong arguments of function";
|
||||||
|
case AsibFM700HardwareErrorCode::ERROR_ENCODERDEV:
|
||||||
|
msg = "encoder device error or can't open";
|
||||||
|
case AsibFM700HardwareErrorCode::ERROR_MOUNTDEV:
|
||||||
|
msg = "mount device error or can't open";
|
||||||
|
case AsibFM700HardwareErrorCode::ERROR_FAILED:
|
||||||
|
msg = "failed to run command - protocol error";
|
||||||
|
default:
|
||||||
|
msg = "UNKNOWN ERROR";
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AsibFM700HardwareErrorCategory& AsibFM700HardwareErrorCategory::get()
|
||||||
|
{
|
||||||
|
static const AsibFM700HardwareErrorCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* AsibFM700Hardware CLASS IMPLEMENTATION */
|
||||||
|
|
||||||
|
|
||||||
|
/* static methods */
|
||||||
|
|
||||||
|
// void AsibFM700Hardware::moveInst(AsibFM700Hardware* from, AsibFM700Hardware* to)
|
||||||
|
// {
|
||||||
|
// to->_hwConfig = std::move(from->_hwConfig);
|
||||||
|
// to->_deviceConfig = std::move(from->_deviceConfig);
|
||||||
|
|
||||||
|
// from->_deviceConfig.MountDevPath = nullptr;
|
||||||
|
// from->_deviceConfig.EncoderDevPath = nullptr;
|
||||||
|
// from->_deviceConfig.EncoderXDevPath = nullptr;
|
||||||
|
// from->_deviceConfig.EncoderYDevPath = nullptr;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/* constructors and destructor */
|
||||||
|
|
||||||
|
AsibFM700Hardware::AsibFM700Hardware(const hardware_config_t& conf) : _hardwareConfig(conf)
|
||||||
|
{
|
||||||
|
_hardwareConfig.devConfig.MountDevPath = const_cast<char*>(_hardwareConfig.MountDevPath.c_str());
|
||||||
|
_hardwareConfig.devConfig.EncoderDevPath = const_cast<char*>(_hardwareConfig.EncoderDevPath.c_str());
|
||||||
|
_hardwareConfig.devConfig.EncoderXDevPath = const_cast<char*>(_hardwareConfig.EncoderXDevPath.c_str());
|
||||||
|
_hardwareConfig.devConfig.EncoderYDevPath = const_cast<char*>(_hardwareConfig.EncoderYDevPath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// AsibFM700Hardware::AsibFM700Hardware(AsibFM700Hardware&& other)
|
||||||
|
// {
|
||||||
|
// moveInst(&other, this);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// AsibFM700Hardware& AsibFM700Hardware::operator=(AsibFM700Hardware&& other)
|
||||||
|
// {
|
||||||
|
// moveInst(&other, this);
|
||||||
|
|
||||||
|
// return *this;
|
||||||
|
// }
|
||||||
|
|
||||||
|
AsibFM700Hardware::~AsibFM700Hardware() {}
|
||||||
|
|
||||||
|
std::string_view AsibFM700Hardware::id() const
|
||||||
|
{
|
||||||
|
return "Sidereal Technology Servo II controller";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AsibFM700Hardware::error_t AsibFM700Hardware::setPos(AsibFM700Hardware::axes_pos_t pos)
|
||||||
|
{
|
||||||
|
double X = pos.x, Y = pos.y;
|
||||||
|
auto err = static_cast<AsibFM700HardwareErrorCode>(Mount.moveTo(&X, &Y));
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AsibFM700Hardware::error_t AsibFM700Hardware::getPos(AsibFM700Hardware::axes_pos_t& pos)
|
||||||
|
{
|
||||||
|
mountdata_t data;
|
||||||
|
auto err = static_cast<AsibFM700HardwareErrorCode>(Mount.getMountData(&data));
|
||||||
|
|
||||||
|
if (err == AsibFM700HardwareErrorCode::ERROR_OK) {
|
||||||
|
// time point from sidservo library is 'struct timeval', i.e., seconds and
|
||||||
|
// microseconds ellapsed from UNIX time epoch
|
||||||
|
|
||||||
|
using secs_t = std::chrono::duration<double>;
|
||||||
|
secs_t secs = secs_t{1.0 * data.encposition.msrtime.tv_sec + 1.0E-6 * data.encposition.msrtime.tv_usec};
|
||||||
|
|
||||||
|
pos.time_point = time_point_t{std::chrono::duration_cast<time_point_t::duration>(secs)};
|
||||||
|
|
||||||
|
pos.x = data.encposition.X;
|
||||||
|
pos.y = data.encposition.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AsibFM700Hardware::error_t AsibFM700Hardware::stop()
|
||||||
|
{
|
||||||
|
auto err = static_cast<AsibFM700HardwareErrorCode>(Mount.stop());
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
AsibFM700Hardware::error_t AsibFM700Hardware::init()
|
||||||
|
{
|
||||||
|
auto err = static_cast<AsibFM700HardwareErrorCode>(Mount.init(&_hardwareConfig.devConfig));
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
128
cxx/asibfm700_hardware.h
Normal file
128
cxx/asibfm700_hardware.h
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* AstroSIB-FM700 FORK MOUNT CONTROL LIBRARY */
|
||||||
|
|
||||||
|
/* HARDWARE WRAPPER IMPLEMENTATION */
|
||||||
|
|
||||||
|
#include "../LibSidServo/sidservo.h"
|
||||||
|
|
||||||
|
#include "mcc_mount_concepts.h"
|
||||||
|
#include "mcc_mount_coord.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace asibfm700
|
||||||
|
{
|
||||||
|
|
||||||
|
/* error codes enum definition */
|
||||||
|
|
||||||
|
enum class AsibFM700HardwareErrorCode : int {
|
||||||
|
// error codes from sidservo library
|
||||||
|
ERROR_OK = MCC_E_OK,
|
||||||
|
ERROR_FATAL = MCC_E_FATAL,
|
||||||
|
ERROR_BADFORMAT = MCC_E_BADFORMAT,
|
||||||
|
ERROR_ENCODERDEV = MCC_E_ENCODERDEV,
|
||||||
|
ERROR_MOUNTDEV = MCC_E_MOUNTDEV,
|
||||||
|
ERROR_FAILED = MCC_E_FAILED,
|
||||||
|
// my codes ...
|
||||||
|
};
|
||||||
|
|
||||||
|
// error category
|
||||||
|
struct AsibFM700HardwareErrorCategory : public std::error_category {
|
||||||
|
const char* name() const noexcept;
|
||||||
|
std::string message(int ec) const;
|
||||||
|
|
||||||
|
static const AsibFM700HardwareErrorCategory& get();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(AsibFM700HardwareErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), AsibFM700HardwareErrorCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace asibfm700
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<asibfm700::AsibFM700HardwareErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace asibfm700
|
||||||
|
{
|
||||||
|
|
||||||
|
class AsibFM700Hardware final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// definitions from concept
|
||||||
|
typedef std::error_code error_t;
|
||||||
|
typedef mcc::MccAngle coord_t;
|
||||||
|
typedef std::chrono::system_clock::time_point time_point_t; // UTC time
|
||||||
|
|
||||||
|
struct axes_pos_t {
|
||||||
|
time_point_t time_point;
|
||||||
|
coord_t x, y;
|
||||||
|
};
|
||||||
|
|
||||||
|
// c++ish wrapper to 'conf_t' struct
|
||||||
|
|
||||||
|
struct device_config_t {
|
||||||
|
std::string MountDevPath; // path to mount device
|
||||||
|
int MountDevSpeed; // serial speed
|
||||||
|
std::string EncoderDevPath; // path to encoder device
|
||||||
|
int EncoderDevSpeed; // serial speed
|
||||||
|
int SepEncoder; // ==1 if encoder works as separate serial device, ==2 if there's new version with two devices
|
||||||
|
std::string EncoderXDevPath; // paths to new controller devices
|
||||||
|
std::string EncoderYDevPath;
|
||||||
|
double MountReqInterval; // interval between subsequent mount requests (seconds)
|
||||||
|
double EncoderReqInterval; // interval between subsequent encoder requests (seconds)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct hardware_config_t {
|
||||||
|
// the 'char*' fields from conf_t:
|
||||||
|
// wrap it to std::string
|
||||||
|
std::string MountDevPath;
|
||||||
|
std::string EncoderDevPath;
|
||||||
|
std::string EncoderXDevPath;
|
||||||
|
std::string EncoderYDevPath;
|
||||||
|
|
||||||
|
conf_t devConfig;
|
||||||
|
hardware_configuration_t hwConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
AsibFM700Hardware(const hardware_config_t& conf);
|
||||||
|
|
||||||
|
~AsibFM700Hardware();
|
||||||
|
|
||||||
|
AsibFM700Hardware(const AsibFM700Hardware&) = delete;
|
||||||
|
AsibFM700Hardware& operator=(const AsibFM700Hardware&) = delete;
|
||||||
|
|
||||||
|
AsibFM700Hardware(AsibFM700Hardware&&) = default;
|
||||||
|
AsibFM700Hardware& operator=(AsibFM700Hardware&&) = default;
|
||||||
|
|
||||||
|
|
||||||
|
std::string_view id() const;
|
||||||
|
|
||||||
|
error_t setPos(axes_pos_t);
|
||||||
|
error_t getPos(axes_pos_t&);
|
||||||
|
error_t stop();
|
||||||
|
error_t init();
|
||||||
|
|
||||||
|
private:
|
||||||
|
hardware_config_t _hardwareConfig;
|
||||||
|
|
||||||
|
// static void moveInst(AsibFM700Hardware* from, AsibFM700Hardware* to);
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(mcc::traits::mcc_mount_hardware_c<AsibFM700Hardware>, "AsibFM700Hardware!!!");
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace asibfm700
|
||||||
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <future>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@ -318,7 +319,7 @@ protected:
|
|||||||
std::vector<std::string_view> _eventID{};
|
std::vector<std::string_view> _eventID{};
|
||||||
|
|
||||||
std::recursive_mutex _transitionMutex{};
|
std::recursive_mutex _transitionMutex{};
|
||||||
|
std::future<void> _currentStateThreadFuture;
|
||||||
|
|
||||||
static MccFiniteStateMachine& copyInstance(const MccFiniteStateMachine* from, MccFiniteStateMachine* to)
|
static MccFiniteStateMachine& copyInstance(const MccFiniteStateMachine* from, MccFiniteStateMachine* to)
|
||||||
{
|
{
|
||||||
@ -400,7 +401,6 @@ public:
|
|||||||
if constexpr (requires(curr_state_t inst) {
|
if constexpr (requires(curr_state_t inst) {
|
||||||
{ inst.exit(std::declval<EvT&>()) };
|
{ inst.exit(std::declval<EvT&>()) };
|
||||||
}) {
|
}) {
|
||||||
// std::get<curr_state_t>(*states).exit(event);
|
|
||||||
std::get<curr_state_t>(*states).exit(*p_event);
|
std::get<curr_state_t>(*states).exit(*p_event);
|
||||||
} else if constexpr (requires(curr_state_t inst) {
|
} else if constexpr (requires(curr_state_t inst) {
|
||||||
{ inst.exit() };
|
{ inst.exit() };
|
||||||
@ -412,7 +412,6 @@ public:
|
|||||||
if constexpr (requires(EvT inst) {
|
if constexpr (requires(EvT inst) {
|
||||||
{ inst.onTransit() };
|
{ inst.onTransit() };
|
||||||
}) {
|
}) {
|
||||||
// event.onTransit();
|
|
||||||
p_event->onTransit();
|
p_event->onTransit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +422,6 @@ public:
|
|||||||
if constexpr (requires(to_state_t inst) {
|
if constexpr (requires(to_state_t inst) {
|
||||||
{ inst.enter(std::declval<EvT&>()) };
|
{ inst.enter(std::declval<EvT&>()) };
|
||||||
}) {
|
}) {
|
||||||
// std::get<to_state_t>(*states).enter(event);
|
|
||||||
std::get<to_state_t>(*states).enter(*p_event);
|
std::get<to_state_t>(*states).enter(*p_event);
|
||||||
} else if constexpr (requires(to_state_t inst) {
|
} else if constexpr (requires(to_state_t inst) {
|
||||||
{ inst.enter() };
|
{ inst.enter() };
|
||||||
|
|||||||
@ -1,42 +1,45 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
||||||
|
|
||||||
/* AN GENERIC MOUNT CLASS IMPLEMENTATION */
|
|
||||||
|
|
||||||
// #include <atomic>
|
|
||||||
|
/* AN GENERIC MOUNT CLASS IMPLEMENTATION BASED ON FINITE STATE MACHINE */
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
// #include <concepts>
|
|
||||||
// #include <cstdint>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include "spdlog/sinks/null_sink.h"
|
#include "spdlog/sinks/null_sink.h"
|
||||||
|
|
||||||
#include "mcc_finite_state_machine.h"
|
#include "mcc_mount_concepts.h"
|
||||||
#include "mcc_mount_coord.h"
|
#include "mcc_mount_coord.h"
|
||||||
#include "mcc_spdlog.h"
|
#include "mcc_spdlog.h"
|
||||||
#include "mcc_traits.h"
|
#include "mcc_traits.h"
|
||||||
// #include "mount_astrom.h"
|
|
||||||
// #include "mcc_mount_pz.h"
|
|
||||||
#include "mcc_mount_concepts.h"
|
#include "mcc_finite_state_machine.h"
|
||||||
|
#include "mcc_mount_events_states.h"
|
||||||
|
|
||||||
namespace mcc
|
namespace mcc
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template <traits::mcc_mount_controls_c MOUNT_CONTROLS>
|
||||||
template <traits::mcc_mount_config_c MOUNT_CONFIG>
|
class MccMount : public fsm::MccFiniteStateMachine, public utils::MccSpdlogLogger, protected MOUNT_CONTROLS
|
||||||
class MccMount : public fsm::MccFiniteStateMachine, public utils::MccSpdlogLogger
|
|
||||||
{
|
{
|
||||||
|
// declare these classes as friends to allow them access protected members 'slewModel' and 'guidingModel'
|
||||||
|
friend class MccMountStateSlew<MccMount>;
|
||||||
|
friend class MccMountStateGuiding<MccMount>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef MOUNT_CONFIG mount_config_t;
|
typedef MOUNT_CONTROLS mount_controls_t;
|
||||||
typedef decltype(mount_config_t::telemetry) mount_telemetry_t;
|
typedef decltype(mount_controls_t::telemetry) mount_telemetry_t;
|
||||||
typedef typename mount_telemetry_t::mount_telemetry_data_t mount_telemetry_data_t;
|
typedef typename mount_telemetry_t::mount_telemetry_data_t mount_telemetry_data_t;
|
||||||
|
|
||||||
typedef decltype(mount_config_t::astrometryEngine) astrom_engine_t;
|
typedef decltype(mount_controls_t::astrometryEngine) astrom_engine_t;
|
||||||
typedef decltype(mount_config_t::PEC) pec_t;
|
typedef decltype(mount_controls_t::PEC) pec_t;
|
||||||
typedef decltype(mount_config_t::hardware) hardware_t;
|
typedef decltype(mount_controls_t::hardware) hardware_t;
|
||||||
typedef decltype(mount_config_t::slewModel) slew_model_t;
|
typedef decltype(mount_controls_t::slewModel) slew_model_t;
|
||||||
typedef decltype(mount_config_t::guidingModel) guiding_model_t;
|
typedef decltype(mount_controls_t::guidingModel) guiding_model_t;
|
||||||
|
|
||||||
typedef typename slew_model_t::slew_params_t slew_params_t;
|
typedef typename slew_model_t::slew_params_t slew_params_t;
|
||||||
|
|
||||||
@ -44,16 +47,13 @@ public:
|
|||||||
/* constructors and destructor */
|
/* constructors and destructor */
|
||||||
|
|
||||||
template <fsm::traits::fsm_state_c InitStateT, traits::mcc_input_char_range LogMarkT = std::string_view>
|
template <fsm::traits::fsm_state_c InitStateT, traits::mcc_input_char_range LogMarkT = std::string_view>
|
||||||
MccMount(mount_config_t mount_config,
|
MccMount(mount_controls_t mount_controls,
|
||||||
InitStateT,
|
InitStateT,
|
||||||
std::shared_ptr<spdlog::logger> logger = spdlog::null_logger_mt("NULL"),
|
std::shared_ptr<spdlog::logger> logger = spdlog::null_logger_mt("NULL"),
|
||||||
const LogMarkT& logger_mark = "[MOUNT]")
|
const LogMarkT& logger_mark = "[MOUNT]")
|
||||||
: fsm::MccFiniteStateMachine(InitStateT{}),
|
: fsm::MccFiniteStateMachine(InitStateT{}),
|
||||||
utils::MccSpdlogLogger(logger),
|
utils::MccSpdlogLogger(logger),
|
||||||
_mountConfig(std::move(mount_config)),
|
mount_controls_t(std::move(mount_controls))
|
||||||
_mountTelemetry(_mountConfig.telemetry),
|
|
||||||
_slewModel(_mountConfig.slewModel),
|
|
||||||
_guidingModel(_mountConfig.guidingModel)
|
|
||||||
{
|
{
|
||||||
addMarkToPatternIdx(logger_mark);
|
addMarkToPatternIdx(logger_mark);
|
||||||
|
|
||||||
@ -87,24 +87,11 @@ public:
|
|||||||
void startGuiding() {}
|
void startGuiding() {}
|
||||||
|
|
||||||
|
|
||||||
// mount_config_t mountConfig() const
|
|
||||||
// {
|
|
||||||
// return _mountConfig;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// returns "mount_config_t&" or "mount_config_t const&"
|
|
||||||
decltype(auto) mountConfig(this auto&& self)
|
|
||||||
{
|
|
||||||
auto& config_ref = std::forward<decltype(self)>(self)._mountConfig;
|
|
||||||
|
|
||||||
return config_ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
mount_telemetry_data_t mountTelemetryData() const
|
mount_telemetry_data_t mountTelemetryData() const
|
||||||
{
|
{
|
||||||
mount_telemetry_data_t mnt_data;
|
mount_telemetry_data_t mnt_data;
|
||||||
|
|
||||||
auto err = _mountTelemetry.data(mnt_data);
|
auto err = this->telemetry.data();
|
||||||
if (err) {
|
if (err) {
|
||||||
// log ....
|
// log ....
|
||||||
}
|
}
|
||||||
@ -149,11 +136,6 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mount_config_t _mountConfig;
|
|
||||||
mount_telemetry_t& _mountTelemetry;
|
|
||||||
slew_model_t& _slewModel;
|
|
||||||
guiding_model_t& _guidingModel;
|
|
||||||
|
|
||||||
// a type to which the result of calling prohibited zone class methods 'timeTo' and 'timeFrom' will be converted
|
// a type to which the result of calling prohibited zone class methods 'timeTo' and 'timeFrom' will be converted
|
||||||
typedef std::chrono::duration<double> pz_duration_t; // seconds as floating-point number
|
typedef std::chrono::duration<double> pz_duration_t; // seconds as floating-point number
|
||||||
|
|
||||||
@ -191,13 +173,14 @@ protected:
|
|||||||
}; // end of MccMount class
|
}; // end of MccMount class
|
||||||
|
|
||||||
|
|
||||||
namespace traits
|
|
||||||
{
|
|
||||||
|
|
||||||
// given mount class must be a descendant of MccMount
|
// namespace traits
|
||||||
template <typename T>
|
// {
|
||||||
concept mcc_mount_c = requires(T t) { []<typename... Ts>(MccMount<Ts...>*) {}(&t); };
|
|
||||||
|
|
||||||
} // namespace traits
|
// // given mount class must be a descendant of MccMount
|
||||||
|
// template <typename T>
|
||||||
|
// concept mcc_mount_c = requires(T t) { []<typename... Ts>(MccMount<Ts...>*) {}(&t); };
|
||||||
|
|
||||||
|
// } // namespace traits
|
||||||
|
|
||||||
} // namespace mcc
|
} // namespace mcc
|
||||||
@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
|
|
||||||
|
#include "mcc_finite_state_machine.h"
|
||||||
#include "mcc_mount_coord.h"
|
#include "mcc_mount_coord.h"
|
||||||
#include "mcc_traits.h"
|
#include "mcc_traits.h"
|
||||||
|
|
||||||
|
|
||||||
/* SOME LIBRARY-WIDE DECLARATIONS */
|
/* SOME LIBRARY-WIDE DECLARATIONS */
|
||||||
|
|
||||||
namespace mcc
|
namespace mcc
|
||||||
@ -63,6 +63,22 @@ namespace mcc::traits
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/* GENERIC LOGGER */
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_logger_c = requires(T t, const T t_const) {
|
||||||
|
typename T::loglevel_t;
|
||||||
|
{ t.setLogLevel(std::declval<typename T::loglevel_t>()) };
|
||||||
|
{ t_const.getLogLevel() } -> std::same_as<typename T::loglevel_t>;
|
||||||
|
|
||||||
|
{ t.logMessage(std::declval<typename T::loglevel_t>(), std::declval<const std::string&>()) };
|
||||||
|
|
||||||
|
{ t.logError(std::declval<const std::string&>()) };
|
||||||
|
{ t.logDebug(std::declval<const std::string&>()) };
|
||||||
|
{ t.logWarn(std::declval<const std::string&>()) };
|
||||||
|
{ t.logInfo(std::declval<const std::string&>()) };
|
||||||
|
};
|
||||||
|
|
||||||
/* ASTROMETRY-RELATED COMPUTATION ENGINE */
|
/* ASTROMETRY-RELATED COMPUTATION ENGINE */
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -171,6 +187,7 @@ concept mcc_mount_hardware_c = !std::copyable<T> && std::movable<T> && requires(
|
|||||||
{ t.setPos(std::declval<typename T::axes_pos_t>()) } -> std::same_as<typename T::error_t>;
|
{ t.setPos(std::declval<typename T::axes_pos_t>()) } -> std::same_as<typename T::error_t>;
|
||||||
{ t.getPos(std::declval<typename T::axes_pos_t&>()) } -> std::same_as<typename T::error_t>;
|
{ t.getPos(std::declval<typename T::axes_pos_t&>()) } -> std::same_as<typename T::error_t>;
|
||||||
{ t.stop() } -> std::same_as<typename T::error_t>;
|
{ t.stop() } -> std::same_as<typename T::error_t>;
|
||||||
|
{ t.init() } -> std::same_as<typename T::error_t>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -235,12 +252,14 @@ concept mcc_mount_telemetry_c = requires(T t, const T t_const) {
|
|||||||
// // a class that at least contains celestial (equatorial and horizontal) coordinates
|
// // a class that at least contains celestial (equatorial and horizontal) coordinates
|
||||||
// requires requires(typename T::mount_telemetry_data_t telemetry) {
|
// requires requires(typename T::mount_telemetry_data_t telemetry) {
|
||||||
// typename T::mount_telemetry_data_t::coord_t;
|
// typename T::mount_telemetry_data_t::coord_t;
|
||||||
// requires std::same_as<decltype(telemetry.mntRA), typename T::mount_telemetry_data_t::coord_t>; // apparent
|
// requires std::same_as<decltype(telemetry.mntRA), typename T::mount_telemetry_data_t::coord_t>; //
|
||||||
// RA requires std::same_as<decltype(telemetry.mntDEC), typename T::mount_telemetry_data_t::coord_t>; //
|
// apparent RA requires std::same_as<decltype(telemetry.mntDEC), typename
|
||||||
// apparent DEC requires std::same_as<decltype(telemetry.mntHA), typename T::mount_telemetry_data_t::coord_t>;
|
// T::mount_telemetry_data_t::coord_t>; // apparent DEC requires std::same_as<decltype(telemetry.mntHA),
|
||||||
// // hour angle requires std::same_as<decltype(telemetry.mntAZ), typename T::mount_telemetry_data_t::coord_t>;
|
// typename T::mount_telemetry_data_t::coord_t>;
|
||||||
// // azimuth requires std::same_as<decltype(telemetry.mntALT), typename T::mount_telemetry_data_t::coord_t>; //
|
// // hour angle requires std::same_as<decltype(telemetry.mntAZ), typename
|
||||||
// altitude
|
// T::mount_telemetry_data_t::coord_t>;
|
||||||
|
// // azimuth requires std::same_as<decltype(telemetry.mntALT), typename
|
||||||
|
// T::mount_telemetry_data_t::coord_t>; // altitude
|
||||||
// };
|
// };
|
||||||
|
|
||||||
requires mcc_mount_telemetry_data_c<typename T::mount_telemetry_data_t>;
|
requires mcc_mount_telemetry_data_c<typename T::mount_telemetry_data_t>;
|
||||||
@ -336,8 +355,8 @@ concept mcc_prohibited_zone_c =
|
|||||||
|
|
||||||
|
|
||||||
// for given coordinates and time the method computes a time to reach the zone.
|
// for given coordinates and time the method computes a time to reach the zone.
|
||||||
// implementation of the method must assume that input coordinates are apparent RA and DEC at given time point,
|
// implementation of the method must assume that input coordinates are apparent RA and DEC at given time
|
||||||
// while the time point is one from which computation should be performed (e.g. current time moment)
|
// point, while the time point is one from which computation should be performed (e.g. current time moment)
|
||||||
{
|
{
|
||||||
t.timeTo(std::declval<typename T::coord_t>(), std::declval<typename T::coord_t>(),
|
t.timeTo(std::declval<typename T::coord_t>(), std::declval<typename T::coord_t>(),
|
||||||
std::declval<typename T::time_point_t>())
|
std::declval<typename T::time_point_t>())
|
||||||
@ -369,11 +388,11 @@ concept mcc_prohibited_zone_c =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* MOUNT GENERIC CONFIGURATION */
|
/* MOUNT GENERIC CONTROLS */
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_mount_config_c = std::movable<T> && requires(T t) {
|
concept mcc_mount_controls_c = std::move_constructible<T> && std::movable<T> && requires(T t) {
|
||||||
requires mcc_astrom_engine_c<decltype(t.astrometryEngine)>;
|
requires mcc_astrom_engine_c<decltype(t.astrometryEngine)>;
|
||||||
requires mcc_mount_pec_c<decltype(t.PEC)>;
|
requires mcc_mount_pec_c<decltype(t.PEC)>;
|
||||||
requires mcc_mount_hardware_c<decltype(t.hardware)>;
|
requires mcc_mount_hardware_c<decltype(t.hardware)>;
|
||||||
@ -388,5 +407,37 @@ concept mcc_mount_config_c = std::movable<T> && requires(T t) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* GENERIC MOUNT CONCEPTS */
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_mount_c = requires(T t) {
|
||||||
|
// the class must define typename 'mount_controls_t' and it must be its base class
|
||||||
|
requires mcc_mount_controls_c<typename T::mount_controls_t>;
|
||||||
|
requires std::derived_from<T, typename T::mount_controls_t>;
|
||||||
|
|
||||||
|
|
||||||
|
// deduced from 'mount_controls_t' typenames
|
||||||
|
requires mcc_mount_telemetry_c<typename T::mount_telemetry_t>;
|
||||||
|
requires std::same_as<typename T::mount_telemetry_data_t, typename T::mount_telemetry_t::mount_telemetry_data_t>;
|
||||||
|
requires mcc_astrom_engine_c<typename T::astrom_engine_t>;
|
||||||
|
requires mcc_mount_pec_c<typename T::pec_t>;
|
||||||
|
requires mcc_mount_hardware_c<typename T::hardware_t>;
|
||||||
|
requires mcc_slew_model_c<typename T::slew_model_t, typename T::mount_telemetry_t>;
|
||||||
|
requires mcc_guiding_model_c<typename T::guiding_model_t, typename T::mount_telemetry_t>;
|
||||||
|
|
||||||
|
requires std::same_as<typename T::slew_params_t, typename T::slew_model_t::slew_params_t>;
|
||||||
|
|
||||||
|
// public method
|
||||||
|
{ t.mountTelemetryData() } -> std::same_as<typename T::mount_telemetry_data_t>;
|
||||||
|
};
|
||||||
|
|
||||||
|
// generic with logging methods
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_log_mount_c = mcc_mount_c<T> && mcc_logger_c<T>;
|
||||||
|
|
||||||
|
|
||||||
|
// a generic Finite State Machine mount with logging methods
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_fsm_log_mount_c = std::derived_from<T, fsm::MccFiniteStateMachine> && mcc_log_mount_c<T>;
|
||||||
|
|
||||||
} // namespace mcc::traits
|
} // namespace mcc::traits
|
||||||
|
|||||||
@ -349,11 +349,18 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unary '-' and '+'
|
||||||
template <typename SelfT>
|
template <typename SelfT>
|
||||||
SelfT& operator-(this SelfT& self)
|
SelfT operator-(this SelfT& self)
|
||||||
{
|
{
|
||||||
self._angleInRads = -self._angleInRads;
|
SelfT res = -self._angleInRads;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename SelfT>
|
||||||
|
SelfT operator+(this SelfT& self)
|
||||||
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,12 +3,13 @@
|
|||||||
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BASIC EVENTS AND MOUNT STATES DEFINITIONS (REFERENCE IMPLEMENTATION)
|
* BASIC EVENTS AND MOUNT STATES DEFINITIONS (POSSIBLE IMPLEMENTATION)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include "mcc_mount.h"
|
#include "mcc_mount_concepts.h"
|
||||||
|
|
||||||
namespace mcc
|
namespace mcc
|
||||||
{
|
{
|
||||||
@ -19,7 +20,7 @@ namespace mcc
|
|||||||
|
|
||||||
// a base class for mount state machine events
|
// a base class for mount state machine events
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
class MccMountEventBase
|
class MccMountEventBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -41,7 +42,7 @@ protected:
|
|||||||
|
|
||||||
// transit to IDLE state
|
// transit to IDLE state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountEventIDLE : public MccMountEventBase<MountT> {
|
struct MccMountEventIDLE : public MccMountEventBase<MountT> {
|
||||||
typedef MccMountEventBase<MountT> base_t;
|
typedef MccMountEventBase<MountT> base_t;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ struct MccMountEventIDLE : public MccMountEventBase<MountT> {
|
|||||||
|
|
||||||
// transit to initialization state
|
// transit to initialization state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountEventInit : public MccMountEventBase<MountT> {
|
struct MccMountEventInit : public MccMountEventBase<MountT> {
|
||||||
typedef MccMountEventBase<MountT> base_t;
|
typedef MccMountEventBase<MountT> base_t;
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ struct MccMountEventInit : public MccMountEventBase<MountT> {
|
|||||||
|
|
||||||
// transit to error state
|
// transit to error state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountEventError : public MccMountEventBase<MountT> {
|
struct MccMountEventError : public MccMountEventBase<MountT> {
|
||||||
typedef MccMountEventBase<MountT> base_t;
|
typedef MccMountEventBase<MountT> base_t;
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ protected:
|
|||||||
|
|
||||||
// transit to slew state
|
// transit to slew state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountEventSlew : public MccMountEventBase<MountT> {
|
struct MccMountEventSlew : public MccMountEventBase<MountT> {
|
||||||
typedef MccMountEventBase<MountT> base_t;
|
typedef MccMountEventBase<MountT> base_t;
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ protected:
|
|||||||
|
|
||||||
// transit to guiding state
|
// transit to guiding state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountEventGuiding : public MccMountEventBase<MountT> {
|
struct MccMountEventGuiding : public MccMountEventBase<MountT> {
|
||||||
typedef MccMountEventBase<MountT> base_t;
|
typedef MccMountEventBase<MountT> base_t;
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ struct MccMountEventGuiding : public MccMountEventBase<MountT> {
|
|||||||
|
|
||||||
// transit to stop state
|
// transit to stop state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountEventStop : public MccMountEventBase<MountT> {
|
struct MccMountEventStop : public MccMountEventBase<MountT> {
|
||||||
typedef MccMountEventBase<MountT> base_t;
|
typedef MccMountEventBase<MountT> base_t;
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ protected:
|
|||||||
|
|
||||||
// transit to shutdown state
|
// transit to shutdown state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountEventShutdown : public MccMountEventBase<MountT> {
|
struct MccMountEventShutdown : public MccMountEventBase<MountT> {
|
||||||
typedef MccMountEventBase<MountT> base_t;
|
typedef MccMountEventBase<MountT> base_t;
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ struct MccMountEventShutdown : public MccMountEventBase<MountT> {
|
|||||||
|
|
||||||
/* MOUNT STATE MACHINE STATES */
|
/* MOUNT STATE MACHINE STATES */
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateBase {
|
struct MccMountStateBase {
|
||||||
// template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
// template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
||||||
// void exit(this auto&& self, EvT& event)
|
// void exit(this auto&& self, EvT& event)
|
||||||
@ -214,45 +215,46 @@ protected:
|
|||||||
void exitLog(this auto&& self, EvT& event)
|
void exitLog(this auto&& self, EvT& event)
|
||||||
{
|
{
|
||||||
using self_t = std::remove_cvref_t<decltype(self)>;
|
using self_t = std::remove_cvref_t<decltype(self)>;
|
||||||
event.mount().logDebug("Exit from '{}' state due to '{}' event ...", self_t::ID, EvT::ID);
|
|
||||||
|
event.mount().logDebug(std::format("Exit from '{}' state due to '{}' event ...", self_t::ID, EvT::ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
||||||
void enterLog(this auto&& self, EvT& event)
|
void enterLog(this auto&& self, EvT& event)
|
||||||
{
|
{
|
||||||
using self_t = std::remove_cvref_t<decltype(self)>;
|
using self_t = std::remove_cvref_t<decltype(self)>;
|
||||||
event.mount().logDebug("Enter to '{}' state due to '{}' event ...", self_t::ID, EvT::ID);
|
event.mount().logDebug(std::format("Enter to '{}' state due to '{}' event ...", self_t::ID, EvT::ID));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// just forward declarations
|
// just forward declarations
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateIDLE;
|
struct MccMountStateIDLE;
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateInit;
|
struct MccMountStateInit;
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateError;
|
struct MccMountStateError;
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateSlew;
|
struct MccMountStateSlew;
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT, fsm::traits::fsm_event_c TrEvT = MccMountEventStop<MountT>>
|
template <traits::mcc_fsm_log_mount_c MountT, fsm::traits::fsm_event_c TrEvT = MccMountEventStop<MountT>>
|
||||||
struct MccMountStateStop;
|
struct MccMountStateStop;
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateGuiding;
|
struct MccMountStateGuiding;
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateShutdown;
|
struct MccMountStateShutdown;
|
||||||
|
|
||||||
|
|
||||||
// stop state
|
// stop state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT, fsm::traits::fsm_event_c TrEvT>
|
template <traits::mcc_fsm_log_mount_c MountT, fsm::traits::fsm_event_c TrEvT>
|
||||||
struct MccMountStateStop : MccMountStateBase<MountT> {
|
struct MccMountStateStop : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-STOP-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-STOP-STATE";
|
||||||
|
|
||||||
@ -287,7 +289,7 @@ struct MccMountStateStop : MccMountStateBase<MountT> {
|
|||||||
mount.stopMount();
|
mount.stopMount();
|
||||||
|
|
||||||
if constexpr (std::same_as<EvT, MccMountEventStop<MountT>>) {
|
if constexpr (std::same_as<EvT, MccMountEventStop<MountT>>) {
|
||||||
mount.logInfo("Stop reason: {}", event.reason());
|
mount.logInfo(std::format("Stop reason: {}", event.reason()));
|
||||||
|
|
||||||
// normal behavior (transit to IDLE state after stopping)
|
// normal behavior (transit to IDLE state after stopping)
|
||||||
mount.template dispatchEvent<MccMountEventIDLE<MountT>>({mount});
|
mount.template dispatchEvent<MccMountEventIDLE<MountT>>({mount});
|
||||||
@ -300,7 +302,7 @@ struct MccMountStateStop : MccMountStateBase<MountT> {
|
|||||||
|
|
||||||
// initialization state
|
// initialization state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateInit : MccMountStateBase<MountT> {
|
struct MccMountStateInit : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-INIT-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-INIT-STATE";
|
||||||
|
|
||||||
@ -329,7 +331,7 @@ struct MccMountStateInit : MccMountStateBase<MountT> {
|
|||||||
|
|
||||||
// error state
|
// error state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateError : MccMountStateBase<MountT> {
|
struct MccMountStateError : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-ERROR-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-ERROR-STATE";
|
||||||
|
|
||||||
@ -348,9 +350,9 @@ struct MccMountStateError : MccMountStateBase<MountT> {
|
|||||||
{
|
{
|
||||||
this->exitLog(event);
|
this->exitLog(event);
|
||||||
|
|
||||||
event.mount().logWarn(
|
event.mount().logWarn(std::format(
|
||||||
"The mount is in the error state!!! One must correct it before transit to any states! Event type is '{}'",
|
"The mount is in the error state!!! One must correct it before transit to any states! Event type is '{}'",
|
||||||
EvT::ID);
|
EvT::ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit(MccMountEventIDLE<MountT>& event)
|
void exit(MccMountEventIDLE<MountT>& event)
|
||||||
@ -372,8 +374,8 @@ struct MccMountStateError : MccMountStateBase<MountT> {
|
|||||||
|
|
||||||
auto err = event.eventData();
|
auto err = event.eventData();
|
||||||
|
|
||||||
event.mount().logError("The mount is in the error state: code = {}, category = {}, message = '{}'", err.value(),
|
event.mount().logError(std::format("The mount is in the error state: code = {}, category = {}, message = '{}'",
|
||||||
err.category().name(), err.message());
|
err.value(), err.category().name(), err.message()));
|
||||||
}
|
}
|
||||||
// template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
// template <std::derived_from<MccMountEventBase<MountT>> EvT>
|
||||||
// void enter(EvT& event)
|
// void enter(EvT& event)
|
||||||
@ -391,7 +393,7 @@ struct MccMountStateError : MccMountStateBase<MountT> {
|
|||||||
|
|
||||||
// IDLE state
|
// IDLE state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateIDLE : MccMountStateBase<MountT> {
|
struct MccMountStateIDLE : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-IDLE-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-IDLE-STATE";
|
||||||
|
|
||||||
@ -419,7 +421,7 @@ struct MccMountStateIDLE : MccMountStateBase<MountT> {
|
|||||||
|
|
||||||
// shutdown state
|
// shutdown state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateShutdown : MccMountStateBase<MountT> {
|
struct MccMountStateShutdown : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-SHUTDOWN-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-SHUTDOWN-STATE";
|
||||||
|
|
||||||
@ -445,7 +447,7 @@ struct MccMountStateShutdown : MccMountStateBase<MountT> {
|
|||||||
|
|
||||||
// slew state
|
// slew state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateSlew : MccMountStateBase<MountT> {
|
struct MccMountStateSlew : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-SLEW-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-SLEW-STATE";
|
||||||
|
|
||||||
@ -478,7 +480,7 @@ struct MccMountStateSlew : MccMountStateBase<MountT> {
|
|||||||
|
|
||||||
// guiding state
|
// guiding state
|
||||||
|
|
||||||
template <traits::mcc_mount_c MountT>
|
template <traits::mcc_fsm_log_mount_c MountT>
|
||||||
struct MccMountStateGuiding : MccMountStateBase<MountT> {
|
struct MccMountStateGuiding : MccMountStateBase<MountT> {
|
||||||
static constexpr std::string_view ID = "MCC-MOUNT-GUIDING-STATE";
|
static constexpr std::string_view ID = "MCC-MOUNT-GUIDING-STATE";
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,7 @@ public:
|
|||||||
// : "ALTLIMIT-UNKNOWN"),
|
// : "ALTLIMIT-UNKNOWN"),
|
||||||
: _altLimit(alt_limit), _latitude(lat), _abs_lat(std::abs(_latitude)), _lat_lim(pi2 - _abs_lat)
|
: _altLimit(alt_limit), _latitude(lat), _abs_lat(std::abs(_latitude)), _lat_lim(pi2 - _abs_lat)
|
||||||
{
|
{
|
||||||
|
_lat_lim = pi2 - _abs_lat;
|
||||||
_altLimit.normalize<MccAngle::NORM_KIND_90_90>();
|
_altLimit.normalize<MccAngle::NORM_KIND_90_90>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
||||||
|
|
||||||
|
|
||||||
/* MOUNT TELEMETRY OBJECT POSSIBLE IMPLEMENTATION */
|
/* MOUNT TELEMETRY OBJECT POSSIBLE GENERIC IMPLEMENTATION */
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
|||||||
@ -164,8 +164,9 @@ concept mcc_nonconst_lvref = std::is_lvalue_reference_v<T> && !std::is_const_v<s
|
|||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_error_c = std::convertible_to<T, bool>;
|
concept mcc_error_c = std::convertible_to<T, bool> || requires(const T t) {
|
||||||
// concept mcc_error_c = std::convertible_to<T, bool> && mcc_formattable<T>;
|
{ t.operator bool() };
|
||||||
|
};
|
||||||
|
|
||||||
namespace details
|
namespace details
|
||||||
{
|
{
|
||||||
|
|||||||
@ -16,8 +16,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mcc_traits.h"
|
#include "mcc_traits.h"
|
||||||
|
#include "mcc_utils.h"
|
||||||
#include "mount_astrom_default.h"
|
#include "mount_astrom_default.h"
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
namespace erfa
|
namespace erfa
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user