ChimeraTK-ControlSystemAdapter-OPCUAAdapter  04.00.01
csa_opcua_adapter_example2.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ChimeraTKs ControlSystem-OPC-UA-Adapter.
3  *
4  * ChimeraTKs ControlSystem-OPC-UA-Adapter is free software: you can
5  * redistribute it and/or modify it under the terms of the Lesser GNU
6  * General Public License as published by the Free Software Foundation,
7  * either version 3 of the License, or (at your option) any later version.
8  *
9  * ChimeraTKs ControlSystem-OPC-UA-Adapter is distributed in the hope
10  * that it will be useful, but WITHOUT ANY WARRANTY; without even the
11  * implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the Lesser GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Foobar. If not, see https://www.gnu.org/licenses/lgpl.html
16  *
17  * Copyright (c) 2016 Chris Iatrou <Chris_Paul.Iatrou@tu-dresden.de>
18  * Copyright (c) 2016 Julian Rahm <Julian.Rahm@tu-dresden.de>
19  * Copyright (c) 2018-2019 Andreas Ebner <Andreas.Ebner@iosb.fraunhofer.de>
20  */
21 
22 extern "C" {
23 #include "csa_namespace.h"
24 
25 #include <signal.h>
26 #include <unistd.h>
27 }
28 
29 #include <ChimeraTK/ControlSystemAdapter/ApplicationBase.h>
30 #include <ChimeraTK/ControlSystemAdapter/DevicePVManager.h>
31 
32 #include <chrono>
33 #include <errno.h>
34 #include <iostream>
35 #include <stdlib.h>
36 
37 using namespace std;
38 using namespace ChimeraTK;
39 
40 struct MyApp : public ApplicationBase {
41  MyApp() : ApplicationBase("opcuaAdapter") {}
42  ~MyApp() { shutdown(); }
43 
44  void run() { cout << "Application run..." << endl; }
45 
46  void shutdown() {
47  ApplicationBase::shutdown();
48  cout << "Application shutdown..." << endl;
49  }
50 
51  void initialise() {
52  boost::shared_ptr<DevicePVManager> devManager = this->_processVariableManager;
53 
54  // Generate dummy data
55  ProcessArray<int8_t>::SharedPtr intA8dev = this->_processVariableManager->createProcessArray<int8_t>(
56  SynchronizationDirection::controlSystemToDevice, "int8Scalar", 1, "Iatrou^2/Rahm");
57  ProcessArray<uint8_t>::SharedPtr intAu8dev = this->_processVariableManager->createProcessArray<uint8_t>(
58  SynchronizationDirection::controlSystemToDevice, "uint8Scalar", 1, "mIatrou*Rahm");
59  ProcessArray<int16_t>::SharedPtr intA16dev = this->_processVariableManager->createProcessArray<int16_t>(
60  SynchronizationDirection::controlSystemToDevice, "int16Scalar", 1);
61  ProcessArray<uint16_t>::SharedPtr intAu16dev = this->_processVariableManager->createProcessArray<uint16_t>(
62  SynchronizationDirection::controlSystemToDevice, "uint16Scalar", 1);
63  ProcessArray<int32_t>::SharedPtr intA32dev = this->_processVariableManager->createProcessArray<int32_t>(
64  SynchronizationDirection::controlSystemToDevice, "int32Scalar", 1);
65  ProcessArray<uint32_t>::SharedPtr intAu32dev = this->_processVariableManager->createProcessArray<uint32_t>(
66  SynchronizationDirection::controlSystemToDevice, "uint32Scalar", 1);
67  ProcessArray<float>::SharedPtr intAfdev = this->_processVariableManager->createProcessArray<float>(
68  SynchronizationDirection::controlSystemToDevice, "floatScalar", 1);
69  ProcessArray<double>::SharedPtr intAddev = this->_processVariableManager->createProcessArray<double>(
70  SynchronizationDirection::controlSystemToDevice, "doubleScalar", 1);
71  ProcessArray<string>::SharedPtr stringAddev =
72  devManager->createProcessArray<string>(SynchronizationDirection::controlSystemToDevice, "stringScalar", 1);
73  ProcessArray<string>::SharedPtr stringAddev2 = devManager->createProcessArray<string>(
74  SynchronizationDirection::deviceToControlSystem, "1/FOLDER/defaultSep/stringScalar", 1, "my unit", "desc");
75 
76  ProcessArray<int8_t>::SharedPtr intB15A8dev =
77  this->_processVariableManager->createProcessArray<int8_t>(SynchronizationDirection::controlSystemToDevice,
78  "int8Array_s15", 15, "mIatrou*Rahm", "Die Einheit ist essentiel und sollte SI Einheit sein...");
79  ProcessArray<uint8_t>::SharedPtr intB10Au8dev = this->_processVariableManager->createProcessArray<uint8_t>(
80  SynchronizationDirection::controlSystemToDevice, "uint8Array_s10", 10, "1/Rahm");
81  ProcessArray<int16_t>::SharedPtr intB15A16dev = this->_processVariableManager->createProcessArray<int16_t>(
82  SynchronizationDirection::controlSystemToDevice, "int16Array_s15", 15, "Iatrou", "Beschreibung eines Iatrous");
83  ProcessArray<uint16_t>::SharedPtr intB10Au16dev = this->_processVariableManager->createProcessArray<uint16_t>(
84  SynchronizationDirection::controlSystemToDevice, "uint16Array_s10", 10);
85  ProcessArray<int32_t>::SharedPtr intB15A32dev = this->_processVariableManager->createProcessArray<int32_t>(
86  SynchronizationDirection::controlSystemToDevice, "int32Array_s15", 15);
87  ProcessArray<uint32_t>::SharedPtr intB10Au32dev = this->_processVariableManager->createProcessArray<uint32_t>(
88  SynchronizationDirection::controlSystemToDevice, "uint32Array_s10", 10);
89  ProcessArray<double>::SharedPtr intB15Afdev = this->_processVariableManager->createProcessArray<double>(
90  SynchronizationDirection::controlSystemToDevice, "doubleArray_s15", 15);
91  ProcessArray<float>::SharedPtr intB10Addev = this->_processVariableManager->createProcessArray<float>(
92  SynchronizationDirection::controlSystemToDevice, "floatArray_s10", 10);
93 
94  // example mapping variable
95  ProcessArray<int8_t>::SharedPtr intB15A8devMap = devManager->createProcessArray<int8_t>(
96  SynchronizationDirection::controlSystemToDevice, "Mein/Name_ist#int8Array_s15", 15, "Iatrou^2/Rahm");
97  ProcessArray<int8_t>::SharedPtr intB15A8devMap2 = devManager->createProcessArray<int8_t>(
98  SynchronizationDirection::controlSystemToDevice, "Mein/Name_ist#int8Array", 15, "Iatrou^2/Rahm");
99  ProcessArray<uint8_t>::SharedPtr intB10Au8devMap1 =
100  devManager->createProcessArray<uint8_t>(SynchronizationDirection::controlSystemToDevice,
101  "/Dein/Name//ist/uint8Array_s10", 10, "Iatrou^2/Rahm", "Beschreibung");
102  ProcessArray<uint8_t>::SharedPtr intB10Au8devMap2 = devManager->createProcessArray<uint8_t>(
103  SynchronizationDirection::controlSystemToDevice, "Unser/Name/ist_uint8Array_s10", 10);
104  ProcessArray<uint32_t>::SharedPtr intAu32devMap = devManager->createProcessArray<uint32_t>(
105  SynchronizationDirection::controlSystemToDevice, "Ist/Name/dieser/uint32Scalar", 1);
106  ProcessArray<int32_t>::SharedPtr intA32devMap = devManager->createProcessArray<int32_t>(
107  SynchronizationDirection::controlSystemToDevice, "Ist/Name/dieser/int32Scalar", 1);
108  ProcessArray<double>::SharedPtr doubledevMap = devManager->createProcessArray<double>(
109  SynchronizationDirection::controlSystemToDevice, "Ist/Name/dieser/doubleScalar", 1);
110  }
111 };
112 
myApp
MyApp myApp
Definition: csa_opcua_adapter_example2.cpp:113
devManager
boost::shared_ptr< ChimeraTK::DevicePVManager > devManager
Definition: csa_opcua_application.cpp:60
csa_namespace.h
MyApp::run
void run()
Definition: csa_opcua_adapter_example2.cpp:44
MyApp
Definition: csa_opcua_adapter_example2.cpp:40
MyApp::initialise
void initialise()
Definition: csa_opcua_adapter_example2.cpp:51
MyApp::~MyApp
~MyApp()
Definition: csa_opcua_adapter_example2.cpp:42
ChimeraTK
Definition: csa_additionalvariable.h:28
MyApp::MyApp
MyApp()
Definition: csa_opcua_adapter_example2.cpp:41
MyApp::shutdown
void shutdown()
Definition: csa_opcua_adapter_example2.cpp:46