CVB++ 15.0
detail_emu_image.hpp
1#pragma once
2
3#include "../../global.hpp"
4
5#include "../_decl/decl_emu_image.hpp"
6#include "../_decl/decl_emu_device.hpp"
7
8namespace Cvb
9{
10
11 CVB_BEGIN_INLINE_NS
12
13 namespace Driver
14 {
15
16 inline std::chrono::milliseconds EmuImage::FrameTime() const
17 {
18 return std::dynamic_pointer_cast<const EmuDevice>(Parent())->FrameTime();
19 }
20
21 template <class Rep, class Period>
22 inline void EmuImage::SetFrameTime(const std::chrono::duration<Rep, Period> &frameTime)
23 {
24#ifdef max
25# undef max
26#endif
27 auto msFrameTime = std::chrono::duration_cast<std::chrono::milliseconds>(frameTime).count();
28 if (msFrameTime > std::numeric_limits<uint32_t>::max())
29 throw std::overflow_error("timeout must fit to unsigned 32 bit integer in ms");
30
31 auto digitalIO = Parent()->DigitalIO();
32 digitalIO->WriteOutputGroup(CExports::Emu::DelayGroup, std::bitset<32>(static_cast<std::uint32_t>(msFrameTime)));
33 }
34
35 } // namespace Driver
36
37 CVB_END_INLINE_NS
38
39} // namespace Cvb
DevicePtr Parent() const noexcept
Gets the parent device of this image.
Definition decl_device_image.hpp:47
T duration_cast(T... args)
T max(T... args)
Namespace for driver or device related operations.
Definition decl_composite.hpp:28
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17