EtherNet/IP tutorials

FairCom Edge EtherNet/IP connector service tutorials

Requirements:

Ensure the FairCom server is installed and running.

Ensure that the Allen-Bradley connector is enabled.

Confirm server access by running the FairCom API explorer. The typical URL is https://localhost:8443/.

 

Initialize the Allen-Bradley simulator

For this tutorial, we are using an open-source Allen-Bradley simulator available with the libplctag package.

  1. Download and extract libplctag package that is available at https://github.com/libplctag/libplctag/releases. For example, libplctag_2.6.4_windows_x64.zip.
  2. Execute Allen-Bradley Server simulator, creating some tags:
    1. cd \libplctag_2.6.4_windows_x64\ 
      
      .\ab_server --plc=ControlLogix --path=1,0 --port=4400 --tag=MESSAGE:STRING[10] --tag=SCADA:dint[10] --tag=TEMPERATURE:real[1]  --tag=OUT_TEMP:real[1]
    2. This instruction executes the Allen-Bradley server simulator of type Control Logix, on Port 4400, creating 4 tags: SCADA, MESSAGE, TEMPERATURE and OUT_TEMP—the first two with ten elements each, the last two with only one element each.
    3. Leave it running.
  3. Execute tag_rw2 to write some data to the Allen-Bradley Server simulator.
    1. cd \libplctag_2.6.4_windows_x64\
      
      .\tag_rw2 --type="sint32" --tag="protocol=ab-eip&gateway=localhost:4400&path=1,0&plc=controllogix&elem_count=10&name=SCADA" --debug=1 --write=10,20,30,40,50,60,70,80,90,100 --timeout=1000
      
      .\tag_rw2 --type="real32" --tag="protocol=ab-eip&gateway=localhost:4400&path=1,0&plc=controllogix&elem_count=1&name=TEMPERATURE" --write=35.3 --timeout=1000
      
      .\tag_rw2 --type="string" --tag="protocol=ab-eip&gateway=127.0.0.1:4400&path=1,0&plc=controllogix&elem_count=5&name=MESSAGE" --debug=1 --write="check temperature","a1","a2","a3","a4" --timeout=1000

Note There is also a Linux version of this simulator.

 

Create a session

  1. Start the FairCom browser-based tools.
    1. The tools icons appear.
  2. Select and log into Data Explorer.
    1. The Data Explorer interface window appears.
  3. Click the API Explorer tab.
    1. The API Explorer interface opens and the Server navigation window shows that you are connected to the "faircom" database and the FairCom server. Use the "faircom" database or another database you create to store the "customer tables".

 

Create integration table

Next, this procedure creates the integration table abTable1, which will receive data from the simulated device, and redirect it to the fields scada0, scada1 and temperature.

{
    "action": "createIntegrationTable",
    "params": {
        "databaseName": "faircom",
        "tableName": "abTable1",
        "fields": [
        	{
        		"name": "scada0",
        		"type": "integer"
        	},
        	{
        	    "name": "scada1",
        		"type": "integer"
        	},
        	{
        	    "name": "temperature",
        		"type": "real"
        	}
        ],
        "transformSteps": [
            {
                "transformStepMethod": "jsonToTableFields",
                "mapOfPropertiesToFields":[
                    {
                        "recordPath":"source_payload.scada0",
                        "fieldName":"scada0"
                    },
                    {
                        "recordPath":"source_payload.scada1",
                        "fieldName":"scada1"
                    },
                    {
                        "recordPath":"source_payload.temperature",
                        "fieldName":"temperature"
                    }
                ]
            }
        ]
    }
}

Note An "errorCode" with a value of 0 indicates success. An "errorCode" with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.

 

Capture Allen-Bradley data as JSON records in a table

This procedure creates an input named "abTest1" that takes Allen-Bradley data and stores it in JSON format in the payload field of records in the previously-created table "abTable1" .

  1. Select Hub API from the Select API dropdown menu.
  2. Select createInput from the JSON Actions dropdown menu.
  3. Replace the JSON in the API Request editor with the following JSON:
    1. {
         "api":"hub",
         "action":"createInput",
         "params":{
            "inputName":"abTest1",
            "serviceName":"ab",
            "tableName":"abTable1",
            "dataCollectionIntervalMilliseconds":5000,
            "settings":{
               "dataReadingTimeoutMilliseconds":4000,
               "dataCollectionBufferCount":1,
               "plcAddress":"localhost:4400",
               "plcType":"controllogix",
               "propertyMapList":[
                  {
                     "eipTagPath":"1,0",
                     "eipTagName":"SCADA",
                     "eipTagElementCount":5,
                     "eipTagType":"int32",
                     "propertyPath":"scada"
                  },
                  {
                     "eipTagPath":"1,0",
                     "eipTagName":"TEMPERATURE",
                     "eipTagType":"float32",
                     "propertyPath":"temperature"
                  },
                  {
                     "eipTagPath":"1,0",
                     "eipTagName":"MESSAGE",
                     "eipTagType":"string",
                     "eipTagSize":20,
                     "propertyPath":"message"
                  }
               ]
            }
         },
         "authToken": "replaceWithAuthTokenFromCreateSession"
      }
  4. This request reads 5 elements from the tag "scada", and 1 element from the other tags.
  5. Click Apply defaults to JSON request to replace the "authToken" value with the valid one from your session.
  6. Click Send request to issue the JSON-based request.
  7. Observe the response and ensure the action is completed successfully.

