8#include "../../exception.hpp"
9#include "../../global.hpp"
10#include "../../size_2d.hpp"
11#include "../../utilities/system_info.hpp"
12#include "../logical_network_interface.hpp"
14#include "../gevserver.hpp"
16#include "../../pfnc_format.hpp"
23 inline HandleGuard<GevServer::Server>::HandleGuard(
void *handle) noexcept
24 : HandleGuard<GevServer::Server>(handle, [](
void *handle) { CVB_CALL_CAPI(
ReleaseObject(handle)); })
149 return handle_.Handle();
265 void Start(
const Cvb::NetworkConnection::IPAddress &address);
280 void Start(
const Cvb::NetworkConnection::IPAddressUInt &address);
298 auto res = CVB_CALL_CAPI(GSGetLastErrorString(
nullptr, messageSize));
299 if (res || messageSize < 2)
302 if (CVB_CALL_CAPI(GSGetLastErrorString(message.data(), messageSize)))
307 void NativeCall(std::function<CExports::cvbres_t()> fn)
const
312 auto message = GetLastGSErrorMessage();
316 std::stringstream stream;
317 stream <<
"Server " << message;
318 std::rethrow_exception(CvbException::FromCvbResult(result, stream.str()));
323 T NativeCall(std::function<CExports::cvbres_t(T &value)> fn)
const
326 auto result = fn(value);
333 std::stringstream stream;
334 stream <<
"Server " << message;
335 std::rethrow_exception(CvbException::FromCvbResult(result, stream.str()));
344 Server(HandleGuard<Server> &&guard,
bool hasStream)
345 : handle_(std::
move(guard))
346 , state_{GevServer::
State::Configuration}
347 , hasStream_{hasStream}
349 if (!handle_.Handle())
350 throw std::runtime_error(
"handle to create GevServer must not be empty");
352 std::size_t dummy{0};
354 return CVB_CALL_CAPI(
355 GSRegisterEvent(
Handle(), CExports::TServerEvent::SE_Connected, &Server::OnConnected,
this, dummy));
358 return CVB_CALL_CAPI(
359 GSRegisterEvent(
Handle(), CExports::TServerEvent::SE_Disconnected, &Server::OnDisconnected,
this, dummy));
362 return CVB_CALL_CAPI(GSRegisterEvent(
Handle(), CExports::TServerEvent::SE_AcquisitionStart,
363 &Server::OnAcquisitionStart,
this, dummy));
366 return CVB_CALL_CAPI(GSRegisterEvent(
Handle(), CExports::TServerEvent::SE_AcquisitionStop,
367 &Server::OnAcquisitionStop,
this, dummy));
371 static void __stdcall OnConnected(
void *pPrivate)
373 auto server =
reinterpret_cast<Server *
>(pPrivate);
374 server->SetState(GevServer::State::Connected);
377 static void __stdcall OnDisconnected(
void *pPrivate)
379 auto server =
reinterpret_cast<Server *
>(pPrivate);
380 server->SetState(GevServer::State::Disconnected);
383 static void __stdcall OnAcquisitionStart(
void *pPrivate)
385 auto server =
reinterpret_cast<Server *
>(pPrivate);
386 server->SetState(GevServer::State::AcquisitionEnabled);
389 static void __stdcall OnAcquisitionStop(
void *pPrivate)
391 auto server =
reinterpret_cast<Server *
>(pPrivate);
392 server->SetState(GevServer::State::Connected);
397 void CreateNodeMap();
399 HandleGuard<Server> handle_;
400 std::atomic<GevServer::State> state_;
403 mutable Internal::AsyncRef<GevServer::Stream> gsStream_;
404 const bool hasStream_;
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
cvbbool_t ReleaseObject(OBJ &Object)
Namespace for GevServer based device configuration.
Definition decl_int_swiss_knife_node.hpp:11
Info
General version and acquisition information.
Definition gevserver.hpp:190
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
@ Auto
Auto select driver type.
Definition gevserver.hpp:140
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
std::string GetLastErrorMessage()
Returns the last error message.
Definition system_info.hpp:167
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
ColorModel
Color model that this image is using.
Definition global.hpp:176
Basic network connection operations.
Definition network_connection.hpp:15