MTConnect Connector#

MTConnectConnector Class

Provides orchestration for deploying MTConnect-based devices into the OpenFactory environment. This includes:

  • Registering the device with OpenFactory.

  • Deploying the MTConnect agent and its adapter (if required) via MTConnectAgentDeployer.

  • Deploying a Kafka producer to publish MTConnect data into the Kafka cluster.

  • Tearing down all associated components when the device is removed.

Note

This connector delegates agent and adapter deployment to MTConnectAgentDeployer, ensuring separation between orchestration logic and MTConnect-specific deployment details.

See also

The schema of the MTConnectConnector is openfactory.schemas.connectors.mtconnect.MTConnectConnectorSchema.

class openfactory.connectors.mtconnect.mtc_connector.MTConnectConnector(deployment_strategy, ksqlClient, bootstrap_servers=None)[source]#

Bases: Connector

Connector for MTConnect devices that manages deployment of MTConnect agents, adapters, and Kafka producers, leveraging a pluggable deployment strategy.

See also

The schema of the MTConnectConnector is openfactory.schemas.connectors.mtconnect.MTConnectConnectorSchema.

__init__(deployment_strategy, ksqlClient, bootstrap_servers=None)[source]#

Initializes the MTConnectConnector.

Parameters:
  • deployment_strategy (OpenFactoryServiceDeploymentStrategy) – The deployment strategy to use.

  • ksqlClient (KSQLDBClient) – The client for interacting with ksqlDB.

  • bootstrap_servers (str) – The Kafka bootstrap server address. Defaults to config.KAFKA_BROKER.

deploy(device, yaml_config_file)[source]#

Deploy a device based on its configuration.

Return type:

None

Parameters:
  • device (Device) – Device to deploy.

  • yaml_config_file (str) – Path to the YAML configuration file.

deploy_kafka_producer(device)[source]#

Deploy a Kafka producer.

Return type:

None

Parameters:

device (Device) – The device for which the producer is to be deployed.

Raises:

OFAException – If the producer cannot be deployed.

tear_down(device_uuid)[source]#

Tear down a deployed device given its UUID.

Return type:

None

Parameters:

device_uuid (str) – Unique identifier of the device to be torn down.

MTConnectAgentDeployer Class

Class to deploy MTConnect agents and their adapters for OpenFactory devices.

The MTConnectAgentDeployer class, handles loading device configurations, preparing environment variables, deploying adapter services if needed, deploying the MTConnect agent service itself, and registering the assets in the system.

It relies on OpenFactory’s deployment strategy, Kafka client, and asset management utilities.

class openfactory.connectors.mtconnect.mtcagent_deployer.MTConnectAgentDeployer(device, yaml_config_file, deployment_strategy, ksqlClient, bootstrap_servers)[source]#

Bases: object

Class to deploy MTConnect agents and adapters for OpenFactory devices.

__init__(device, yaml_config_file, deployment_strategy, ksqlClient, bootstrap_servers)[source]#

Initialize the MTConnectAgentDeployer.

Parameters:
  • device (Device) – The device schema object containing connector information.

  • yaml_config_file (str) – Path to the YAML config file for device XML resolution.

  • deployment_strategy (OpenFactoryServiceDeploymentStrategy) – Deployment strategy to use for services.

  • ksqlClient (KSQLDBClient) – KSQL client instance for asset registration.

  • bootstrap_servers (str) – Kafka bootstrap servers connection string.

deploy()[source]#

Deploy the MTConnect agent including loading XML, deploying adapter, service, and registering assets.

Return type:

None

Raises:

OFAException – Propagated from underlying methods if loading files fails.

deploy_adapter()[source]#

Deploy the MTConnect adapter service with specified environment and resource constraints.

Handles deployment failures by notifying the user.

Return type:

None

deploy_adapter_if_needed()[source]#

Deploy the MTConnect adapter service if an adapter image is specified.

Return type:

None

deploy_service()[source]#

Deploy the MTConnect agent service.

Return type:

None

load_agent_config()[source]#

Load the MTConnect agent configuration file contents.

Return type:

str

Returns:

str – The contents of the MTConnect agent config file.

Raises:

OFAException – If the MTConnect agent config file is not found.

load_device_xml()[source]#

Load and return the device XML model for the MTConnect agent.

If the agent has an IP defined, returns an empty string. Otherwise, reads the device XML from the provided URI, supporting relative paths based on the YAML config file location.

Return type:

str

Returns:

str – The device XML content, or an empty string if agent IP is set.

Raises:

OFAException – If the device XML cannot be loaded.

prepare_env()[source]#

Prepare environment variables for deploying the MTConnect agent.

Return type:

list[str]

Returns:

list[str] – List of environment variables as strings.

register_assets()[source]#

Register the MTConnect agent and device assets.

Return type:

None