pvxslibs 1.5.0__cp310-cp310-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pvxslibs/__init__.py +0 -0
- pvxslibs/dbd/pvxsIoc.dbd +8 -0
- pvxslibs/include/pvxs/client.h +1094 -0
- pvxslibs/include/pvxs/data.h +948 -0
- pvxslibs/include/pvxs/iochooks.h +170 -0
- pvxslibs/include/pvxs/log.h +148 -0
- pvxslibs/include/pvxs/netcommon.h +82 -0
- pvxslibs/include/pvxs/nt.h +208 -0
- pvxslibs/include/pvxs/server.h +238 -0
- pvxslibs/include/pvxs/sharedArray.h +748 -0
- pvxslibs/include/pvxs/sharedpv.h +121 -0
- pvxslibs/include/pvxs/source.h +290 -0
- pvxslibs/include/pvxs/srvcommon.h +148 -0
- pvxslibs/include/pvxs/unittest.h +327 -0
- pvxslibs/include/pvxs/util.h +354 -0
- pvxslibs/include/pvxs/version.h +97 -0
- pvxslibs/include/pvxs/versionNum.h +6 -0
- pvxslibs/ioc.py +10 -0
- pvxslibs/lib/__init__.py +0 -0
- pvxslibs/lib/event_core_dsoinfo.py +14 -0
- pvxslibs/lib/event_pthread_dsoinfo.py +14 -0
- pvxslibs/lib/libevent_core.so +0 -0
- pvxslibs/lib/libevent_core.so.2.2.0 +0 -0
- pvxslibs/lib/libevent_pthread.so +0 -0
- pvxslibs/lib/libevent_pthread.so.2.2.0 +0 -0
- pvxslibs/lib/libpvxs.so +0 -0
- pvxslibs/lib/libpvxs.so.1.5 +0 -0
- pvxslibs/lib/libpvxsIoc.so +0 -0
- pvxslibs/lib/libpvxsIoc.so.1.5 +0 -0
- pvxslibs/lib/pvxsIoc_dsoinfo.py +14 -0
- pvxslibs/lib/pvxs_dsoinfo.py +14 -0
- pvxslibs/path.py +12 -0
- pvxslibs/test/__init__.py +0 -0
- pvxslibs/test/test_load.py +30 -0
- pvxslibs/version.py +32 -0
- pvxslibs-1.5.0.dist-info/METADATA +44 -0
- pvxslibs-1.5.0.dist-info/RECORD +40 -0
- pvxslibs-1.5.0.dist-info/WHEEL +5 -0
- pvxslibs-1.5.0.dist-info/licenses/LICENSE +26 -0
- pvxslibs-1.5.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright - See the COPYRIGHT that is included with this distribution.
|
|
3
|
+
* pvxs is distributed subject to a Software License Agreement found
|
|
4
|
+
* in file LICENSE that is included with this distribution.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PVXS_SERVER_H
|
|
7
|
+
#define PVXS_SERVER_H
|
|
8
|
+
|
|
9
|
+
#include <osiSock.h>
|
|
10
|
+
|
|
11
|
+
#include <iosfwd>
|
|
12
|
+
#include <functional>
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <tuple>
|
|
15
|
+
#include <set>
|
|
16
|
+
#include <map>
|
|
17
|
+
#include <vector>
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include <array>
|
|
20
|
+
|
|
21
|
+
#include <epicsEndian.h>
|
|
22
|
+
|
|
23
|
+
#include <pvxs/version.h>
|
|
24
|
+
#include <pvxs/util.h>
|
|
25
|
+
#include <pvxs/data.h>
|
|
26
|
+
#include <pvxs/netcommon.h>
|
|
27
|
+
|
|
28
|
+
namespace pvxs {
|
|
29
|
+
namespace client {
|
|
30
|
+
struct Config;
|
|
31
|
+
}
|
|
32
|
+
namespace server {
|
|
33
|
+
|
|
34
|
+
struct SharedPV;
|
|
35
|
+
struct Source;
|
|
36
|
+
struct Config;
|
|
37
|
+
|
|
38
|
+
/** PV Access protocol server instance
|
|
39
|
+
*
|
|
40
|
+
* Use a Config to determine how this server will bind, listen,
|
|
41
|
+
* and announce itself.
|
|
42
|
+
*
|
|
43
|
+
* In order to be useful, a Server will have one or more Source instances added
|
|
44
|
+
* to it with addSource().
|
|
45
|
+
*
|
|
46
|
+
* As a convenience, each Server instance automatically contains a "__builtin" StaticSource
|
|
47
|
+
* to which SharedPV instances can be directly added.
|
|
48
|
+
* The "__builtin" has priority zero, and can be accessed or even removed like any Source
|
|
49
|
+
* explicitly added with addSource().
|
|
50
|
+
*
|
|
51
|
+
* There is also a "__server" source which provides the special "server" PV
|
|
52
|
+
* used by the pvlist CLI.
|
|
53
|
+
*/
|
|
54
|
+
class PVXS_API Server
|
|
55
|
+
{
|
|
56
|
+
public:
|
|
57
|
+
|
|
58
|
+
//! An empty/dummy Server
|
|
59
|
+
constexpr Server() = default;
|
|
60
|
+
//! Create/allocate, but do not start, a new server with the provided config.
|
|
61
|
+
explicit Server(const Config&);
|
|
62
|
+
Server(const Server&) = default;
|
|
63
|
+
Server(Server&& o) = default;
|
|
64
|
+
Server& operator=(const Server&) = default;
|
|
65
|
+
Server& operator=(Server&& o) = default;
|
|
66
|
+
~Server();
|
|
67
|
+
|
|
68
|
+
/** Create new server based on configuration from $EPICS_PVA* environment variables.
|
|
69
|
+
*
|
|
70
|
+
* Shorthand for @code Config::fromEnv().build() @endcode.
|
|
71
|
+
* @since 0.2.1
|
|
72
|
+
*/
|
|
73
|
+
static
|
|
74
|
+
Server fromEnv();
|
|
75
|
+
|
|
76
|
+
//! Begin serving. Does not block.
|
|
77
|
+
Server& start();
|
|
78
|
+
//! Stop server
|
|
79
|
+
Server& stop();
|
|
80
|
+
|
|
81
|
+
/** start() and then (maybe) stop()
|
|
82
|
+
*
|
|
83
|
+
* run() may be interrupted by calling interrupt(),
|
|
84
|
+
* or by SIGINT or SIGTERM (only one Server per process)
|
|
85
|
+
*
|
|
86
|
+
* Intended to simple CLI programs.
|
|
87
|
+
* Only one Server in a process may be in run() at any moment.
|
|
88
|
+
* Other use case should call start()/stop()
|
|
89
|
+
*/
|
|
90
|
+
Server& run();
|
|
91
|
+
//! Queue a request to break run()
|
|
92
|
+
Server& interrupt();
|
|
93
|
+
|
|
94
|
+
//! effective config
|
|
95
|
+
const Config& config() const;
|
|
96
|
+
|
|
97
|
+
//! Create a client configuration which can communicate with this Server.
|
|
98
|
+
//! Suitable for use in self-contained unit-tests.
|
|
99
|
+
client::Config clientConfig() const;
|
|
100
|
+
|
|
101
|
+
//! Add a SharedPV to the "__builtin" StaticSource
|
|
102
|
+
Server& addPV(const std::string& name, const SharedPV& pv);
|
|
103
|
+
//! Remove a SharedPV from the "__builtin" StaticSource
|
|
104
|
+
Server& removePV(const std::string& name);
|
|
105
|
+
|
|
106
|
+
//! Add a Source to this server with an arbitrary source name.
|
|
107
|
+
//!
|
|
108
|
+
//! Source names beginning with "__" are reserved for internal use.
|
|
109
|
+
//! eg. "__builtin" and "__server".
|
|
110
|
+
//!
|
|
111
|
+
//! @param name Source name
|
|
112
|
+
//! @param src The Source. A strong reference to this Source which will be released by removeSource() or ~Server()
|
|
113
|
+
//! @param order Determines the order in which this Source::onCreate() will be called. Lowest first.
|
|
114
|
+
//!
|
|
115
|
+
//! @throws std::runtime_error If this (name, order) has already been added.
|
|
116
|
+
Server& addSource(const std::string& name,
|
|
117
|
+
const std::shared_ptr<Source>& src,
|
|
118
|
+
int order =0);
|
|
119
|
+
|
|
120
|
+
//! Disassociate a Source using the name and priority given to addSource()
|
|
121
|
+
std::shared_ptr<Source> removeSource(const std::string& name,
|
|
122
|
+
int order =0);
|
|
123
|
+
|
|
124
|
+
//! Fetch a previously added Source.
|
|
125
|
+
std::shared_ptr<Source> getSource(const std::string& name,
|
|
126
|
+
int order =0);
|
|
127
|
+
|
|
128
|
+
//! List all source names and priorities.
|
|
129
|
+
std::vector<std::pair<std::string, int> > listSource();
|
|
130
|
+
|
|
131
|
+
#ifdef PVXS_EXPERT_API_ENABLED
|
|
132
|
+
//! Compile report about peers and channels
|
|
133
|
+
//! @param zero If true, zero counters after reading
|
|
134
|
+
//! @since 0.2.0
|
|
135
|
+
Report report(bool zero=true) const;
|
|
136
|
+
#endif
|
|
137
|
+
|
|
138
|
+
explicit operator bool() const { return !!pvt; }
|
|
139
|
+
|
|
140
|
+
friend
|
|
141
|
+
PVXS_API
|
|
142
|
+
std::ostream& operator<<(std::ostream& strm, const Server& serv);
|
|
143
|
+
|
|
144
|
+
struct Pvt;
|
|
145
|
+
private:
|
|
146
|
+
std::shared_ptr<Pvt> pvt;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
PVXS_API
|
|
150
|
+
std::ostream& operator<<(std::ostream& strm, const Server& serv);
|
|
151
|
+
|
|
152
|
+
//! Configuration for a Server
|
|
153
|
+
struct PVXS_API Config {
|
|
154
|
+
//! List of network interface addresses (**not** host names) to which this server will bind.
|
|
155
|
+
//! interfaces.empty() treated as an alias for "0.0.0.0", which may also be given explicitly.
|
|
156
|
+
//! Port numbers are optional and unused (parsed and ignored)
|
|
157
|
+
std::vector<std::string> interfaces;
|
|
158
|
+
//! Ignore client requests originating from addresses in this list.
|
|
159
|
+
//! Entries must be IP addresses with optional port numbers.
|
|
160
|
+
//! Port number zero (default) is treated as a wildcard which matches any port.
|
|
161
|
+
//! @since 0.2.0
|
|
162
|
+
std::vector<std::string> ignoreAddrs;
|
|
163
|
+
//! Addresses (**not** host names) to which (UDP) beacons message will be sent.
|
|
164
|
+
//! May include broadcast and/or unicast addresses.
|
|
165
|
+
//! Supplemented only if auto_beacon==true
|
|
166
|
+
std::vector<std::string> beaconDestinations;
|
|
167
|
+
//! TCP port to bind. Default is 5075. May be zero.
|
|
168
|
+
unsigned short tcp_port = 5075;
|
|
169
|
+
//! UDP port to bind. Default is 5076. May be zero, cf. Server::config() to find allocated port.
|
|
170
|
+
unsigned short udp_port = 5076;
|
|
171
|
+
//! Whether to populate the beacon address list automatically. (recommended)
|
|
172
|
+
bool auto_beacon = true;
|
|
173
|
+
|
|
174
|
+
//! Inactivity timeout interval for TCP connections. (seconds)
|
|
175
|
+
//! @since 0.2.0
|
|
176
|
+
double tcpTimeout = 40.0;
|
|
177
|
+
|
|
178
|
+
//! Server unique ID. Only meaningful in readback via Server::config()
|
|
179
|
+
ServerGUID guid{};
|
|
180
|
+
|
|
181
|
+
private:
|
|
182
|
+
bool BE = EPICS_BYTE_ORDER==EPICS_ENDIAN_BIG;
|
|
183
|
+
bool UDP = true;
|
|
184
|
+
public:
|
|
185
|
+
|
|
186
|
+
// compat
|
|
187
|
+
static inline Config from_env() { return Config{}.applyEnv(); }
|
|
188
|
+
|
|
189
|
+
//! Default configuration using process environment
|
|
190
|
+
static inline Config fromEnv() { return Config{}.applyEnv(); }
|
|
191
|
+
|
|
192
|
+
//! Configuration limited to the local loopback interface on a randomly chosen port.
|
|
193
|
+
//! Suitable for use in self-contained unit-tests.
|
|
194
|
+
//! @since 0.3.0 Address family argument added.
|
|
195
|
+
static Config isolated(int family=AF_INET);
|
|
196
|
+
|
|
197
|
+
//! update using defined EPICS_PVA* environment variables
|
|
198
|
+
Config& applyEnv();
|
|
199
|
+
|
|
200
|
+
typedef std::map<std::string, std::string> defs_t;
|
|
201
|
+
//! update with definitions as with EPICS_PVA* environment variables.
|
|
202
|
+
//! Process environment is not changed.
|
|
203
|
+
Config& applyDefs(const defs_t& def);
|
|
204
|
+
|
|
205
|
+
//! extract definitions with environment variable names as keys.
|
|
206
|
+
//! Process environment is not changed.
|
|
207
|
+
void updateDefs(defs_t& defs) const;
|
|
208
|
+
|
|
209
|
+
/** Apply rules to translate current requested configuration
|
|
210
|
+
* into one which can actually be loaded based on current host network configuration.
|
|
211
|
+
*
|
|
212
|
+
* Explicit use of expand() is optional as the Context ctor expands any Config given.
|
|
213
|
+
* expand() is provided as a aid to help understand how Context::effective() is arrived at.
|
|
214
|
+
*
|
|
215
|
+
* @post autoAddrList==false
|
|
216
|
+
*/
|
|
217
|
+
void expand();
|
|
218
|
+
|
|
219
|
+
//! Create a new Server using the current configuration.
|
|
220
|
+
inline Server build() const {
|
|
221
|
+
return Server(*this);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
#ifdef PVXS_EXPERT_API_ENABLED
|
|
225
|
+
// for protocol compatibility testing
|
|
226
|
+
inline Config& overrideSendBE(bool be) { BE = be; return *this; }
|
|
227
|
+
inline bool sendBE() const { return BE; }
|
|
228
|
+
inline Config& overrideShareUDP(bool share) { UDP = share; return *this; }
|
|
229
|
+
inline bool shareUDP() const { return UDP; }
|
|
230
|
+
#endif
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
PVXS_API
|
|
234
|
+
std::ostream& operator<<(std::ostream& strm, const Config& conf);
|
|
235
|
+
|
|
236
|
+
}} // namespace pvxs::server
|
|
237
|
+
|
|
238
|
+
#endif // PVXS_SERVER_H
|