Class TargetInfo

Nested Relationships

Nested Types

Class Documentation

class TargetInfo

target information class contains info for a single target row and how to read it

Public Types

enum TargetState

TargetState enums are the possible return values from the TargetInfo::TargetState get_next() function

Values:

enumerator TARGET_ERROR

error getting target from database

enumerator TARGET_NOT_FOUND

no active targets found with requested state

enumerator TARGET_FOUND

target found

Public Functions

template<typename T>
inline T extract_column_from_row(const std::string &field, mysqlx::Row row, T defaultvalue = T{})

gets named column value of the correct type from a mysqlx Row

Parameters:
  • field[in] database column name

  • row[in] mysqlx Row read from database

  • defaultvalue[in] optional arg to set value in case it’s null

template<typename T>
inline void column_from_json(const std::string &colname, const std::string &jkey, const nlohmann::json &jmessage)

assigns value from json telemetry message to a database column

This will extract the value for the named jkey from the JSON message and assign it to external_telemetry map using colname as the map key, where colname is expected to be a database column name. When a non-null value is successfully found then set the .valid flag true, which will enable writing the value to the database. When valid is false then the column will not be written to the database, which is the sign of a bad value.

Parameters:
  • colname[in] database field name to assign value

  • jkey[in] key to find value from jmessage

  • jmessage[in] json message from telemetry provider

inline bool is_db_configured()
mysqlx::col_count_t colnum(std::string field, std::vector<std::string> vec)

get column number of requested field from specified vector list

TargetInfo::TargetState get_specified_target(std::string args, std::string &retstring)
TargetInfo::TargetState get_next()

get the next target from the database with state=Sequencer::TARGET_PENDING

TargetInfo::TargetState get_next(std::string &status)

get the next target from the database with state=Sequencer::TARGET_PENDING

TargetInfo::TargetState get_next(std::string state_in, std::string &status)

get the next target from the database with state=state_in

long parse_target_from_row(const mysqlx::Row &row)

fills target class using cols from DB row

long target_qc_check(std::string &status)

target info quality control check

long add_row(int number_in, std::string name_in, std::string ra_hms_in, std::string dec_dms_in, double slita_in, double slitw_in, double exptime_in, std::string pointmode_in)

add a row to the database

long update_state(std::string newstate)

update the target status in the database DB_ACTIVE table

long insert_completed()

insert target record into completed observations table

long get_table_names()

utility to print all database table names

void init_record()

initialize current target record variables

long configure_db(std::string param, std::string value)

configure the database connection parameters (host, user, etc.)

long targetset(std::string args, std::string &retstring)

set or get the target set to read from the targets table

Public Members

std::unique_ptr<Database::Database> database
SkyInfo::FPOffsets fpoffsets

for calling Python fpoffsets, defined in ~/Software/common/skyinfo.h

std::map<std::string, ColumnData> external_telemetry
const double RA_MIN = 0

get the private db_configured state

minimum target right ascension

const double RA_MAX = 24

maximum target right ascension

const double DEC_MIN = -90

minimum target declination

const double DEC_MAX = 90

maximum target declination

const double SLIT_MIN = 0

minimum slit width

const double SLIT_MAX = 10

maximum slit width

const long EXPTIME_MIN = 0

minimum value for exptime

const long EXPTIME_MAX = 1 << 24

maximum value for exptime

std::vector<std::string> targetlist_cols

target list fields, used for accessing the target table, which accepts a variadic param

std::vector<std::string> targetset_cols

target set fields, used for accessing the table of target sets

mysqlx::string owner

target table owner

int obsid

current target observation ID (DB internal, used for record-checking)

int setid

ID of the set to get from the targets table.

mysqlx::string setname

set name associated with setid

int obsorder

observation order (DB internal)

long targetnum

??

long sequencenum

??

bool iscal

is this a calibration target?

std::string imgtype

image type. camerad will use this to fill IMGTYPE keyword

mysqlx::string name

name of astronomical target or calibration

mysqlx::string fitsfile

file with the spectrum images

mysqlx::string ra_hms

current target right ascension in units hh:mm:ss

mysqlx::string dec_dms

current target declination in units dd:mm:ss

mysqlx::string tel_ra

current target right ascension in units hh:mm:ss

mysqlx::string tel_dec

current target declination in units dd:mm:ss

double offset_ra
double offset_dec
double tel_alt

telescope alt (deg) at exposure start

double tel_az

telescope az (deg) at exposure start

double airmass

airmass at exposure start

double casangle

current target cass angle

double slitangle_req

slit angle requested

mysqlx::string pointmode

pointing mode contains slit|acam with optional space-delimited filter

mysqlx::string notbefore

earliest date/time to start exposure

mysqlx::string slewstart

slew start date/time

mysqlx::string slewend

slew end date/time

double exptime_act

exposure time in seconds for this target comes from camerad telemetry

double exptime_req

exposure time request

mysqlx::string expstart

exposure start date/time

mysqlx::string expend

exposure end date/time

double slitwidth

slit width for this target

double slitwidth_req

slit width request

double slitoffset

slit offset for this target

double slitoffset_req

slit offset for this target

int binspect

binning in spectral direction for this target

int binspat

binning in spatial direction for this target

int nexp

number of exposures to perform for this target

double airmasslimit

individual target airmass limit, above which we don’t observe

mysqlx::string obsmode

observation mode contains CCD settings TBD

mysqlx::string note

observer notes, read just so that it can be written back to the DB completed table (!)

mysqlx::string otmflag

OTM flag, read just so that it can be written back to the DB completed table (!)

mysqlx::string state

current target state

double slitangle

current slit angle

double offset_threshold

computed offset below this threshold (in arcsec) defines successful acquisition

double max_tcs_offset

max allowable TCS offset

int min_repeat

minimum number of sequentiall successful acquires

std::atomic<bool> acquired

true on successful acquisition and while guiding

struct ColumnData

Public Members

bool valid
mysqlx::Value value