Skip to content

Commit 690e3f6

Browse files
authored
Document Arduino_open62541 library using Doxygen and "render-docs" tool. (#19)
1 parent 8edb620 commit 690e3f6

34 files changed

+1732
-272
lines changed

.github/workflows/render-documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ jobs:
2525
with:
2626
source-path: './src'
2727
target-path: './docs/api.md'
28-
exclude-pattern: '*/open62541/* open62541.h'
28+
exclude-pattern: '*/open62541/* open62541.h o1heap.h'
2929
commit: ${{ github.event_name != 'pull_request' }} # Only commit changes if not a PR

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.vscode/
22
.idea/
33
node_modules
4+
doxygen-build/
5+
moxygen.log

docs/api.md

Lines changed: 854 additions & 231 deletions
Large diffs are not rendered by default.

src/Opta.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,18 @@ void
146146
Opta::add_analog_input(
147147
UA_Server * server,
148148
const char * display_name,
149-
AnalogInput::OnReadRequestFunc const on_read_request_func)
149+
AnalogInput::OnReadRequestFunc const on_read_request)
150150
{
151-
_analog_input_mgr->add_analog_input(server, display_name, on_read_request_func);
151+
_analog_input_mgr->add_analog_input(server, display_name, on_read_request);
152152
}
153153

154154
void
155155
Opta::add_digital_input(
156156
UA_Server * server,
157157
const char * display_name,
158-
DigitalInput::OnReadRequestFunc const on_read_request_func)
158+
DigitalInput::OnReadRequestFunc const on_read_request)
159159
{
160-
_digital_input_mgr->add_digital_input(server, display_name, on_read_request_func);
160+
_digital_input_mgr->add_digital_input(server, display_name, on_read_request);
161161
}
162162

163163
void

src/Opta.h

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,100 @@
2929
* NAMESPACE
3030
**************************************************************************************/
3131

32+
/**
33+
* opcua is used as enclosing namespace for all parts of the Arduino_open62541 library
34+
* in order to avoid naming conflicts with already existing frameworks pertaining the
35+
* Arduino Opta.
36+
*/
3237
namespace opcua
3338
{
3439

3540
/**************************************************************************************
3641
* CLASS DECLARATION
3742
**************************************************************************************/
3843

44+
/**
45+
* @class Opta
46+
* @brief Provides functions for exposing various IO capabilities of the Arduino Opta via OPC UA.
47+
*
48+
* This class allows the user to expose analog and digital inputs, as well as relay and LED outputs
49+
* via OPC UA properties.
50+
*/
3951
class Opta
4052
{
4153
public:
54+
/**
55+
* SharedPtr is std::shared_ptr of an Opta class.
56+
*/
4257
typedef std::shared_ptr<Opta> SharedPtr;
4358

4459

60+
/**
61+
* Creates a new instance of the opcua::Opta class, creating an OPC UA object abstraction in the process.
62+
* @param server Pointer to the OPC UA server implementation of the open62541 library.
63+
* @param opta_type Enumerated type describing which Opta (WiFi, RS485, Lite) variant is being created.
64+
* @return std::shared_ptr holding the newly allocated instance of opcua::Opta.
65+
*/
4566
static SharedPtr
4667
create(
4768
UA_Server * server,
4869
OptaVariant::Type const opta_type);
4970

5071

72+
/**
73+
* Constructor of the opcua::Opta class.
74+
* @param server Pointer to the OPC UA server implementation of the open62541 library.
75+
* @param node_id OPC UA node id uniquely identifying the OPC UA representation of the opcua::Opta class as an OPC UA object node.
76+
* @param opta_type Enumerated type describing which Opta (WiFi, RS485, Lite) variant is being created.
77+
*/
5178
Opta(
5279
UA_Server * server,
5380
UA_NodeId const & node_id,
5481
OptaVariant::Type const opta_type);
5582

5683

84+
/**
85+
* Adds an analog input to the opcua::Opta object node and exposes it as an OPC UA variable node.
86+
* @param server Pointer to the OPC UA server implementation of the open62541 library.
87+
* @param display_name Character string providing an easy identifiable name for the variable node.
88+
* @param on_read_request Function pointer which is called during a read-access on the variable node representing the analog input.
89+
*/
5790
void
5891
add_analog_input(
5992
UA_Server * server,
6093
const char * display_name,
61-
AnalogInput::OnReadRequestFunc const on_read_request_func);
62-
94+
AnalogInput::OnReadRequestFunc const on_read_request);
95+
96+
/**
97+
* Adds a digital input to the opcua::Opta object node and exposes it as an OPC UA variable node.
98+
* @param server Pointer to the OPC UA server implementation of the open62541 library.
99+
* @param display_name Character string providing an easy identifiable name for the variable node.
100+
* @param on_read_request Function pointer which is called during a read-access on the variable node representing the digital input.
101+
*/
63102
void
64103
add_digital_input(
65104
UA_Server * server,
66105
const char * display_name,
67-
DigitalInput::OnReadRequestFunc const on_read_request_func);
68-
106+
DigitalInput::OnReadRequestFunc const on_read_request);
107+
108+
/**
109+
* Adds a relay output to the opcua::Opta object node and exposes it as an OPC UA variable node.
110+
* @param server Pointer to the OPC UA server implementation of the open62541 library.
111+
* @param display_name Character string providing an easy identifiable name for the variable node.
112+
* @param on_set_relay_state Function pointer which is called during a write-access on the variable node representing the relay output.
113+
*/
69114
void
70115
add_relay_output(
71116
UA_Server * server,
72117
const char * display_name,
73118
Relay::OnSetRelayStateFunc const on_set_relay_state);
74119

