A running OPC UA Server (Release 1.03) that was implemented in C for both Windows and Linux distributions. The OPC UA Server runs with binary encoding over TCP. This specific implementation of the OPC UA Server exposes through the address space a set of ODBC functions. In other words, the current implementation encapsulates an ODBC-supported database abstractly through method calls rather than directly exposing the internal database structure and internal data directly in the address space.
This server was originally developed as part of a year-long research project for an academic course (AP Research). This particular version of the source code is released with explicit permission from iData Inc. for which I am grateful for. However, this repository has been and is no longer actively maintained since August 2017 due to contractual clauses between myself and iData Inc. concerning this codebase.This repository contains the following pieces of information. Although the Visual Studio 2015 and Netbeans (for Ubuntu/CentOS) projects have been distributed in this repository, the projects still require tweaking to account for library search paths and other more system-specific configurations. The codebase has been separated into various folders depending on the specific function of that particular code within the larger context (i.e AddressSpace infrastructure are in the AddressSpace folder, OPC UA function definitions and database methods are in the Functions folder).
- README.md
- Visual Studio 2015 Project
- Netbeans C/C++ Project
- Source Code in Subfolders
At the current moment, the following functions are supported. For allowing the end-user to selectively target an ODBC driver, both wchar_t and multibyte char functions are exposed. The prefixing to functions mirrors the convention surrounding ODBC with the 'W' suffix indicating Unicode Driver and 'A' indicating ANSI Driver. Although these functions have been tested primarily against SQL Server 2014 and 2017, other databases will work, although minor adjustments may be necessary for optimization purposes and/or to improve compatibility.
The currently publicly exposed functions are:
- SQLConnect
- SQLSetCommit
- SQLCommit
- SQLDisconnect
- SQLAllocHandle
- SQLCloseHandle
- SQLResetParamsHandle
- SQLFreeHandle
- SQLExecDirect
- SQLInsert
- SQLUpdate
- SQLDelete
- SQLSelect
- SQLFetch
- SQLPrepare
- SQLBind
- SQLExecute
The privately depended upon functions are:
- SQLColumns
- SQLBindCol
- SQLDescribeCol
- SQLFetch
- SQLGetInfo (SQL_DYNAMIC_CURSOR_ATTRIBUTES1)
- SQLNumResultCols
- SQLFetchScroll
- SQLGetDiagRec
Notes/Caveats
- Storing BINARY data into the database is supported through the functions provided. However, the BINARY data when passed into the function as an OPC UA parameter must be encoded in Base64 without any line breaks.
- All publicly exposed functions require the first parameter to be an UINT32 value that was passed into SQLAllocHandle.
- Most publicly exposed functions accept a second parameter that must be JSON-encoded.
- The functions return up to a maximum of 3 values - with the first parameter indicating success/failure of the database operation, the second parameter representing a textual JSON-encoded result if applicable, and the third result indicates the number of affected rows.
- The JSON definitions can be accessed via querying the description attribute of the Argument or in UASpace/InitializeCustom.c
- Address Space Node IDs and Namespace are defined in Definitions/id_opcua_db_def.h
- Server Information configuration in Definitions/id_opcua_serverinfo.h
- Parameters concerning communication (including PKI) in Definitions/id_opcua_comm.h
- By default, the server listens on port 4840 and uses PKI for verification of client certificates
- Insert, Update, Delete, Select, and Fetch Sequence
SQLAllocHandle()
...
SQLInsert()
...
SQLUpdate()
...
SQLDelete()
...
SQLSelect()
SQLFetch()
SQLFetch()
SQLFreeHandle()
- Prepared Statements, SQLResetParams Sequence
SQLAllocHandle()
SQLPrepare()
SQLBind()
...
SQLBind()
SQLExecute()
SQLResetParamsHandle()
SQLBind()
SQLExecute()
SQLFreeHandle()
- Connection, SQLSetCommit, SQLCommit Sequence
SQLConnect()
SQLSetCommit()
...(various operations)
SQLCommit()
SQLDisconnect()
- OpenSSL 1.0.2j with development headers
- OPC UA UA-AnsiC Stack
- cJSON library by DaveGamble
- ODBC in addition to ODBC headers (sql.h, sqlext.h)
- Various system libraries
Please refer any contact to [email protected] with 'OPC UA' in the subject header.
© 2017. William Zhang