ChimeraTK-ControlSystemAdapter-OPCUAAdapter  04.00.01
test_sample_data.h
Go to the documentation of this file.
1 #ifndef _TEST_SAMPLE_DATA_H_
2 #define _TEST_SAMPLE_DATA_H_
3 
4 #include "ChimeraTK/ControlSystemAdapter/ControlSystemPVManager.h"
5 #include "ChimeraTK/ControlSystemAdapter/DevicePVManager.h"
6 #include "ChimeraTK/ControlSystemAdapter/ProcessArray.h"
7 #include "ChimeraTK/ControlSystemAdapter/PVManager.h"
8 
9 extern "C" {
10 #include "csa_namespace.h"
11 #include "unistd.h"
12 }
13 
14 #include <open62541/client.h>
15 #include <open62541/client_config_default.h>
16 #include <open62541/client_highlevel.h>
17 #include <open62541/server_config_default.h>
18 
19 using namespace ChimeraTK;
20 using namespace std;
21 
23  std::pair<boost::shared_ptr<ControlSystemPVManager>, boost::shared_ptr<DevicePVManager>> pvManagers;
24  boost::shared_ptr<ControlSystemPVManager> csManager;
25  boost::shared_ptr<DevicePVManager> devManager;
26 
27  TestFixtureEmptySet() : pvManagers(createPVManager()), csManager(pvManagers.first), devManager(pvManagers.second) {
28  std::cout << "TestFixtureEmptySet BEGIN" << std::endl;
29  std::cout << "TestFixtureEmptySet END" << std::endl;
30  }
31 };
32 
34  std::pair<boost::shared_ptr<ControlSystemPVManager>, boost::shared_ptr<DevicePVManager>> pvManagers;
35  boost::shared_ptr<ControlSystemPVManager> csManager;
36  boost::shared_ptr<DevicePVManager> devManager;
37 
38  TestFixturePVSet() : pvManagers(createPVManager()), csManager(pvManagers.first), devManager(pvManagers.second) {
39  std::cout << "TestFixturePVSet BEGIN" << std::endl;
40 
41  // Testset
42  ProcessArray<int8_t>::SharedPtr intA8dev = devManager->createProcessArray<int8_t>(
43  SynchronizationDirection::controlSystemToDevice, "int8Scalar", 1, "Einheit", "Beschreibung der Variable");
44  ProcessArray<uint8_t>::SharedPtr intAu8dev =
45  devManager->createProcessArray<uint8_t>(SynchronizationDirection::controlSystemToDevice, "uint8Scalar", 1);
46  ProcessArray<int16_t>::SharedPtr intA16dev =
47  devManager->createProcessArray<int16_t>(SynchronizationDirection::controlSystemToDevice, "int16Scalar", 1);
48  ProcessArray<uint16_t>::SharedPtr intAu16dev =
49  devManager->createProcessArray<uint16_t>(SynchronizationDirection::controlSystemToDevice, "uint16Scalar", 1);
50  ProcessArray<int32_t>::SharedPtr intA3devMap = devManager->createProcessArray<int32_t>(
51  SynchronizationDirection::controlSystemToDevice, "Dein/Name/ist/int32Scalar", 1);
52  ProcessArray<uint32_t>::SharedPtr intAu32devMap = devManager->createProcessArray<uint32_t>(
53  SynchronizationDirection::controlSystemToDevice, "Mein/Name/ist/uint32Scalar", 1);
54  ProcessArray<int64_t>::SharedPtr intA64devMap = devManager->createProcessArray<int64_t>(
55  SynchronizationDirection::controlSystemToDevice, "Mein/Name/ist/int64Scalar", 1);
56  ProcessArray<uint64_t>::SharedPtr intAu64devMap = devManager->createProcessArray<uint64_t>(
57  SynchronizationDirection::controlSystemToDevice, "Mein/Name/ist/uint64Scalar", 1);
58  ProcessArray<float>::SharedPtr intAfdev =
59  devManager->createProcessArray<float>(SynchronizationDirection::controlSystemToDevice, "floatScalar", 1);
60  ProcessArray<double>::SharedPtr doubledevMap = devManager->createProcessArray<double>(
61  SynchronizationDirection::controlSystemToDevice, "Dieser/Name/ist/doubleScalar", 1);
62  ProcessArray<string>::SharedPtr stringAddev2 =
63  devManager->createProcessArray<string>(SynchronizationDirection::deviceToControlSystem,
64  "1/FOLDER/defaultSep/stringScalar", 1, "my description", "desc");
65 
66  ProcessArray<int8_t>::SharedPtr intB15A8devMap =
67  devManager->createProcessArray<int8_t>(SynchronizationDirection::controlSystemToDevice,
68  "Mein/Name_ist#int8Array_s15", 15, "Einheit", "Beschreibung der Variable");
69  ProcessArray<uint8_t>::SharedPtr intB10Au8devMap1 = devManager->createProcessArray<uint8_t>(
70  SynchronizationDirection::controlSystemToDevice, "Dein/Name/ist/uint8Array_s10", 10);
71  ProcessArray<int16_t>::SharedPtr intB10Au16devMap2 = devManager->createProcessArray<int16_t>(
72  SynchronizationDirection::controlSystemToDevice, "Unser/Name/ist_int16Array_s10", 12);
73  ProcessArray<uint16_t>::SharedPtr intB10Au8devMap2 =
74  devManager->createProcessArray<uint16_t>(SynchronizationDirection::controlSystemToDevice,
75  "Unser/Name/ist_uint8Array_s10", 10, "Einheit", "Beschreibung der Variable");
76  ProcessArray<int32_t>::SharedPtr intB15A32dev =
77  devManager->createProcessArray<int32_t>(SynchronizationDirection::controlSystemToDevice, "int32Array_s15", 15);
78  ProcessArray<uint32_t>::SharedPtr intB10Au32dev = devManager->createProcessArray<uint32_t>(
79  SynchronizationDirection::controlSystemToDevice, "uint32Array_s10", 10);
80  ProcessArray<int64_t>::SharedPtr intB15A64dev =
81  devManager->createProcessArray<int64_t>(SynchronizationDirection::controlSystemToDevice, "int64Array_s15", 15);
82  ProcessArray<uint64_t>::SharedPtr intB15Au64dev = devManager->createProcessArray<uint64_t>(
83  SynchronizationDirection::controlSystemToDevice, "uint64Array_s10", 10);
84  ProcessArray<double>::SharedPtr intB15Afdev =
85  devManager->createProcessArray<double>(SynchronizationDirection::controlSystemToDevice, "doubleArray_s15", 15);
86  ProcessArray<float>::SharedPtr intB10Addev = devManager->createProcessArray<float>(
87  SynchronizationDirection::controlSystemToDevice, "floatArray_s101234", 10);
88 
89  std::cout << "TestFixturePVSet END" << std::endl;
90  }
91 };
92 
94  uint32_t opcuaPort = 16663;
95  /* Create new Server */
96  UA_ServerConfig* server_config;
97  UA_Server* mappedServer{nullptr};
98  UA_NodeId baseNodeId;
99  UA_Boolean runUAServer;
100 
102  this->mappedServer = UA_Server_new();
103  UA_ServerConfig_setMinimal(UA_Server_getConfig(this->mappedServer), opcuaPort, NULL);
104  server_config = UA_Server_getConfig(mappedServer);
105 
106  runUAServer = UA_TRUE;
107  baseNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
108 
109  csa_namespace_init(mappedServer);
110  }
111 
113  if(mappedServer != nullptr) UA_Server_delete(mappedServer);
114  }
115 };
116 
117 #endif // _TEST_SAMPLE_DATA_H_
TestFixtureEmptySet::devManager
boost::shared_ptr< DevicePVManager > devManager
Definition: test_sample_data.h:25
TestFixturePVSet::TestFixturePVSet
TestFixturePVSet()
Definition: test_sample_data.h:38
TestFixtureServerSet::runUAServer
UA_Boolean runUAServer
Definition: test_sample_data.h:99
devManager
boost::shared_ptr< ChimeraTK::DevicePVManager > devManager
Definition: csa_opcua_application.cpp:60
csa_namespace.h
TestFixturePVSet::pvManagers
std::pair< boost::shared_ptr< ControlSystemPVManager >, boost::shared_ptr< DevicePVManager > > pvManagers
Definition: test_sample_data.h:34
TestFixtureEmptySet::pvManagers
std::pair< boost::shared_ptr< ControlSystemPVManager >, boost::shared_ptr< DevicePVManager > > pvManagers
Definition: test_sample_data.h:23
TestFixturePVSet
Definition: test_sample_data.h:33
TestFixtureEmptySet::csManager
boost::shared_ptr< ControlSystemPVManager > csManager
Definition: test_sample_data.h:24
TestFixturePVSet::csManager
boost::shared_ptr< ControlSystemPVManager > csManager
Definition: test_sample_data.h:35
csManager
boost::shared_ptr< ChimeraTK::ControlSystemPVManager > csManager
Definition: csa_opcua_application.cpp:59
csa_namespace_init
UA_StatusCode csa_namespace_init(UA_Server *server)
Definition: csa_namespace.c:101
TestFixtureServerSet::server_config
UA_ServerConfig * server_config
Definition: test_sample_data.h:96
TestFixtureServerSet::TestFixtureServerSet
TestFixtureServerSet()
Definition: test_sample_data.h:101
TestFixtureEmptySet
Definition: test_sample_data.h:22
TestFixturePVSet::devManager
boost::shared_ptr< DevicePVManager > devManager
Definition: test_sample_data.h:36
TestFixtureServerSet
Definition: test_sample_data.h:93
TestFixtureServerSet::~TestFixtureServerSet
~TestFixtureServerSet()
Definition: test_sample_data.h:112
TestFixtureServerSet::baseNodeId
UA_NodeId baseNodeId
Definition: test_sample_data.h:98
TestFixtureEmptySet::TestFixtureEmptySet
TestFixtureEmptySet()
Definition: test_sample_data.h:27
ChimeraTK
Definition: csa_additionalvariable.h:28