Class Sequence

Class Documentation

class Sequence

the Sequence class defines the “sequences”, i.e. functions of the sequencer

Public Functions

inline Sequence()
inline ~Sequence()
inline void ontarget()

sends ontarget signal, clears after 3 seconds

inline void reset_ontarget()
inline void usercontinue()

sends usercontinue signal, clears after 3 seconds

inline void reset_usercontinue()
inline void reset_cancel_flag()
inline long init_pubsub(const std::initializer_list<std::string> &topics = {})
inline void start_subscriber_thread()
inline void stop_subscriber_thread()
void handletopic_snapshot(const nlohmann::json &jmessage)
void handletopic_camerad(const nlohmann::json &jmessage)
void handletopic_acamd(const nlohmann::json &jmessage)
void handletopic_slicecamd(const nlohmann::json &jmessage)
void handletopic_slitd(const nlohmann::json &jmessage)
void handletopic_tcsd(const nlohmann::json &jmessage)
void publish_snapshot()
void request_snapshot()
void publish_seqstate()
void publish_waitstate()
void publish_daemonstate()
void publish_threadstate()
void broadcast_daemonstate()

void set_seqstate_bit( uint32_t mb ); ///< set the specified masked bit in the seqstate word

inline bool is_seqstate_set( uint32_t mb ) { return( mb & this->seqstate.load() ); } ///< is the masked bit set in seqstate? inline bool is_reqstate_set( uint32_t mb ) { return( mb & this->reqstate.load() ); } ///< is the masked bit set in reqstate?

void broadcast_threadstate()
void broadcast_seqstate()

publishes the seqstate on the seq_seqstate topic

void broadcast_waitstate()

publishes the waitstate on the seq_waitstate topic

uint32_t get_reqstate()

get the reqstate word

long startup()

nightly startup sequence

long shutdown()

nightly shutdown sequence

inline bool is_ready()

returns the ready_to_start state, set true only after nightly startup

long parse_calibration_target()
long parse_state(std::string whoami, std::string reply, bool &state)

parse true|false state from reply string

void dothread_test_fpoffset()

for testing, calls Python function from thread

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

enable|disable fineacquisition step

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

handles test commands

long extract_tcs_value(std::string reply, int &value)

extract value returned by the TCS via tcsd

long parse_tcs_generic(int value)

parse generic TCS reply

std::string seqstate_string(uint32_t state)

returns string form of states set in state word

long dotype(std::string args)

set do type (one/all)

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

set or get do type (one/all)

long poll_dome_position(double &domeazi, double &telazi)
long get_dome_position(double &domeazi, double &telazi)
long get_dome_position(bool poll, double &domeazi, double &telazi)
long poll_tcs_motion(std::string &state_out)
long get_tcs_motion(std::string &state_out)
long get_tcs_motion(bool poll, std::string &state_out)
long get_tcs_coords_type(std::string cmd, double &ra_h, double &dec_d)

read the current TCS ra,dec in decimal hr,deg

long get_tcs_weather_coords(double &ra_h, double &dec_d)

read the current TCS ra,dec in decimal hr,deg

long get_tcs_coords(double &ra_h, double &dec_d)

read the current TCS ra,dec,cass in decimal hr,deg

long get_tcs_cass(double &cass)
long target_offset()
void publish_targetinfo(bool force = false)

publish target info on change (or force)

long set_power_switch(PowerState state, const std::string which, std::chrono::seconds delay)
long check_power_switch(PowerState checkstate, const std::string which, bool &is_set)
long open_hardware(Common::DaemonClient &daemon)
long open_hardware(Common::DaemonClient &daemon, bool &was_opened)
long open_hardware(Common::DaemonClient &daemon, const std::string opencmd, const int opentimeout)
long open_hardware(Common::DaemonClient &daemon, const std::string opencmd, const int opentimeout, bool &was_opened)
long open_hardware(Common::DaemonClient &daemon, const std::string opencmd, const int opentimeout, bool &was_opened, bool forceopen)
long reopen_hardware(Common::DaemonClient &daemon, const std::string opencmd, const int opentimeout)
long connect_to_daemon(Common::DaemonClient &daemon)
long daemon_restart(Common::DaemonClient &daemon)
long trigger_exposure()

trigger and wait for exposure

long set_imgtype()

set IMGTYPE

void abort_process()

tries to abort everything

void stop_exposure()

stop exposure timer in progress

long repeat_exposure()

repeat the last exposure

void modify_exptime(double exptime_in)

modify exptime while exposure running

void dothread_test()
long wait_for_user()

wait for the user or cancel

void sequence_start(std::string obsid_in)

main sequence start thread. optional obsid_in for single target obs

long calib_set()

sets calib according to target entry params

long camera_set()

sets camera according to target entry params

long slit_set(VirtualSlitMode mode = VSM_DATABASE)

sets slit according to target entry params and mode

long move_to_target()

sends request to TCS to move to target coords

long focus_set()
long flexure_set()
long do_acam_acquire()

these are in sequence_acquisition.cpp

long do_acam_stop()
long do_slicecam_fineacquire()
long do_slicecam_stop()
long do_slicecam_autoexpose(bool enable)
long acam_init()

initializes connection to acamd

long calib_init()

initializes connection to calibd

long camera_init()

initializes connection to camerad

long flexure_init()

initializes connection to flexured

long focus_init()

initializes connection to focusd

long power_init()

initializes connection to powerd

long slicecam_init()

initializes connection to slicecamd

long slit_init()

initializes connection to slitd

long tcs_init()

initializes connection to tcsd

long acam_shutdown()

shutdown the acam

long calib_shutdown()

shutdown the calibrator

long camera_shutdown()

shutdown the camera

long flexure_shutdown()

shutdown flexure system

