5 #include "ScopeException.h"
33 typedef std::pair<typename std::vector<T>::iterator,
typename std::vector<T>::iterator>
datapart_t;
36 typename typedef std::vector<T>::const_iterator
citerator;
39 typename typedef std::vector<T>::size_type
size_type;
80 ScopeImage(
const uint32_t& _lines = 128,
const uint32_t& _linewidth = 128,
const uint32_t& _area = 0,
const bool& _complete_avg =
false,
const bool& _complete_frame =
false)
83 , linewidth(_linewidth)
84 , complete_frame(_complete_frame)
85 , percent_complete(0.0)
86 , complete_avg(_complete_avg)
87 , data(_lines*_linewidth, T(0))
88 , inserter(data.begin())
89 , newpart(data.begin(), data.begin())
97 , linewidth(_si.linewidth)
98 , complete_frame(_si.complete_frame)
99 , percent_complete(_si.percent_complete)
100 , complete_avg(_si.complete_avg)
101 , reading_access(0) {
104 inserter = data.begin();
105 newpart =
datapart_t(data.begin(), data.begin());
111 if (
this != &_si ) {
112 assert(lines == _si.
lines);
120 inserter = data.begin();
121 newpart =
datapart_t(data.begin(), data.begin());
128 uint32_t Area()
const {
return area; }
129 uint32_t Lines()
const {
return lines; }
130 uint32_t Linewidth()
const {
return linewidth; }
131 datapart_t Newpart()
const {
return newpart; }
139 void SetCompleteFrame(
const bool& _complete) { complete_frame = _complete; }
140 void SetPercentComplete(
const double& _percent) { percent_complete = _percent; }
141 void SetCompleteAvg(
const bool& _complete) { complete_avg = _complete; }
145 T
Pixel (
const uint32_t& _column,
const uint32_t& _line)
const {
147 return acc.
GetConstData()->at(_line * linewidth + _column);
152 std::lock_guard<std::mutex> lock(pixelmutex);
154 mt.seed(static_cast<unsigned long>(GetTickCount64()));
155 std::generate( std::begin(data), std::end(data), mt);
156 newpart = std::make_pair(data.begin(), data.end());
163 std::unique_lock<std::mutex> lock(pixelmutex);
164 while ( reading_access > 0 )
185 assert(reading_access > 0);
187 readcond.notify_all();
194 class ScopeImageAccess {
220 return pData->data();
227 class ScopeImageConstAccess {
238 , pData(image->GetDataConst()) {
253 typedef std::shared_ptr<ScopeImage<uint16_t>> ScopeImageU16Ptr;
255 typedef std::shared_ptr<const ScopeImage<uint16_t>> ScopeImageU16CPtr;
257 typedef ScopeImageAccess<uint16_t> ScopeImageAccessU16;
259 typedef ScopeImageConstAccess<uint16_t> ScopeImageConstAccessU16;
280 bool InsertAndAveragePixels(ScopeImageU16Ptr
const _img, std::vector<uint16_t>::iterator& _where,
const DaqChunk::iterator _from,
const DaqChunk::iterator _to,
const uint16_t& _currentavgcount);
uint32_t linewidth
width of a line, x resolution
~ScopeImageAccess()
Release data on destruction, unlocks mutex.
std::vector< T > * GetData()
std::condition_variable readcond
condition variable for read access
std::vector< T >::size_type size_type
the size type
std::vector< uint16_t >::iterator iterator
Iterator over the data vector.
double percent_complete
how many percent of the frame are already filled
const std::vector< T > * GetDataConst() const
std::atomic< int16_t > reading_access
>0 if someone got a pointer to the const datavector
void ReleaseDataConst() const
Decreases reading_access counter.
const ScopeImage< T > *const image
pointer to the ScopeImage
std::vector< T >::iterator inserter
current insertion position
~ScopeImageConstAccess()
Release data on destruction, unlocks mutex.
std::vector< T > data
vector with pixel data
Gives RAII safe access (read&write) to the pixeldata of a ScopeImage.
The BGRA8Pixel struct and various related helpers for color conversions.
std::vector< T > * GetData() const
std::vector< T > *const pData
Pointer to the ScopeImage's data vector.
bool complete_avg
false if this is a not completely averaged frame, it is then only for display purpose and will not be...
const uint32_t area
area of the image
ScopeImage< T > *const image
pointer to the ScopeImage
ScopeImage & operator=(const ScopeImage &_si)
Safe assignment.
bool complete_frame
false if frame not complete, allows for partial display during acquisition
void FillRandom()
Fills the complete image with random pixel data.
ScopeImageAccess(ScopeImage< T > &_image)
Get the data, locks mutex inside ScopeImage.
datapart_t newpart
range of freshly inserted pixels
ScopeImage(const uint32_t &_lines=128, const uint32_t &_linewidth=128, const uint32_t &_area=0, const bool &_complete_avg=false, const bool &_complete_frame=false)
Initialize with zeros.
const std::vector< T > * GetConstData() const
T Pixel(const uint32_t &_column, const uint32_t &_line) const
ScopeImage(const ScopeImage &_si)
Safe copy.
std::mutex pixelmutex
mutex for protection of pixel operations
uint32_t lines
number of lines, y resolution
Various helper functions and classes for Scope.
std::pair< typename std::vector< T >::iterator, typename std::vector< T >::iterator > datapart_t
pair of two iterators over the data vector
Gives RAII safe const access (read-only) to the pixeldata of a ScopeImage.
ScopeImageConstAccess(const ScopeImage< T > &_image)
Get the data, locks mutex inside ScopeImage.
std::vector< T >::const_iterator citerator
const iterator over the data vector
const std::vector< T > *const pData
Pointer to the ScopeImage's data vector.