Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Config/slicecamd.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,50 @@ FINE_ACQUIRE_GAIN_LARGE=1.0
#
FINE_ACQUIRE_GAIN_THRESHOLD=2.0

# FINE_ACQUIRE_EXPTIME_MIN / _MAX = <sec>
# Clamp range for auto-adjusted fine-acquisition exposure time.
#
FINE_ACQUIRE_EXPTIME_MIN=0.1
FINE_ACQUIRE_EXPTIME_MAX=15.0

# Exposure-compensation band (two-band model). FAINT/BRIGHT are the trip points
# that decide WHETHER to adjust; the _GOAL values are what the exposure is scaled
# toward once it does. Within [FAINT, BRIGHT] the source is adequately exposed and
# the exposure is left unchanged.
#
# REQUIRED ORDERING (enforced at config time -- slicecamd will refuse to start if
# violated): FAINT <= FAINT_GOAL <= BRIGHT and FAINT <= BRIGHT_GOAL <= BRIGHT,
# with FAINT, BRIGHT > 0. A goal left unset defaults to its own threshold. A goal
# outside its band edge would make the correction scale the WRONG way (e.g. a
# BRIGHT_GOAL above BRIGHT drives the source brighter and never re-enters the band).
#
# FINE_ACQUIRE_COUNTS_FAINT / _FAINT_GOAL = <counts>
# Below COUNTS_FAINT (top-10%-mean of background-subtracted pixels) the source is
# under-exposed: raise exposure toward COUNTS_FAINT_GOAL. Leave both unset to
# disable exposure compensation.
#
FINE_ACQUIRE_COUNTS_FAINT=250
FINE_ACQUIRE_COUNTS_FAINT_GOAL=1500

# FINE_ACQUIRE_SATURATION=<counts>
# Raw-peak ceiling. A source is treated as saturated at or above this value.
#
FINE_ACQUIRE_SATURATION=55000

# FINE_ACQUIRE_COUNTS_BRIGHT / _BRIGHT_GOAL = <counts>
# Above COUNTS_BRIGHT the source is over-exposed: lower exposure toward
# COUNTS_BRIGHT_GOAL. Between FAINT and BRIGHT the exposure is left unchanged
# (the source is adequately exposed).
#
FINE_ACQUIRE_COUNTS_BRIGHT=10000
FINE_ACQUIRE_COUNTS_BRIGHT_GOAL=2500

# FINE_ACQUIRE_AUTOEXPOSE_WINDOW=<n>
# Number of frames the pre-acquisition auto-exposure averages before each
# decision.
#
FINE_ACQUIRE_AUTOEXPOSE_WINDOW=2

