14 #include <ImageStruct.h>
15 #include <ImageStreamIO.h>
23 #include "../../libMagAOX/libMagAOX.hpp"
24 #include "../../magaox_git_version.h"
33 unsigned char sVersion[80];
35 memset ((
char *)sVersion, 0x00,
sizeof(sVersion));
36 GetQHYCCDSDKVersion(&YMDS[0], &YMDS[1], &YMDS[2], &YMDS[3]);
38 if ((YMDS[1] < 10) && (YMDS[2] < 10)){
39 sprintf((
char *)sVersion,
"V20%d0%d0%d_%d\n", YMDS[0], YMDS[1], YMDS[2], YMDS[3]);
40 }
else if ((YMDS[1] < 10) && (YMDS[2] > 10)){
41 sprintf((
char *)sVersion,
"V20%d0%d%d_%d\n", YMDS[0], YMDS[1], YMDS[2], YMDS[3]);
42 }
else if ((YMDS[1] > 10) && (YMDS[2] < 10)){
43 sprintf((
char *)sVersion,
"V20%d%d0%d_%d\n", YMDS[0], YMDS[1], YMDS[2], YMDS[3]);
45 sprintf((
char *)sVersion,
"V20%d%d%d_%d\n", YMDS[0], YMDS[1], YMDS[2], YMDS[3]);
47 fprintf(stderr,
"QHYCCD SDK Version: %s\n", sVersion);
52 unsigned char fwv[32], FWInfo[256];
54 memset (FWInfo, 0x00,
sizeof(FWInfo));
55 ret = GetQHYCCDFWVersion(h, fwv);
57 if(ret == QHYCCD_SUCCESS){
58 if((fwv[0] >> 4) <= 9){
59 sprintf((
char *)FWInfo,
"Firmware version:20%d_%d_%d\n", ((fwv[0] >> 4) + 0x10), (fwv[0]&~0xf0),fwv[1]);
61 sprintf((
char *)FWInfo,
"Firmware version:20%d_%d_%d\n", (fwv[0] >> 4), (fwv[0]&~0xf0), fwv[1]);
64 sprintf((
char *)FWInfo,
"Firmware version:Not Found!\n");
67 fprintf(stderr,
"%s\n", FWInfo);
81 return "UNKNOWN: " + std::to_string(error);
314 config.add(
"camera.serialNumber",
"",
"camera.serialNumber", argType::Required,
"camera",
"serialNumber",
false,
"string",
"The identifying serial number of the camera.");
315 config.add(
"camera.bits",
"",
"camera.bits", argType::Required,
"camera",
"bits",
false,
"int",
"The number of bits used by the camera. Default is 16.");
327 for(
int i=0; i < 32; ++i){
331 config(
m_bits,
"camera.bits");
345 unsigned int m_retVal = InitQHYCCDResource();
347 printf(
"SDK resources initialized.\n");
349 printf(
"Cannot initialize SDK resources, error: %d\n",
m_retVal);
408 printf(
"Close QHYCCD success.\n");
410 printf(
"Close QHYCCD failure, error: %d\n",
m_retVal);
417 printf(
"SDK resources released.\n");
419 printf(
"Cannot release SDK resources, error %d.\n",
m_retVal);
447 log<text_log>(
"no camera with serial number " +
m_serialNumber +
" found.");
471 return log<
software_error,-1>({__FILE__, __LINE__,
"QHYCCD SDK Error from GetStatus: " });
492 uint32_t new_frame_length = GetQHYCCDMemLength(&
m_camera);
688 log<software_error>({__FILE__, __LINE__,
"Error setting exposure time"});
692 log<text_log>(
"Set exposure time: " + std::to_string(
m_expTimeSet) +
" sec");
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.
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.
std::mutex m_indiMutex
Mutex for locking INDI communications.
uint32_t m_width
The width of the image, once deinterlaced etc.
int appShutdown()
Shuts down the framegrabber thread.
void * loadImageIntoStreamCopy(void *dest, void *src, size_t width, size_t height, size_t szof)
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.
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.
std::string m_nextMode
The mode to be set by the next reconfiguration.
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.
pcf::IndiProperty m_indiP_roi_h
Property used to set the ROI height.
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
pcf::IndiProperty m_indiP_roi_w
Property used to set the ROI width.
std::string m_modeName
The current mode name.
pcf::IndiProperty m_indiP_roi_bin_x
Property used to set the ROI x binning.
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
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.
static constexpr bool c_stdCamera_fps
app::dev config to tell stdCamera not to expose FPS status (ignored since fpsCtrl=true)
static constexpr bool c_stdCamera_usesStateString
app::dev confg to tell stdCamera to expose the state string property
int checkNextROI()
Check the next ROI.
int powerOnDefaults()
Set defaults for a power on state.
int setNextROI()
Set the next ROI.
~qhyCtrl() noexcept
Destructor.
int configureAcquisition()
qhyccd_handle * m_camera
The library camera handle.
unsigned int m_retVal
Return code for QHYCCD cameras.
static constexpr bool c_stdCamera_usesModes
app:dev config to tell stdCamera not to expose mode controls
static constexpr bool c_stdCamera_exptimeCtrl
app::dev config to tell stdCamera to expose exposure time controls
static constexpr bool c_stdCamera_cropMode
app:dev config to tell stdCamera not to expose Crop Mode controls
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].
int loadImageIntoStream(void *dest)
static constexpr bool c_stdCamera_tempControl
app::dev config to tell stdCamera to not expose temperature controls
static constexpr bool c_stdCamera_fpsCtrl
app::dev config to tell stdCamera to expose FPS controls
static constexpr bool c_stdCamera_vShiftSpeed
app:dev config to tell stdCamera not to expose vertical shift speed control
int setTempSetPt()
Set the CCD temperature setpoint [stdCamera interface].
static constexpr bool c_stdCamera_emGain
app::dev config to tell stdCamera to not expose EM gain controls
virtual int appStartup()
Startup functions.
static constexpr bool c_stdCamera_temp
app::dev config to tell stdCamera to expose temperature
char m_camId[32]
The camera's ID.
int getTemp()
Get the current detector temperature.
int getExpTime()
Get the current exposure time.
int acquireAndCheckValid()
uint32_t m_bits
The number of bits used by the camera.
static constexpr bool c_stdCamera_readoutSpeed
app::dev config to tell stdCamera not to expose readout speed controls
virtual int appShutdown()
Do any needed shutdown tasks. Currently nothing in this app.
virtual int appLogic()
Implementation of the FSM for the Siglent SDG.
int recordTelem(const telem_stdcam *)
static constexpr bool c_stdCamera_hasShutter
app:dev config to tell stdCamera to expose shutter controls
static constexpr bool c_stdCamera_usesROI
app:dev config to tell stdCamera to expose ROI controls
virtual void setupConfig()
Setup the configuration system (called by MagAOXApp::setup())
virtual void loadConfig()
load the configuration system results (called by MagAOXApp::setup())
std::string m_serialNumber
The camera's identifying serial number.
int getFPS()
Get the current framerate.
@ OPERATING
The device is operating, other than homing.
@ NODEVICE
No device exists for the application to control.
@ CONFIGURING
The application is configuring the device.
@ ERROR
The application has encountered an error, from which it is recovering (with or without intervention)
@ NOTCONNECTED
The application is not connected to the device or service.
std::string qhyccdSDKErrorName(CONTROL_ID error)
std::unique_lock< std::mutex > lock(m_indiMutex)
void FirmWareVersion(qhyccd_handle *h)
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.
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.