14#include "../../libMagAOX/libMagAOX.hpp"
15#include "../../magaox_git_version.h"
155 mx::improc::eigenImage<int16_t>
421 config.add(
"camera.ocamDescrambleFile",
423 "camera.ocamDescrambleFile",
426 "ocamDescrambleFile",
429 "The path of the OCAM descramble file, relative to MagAOX/config." );
433 config.add(
"framegrabber.syncShmimName",
435 "framegrabber.syncShmimName",
441 "The name of the 1x1 uint8 ImageStreamIO sync stream used only for frame metadata and semaphores. "
442 "Defaults to framegrabber.shmimName + \"_sync\"." );
519 {
__FILE__,
__LINE__,
"error opening existing sync ImageStreamIO stream" } );
525 {
__FILE__,
__LINE__,
"error destroying existing sync ImageStreamIO stream" } );
676 std::string response;
745 if( !
lock.owns_lock() )
905 std::string response;
934 std::cerr <<
"Temp. parse error. Response:\n" << response << std::endl;
1002 std::string response;
1006 std::string
comStr =
"temp ";
1040 std::cerr <<
"response: " << response <<
"\n";
1057 std::string response;
1064 return log<
text_log, -1>( {
"attempt to set temperature outside valid range: " +
tempStr },
1079 std::cerr <<
"response: " << response <<
"\n";
1084 std::cerr <<
"temp " <<
tempStr <<
" response: " << response <<
"\n";
1094 std::string response;
1109 std::cerr <<
"fps parse error. Response:\n" << response <<
"\n";
1135 std::string response;
1149 std::cerr <<
"fps " <<
fpsStr <<
" response: " << response <<
"\n";
1160 std::cerr <<
"setting: " <<
fpsStr <<
"\n";
1162 pcf::IndiProperty
ipFreq( pcf::IndiProperty::Number );
1166 ipFreq.add( pcf::IndiElement(
"target" ) );
1178 std::string response;
1184 std::string
fpsStr = std::to_string( 0 );
1188 std::cerr <<
"fps " <<
fpsStr <<
" response: " << response <<
"\n";
1207 std::cerr <<
"synchro " <<
sStr <<
" resonse: " << response <<
"\n";
1253 ss += std::to_string(
m_fps ) +
"_";
1272 std::string response;
1285 std::cerr <<
"\n******************************************\n";
1286 std::cerr <<
"protection reset:\n";
1287 std::cerr << response <<
"\n";
1288 std::cerr <<
"\n******************************************\n";
1305 std::string response;
1324 if( response.find(
"HV" ) != std::string::npos )
1331 std::cerr <<
"EM Gain parse error, response:\n" << response <<
"\n";
1344 std::string response;
1360 log<text_log>(
"Attempt to set EM gain to " + std::to_string(
emg ) +
" outside limits refused",
1365 std::string
emgStr = std::to_string(
emg );
1378 std::cerr <<
"gain " <<
emgStr <<
" response: " <<
emgStr <<
"\n";
1393 std::string response;
1417 std::cerr <<
"digital binning!\n";
1510 std::cerr <<
"and digital binning!\n";
1526 return log<
software_error, -1>( {
"Error preparing sync ImageStreamIO stream" } );
1674 return log<
software_error, -1>( {
"Sync ImageStreamIO stream unavailable during publication" } );
1704 if( !
ipRecv.find(
"request" ) )
1737 if( !
ipRecv.find(
"current" ) )
The base-class for XWCTk applications.
void updateIfChanged(pcf::IndiProperty &p, const std::string &el, const T &newVal, pcf::IndiProperty::PropertyStateType ipState=pcf::IndiProperty::Ok)
Update an INDI property element value if it has changed.
int createStandardIndiRequestSw(pcf::IndiProperty &prop, const std::string &name, const std::string &label="", const std::string &group="")
Create a standard R/W INDI switch with a single request element.
stateCodes::stateCodeT state()
Get the current state code.
int registerIndiPropertyNew(pcf::IndiProperty &prop, int(*)(void *, const pcf::IndiProperty &))
Register an INDI property which is exposed for others to request a New Property for.
int powerState()
Returns the current power state.
int m_powerState
Current power state, 1=On, 0=Off, -1=Unk.
int powerStateTarget()
Returns the target power state.
void updateSwitchIfChanged(pcf::IndiProperty &p, const std::string &el, const pcf::IndiElement::SwitchStateType &newVal, pcf::IndiProperty::PropertyStateType ipState=pcf::IndiProperty::Ok)
Update an INDI switch element value if it has changed.
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
std::string m_configDir
The path to configuration files for MagAOX.
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.
int sendNewProperty(const pcf::IndiProperty &ipSend, const std::string &el, const T &newVal)
Send a newProperty command to another device (using the INDI Client interface)
MagAO-X Uniblitz DSS Shutter interface.
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
int appShutdown()
applogic shutdown
int open()
Open the shutter.
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
MagAO-X EDT framegrabber interface.
u_char * m_image_p
The image data grabbed.
int m_raw_height
The height of the frame, according to the framegrabber.
int pdvSerialWriteRead(std::string &response, const std::string &command, bool logErrors=true)
Send a serial command over cameralink and retrieve the response.
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
int appShutdown()
Application the shutdown.
timespec m_currImageTimestamp
The timestamp of the current image.
uint32_t m_width
The width of the image, once deinterlaced etc.
int appShutdown()
Shuts down the framegrabber thread.
int recordFGTimings(bool force=false)
int loadConfig(mx::app::appConfigurator &config)
load the configuration system results
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.
int setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
MagAO-X standard camera interface.
float m_maxEMGain
The configurable maximum EM gain. To be enforced in derivedT.
float m_fpsSet
The commanded fps, as set by user.
bool m_synchroSet
Target status of m_synchro.
std::string m_tempControlStatusStr
Camera specific description of temperature control status.
float m_emGain
The camera's current EM gain (if available).
float m_emGainSet
The camera's EM gain, as set by the user.
std::string m_nextMode
The mode to be set by the next reconfiguration.
int recordCamera(bool force=false)
pcf::IndiProperty m_indiP_synchro
float m_ccdTempSetpt
The desired temperature, in C.
bool m_tempControlStatus
Whether or not temperature control is active.
int setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
std::string m_modeName
The current mode name.
float m_startupTemp
The temperature to set after a power-on. Set to <= -999 to not use [default].
int loadConfig(mx::app::appConfigurator &config)
load the configuration system results
bool m_synchro
Status of synchronization, true is on, false is off.
float m_ccdTemp
The current temperature, in C.
bool m_tempControlOnTarget
Whether or not the temperature control system is on its target temperature.
cameraConfigMap m_cameraModes
Map holding the possible camera mode configurations.
int appShutdown()
Application shutdown.
float m_fps
The current FPS.
bool m_tempControlStatusSet
Desired state of temperature control.
static constexpr bool c_stdCamera_fps
app::dev config to tell stdCamera not to expose FPS status (ignored since fpsCtrl==true)
pcf::IndiProperty m_indiP_temps
INDI property publishing the latest camera temperatures.
static constexpr bool c_stdCamera_usesModes
app:dev config to tell stdCamera not to expose mode controls
float m_syncFreq
Current externally supplied sync frequency in Hz.
bool m_poweredOn
Tracks that power-on defaults still need to restore the configured temperature setpoint.
int resetEMProtection()
Reset the EM Protection.
bool m_protectionReset
Flag indicating that protection has been reset at least once.
int setShutter(int sh)
Sets the shutter state, via call to dssShutter::setShutterState(int) [stdCamera interface].
mx::improc::eigenImage< int16_t > m_digitalBinWork
Scratch image holding the full descrambled frame before digital binning.
std::string stateString()
Return the current stdCamera state string.
virtual int appLogic()
Implementation of the FSM for the OCAM 2K.
int recordTelem(const ocam_temps *)
int frameGrabberPostPublish(IMAGE *imageStream)
Publish the sync-only stream immediately after the main framegrabber publication.
static constexpr bool c_stdCamera_usesStateString
app::dev confg to tell stdCamera to expose the state string property
bool m_digitalBin
Indicates whether post-descramble digital binning is active for the current mode.
static constexpr bool c_stdCamera_exptimeCtrl
app::dev config to tell stdCamera not to expose exposure time controls
static constexpr uint32_t c_syncStreamHeight
Height of the sync-only ImageStreamIO stream.
int setNextROI()
Required by stdCamera, but this does not do anything for this camera [stdCamera interface].
virtual void setupConfig()
Setup the configuration system (called by MagAOXApp::setup())
pcf::IndiProperty m_indiP_emProtReset
INDI property handling operator requests to reset EM protection.
static constexpr uint32_t c_syncStreamDepth
Depth of the sync-only ImageStreamIO stream.
static constexpr bool c_stdCamera_fanSpeed
app::dev config to tell stdCamera not to expose fan-speed control
~ocam2KCtrl() noexcept
Destructor.
int ensureSyncStream()
Ensure the sync-only ImageStreamIO stream exists with the expected 1x1 uint8 layout.
virtual int onPowerOff()
Implementation of the on-power-off FSM logic.
std::string m_ocamDescrambleFile
ocamTemps m_temps
Structure holding the last temperature measurement.
static constexpr bool c_edtCamera_relativeConfigPath
app::dev config to tell edtCamera to use relative path to camera config file
bool stateStringValid()
Report whether the current stdCamera state string is valid for persistence and telemetry.
int powerOnDefaults()
Set defaults for a power on state.
int setSynchro()
Set the synchro state. [stdCamera interface].
virtual int appShutdown()
Do any needed shutdown tasks.
static constexpr bool c_stdCamera_synchro
app::dev config to tell stdCamera to expose synchro mode controls
int getEMGain()
Get the current EM Gain.
unsigned m_protectionResetConfirmed
virtual void loadConfig()
load the configuration system results (called by MagAOXApp::setup())
int setExpTime()
Required by stdCamera, but this does not do anything for this camera [stdCamera interface].
float fps()
Implementation of the frameGrabber fps interface.
int loadImageIntoStream(void *dest)
Implementation of the framegrabber loadImageIntoStream interface.
static constexpr uint32_t c_syncStreamWidth
Width of the sync-only ImageStreamIO stream.
static constexpr uint8_t c_syncStreamDataType
Data type of the sync-only stream.
int setTempControl()
Turn temperature control on or off.
std::string m_syncDevice
INDI device providing the external sync frequency when synchro mode is enabled.
pcf::IndiProperty m_indiP_emProt
INDI property publishing the EM protection state.
int reconfig()
Implementation of the framegrabber reconfig interface.
static constexpr bool c_stdCamera_emGain
app::dev config to tell stdCamera to expose EM gain controls
long m_currImageNumber
The current image number, retrieved from the raw image itself.
int setTempSetPt()
Set the CCD temperature setpoint [stdCamera interface].
static constexpr bool c_stdCamera_vShiftSpeed
app:dev config to tell stdCamera not to expose vertical shift speed control
std::string m_syncFreqProp
INDI property name reporting the external sync frequency.
int startAcquisition()
Implementation of the framegrabber startAcquisition interface.
static constexpr bool c_stdCamera_tempControl
app::dev config to tell stdCamera to expose temperature controls
int setEMGain()
Set the EM gain.
int setFPS()
Set the frame rate. [stdCamera interface].
static constexpr bool c_stdCamera_temp
app::dev config to tell stdCamera to expose temperature (ignored since tempControl==true)
unsigned m_digitalBinY
Digital y-binning factor applied after descrambling.
unsigned m_digitalBinX
Digital x-binning factor applied after descrambling.
static constexpr bool c_stdCamera_usesROI
app:dev config to tell stdCamera to expose ROI controls
int recordTemps(bool force=false)
int getFPS()
Get the current frame rate.
int configureAcquisition()
Implementation of the framegrabber configureAcquisition interface.
double m_protectionResetReqTime
The time at which protection reset was requested. You have 10 seconds to confirm.
std::recursive_mutex m_cameraMutex
Protects EDT PDV access and OCAM SDK lifetime across reconfigure, grab, and control paths.
ocam2KCtrl()
Default c'tor.
int acquireAndCheckValid()
Implementation of the framegrabber acquireAndCheckValid interface.
static constexpr bool c_stdCamera_fpsCtrl
app::dev config to tell stdCamera to expose FPS controls
static constexpr bool c_stdCamera_cropMode
app:dev config to tell stdCamera to expose Crop Mode controls
static constexpr bool c_frameGrabber_flippable
app:dev config to tell framegrabber these images can not be flipped
static constexpr bool c_stdCamera_readoutSpeed
app::dev config to tell stdCamera not to expose readout speed controls
ocam2_id m_ocam2_id
OCAM SDK id.
virtual int whilePowerOff()
Implementation of the while-powered-off FSM.
std::string m_syncShmimName
long m_lastImageNumber
The last image number saved from the previous acquisition loop.
int getTemps()
Get the current device temperatures.
IMAGE * m_syncImageStream
virtual int appStartup()
Startup functions.
static constexpr bool c_stdCamera_hasShutter
app:dev config to tell stdCamera to expose shutter controls
pcf::IndiProperty m_indiP_syncFreq
INDI subscription to the external sync-frequency source.
int destroySyncStream()
Destroy the sync-only ImageStreamIO stream owned by this app.
Shared EDT SDK stub declarations for MagAO-X test builds.
#define INDI_NEWCALLBACK_DEFN(class, prop)
Define the callback for a new property request.
#define REG_INDI_NEWPROP_NOCB(prop, propName, type)
Register a NEW INDI property with the class, with no callback.
#define INDI_NEWCALLBACK(prop)
Get the name of the static callback wrapper for a new property.
#define INDI_SETCALLBACK_DECL(class, prop)
Declare the callback for a set property request, and declare and define the static wrapper.
#define INDI_SETCALLBACK_DEFN(class, prop)
Define the callback for a set property request.
#define REG_INDI_SETPROP(prop, devName, propName)
Register a SET INDI property with the class, using the standard callback name.
#define INDI_NEWCALLBACK_DECL(class, prop)
Declare the callback for a new property request, and declare and define the static wrapper.
int parseFPS(float &fps, const std::string &fstr)
Parse the FPS response.
int parseTemps(ocamTemps &temps, const std::string &tstr)
Parse the OCAM temp query and fill the ocamTemps structure.
int parseEMGain(unsigned &emGain, const std::string &fstr)
Parse the EM gain response.
#define INDI_VALIDATE_CALLBACK_PROPS(prop1, prop2)
Standard check for matching INDI properties in a callback.
const pcf::IndiProperty & ipRecv
std::unique_lock< std::mutex > lock(m_indiMutex)
static constexpr logPrioT LOG_NOTICE
A normal but significant condition.
static constexpr logPrioT LOG_WARNING
A condition has occurred which may become an error, but the process continues.
static constexpr logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
MagAOX::app::MagAOXApp< true > MagAOXAppT
ocam2_rc ocam2_init(ocam2_mode mode, const char *descrbFile, ocam2_id *id)
Create a camera instance with the provided mode.
void ocam2_descramble(ocam2_id id, unsigned int *number, short *image, const short *imageRaw)
Create a camera instance with the provided mode.
const char * ocam2_modeStr(ocam2_mode mode)
Return a description text for camera mode.
ocam2_rc ocam2_exit(ocam2_id id)
Clear a camera instance.
ocam2_mode ocam2_getMode(ocam2_id id)
Return the camera mode.
The purpose of the libocam2sdk library is to provide an easy way to achieve ocam2 specific opération....
int ocam2_id
Library camera identifier.
ocam2_rc
Enum of ocam2 library return code.
enum workMode ocam2_mode
typedef of ocam2 camera mode
#define OCAM2_IMAGE_NB_OFFSET
Utilities for the OCAM camera.
A device base class which saves telemetry.
int appShutdown()
Perform telemeter application shutdown.
int loadConfig(appConfigurator &config)
Load the device section from an application configurator.
int setupConfig(appConfigurator &config)
Setup an application configurator for the device section.
Structure to hold the OCAM camera temperature readings returned by the device.
float WATER
Cooling water temperature.
int setInvalid()
Set all values to the invalid value, -999.
float COOLING_POWER
the cooling power in 100 mw.
float BIAS
Bias temperature.
float SET
The CCD set temeperature.
float CCD
The detector temperature.
float POWER
Power supply temperature.
float CPU
The CPU temperature.
float LEFT
The left amplifier temperature.
float RIGHT
The right amplifier temperature.
@ OPERATING
The device is operating, other than homing.
@ 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.
Log entry recording the build-time git state.
Software CRITICAL log entry.
Log entry recording framegrabber timings.
Log entry recording stdcam stage specific status.
A simple text log, a string-type log.