...
This commit is contained in:
@@ -62,12 +62,40 @@ const AsibFM700HardwareErrorCategory& AsibFM700HardwareErrorCategory::get()
|
||||
|
||||
/* constructors and destructor */
|
||||
|
||||
AsibFM700Hardware::AsibFM700Hardware(const hardware_config_t& conf) : _hardwareConfig(conf)
|
||||
AsibFM700Hardware::AsibFM700Hardware(const hardware_config_t& conf)
|
||||
: _hardwareConfig(conf), _sideralRate2(_hardwareConfig.hwConfig.eqrate)
|
||||
{
|
||||
_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());
|
||||
|
||||
_sideralRate2 *= _sideralRate2;
|
||||
_sideralRateEps2 = 0.01; // 1%
|
||||
|
||||
// start state polling
|
||||
|
||||
_statePollingThread = std::jthread([this](std::stop_token stoken) {
|
||||
mountdata_t data;
|
||||
|
||||
while (true) {
|
||||
if (stoken.stop_requested()) {
|
||||
return;
|
||||
}
|
||||
|
||||
error_t err = static_cast<AsibFM700HardwareErrorCode>(Mount.getMountData(&data));
|
||||
|
||||
|
||||
if (err == AsibFM700HardwareErrorCode::ERROR_OK) {
|
||||
// are both motors stopped?
|
||||
bool stop_motors =
|
||||
(data.extradata.ExtraBits & XMOTOR_STOP_BIT) && (data.extradata.ExtraBits & YMOTOR_STOP_BIT);
|
||||
if (stop_motors) {
|
||||
_state = hw_state_t::HW_STATE_STOP;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// AsibFM700Hardware::AsibFM700Hardware(AsibFM700Hardware&& other)
|
||||
@@ -102,6 +130,15 @@ AsibFM700Hardware::error_t AsibFM700Hardware::getState(AsibFM700Hardware::hw_sta
|
||||
state = hw_state_t::HW_STATE_STOP;
|
||||
return AsibFM700HardwareErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
// compute current speed
|
||||
auto rate2 = data.encXspeed.val * data.encXspeed.val + data.encYspeed.val * data.encYspeed.val;
|
||||
auto ratio2 = rate2 / _sideralRate2;
|
||||
if (ratio2 <= _sideralRateEps2) { // tracking
|
||||
state = hw_state_t::HW_STATE_TRACK;
|
||||
} else {
|
||||
state = hw_state_t::HW_STATE_SLEW;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
@@ -115,6 +152,10 @@ AsibFM700Hardware::error_t AsibFM700Hardware::setPos(AsibFM700Hardware::axes_pos
|
||||
// according to"SiTech protocol notes" X is DEC-axis and Y is HA-axis
|
||||
coordpair_t hw_pos{.X = pos.y, .Y = pos.x};
|
||||
|
||||
if (!pos.flags.slewNguide) {
|
||||
return static_cast<AsibFM700HardwareErrorCode>(Mount.slewTo(&hw_pos, pos.flags));
|
||||
}
|
||||
|
||||
switch (pos.state) {
|
||||
case hw_state_t::HW_STATE_SLEW: // slew mount
|
||||
err = static_cast<AsibFM700HardwareErrorCode>(Mount.slewTo(&hw_pos, pos.flags));
|
||||
|
||||
Reference in New Issue
Block a user