10 #define ocam2KCtrl_hpp
17 #include "../../libMagAOX/libMagAOX.hpp"
18 #include "../../magaox_git_version.h"
377 config.add(
"camera.ocamDescrambleFile",
"",
"camera.ocamDescrambleFile", argType::Required,
"camera",
"ocamDescrambleFile",
false,
"string",
"The path of the OCAM descramble file, relative to MagAOX/config.");
398 log<text_log>(
"maxEMGain set to 1");
404 log<text_log>(
"maxEMGain set to 600");
507 std::string response;
540 return log<software_error,0>({__FILE__,__LINE__});
548 log<software_error>({__FILE__, __LINE__,
"error from setSynchro on CONNECT"});
555 return log<software_error,0>({__FILE__,__LINE__});
565 if(!
lock.owns_lock())
return 0;
603 log<software_error>({__FILE__, __LINE__});
610 log<software_error>({__FILE__, __LINE__});
617 log<software_error>({__FILE__, __LINE__});
624 log<software_error>({__FILE__, __LINE__});
657 log<software_error>({__FILE__, __LINE__});
662 log<software_error>({__FILE__, __LINE__});
667 log<software_error>({__FILE__, __LINE__});
672 log<software_error>({__FILE__, __LINE__});
689 log<software_error>({__FILE__, __LINE__});
694 log<software_error>({__FILE__, __LINE__});
699 log<software_error>({__FILE__, __LINE__});
727 std::string response;
818 std::string response;
822 std::string comStr =
"temp ";
847 std::cerr <<
"response: " << response <<
"\n";
849 log<text_log,0>({
"Set temperature control to " + command});
870 std::string response;
882 std::cerr <<
"response: " << response <<
"\n";
887 std::cerr <<
"temp " << tempStr <<
" response: " << response <<
"\n";
889 return log<text_log,0>({
"set temperature: " + tempStr});
904 std::string response;
938 std::string fpsStr= std::to_string(
m_fpsSet);
942 std::string response;
947 std::cerr <<
"fps " << fpsStr <<
" response: " << response <<
"\n";
948 log<text_log>({
"set fps: " + fpsStr});
964 std::cerr <<
"setting: " << fpsStr <<
"\n";
966 pcf::IndiProperty ipFreq(pcf::IndiProperty::Number);
970 ipFreq.add(pcf::IndiElement(
"target"));
972 ipFreq[
"target"] = fpsStr;
985 std::string response;
988 std::string fpsStr= std::to_string(0);
992 std::cerr <<
"fps " << fpsStr <<
" response: " << response <<
"\n";
993 log<text_log>({
"set fps: " + fpsStr});
1008 std::cerr <<
"synchro " << sStr <<
" resonse: " << response <<
"\n";
1009 log<text_log>({
"set synchro: " + sStr});
1056 ss += std::to_string(
m_fps) +
"_";
1057 ss += std::to_string(
m_emGain) +
"_";
1076 std::string response;
1080 std::cerr <<
"\n******************************************\n";
1083 std::cerr <<
"\n******************************************\n";
1107 std::string response;
1116 std::cerr <<
"EM Gain parse error, response: " << response <<
"\n";
1134 std::string response;
1146 log<text_log>(
"Attempt to set EM gain to " + std::to_string(emg) +
" outside limits refused",
logPrio::LOG_WARNING);
1150 std::string emgStr= std::to_string(emg);
1154 std::cerr <<
"gain " << emgStr <<
" response: " << emgStr <<
"\n";
1156 log<text_log>({
"set EM Gain: " + emgStr});
1175 std::string response;
1180 log<software_error>({__FILE__, __LINE__,
"Error sending command to set mode"});
1213 log<text_log>(
"Response was: " + response);
1217 log<software_error>({__FILE__, __LINE__,
"Error setting synchro during configureAcquisition"});
1264 std::cerr <<
"ocamDescrambleFile: " << ocamDescrambleFile << std::endl;
1271 log<text_log>(
"ocam2_init error. Failed to initialize OCAM SDK with descramble file: " + ocamDescrambleFile,
logPrio::LOG_ERROR);
1276 log<text_log>(
"OCAM2K initialized. id: " + std::to_string(
m_ocam2_id));
1355 log<text_log>(
"frames skipped: " + std::to_string(framesSkipped),
logPrio::LOG_ERROR);
1387 unsigned currImageNumber = 0;
1398 mx::improc::eigenMap<int16_t> destMap(
reinterpret_cast<int16_t*
>(dest),
m_width,
m_height);
1402 for(
int cc = 0; cc < destMap.cols(); ++cc)
1404 for(
int rr = 0; rr < destMap.rows(); ++rr)
1428 if(rv < 0)
return rv;
1439 log<software_error>({__FILE__,__LINE__,
"wrong INDI property received."});
1443 if(!
ipRecv.find(
"request"))
1448 if(
ipRecv[
"request"].getSwitchState() == pcf::IndiElement::Off )
1477 if(!
ipRecv.find(
"current"))
1526 if(!(lastTemps ==
m_temps) || force)
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
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.
int whilePowerOff()
Actions while powered off.
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
int onPowerOff()
Actions on power off.
int appShutdown()
applogic shutdown
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int setShutterState(int sh)
Change shutter state.
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 pdvAcquire(timespec &currImageTimestamp)
int pdvSerialWriteRead(std::string &response, const std::string &command)
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 onPowerOff()
Actions on power off.
int updateINDI()
The static callback function to be registered for the channel properties.
int pdvStartAcquisition()
int appShutdown()
Application the shutdown.
int whilePowerOff()
Actions while powered off.
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
int updateINDI()
Update the INDI properties for this device controller.
int onPowerOff()
On power off, sets m_reconfig to true.
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)
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
pcf::IndiProperty m_indiP_synchro
float m_ccdTempSetpt
The desired temperature, in C.
bool m_tempControlStatus
Whether or not temperature control is active.
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].
bool m_synchro
Status of synchronization, true is on, false is off.
float m_ccdTemp
The current temperature, in C.
int updateINDI()
Update the INDI properties for this device controller.
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.
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
int whilePowerOff()
Actions while powered off.
int appShutdown()
Application shutdown.
float m_fps
The current FPS.
bool m_tempControlStatusSet
Desired state of temperature control.
int onPowerOff()
Actions on power off.
static constexpr bool c_stdCamera_fps
app::dev config to tell stdCamera not to expose FPS status (ignored since fpsCtrl==true)
INDI_SETCALLBACK_DECL(ocam2KCtrl, m_indiP_syncFreq)
pcf::IndiProperty m_indiP_temps
static constexpr bool c_stdCamera_usesModes
app:dev config to tell stdCamera not to expose mode controls
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
std::string stateString()
virtual int appLogic()
Implementation of the FSM for the OCAM 2K.
int recordTelem(const ocam_temps *)
static constexpr bool c_stdCamera_usesStateString
app::dev confg to tell stdCamera to expose the state string property
static constexpr bool c_stdCamera_exptimeCtrl
app::dev config to tell stdCamera not to expose exposure time controls
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
~ocam2KCtrl() noexcept
Destructor.
virtual int onPowerOff()
Implementation of the on-power-off FSM logic.
std::string m_ocamDescrambleFile
Path the OCAM 2K pixel descrambling file, relative to MagAO-X config directory.
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
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
Counter indicating the number of times that the protection reset has been requested within 10 seconds...
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.
int setTempControl()
Turn temperature control on or off.
pcf::IndiProperty m_indiP_emProt
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 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
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.
INDI_NEWCALLBACK_DECL(ocam2KCtrl, m_indiP_emProtReset)
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)
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.
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.
long m_lastImageNumber
The last image number, saved from the last loop through.
int getTemps()
Get the current device temperatures.
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
#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 REG_INDI_SETPROP(prop, devName, propName)
Register a SET INDI property with the class, using the standard callback name.
@ 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.
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.
INDI_VALIDATE_CALLBACK_PROPS(function, ipRecv)
const pcf::IndiProperty & ipRecv
int parseEMGain(unsigned &emGain, const std::string &fstr)
Parse the EM gain response.
INDI_SETCALLBACK_DEFN(adcTracker, m_indiP_teldata)(const pcf
INDI_NEWCALLBACK_DEFN(acesxeCtrl, m_indiP_windspeed)(const pcf
std::unique_lock< std::mutex > lock(m_indiMutex)
constexpr static logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
constexpr static logPrioT LOG_WARNING
A condition has occurred which may become an error, but the process continues.
constexpr static logPrioT LOG_NOTICE
A normal but significant condition.
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 appLogic()
Perform telemeter application logic.
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.
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.
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.