UniSet 2.32.1
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
30 void setX( int num, int32_t val, opcua::Type type );
31 int32_t getX( int num, opcua::Type type );
32
33 int32_t getI32( int num );
34 int32_t getI32( const std::string& name );
35 float getF32( const std::string& name );
36 bool getBool( const std::string& name );
37
38 protected:
39 void work();
40
41 struct IONode
42 {
43 opcua::Node<opcua::Server> node;
44 IONode( const opcua::Node<opcua::Server>& n ): node(n) {};
45 };
46
47 std::unique_ptr<opcua::Server> server;
48 std::unique_ptr<IONode> ioNode;
49 std::string addr;
50 bool verbose;
51
52 std::unordered_map<int, std::unique_ptr<IONode>> imap;
53 std::unordered_map<std::string, std::unique_ptr<IONode>> smap;
54 std::shared_ptr< uniset::ThreadCreator<OPCUATestServer> > serverThread;
55
56 private:
57 bool disabled;
58 std::string myname;
59};
60// -------------------------------------------------------------------------
61#endif // OPCUATestServer_H_
62// -------------------------------------------------------------------------
Definition OPCUATestServer.h:12
Definition OPCUATestServer.h:42