From 5f404a62910f87391bbc4c16b0a7fcb6bdf87864 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Mon, 27 Jan 2025 17:58:39 +0300 Subject: [PATCH] ... --- cxx/control_proto.h | 4 ++++ cxx/mount.h | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 cxx/mount.h diff --git a/cxx/control_proto.h b/cxx/control_proto.h index 0f436c5..58eaba6 100644 --- a/cxx/control_proto.h +++ b/cxx/control_proto.h @@ -49,6 +49,10 @@ static constexpr std::string_view CONTROL_PROTO_STR_TRACK_XVEL = "trackXVEL"; static constexpr std::string_view CONTROL_PROTO_STR_TRACK_YVEL = "trackYVEL"; static constexpr std::string_view CONTROL_PROTO_STR_STOP = "stop"; +// site coordinates +static constexpr std::string_view CONTROL_PROTO_STR_SITE_LON = "siteLON"; +static constexpr std::string_view CONTROL_PROTO_STR_SITE_LAT = "siteLAT"; + static constexpr std::array CONTROL_PROTO_VALID_COMMAND = {CONTROL_PROTO_STR_SLEW_AZALT, CONTROL_PROTO_STR_SLEW_RADEC}; class ControlProtoParser diff --git a/cxx/mount.h b/cxx/mount.h new file mode 100644 index 0000000..2d6de35 --- /dev/null +++ b/cxx/mount.h @@ -0,0 +1,56 @@ +#pragma once + +/* MOUNT CONTROL COMPONENTS LIBRARY */ + +#include +#include +#include + +namespace mcc +{ + +enum class MccMountType : uint8_t { GERMAN_TYPE, FORK_TYPE, CROSSAXIS_TYPE, ALTAZ_TYPE }; + + +// mount state type concept +template +concept mcc_mount_state_c = requires(T t, const T t_const) { + typename T::state_id_t; + { t.ident() } -> std::same_as; + + typename T::context_t; + { t.enter(std::declval()) } -> std::same_as; + { t.exit(std::declval()) } -> std::same_as; +}; + + + +// implements a Finite State Machine Pattern +template +class MccMount +{ +public: + static constexpr MccMountType mountType = MOUNT_TYPE; + + + MccMount() + { + _exitCurrentState = []() {}; // do nothing + } + + virtual ~MccMount() {} + + template + void setMountState(StateT& state) + { + _exitCurrentState(); // exit from current state + _exitCurrentState = [&state, this]() { state.exit(this); }; + + state.enter(this); + } + +protected: + std::function _exitCurrentState; +}; + +} // namespace mcc