Skip to content

Commit

Permalink
debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredmales committed Nov 11, 2023
1 parent 25b3fe0 commit 38c8e12
Show file tree
Hide file tree
Showing 18 changed files with 1,511 additions and 833 deletions.
2 changes: 1 addition & 1 deletion src/images/fitsDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <unistd.h>
#include <sys/inotify.h>

fitsDirectory::fitsDirectory()
fitsDirectory::fitsDirectory(std::mutex * mut) : rtimvImage(mut)
{
connect(&m_timer, SIGNAL(timeout()), this, SLOT(imageTimerout()));

Expand Down
6 changes: 4 additions & 2 deletions src/images/fitsDirectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ struct fitsDirectory : public rtimvImage

public:

///Default c'tor
fitsDirectory();
fitsDirectory() = delete;

///Only c'tor
fitsDirectory(std::mutex * mut);

/// Set the image key to the directory path
/**
Expand Down
2 changes: 1 addition & 1 deletion src/images/fitsImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <unistd.h>
#include <sys/inotify.h>

fitsImage::fitsImage()
fitsImage::fitsImage(std::mutex * mut) : rtimvImage(mut)
{
connect(&m_timer, SIGNAL(timeout()), this, SLOT(imageTimerout()));

Expand Down
6 changes: 4 additions & 2 deletions src/images/fitsImage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ struct fitsImage : public rtimvImage

public:

///Default c'tor
fitsImage();
fitsImage() = delete;

///Only c'tor
fitsImage(std::mutex * mut);

/// Set the image key to a path to a fits file.
/**
Expand Down
54 changes: 33 additions & 21 deletions src/images/mzmqImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ constexpr size_t imageOffset = headerSize;
static_assert(endOfHeader <= imageOffset, "Header fields sum to larger than reserved headerSize");


mzmqImage::mzmqImage()
mzmqImage::mzmqImage(std::mutex * mut) : rtimvImage(mut)
{
m_ZMQ_context = new zmq::context_t(1);

Expand Down Expand Up @@ -314,7 +314,12 @@ void mzmqImage::imageThreadExec()

if( nx != new_nx || ny != new_ny || atype != new_atype || !m_imageAttached)
{
if(m_data)
DEBUG_TRACE_CRUMB
std::lock_guard<std::mutex> guard(*m_accessMutex);

DEBUG_TRACE_CRUMB

if(m_data) //This can't be a call to detach due to mutex
{
m_imageAttached = false;
delete m_data;
Expand Down Expand Up @@ -370,6 +375,8 @@ void mzmqImage::imageThreadExec()
xe = xrif_allocate(xrif);

m_imageAttached = true;

DEBUG_TRACE_CRUMB
}

atype = new_atype;
Expand Down Expand Up @@ -423,12 +430,7 @@ void mzmqImage::imageThreadExec()

subscriber.close(); //close so that unsent messages are dropped.

m_imageAttached = false;
if(m_data)
{
delete m_data;
}
m_data = nullptr;
detach();

atype=0;
nx =0;
Expand All @@ -446,12 +448,7 @@ void mzmqImage::imageThreadExec()

}// outer loop (checking stale connections)

m_imageAttached = false;
if(m_data)
{
delete m_data;
}
m_data = nullptr;
detach();

xrif_delete(xrif);

Expand Down Expand Up @@ -514,19 +511,34 @@ int mzmqImage::update()

void mzmqImage::detach()
{
m_imageAttached = false;
if(m_data) delete m_data;
m_data = nullptr;
DEBUG_TRACE_ANCHOR(mzmqImage::detach begin)

std::lock_guard<std::mutex> guard(*m_accessMutex);

DEBUG_TRACE_CRUMB

m_imageAttached = false;
if(m_data) delete m_data;
m_data = nullptr;

m_lastCnt0 = -1;
m_lastCnt0 = -1;

DEBUG_TRACE_ANCHOR(mzmqImage::detach end)
}

bool mzmqImage::valid()
{
if(m_data && m_imageAttached) return true;

return false;
DEBUG_TRACE_ANCHOR(mzmqImage::valid begin)

if(m_data && m_imageAttached)
{
DEBUG_TRACE_ANCHOR(mzmqImage::valid true)
return true;
}

DEBUG_TRACE_ANCHOR(mzmqImage::valid false)
return false;

}

float mzmqImage::pixel(size_t n)
Expand Down
6 changes: 4 additions & 2 deletions src/images/mzmqImage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ struct mzmqImage : public rtimvImage

public:

///Default c'tor
mzmqImage();
mzmqImage() = delete;

///Only c'tor
mzmqImage(std::mutex * mut);

///Destructor, cleans up the zmq context and allocate memory.
~mzmqImage();
Expand Down
32 changes: 27 additions & 5 deletions src/images/shmimImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

#ifdef RTIMV_MILK

shmimImage::shmimImage()
shmimImage::shmimImage(std::mutex * mut) : rtimvImage(mut)
{
//ImageStreamIO_set_printError(new_printError);

connect(&m_timer, SIGNAL(timeout()), this, SLOT(shmimTimerout()));

connect(&m_timer, SIGNAL(timeout()), this, SLOT(shmimTimerout()));
}

int shmimImage::imageKey( const std::string & sn )
Expand Down Expand Up @@ -95,6 +92,11 @@ void shmimImage::imConnect()
m_notFoundLogged = false;
close(SM_fd);

if(m_accessMutex)
{
std::lock_guard<std::mutex> guard(*m_accessMutex);
}

if( ImageStreamIO_openIm(&m_image, m_shmimName.c_str()) != 0)
{
//This shouldn't really happen . . .
Expand Down Expand Up @@ -199,6 +201,11 @@ int shmimImage::update()

if(m_image.md->sem <= 0 || m_image.md == NULL) //Indicates that the server has cleaned up.
{
if(m_accessMutex)
{
std::lock_guard<std::mutex> guard(*m_accessMutex);
}

m_data = nullptr;
ImageStreamIO_closeIm(&m_image);
m_shmimAttached = 0;
Expand All @@ -222,6 +229,11 @@ int shmimImage::update()

if( snx != m_nx || sny != m_ny ) //Something else changed!
{
if(m_accessMutex)
{
std::lock_guard<std::mutex> guard(*m_accessMutex);
}

m_data = nullptr;
ImageStreamIO_closeIm(&m_image);
m_shmimAttached = 0;
Expand All @@ -234,6 +246,11 @@ int shmimImage::update()

if(cnt0 != m_lastCnt0) //Only redraw if it's actually a new image.
{
if(m_accessMutex)
{
std::lock_guard<std::mutex> guard(*m_accessMutex);
}

m_data = ((char *) (m_image.array.raw)) + curr_image*snx*sny*m_typeSize;
m_imageTime = m_image.md->writetime.tv_sec + ((double) m_image.md->writetime.tv_nsec)/1e9;

Expand Down Expand Up @@ -302,6 +319,11 @@ void shmimImage::detach()
{
if(m_shmimAttached == 0) return;

if(m_accessMutex)
{
std::lock_guard<std::mutex> guard(*m_accessMutex);
}

m_data = nullptr;
ImageStreamIO_closeIm(&m_image);
m_shmimAttached = 0;
Expand Down
6 changes: 4 additions & 2 deletions src/images/shmimImage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ struct shmimImage : public rtimvImage

public:

///Default c'tor
shmimImage();
shmimImage() = delete;

///Only c'tor
shmimImage(std::mutex * mut);

///Set the image key to a shared memory image name
/** If this contains the string ".fits" then it is treated as a FITS file and loaded as a static image. Otherwise
Expand Down
Loading

0 comments on commit 38c8e12

Please sign in to comment.