...
This commit is contained in:
116
include/mcc/mcc_generic_movecontrols.h
Normal file
116
include/mcc/mcc_generic_movecontrols.h
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "mcc_error.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
enum class MccGenericMovementControlsErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_IN_PZONE,
|
||||||
|
ERRROR_NEAR_PZONE,
|
||||||
|
ERROR_TELEMETRY_TIMEOUT
|
||||||
|
};
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccGenericMovementControlsErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
// error category
|
||||||
|
struct MccGenericMovementControlsErrorCategory : std::error_category {
|
||||||
|
const char* name() const noexcept { return "MCC-GENERIC-MOVECONTRL"; }
|
||||||
|
|
||||||
|
std::string message(int ec) const
|
||||||
|
{
|
||||||
|
MccGenericMovementControlsErrorCode err = static_cast<MccGenericMovementControlsErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_IN_PZONE:
|
||||||
|
return "target is in zone";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERRROR_NEAR_PZONE:
|
||||||
|
return "mount is near zone";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_TELEMETRY_TIMEOUT:
|
||||||
|
return "telemetry data timeout";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccGenericMovementControlsErrorCategory& get()
|
||||||
|
{
|
||||||
|
static const MccGenericMovementControlsErrorCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccGenericMovementControlsErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccGenericMovementControlsErrorCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct MccGenericMovementControlsParams {
|
||||||
|
// timeout to telemetry updating
|
||||||
|
std::chrono::milliseconds telemetryTimeout{3000};
|
||||||
|
|
||||||
|
// braking acceleration after execution of mount stopping command (in rads/s^2)
|
||||||
|
// it must be given as non-negative value!!!
|
||||||
|
double brakingAccelX{0.0};
|
||||||
|
double brakingAccelY{0.0};
|
||||||
|
|
||||||
|
// ******* slewing mode *******
|
||||||
|
|
||||||
|
// coordinates difference to stop slewing (in radians)
|
||||||
|
double slewToleranceRadius{5.0_arcsecs};
|
||||||
|
|
||||||
|
// slewing trajectory file. if empty - just skip saving
|
||||||
|
std::string slewingPathFilename{};
|
||||||
|
|
||||||
|
|
||||||
|
// ******* tracking mode *******
|
||||||
|
|
||||||
|
// maximal target-to-mount difference for tracking process (in arcsecs)
|
||||||
|
// it it is greater then the current mount coordinates are used as target one
|
||||||
|
double trackingMaxCoordDiff{20.0};
|
||||||
|
|
||||||
|
// tracking trajectory file. if empty - just skip saving
|
||||||
|
std::string trackingPathFilename{};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <std::default_constructible PARAMS_T>
|
||||||
|
class MccGenericMovementControls
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef MccError error_t;
|
||||||
|
|
||||||
|
typedef PARAMS_T movement_params_t;
|
||||||
|
|
||||||
|
error_t slewToTarget(bool slew_and_stop) {}
|
||||||
|
|
||||||
|
error_t trackTarget() {}
|
||||||
|
|
||||||
|
error_t stopMount() {}
|
||||||
|
|
||||||
|
error_t setMovementParams(movement_params_t const& pars) { _currentParams->store(pars); }
|
||||||
|
|
||||||
|
movement_params_t getMovementParams() const { return _currentParams->load(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MccGenericMovementControls() = default;
|
||||||
|
|
||||||
|
std::unique_ptr<std::atomic<PARAMS_T>> _currentParams{new std::atomic<PARAMS_T>{}};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
Reference in New Issue
Block a user