3#include "../../_cexports/c_gev_server.h"
4#include "../../global.hpp"
6#include "../_decl/decl_node_map.hpp"
7#include "../_decl/decl_server.hpp"
8#include "../_decl/decl_stream.hpp"
9#include "../logical_network_interface.hpp"
24 return gsStream_.AtomicGet(
32 ServerPtr server(
new Server(HandleGuard<Server>(CVB_CALL_CAPI(CreateGevServer())),
false));
33 server->CreateNodeMap();
45 if (pixelFormat == PfncFormat::InvalidPixelFormat)
48 using namespace CExports;
49 auto pixelFormatName = PfncFormatValue::ToANSI(pixelFormat);
50 GSFixedSizeInitInfo init{GSSI_FixedSize,
51 static_cast<cvbuint32_t
>(pixelFormat),
52 pixelFormatName.c_str(),
53 static_cast<cvbuint32_t
>(size.
Width()),
54 static_cast<cvbuint32_t
>(size.
Height()),
57 ServerPtr server(
new Server(HandleGuard<Server>(CVB_CALL_CAPI(CreateGevServer2(
58 static_cast<TDriver
>(driverType),
reinterpret_cast<GSInitInfo &
>(init)))),
60 server->CreateNodeMap();
80 if (maxSize.
Width() < 1)
84 if (pixelFormat == PfncFormat::InvalidPixelFormat)
87 using namespace CExports;
88 GSDynamicSizeInitInfo init{GSFixedSizeInitInfo{GSSI_DynamicSize,
static_cast<CExports::cvbuint32_t
>(pixelFormat),
89 PfncFormatValue::ToANSI(pixelFormat).c_str(),
90 static_cast<CExports::cvbuint32_t
>(maxSize.
Width()),
91 static_cast<CExports::cvbuint32_t
>(maxSize.
Height()), intptr_t()},
92 static_cast<CExports::cvbuint32_t
>(maxSize.
Width()),
93 static_cast<CExports::cvbuint32_t
>(maxSize.
Height())};
95 ServerPtr server(
new Server(HandleGuard<Server>(CVB_CALL_CAPI(CreateGevServer2(
96 static_cast<TDriver
>(driverType),
reinterpret_cast<GSInitInfo &
>(init)))),
98 server->CreateNodeMap();
109 CExports::TDriver driverType = CExports::DT_Auto;
110 NativeCall([&]() {
return CVB_CALL_CAPI(GSDriverType(
Handle(), driverType)); });
122 [&]() {
return CExports::GSSetInfoAsStringTyped(
Handle(), CExports::GSI_ServerUserVersion, value.c_str()); });
127 CExports::gsipv4 ip = 0;
128 CExports::gsport port = 0;
129 NativeCall([&]() {
return CVB_CALL_CAPI(GSGetLocalIPv4(
Handle(), ip, port)); });
135 CExports::gsipv4 ip = 0;
136 CExports::gsport port = 0;
137 CVB_CALL_CAPI(GSGetRemoteIPv4(
Handle(), ip, port));
146 state_ = GevServer::State::Disconnected;
149 inline void Server::Start(
const Cvb::NetworkConnection::IPAddressUInt &address)
152 NativeCall([&]() {
return CVB_CALL_CAPI(GSStartIPv4(
Handle(), address)); });
153 state_ = GevServer::State::Disconnected;
149 inline void Server::Start(
const Cvb::NetworkConnection::IPAddressUInt &address) {
…}
159 NativeCall([&]() {
return CVB_CALL_CAPI(GSStop(
Handle())); });
160 state_ = GevServer::State::Configuration;
163 inline String Server::GetInfoAsString(
Info command)
const
165 auto bufferSize = NativeCall<size_t>([&](
size_t &size) {
166 return CExports::GSGetInfoAsStringTyped(
Handle(),
static_cast<CExports::TGSInfo
>(command),
167 reinterpret_cast<Char *
>(0), size);
170 bufferSize +=
sizeof(
Char);
174 return CExports::GSGetInfoAsStringTyped(
Handle(),
static_cast<CExports::TGSInfo
>(command), buffer.data(),
178 return buffer.data();
186 inline void Server::CreateNodeMap()
188 std::lock_guard<std::mutex>
lock(mtx);
189 nodeMap_ = std::make_shared<GevServer::NodeMap>(std::const_pointer_cast<Server>(shared_from_this()));
Data type description for an image plane.
Definition data_type.hpp:23
String UserVersion() const
Gets the user defined version that is appended to the device version.
Definition detail_server.hpp:114
void Stop()
Stops this server.
Definition detail_server.hpp:156
void SetUserVersion(const String &value)
Sets the user defined version that is appended to the device version.
Definition detail_server.hpp:119
GevServer::DriverType DriverType()
Gets the GigE Vision driver used by this server object.
Definition detail_server.hpp:107
Cvb::NetworkConnection LocalEndpoint() const
Gets the local end point this server is bound to.
Definition detail_server.hpp:125
void Start(const Cvb::NetworkConnection::IPAddress &address)
Starts this server and binds it to the given address .
Definition detail_server.hpp:141
static ServerPtr CreateNonStreaming()
Creates a non-streaming GigE Vision server object.
Definition detail_server.hpp:30
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:70
GevServer::State State()
Gets the the current state this server is in.
Definition detail_server.hpp:102
NodeMapPtr NodeMap() const
Gets this servers node map.
Definition detail_server.hpp:16
Cvb::NetworkConnection RemoteEndpoint() const
Gets the remote end point this server is connected to.
Definition detail_server.hpp:133
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:37
StreamPtr Stream() const
Gets the Cvb::GevServer::Stream for sending Images or other data.
Definition detail_server.hpp:21
void * Handle() const noexcept
Classic API device handle.
Definition decl_server.hpp:147
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
Namespace for GevServer based device configuration.
Definition decl_int_swiss_knife_node.hpp:11
Info
General version and acquisition information.
Definition gevserver.hpp:190
@ ServerUserVersion
User version of the server.
Definition gevserver.hpp:194
std::shared_ptr< Stream > StreamPtr
Convenience shared pointer for Stream.
Definition gevserver.hpp:49
State
The possible states this GevServer can be in.
Definition decl_server.hpp:32
DriverType
GigE Vision driver to use for communication and streaming.
Definition gevserver.hpp:139
std::shared_ptr< NodeMap > NodeMapPtr
Convenience shared pointer for NodeMap.
Definition gevserver.hpp:45
std::shared_ptr< Server > ServerPtr
Convenience shared pointer for GevServer.
Definition gevserver.hpp:37
@ String
Node is a string node (no reg).
Definition gevserver.hpp:177
PfncFormat
GenICam Pixel Format Naming Convention (PFNC) format values.
Definition pfnc_format.hpp:34
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
char Char
Character type for wide characters or unicode characters.
Definition string.hpp:63
ColorModel
Color model that this image is using.
Definition global.hpp:176
T const_pointer_cast(T... args)
Basic network connection operations.
Definition network_connection.hpp:15
static IPAddressUInt ToIPAddressUInt(const IPAddress &ip)
Creates an uint ip . from the given IPAddress
Definition network_connection.hpp:68