A simple GOTO telescope that simulator slewing operation.
#include <cmath>
#include <memory>
static std::unique_ptr<SimpleScope> simpleScope(
new SimpleScope());
{
}
{
return true;
}
{
return true;
}
{
return "Simple Scope";
}
{
char RAStr[64]={0}, DecStr[64]={0};
fs_sexa(DecStr, targetDEC, 2, 3600);
LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
return true;
}
{
return true;
}
{
static struct timeval ltv { 0, 0 };
struct timeval tv { 0, 0 };
double dt = 0, da_ra = 0, da_dec = 0, dx = 0, dy = 0;
int nlocked;
gettimeofday(&tv, nullptr);
if (ltv.tv_sec == 0 && ltv.tv_usec == 0)
ltv = tv;
dt = tv.tv_sec - ltv.tv_sec + (tv.tv_usec - ltv.tv_usec) / 1e6;
ltv = tv;
da_ra = SLEW_RATE * dt;
da_dec = SLEW_RATE * dt;
{
nlocked = 0;
dx = targetRA - currentRA;
if (fabs(dx) * 15. <= da_ra)
{
nlocked++;
}
else if (dx > 0)
else
dy = targetDEC - currentDEC;
if (fabs(dy) <= da_dec)
{
nlocked++;
}
else if (dy > 0)
else
if (nlocked == 2)
{
LOG_INFO(
"Telescope slew is complete. Tracking...");
}
break;
default:
break;
}
char RAStr[64]={0}, DecStr[64]={0};
fs_sexa(RAStr, currentRA, 2, 3600);
fs_sexa(DecStr, currentDEC, 2, 3600);
DEBUGF(DBG_SCOPE,
"Current RA: %s Current DEC: %s", RAStr, DecStr);
return true;
}