Skip to content

Commit

Permalink
first commit - needs renaming and rebasing later on, just to trigger CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
aentinger committed Sep 9, 2024
1 parent 8edb620 commit 4344375
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
.idea/
node_modules
doxygen-build/
44 changes: 43 additions & 1 deletion src/Opta.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,84 @@ namespace opcua
* CLASS DECLARATION
**************************************************************************************/

/**
* @class Opta
* @brief Provides functions for exposing various IO capabilities of the Arduino Opta via OPC UA.
*
* This class allows the user to expose analog and digital inputs, as well as relay and LED outputs
* via OPC UA properties.
*/
class Opta
{
public:
typedef std::shared_ptr<Opta> SharedPtr;


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


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


/**
* Adds an analog input to the opcua::Opta object node and exposes it as an OPC UA variable node.
* @param server Pointer to the OPC UA server implementation of the open62541 library.
* @param display_name Character string providing an easy identifiable name for the variable node.
* @param on_read_request_func Function pointer which is called during a read-access on the variable node representing the analog input.
*/
void
add_analog_input(
UA_Server * server,
const char * display_name,
AnalogInput::OnReadRequestFunc const on_read_request_func);

/**
* Adds a digital input to the opcua::Opta object node and exposes it as an OPC UA variable node.
* @param server Pointer to the OPC UA server implementation of the open62541 library.
* @param display_name Character string providing an easy identifiable name for the variable node.
* @param on_read_request_func Function pointer which is called during a read-access on the variable node representing the digital input.
*/
void
add_digital_input(
UA_Server * server,
const char * display_name,
DigitalInput::OnReadRequestFunc const on_read_request_func);

/**
* Adds a relay output to the opcua::Opta object node and exposes it as an OPC UA variable node.
* @param server Pointer to the OPC UA server implementation of the open62541 library.
* @param display_name Character string providing an easy identifiable name for the variable node.
* @param on_set_relay_state Function pointer which is called during a write-access on the variable node representing the relay output.
*/
void
add_relay_output(
UA_Server * server,
const char * display_name,
Relay::OnSetRelayStateFunc const on_set_relay_state);

/**
* Adds a LED output to the opcua::Opta object node and exposes it as an OPC UA variable node.
* @param server Pointer to the OPC UA server implementation of the open62541 library.
* @param display_name Character string providing an easy identifiable name for the variable node.
* @param on_set_led_state Function pointer which is called during a write-access on the variable node representing the LED output.
*/
void
add_led_output(
UA_Server * server,
Expand Down
46 changes: 43 additions & 3 deletions src/OptaExpansionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,68 @@ namespace opcua
* CLASS DECLARATION
**************************************************************************************/

/**
* @class OptaExpansionManager
* @brief High-level class to create OPC UA representations for Arduino Opta digital and analog expansion boards.
*
* This class allows the user to create OPC UA representations of digital (mechanical and solid-state relays) as
* well as analog expansion boards connected to the Arduino Opta.
*/
class OptaExpansionManager
{
public:
typedef std::shared_ptr<OptaExpansionManager> SharedPtr;


/**
* Creates a new instance of the opcua::OptaExpansionManager class.
* @param server Pointer to the OPC UA server implementation of the open62541 library.
* @return std::shared_ptr holding the newly allocated instance of opcua::OptaExpansionManager.
*/
static SharedPtr
create(
UA_Server * server) {
return std::make_shared<OptaExpansionManager>(server);
}


/**
* Constructor of the opcua::OptaExpansionManager class.
* @param server Pointer to the OPC UA server implementation of the open62541 library.
*/
OptaExpansionManager(
UA_Server * server)
: _server{server}
{ }


DigitalMechExpansion::SharedPtr create_digital_mechanical_expansion(uint8_t const exp_num);
DigitalStSolidExpansion::SharedPtr create_digital_solid_state_expansion(uint8_t const exp_num);
AnalogExpansion::SharedPtr create_analog_expansion(uint8_t const exp_num);
/**
* Creates a new instance of the opcua::DigitalMechExpansion (digital expansion with mechanical relays) class.
* @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.
* @return std::shared_ptr holding the newly allocated instance of opcua::DigitalMechExpansion.
*/
DigitalMechExpansion::SharedPtr
create_digital_mechanical_expansion(
uint8_t const exp_num);

/**
* Creates a new instance of the opcua::DigitalStSolidExpansion (digital expansion with solid-state relays) class.
* @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.
* @return std::shared_ptr holding the newly allocated instance of opcua::DigitalStSolidExpansion.
*/
DigitalStSolidExpansion::SharedPtr
create_digital_solid_state_expansion(
uint8_t const exp_num);

/**
* Creates a new instance of the opcua::AnalogExpansion class.
* @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.
* @return std::shared_ptr holding the newly allocated instance of opcua::AnalogExpansion.
*/
AnalogExpansion::SharedPtr
create_analog_expansion(
uint8_t const exp_num);


private:
UA_Server * _server;
Expand Down
23 changes: 23 additions & 0 deletions src/OptaVariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ namespace opcua
* CLASS DECLARATION
**************************************************************************************/

/**
* @class OptaVariant
* @brief Enables determination of Opta variant (WiFi, RS485, Lite) on which the OPC UA firmware is running on.
*
* This class allows the user to determine the concrete Opta variant (WiFi, RS485, Lite) on which the OPC UA
* firmware is running on. This is archived by interrogating information stored by the bootloader.
*/
class OptaVariant
{
public:
Expand All @@ -36,13 +43,29 @@ class OptaVariant
enum class Type { Lite, RS485, WiFi };


/**
* Determines the current Opta variant by reading information provided by the bootloader.
* @param type Output parameter containing the current Opta variant.
* @return True if the Opta variant could be obtained successfully.
*/
static bool
get_opta_variant(
Type & type);

/**
* Convert enumerated variant type to variant product name.
* @param type Enumerated type describing an Opta variant.
* @return String describing the Opta variant's product name, i.e. Type::Lite -> "Arduino Opta Lite"
*/
static std::string
toString(
Type const type);

/**
* Convert enumerated variant type to variant product SKU number.
* @param type Enumerated type describing an Opta variant.
* @return String describing the Opta variant's SKU number, i.e. Type::Lite -> "AFX00003"
*/
static std::string
toSKUString(
Type const type);
Expand Down
8 changes: 8 additions & 0 deletions src/io/analog/AnalogInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ class AnalogInput
typedef std::function<float(void)> OnReadRequestFunc;


/**
* Creates a new instance of the opcua::AnalogInput class, creating an OPC UA variable node abstraction in the process.
* @param server Pointer to the OPC UA server implementation of the open62541 library.
* @param UA_NodeId OPC UA node id of parent object in OPC UA tree.
* @param display_name Character string providing an easy identifiable name for the variable node representing an analog input, i.e. "Analog Input 0".
* @param on_read_request_func Function pointer which is called during a read-access on the variable node representing the analog input.
* @return std::shared_ptr holding the newly allocated instance of opcua::Opta.
*/
static SharedPtr
create(
UA_Server * server,
Expand Down

0 comments on commit 4344375

Please sign in to comment.