-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from martinkosch/docstrings
Adding more docstrings, high level interface improvements
- Loading branch information
Showing
40 changed files
with
2,903 additions
and
878 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
gen/Manifest.toml | ||
gen/Manifest.toml | ||
.vscode/settings.json | ||
docs/Manifest.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,103 @@ | ||
# open62541 | ||
# open62541.jl | ||
|
||
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://martinkosch.github.io/open62541.jl/dev) | ||
[![CI](https://github.com/martinkosch/open62541.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/martinkosch/open62541.jl/actions/workflows/CI.yml) | ||
[![codecov](https://codecov.io/gh/martinkosch/open62541.jl/graph/badge.svg?token=lJe2xOTO7g)](https://codecov.io/gh/martinkosch/open62541.jl) | ||
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) | ||
|
||
open62541.jl is a [Julia](https://julialang.org) package that interfaces with the [open62541](https://www.open62541.org/) | ||
library written in C ([source](https://github.com/open62541/open62541)). | ||
|
||
As such, it provides functionality following the [OPC Unified Architecture (OPC UA) standard](https://en.wikipedia.org/wiki/OPC_Unified_Architecture) | ||
for data exchange from sensors to cloud applications developed by the [OPC Foundation](https://opcfoundation.org/). | ||
|
||
In short, it provides the ability to create OPC servers that make data from different | ||
sources available to clients and, naturally, also a client functionality that allows | ||
to read data from OPC UA servers. Features are summarized further on the [open62541 website](https://www.open62541.org/). | ||
|
||
open62541.jl's *ultimate* aim is to provide the full functionality of open62541 to | ||
Julia users through a convenient high level interface without the need to engage | ||
in manual memory management etc. (as required in open62541). | ||
|
||
At its current development stage the high level interface is implemented for a | ||
(commonly used) subset of functionality. An essentially feature-complete lower | ||
level interface that wraps all functionality of open62541 is, however, available. | ||
|
||
## Warning: active development | ||
|
||
Note that open62541.jl is still under active development and has not reached a maturity | ||
that would make it safe to use in a production environment. | ||
|
||
The developers aim to observe [semantic versioning](https://semver.org/), but | ||
accidental breakage and evolutions of the API have to be expected. | ||
|
||
Documentation is also a work in progress. | ||
|
||
## Installation | ||
|
||
open62541.jl is not yet registered in Julia's General registry, but it will | ||
hopefully be soon (status: May 2024). | ||
|
||
Assuming you have Julia already installed (otherwise: [JuliaLang Website](https://julialang.org/)), | ||
you can install by executing: | ||
|
||
```julia | ||
using Pkg | ||
Pkg.add("https://github.com/martinkosch/open62541.jl") | ||
``` | ||
|
||
## Server example | ||
|
||
Starting up a server with a default configuration in open62541.jl is very simple. | ||
Just execute the following code in the REPL or as a script: | ||
|
||
```julia | ||
using open62541 | ||
server = JUA_Server() | ||
config = JUA_ServerConfig(server) | ||
JUA_ServerConfig_setDefault(config) | ||
JUA_Server_runUntilInterrupt(server) | ||
``` | ||
|
||
This will configure a server with the default configuration (address: opc.tcp://localhost:4840/) | ||
and start it. The server can be shut down by pressing CTRL+C multiple times. | ||
|
||
While the server is running, it can be accessed via the Client API of open62541.jl | ||
or it can be browsed and accessed with a graphical client, such as [UA Expert](https://www.unified-automation.com/products/development-tools/uaexpert.html). | ||
|
||
## Basic client example | ||
|
||
In order to showcase the Client API functionality, we will use the above server | ||
and read some basic information from it, namely the software version number and | ||
the current time. Note that this information should be contained in all OPC UA | ||
servers, so you could also connect to a different server that you know is running. | ||
|
||
```julia | ||
using open62541 | ||
using Printf | ||
|
||
#initiate client, configure it and connect to server | ||
client = JUA_Client() | ||
config = JUA_ClientConfig(client) | ||
JUA_ClientConfig_setDefault(config) | ||
JUA_Client_connect(client, "opc.tcp://localhost:4840") | ||
|
||
#define nodeids that we are interested in | ||
nodeid_currenttime = JUA_NodeId(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME) | ||
nodeid_version = JUA_NodeId(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_SOFTWAREVERSION) | ||
|
||
#read data from nodeids | ||
currenttime = JUA_Client_readValueAttribute(client, nodeid_currenttime) #Int64 which represents the number of 100 nanosecond intervals since January 1, 1601 (UTC) | ||
version = JUA_Client_readValueAttribute(client, nodeid_version) #String containing open62541 version number | ||
|
||
#Convert current time into human understandable format | ||
dts = UA_DateTime_toStruct(currenttime) | ||
|
||
#Print results to terminal | ||
Printf.@printf("current date and time (UTC) is: %u-%u-%u %u:%u:%u.%03u\n", | ||
dts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec) | ||
Printf.@printf("The server is running open62541 version %s.", version) | ||
|
||
#disconnect the client (good housekeeping practice) | ||
JUA_Client_disconnect(client) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Attribute generation | ||
|
||
This page lists docstrings of functions used for the convenient generation of | ||
node attribute structures. Their main use is when adding nodes to a server through | ||
client API (see [`JUA_Client_addNode`](@ref)) or the server API (see [`JUA_Server_addNode`](@ref)). | ||
|
||
Convenience functions that allow setting values for specific attributes: | ||
|
||
```@docs | ||
UA_VALUERANK | ||
UA_ACCESSLEVEL | ||
UA_USERACCESSLEVEL | ||
UA_WRITEMASK | ||
UA_USERWRITEMASK | ||
UA_EVENTNOTIFIER | ||
``` | ||
|
||
High level generators for attribute blocks: | ||
```@docs | ||
JUA_VariableAttributes | ||
JUA_VariableTypeAttributes | ||
JUA_ObjectAttributes | ||
JUA_ObjectTypeAttributes | ||
JUA_MethodAttributes | ||
JUA_ViewAttributes | ||
JUA_DataTypeAttributes | ||
JUA_ReferenceTypeAttributes | ||
``` | ||
|
||
Lower level generators for attribute blocks: | ||
```@docs | ||
UA_VariableAttributes_generate | ||
UA_VariableTypeAttributes_generate | ||
UA_ObjectAttributes_generate | ||
UA_ObjectTypeAttributes_generate | ||
UA_MethodAttributes_generate | ||
UA_ViewAttributes_generate | ||
UA_DataTypeAttributes_generate | ||
UA_ReferenceTypeAttributes_generate | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Client | ||
|
||
This page lists docstrings relevant to the client API. | ||
|
||
## Adding different types of nodes: | ||
|
||
```@docs | ||
JUA_Client_addNode | ||
UA_Client_addVariableNode | ||
UA_Client_addObjectNode | ||
UA_Client_addVariableTypeNode | ||
UA_Client_addObjectTypeNode | ||
UA_Client_addViewNode | ||
UA_Client_addReferenceTypeNode | ||
UA_Client_addDataTypeNode | ||
``` | ||
|
||
## Reading from nodes: | ||
|
||
```@docs | ||
UA_Client_readAccessLevelAttribute | ||
UA_Client_readBrowseNameAttribute | ||
UA_Client_readContainsNoLoopsAttribute | ||
UA_Client_readDataTypeAttribute | ||
UA_Client_readDescriptionAttribute | ||
UA_Client_readDisplayNameAttribute | ||
UA_Client_readEventNotifierAttribute | ||
UA_Client_readExecutableAttribute | ||
UA_Client_readHistorizingAttribute | ||
UA_Client_readInverseNameAttribute | ||
UA_Client_readIsAbstractAttribute | ||
UA_Client_readMinimumSamplingIntervalAttribute | ||
UA_Client_readNodeClassAttribute | ||
UA_Client_readNodeIdAttribute | ||
UA_Client_readSymmetricAttribute | ||
UA_Client_readUserAccessLevelAttribute | ||
UA_Client_readUserExecutableAttribute | ||
UA_Client_readUserWriteMaskAttribute | ||
UA_Client_readValueAttribute | ||
UA_Client_readValueRankAttribute | ||
UA_Client_readWriteMaskAttribute | ||
``` | ||
|
||
## Writing to nodes: | ||
|
||
```@docs | ||
UA_Client_writeAccessLevelAttribute | ||
UA_Client_writeBrowseNameAttribute | ||
UA_Client_writeContainsNoLoopsAttribute | ||
UA_Client_writeDataTypeAttribute | ||
UA_Client_writeDescriptionAttribute | ||
UA_Client_writeDisplayNameAttribute | ||
UA_Client_writeEventNotifierAttribute | ||
UA_Client_writeExecutableAttribute | ||
UA_Client_writeHistorizingAttribute | ||
UA_Client_writeInverseNameAttribute | ||
UA_Client_writeIsAbstractAttribute | ||
UA_Client_writeMinimumSamplingIntervalAttribute | ||
UA_Client_writeNodeClassAttribute | ||
UA_Client_writeNodeIdAttribute | ||
UA_Client_writeSymmetricAttribute | ||
UA_Client_writeUserAccessLevelAttribute | ||
UA_Client_writeUserExecutableAttribute | ||
UA_Client_writeUserWriteMaskAttribute | ||
UA_Client_writeValueAttribute | ||
UA_Client_writeValueRankAttribute | ||
UA_Client_writeWriteMaskAttribute | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Nodeid | ||
|
||
This page lists docstrings of functions used to create NodeId identifiers. | ||
|
||
## Low level interface | ||
|
||
test | ||
|
||
```@docs | ||
UA_NODEID | ||
UA_NODEID_BYTESTRING_ALLOC | ||
UA_NODEID_GUID | ||
UA_NODEID_NUMERIC | ||
UA_NODEID_STRING | ||
UA_NODEID_STRING_ALLOC | ||
``` | ||
|
||
## High level interface | ||
|
||
```@docs | ||
JUA_NodeId | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Supported number types | ||
|
||
It is noteworthy that the open62541 library supports the following Julia | ||
number types natively. open62541.jl provides support for the same number types. | ||
Adding other types is possible, but must rely on a custom datatype. See the [open62541 documentation](https://github.com/open62541/open62541/tree/master/examples/custom_datatype). | ||
|
||
**Real:** | ||
|
||
- Integers: Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64. | ||
- Float: Float32 and Float64. | ||
|
||
**Complex:** | ||
|
||
- Complex{Float32}, Complex{Float64} |
Oops, something went wrong.