Note An "errorCode" with a value of 0 indicates success. An "errorCode" with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.

 

View the captured Allen-Bradley data in the "abTest1" table

  1. Start the FairCom Data Explorer
  2. Navigate to and select abTest1 in the Server navigation window through faircom>admin>Tables.
  3. Click the Table Records tab.
  4. Select a record and click the source_payload field.
  5. Observe the JSON contents of the field. Click the "edit" icon of the source_payload field to see the content formatted as JSON.

The value should look like this:

{
  "create_ts":"2025-04-25T21:13:48.543Z",
  "scada0":10,
  "scada1":20,
  "temperature":35.299999237060547
}

Note If the table has no records, look at <faircom>/data/CTSTATUS.FCS to see errors related to the connector.

 

View the transformed data

View the "abTable1" table in the "faircom" database for the transformed data.

Both of the following procedures will let you view the transformed data. You can use either of these procedures to view the transformed data.

 

View transformed data through the Server navigation window

  1. Select the "faircom" database in the Server navigation window.
  2. Select Connect from the JSON Actions dropdown menu.
  3. Navigate to and select the ab1 table in the Server navigation window through faircom>admin>Tables.
  4. Click the Table Records tab.
  5. Observe the table records.

 

View transformed data through a SQL query

  1. Click the SQL Queries tab.
  2. Enter the following SQL query in the textbox.
    1. SELECT * from ab1 where scada0>0
  3. Click the Execute SQL statement button.
  4. Observe the response and ensure the action is completed successfully.

 

Forward captured data to an MQTT topic

Once Allen-Bradley data is flowing into a table as JSON and is being transformed into discrete fields in another table, forward the data out over MQTT.

  1. Select MQ API from the Select API dropdown menu.
  2. Select configureTopic from the JSON Actions dropdown menu.
  3. Replace the JSON in the API Request editor with the following JSON:
    1. {
        "api": "mq",
        "action": "configureTopic",
        "params":
        {
          "topic": "abTopic",
          "databaseName": "faircom",
          "tableName": "abTable1"
        },
        "authToken": "replaceWithAuthTokenFromCreateSession"
      }
  4. Click Send request.
  5. Observe the response and ensure the action is completed successfully.

 

Subscribe to the MQTT topic to verify that data was forwarded

  1. Start the FairCom Browser-Based tools.
  2. Select and connect to MQ Explorer.
  3. Select MQTT Management from the Control menu.
  4. Click Subscribe to open the Manage Subscriptions window.
  5. Select the topic you subscribed to from the Topic dropdown menu.
  6. Click + Subscribe.
  7. Close the Manage Subscriptions window.
  8. Observe your message, displayed under Incoming Messages every 10 seconds.
  9. Click Subscribe.
  10. Delete your subscription from the list.

 

Query captured Allen-Bradley data using the JSON DB API

  1. Select DB API from the Select API dropdown menu.
  2. Select the getRecordsByIndex from the JSON Actions dropdown menu.
  3. Replace the JSON in the API Request editor with the following JSON:
    1. {
        "api": "db",
        "action": "getRecordsByIndex",
        "params": {
          "databaseName": "faircom",
          "tableName": "abTable1",
          "indexName": "ts_index"
        },
        "authToken": "replaceWithAuthTokenFromCreateSession"
      }
  4. Click Send request.
  5. Observe the API Response response and ensure the action is completed successfully.
     

Send data to the Allen-Bradley simulator

It is also possible to send data back to the Allen-Bradley server simulator. For instance, you can copy the value from the temperature field in the abTable1 integration table to the OUT_TEMP tag created earlier when server was initialized. 

Create an output with the following JSON action:

{
 "action": "createOutput",
 "params": {
   "outputName": "abOutput",
   "serviceName": "ab",
   "databaseName": "faircom",
   "tableName": "abTable1",
   "settings": {
     "plcAddress": "localhost:4400",
     "plcType": "controllogix",
     "propertyMapList": [
       {
         "eipTagPath": "1,0",
         "eipTagName": "OUT_TEMP",
         "eipTagType": "float32",
         "propertyPath": "temperature"
       }
     ]
   }
 },
 "authToken": "replaceWithAuthTokenFromCreateSession"
}

You can verify that the value of temperature has been written in the OUT_TEMP tag using the command

.\tag_rw2 --type="real32" --tag="protocol=ab-eip&gateway=localhost:4400&path=1,0&plc=controllogix&elem_count=1&name=OUT_TEMP" --timeout=1000 

The output of the previous command should contain this line, which confirms that the value has been written correctly.

data[0]=35.299999