Skip to content

Commit

Permalink
Add strict StarbookEqu serialization and transform Ra from INDI
Browse files Browse the repository at this point in the history
Starbook doesn't like certain input parameters.
By setting fixed with we can minimize possible errors.
INDI supplies different ra parameter than those used in libnova.
  • Loading branch information
not7cd committed Dec 13, 2018
1 parent 20005ba commit a6fbfa0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
11 changes: 9 additions & 2 deletions indi-starbook/indi_starbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ bool Starbook::ReadScopeStatus() {
} else if (value == "INIT") {
state = StarbookState::SB_SCOPE;
} else {
LOGF_ERROR("unknown state %s", value.c_str());
LOGF_ERROR("Unknown state %s", value.c_str());
}
LOGF_DEBUG("Parsed STATE %i", state);
}

response = sm.suffix();
Expand All @@ -160,8 +161,14 @@ bool Starbook::ReadScopeStatus() {
bool Starbook::Goto(double ra, double dec) {
LOG_INFO("Goto! Sending GOTORADEC command");

// ln_equ_posn target_d = {ra * 15.0, dec};
// lnh_equ_posn equ_posn = {{0, 0, 0},
// {0, 0, 0, 0}};
// ln_equ_to_hequ(&target_d, &equ_posn);
std::ostringstream params;
params << StarbookEqu(ra, dec);
params << "?" << StarbookEqu(ra, dec);

LOG_ERROR(params.str().c_str());

bool res = SendCommand("GOTORADEC" + params.str());
return res;
Expand Down
18 changes: 11 additions & 7 deletions indi-starbook/starbook_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ enum StarbookState {
class StarbookEqu {
public:
StarbookEqu(double ra, double dec) {
ln_equ_posn target_d = {ra, dec};
ln_equ_posn target_d = {0, 0};
target_d.ra = ra * 15;
target_d.dec = dec;
equ_posn = {{0, 0, 0},
{0, 0, 0, 0}};
ln_equ_to_hequ(&target_d, &equ_posn);
Expand All @@ -31,11 +33,17 @@ class StarbookEqu {
friend std::ostream &operator<<(std::ostream &os, const StarbookEqu &e) {
os << std::fixed << std::setprecision(0);
os << "RA=";
os << e.equ_posn.ra.hours << "+" << e.equ_posn.ra.minutes << "." << e.equ_posn.ra.seconds;
os << std::setfill('0') << std::setw(2) << e.equ_posn.ra.hours
<< std::setw(0) << "+"
<< std::setw(2) << e.equ_posn.ra.minutes
<< std::setw(0) << "." << e.equ_posn.ra.seconds;

os << "&DEC=";
if (e.equ_posn.dec.neg != 0) os << "-";
os << e.equ_posn.dec.degrees << "+" << e.equ_posn.dec.minutes;
os << std::setfill('0') << std::setw(3) << e.equ_posn.dec.degrees
<< std::setw(0) << "+"
<< std::setw(2) << e.equ_posn.dec.minutes
<< std::setw(0);
return os;
}

Expand All @@ -54,7 +62,3 @@ class StarbookEqu {
lnh_equ_posn equ_posn;

};




0 comments on commit a6fbfa0

Please sign in to comment.