5#include "../../global.hpp"
7#include "../_decl/decl_indexed_stream.hpp"
8#include "../_decl/decl_emu_device.hpp"
9#include "../_decl/decl_emu_image.hpp"
10#include "../_decl/decl_digital_io.hpp"
31 inline StreamBasePtr EmuDevice::CreateStream(
int, StreamType streamType)
const
33 if (streamType != StreamType::Legacy)
38 inline EmuDevice::EmuStream::EmuStream(
const DevicePtr &device)
39 : IndexedStream(device)
40 , layout_(Driver::BufferImage::ImageLayout::FromIMGHandle(device->Handle()))
41 , imageCount_(static_cast<int>(device->DigitalIO()->ReadInputGroup(CExports::Emu::ImageCountGroup).to_ulong()))
47 auto frameTime = std::dynamic_pointer_cast<const Driver::EmuDevice>(
Parent())->FrameTime();
48 return Driver::BufferImage::Create(
Parent(), *layout_,
static_cast<double>(ImageIndex() * frameTime.count()));
51 inline int EmuDevice::EmuStream::ImageIndex()
const
53 auto digitalIO = Parent()->DigitalIO();
54 return static_cast<int>(digitalIO->ReadOutputGroup(CExports::Emu::CurrentImageIndexGroup).to_ullong());
57 inline void EmuDevice::EmuStream::SetImageIndex(
int index)
59 if (index < 0 || index >= ImageCount())
60 throw std::out_of_range(
"image index out of range");
62 auto digitalIO = Parent()->DigitalIO();
63 digitalIO->WriteOutputGroup(CExports::Emu::CurrentImageIndexGroup,
64 std::bitset<32>(
static_cast<std::uint32_t
>(index)));
65 std::dynamic_pointer_cast<const EmuDevice>(Parent())->OnImageAcquired();
DigitalIOPtr DigitalIO() const
Gets the DigitalIO interface if present.
Definition detail_device.hpp:167
std::chrono::milliseconds FrameTime() const
Gets the time when frame is valid.
Definition detail_emu_device.hpp:20
DevicePtr Parent() const noexcept
Gets the parent device of this stream.
Definition stream_base.hpp:42
Namespace for driver or device related operations.
Definition decl_composite.hpp:28
std::shared_ptr< StreamImage > StreamImagePtr
Convenience shared pointer for StreamImage.
Definition driver.hpp:93
std::shared_ptr< DeviceImage > DeviceImagePtr
Convenience shared pointer for DeviceImage.
Definition driver.hpp:61
std::shared_ptr< StreamBase > StreamBasePtr
Convenience shared pointer for StreamBase.
Definition driver.hpp:113
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::shared_ptr< Device > DevicePtr
Convenience shared pointer for Device.
Definition global.hpp:98
T const_pointer_cast(T... args)