CVB++ 15.0
Loading...
Searching...
No Matches
detail_server.hpp
1#pragma once
2
3#include "../../_cexports/c_gev_server.h"
4#include "../_decl/decl_node_map.hpp"
5#include "../_decl/decl_server.hpp"
6#include "../_decl/decl_stream.hpp"
7#include "../../driver/flow_set_pool.hpp"
8#include "../../driver/gendc_descriptor.hpp"
9#include "../logical_network_interface.hpp"
10
11namespace Cvb
12{
13 CVB_BEGIN_INLINE_NS
14 namespace GevServer
15 {
16
18 {
19 auto server =
20 std::make_shared<Server>(HandleGuard<Server>(CVB_CALL_CAPI(CreateGevServer())), false, ProtectedTag{});
21 return server;
22 }
23
25 GevServer::DriverType driverType)
26 {
27 // Check here is necessary as we cast to uint
28 if (size.Width() < 1)
29 throw std::runtime_error("Width must be larger or equal to 1");
30 if (size.Height() < 1)
31 throw std::runtime_error("Height must be larger or equal to 1");
32 if (pixelFormat == PfncFormat::InvalidPixelFormat)
33 throw std::runtime_error("Invalid pixel format");
34
35 using namespace CExports;
36 auto pixelFormatName = PfncFormatValue::ToANSI(pixelFormat);
37 GSFixedSizeInitInfo init{GSSI_FixedSize,
38 static_cast<cvbuint32_t>(pixelFormat),
39 pixelFormatName.c_str(),
40 static_cast<cvbuint32_t>(size.Width()),
41 static_cast<cvbuint32_t>(size.Height()),
42 intptr_t()}; // Auto calculation
43
44 auto server = std::make_shared<Server>(
45 HandleGuard<Server>(
46 CVB_CALL_CAPI(CreateGevServer2(static_cast<TDriver>(driverType), reinterpret_cast<GSInitInfo &>(init)))),
47 true, ProtectedTag{});
48 return server;
49 }
50
52 GevServer::DriverType driverType)
53 {
54 return CreateWithConstSize(size, PfncFormatValue::From(colorModel, dataType), driverType);
55 }
56
58 GevServer::DriverType driverType)
59 {
60 return CreateWithVariableSize(maxSize, PfncFormatValue::From(colorModel, dataType), driverType);
61 }
62
64 GevServer::DriverType driverType)
65 {
66 // check here is necessary as we cast to uint
67 if (maxSize.Width() < 1)
68 throw std::runtime_error("Width must be larger or equal to 1");
69 if (maxSize.Height() < 1)
70 throw std::runtime_error("Height must be larger or equal to 1");
71 if (pixelFormat == PfncFormat::InvalidPixelFormat)
72 throw std::runtime_error("Invalid pixel format");
73
74 using namespace CExports;
75 GSDynamicSizeInitInfo init{GSFixedSizeInitInfo{GSSI_DynamicSize, static_cast<CExports::cvbuint32_t>(pixelFormat),
76 PfncFormatValue::ToANSI(pixelFormat).c_str(),
77 static_cast<CExports::cvbuint32_t>(maxSize.Width()),
78 static_cast<CExports::cvbuint32_t>(maxSize.Height()), intptr_t()},
79 static_cast<CExports::cvbuint32_t>(maxSize.Width()),
80 static_cast<CExports::cvbuint32_t>(maxSize.Height())};
81
82 auto server = std::make_shared<Server>(
83 HandleGuard<Server>(
84 CVB_CALL_CAPI(CreateGevServer2(static_cast<TDriver>(driverType), reinterpret_cast<GSInitInfo &>(init)))),
85 true, ProtectedTag{});
86
87 return server;
88 }
89
91 {
92 if (hasStream_)
93 return gsStream_.AtomicGet([&]() {
95 });
96 else
97 return nullptr;
98 }
99
100 } // namespace GevServer
101 CVB_END_INLINE_NS
102} // namespace Cvb
Data type description for an image plane.
Definition data_type.hpp:23
static ServerPtr CreateNonStreaming()
Creates a non-streaming GigE Vision server object.
Definition detail_server.hpp:17
static ServerPtr CreateWithVariableSize(Size2D< int > maxSize, ColorModel colorModel, DataType dataType, GevServer::DriverType driverType=GevServer::DriverType::Auto)
Creates a new Server object with a client configurable width, height and offsets.
Definition detail_server.hpp:57
static ServerPtr CreateWithConstSize(Size2D< int > size, PfncFormat pixelFormat, GevServer::DriverType driverType=GevServer::DriverType::Auto)
Creates a new Server object with a constant width and height.
Definition detail_server.hpp:24
StreamPtr Stream() const
Gets the stream associated with the server.
Definition detail_server.hpp:90
static PfncFormat From(const ColorModel &colorModel, const DataType &dataType)
Tries to coerce the PfncFormat from the given colorModel and dataType .
Definition pfnc_format.hpp:1068
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
T Height() const noexcept
Gets the vertical component of the size.
Definition size_2d.hpp:77
T Width() const noexcept
Gets the horizontal component of the size.
Definition size_2d.hpp:57
T make_shared(T... args)
Namespace for GevServer based device configuration.
Definition decl_int_swiss_knife_node.hpp:11
std::shared_ptr< Stream > StreamPtr
Convenience shared pointer for Stream.
Definition gevserver.hpp:64
DriverType
GigE Vision driver to use for communication and streaming.
Definition gevserver.hpp:167
std::shared_ptr< Server > ServerPtr
Convenience shared pointer for GevServer.
Definition gevserver.hpp:43
PfncFormat
GenICam Pixel Format Naming Convention (PFNC) format values.
Definition pfnc_format.hpp:34
Root namespace for the Image Manager interface.
Definition version.hpp:11
ColorModel
Color model that this image is using.
Definition global.hpp:176
T const_pointer_cast(T... args)