Skip to main content

"createOutput" (jsonAction)

JSON hub "createOutput" action creates a new FairCom Edge integration

The "createOutput" action creates a new integration.

  • An integration connects data in the server to an output plugin that delivers tags from the server to external systems, such as connecting the integration table populated by OPC UA to the ThingWorx connector.

    • The data source for an output definition is an integration table.

    • An output plugin delivers tags from an integration table in FairCom Edge over an external protocol, such as OPC UA, to an external system, such as a device or Manufacturing Execution System (MES).

  • Each integration table can have zero or more integrations assigned to it. Thus, multiple plugins can read from the same integration table. For example, the MQTT and THINGWORX plugins can use the same integration table.

    Note

    Use "mqtt_configureTopic" to connect MQTT to an existing integration table.

Note

A tag is a piece of named data with an associated value. For example, the tag temperature 70 includes both the named data temperature and the value 70. In JSON, a tag is a JSON property, such as "temperature": 70. In a SQL table, a tag is a data field, such as a field named temperature with a value of 70.

Request examples

Minimal

{
    "api": "hub",
    "action": "createOutput",
    "params": {
        "outputName": "writeEverythingToModbus",
        "databaseName": "faircom",
        "tableName": "modbusTableTCP",
        "serviceName": "modbus",
        "settings": {
            "modbusProtocol": "TCP",
            "modbusServer": "127.0.0.1",
            "modbusServerPort": 1505,
            "propertyMapList": [
                {
                    "propertyPath": "source_payload",
                    "modbusDataAddress": 1199,
                    "modbusDataAccess": "holdingregister",
                    "modbusUnitId": 5,
                    "modbusDataLen": 1
                }
            ]
        }
    },
    "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
    "api": "hub",
    "action": "createOutput",
    "params": {
        "outputName": "writeTemperatureToModbus",
        "serviceName": "modbus",
        "databaseName": "faircom",
        "ownerName": "admin",
        "tableName": "modbus1",
        "sourceFields": [
            "source_payload"
        ],
        "settings": {
            "modbusProtocol": "TCP",
            "modbusServer": "127.0.0.1",
            "modbusServerPort": 1505,
            "propertyMapList": [
                {
                    "propertyPath": "source_payload.temperature",
                    "modbusDataAddress": 1199,
                    "modbusDataAccess": "holdingregister",
                    "modbusUnitId": 5,
                    "modbusDataLen": 1
                }
            ]
        }
    },
    "responseOptions": {
        "binaryFormat": "hex",
        "dataFormat": "objects",
        "numberFormat": "string",
        "includeFields": [],
        "excludeFields": []
    },
    "authToken": "replaceWithAuthTokenFromCreateSession",
    "requestId": "3",
    "debug": "max"
}
{
  "result": {},
  "requestId": "00000004",
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

Use the createOutput JSON API action to creates a new FairCom Edge integration

JSON hub APIAPI actionsjsonActionoutput actionscreate outputcreateOutput

The "params" property is an object that contains an action's parameters. Each action defines its own required and optional properties.

Table 1. "params" property summaries

Property

Description

Default

Type

Limits (inclusive)

databaseName

(optional) specifies the name of a database

Defaults to the "defaultDatabaseName" value that is set during "createSession". If no default is set during "createSession", then "faircom" is used.

string

1 to 64 bytes

metadata

(optional) exists primarily for the user interface to find integration information

{}

object

May contain any number and type of user-defined properties

outputFieldName

(optional) specifies the field that the MQTT Subscription engine should use as the payload when it sends the payload to subscribers

"source_payload"

string

"source_payload"
"t1"
"t2"
"t3"
"t4"
"t5"
"t6"
"t7"
"t8"
"t9"

outputName

(optional) specifies a unique name for mapping of an integration table to an output plugin to an external system

A FairCom generated name that follows the pattern "Output #n from <databaseName>.<schemaName>.<tableName> to <pluginName>"

string

1 to 64 bytes

serviceName

specifies the name of a service that collects data from an external source and inserts it into an integration table

Required - No default value

string

1 to 64 bytes

"modbus"
"opcua"
"rest"
"thingWorx"

settings

(optional) contains properties needed to configure the data source of the specified plugin

{}

object

settings
.body

(optional) specifies information to send to a REST server

[]

array of objects

settings
.body
.propertyPath

specifies the name of data to be defined by "propertyValue"

Required - No default value

string

settings
.body
.propertyValue

specifies an array of properties that define the data of a named "propertyPath"

Required - No default value

object

settings
.headers

(optional) specifies additional information about the request. It is a list of elements with the key-value format

{}

List of strings with the format key: value

settings
.host

specifies the IP or hostname of the Rest resource, including port

Required - No default value

string

settings
.threshold

(optional) specifies properties that define the threshold for sending a REST command

settings
.uri

specifies the identifier name of the REST resource

Required - No default value

string

sourceFields

(optional) specifies the fields the FairCom server makes available to the output connector

[]

array

tableName

(optional) specifies the name of a table

""

string

1 to 64 bytes



The "databaseName" property is an optional string that specifies the database that contains the tables. It defaults to the database name supplied at login.

Note

In the API Explorer, "defaultDatabaseName" is set to "ctreeSQL" in the "createSession" action that happens at login.

  • A zero-length "databaseName" is invalid.

  • Its limits are from 0 to 64 bytes.

  • If the "databaseName" property is omitted or set to null, the server will use the default database name specified at login.

  • If no default database is specified during "createSession", "defaultDatabaseName" will be set to the "defaultDatabaseName" value that is specified in the services.json file.

The "metadata" property is an optional JSON object. It exists primarily for the user interface to find integration information. By default, it is an empty JSON object.

  • It contains a flexible set of properties.

  • It typically contains tags and description properties.

Example

{
  "description": "",
  "tags": [""],
  "yourOwnProperties": "usage, purpose, notes, location, etc.",
}
Table 2. "settings" property summaries

Property

Description

Default

Type

Limits

host

contains the IP or hostname of the Rest resource, including the port

Required - No default

string

uri

contains the identifier name of the REST resource

Required - No default

string

headers

contains additional information about the request. It is a list of elements with the key-value format

""

List of strings with the format key: value

body

contains information to send to a REST server.

[]

array of objects

body
.propertyPath

specifies the name of data to be defined by "propertyValue".

[Required]

No default

string

body
.propertyValue

contains an array of properties that define the data of a named "propertyPath".

[Required]

No default.

object

threshold

contains properties that define the threshold for sending a REST command



This is a required object that contains properties that define the data values of a "propertyPath". It is required and has no default value.

The data values specified in the "propertyValue" object can be a string or an object.

  • "fromConstant" indicates the value is a string. For example —

    "propertyValue": {"fromConstant": "0002"}

  • "fromSourcePropertyPath" indicates the value is an object. For example —

    "propertyValue": {"fromSourcePropertyPath": { "formatString": "Temperature = <%input_temp%>" }}

    Characters in the "formatString" value that are enclosed by "<%" and "%>", specify the name as an input property that will be replaced by an input property value.

    Here is a REST command example for the "propertyPath" named "description", that received an input_temp value of 103:

    {  description: "Temperature = 103."}

    If the input value is not found, it is replaced with NULL:

    {  description: "Temperature = NULL."}

The "outputFieldName" property is an optional string that contains the name of a field from an integration table. It defaults to "source_payload".

The optional "sourceFields" property specifies the fields the FairCom server makes available to the output connector. The server creates a JSON object from the fields you specify and the output connector uses it as its source data. If "sourceFields" is omitted, set to null or [], the FairCom server defaults to creating a JSON document that contains all fields from the integration table. This default allows the output connector to send data to a device from any field in the table.

An integration table has many fields, such as fields populated by transforms and MQTT. Converting all fields into JSON is slower than converting only the fields needed by the output connector. For example, input connectors and MQTT messages store their data in the source_payload field. You can use "sourceFields": ["source_payload"] to make only the source_payload field available to the output connector.

When you configure an output connector, you add propertyMap objects to the "propertyMapList". Each propertyMap object extracts data from one field and writes that data to the connected device. The value of the "propertyPath" property is a string containing the path of the data. It always starts with a field name in the "sourceFields" property. For example, if "sourceFields" is set to ["pressure"], then you must set "propertyPath" to "pressure" to use the pressure field’s value in your output. If the value you want to extract is a JSON property nested inside a field, you must add its full path to the "propertyPath". For example, if "sourceFields" is set to ["source_payload"] and source payload contains a JSON object with a "temperature" property, then you must set "propertyPath" to "source_payload.temperature".

The "tableName" property contains the name of the table in the database where the event occurred. It is a non-zero-length string.

A table name may contain up to 64 ASCII characters and must not start with a number.

A table in DBnotify is defined by "databaseName", "ownerName" and "tableName" or by "dataFilePath".

Would you like to provide feedback?