UniSet 2.35.2
OPCUATestServer.h
1#ifndef OPCUATestServer_H_
2#define OPCUATestServer_H_
3// -------------------------------------------------------------------------
4#include <string>
5#include <atomic>
6#include <ostream>
7#include "open62541pp/open62541pp.h"
8#include "ThreadCreator.h"
9// -------------------------------------------------------------------------
12{
13 public:
14 OPCUATestServer( const std::string& addr, uint16_t port = 4840 );
16
17 inline void setVerbose( bool state )
18 {
19 verbose = state;
20 }
21
22 void start();
23 void stop();
24 bool isRunning();
25 void setI32( const std::string& varname, int32_t val );
26 void setBool( const std::string& varname, bool set );
27 void setI32( int num, int32_t val );
28 void setF32( const std::string& varname, float val );
29 void setRWLimits(unsigned int rlim, unsigned int wlim);
30
31 void setX( int num, int32_t val, opcua::DataTypeId type );
32 int32_t getX( int num, opcua::DataTypeId type );
33
34 int32_t getI32( int num );
35 int32_t getI32( const std::string& name );
36 float getF32( const std::string& name );
37 bool getBool( const std::string& name );
38
39 protected:
40 void work();
41
42 struct IONode
43 {
44 opcua::Node<opcua::Server> node;
45 IONode( const opcua::Node<opcua::Server>& n ): node(n) {};
46 };
47
48 std::unique_ptr<opcua::Server> server;
49 std::unique_ptr<IONode> ioNode;
50 std::string addr;
51 bool verbose = {true};
52
53 std::unordered_map<int, std::unique_ptr<IONode>> imap;
54 std::unordered_map<std::string, std::unique_ptr<IONode>> smap;
55 std::shared_ptr< uniset::ThreadCreator<OPCUATestServer> > serverThread;
56
57 private:
58 //bool disabled;
59 std::string myname;
60};
61// -------------------------------------------------------------------------
62#endif // OPCUATestServer_H_
63// -------------------------------------------------------------------------
Definition OPCUATestServer.h:12
Definition OPCUATestServer.h:43