2#include "../../../tests/catch2/catch.hpp"
3#include "../../tests/testMacrosINDI.hpp"
5#include "../streamWriter.hpp"
45 int setup_circbufs(
int width,
int height,
int dataType,
int circBuffLength,
int writeChunkLength )
93 curr_timing[1] = pp + 1000;
94 curr_timing[2] = pp + 2000;
122 xrif_error_t xrv = xrif_new( &xrif );
124 char header[XRIF_HEADER_SIZE];
127 size_t nr = fread( header, 1, XRIF_HEADER_SIZE, fp_xrif );
129 if( nr != XRIF_HEADER_SIZE )
136 uint32_t header_size;
137 xrif_read_header( xrif, &header_size, header );
142 std::cerr <<
"width mismatch\n";
148 std::cerr <<
"height mismatch\n";
152 if( xrif_depth( xrif ) != 1 )
154 std::cerr <<
"depth mismatch\n";
158 if( xrif_frames( xrif ) != stop - start )
160 std::cerr <<
"frames mismatch\n";
164 xrif_allocate( xrif );
166 nr = fread( xrif->raw_buffer, 1, xrif->compressed_size, fp_xrif );
168 if( nr != xrif->compressed_size )
170 std::cerr <<
"error reading compressed image buffer.\n";
174 xrv = xrif_decode( xrif );
175 if( xrv != XRIF_NOERROR )
177 std::cerr <<
"error decoding compressed image buffer. Code: " << xrv <<
"\n";
186 xrif->raw_buffer[n] )
192 std::cerr <<
"Buffers don't match: " << badpix <<
" bad pixels.\n";
204SCENARIO(
"streamWriter INDI Callbacks",
"[streamWriter]" )
209SCENARIO(
"streamWriter Configuration",
"[streamWriter]" )
211 GIVEN(
"A default constructed streamWriter" )
216 WHEN(
"default configurations" )
223SCENARIO(
"streamWriter encoding data",
"[streamWriter]" )
225 GIVEN(
"A default constructed streamWriter and a 120x120 uint16 stream" )
230 WHEN(
"writing full 1st chunk" )
232 int circBuffLength = 10;
233 int writeChunkLength = 5;
234 REQUIRE( sw_test.
setup_circbufs( 120, 120, XRIF_TYPECODE_UINT16, circBuffLength, writeChunkLength ) == 0 );
244 WHEN(
"writing full 2nd chunk" )
246 int circBuffLength = 10;
247 int writeChunkLength = 5;
248 REQUIRE( sw_test.
setup_circbufs( 120, 120, XRIF_TYPECODE_UINT16, circBuffLength, writeChunkLength ) == 0 );
259 WHEN(
"writing partial 1st chunk" )
261 int circBuffLength = 10;
262 int writeChunkLength = 5;
263 REQUIRE( sw_test.
setup_circbufs( 120, 120, XRIF_TYPECODE_UINT16, circBuffLength, writeChunkLength ) == 0 );
274 WHEN(
"writing partial 2nd chunk" )
276 int circBuffLength = 10;
277 int writeChunkLength = 5;
278 REQUIRE( sw_test.
setup_circbufs( 120, 120, XRIF_TYPECODE_UINT16, circBuffLength, writeChunkLength ) == 0 );
std::string m_configName
The name of the configuration file (minus .conf).
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
size_t m_circBuffLength
The length of the circular buffer, in frames.
int initialize_xrif()
Initialize the xrif system.
uint64_t * m_timingCircBuff
uint8_t m_dataType
The ImageStreamIO type code.
int m_typeSize
The pixel byte depth.
uint64_t m_currSaveStart
The circular buffer position at which to start saving.
size_t m_height
The height of the image.
uint64_t m_currSaveStopFrameNo
The frame number of the image at which saving stopped (for logging)
int allocate_circbufs()
Worker function to allocate the circular buffers.
std::string m_outName
The name to use for outputting files, Default is m_shmimName.
size_t m_maxCircBuffLength
The maximum length of the circular buffer, in frames.
char * m_rawImageCircBuff
int allocate_xrif()
Worker function to configure and allocate the xrif handles.
std::string m_rawimageDir
The path where files will be saved.
double m_maxCircBuffSize
The maximum size of the circular bufffer in MB.
int doEncode()
Function called when semaphore is raised to do the encode and write.
uint64_t m_currSaveStop
The circular buffer position at which to stop saving.
std::string m_outFilePath
The full path for the latest output file.
size_t m_maxWriteChunkLength
size_t m_width
The width of the image.
#define XWCTEST_INDI_NEW_CALLBACK(testclass, propname)
Catch-2 tests for whether a NEW callback properly validates the input property properly.
SCENARIO("streamWriter INDI Callbacks", "[streamWriter]")
int fill_circbuf_uint16()
int comp_frames_uint16(size_t start, size_t stop)
int write_frames(int start, int stop)
streamWriter_data_test(streamWriter_test *sw)
std::string rawimageDir()
int setup_circbufs(int width, int height, int dataType, int circBuffLength, int writeChunkLength)
streamWriter_test(const std::string &device)
#define XWCTEST_SETUP_INDI_NEW_PROP(propname)