16 #include "../../common/paths.hpp"
53template <
class derivedT>
95 const std::
string &command,
235 return *
static_cast<derivedT *
>( this );
239template <
class derivedT>
244template <
class derivedT>
253 #define MAGAOX_PDV_SERBUFSIZE 512
255template <
class derivedT>
268 derivedT::template log<software_error>( { __FILE__, __LINE__,
"PDV: error sending serial command" } );
279 if( derived().powerState() != 1 || derived().powerStateTarget() != 1 )
284 derivedT::template log<software_error>( { __FILE__, __LINE__,
"PDV: timeout, no serial response" } );
300 response.append( buf, ret );
301 lastbyte =
static_cast<u_char>( buf[ret - 1] );
322 derivedT::template log<software_error>( { __FILE__, __LINE__,
"PDV: timeout in serial response" } );
343template <
class derivedT>
357 derived().m_modeName = modeName;
364 if( derived().m_cameraModes.count( modeName ) != 1 )
370 std::string configFile;
372 if( derivedT::c_edtCamera_relativeConfigPath )
374 configFile = derived().configDir() +
"/";
377 configFile += derived().m_cameraModes[modeName].m_configFile;
379 derivedT::template log<text_log>(
"Loading EDT PDV config file: " + configFile );
383 return derivedT::template log<
software_error, -1>( { __FILE__, __LINE__,
"EDT PDV alloc_dependent FAILED" } );
386 if(
pdv_readcfg( configFile.c_str(), dd_p, &edtinfo ) != 0 )
389 return derivedT::template log<
software_error, -1>( { __FILE__, __LINE__,
"EDT PDV readcfg FAILED" } );
392 char edt_devname[128];
393 strncpy( edt_devname,
EDT_INTERFACE,
sizeof( edt_devname ) );
395 if( ( edt_p =
edt_open_channel( edt_devname, m_unit, m_channel ) ) == NULL )
401 { __FILE__, __LINE__, std::string(
"EDT PDV edt_open_channel FAILED: " ) + errstr } );
412 if(
pdv_initcam( edt_p, dd_p, m_unit, &edtinfo, configFile.c_str(), bitdir, pdv_debug ) != 0 )
417 { __FILE__, __LINE__,
"initcam failed. Run with '--logLevel=DBG' to see complete debugging output." } );
424 if( ( m_pdv =
pdv_open_channel( edt_devname, m_unit, m_channel ) ) == NULL )
426 std::string errstr = std::string(
"pdv_open_channel(" ) + edt_devname + std::to_string( m_unit ) +
"_" +
427 std::to_string( m_channel ) +
")";
429 derivedT::template log<software_error>( { __FILE__, __LINE__, errstr } );
430 derivedT::template log<software_error>( { __FILE__, __LINE__, errno } );
444 derivedT::template log<text_log>(
"Initialized framegrabber: " + m_cameraType );
445 derivedT::template log<text_log>(
"WxHxD: " + std::to_string( m_raw_width ) +
" X " +
446 std::to_string( m_raw_height ) +
" X " + std::to_string( m_raw_depth ) );
453 derivedT::template log<text_log>(
"allocated " + std::to_string( m_numBuffs ) +
" buffers" );
458template <
class derivedT>
461 config.add(
"framegrabber.pdv_unit",
463 "framegrabber.pdv_unit",
469 "The EDT PDV framegrabber unit number. Default is 0." );
470 config.add(
"framegrabber.pdv_channel",
472 "framegrabber.pdv_channel",
478 "The EDT PDV framegrabber channel number. Default is 0." );
479 config.add(
"framegrabber.numBuffs",
481 "framegrabber.numBuffs",
487 "The EDT PDV framegrabber DMA buffer size [images]. Default is 4." );
492template <
class derivedT>
495 config( m_unit,
"framegrabber.pdv_unit" );
496 config( m_channel,
"framegrabber.pdv_channel" );
497 config( m_numBuffs,
"framegrabber.numBuffs" );
499 m_readTimeout = 1000;
500 m_writeTimeout = 1000;
504template <
class derivedT>
507 if( pdvConfig( derived().m_startupMode ) < 0 )
509 derivedT::template log<software_error>( { __FILE__, __LINE__ } );
516template <
class derivedT>
522template <
class derivedT>
528template <
class derivedT>
534template <
class derivedT>
540template <
class derivedT>
548template <
class derivedT>
552 uint dmaTimeStamp[2];
557 currImageTimestamp.tv_sec = dmaTimeStamp[0];
558 currImageTimestamp.tv_nsec = dmaTimeStamp[1];
563template <
class derivedT>
567 if( pdvConfig( derived().m_nextMode ) < 0 )
569 derivedT::template log<text_log>(
"error trying to re-configure with " + derived().m_nextMode,
575 derived().m_nextMode =
"";
581template <
class derivedT>
MagAO-X EDT framegrabber interface.
int m_channel
EDT PDV board channel number.
int m_raw_depth
The bit-depth of the frame, according to the framegrabber.
int appLogic()
Application logic.
u_char * m_image_p
The image data grabbed.
int m_raw_height
The height of the frame, according to the framegrabber.
PdvDev * m_pdv
The EDT PDV device handle.
int pdvConfig(std::string &cfgname)
Configure the EDT framegrabber.
int pdvAcquire(timespec &currImageTimestamp)
int m_unit
EDT PDV board unit number.
std::string m_cameraType
The camera type according to the framegrabber.
~edtCamera() noexcept
Destructor, destroys the PdvDev structure.
edtCamera()
C'tor, sets up stdCamera.
int pdvSerialWriteRead(std::string &response, const std::string &command, bool logErrors=true)
Send a serial command over cameralink and retrieve the response.
int appStartup()
Startup function.
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 m_raw_width
The width of the frame, according to the framegrabber.
int pdvStartAcquisition()
int m_numBuffs
EDT PDV DMA buffer size, indicating number of images.
int appShutdown()
Application the shutdown.
int whilePowerOff()
Actions while powered off.
void pdv_flush_fifo(PdvDev *pdv_p)
Flush the stub PDV FIFO.
int pdv_readcfg(const char *configFile, Dependent *dd_p, Edtinfo *edtinfo)
Read a stub EDT configuration file.
void pdv_start_images(PdvDev *pdv_p, int numBuffs)
Start stub PDV acquisition for multiple images.
void edt_perror(char *errstr)
Report the last stub EDT error message.
void pdv_start_image(PdvDev *pdv_p)
Start acquisition of the next stub PDV image.
EdtDev * edt_open_channel(const char *deviceName, int unit, int channel)
Open a stub EDT device channel.
int pdv_get_waitchar(PdvDev *pdv_p, u_char *waitc)
Return the configured stub PDV serial terminator.
void pdv_serial_read_enable(PdvDev *pdv_p)
Enable stub PDV serial reads.
int pdv_serial_command(PdvDev *pdv_p, const char *command)
Send a command over the stub PDV serial channel.
void pdv_close(PdvDev *pdv_p)
Close a stub PDV device handle.
void edt_close(EdtDev *edt_p)
Close a stub EDT device channel.
int pdv_initcam(EdtDev *edt_p, Dependent *dd_p, int unit, Edtinfo *edtinfo, const char *configFile, char *bitdir, int pdv_debug)
Initialize a stub EDT camera instance.
int pdv_get_width(PdvDev *pdv_p)
Return the stub PDV frame width.
int pdv_get_height(PdvDev *pdv_p)
Return the stub PDV frame height.
PdvDev * pdv_open_channel(const char *deviceName, int unit, int channel)
Open a stub PDV device handle.
int pdv_get_depth(PdvDev *pdv_p)
Return the stub PDV frame bit depth.
int pdv_serial_wait(PdvDev *pdv_p, int timeout, int count)
Wait for serial data on the stub PDV channel.
char * pdv_get_cameratype(PdvDev *pdv_p)
Return the stub PDV camera type string.
u_char * pdv_wait_last_image_timed(PdvDev *pdv_p, uint dmaTimeStamp[2])
Wait for the last stub PDV image and fill the DMA timestamp.
Dependent * pdv_alloc_dependent()
Allocate a stub EDT dependent configuration object.
void pdv_multibuf(PdvDev *pdv_p, int numBuffs)
Configure the stub PDV ring-buffer depth.
int pdv_serial_read(PdvDev *pdv_p, char *buf, int size)
Read bytes from the stub PDV serial channel.
#define MAGAOX_PDV_SERBUFSIZE
Shared EDT SDK stub declarations for MagAO-X test builds.
#define EDT_INTERFACE
Default EDT interface name used by the production code.
Stub EDT dependent-configuration type used by unit tests.
Stub EDT device handle type used by unit tests.
Stub EDT configuration info structure used by unit tests.
Stub EDT camera handle type used by unit tests.
Configuration and control of an input and output device.
static constexpr logPrioT LOG_INFO
Informational. The info log level is the lowest level recorded during normal operations.
static constexpr logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
Standard camera interface.
An input/output capable device.
int loadConfig(mx::app::appConfigurator &config)
Load the device section from an application configurator.
int setupConfig(mx::app::appConfigurator &config)
Setup an application configurator for the device section.
A simple text log, a string-type log.