# SkySimulator options:
# SKYSIM_IMAGE_SIZE=<is> where <is> is integer
# Sets the keyword argument "IMAGE_SIZE=<is>"
Expand Down
1 change: 1 addition & 0 deletions common/message_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ namespace Key {
namespace Slicecamd {
inline const std::string FINEACQUIRE_LOCKED = "fineacquire_locked";
inline const std::string FINEACQUIRE_RUNNING = "fineacquire_running";
inline const std::string AUTOEXPOSE_RUNNING = "autoexpose_running";
inline const std::string TANDOR_L = "tandor_L";
inline const std::string TANDOR_R = "tandor_R";
}
Expand Down
2 changes: 2 additions & 0 deletions common/slicecamd_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const std::string SLICECAMD_EXIT = "exit"; ///<
const std::string SLICECAMD_EXPTIME = "exptime"; ///< set/get camera exposure time
const std::string SLICECAMD_FAN = "fan"; ///< set Andor fan mode
const std::string SLICECAMD_FINEACQUIRE = "fineacquire"; ///< fine acquisition
const std::string SLICECAMD_AUTOEXPOSE = "autoexpose"; ///< auto-adjust fine-acquire exposure
const std::string SLICECAMD_GUISET = "guiset"; ///< set params for gui display
const std::string SLICECAMD_INIT = "init"; ///< ***
const std::string SLICECAMD_ISACQUIRED = "isacquired"; ///< is the target acquired?
Expand Down Expand Up @@ -55,6 +56,7 @@ const std::vector<std::string> SLICECAMD_SYNTAX = {
SLICECAMD_TCSISOPEN+" [ ? ]",
" CAMERA COMMANDS:",
SLICECAMD_FINEACQUIRE+" [ ? | status | stop | start { L | R } ]",
SLICECAMD_AUTOEXPOSE+" [ ? | on | off | status ]",
SLICECAMD_AVGFRAMES+" [ ? | <num> ]",
SLICECAMD_FRAMEGRAB+" [ ? | start | stop | one [ <filename> ] | status ]",
SLICECAMD_FRAMEGRABFIX+" [ ? ]",
Expand Down
15 changes: 13 additions & 2 deletions sequencerd/sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,19 @@ namespace Sequencer {
//
if ( !this->target.iscal ) {

// during acam acquisition, enable slicecam autoexpose to try to get the
// exposure time set before fine acquisition starts.
//
const bool dofine = this->should_fineacquire.load();
if ( dofine ) (void)this->do_slicecam_autoexpose( true );

// start ACAM acquisition. If it fails then wait for user to continue or cancel.
if ( this->do_acam_acquire() != NO_ERROR ) {
const long acq_error = this->do_acam_acquire();

// disable autoexpose no matter how ACAM finished
if ( dofine ) (void)this->do_slicecam_autoexpose( false );

if ( acq_error != NO_ERROR ) {
this->broadcast.warning( function, "acam acquisition failed" );
if (this->wait_for_user()==ABORT) {
this->broadcast.notice( function, "cancelled" );
Expand All @@ -759,7 +770,6 @@ namespace Sequencer {
else { // ACAM success...
// start SLICECAM fine acquisition if enabled
long ret=NO_ERROR;
bool dofine = this->should_fineacquire.load();
if ( dofine ) ret = this->do_slicecam_fineacquire();
if ( ret!=NO_ERROR ) this->broadcast.warning( function, "slicecam fine acquisition failed" );

Expand Down Expand Up @@ -847,6 +857,7 @@ namespace Sequencer {
this->request_snapshot();
lock.lock();
}
this->broadcast.notice( function, "done waiting for readout" );
}
this->wait_state_manager.clear( Sequencer::SEQ_WAIT_READOUT );

Expand Down
1 change: 1 addition & 0 deletions sequencerd/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ namespace Sequencer {
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
Expand Down
25 changes: 25 additions & 0 deletions sequencerd/sequence_acquisition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,29 @@ namespace Sequencer {
}
/***** Sequencer::Sequence::do_slicecam_stop *********************************/


/***** Sequencer::Sequence::do_slicecam_autoexpose **************************/
/**
* @brief enable/disable slicecam pre-acquisition auto-exposure
* @details Enabling autoexpose on slicecam before the fineacquire sequence
* to adjust exposure time before the fine acquisition sequence
* starts. A failure here never aborts the sequence.
* @param[in] enable true = turn auto-exposure on, false = turn it off
* @return NO_ERROR | ERROR
*
*/
long Sequence::do_slicecam_autoexpose( bool enable ) {
const std::string function("Sequencer::Sequence::do_slicecam_autoexpose");
const std::string arg = enable ? " on" : " off";

std::string reply;
if ( this->slicecamd.command( SLICECAMD_AUTOEXPOSE + arg, reply ) != NO_ERROR
|| reply.find("DONE") == std::string::npos ) {
this->broadcast.warning( function, "slicecam autoexpose"+arg+" not confirmed (reply=\""+reply+"\")" );
return ERROR;
}
return NO_ERROR;
}
/***** Sequencer::Sequence::do_slicecam_autoexpose **************************/

}
Loading
Loading