T06 - EDC Connector

EDC Connector is a use case to show the Eclipse Data Components (EDC) connector feature of the AAS Digital Twin generated by Papyrus4Manufacturing (P4M) version Desktop. The use case simulates two Factories A and B, each has a corresponding AAS DT. In the dataspace, the two AAS DTs play the role of data providers that serve real-time data from the factories to data consumers.

Requirements

The following components are required:

The following knowledge are required:

  • Basic about Java + Eclipse IDE

  • Basic about AAS

  • Basic about EDC

  • Basic about Docker

  • Basic about Python3

Deployment Instructions

In this example, all software components will be run on the computer; however, it is possible to run them in different machines. After downloading the T06 Kit, decompress it to get the three packages: (1) factory_v0.1.tar.gz contains the Docker image to run factories, (2) T06-Factory.tar.gz contains the AAS model design for AAS DTs, and (3) lib_minedc_v0.1.0.tar.gz contains a python library for data consumers.

Factory setup

The production of a factory has three parameters:

  • <QUALITY_RATE>means the possibility that a produced product reaches the quality to be valid. It has a value between 0 and 100. When the rate is 100, then all produced products are valid.

  • <CYCLE_TIME> means the interval between two consecutive products. The more cycle time, the slower the production.

  • <PRODUCT_COST> means the basic unit price of a product. The more products in the storage, the lower unit price.

On the computer, install and run the Docker image with the following command:

$ docker load -i factory_v0.1.tar.gz
$ docker run -it --net=host --rm factory:v0.1 ./factory 100 1 10 1234
$ docker run -it --net=host --rm factory:v0.1 ./factory 60 2 6 3234

Two factories will be run. Factory A is listening on port 1234. It has quality rate 100, cycle time 1, and basic unit price 10. Factory B is listening on port 3234. It has quality rate 60, cycle time 2, and basic unit price 6.

The expected result of Factory A shown in Figure 1. The Factory A’s server is exposed at the endpoint http://0.0.0.0:1234.

Figure 1. Result when running the Docker image for Factory A

The Factory B’s server is exposed at the endpoint http://0.0.0.0:3234.

Factory DT setup

Extract T06-EDCConnector.tar.gz with the following command:

$ tar -xzvf T06-EDCConnector.tar.gz

Open Papyrus4Manufacturing and import the project as in Figure 2. The AAS Design Diagram shows the basic elements of the project. Note that users can see two properties number_products and unit_price, and one operation buy inside submodel Production.

Figure 2. Project T06-Factory shown on Papyrus4Manufacturing

In Model Explorer, right click on the AssetAministrationShell FactoryA, choose AAS, then click Generate Asset Administration Shell Basyx code (AAS). When a new project AAS_FactoryA is generated, users open the file DynamicElementsWorkspace.java inside the package production and modify it as follows. Repeat same steps to generate AAS_FactoryB.

public DynamicElementsWorkspace(ConnectedDevices connectedDevices) {
  this.connectedDevices = connectedDevices;
  
  new Thread(() -> {
    while (true) {
      Function.delay(1);
      Cache.properties.put("Production_number_products",
        Integer.parseInt(connectedDevices.ep_http.readValue("/number")));
      Cache.properties.put("Production_unit_price",
        Integer.parseInt(connectedDevices.ep_http.readValue("/price")));
    }
  }).start();
}

public void Production_buy() {
  connectedDevices.ep_http.invokeMethod("/order/?number=100", null);
};

public Integer get_Production_number_products() {
  Integer defaultVar = Integer
    .parseInt(connectedDevices.ep_http.readValue("/number"));
  return defaultVar;
}

public Integer get_Production_unit_price() {
  Integer defaultVar = Integer
    .parseInt(connectedDevices.ep_http.readValue("/price"));
  return defaultVar;
}

Next, open file application.properties in project AAS_FactoryA and add the configuration for Factory A as follows.

edc.participant.id=provider
edc.dsp.callback.address=http://localhost:19194/protocol
edc.hostname=localhost
web.http.port=19191
web.http.path=/api
web.http.management.port=19193
web.http.management.path=/management
web.http.protocol.port=19194
web.http.protocol.path=/protocol
edc.transfer.proxy.token.signer.privatekey.alias=private-key
edc.transfer.proxy.token.verifier.publickey.alias=public-key
web.http.public.port=19291
web.http.public.path=/public
web.http.control.port=19192
web.http.control.path=/control
web.http.version.port=19195
web.http.version.path=/version
edc.dataplane.api.public.baseurl=http://localhost:19291/public
edc.dataplane.proxy.public.endpoint=http://localhost:19291/public

Add the configuration for Factory B in file application.properties of project AAS_FactoryB as follows.

edc.participant.id=provider
edc.dsp.callback.address=http://localhost:39194/protocol
edc.hostname=localhost
web.http.port=39191
web.http.path=/api
web.http.management.port=39193
web.http.management.path=/management
web.http.protocol.port=39194
web.http.protocol.path=/protocol
edc.transfer.proxy.token.signer.privatekey.alias=private-key
edc.transfer.proxy.token.verifier.publickey.alias=public-key
web.http.public.port=39291
web.http.public.path=/public
web.http.control.port=39192
web.http.control.path=/control
web.http.version.port=39195
web.http.version.path=/version
edc.dataplane.api.public.baseurl=http://localhost:39291/public
edc.dataplane.proxy.public.endpoint=http://localhost:39291/public

To run AAS DT servers, right click on AASServer.launch, choose Run As, then click AASServer.

The expected result of Factory A’s AAS DT shown in Figure 3. The AAS server is exposed at the endpoint http://0.0.0.0:12340.

Figure 3. Result when running the Factory A's AAS DT

Data Consumer setup

Extract lib_minedc_v0.1.0.tar.gz and install the EDC connector library in python venv with the following commands:

$ tar -xzvf lib_mineedc_v0.1.0.tar.gz
$ python -m venv venv
$ source venv/bin/activate
$ pip install minedc-0.1.0-py3-none-any.whl

After installing the library, users can launch consumer python file which will use configurations factory_a.properties and factory_b.properties to connect with the two AAS DTs of the two factories. These files are also in the extracted folder.

The expected result when running Consumer shown in Figure 4. User can choose 1 to get data from Factory A, and 2 to get data from Factory B. User can modify the Python code to add more function to the consumer.

Figure 4. Result when running the Consumer