...
This commit is contained in:
parent
83b7e0d924
commit
f5039a329b
@ -6,6 +6,7 @@ namespace asibfm700
|
||||
{
|
||||
|
||||
|
||||
/* CONSTRUCTOR AND DESTRUCTOR */
|
||||
|
||||
Asibfm700Mount::Asibfm700Mount(Asibfm700MountConfig const& config,
|
||||
std::shared_ptr<spdlog::logger> logger,
|
||||
@ -19,30 +20,13 @@ Asibfm700Mount::Asibfm700Mount(Asibfm700MountConfig const& config,
|
||||
base_gm_class_t(gm_class_t{AsibFM700ServoController{config.servoControllerConfig}, mcc::MccTelemetry{this},
|
||||
Asibfm700PZoneContainer{}, mcc::MccSimpleSlewingModel{this},
|
||||
mcc::MccSimpleTrackingModel{this}, Asibfm700Logger{std::move(logger), pattern_range}},
|
||||
Asibfm700StartState{})
|
||||
Asibfm700StartState{}),
|
||||
_mountConfig(config),
|
||||
_mountConfigMutex(new std::mutex)
|
||||
{
|
||||
logDebug("Create Asibfm700Mount class instance ({})", this->getThreadId());
|
||||
|
||||
logInfo("Init AstroSib FM-700 mount with configuration:");
|
||||
logInfo(" site latitude: {}", config.siteLatitude.sexagesimal());
|
||||
logInfo(" site longitude: {}", config.siteLongitude.sexagesimal());
|
||||
logInfo(" site elevation: {} meters", config.siteElevation);
|
||||
logInfo(" refraction wavelength: {} mkm", config.refractWavelength);
|
||||
logInfo(" leap seconds filename: {}", config.leapSecondFilename);
|
||||
logInfo(" IERS Bulletin A filename: {}", config.bulletinAFilename);
|
||||
|
||||
logInfo("Add prohibited zones ...");
|
||||
|
||||
logInfo("Add MccAltLimitPZ zone: min alt = {}, lat = {}", config.pzMinAltitude.degrees(),
|
||||
config.siteLatitude.degrees());
|
||||
addPZone(mcc::MccAltLimitPZ<mcc::MccAltLimitKind::MIN_ALT_LIMIT>{config.pzMinAltitude, config.siteLatitude, this});
|
||||
|
||||
logInfo("Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {}", config.pzLimitSwitchHAMin,
|
||||
config.pzLimitSwitchHAMax);
|
||||
size_t pz_num = addPZone(mcc::MccAxisLimitSwitchPZ<mcc::MccCoordKind::COORDS_KIND_HA>{
|
||||
config.pzLimitSwitchHAMin, config.pzLimitSwitchHAMax, this});
|
||||
|
||||
logInfo("{} prohibited zones were added", pz_num);
|
||||
initMount();
|
||||
}
|
||||
|
||||
|
||||
@ -51,4 +35,104 @@ Asibfm700Mount::~Asibfm700Mount()
|
||||
logDebug("Delete Asibfm700Mount class instance ({})", this->getThreadId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* PUBIC METHODS */
|
||||
|
||||
Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
||||
{
|
||||
std::lock_guard lock{*_mountConfigMutex};
|
||||
|
||||
logInfo("Init AstroSib FM-700 mount with configuration:");
|
||||
logInfo(" site latitude: {}", _mountConfig.siteLatitude.sexagesimal());
|
||||
logInfo(" site longitude: {}", _mountConfig.siteLongitude.sexagesimal());
|
||||
logInfo(" site elevation: {} meters", _mountConfig.siteElevation);
|
||||
logInfo(" refraction wavelength: {} mkm", _mountConfig.refractWavelength);
|
||||
logInfo(" leap seconds filename: {}", _mountConfig.leapSecondFilename);
|
||||
logInfo(" IERS Bulletin A filename: {}", _mountConfig.bulletinAFilename);
|
||||
|
||||
logInfo("");
|
||||
clearPZones();
|
||||
logInfo("Add prohibited zones ...");
|
||||
|
||||
logInfo(" Add MccAltLimitPZ zone: min alt = {}, lat = {}", _mountConfig.pzMinAltitude.degrees(),
|
||||
_mountConfig.siteLatitude.degrees());
|
||||
addPZone(mcc::MccAltLimitPZ<mcc::MccAltLimitKind::MIN_ALT_LIMIT>{_mountConfig.pzMinAltitude,
|
||||
_mountConfig.siteLatitude, this});
|
||||
|
||||
logInfo(" Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {}",
|
||||
_mountConfig.pzLimitSwitchHAMin.degrees(), _mountConfig.pzLimitSwitchHAMax.degrees());
|
||||
size_t pz_num = addPZone(mcc::MccAxisLimitSwitchPZ<mcc::MccCoordKind::COORDS_KIND_HA>{
|
||||
_mountConfig.pzLimitSwitchHAMin, _mountConfig.pzLimitSwitchHAMax, this});
|
||||
|
||||
logInfo("{} prohibited zones were added successfully", pz_num);
|
||||
|
||||
logInfo("");
|
||||
logInfo("Setup slewing and tracking parameters ...");
|
||||
auto st_err = setSlewingParams(_mountConfig.movingModelParams);
|
||||
if (st_err) {
|
||||
errorLogging(" An error occured while setting slewing parameters: ", st_err);
|
||||
}
|
||||
st_err = setTrackingParams(_mountConfig.movingModelParams);
|
||||
if (st_err) {
|
||||
errorLogging(" An error occured while setting tracking parameters: ", st_err);
|
||||
}
|
||||
logInfo("Slewing and tracking parameters have been set successfully");
|
||||
|
||||
logInfo("");
|
||||
logInfo("Hardware initialization ...");
|
||||
logInfo(" set hardware configuration:");
|
||||
logInfo(" RunModel: {}",
|
||||
_mountConfig.servoControllerConfig.devConfig.RunModel == 1 ? "MODEL-MODE" : "REAL-MODE");
|
||||
logInfo(" mount dev path: {}", _mountConfig.servoControllerConfig.MountDevPath);
|
||||
logInfo(" encoder dev path: {}", _mountConfig.servoControllerConfig.EncoderDevPath);
|
||||
logInfo(" encoder X-dev path: {}", _mountConfig.servoControllerConfig.EncoderXDevPath);
|
||||
logInfo(" encoder Y-dev path: {}", _mountConfig.servoControllerConfig.EncoderYDevPath);
|
||||
|
||||
logInfo(" EncoderDevSpeed: {}", _mountConfig.servoControllerConfig.devConfig.EncoderDevSpeed);
|
||||
logInfo(" SepEncoder: {}", _mountConfig.servoControllerConfig.devConfig.SepEncoder);
|
||||
logInfo(" MountReqInterval: {}", _mountConfig.servoControllerConfig.devConfig.MountReqInterval);
|
||||
logInfo(" EncoderReqInterval: {}", _mountConfig.servoControllerConfig.devConfig.EncoderReqInterval);
|
||||
logInfo(" EncoderSpeedInterval: {}", _mountConfig.servoControllerConfig.devConfig.EncoderSpeedInterval);
|
||||
|
||||
logInfo(" XPIDC: [P: {}, I: {}, D: {}]", _mountConfig.servoControllerConfig.devConfig.XPIDC.P,
|
||||
_mountConfig.servoControllerConfig.devConfig.XPIDC.I, _mountConfig.servoControllerConfig.devConfig.XPIDC.D);
|
||||
logInfo(" XPIDV: [P: {}, I: {}, D: {}]", _mountConfig.servoControllerConfig.devConfig.XPIDV.P,
|
||||
_mountConfig.servoControllerConfig.devConfig.XPIDV.I, _mountConfig.servoControllerConfig.devConfig.XPIDV.D);
|
||||
logInfo(" YPIDC: [P: {}, I: {}, D: {}]", _mountConfig.servoControllerConfig.devConfig.YPIDC.P,
|
||||
_mountConfig.servoControllerConfig.devConfig.YPIDC.I, _mountConfig.servoControllerConfig.devConfig.YPIDC.D);
|
||||
logInfo(" YPIDV: [P: {}, I: {}, D: {}]", _mountConfig.servoControllerConfig.devConfig.YPIDV.P,
|
||||
_mountConfig.servoControllerConfig.devConfig.YPIDV.I, _mountConfig.servoControllerConfig.devConfig.YPIDV.D);
|
||||
|
||||
auto hw_err = hardwareInit();
|
||||
if (hw_err) {
|
||||
errorLogging("", hw_err);
|
||||
}
|
||||
|
||||
return mcc::MccGenericMountErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountConfig& cfg)
|
||||
{
|
||||
std::lock_guard lock{*_mountConfigMutex};
|
||||
|
||||
hardwareUpdateConfig(_mountConfig.servoControllerConfig.devConfig);
|
||||
hardwareUpdateConfig(_mountConfig.servoControllerConfig.hwConfig);
|
||||
|
||||
return AsibFM700ServoControllerErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/* PROTECTED METHODS */
|
||||
|
||||
void Asibfm700Mount::errorLogging(const std::string& msg, const std::error_code& err)
|
||||
{
|
||||
if (msg.empty()) {
|
||||
logError("{}::{} ({})", err.category().name(), err.value(), err.message());
|
||||
} else {
|
||||
logError("{}: {}::{} ({})", msg, err.category().name(), err.value(), err.message());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace asibfm700
|
||||
|
||||
@ -100,6 +100,18 @@ public:
|
||||
const auto& pattern_range = mcc::utils::MccSpdlogLogger::LOGGER_DEFAULT_FORMAT);
|
||||
|
||||
~Asibfm700Mount();
|
||||
|
||||
|
||||
error_t initMount();
|
||||
|
||||
error_t updateMountConfig(Asibfm700MountConfig const&);
|
||||
Asibfm700MountConfig currentMountConfig();
|
||||
|
||||
protected:
|
||||
Asibfm700MountConfig _mountConfig;
|
||||
std::unique_ptr<std::mutex> _mountConfigMutex;
|
||||
|
||||
void errorLogging(const std::string&, const std::error_code&);
|
||||
};
|
||||
|
||||
static_assert(mcc::mcc_position_controls_c<Asibfm700Mount>, "");
|
||||
|
||||
@ -142,4 +142,33 @@ AsibFM700ServoController::error_t AsibFM700ServoController::hardwareGetState(har
|
||||
}
|
||||
|
||||
|
||||
void AsibFM700ServoController::hardwareUpdateConfig(conf_t cfg)
|
||||
{
|
||||
_hardwareConfig.devConfig = std::move(cfg);
|
||||
|
||||
_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());
|
||||
}
|
||||
|
||||
|
||||
AsibFM700ServoController::error_t AsibFM700ServoController::hardwareUpdateConfig(hardware_configuration_t cfg)
|
||||
{
|
||||
_hardwareConfig.hwConfig = std::move(cfg);
|
||||
return static_cast<AsibFM700ServoControllerErrorCode>(Mount.saveHWconfig(&_hardwareConfig.hwConfig));
|
||||
}
|
||||
|
||||
|
||||
AsibFM700ServoController::error_t AsibFM700ServoController::hardwareUpdateConfig()
|
||||
{
|
||||
return static_cast<AsibFM700ServoControllerErrorCode>(Mount.getHWconfig(&_hardwareConfig.hwConfig));
|
||||
}
|
||||
|
||||
|
||||
AsibFM700ServoController::hardware_config_t AsibFM700ServoController::hardwareConfig() const
|
||||
{
|
||||
return _hardwareConfig;
|
||||
}
|
||||
|
||||
} // namespace asibfm700
|
||||
|
||||
@ -89,8 +89,8 @@ public:
|
||||
std::string EncoderXDevPath;
|
||||
std::string EncoderYDevPath;
|
||||
|
||||
conf_t devConfig;
|
||||
hardware_configuration_t hwConfig;
|
||||
conf_t devConfig; // devices paths and PIDs parameters
|
||||
hardware_configuration_t hwConfig; // EEPROM-located configuration
|
||||
|
||||
std::chrono::milliseconds pollingInterval{300}; // hardware polling interval
|
||||
std::chrono::milliseconds pollingTimeout{30000}; // hardware polling timeout
|
||||
@ -121,7 +121,13 @@ public:
|
||||
error_t hardwareInit();
|
||||
|
||||
void hardwareUpdateConfig(conf_t cfg);
|
||||
void hardwareUpdateConfig(hardware_configuration_t cfg);
|
||||
|
||||
// save config to EEPROM
|
||||
error_t hardwareUpdateConfig(hardware_configuration_t cfg);
|
||||
// load config from EEPROM
|
||||
error_t hardwareUpdateConfig();
|
||||
|
||||
hardware_config_t hardwareConfig() const;
|
||||
|
||||
private:
|
||||
hardware_config_t _hardwareConfig;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user