16#include "../../libMagAOX/libMagAOX.hpp"
17#include "../../magaox_git_version.h"
28#ifndef PL_ERR_LIBRARY_NOT_INITIALIZED
29 #define PL_ERR_LIBRARY_NOT_INITIALIZED ( 157 )
38 const std::string &more
41 char pvmsg[ERROR_MSG_LEN];
42 pl_error_message( pec, pvmsg );
44 std::string msg = func +
" failed: " + pvmsg;
52#define log_pvcam_software_error( func, \
56 int pec = pl_error_code(); \
57 log<software_error>( { __FILE__, __LINE__, 0, pec, pvcamErrMessage( func, pec, more ) } ); \
226 mx::app::appConfigurator &
_config );
401 config.add(
"camera.serialNumber",
403 "camera.serialNumber",
409 "The identifying serial number of the camera." );
412 config.add(
"camera.circBuffMaxBytes",
414 "camera.circBuffMaxBytes",
420 "Maximum size in bytes of the circular buffer to allocate. Default is 0.5 GB." );
426 config.add(
"framegrabber.acqSleep",
428 "framegrabber.acqSleep",
434 "The acquisition pause time, in ns, when no frame is ready. Default is 5000." );
832 static_cast<void *
>(
this ) ) !=
true )
1018 {
__FILE__,
__LINE__,
"could not restore configured fan speed after acquisition setup" } );
1304 std::cerr <<
"Found " <<
nports <<
" ports\n";
1321 std::cerr <<
"failed to allocate string\n";
1337 std::cerr <<
"Port: " << p <<
" name: " <<
text <<
" value: " << value <<
"\n";
1353 std::cerr <<
" Speeds: " <<
nspeeds <<
"\n";
1395 std::cerr <<
" Speed: " <<
s <<
" " <<
" pixtime: " <<
pixtime <<
" gains: " <<
ngains <<
" [" <<
ming
1396 <<
"-" <<
maxg <<
"]\n";
1419 std::cerr <<
" Gain: " <<
g <<
" bitdepth: " <<
bitdepth <<
"\n";
1442 std::cerr <<
paramMnem <<
": count 0\n";
1475 std::cerr <<
"dumpEnum: not CONNECTED\n";
1567 {
__FILE__,
__LINE__,
"PARAM_FAN_SPEED_SETPOINT not available while fan control is enabled" } );
1599 {
__FILE__,
__LINE__,
"unknown PVCAM fan-speed value: " + std::to_string( fanSpeed ) } );
1640 mx::sys::timespecAddNsec(
ts, 1
e9 );
The base-class for XWCTk applications.
stateCodes::stateCodeT state()
Get the current state code.
int powerState()
Returns the current power state.
int m_shutdown
Flag to signal it's time to shutdown. When not 0, the main loop exits.
int powerStateTarget()
Returns the target power state.
int stateLogged()
Updates and returns the value of m_stateLogged. Will be 0 on first call after a state change,...
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
bool powerOnWaitElapsed()
This method tests whether the power on wait time has elapsed.
unsigned long m_powerOnWait
Default time in sec to wait for device to boot after power on.
std::mutex m_indiMutex
Mutex for locking INDI communications.
MagAO-X Uniblitz DSS Shutter interface.
int appStartup()
Startup function.
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
int appLogic()
application logic
int appShutdown()
applogic shutdown
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int setShutterState(int sh)
Change shutter state.
timespec m_currImageTimestamp
The timestamp of the current image.
uint32_t m_width
The width of the image, once deinterlaced etc.
int recordFGTimings(bool force=false)
uint8_t m_dataType
The ImageStreamIO type code.
bool m_reconfig
Flag to set if a camera reconfiguration requires a framegrabber reset.
uint32_t m_height
The height of the image, once deinterlaced etc.
MagAO-X standard camera interface.
std::vector< std::string > m_readoutSpeedNames
float m_fpsSet
The commanded fps, as set by user.
float m_default_x
Power-on ROI center x coordinate.
std::string m_tempControlStatusStr
Camera specific description of temperature control status.
std::vector< std::string > m_fanSpeedNames
Valid fan-control option names for the INDI selection switch.
std::vector< std::string > m_readoutSpeedNameLabels
int m_full_w
The full ROI width.
std::string m_defaultReadoutSpeed
The default readout speed of the camera.
float m_expTime
The current exposure time, in seconds.
int m_default_bin_x
Power-on ROI x binning.
int m_default_w
Power-on ROI width.
int recordCamera(bool force=false)
int m_default_h
Power-on ROI height.
float m_expTimeSet
The exposure time, in seconds, as set by user.
std::string m_fanSpeedNameSet
Requested fan-control option name.
int m_full_h
The full ROI height.
bool m_fanSpeedControlEnabled
Whether or not fan-speed control is published through INDI.
float m_full_y
The full ROI center y coordinate.
std::string m_readoutSpeedName
The current readout speed name.
float m_ccdTempSetpt
The desired temperature, in C.
bool m_tempControlStatus
Whether or not temperature control is active.
std::string m_fanSpeedName
Current fan-control option name.
float m_full_x
The full ROI center x coordinate.
std::string m_defaultFanSpeed
The default fan speed to apply after power on.
float m_ccdTemp
The current temperature, in C.
bool m_fanSpeedValid
True once the current fan-control state is known.
bool m_tempControlOnTarget
Whether or not the temperature control system is on its target temperature.
std::vector< std::string > m_fanSpeedNameLabels
Optional GUI labels for the fan-control options.
float m_default_y
Power-on ROI center y coordinate.
float m_fps
The current FPS.
int m_default_bin_y
Power-on ROI y binning.
std::string m_readoutSpeedNameSet
The user requested readout speed name, to be set by derived()
The MagAO-X pvcam controller.
int setNextROI()
Queue the requested ROI for the next acquisition setup.
static constexpr bool c_stdCamera_exptimeCtrl
app::dev config to tell stdCamera to expose exposure time controls
int16 m_handle
Camera handle, set when camera is opened.
static constexpr bool c_stdCamera_usesROI
app:dev config to tell stdCamera to expose ROI controls
uint32_t m_acqSleep
The acquisition pause time, in ns, when no frame is ready.Default is 5000.
static constexpr bool c_stdCamera_emGain
app::dev config to tell stdCamera not to expose EM gain controls
int setTempControl()
PVCAM does not expose a separate temperature-control toggle.
static constexpr bool c_stdCamera_usesStateString
app::dev confg to tell stdCamera to expose the state string property
static constexpr bool c_stdCamera_fps
app::dev config to tell stdCamera to expose FPS status
int connect()
Find and open the configured PVCAM camera.
friend class pvcamCtrl_test
void endOfFrameCallback(FRAME_INFO *finfo)
Process a PVCAM end-of-frame callback.
virtual void loadConfig()
static constexpr bool c_stdCamera_tempControl
app::dev config to tell stdCamera not to expose temperature controls
int setFPS()
PVCAM does not expose FPS as a direct settable control in this app.
int recordTelem(const telem_stdcam *)
float fps()
Return the current measured frame rate.
int setExpTime()
Queue the requested exposure time for the next acquisition setup.
static void st_endOfFrameCallback(FRAME_INFO *finfo, void *pvcamCtrlInst)
Static trampoline for the PVCAM end-of-frame callback.
int setShutter(int sh)
Sets the shutter state, via call to dssShutter::setShutterState(int) [stdCamera interface].
static constexpr bool c_stdCamera_usesModes
app:dev config to tell stdCamera not to expose mode controls
std::vector< port > m_ports
virtual int appShutdown()
Shutdown the app.
bool m_fpsSetted
Flag indicating that FPS was set, not exposure time.
uint32_t m_circBuffMaxBytes
Max size in bytes of the circular buffer to allocate. Default is 0.5 GB.
int checkNextROI()
Check the next ROI.
int setReadoutSpeed()
Queue the requested readout-speed selection for the next acquisition setup.
int setFanSpeed()
Set the fan speed according to the configured stdCamera target.
std::vector< speed > speeds
static constexpr bool c_stdCamera_hasShutter
app:dev config to tell stdCamera to expose shutter controls
int acquireAndCheckValid()
Wait for the next frame-ready signal and validate the acquisition state.
static constexpr bool c_stdCamera_fpsCtrl
app::dev config to tell stdCamera to expose FPS controls
int configureAcquisition()
Configure the PVCAM acquisition state for the pending settings.
dev::stdCamera< pvcamCtrl > stdCameraT
dev::frameGrabber< pvcamCtrl > frameGrabberT
static constexpr bool c_stdCamera_temp
app::dev config to tell stdCamera not to expose temperature
int startAcquisition()
Start continuous PVCAM acquisition.
static constexpr bool c_stdCamera_fanSpeed
app::dev config to tell stdCamera to expose fan-speed control
pvcamCtrl()
Default c'tor.
virtual int appLogic()
Implementation of the FSM for pvcamCtrl.
sem_t m_frSemaphore
Semaphore used to signal that a frame is ready.
sem_t m_frDoneSemaphore
Semaphore used to signal that a frame has been processed.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
int powerOnDefaults()
Set defaults for a power-on state.
~pvcamCtrl() noexcept
D'tor, declared and defined for noexcept.
std::string m_camName
Camera name, filled in as part of opening the camera.
virtual int appStartup()
Startup function.
int loadImageIntoStream(void *dest)
Copy the latest PVCAM frame into the destination image stream.
dev::dssShutter< pvcamCtrl > shutterT
int setEMGain()
PVCAM does not expose EM gain through this app.
static constexpr bool c_stdCamera_readoutSpeed
app::dev config to tell stdCamera to expose readout speed controls
int fillSpeedTable()
Enumerate the PVCAM readout-speed table for the connected camera.
int reconfig()
Stop acquisition so the framegrabber can reconfigure.
void dumpEnum(uns32 paramID, const std::string ¶mMnem)
Dump the values of a PVCAM enumerated parameter for debugging.
int setTempSetPt()
PVCAM does not expose a writable detector temperature setpoint in this app.
static constexpr bool c_stdCamera_synchro
app::dev config to tell stdCamera to not expose synchro mode controls
dev::telemeter< pvcamCtrl > telemeterT
std::vector< gain > gains
int getFanSpeed()
Get the current fan speed from the camera.
static constexpr bool c_stdCamera_cropMode
app:dev config to tell stdCamera to expose Crop Mode controls
float m_tempTol
Tolerance in degrees C to declare the temperature control locked.
int setVShiftSpeed()
PVCAM does not expose vertical-shift control through this app.
std::string m_serialNumber
The camera serial number.
virtual void setupConfig()
static constexpr bool c_stdCamera_vShiftSpeed
app:dev config to tell stdCamera not to expose vertical shift speed control
int getTemp()
Get the current detector temperature and set point from the camera.
static constexpr bool c_frameGrabber_flippable
app:dev config to tell framegrabber this camera can not be flipped
#define FRAMEGRABBER_SETUP_CONFIG(cfig)
Call frameGrabberT::setupConfig with error checking for frameGrabber.
#define FRAMEGRABBER_APP_LOGIC
Call frameGrabberT::appLogic with error checking for frameGrabber.
#define FRAMEGRABBER_APP_SHUTDOWN
Call frameGrabberT::appShutdown with error checking for frameGrabber.
#define FRAMEGRABBER_UPDATE_INDI
Call frameGrabberT::updateINDI with error checking for frameGrabber.
#define FRAMEGRABBER_LOAD_CONFIG(cfig)
Call frameGrabberT::loadConfig with error checking for frameGrabber.
#define FRAMEGRABBER_APP_STARTUP
Call frameGrabberT::appStartup with error checking for frameGrabber.
std::unique_lock< std::mutex > lock(m_indiMutex)
static constexpr logPrioT LOG_NOTICE
A normal but significant condition.
static constexpr logPrioT LOG_INFO
Informational. The info log level is the lowest level recorded during normal operations.
static constexpr logPrioT LOG_CRITICAL
The process can not continue and will shut down (fatal)
#define PL_ERR_LIBRARY_NOT_INITIALIZED
std::string pvcamErrMessage(const std::string &func, int pec, const std::string &more)
Format an error message using pvcam facilities.
#define log_pvcam_software_error(func, more)
Helper for logging an error from pvcam.
#define STDCAMERA_SETUP_CONFIG(cfig)
Call stdCameraT::setupConfig with error checking for stdCamera.
#define STDCAMERA_APP_LOGIC
Call stdCameraT::appLogic with error checking for stdCamera.
#define STDCAMERA_APP_STARTUP
Call stdCameraT::appStartup with error checking for stdCamera.
#define STDCAMERA_LOAD_CONFIG(cfig)
Call stdCameraT::loadConfig with error checking for stdCamera.
#define STDCAMERA_UPDATE_INDI
Call stdCameraT::updateINDI with error checking for stdCamera.
#define STDCAMERA_APP_SHUTDOWN
Call stdCameraT::appShutdown with error checking for stdCamera.
A device base class which saves telemetry.
int checkRecordTimes(const telT &tel, telTs... tels)
Check the time of the last record for each telemetry type and make an entry if needed.
@ OPERATING
The device is operating, other than homing.
@ NODEVICE
No device exists for the application to control.
@ FAILURE
The application has failed, should be used when m_shutdown is set for an error.
@ ERROR
The application has encountered an error, from which it is recovering (with or without intervention)
@ READY
The device is ready for operation, but is not operating.
@ CONNECTED
The application has connected to the device or service.
@ NOTCONNECTED
The application is not connected to the device or service.
@ POWERON
The device power is on.
Software CRITICAL log entry.
Log entry recording framegrabber timings.
Log entry recording stdcam stage specific status.
#define TELEMETER_APP_LOGIC
Call telemeter::appLogic with error checking.
#define TELEMETER_LOAD_CONFIG(cfig)
Call telemeter::loadConfig with error checking.
#define TELEMETER_APP_STARTUP
Call telemeter::appStartup with error checking.
#define TELEMETER_SETUP_CONFIG(cfig)
Call telemeter::setupConfig with error checking.
#define TELEMETER_APP_SHUTDOWN
Call telemeter::appShutdown with error checking.