The Toolkit API provides an interface for external applications to interact with the solutions, enhancing interoperability and integration capabilities. It requires .NET Standard 4.8 and licensing of the software platform, ensuring that external applications can securely and efficiently manage and exchange data with the platform. This API opens up possibilities for extending and customizing the functionality of existing solution deployments.
On this page:
Using TKDataAccess.Py
The Python code using the TKDataAccess.py module in Main.py is described below:
import sys from Extensions.TKDataAccess import TKDataAccess dataAccess = TKDataAccess() connectionStatus = dataAccess.Connect("127.0.0.1:3101", "guest", "") print("Connection: " + connectionStatus) if dataAccess.IsConnected() : ret = dataAccess.GetObjectValue("Tag.tag1") print("Value: " + str(ret)) dataAccess.SetObjectValue("Tag.tag2", ret) dataAccess.Disconnect()
Then you need to create the code that is shown below or create a Python Script Task that executes the Main.py file, which contains the calling for TKDataAccess shown above. So here, we will use the Python namespace as previously described.
The code is shown below.
try { string error = Python.ExecutePyFile(@Info.GetExecutionFolder() + @"\Main.py", null, true); if (!string.IsNullOrEmpty(error)) throw new Exception(error); } catch (Exception ex) { @Info.Trace("Python: " + (ex.InnerException == null ? ex.Message : ex.InnerException.Message)); }
In this section: