1 #include <boost/regex.hpp> 21 namespace ba = boost::asio;
22 namespace bs = boost::system;
23 namespace dummy = ba::placeholders;
26 using namespace Drive;
83 virtual void UpdateSource(
const array<double, 6> &,
const string& =
"")
95 uint16_t y, m, d, hh, mm, ss, ms;
96 in >> y >> m >> d >> hh >> mm >> ss >> ms;
98 return Time(y, m, d, hh, mm, ss, ms*1000);
107 in >> sgn >> d >> m >> s;
109 const double ret = ((60.0 * (60.0 * (double)d + (
double)m) + s))/3600.;
110 return sgn==
'-' ? -ret : ret;
113 double GetDevAbs(
double nomzd,
double meszd,
double devaz)
119 const double x = sin(meszd) * sin(nomzd) * cos(devaz);
120 const double y = cos(meszd) * cos(nomzd);
122 return acos(x + y) * 180/M_PI;
141 istringstream stream(line);
154 double misszd, missaz;
155 stream >> misszd >> missaz;
157 const double zd = ReadAngle(stream);
158 const double az = ReadAngle(stream);
167 stream >> bright >> mjd;
169 int nled, nring, nstars;
170 stream >> nled >> nring >> nstars;
177 data.fMissZd = misszd;
178 data.fMissAz = missaz;
179 data.fNominalZd = zd;
180 data.fNominalAz = az;
183 data.fNumCorrelated = ncor;
184 data.fBrightness = bright;
185 data.fNumLeds = nled;
186 data.fNumRings = nring;
187 data.fNumStars = nstars;
189 UpdateStarguider(
Time(mjd), data);
196 istringstream stream(line);
200 const Time t1 = ReadTime(stream);
211 double az1, alt1, az2, alt2, ra, dec, dzd, daz;
212 stream >> az1 >> alt1 >> az2 >> alt2 >> ra >> dec >> dzd >> daz;
215 double mjd, cmag, smag, cx, cy, sx, sy;
216 stream >> mjd >> cmag >> smag >> cx >> cy >> sx >> sy;
218 int nled, nring, nstar, ncor;
219 stream >> nled >> nring >> nstar >> ncor;
222 stream >> bright >>
mag;
257 UpdateTPoint(t1, tpoint, name);
285 istringstream stream(line);
289 const Time t1 = ReadTime(stream);
295 const double ra = ReadAngle(stream);
296 const double dec = ReadAngle(stream);
297 const double ha = ReadAngle(stream);
302 const double zd1 = ReadAngle(stream);
303 const double az1 = ReadAngle(stream);
304 const double zd2 = ReadAngle(stream);
305 const double az2 = ReadAngle(stream);
307 double zd_err, az_err;
311 uint16_t armed, stgmd;
316 stream >> hex >> pdo3;
328 const bool ready = (pdo3&0xef00ef)==0xef00ef;
330 fState = Drive::State::kNotReady;
332 fState = status1==1 ?
333 Drive::State::kReady+armed :
334 Drive::State::kNotReady+status1;
368 const double dev = GetDevAbs(zd1, zd1-zd_err, az_err)*3600;
370 fDevBuffer[fDevCount++%5] =
dev;
372 const uint8_t cnt = fDevCount<5 ? fDevCount : 5;
373 const double avgdev = accumulate(fDevBuffer.begin(), fDevBuffer.begin()+cnt, 0)/cnt;
378 fTrackingCounter = 0;
444 const array<uint8_t, 3> state = {{ uint8_t(pdo3>>16), uint8_t(pdo3), uint8_t(pdo3>>24) }};
445 UpdateStatus(t1, state);
447 const array<double, 2> point = {{ zd2, az2 }};
448 UpdatePointing(t1, point);
450 const array<double, 8> track =
458 UpdateTracking(
Time(mjd), track);
487 if (bytes_received==0 || err)
489 if (err==ba::error::eof)
490 Warn(
"Connection closed by remote host (cosy).");
494 if (err && err!=ba::error::eof &&
495 err!=ba::error::basic_errors::not_connected &&
496 err!=ba::error::basic_errors::operation_aborted)
499 str <<
"Reading from " << URL() <<
": " << err.message() <<
" (" << err <<
")";
502 PostClose(err!=ba::error::basic_errors::operation_aborted);
506 istream is(&fBuffer);
512 Out() << line << endl;
516 if (line.substr(0, 13)==
"DRIVE-STATUS ")
518 ProcessDriveStatus(line.substr(70));
522 if (line.substr(0, 13)==
"STARG-REPORT ")
524 ProcessStargReport(line.substr(16));
528 if (line.substr(0, 14)==
"TPOINT-REPORT ")
530 ProcessTpointReport(line.substr(17));
534 if (line.substr(0, 13)==
"DRIVE-REPORT ")
536 ProcessDriveReport(line.substr(16));
543 boost::asio::async_read_until(*
this, fBuffer,
'\n',
545 dummy::error, dummy::bytes_transferred));
552 PostMessage(
string(
"KEEP_ALIVE"));
554 fKeepAlive.expires_from_now(boost::posix_time::seconds(10));
556 this, dummy::error));
562 if (error && error!=ba::error::basic_errors::operation_aborted)
565 str <<
"Write timeout of " << URL() <<
": " << error.message() <<
" (" << error <<
")";
583 if (fKeepAlive.expires_at() > ba::deadline_timer::traits_type::now())
638 fState(-1), fIsVerbose(true),
639 fDeviationLimit(120), fDeviationCounter(5), fDeviationMax(240),
640 fDevBuffer(5), fDevCount(0),
641 fTrackingCounter(0), fKeepAlive(ioservice)
653 fDeviationLimit = limit;
662 if (IsConnected() && fState<0)
704 vector<char> dim(
sizeof(data)+name.length()+1);
705 memcpy(dim.data(), &
data,
sizeof(
data));
706 memcpy(dim.data()+
sizeof(
data), name.c_str(), name.length()+1);
715 fDimPointing(
"DRIVE_CONTROL/POINTING_POSITION",
"D:1;D:1",
716 "|Zd[deg]:Zenith distance (encoder readout)" 717 "|Az[deg]:Azimuth angle (encoder readout)"),
718 fDimTracking(
"DRIVE_CONTROL/TRACKING_POSITION",
"D:1;D:1;D:1;D:1;D:1;D:1;D:1;D:1",
719 "|Ra[h]:Command right ascension" 720 "|Dec[deg]:Command declination" 721 "|Ha[h]:Corresponding hour angle" 722 "|Zd[deg]:Nominal zenith distance" 723 "|Az[deg]:Nominal azimuth angle" 724 "|dZd[deg]:Control deviation Zd" 725 "|dAz[deg]:Control deviation Az" 726 "|dev[arcsec]:Absolute control deviation"),
727 fDimSource(
"DRIVE_CONTROL/SOURCE_POSITION",
"D:1;D:1;D:1;D:1;D:1;D:1;C:31",
728 "|Ra_src[h]:Source right ascension" 729 "|Dec_src[deg]:Source declination" 730 "|Ra_cmd[h]:Command right ascension" 731 "|Dec_cmd[deg]:Command declination" 732 "|Offset[deg]:Wobble offset" 733 "|Angle[deg]:Wobble angle" 734 "|Name[string]:Source name if available"),
735 fDimTPoint(
"DRIVE_CONTROL/TPOINT_DATA",
"D:1;D:1;D:1;D:1;D:1;D:1;D:1;D:1;S:1;S:1;D:1;D:1;D:1;D:1;D:1;D:1;D:1;C",
736 "|Ra[h]:Command right ascension" 737 "|Dec[deg]:Command declination" 738 "|Zd_nom[deg]:Nominal zenith distance" 739 "|Az_nom[deg]:Nominal azimuth angle" 740 "|Zd_cur[deg]:Current zenith distance (calculated from image)" 741 "|Az_cur[deg]:Current azimuth angle (calculated from image)" 742 "|Zd_enc[deg]:Feedback zenith axis (from encoder)" 743 "|Az_enc[deg]:Feedback azimuth angle (from encoder)" 744 "|N_leds[cnt]:Number of detected LEDs" 745 "|N_rings[cnt]:Number of rings used to calculate the camera center" 746 "|Xc[pix]:X position of center in CCD camera frame" 747 "|Yc[pix]:Y position of center in CCD camera frame" 748 "|Ic[au]:Average intensity (LED intensity weighted with their frequency of occurance in the calculation)" 749 "|Xs[pix]:X position of start in CCD camera frame" 750 "|Ys[pix]:Y position of star in CCD camera frame" 751 "|Ms[mag]:Artifical magnitude of star (calculated form image))" 752 "|Mc[mag]:Catalog magnitude of star" 753 "|name[string]:Name of star"),
754 fDimStatus(
"DRIVE_CONTROL/STATUS",
"C:2;C:1",
"")
761 vector<char> dat(6*
sizeof(
double)+31, 0);
762 strncpy(dat.data()+6*
sizeof(double), name.c_str(), 30);
770 vector<char> dat(6*
sizeof(
double)+31, 0);
771 memcpy(dat.data(), arr.data(), 6*
sizeof(double));
772 strncpy(dat.data()+6*
sizeof(double), name.c_str(), 30);
783 template <
class T,
class S>
810 msg << name <<
" - Received event has " << has <<
" bytes, but expected " << size <<
".";
825 const char sgn = angle<0?
'-':
'+';
828 double a = round(3600. * fabs(angle));
831 const double ad = trunc(a/3600.);
833 const double am = trunc(a/60.);
835 const double as = trunc(a);
839 str << sgn <<
" " << uint16_t(ad) <<
" " << uint16_t(am) <<
" " << as;
849 T::Info(
"Last command was not a tracking command. RESUME ignored.");
850 return T::GetCurrentState();
853 fLastCommand = str.compare(0, 6,
"RADEC ")==0 ? str :
"";
855 fDrive.PostMessage(str);
856 T::Message(
"Sending: "+str);
858 return T::GetCurrentState();
865 fDrive.UpdateSource(source,
true);
867 return T::GetCurrentState();
873 fDrive.UpdateSource(
"Park");
882 fDrive.UpdateSource();
884 return T::GetCurrentState();
889 if (fLastCommand.empty())
891 T::Info(
"Last command was not a tracking command. RESUME ignored.");
892 return T::GetCurrentState();
896 T::Info(
"Resume: "+fLastCommand);
902 if (!CheckEventSize(evt.
GetSize(),
"SendCoordinates", 16))
903 return T::kSM_FatalError;
905 const double *dat = evt.
Ptr<
double>();
911 case kPoint: command +=
"ZDAZ ";
break;
912 case kTrackSlow: command +=
"RADEC ";
break;
913 case kTrackFast: command +=
"GRB ";
break;
918 const array<double, 6> dim = {{ dat[0], dat[1], dat[0], dat[1], 0, 0 }};
919 fDrive.UpdateSource(dim);
922 fDrive.UpdateSource(
"",
false);
925 command += AngleToStr(dat[0]) +
' ' + AngleToStr(dat[1]);
930 const double &woboff,
const double &wobang,
931 const string name=
"")
933 const double ra = srcra *M_PI/12;
934 const double dec = srcdec*M_PI/180;
935 const double off = woboff*M_PI/180;
936 const double dir = wobang*M_PI/180;
938 const double cosdir = cos(dir);
939 const double sindir = sin(dir);
940 const double cosoff = cos(off);
941 const double sinoff = sin(off);
942 const double cosdec = cos(dec);
943 const double sindec = sin(dec);
947 const array<double, 6> dim = {{ srcra, srcdec, srcra, srcdec, 0, 0 }};
948 fDrive.UpdateSource(dim, name);
950 string command =
"RADEC ";
951 command += AngleToStr(srcra) +
' ' + AngleToStr(srcdec);
955 const double sintheta = sindec*cosoff + cosdec*sinoff*cosdir;
959 return T::GetCurrentState();
962 const double costheta = sqrt(1 - sintheta*sintheta);
964 const double cosdeltara = (cosoff - sindec*sintheta)/(cosdec*costheta);
965 const double sindeltara = sindir*sinoff/costheta;
967 const double ndec = asin(sintheta)*180/M_PI;
968 const double nra = (atan2(sindeltara, cosdeltara) + ra)*12/M_PI;
970 const array<double, 6> dim = {{ srcra, srcdec, nra, ndec, woboff, wobang }};
971 fDrive.UpdateSource(dim, name);
973 string command =
"RADEC ";
974 command += AngleToStr(nra) +
' ' + AngleToStr(ndec);
980 if (!CheckEventSize(evt.
GetSize(),
"Wobble", 32))
981 return T::kSM_FatalError;
983 const double *dat = evt.
Ptr<
double>();
985 return StartWobble(dat[0], dat[1], dat[2], dat[3]);
990 if (find(ptr, last,
'\0')==last)
992 T::Fatal(
"TrackWobble - The name transmitted by dim is not null-terminated.");
993 throw uint32_t(T::kSM_FatalError);
996 const string name(ptr);
998 const sources::const_iterator it = fSources.find(name);
999 if (it==fSources.end())
1001 T::Error(
"Source '"+name+
"' not found in list.");
1002 throw uint32_t(T::GetCurrentState());
1013 msg <<
"Track - Received event has " << evt.
GetSize() <<
" bytes, but expected at least 3.";
1015 return T::kSM_FatalError;
1018 const uint16_t wobble = evt.
GetUShort();
1019 if (wobble!=1 && wobble!=2)
1022 msg <<
"TrackWobble - Wobble id " << wobble <<
" undefined, only 1 and 2 allowed.";
1024 return T::GetCurrentState();
1027 const char *ptr = evt.
Ptr<
char>(2);
1028 const char *last = ptr+evt.
GetSize()-2;
1032 const sources::const_iterator it = GetSourceFromDB(ptr, last);
1034 const string &name = it->first;
1035 const Source &src = it->second;
1037 return StartWobble(src.
ra, src.
dec, src.
offset, src.angle[wobble-1], name);
1039 catch (
const uint32_t &e)
1047 const char *last = ptr+
size;
1051 const sources::const_iterator it = GetSourceFromDB(ptr, last);
1053 const string &name = it->first;
1054 const Source &src = it->second;
1056 return StartWobble(src.
ra, src.
dec, offset, angle, name);
1058 catch (
const uint32_t &e)
1070 msg <<
"Track - Received event has " << evt.
GetSize() <<
" bytes, but expected at least 17.";
1072 return T::kSM_FatalError;
1075 const double *dat = evt.
Ptr<
double>();
1076 const char *ptr = evt.
Ptr<
char>(16);
1079 return StartTrackWobble(ptr, size, dat[0], dat[1]);
1087 msg <<
"TrackOn - Received event has " << evt.
GetSize() <<
" bytes, but expected at least 1.";
1089 return T::kSM_FatalError;
1092 return StartTrackWobble(evt.
Ptr<
char>(), evt.
GetSize());
1101 msg <<
"TakePoint - Received event has " << evt.
GetSize() <<
" bytes, but expected at least 5.";
1103 return T::kSM_FatalError;
1106 const float mag = evt.
Get<
float>();
1107 const char *ptr = evt.
Ptr<
char>(4);
1111 while (src.find_first_of(
' ')!=string::npos)
1112 src.erase(src.find_first_of(
' '), 1);
1116 return T::GetCurrentState();
1121 if (!CheckEventSize(evt.
GetSize(),
"SetLedBrightness", 8))
1122 return T::kSM_FatalError;
1124 const uint32_t *led = evt.
Ptr<uint32_t>();
1126 return SendCommand(
"LEDS "+to_string(led[0])+
" "+to_string(led[1]));
1132 if (!CheckEventSize(evt.
GetSize(),
"SetVerbosity", 1))
1133 return T::kSM_FatalError;
1135 fDrive.SetVerbose(evt.
GetBool());
1137 return T::GetCurrentState();
1142 if (!CheckEventSize(evt.
GetSize(),
"SetAutoResume", 1))
1143 return T::kSM_FatalError;
1147 return T::GetCurrentState();
1154 T::Warn(
"Drive in error - maybe no connection to electronics... trying to send STOP.");
1158 return Drive::State::kNotReady;
1163 for (
auto it=fSources.begin(); it!=fSources.end(); it++)
1165 const string &name = it->first;
1166 const Source &src = it->second;
1168 T::Out() << name <<
",";
1169 T::Out() << src.
ra <<
"," << src.
dec <<
"," << src.
offset <<
",";
1170 T::Out() << src.angle[0] <<
"," << src.angle[1] << endl;
1172 return T::GetCurrentState();
1181 catch (
const exception &e)
1183 T::Error(
"Reading sources from databse failed: "+
string(e.what()));
1185 return T::GetCurrentState();
1191 fDrive.PostClose(
false);
1199 return T::GetCurrentState();
1205 fDrive.PostClose(
false);
1209 ba::io_service::poll();
1215 fDrive.PostClose(
true);
1217 return T::GetCurrentState();
1263 msg <<
"Next sun-rise will be at " << fSunRise;
1273 const int state = fDrive.GetState();
1275 if (!fLastCommand.empty())
1285 fAutoResumeTime = now;
1288 if (fAutoResume==2 && fAutoResumeTime+boost::posix_time::seconds(5)<now)
1310 fAutoResume(false), fSunRise(
Time().GetNextSunRise())
1314 "No connection to cosy");
1317 "Cosy connected, drive stopped");
1319 T::AddStateName(State::kNotReady,
"NotReady",
1320 "Drive system not ready for movement");
1323 "Drive system is locked (will not accept commands)");
1325 T::AddStateName(State::kReady,
"Ready",
1326 "Drive system ready for movement");
1329 "Cosy armed, drive stopped");
1332 "Telescope moving");
1335 "Telescope is in tracking mode");
1338 "Telescope tracking stable");
1367 (
"Move the telescope to the given local coordinates" 1368 "|Zd[deg]:Zenith distance" 1369 "|Az[deg]:Azimuth");
1373 (
"Move the telescope to the given sky coordinates and start tracking them" 1374 "|Ra[h]:Right ascension" 1375 "|Dec[deg]:Declination");
1379 (
"Move the telescope to the given wobble position around the given sky coordinates and start tracking them" 1380 "|Ra[h]:Right ascension" 1381 "|Dec[deg]:Declination" 1382 "|Offset[deg]:Wobble offset" 1383 "|Angle[deg]:Wobble angle");
1387 (
"Move the telescope to the given wobble position around the given source and start tracking" 1388 "|Offset[deg]:Wobble offset" 1389 "|Angle[deg]:Wobble angle" 1390 "|Name[string]:Source name");
1394 (
"Move the telescope to the given wobble position around the given source and start tracking" 1395 "|id:Wobble angle id (1 or 2)" 1396 "|Name[string]:Source name");
1400 (
"Move the telescope to the given position and start tracking" 1401 "|Name[string]:Source name");
1405 (
"If drive is in Error state, this can b used to resume the last tracking command, if the last command sent to cosy was a tracking command.");
1409 (
"Start tracking the moon");
1412 (
"Start tracking Venus");
1415 (
"Start tracking Mars");
1418 (
"Start tracking Jupiter");
1421 (
"Start tracking Saturn");
1425 (
"Park the telescope");
1427 T::AddEvent(
"TAKE_TPOINT")
1431 T::AddEvent(
"TPOINT",
"F:1;C")
1433 (
"Take a TPoint (given values will be written to the TPoint files)" 1434 "|mag[float]:Magnitude of the star" 1435 "|name[string]:Name of the star");
1437 T::AddEvent(
"SET_LED_BRIGHTNESS",
"I:2")
1439 (
"Set the LED brightness of the top and bottom leds" 1440 "|top[au]:Allowed range 0-32767 for top LEDs" 1441 "|bot[au]:Allowed range 0-32767 for bottom LEDs");
1443 T::AddEvent(
"LEDS_OFF")
1445 (
"Switch off TPoint LEDs");
1449 (
"Stop any kind of movement.");
1457 (
"Unlock locked state.");
1459 T::AddEvent(
"SET_AUTORESUME",
"B:1")
1461 (
"Enable/disable auto resume" 1462 "|resume[bool]:if enabled, drive is tracking and goes to error state, the last tracking command is repeated automatically.");
1465 T::AddEvent(
"SET_VERBOSE",
"B:1")
1467 (
"Set verbosity state" 1468 "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
1473 (
"disconnect from ethernet");
1477 (
"(Re)connect Ethernet connection to cosy, a new address can be given" 1478 "|[host][string]:new ethernet address in the form <host:port>");
1481 T::AddEvent(
"PRINT")
1483 (
"Print source list.");
1485 T::AddEvent(
"RELOAD_SOURCES")
1487 (
"Reload sources from database after database has changed..");
1489 fDrive.StartConnect();
1494 fDrive.SetEndpoint(url);
1499 const auto it = fSources.find(name);
1500 if (it!=fSources.end())
1501 T::Warn(
"Source '"+name+
"' already in list... overwriting.");
1503 fSources[name] = src;
1504 return it==fSources.
end();
1512 T::Message(
"Connected to '"+db.
uri()+
"'");
1514 const mysqlpp::StoreQueryResult res =
1515 db.query(
"SELECT fSourceName, fRightAscension, fDeclination, fWobbleOffset, fWobbleAngle0, fWobbleAngle1 FROM Source").store();
1518 for (vector<mysqlpp::Row>::const_iterator v=res.begin(); v<res.end(); v++)
1520 const string name = (*v)[0].c_str();
1526 src.angle[0] = (*v)[4];
1527 src.angle[1] = (*v)[5];
1528 AddSource(name, src);
1534 msg <<
" " << name << setprecision(8) <<
": Ra=" << src.
ra <<
"h Dec=" << src.
dec <<
"deg";
1535 msg <<
" Wobble=[" << src.
offset <<
"," << src.angle[0] <<
"," << src.angle[1] <<
"]";
1539 T::Warn(
"MySQL support not compiled into the program.");
1548 fDrive.SetVerbose(!conf.
Get<
bool>(
"quiet"));
1550 const vector<string> &vec = conf.
Vec<
string>(
"source");
1552 for (vector<string>::const_iterator it=vec.begin(); it!=vec.end(); it++)
1554 istringstream stream(*it);
1563 while (getline(stream, buffer,
','))
1565 istringstream is(buffer);
1569 case 0: name =
buffer;
break;
1572 case 3: is >> src.
offset;
break;
1573 case 4: is >> src.angle[0];
break;
1574 case 5: is >> src.angle[1];
break;
1583 AddSource(name, src);
1587 T::Warn(
"Resource 'source' not correctly formatted: '"+*it+
"'");
1590 fDrive.SetDeviationCondition(conf.
Get<uint16_t>(
"deviation-limit"),
1591 conf.
Get<uint16_t>(
"deviation-count"),
1592 conf.
Get<uint16_t>(
"deviation-max"));
1594 fAutoResume = conf.
Get<
bool>(
"auto-resume");
1596 if (conf.
Has(
"source-database"))
1598 fDatabase = conf.
Get<
string>(
"source-database");
1605 msg <<
"Next sun-rise will be at " << fSunRise;
1611 SetEndpoint(conf.
Get<
string>(
"addr"));
1622 template<
class T,
class S,
class R>
1625 return Main::execute<T, StateMachineDrive<S, R>>(conf);
1630 const string def =
"localhost:7404";
1632 po::options_description control(
"Drive control options");
1633 control.add_options()
1634 (
"no-dim,d",
po_switch(),
"Disable dim services")
1635 (
"addr,a", var<string>(def),
"Network address of cosy")
1636 (
"quiet,q",
po_bool(
true),
"Disable printing contents of all received messages (except dynamic data) in clear text.")
1637 (
"source-database", var<string>(),
"Database link as in\n\tuser:password@server[:port]/database.")
1638 (
"source", vars<string>(),
"Additional source entry in the form \"name,hh:mm:ss,dd:mm:ss\"")
1639 (
"deviation-limit", var<uint16_t>(90),
"Deviation limit in arcsec to get 'OnTrack'")
1640 (
"deviation-count", var<uint16_t>(3),
"Minimum number of reported deviation below deviation-limit to get 'OnTrack'")
1641 (
"deviation-max", var<uint16_t>(180),
"Maximum deviation in arcsec allowed to keep status 'OnTrack'")
1642 (
"auto-resume",
po_bool(
false),
"Enable auto result during tracking if connection is lost")
1660 "The cosyctrl is an interface to cosy.\n" 1662 "The default is that the program is started without user intercation. " 1663 "All actions are supposed to arrive as DimCommands. Using the -c " 1664 "option, a local shell can be initialized. With h or help a short " 1665 "help message about the usuage can be brought to the screen.\n" 1667 "Usage: cosyctrl [-c type] [OPTIONS]\n" 1668 " or: cosyctrl [OPTIONS]\n";
1674 Main::PrintHelp<StateMachineDrive<StateMachine,ConnectionDrive>>();
1694 int main(
int argc,
const char* argv[])
1707 if (!conf.
Has(
"console"))
1709 if (conf.
Get<
bool>(
"no-dim"))
1710 return RunShell<LocalStream, StateMachine, ConnectionDrive>(conf);
1712 return RunShell<LocalStream, StateMachineDim, ConnectionDimDrive>(conf);
1715 if (conf.
Get<
bool>(
"no-dim"))
1717 if (conf.
Get<
int>(
"console")==0)
1718 return RunShell<LocalShell, StateMachine, ConnectionDrive>(conf);
1720 return RunShell<LocalConsole, StateMachine, ConnectionDrive>(conf);
1724 if (conf.
Get<
int>(
"console")==0)
1725 return RunShell<LocalShell, StateMachineDim, ConnectionDimDrive>(conf);
1727 return RunShell<LocalConsole, StateMachineDim, ConnectionDimDrive>(conf);
boost::asio::deadline_timer fKeepAlive
const uint16_t ConnectionkMaxAddr
int TrackOn(const EventImp &evt)
vector< double > fDevBuffer
int EvalOptions(Configuration &conf)
virtual void UpdateStarguider(const Time &, const DimStarguider &)
int main(int argc, const char *argv[])
A general base-class describing events issues in a state machine.
DimDescribedService fDimPointing
void UpdateTracking(const Time &t, const array< double, 8 > &arr)
static const uint16_t kMaxAddr
void SetDeviationCondition(uint16_t limit, uint16_t counter, uint16_t max)
void HandleReceivedReport(const boost::system::error_code &err, size_t bytes_received)
void SetupConfiguration(Configuration &conf)
void setQuality(int quality)
The base implementation of a distributed messaging system.
Adds some functionality to boost::posix_time::ptime for our needs.
void SetPrintUsage(const std::function< void(void)> &func)
T Get(const std::string &var)
bool ProcessDriveReport(const string &line)
Time GetNextSunRise(double horizon) const
ConnectionDrive(ba::io_service &ioservice, MessageImp &imp)
int SendCoordinates(const EventImp &evt, const Coordinates type)
void SetupConfiguration(Configuration &conf)
po::typed_value< bool > * po_switch()
int StartTrackWobble(const char *ptr, size_t size, const double &offset=0, const double &angle=0)
int Reconnect(const EventImp &evt)
DimDescribedService fDimTPoint
std::vector< T > Vec(const std::string &var)
int TakeTPoint(const EventImp &evt)
std::string GetString() const
static double ReadAngle(istream &in)
void UpdatePointing(const Time &t, const array< double, 2 > &arr)
map< string, Source > sources
uint16_t GetUShort() const
static Time ReadTime(istream &in)
void HandleKeepAlive(const bs::error_code &error)
void UpdateTPoint(const Time &t, const DimTPoint &data, const string &name)
bool SendCommand(const std::string &command)
bool ProcessTpointReport(const string &line)
void ReadDatabase(bool print=true)
bool Has(const std::string &var)
DimDescribedService fDimTracking
uint64_t fTrackingCounter
int SetLedBrightness(const EventImp &evt)
void AddOptions(const po::options_description &opt, bool visible=true)
void setData(const void *ptr, size_t sz)
int TrackWobble(const EventImp &evt)
string AngleToStr(double angle)
virtual void UpdateSource(const string &="", bool=false)
double GetDevAbs(double nomzd, double meszd, double devaz)
bool AddSource(const string &name, const Source &src)
int SetAutoResume(const EventImp &evt)
virtual void UpdateTracking(const Time &, const array< double, 8 > &)
map< uint16_t, int > fCounter
Commandline parsing, resource file parsing and database access.
virtual void UpdateSource(const array< double, 6 > &, const string &="")
virtual void UpdateStatus(const Time &, const array< uint8_t, 3 > &)
int StartWobble(const double &srcra, const double &srcdec, const double &woboff, const double &wobang, const string name="")
int RunShell(Configuration &conf)
DimDescribedService fDimStatus
ConnectionDimDrive(ba::io_service &ioservice, MessageImp &imp)
int SetVerbosity(const EventImp &evt)
int SendCommand(const string &str)
void ProcessDriveStatus(const string &line)
void ConnectionEstablished()
DimDescribedService fDimSource
Error states should be between 0x100 and 0xffff.
Return to feeserver c CVS log Up to[MAIN] dcscvs FeeServer feeserver src Wed FeeServer_v0 v0 dev
void UpdateSource(const string &name="", bool tracking=false)
void SetEndpoint(const string &url)
Connection(boost::asio::io_service &io_service, std::ostream &out)
po::typed_value< bool > * po_bool(bool def=false)
int Wobble(const EventImp &evt)
int Track(const EventImp &evt)
virtual void UpdatePointing(const Time &, const array< double, 2 > &)
T Get(size_t offset=0) const
bool CheckEventSize(size_t has, const char *name, size_t size)
bool DoParse(int argc, const char **argv, const std::function< void()> &func=std::function< void()>())
void UpdateStatus(const Time &t, const array< uint8_t, 3 > &arr)
int TrackCelest(const string &cmd, const string &source)
const T * Ptr(size_t offset=0) const
const sources::const_iterator GetSourceFromDB(const char *ptr, const char *last)
void UpdateSource(const array< double, 6 > &arr, const string &name="")
StateMachineDrive(ostream &out=cout)
virtual void UpdateTPoint(const Time &, const DimTPoint &, const string &)
uint16_t fDeviationCounter
bool ProcessStargReport(const string &line)
virtual size_t GetSize() const