CVB++ 15.0
Loading...
Searching...
No Matches
detail_server_base.hpp
1#pragma once
2
3#include "../../_cexports/c_gev_server.h"
4#include "../_decl/decl_node_map.hpp"
5#include "../_decl/decl_server_base.hpp"
6#include "../_decl/decl_stream_base.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 {
17 {
18 return nodeMap_.AtomicGet([this]() {
20 });
21 }
22
24 {
25 return state_;
26 }
27
29 {
30 CExports::TDriver driverType = CExports::DT_Auto;
31 NativeCall([&]() { return CVB_CALL_CAPI(GSDriverType(Handle(), driverType)); });
32 return static_cast<GevServer::DriverType>(driverType);
33 }
34
36 {
37 return GetInfoAsString(Info::ServerUserVersion);
38 }
39
40 inline void ServerBase::SetUserVersion(const String &value)
41 {
42 NativeCall(
43 [&]() { return CExports::GSSetInfoAsStringTyped(Handle(), CExports::GSI_ServerUserVersion, value.c_str()); });
44 }
45
47 {
48 CExports::gsipv4 ip = 0;
49 CExports::gsport port = 0;
50 NativeCall([&]() { return CVB_CALL_CAPI(GSGetLocalIPv4(Handle(), ip, port)); });
51 return Cvb::NetworkConnection{ip, port};
52 }
53
55 {
56 CExports::gsipv4 ip = 0;
57 CExports::gsport port = 0;
58 CVB_CALL_CAPI(GSGetRemoteIPv4(Handle(), ip, port));
59 return Cvb::NetworkConnection{ip, port};
60 }
61
62 inline void ServerBase::Start(const Cvb::NetworkConnection::IPAddress &address)
63 {
65 NativeCall(
66 [&]() { return CVB_CALL_CAPI(GSStartIPv4(Handle(), Cvb::NetworkConnection::ToIPAddressUInt(address))); });
67 state_ = GevServer::State::Disconnected;
68 }
69
70 inline void ServerBase::Start(const Cvb::NetworkConnection::IPAddressUInt &address)
71 {
73 NativeCall([&]() { return CVB_CALL_CAPI(GSStartIPv4(Handle(), address)); });
74 state_ = GevServer::State::Disconnected;
75 }
76
77 inline void ServerBase::Stop()
78 {
80 NativeCall([&]() { return CVB_CALL_CAPI(GSStop(Handle())); });
81 state_ = GevServer::State::Configuration;
82 }
83
84 inline String ServerBase::GetInfoAsString(Info command) const
85 {
86 auto bufferSize = NativeCall<size_t>([&](size_t &size) {
87 return CExports::GSGetInfoAsStringTyped(Handle(), static_cast<CExports::TGSInfo>(command),
88 reinterpret_cast<Char *>(0), size);
89 });
90
91 bufferSize += sizeof(Char);
92 std::vector<Char> buffer(bufferSize);
93
94 NativeCall([&]() {
95 return CExports::GSGetInfoAsStringTyped(Handle(), static_cast<CExports::TGSInfo>(command), buffer.data(),
96 bufferSize);
97 });
98
99 return buffer.data();
100 }
101
102 inline void ServerBase::SetState(const GevServer::State &state) noexcept
103 {
104 state_ = state;
105 }
106
107 inline void ServerBase::RegisterEvents()
108 {
109 std::size_t dummy{0};
110 NativeCall([&]() {
111 return CVB_CALL_CAPI(
112 GSRegisterEvent(Handle(), CExports::TServerEvent::SE_Connected, &ServerBase::OnConnected, this, dummy));
113 });
114 NativeCall([&]() {
115 return CVB_CALL_CAPI(
116 GSRegisterEvent(Handle(), CExports::TServerEvent::SE_Disconnected, &OnDisconnected, this, dummy));
117 });
118 NativeCall([&]() {
119 return CVB_CALL_CAPI(
120 GSRegisterEvent(Handle(), CExports::TServerEvent::SE_AcquisitionStart, &OnAcquisitionStart, this, dummy));
121 });
122 NativeCall([&]() {
123 return CVB_CALL_CAPI(
124 GSRegisterEvent(Handle(), CExports::TServerEvent::SE_AcquisitionStop, &OnAcquisitionStop, this, dummy));
125 });
126 }
127
128 } // namespace GevServer
129 CVB_END_INLINE_NS
130} // namespace Cvb
virtual String UserVersion() const
Gets the user defined version that is appended to the device version.
Definition detail_server_base.hpp:35
virtual void Stop()
Stops this server.
Definition detail_server_base.hpp:77
virtual void SetUserVersion(const String &value)
Sets the user defined version that is appended to the device version.
Definition detail_server_base.hpp:40
virtual GevServer::DriverType DriverType()
Gets the GigE Vision driver used by this server object.
Definition detail_server_base.hpp:28
virtual Cvb::NetworkConnection LocalEndpoint() const
Gets the local end point this server is bound to.
Definition detail_server_base.hpp:46
virtual void * Handle() const noexcept=0
Returns the internal handle of this server object.
virtual void Start(const Cvb::NetworkConnection::IPAddress &address)
Starts this server and binds it to the given address .
Definition detail_server_base.hpp:62
virtual GevServer::State State()
Gets the the current state this server is in.
Definition detail_server_base.hpp:23
virtual NodeMapPtr NodeMap() const
Returns the GenApi node map of this server.
Definition detail_server_base.hpp:16
virtual Cvb::NetworkConnection RemoteEndpoint() const
Gets the remote end point this server is connected to.
Definition detail_server_base.hpp:54
T make_shared(T... args)
Namespace for GevServer based device configuration.
Definition decl_int_swiss_knife_node.hpp:11
Info
General version and acquisition information.
Definition gevserver.hpp:231
@ ServerUserVersion
User version of the server.
Definition gevserver.hpp:235
State
These enum entries model the states the server can be in.
Definition decl_server_base.hpp:28
DriverType
GigE Vision driver to use for communication and streaming.
Definition gevserver.hpp:167
std::shared_ptr< NodeMap > NodeMapPtr
Convenience shared pointer for NodeMap.
Definition gevserver.hpp:56
@ String
Node is a string node (no reg).
Definition gevserver.hpp:218
Root namespace for the Image Manager interface.
Definition version.hpp:11
char Char
Character type for wide characters or unicode characters.
Definition string.hpp:63
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