CtAPI
- Last UpdatedJul 13, 2023
- 3 minute read
CtAPI allows access to Plant SCADA's tag data via a DLL interface. It allows third party developers to create applications in C (or other languages) to read and write to I/O devices, to use data query, and to call Cicode functions.
Building Applications
To build CtAPI client applications, you need runtime binaries, a DLL helper static library (CtAPI.lib) and a header file (CtAPI.h) that defines data structures and functions. Configure your project to use these files by following these steps:
-
Check that the files necessary to build your application that calls CtAPI functions are ready on your development environment as per your target platform (x86 or x64), by deploying these files into your project location:
-
All the runtime binaries packaged in the files CtAPI.Win32.Redist.zip and CtAPI.x64.Redist.zip (see Running CtAPI Applications below).
-
Development specific files in [bin] directory for x86 platform or in [bin]\Bin (x64)\ directory for x64 platform:
-
CtAPI.lib
-
CtAPI.
-
-
-
Add CtAPI.lib on your imported static library (dependency) list, to load up CtAPI.dll and its satellite binaries at application startup.
-
Include CtAPI.h on your source files that use CtAPI functions.
Note: This procedure may differ based on your development environment. Contact your system administrator or system provider if more detailed information is required.
Running CtAPI Applications
To run a CtAPI application, the program needs to be able to locate CtAPI.dll and its dependencies. There are several ways to achieve this:
-
If you are running your application on a computer where Plant SCADA is installed, you can copy your program and its dependencies to the Plant SCADA Bin directory.
-
You can copy the set of required binaries into the same directory as your application. These binaries are packaged in the files CtAPI.Win32.Redist.zip and CtAPI.x64.Redist.zip, which can be found in the following directory on the Plant SCADA installation media:
\AVEVA Plant SCADA2023\Extras\CtAPI
You will need to use this approach if you want to use CtAPI on a computer that does not have Plant SCADA installed.
-
If the above options are not possible (for example, you are using CtAPI from VBA in a Microsoft™ Office application such as Excel™), then you can add the Plant SCADA Bin directory to the %PATH% environment variable. This allows your application to locate CtAPI.dll, however, certain dependencies will not be located this way because Windows will not use the path to locate .NET managed assemblies.
To resolve this, call the CtAPI function ctSetManagedBinDirectory with the path to the Plant SCADA Bin directory before your call to ctOpen. If Plant SCADA is not installed on the computer running the application, then extract the binaries from the above zip file to another directory and use that directory in place of the Bin directory.
Note: You can encrypt the connection between a remote CtAPI client and Plant SCADA. For more information, see Secure the Connection from a Remote CtAPI Application.
The following needs to be installed on remote CtAPI clients:
-
.NET 4.8
-
Microsoft Visual C++ 2015-2022 Redistributable (x86)
Or:
Microsoft Visual C++ 2015-2022 Redistributable (x64)
Note: This API has not been designed to be called from Plant SCADA Cicode DLL functions or from a Plant SCADA protocol driver. If you attempt this, it may cause a deadlock condition to occur. If you need to call the CtAPI from a protocol driver, create a new Win32 thread to call the API. You cannot call the CtAPI from the Cicode DLL interface.
See Also
Read Data Using the CtAPI Functions