13#include <ImageStreamIO/ImageStreamIO.h>
15#include <picam_advanced.h>
17#include "../../libMagAOX/libMagAOX.hpp"
18#include "../../magaox_git_version.h"
23 #define BREADCRUMB std::cerr << __FILE__ << " " << __LINE__ << "\n";
31 Picam_GetEnumerationString( type, value, &
string );
32 std::string str(
string );
33 Picam_DestroyString(
string );
43int readoutParams( piint &adcQual, piflt &adcSpeed,
const std::string &rosn )
45 if( rosn ==
"ccd_00_1MHz" )
47 adcQual = PicamAdcQuality_LowNoise;
50 else if( rosn ==
"ccd_01MHz" )
52 adcQual = PicamAdcQuality_LowNoise;
55 else if( rosn ==
"emccd_05MHz" )
57 adcQual = PicamAdcQuality_ElectronMultiplied;
60 else if( rosn ==
"emccd_10MHz" )
62 adcQual = PicamAdcQuality_ElectronMultiplied;
65 else if( rosn ==
"emccd_20MHz" )
67 adcQual = PicamAdcQuality_ElectronMultiplied;
70 else if( rosn ==
"emccd_30MHz" )
72 adcQual = PicamAdcQuality_ElectronMultiplied;
89 else if( vsn ==
"1_2us" )
93 else if( vsn ==
"2_0us" )
97 else if( vsn ==
"5_0us" )
389 m_readoutSpeedNames = {
"ccd_00_1MHz",
"ccd_01MHz",
"emccd_05MHz",
"emccd_10MHz",
"emccd_20MHz",
"emccd_30MHz" };
391 "CCD 0.1 MHz",
"CCD 1 MHz",
"EMCCD 5 MHz",
"EMCCD 10 MHz",
"EMCCD 20 MHz",
"EMCCD 30 MHz" };
433 std::cerr <<
"Turning synchro on for " <<
m_otherCamName << std::endl;
437 std::cerr <<
"Setting " <<
m_otherCamName <<
"'s exposure time" << std::endl;
443 std::cerr <<
"Turning synchro off for " <<
m_otherCamName << std::endl;
457 config.add(
"camera.serialNumber",
459 "camera.serialNumber",
465 "The identifying serial number of the camera." );
467 config.add(
"synchro.deviceName",
469 "synchro.deviceName",
475 "The fxngen device name used for synchronizing the camera." );
476 config.add(
"synchro.channel",
484 "The fxngen channel used for synchronizing the camera." );
485 config.add(
"synchro.otherCamName",
487 "synchro.otherCamName",
493 "The other camera (used for coupling exposure time while synchro'd)" );
522 indi::addNumberElement<float>(
523 m_indiP_readouttime,
"value", 0.0, std::numeric_limits<float>::max(), 0.0,
"%0.1f",
"readout time" );
686 if( !
lock.owns_lock() )
863 return log<
text_log, -1>(
"Parameter not committed" );
903 return log<
text_log, -1>(
"Parameter not committed" );
943 return log<
text_log, -1>(
"Parameter not committed" );
1057 std::cerr <<
"found " <<
id_count <<
" PI cameras.\n";
1108 "Fan control enabled in config, but DisableCoolingFan is not supported "
1109 "by this camera." } );
1151 "cooling-fan status parameter unavailable; using commanded state without hardware readback",
1482 std::cerr <<
"Setting fxngen frequency to " << std::to_string(
m_fps ) <<
" Hz" << std::endl;
1553 log<text_log>(
"Got exposure time " + std::to_string( exptime ) +
" ms but min value is " +
1970 std::cerr <<
rois->roi_array[0].x <<
"\n";
1971 std::cerr << (
rois->roi_array[0].x - 1 ) <<
"\n";
1972 std::cerr <<
rois->roi_array[0].width <<
"\n";
1973 std::cerr << 0.5 * ( (
float)(
rois->roi_array[0].width - 1.0 ) ) <<
"\n";
1977 m_currentROI.x = ( 1023.0 -
rois->roi_array[0].x ) - 0.5 * ( (
float)(
rois->roi_array[0].width - 1.0 ) );
1982 m_currentROI.x = (
rois->roi_array[0].x ) + 0.5 * ( (
float)(
rois->roi_array[0].width - 1.0 ) );
1987 m_currentROI.y = ( 1023.0 -
rois->roi_array[0].y ) - 0.5 * ( (
float)(
rois->roi_array[0].height - 1.0 ) );
1992 m_currentROI.y = (
rois->roi_array[0].y ) + 0.5 * ( (
float)(
rois->roi_array[0].height - 1.0 ) );
2072 std::cerr <<
"Setting exposure time to " <<
m_expTimeSet <<
"\n";
2115 std::cerr <<
"could not get AdcQuality\n";
2118 std::cerr <<
"AdcQuality is: " <<
adcqStr <<
"\n";
2123 std::cerr <<
"could not get VerticalShiftRate\n";
2130 std::cerr <<
"could not get AdcSpeed\n";
2132 std::cerr <<
"AdcSpeed is: " <<
AdcSpeed <<
"\n";
2134 std::cerr <<
"************************************************************\n";
2139 std::cerr <<
"could not get AdcAnalogGain\n";
2142 std::cerr <<
"AdcAnalogGain is: " <<
adcgStr <<
"\n";
2153 std::cerr <<
"could not get AdcEMGain\n";
2191 std::cerr <<
"Clearing\n";
2198 std::cerr <<
"m_acqBuff.memory_size: " <<
m_acqBuff.memory_size <<
"\n";
2217 std::cerr <<
"Turning synchro on" << std::endl;
2225 std::cerr <<
"Turning synchro off" << std::endl;
2436 if( !
ipRecv.find(
"toggle" ) )
2471 if( !
ipRecv.find(
"target" ) )
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.
stateCodes::stateCodeT state()
Get the current state code.
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.
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.
int createROIndiNumber(pcf::IndiProperty &prop, const std::string &propName, const std::string &propLabel="", const std::string &propGroup="")
Create a ReadOnly INDI Number property.
int registerIndiPropertyReadOnly(pcf::IndiProperty &prop)
Register an INDI property which is read only.
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
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int m_xbinning
The x-binning according to the framegrabber.
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 loadConfig(mx::app::appConfigurator &config)
load the configuration system results
int m_ybinning
The y-binning according to the framegrabber.
size_t m_typeSize
The size of the type, in bytes. Result of sizeof.
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.
std::vector< std::string > m_readoutSpeedNames
float m_minExpTime
The minimum exposure time, used for INDI attributes.
bool m_synchroSet
Target status of m_synchro.
pcf::IndiProperty m_indiP_roi_y
Property used to set the ROI x center coordinate.
std::string m_tempControlStatusStr
Camera specific description of temperature control status.
float m_emGain
The camera's current EM gain (if available).
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.
float m_emGainSet
The camera's EM gain, as set by the user.
std::string m_vShiftSpeedNameSet
The user requested vshift speed name, to be set by derived()
std::string m_defaultReadoutSpeed
The default readout speed of the camera.
float m_expTime
The current exposure time, in seconds.
int recordCamera(bool force=false)
float m_maxExpTime
The maximum exposure time, used for INDI attributes.
float m_expTimeSet
The exposure time, in seconds, as set by user.
pcf::IndiProperty m_indiP_roi_h
Property used to set the ROI height.
std::string m_fanSpeedNameSet
Requested fan-control option name.
int m_full_h
The full ROI height.
pcf::IndiProperty m_indiP_synchro
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.
bool checkFocusSwitchState()
Evaluate the configured focus-state switch helper as an in-focus boolean.
float m_ccdTempSetpt
The desired temperature, in C.
bool m_tempControlStatus
Whether or not temperature control is active.
pcf::IndiProperty m_indiP_fps
int setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
pcf::IndiProperty m_indiP_roi_w
Property used to set the ROI width.
pcf::IndiProperty m_indiP_roi_bin_x
Property used to set the ROI x binning.
std::string m_fanSpeedName
Current fan-control option name.
float m_full_x
The full ROI center x coordinate.
int loadConfig(mx::app::appConfigurator &config)
load the configuration system results
pcf::IndiProperty m_indiP_exptime
bool m_synchro
Status of synchronization, true is on, false is off.
std::string m_vShiftSpeedName
The current vshift speed name.
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.
std::vector< std::string > m_vShiftSpeedNames
int sendGotoFocusCommand()
Format and send the configured goto-focus switch command.
std::string m_defaultVShiftSpeed
The default readout speed of the camera.
pcf::IndiProperty m_indiP_tempcont
bool m_tempControlOnTarget
Whether or not the temperature control system is on its target temperature.
float m_stepExpTime
The maximum exposure time stepsize, used for INDI attributes.
std::vector< std::string > m_vShiftSpeedNameLabels
pcf::IndiProperty m_indiP_roi_set
Property used to trigger setting the ROI.
std::vector< std::string > m_fanSpeedNameLabels
Optional GUI labels for the fan-control options.
float m_fps
The current FPS.
pcf::IndiProperty m_indiP_roi_bin_y
Property used to set the ROI y binning.
pcf::IndiProperty m_indiP_roi_x
Property used to set the ROI x center coordinate.
bool m_tempControlStatusSet
Desired state of temperature control.
std::string m_readoutSpeedNameSet
The user requested readout speed name, to be set by derived()
bool m_fanStatusSupported
True when the camera exposes readable cooling-fan status.
int recordTelem(const telem_stdcam *)
int loadImageIntoStream(void *dest)
static constexpr bool c_stdCamera_usesROI
app:dev config to tell stdCamera to expose ROI controls
virtual void loadConfig()
load the configuration system results (called by MagAOXApp::setup())
pcf::IndiProperty m_indiP_otherCamSynchro
Property for setting otherCam synchro.
std::string m_cameraModel
std::string m_serialNumber
The camera's identifying serial number.
static constexpr bool c_stdCamera_exptimeCtrl
app::dev config to tell stdCamera to expose exposure time controls
static constexpr bool c_stdCamera_synchro
app::dev config to tell stdCamera to not expose synchro mode controls
bool m_fanControlSupported
True when the camera exposes the DisableCoolingFan control parameter.
int setShutter(int sh)
Sets the shutter state, via call to dssShutter::setShutterState(int) [stdCamera interface].
virtual int appShutdown()
Do any needed shutdown tasks. Currently nothing in this app.
static constexpr bool c_stdCamera_vShiftSpeed
app:dev config to tell stdCamera to expose vertical shift speed control
virtual void setupConfig()
Setup the configuration system (called by MagAOXApp::setup())
int checkNextROI()
Check the next ROI.
PicamHandle m_cameraHandle
pcf::IndiProperty m_indiP_receiveSynchro
Synchro that can only be triggered from the otherCam.
static constexpr bool c_stdCamera_fpsCtrl
app::dev config to tell stdCamera not to expose FPS controls
bool m_fanForcedOn
True while the camera reports the cooling fan is forced on for protection.
static constexpr bool c_stdCamera_fanSpeed
app::dev config to tell stdCamera to expose fan-speed control
static constexpr bool c_stdCamera_cropMode
app:dev config to tell stdCamera to expose Crop Mode controls
std::string m_otherCamName
PicamHandle m_modelHandle
static constexpr bool c_stdCamera_hasShutter
app:dev config to tell stdCamera to expose shutter controls
pcf::IndiProperty m_indiP_otherCamExptime
Property for setting otherCam exptime.
int acquireAndCheckValid()
static constexpr bool c_stdCamera_tempControl
app::dev config to tell stdCamera to expose temperature controls
static constexpr bool c_stdCamera_hasFocus
app:dev config to tell stdCamera to expose focus-state reporting and goto-focus control
bool checkFocus()
Reports whether the camera is currently in focus. [stdCamera interface].
static constexpr bool c_stdCamera_temp
app::dev config to tell stdCamera to expose temperature
~picamCtrl() noexcept
Destructor.
static constexpr bool c_stdCamera_emGain
app::dev config to tell stdCamera to expose EM gain controls
int setSynchro()
Interface to setSynchro when the derivedT has synchronization.
pcf::IndiProperty m_indiP_readouttime
bool m_fanSpeedLogPending
True when the next successful fan apply should emit a notice even without a state change.
int gotoFocus()
Requests the configured focus preset. [stdCamera interface].
virtual int whilePowerOff()
Implementation of the while-powered-off FSM.
pcf::IndiProperty m_indiP_fxngensync_freq
Property for setting fxngensync frequency.
int setFanSpeed()
Request a cooling-fan state change through the next reconfiguration.
int getPicamParameter(piint &value, PicamParameter parameter)
picamCtrl()
Default c'tor.
int setPicamParameter(PicamParameter parameter, pi64s value, bool commit=true)
static constexpr bool c_stdCamera_readoutSpeed
app::dev config to tell stdCamera to expose readout speed controls
virtual int onPowerOff()
Implementation of the on-power-off FSM logic.
piflt m_ReadOutTimeCalculation
static constexpr bool c_stdCamera_usesModes
app:dev config to tell stdCamera not to expose mode controls
pcf::IndiProperty m_indiP_receiveExptime
Exptime that can only be triggered from the otherCam.
static constexpr bool c_stdCamera_usesStateString
app::dev confg to tell stdCamera to expose the state string property
int setPicamParameterOnline(PicamHandle handle, PicamParameter parameter, piflt value)
std::string m_fxngenCh
Default fxngen channel.
int getAcquisitionState()
static constexpr bool c_frameGrabber_flippable
app:dev config to tell framegrabber this camera can be flipped
double m_camera_timestamp
PicamAvailableData m_available
static constexpr bool c_stdCamera_fps
app::dev config to tell stdCamera not to expose FPS status
virtual int appStartup()
Startup functions.
int configureAcquisition()
virtual int appLogic()
Implementation of the FSM for the Siglent SDG.
piflt m_FrameRateCalculation
pcf::IndiProperty m_indiP_fxngensync_output
Proprety for turning on fxngensync.
int getFanSpeed()
Get the current cooling-fan state from the camera.
PicamAcquisitionBuffer m_acqBuff
int capExpTime(piflt &exptime)
std::string m_fxngenName
Default fxngen device name.
#define INDI_NEWCALLBACK_DEFN(class, prop)
Define the callback for a new property request.
#define CREATE_REG_INDI_NEW_TOGGLESWITCH(prop, name)
Create and register a NEW INDI property as a standard toggle switch, using the standard callback name...
#define CREATE_REG_INDI_NEW_NUMBERD(prop, name, min, max, step, format, label, group)
Create and register a NEW INDI property as a standard number as double, using the standard callback n...
#define INDI_NEWCALLBACK_DECL(class, prop)
Declare the callback for a new property request, and declare and define the static wrapper.
#define INDI_VALIDATE_CALLBACK_PROPS(prop1, prop2)
Standard check for matching INDI properties in a callback.
const pcf::IndiProperty & ipRecv
int readoutParams(int &newa, int &newhss, const std::string &ron)
int vshiftParams(int &newvs, const std::string &vssn, float &vs)
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.
static constexpr logPrioT LOG_ALERT
This should only be used if some action is required by operators to keep the system safe.
std::string PicamEnum2String(PicamEnumeratedType type, piint value)
A device base class which saves telemetry.
int loadConfig(appConfigurator &config)
Load the device section from an application configurator.
int setupConfig(appConfigurator &config)
Setup an application configurator for the device section.
@ OPERATING
The device is operating, other than homing.
@ NODEVICE
No device exists for the application to control.
@ 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.
Software CRITICAL log entry.
Log entry recording stdcam stage specific status.
A simple text log, a string-type log.