13 #include <ImageStreamIO/ImageStreamIO.h>
15 #include <mx/math/func/gaussian.hpp>
16 #include <mx/math/randomT.hpp>
18 #include "../../libMagAOX/libMagAOX.hpp"
19 #include "../../magaox_git_version.h"
276 config.add(
"camsim.fullW",
284 "Full (maximum) width of the simulated detector" );
286 config.add(
"camsim.fullH",
294 "Full (maximum) height of the simulated detector" );
296 config.add(
"camsim.defaultFPS",
304 "the camera default FPS, set at startup. Default is 10" );
306 config.add(
"camsim.bias",
314 "the simulated bias level. default 500." );
316 config.add(
"camsim.ron",
324 "the simulated readout noise, in counts/read. default 5." );
326 config.add(
"camsim.xcen",
334 "the simulated star x center coordinate, relative to image center. one per star. default 0." );
336 config.add(
"camsim.ycen",
344 "the simulated star y center coordinate, relative to image center. one per star. default 0." );
346 config.add(
"camsim.peak",
354 "the simulated star peak, in counts/second. one per star. default 2000." );
356 config.add(
"camsim.fwhm",
364 "the simulated star FWHM in pixels. the same for all stars. default 2." );
366 config.add(
"camsim.jitter",
374 "the simulated jitter, in pixels/read. the same for all stars. default 0.1." );
404 cfg(
m_fps,
"camsim.defaultFPS" );
407 config(
m_bias,
"camsim.bias" );
408 config(
m_ron,
"camsim.ron" );
410 config(
m_xcen,
"camsim.xcen" );
411 config(
m_ycen,
"camsim.ycen" );
412 config(
m_peak,
"camsim.peak" );
416 log<software_error>( { __FILE__, __LINE__,
"cameraSim: xcen, ycen, and peak must be the same size." } );
419 config(
m_fwhm,
"camsim.fwhm" );
421 config(
m_jitter,
"camsim.jitter" );
502 if( !
lock.owns_lock() )
507 log<software_error>( { __FILE__, __LINE__ } );
559 log<software_error>( { __FILE__, __LINE__,
"invalid ROI specifications" } );
580 double et = mx::sys::get_curr_time() -
m_lastTime;
593 for( uint32_t cc = 0; cc <
m_height; ++cc )
595 float y = ( cc - 0.5 * ( 1.0 *
m_height - 1.0 ) ) +
598 for( uint32_t rr = 0; rr <
m_width; ++rr )
600 float x = ( rr - 0.5 * ( 1.0 *
m_width - 1.0 ) ) +
607 for(
size_t s = 0; s <
m_xcen.size(); ++s )
614 float flux = mx::math::func::gaussian2D<float>(
616 flux +=
m_norm * sqrt( flux );
696 log<text_log>(
"Set exposure time: " + std::to_string(
m_expTimeSet ) +
" sec" );
711 log<text_log>(
"Set frame rate: " + std::to_string(
m_fps ) +
" fps" );
769 return "stateString";
#define IMAGESTRUCT_UINT16
The base-class for MagAO-X 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 m_shutdown
Flag to signal it's time to shutdown. When not 0, the main loop exits.
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::mutex m_indiMutex
Mutex for locking INDI communications.
static constexpr bool c_stdCamera_usesStateString
app::dev confg to tell stdCamera to expose the state string property
int setFPS()
Set the framerate.
static constexpr bool c_stdCamera_fps
app::dev config to tell stdCamera not to expose FPS status (ignored since fpsCtrl=true)
dev::stdCamera< cameraSim > stdCameraT
std::vector< float > m_xcen
static constexpr bool c_stdCamera_usesROI
app:dev config to tell stdCamera to expose ROI controls
std::string stateString()
static constexpr bool c_stdCamera_fpsCtrl
app::dev config to tell stdCamera to expose FPS controls
int powerOnDefaults()
Set defaults for a power on state.
virtual void loadConfig()
load the configuration system results (called by MagAOXApp::setup())
static constexpr bool c_stdCamera_exptimeCtrl
app::dev config to tell stdCamera to expose exposure time controls
int configureAcquisition()
float m_jitter
the simulated jitter, in pixels/read. the same for all stars. default 0.1.
static constexpr bool c_stdCamera_hasShutter
app:dev config to tell stdCamera to expose shutter controls
mx::improc::eigenImage< int16_t > m_fgimage
int recordTelem(const telem_stdcam *)
dev::telemeter< cameraSim > telemeterT
float m_ron
the simulated readout noise, in counts/read. default 5.
virtual int loadConfigImpl(mx::app::appConfigurator &cfg)
load the configuration system results (called by MagAOXApp::setup())
std::vector< float > m_peak
the simulated star peak, in counts/second. one per star. default 2000.
static constexpr bool c_stdCamera_readoutSpeed
app::dev config to tell stdCamera not to expose readout speed controls
int setNextROI()
Set the next ROI.
static constexpr bool c_stdCamera_synchro
app::dev config to tell stdCamera to not expose synchro mode controls
~cameraSim() noexcept
Destructor.
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 not to expose vertical shift speed control
std::vector< float > m_ycen
cameraSim()
Default c'tor.
static constexpr bool c_stdCamera_cropMode
app:dev config to tell stdCamera not to expose Crop Mode controls
static constexpr bool c_stdCamera_tempControl
app::dev config to tell stdCamera to not expose temperature controls
static constexpr bool c_stdCamera_temp
app::dev config to tell stdCamera to expose temperature
mx::math::normDistT< float > m_norm
static constexpr bool c_frameGrabber_flippable
app:dev config to tell framegrabber that this camera can be flipped
int setExpTime()
Set the Exposure Time. [stdCamera interface].
float m_fwhm
the simulated star FWHM in pixels. the same for all stars. default 2.
int loadImageIntoStream(void *dest)
static constexpr bool c_stdCamera_emGain
app::dev config to tell stdCamera to not expose EM gain controls
int acquireAndCheckValid()
virtual int appLogic()
Implementation of the FSM for the Siglent SDG.
dev::frameGrabber< cameraSim > frameGrabberT
int checkNextROI()
Check the next ROI.
virtual void setupConfig()
Setup the configuration system (called by MagAOXApp::setup())
static constexpr bool c_stdCamera_usesModes
app:dev config to tell stdCamera not to expose mode controls
float m_bias
the simulated bias level. default 500.
virtual int appStartup()
Startup functions.
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.
void * loadImageIntoStreamCopy(void *dest, void *src, size_t width, size_t height, size_t szof)
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.
IMAGE * m_imageStream
The ImageStreamIO shared memory buffer.
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.
bool m_synchroSet
Target status of m_synchro.
pcf::IndiProperty m_indiP_roi_y
Property used to set the ROI x center coordinate.
float m_default_x
Power-on ROI center x coordinate.
float m_emGain
The camera's current EM gain (if available).
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()
bool m_cropModeSet
Desired status of crop mode ROIs, if enabled for this camera.
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)
bool m_cropMode
Status of crop mode ROIs, if enabled for this camera.
int m_default_h
Power-on ROI height.
pcf::IndiProperty m_indiP_roi_last
Property used to trigger setting the last ROI.
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.
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int m_full_h
The full ROI height.
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.
pcf::IndiProperty m_indiP_roi_w
Property used to set the ROI width.
pcf::IndiProperty m_indiP_roi_default
Property used to trigger setting the default and startup ROI.
pcf::IndiProperty m_indiP_roi_bin_x
Property used to set the ROI x binning.
float m_full_x
The full ROI center x coordinate.
std::string m_shutterStatus
bool m_synchro
Status of synchronization, true is on, false is off.
std::string m_vShiftSpeedName
The current vshift speed name.
float m_ccdTemp
The current temperature, in C.
int updateINDI()
Update the INDI properties for this device controller.
std::vector< std::string > m_vShiftSpeedNames
std::string m_defaultVShiftSpeed
The default readout speed of the camera.
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
std::vector< std::string > m_vShiftSpeedNameLabels
pcf::IndiProperty m_indiP_roi_full
Property used to trigger setting the full ROI.
pcf::IndiProperty m_indiP_roi_set
Property used to trigger setting the ROI.
int appShutdown()
Application shutdown.
float m_default_y
Power-on ROI center y coordinate.
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.
int m_default_bin_y
Power-on ROI y binning.
bool m_tempControlStatusSet
Desired state of temperature control.
std::string m_readoutSpeedNameSet
The user requested readout speed name, to be set by derived()
#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.
@ 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.
@ NOTCONNECTED
The application is not connected to the device or service.
void nanoSleep(unsigned long nsec)
std::unique_lock< std::mutex > lock(m_indiMutex)
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.
Software CRITICAL log entry.
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.