Python Utilities

The Core Python utilities provides a set of Python tools to assist the development of Python libraries and program in the context of ICS.

The following modules/tools are provided:

  • “ifw-core/pyutils/utils”: Various general purpose Python utilities.

  • “ifw-core/pyutils/opcua/srvlib”: Provides an SCXML driven, OPC UA server tool kit based on the Free OPC UA SDK.

  • “ifw-core/pyutils/opcua/clientLib”: Provides an OPC UA client class, based on the Free OPC UA SDK.

  • “ifw-core/pyutils/opcua/utils”: Various OPC UA helper tools.

  • “ifw-core/pyutils/opcua_gen_profile”: Tool to generate the OPC UA XML Profile from a easier-to-handle YAML-based format.

Module: “ifw-core/pyutils/utils”

Python import statement: “import ifw.core.utils.utils”.

Module: “ifw-core/pyutils/opcua/srvlib”

Python import statement: “import ifw.core.opcualib.srvlib”.

For examples of usage of the OPC UA/SCXML server toolkit, the Device Simulators can be used.

Module: “ifw-core/pyutils/opcua/clientlib”

Python import statement: “import ifw.core.opcualib.clientlib”.

Module: “ifw-core/pyutils/opcua/utils”

Python import statement: “import ifw.core.opcualib.utils”.

Module: “ifw-core/pyutils/opcua_gen_profile”

The tool is used to generate the OPC UA XML profile for the Core OPC UA/SCXML Server Toolkit. The OPC UA XML profile defines the namespace of the server.

The names are defined in a simple YAML-based file and the XML document generated via the tool.

An example of a YAML namespace definition to be used as input for the tool can be found here: Motor Device Simulator

Note

For the Core OPC UA/SCXML Server toolkit, it is recommended to use the feature to generate the OPC/UA XML namespace on-the-fly, from the simpler YAML format, unless for performance reasons it is better to use a pre-generated XML profile.

Module: “ifw-core/pyutils/log_collector”

Tool for collecting logs coming from PLCs and ingesting them in the CII logging environment using the CII logging API.

Usage:

$ ifwCoreLogCollector --help
usage: ifwCoreLogCollector [-h] [-i INTERFACE] [-p PORT] [-l LOG]

Cii log collector

optional arguments:
  -h, --help            show this help message and exit
  -i INTERFACE, --interface INTERFACE
                      server network interface
  -p PORT, --port PORT  server listening port
  -l LOG, --log LOG     logging configuration

Module: “ifw-core/pyutils/network”

Module to create udp mudpi server or clients. Python import statement: “import ifw.core.network”.

Module: “ifw-core/pyutils/mudpi”

Module to build or read mudpi packets. Python import statement: “import ifw.core.mudpi”.