rewrite to use of the new implementation of mount config
(asibfm700_config.h: Asibfm700MountConfiguration class)
This commit is contained in:
@@ -11,7 +11,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||||||
# pass to mcc-library
|
# pass to mcc-library
|
||||||
option(USE_BSPLINE_PCM "Use of FITPACK bivariate splines for PCM" ON)
|
option(USE_BSPLINE_PCM "Use of FITPACK bivariate splines for PCM" ON)
|
||||||
|
|
||||||
find_package(cxxopts REQUIRED)
|
# find_package(cxxopts REQUIRED)
|
||||||
|
|
||||||
#set(EXAMPLES OFF CACHE BOOL "" FORCE)
|
#set(EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
# set(CMAKE_BUILD_TYPE "Release")
|
# set(CMAKE_BUILD_TYPE "Release")
|
||||||
@@ -82,14 +82,23 @@ set(CMAKE_BUILD_TYPE "Debug")
|
|||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
cxxopts
|
||||||
|
GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git
|
||||||
|
GIT_SHALLOW 1
|
||||||
|
GIT_PROGRESS 1
|
||||||
|
CMAKE_ARGS
|
||||||
|
-DCXXOPTS_USE_UNICODE=0
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(cxxopts)
|
||||||
|
|
||||||
set(EXAMPLES OFF CACHE BOOL "" FORCE)
|
set(EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
servo_lib
|
servo_lib
|
||||||
GIT_REPOSITORY https://timur@git.sao.ru/timur/LibSidServo.git
|
GIT_REPOSITORY https://timur@git.sao.ru/timur/LibSidServo.git
|
||||||
GIT_SHALLOW 1
|
GIT_SHALLOW 1
|
||||||
GIT_PROGRESS 1
|
GIT_PROGRESS 1
|
||||||
SOURCE_DIR
|
SOURCE_DIR ${CMAKE_BINARY_DIR}/LibSidServo
|
||||||
${CMAKE_BINARY_DIR}/LibSidServo
|
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(servo_lib)
|
FetchContent_MakeAvailable(servo_lib)
|
||||||
@@ -101,8 +110,7 @@ FetchContent_Declare(
|
|||||||
# GIT_REPOSITORY ssh://git@95.140.147.151:/home/git/mcc.git
|
# GIT_REPOSITORY ssh://git@95.140.147.151:/home/git/mcc.git
|
||||||
GIT_SHALLOW 1
|
GIT_SHALLOW 1
|
||||||
GIT_PROGRESS 1
|
GIT_PROGRESS 1
|
||||||
SOURCE_DIR
|
SOURCE_DIR ${CMAKE_BINARY_DIR}/mcc
|
||||||
${CMAKE_BINARY_DIR}/mcc
|
|
||||||
# OVERRIDE_FIND_PACKAGE
|
# OVERRIDE_FIND_PACKAGE
|
||||||
)
|
)
|
||||||
set(BUILD_TESTS OFF)
|
set(BUILD_TESTS OFF)
|
||||||
|
|||||||
@@ -293,6 +293,11 @@ static auto Asibfm700MountConfigurationDefaults = std::make_tuple(
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
static_assert(std::is_copy_assignable_v<mcc::impl::MccAxisLimitSwitchPZ<mcc::impl::MccCoordKind::COORDS_KIND_HA_OBS>>);
|
||||||
|
static_assert(std::is_copy_assignable_v<mcc::impl::MccAltLimitPZ<mcc::impl::MccAltLimitKind::MIN_ALT_LIMIT>>);
|
||||||
|
|
||||||
|
// static_assert(std::is_copy_assignable_v<decltype(Asibfm700MountConfigurationDefaults)>);
|
||||||
|
|
||||||
class Asibfm700MountConfiguration : public mcc::impl::MccKeyValueHolder<decltype(Asibfm700MountConfigurationDefaults)>
|
class Asibfm700MountConfiguration : public mcc::impl::MccKeyValueHolder<decltype(Asibfm700MountConfigurationDefaults)>
|
||||||
{
|
{
|
||||||
using base_t = mcc::impl::MccKeyValueHolder<decltype(Asibfm700MountConfigurationDefaults)>;
|
using base_t = mcc::impl::MccKeyValueHolder<decltype(Asibfm700MountConfigurationDefaults)>;
|
||||||
@@ -321,6 +326,12 @@ public:
|
|||||||
|
|
||||||
~Asibfm700MountConfiguration() = default;
|
~Asibfm700MountConfiguration() = default;
|
||||||
|
|
||||||
|
Asibfm700MountConfiguration(const Asibfm700MountConfiguration&) = default;
|
||||||
|
Asibfm700MountConfiguration(Asibfm700MountConfiguration&&) = default;
|
||||||
|
|
||||||
|
Asibfm700MountConfiguration& operator=(const Asibfm700MountConfiguration&) = default;
|
||||||
|
Asibfm700MountConfiguration& operator=(Asibfm700MountConfiguration&&) = default;
|
||||||
|
|
||||||
std::error_code load(const std::filesystem::path& path)
|
std::error_code load(const std::filesystem::path& path)
|
||||||
{
|
{
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ namespace asibfm700
|
|||||||
|
|
||||||
/* CONSTRUCTOR AND DESTRUCTOR */
|
/* CONSTRUCTOR AND DESTRUCTOR */
|
||||||
|
|
||||||
Asibfm700Mount::Asibfm700Mount(Asibfm700MountConfig const& config, std::shared_ptr<spdlog::logger> logger)
|
// Asibfm700Mount::Asibfm700Mount(Asibfm700MountConfig const& config, std::shared_ptr<spdlog::logger> logger)
|
||||||
|
Asibfm700Mount::Asibfm700Mount(Asibfm700MountConfiguration const& config, std::shared_ptr<spdlog::logger> logger)
|
||||||
: _servolController(config.servoControllerConfig()),
|
: _servolController(config.servoControllerConfig()),
|
||||||
_pcm(config.pcmData()),
|
_pcm(config.pcmData()),
|
||||||
gm_class_t(std::make_tuple(&_servolController, &_pcm),
|
gm_class_t(std::make_tuple(&_servolController, &_pcm),
|
||||||
@@ -106,17 +107,36 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
|||||||
clearPZones();
|
clearPZones();
|
||||||
logInfo("Add prohibited zones ...");
|
logInfo("Add prohibited zones ...");
|
||||||
|
|
||||||
|
// logInfo(" Add MccAltLimitPZ zone: min alt = {}, lat = {} (pzone type: '{}')",
|
||||||
|
// _mountConfig.pzMinAltitude().degrees(), _mountConfig.siteLatitude().degrees(),
|
||||||
|
// "Minimal altitude prohibited zone");
|
||||||
|
// addPZone(mcc::impl::MccAltLimitPZ<mcc::impl::MccAltLimitKind::MIN_ALT_LIMIT>{_mountConfig.pzMinAltitude(),
|
||||||
|
// _mountConfig.siteLatitude()});
|
||||||
|
|
||||||
|
// logInfo(" Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {} (pzone type: '{}')",
|
||||||
|
// _mountConfig.pzLimitSwitchHAMin().degrees(), _mountConfig.pzLimitSwitchHAMax().degrees(),
|
||||||
|
// "HA-axis limit switch");
|
||||||
|
// size_t pz_num = addPZone(mcc::impl::MccAxisLimitSwitchPZ<mcc::impl::MccCoordKind::COORDS_KIND_HA_OBS>{
|
||||||
|
// _mountConfig.pzLimitSwitchHAMin(), _mountConfig.pzLimitSwitchHAMax(), &_pcm});
|
||||||
|
|
||||||
|
size_t pz_num = addPZone(_mountConfig.minAltPZone());
|
||||||
logInfo(" Add MccAltLimitPZ zone: min alt = {}, lat = {} (pzone type: '{}')",
|
logInfo(" Add MccAltLimitPZ zone: min alt = {}, lat = {} (pzone type: '{}')",
|
||||||
_mountConfig.pzMinAltitude().degrees(), _mountConfig.siteLatitude().degrees(),
|
_mountConfig.minAltPZone().altLimit().degrees(), _mountConfig.minAltPZone().latitude().sexagesimal(),
|
||||||
"Minimal altitude prohibited zone");
|
"Minimal altitude prohibited zone");
|
||||||
addPZone(mcc::impl::MccAltLimitPZ<mcc::impl::MccAltLimitKind::MIN_ALT_LIMIT>{_mountConfig.pzMinAltitude(),
|
|
||||||
_mountConfig.siteLatitude()});
|
auto haPZone = _mountConfig.axisLimitSwitchHA();
|
||||||
|
haPZone.setPCM(&_pcm);
|
||||||
|
|
||||||
logInfo(" Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {} (pzone type: '{}')",
|
logInfo(" Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {} (pzone type: '{}')",
|
||||||
_mountConfig.pzLimitSwitchHAMin().degrees(), _mountConfig.pzLimitSwitchHAMax().degrees(),
|
haPZone.maxLimit().degrees(), haPZone.maxLimit().degrees(), "HA-axis limit switch");
|
||||||
"HA-axis limit switch");
|
pz_num = addPZone(std::move(haPZone));
|
||||||
size_t pz_num = addPZone(mcc::impl::MccAxisLimitSwitchPZ<mcc::impl::MccCoordKind::COORDS_KIND_HA_OBS>{
|
|
||||||
_mountConfig.pzLimitSwitchHAMin(), _mountConfig.pzLimitSwitchHAMax(), &_pcm});
|
auto decPZone = _mountConfig.axisLimitSwitchDEC();
|
||||||
|
decPZone.setPCM(&_pcm);
|
||||||
|
|
||||||
|
logInfo(" Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {} (pzone type: '{}')",
|
||||||
|
decPZone.maxLimit().degrees(), decPZone.maxLimit().degrees(), "DEC-axis limit switch");
|
||||||
|
pz_num = addPZone(std::move(decPZone));
|
||||||
|
|
||||||
logInfo("{} prohibited zones were added successfully", pz_num);
|
logInfo("{} prohibited zones were added successfully", pz_num);
|
||||||
|
|
||||||
@@ -149,12 +169,12 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
|||||||
logInfo(" PIDRefreshDt: {}", to_msecs(hw_cfg.devConfig.PIDRefreshDt));
|
logInfo(" PIDRefreshDt: {}", to_msecs(hw_cfg.devConfig.PIDRefreshDt));
|
||||||
logInfo(" PIDCycleDt: {}", to_msecs(hw_cfg.devConfig.PIDCycleDt));
|
logInfo(" PIDCycleDt: {}", to_msecs(hw_cfg.devConfig.PIDCycleDt));
|
||||||
|
|
||||||
logInfo(" XPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDC.P, hw_cfg.devConfig.XPIDC.I,
|
// logInfo(" XPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDC.P, hw_cfg.devConfig.XPIDC.I,
|
||||||
hw_cfg.devConfig.XPIDC.D);
|
// hw_cfg.devConfig.XPIDC.D);
|
||||||
logInfo(" XPIDV: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDV.P, hw_cfg.devConfig.XPIDV.I,
|
logInfo(" XPIDV: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDV.P, hw_cfg.devConfig.XPIDV.I,
|
||||||
hw_cfg.devConfig.XPIDV.D);
|
hw_cfg.devConfig.XPIDV.D);
|
||||||
logInfo(" YPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.YPIDC.P, hw_cfg.devConfig.YPIDC.I,
|
// logInfo(" YPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.YPIDC.P, hw_cfg.devConfig.YPIDC.I,
|
||||||
hw_cfg.devConfig.YPIDC.D);
|
// hw_cfg.devConfig.YPIDC.D);
|
||||||
logInfo(" YPIDV: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.YPIDV.P, hw_cfg.devConfig.YPIDV.I,
|
logInfo(" YPIDV: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.YPIDV.P, hw_cfg.devConfig.YPIDV.I,
|
||||||
hw_cfg.devConfig.YPIDV.D);
|
hw_cfg.devConfig.YPIDV.D);
|
||||||
logInfo(" XEncZero: {}", hw_cfg.devConfig.XEncZero);
|
logInfo(" XEncZero: {}", hw_cfg.devConfig.XEncZero);
|
||||||
@@ -359,7 +379,8 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountConfig& cfg)
|
// Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountConfig& cfg)
|
||||||
|
Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountConfiguration& cfg)
|
||||||
{
|
{
|
||||||
std::lock_guard lock{*_mountConfigMutex};
|
std::lock_guard lock{*_mountConfigMutex};
|
||||||
|
|
||||||
@@ -375,7 +396,8 @@ Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountCo
|
|||||||
|
|
||||||
Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const std::string& cfg_filename)
|
Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const std::string& cfg_filename)
|
||||||
{
|
{
|
||||||
Asibfm700MountConfig new_config;
|
// Asibfm700MountConfig new_config;
|
||||||
|
Asibfm700MountConfiguration new_config;
|
||||||
auto err =
|
auto err =
|
||||||
new_config.load(cfg_filename.empty() ? _mountConfig.configFilename() : std::filesystem::path{cfg_filename});
|
new_config.load(cfg_filename.empty() ? _mountConfig.configFilename() : std::filesystem::path{cfg_filename});
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
#include <mcc/mcc_telemetry.h>
|
#include <mcc/mcc_telemetry.h>
|
||||||
|
|
||||||
#include "asibfm700_common.h"
|
#include "asibfm700_common.h"
|
||||||
#include "asibfm700_configfile.h"
|
// #include "asibfm700_configfile.h"
|
||||||
|
#include "asibfm700_config.h"
|
||||||
|
|
||||||
namespace asibfm700
|
namespace asibfm700
|
||||||
{
|
{
|
||||||
@@ -50,7 +51,8 @@ public:
|
|||||||
|
|
||||||
// using Asibfm700PZoneContainer::addPZone;
|
// using Asibfm700PZoneContainer::addPZone;
|
||||||
|
|
||||||
Asibfm700Mount(Asibfm700MountConfig const& config, std::shared_ptr<spdlog::logger> logger);
|
// Asibfm700Mount(Asibfm700MountConfig const& config, std::shared_ptr<spdlog::logger> logger);
|
||||||
|
Asibfm700Mount(Asibfm700MountConfiguration const& config, std::shared_ptr<spdlog::logger> logger);
|
||||||
|
|
||||||
~Asibfm700Mount();
|
~Asibfm700Mount();
|
||||||
|
|
||||||
@@ -62,9 +64,11 @@ public:
|
|||||||
|
|
||||||
error_t initMount();
|
error_t initMount();
|
||||||
|
|
||||||
error_t updateMountConfig(Asibfm700MountConfig const&);
|
// error_t updateMountConfig(Asibfm700MountConfig const&);
|
||||||
|
error_t updateMountConfig(Asibfm700MountConfiguration const&);
|
||||||
error_t updateMountConfig(std::string const& = std::string{}); // new filename
|
error_t updateMountConfig(std::string const& = std::string{}); // new filename
|
||||||
Asibfm700MountConfig currentMountConfig();
|
// Asibfm700MountConfig currentMountConfig();
|
||||||
|
Asibfm700MountConfiguration currentMountConfig();
|
||||||
|
|
||||||
// redefined method
|
// redefined method
|
||||||
auto getPointingTarget() const
|
auto getPointingTarget() const
|
||||||
@@ -73,7 +77,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Asibfm700MountConfig _mountConfig;
|
// Asibfm700MountConfig _mountConfig;
|
||||||
|
Asibfm700MountConfiguration _mountConfig;
|
||||||
std::unique_ptr<std::mutex> _mountConfigMutex;
|
std::unique_ptr<std::mutex> _mountConfigMutex;
|
||||||
|
|
||||||
AsibFM700ServoController _servolController;
|
AsibFM700ServoController _servolController;
|
||||||
|
|||||||
@@ -64,12 +64,17 @@ int main(int argc, char* argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
asibfm700::Asibfm700MountConfig mount_cfg;
|
// asibfm700::Asibfm700MountConfig mount_cfg;
|
||||||
|
asibfm700::Asibfm700MountConfiguration mount_cfg;
|
||||||
|
|
||||||
std::string fname = opt_result["dump"].as<std::string>();
|
std::string fname = opt_result["dump"].as<std::string>();
|
||||||
if (fname.size()) {
|
if (fname.size()) {
|
||||||
bool ok = mount_cfg.dumpDefaultsToFile(fname);
|
// bool ok = mount_cfg.dumpDefaultsToFile(fname);
|
||||||
if (!ok) {
|
// if (!ok) {
|
||||||
|
// return 255;
|
||||||
|
// }
|
||||||
|
auto err = mount_cfg.dumpDefaultsToFile(fname);
|
||||||
|
if (!err) {
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user