long focus_shutdown()

shutdown focusd

long power_shutdown()
long slicecam_shutdown()

shutdown the slicecam

long slit_shutdown()

shutdown slitd

long tcs_shutdown()

shutdown the TCS

Public Members

double acquisition_timeout

timeout for target acquisition (in sec) set by configuration parameter ACAM_ACQUIRE_TIMEOUT

int acquisition_max_retrys

max number of acquisition loop attempts

double tcs_offsetrate_ra

TCS offset rate RA (“MRATE”) in arcsec per second.

double tcs_offsetrate_dec

TCS offset rate DEC (“MRATE”) in arcsec per second.

double tcs_settle_timeout

timeout for telescope to settle (in sec) set by configuration parameter TCS_SETTLE_TIMEOUT

double tcs_settle_stable

time that TCS must report TRACKING before it is really tracking

double tcs_domeazi_ready

max degrees azimuth that dome and telescope can differ before ready to observe

double tcs_preauth_time

seconds before end of exposure to notify TCS of next target’s coords (0 to disable)

std::mutex fineacquire_mtx

std::mutex tcs_ontarget_mtx; std::condition_variable tcs_ontarget_cv;

std::condition_variable fineacquire_cv
std::mutex acam_mtx
std::condition_variable acam_cv
std::mutex camerad_mtx
std::condition_variable camerad_cv
std::mutex slitd_mtx
std::condition_variable slitd_cv
std::mutex tcsd_mtx
std::condition_variable tcsd_cv
std::mutex wait_mtx
std::condition_variable cv
std::mutex cv_mutex
std::mutex monitor_mtx
std::map<int, std::string> sequence_states
std::vector<int> sequence_state_bits
std::atomic<bool> do_once

set if “do one” selected, clear if “do all” selected

ImprovedStateManager<static_cast<size_t>(Sequencer::NUM_THREAD_STATES)> thread_error_manager = {Sequencer::thread_names}
ImprovedStateManager<static_cast<size_t>(Sequencer::NUM_SEQ_STATES)> seq_state_manager = {Sequencer::seq_state_names}
ImprovedStateManager<static_cast<size_t>(Sequencer::NUM_WAIT_STATES)> wait_state_manager = {Sequencer::wait_state_names}
ImprovedStateManager<static_cast<size_t>(Sequencer::NUM_THREAD_STATES)> thread_state_manager = {Sequencer::thread_names}
ImprovedStateManager<static_cast<size_t>(Sequencer::NUM_DAEMONS)> daemon_manager = {Sequencer::daemon_name}
TargetInfo target

TargetInfo object contains info for a target row and how to read it Sequencer::TargetInfo is defined in sequencer_interface.h

CalibrationTarget caltarget
std::string single_obsid

obsid for single-target GETONE command

std::string prev_single_obsid

the previous single_obsid, used for REPEAT

std::string last_target

Sequence::move_to_target remembers the last target name and coordinates.

mysqlx::string last_ra_hms
mysqlx::string last_dec_dms
std::string tcs_which

configured TCS

std::string tcs_name

name of TCS set on tcs initialization and shutdown

std::string test_solver_args

optional solver args that can be passed in with a test command

std::string daemon_control

daemon control script

Common::DaemonClient acamd = {"acamd"}
Common::DaemonClient calibd = {"calibd"}
Common::DaemonClient camerad = {"camerad"}
Common::DaemonClient filterd = {"filterd"}
Common::DaemonClient flexured = {"flexured"}
Common::DaemonClient focusd = {"focusd"}
Common::DaemonClient powerd = {"powerd"}
Common::DaemonClient slicecamd = {"slicecamd"}
Common::DaemonClient slitd = {"slitd"}
Common::DaemonClient tcsd = {"tcsd"}
std::map<std::string, class PowerSwitch> power_switch

STL map of PowerSwitch objects maps all plugnames to each subsystem.

float slitoffsetexpose

“virtual slit mode” offset for expose

float slitoffsetacquire

“virtual slit mode” offset for acquire

float slitwidthacquire

“virtual slit mode” width for acquire

std::unique_ptr<Common::PubSub> publisher

publisher object

std::string publisher_address

publish socket endpoint

std::string publisher_topic

my default topic for publishing

std::unique_ptr<Common::PubSub> subscriber

subscriber object

std::string subscriber_address

subscribe socket endpoint

std::vector<std::string> subscriber_topics

list of topics I subscribe to

std::atomic<bool> is_subscriber_thread_running

is my subscriber thread running?

std::atomic<bool> should_subscriber_thread_run

should my subscriber thread run?

std::unordered_map<std::string, std::function<void(const nlohmann::json&)>> topic_handlers

maps a handler function to each topic

std::unordered_map<std::string, std::string> config_init

init values from config file

std::unordered_map<std::string, std::string> config_shutdown

shutdown values from config file

std::vector<std::string> camera_prologue

commands sent to camera on init, read from cfg file

std::vector<std::string> camera_epilogue

commands sent to camera on shutdown, read from cfg file

Common::Broadcaster broadcast = {this->publisher, Sequencer::DAEMON_NAME}

logs and publishes a narrative message on Topic::BROADCAST

std::string last_seqstate_str

last seqstate string announced via broadcast_seqstate() (for change detection)

nlohmann::json last_published_targetinfo

last published targetinfo (for change detection)

std::mutex publish_targetinfo_mtx

guards last_published_targetinfo check-then-act

Public Static Functions

static void dothread_monitor_ready_state(Sequencer::Sequence &seq)
static void dothread_sequencer_async_listener(Sequencer::Sequence &seq, Network::UdpSocket udp)

UDP ASYNC message listening thread.

static void dothread_notify_tcs(Sequencer::Sequence &seq)

like move_to_target but for preauth only