120+
/**
121+
* Adds a LED output to the opcua::Opta object node and exposes it as an OPC UA variable node.
122+
* @param server Pointer to the OPC UA server implementation of the open62541 library.
123+
* @param display_name Character string providing an easy identifiable name for the variable node.
124+
* @param on_set_led_state Function pointer which is called during a write-access on the variable node representing the LED output.
125+
*/
75126
void
76127
add_led_output(
77128
UA_Server * server,

src/OptaExpansionManager.h

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,71 @@ namespace opcua
3232
* CLASS DECLARATION
3333
**************************************************************************************/
3434

35+
/**
36+
* @class OptaExpansionManager
37+
* @brief High-level class to create OPC UA representations for Arduino Opta digital and analog expansion boards.
38+
*
39+
* This class allows the user to create OPC UA representations of digital (mechanical and solid-state relays) as
40+
* well as analog expansion boards connected to the Arduino Opta.
41+
*/
3542
class OptaExpansionManager
3643
{
3744
public:
45+
/**
46+
* SharedPtr is std::shared_ptr of an OptaExpansionManager class.
47+
*/
3848
typedef std::shared_ptr<OptaExpansionManager> SharedPtr;
3949

4050

51+
/**
52+
* Creates a new instance of the opcua::OptaExpansionManager class.
53+
* @param server Pointer to the OPC UA server implementation of the open62541 library.
54+
* @return std::shared_ptr holding the newly allocated instance of opcua::OptaExpansionManager.
55+
*/
4156
static SharedPtr
4257
create(
4358
UA_Server * server) {
4459
return std::make_shared<OptaExpansionManager>(server);
4560
}
4661

4762

63+
/**
64+
* Constructor of the opcua::OptaExpansionManager class.
65+
* @param server Pointer to the OPC UA server implementation of the open62541 library.
66+
*/
4867
OptaExpansionManager(
4968
UA_Server * server)
5069
: _server{server}
5170
{ }
5271

5372

54-
DigitalMechExpansion::SharedPtr create_digital_mechanical_expansion(uint8_t const exp_num);
55-
DigitalStSolidExpansion::SharedPtr create_digital_solid_state_expansion(uint8_t const exp_num);
56-
AnalogExpansion::SharedPtr create_analog_expansion(uint8_t const exp_num);
73+
/**
74+
* Creates a new instance of the opcua::DigitalMechExpansion (digital expansion with mechanical relays) class.
75+
* @param exp_num A numerical identifier provided by the Arduino_Opta_Blueprint library and identifying the number of the expansion module in the daisy-chain of expansion modules, i.e. exp_num = 2 refers to the second connect expansion module.
76+
* @return std::shared_ptr holding the newly allocated instance of opcua::DigitalMechExpansion.
77+
*/
78+
DigitalMechExpansion::SharedPtr
79+
create_digital_mechanical_expansion(
80+
uint8_t const exp_num);
81+
82+
/**
83+
* Creates a new instance of the opcua::DigitalStSolidExpansion (digital expansion with solid-state relays) class.
84+
* @param exp_num A numerical identifier provided by the Arduino_Opta_Blueprint library and identifying the number of the expansion module in the daisy-chain of expansion modules, i.e. exp_num = 2 refers to the second connect expansion module.
85+
* @return std::shared_ptr holding the newly allocated instance of opcua::DigitalStSolidExpansion.
86+
*/
87+
DigitalStSolidExpansion::SharedPtr
88+
create_digital_solid_state_expansion(
89+
uint8_t const exp_num);
90+
91+
/**
92+
* Creates a new instance of the opcua::AnalogExpansion class.
93+
* @param exp_num A numerical identifier provided by the Arduino_Opta_Blueprint library and identifying the number of the expansion module in the daisy-chain of expansion modules, i.e. exp_num = 2 refers to the second connect expansion module.
94+
* @return std::shared_ptr holding the newly allocated instance of opcua::AnalogExpansion.
95+
*/
96+
AnalogExpansion::SharedPtr
97+
create_analog_expansion(
98+
uint8_t const exp_num);
99+
57100

58101
private:
59102
UA_Server * _server;

src/OptaVariant.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,63 @@ namespace opcua
2626
* CLASS DECLARATION
2727
**************************************************************************************/
2828

29+
/**
30+
* @class OptaVariant
31+
* @brief Enables determination of Opta variant (WiFi, RS485, Lite) on which the OPC UA firmware is running on.
32+
*
33+
* This class allows the user to determine the concrete Opta variant (WiFi, RS485, Lite) on which the OPC UA
34+
* firmware is running on. This is archived by interrogating information stored by the bootloader.
35+
*/
2936
class OptaVariant
3037
{
3138
public:
39+
/**
40+
* The constructor of OptaVariant is deleted because this object shall not be instantiated.
41+
*/
3242
OptaVariant() = delete;
43+
/**
44+
* The copy constructor of OptaVariant is deleted because this object shall not be copied.
45+
*/
3346
OptaVariant(OptaVariant const &) = delete;
3447

3548

36-
enum class Type { Lite, RS485, WiFi };
49+
/**
50+
* Type is an enumeration type to describe the various different Arduino Opta variants.
51+
*/
52+
enum class Type
53+
{
54+
/** Arduino Opta Lite */
55+
Lite,
56+
/** Arduino Opta RS485 */
57+
RS485,
58+
/** Arduino Opta WiFi */
59+
WiFi
60+
};
3761

3862

63+
/**
64+
* Determines the current Opta variant by reading information provided by the bootloader.
65+
* @param type Output parameter containing the current Opta variant.
66+
* @return True if the Opta variant could be obtained successfully.
67+
*/
3968
static bool
4069
get_opta_variant(
4170
Type & type);
4271

72+
/**
73+
* Convert enumerated variant type to variant product name.
74+
* @param type Enumerated type describing an Opta variant.
75+
* @return String describing the Opta variant's product name, i.e. Type::Lite -> "Arduino Opta Lite"
76+
*/
4377
static std::string
4478
toString(
4579
Type const type);
80+
81+
/**
82+
* Convert enumerated variant type to variant product SKU number.
83+
* @param type Enumerated type describing an Opta variant.
84+
* @return String describing the Opta variant's SKU number, i.e. Type::Lite -> "AFX00003"
85+
*/
4686
static std::string
4787
toSKUString(
4888
Type const type);

src/expansion/AnalogExpansion.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ void
6969
AnalogExpansion::add_analog_input(
7070
UA_Server * server,
7171
const char * display_name,
72-
AnalogInput::OnReadRequestFunc const on_read_request_func)
72+
AnalogInput::OnReadRequestFunc const on_read_request)
7373
{
74-
_analog_input_mgr->add_analog_input(server, display_name, on_read_request_func);
74+
_analog_input_mgr->add_analog_input(server, display_name, on_read_request);
7575
}
7676

7777
void
7878
AnalogExpansion::add_analog_output(
7979
UA_Server * server,
8080
const char * display_name,
8181
AnalogOutput::OnReadRequestFunc const on_read_request,
82-
AnalogOutput::OnWriteRequestFunc const on_write_request_func)
82+
AnalogOutput::OnWriteRequestFunc const on_write_request)
8383
{
84-
_analog_output_mgr->add_analog_output(server, display_name, on_read_request, on_write_request_func);
84+
_analog_output_mgr->add_analog_output(server, display_name, on_read_request, on_write_request);
8585
}
8686

8787
void

0 commit comments

Comments
 (0)