The "createInput" action creates a new input. It configures a service to collect tags from a data source and insert those tags into an integration table.
Note A tag is a piece of named data with an associated value. For example, the tag
temperature 70includes both the named data temperature and the value70. 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 of70.
- An input configures a connector to collect data tags periodically from a device and store them in an integration table. For example, an input can configure the OPC UA connector to collect and store data from an OPC UA device.
- An input is a mapping from a service to an integration table.
- The action
"createInput"is the only way to create this mapping. If the mapping already exists, this action returns an error. To modify an existing input, use the"alterInput"action.
- The action
- Each input typically configures a connector to store data in its own dedicated integration table.
- You may create multiple inputs that configure a variety of connectors to collect data from different devices for storage in the same integration table. This is useful when different devices collect the same type of data, such as temperature, and you want all temperature data to be stored in one table.
- When you want the same collected data to exist in multiple integration tables, to publish the data to multiple MQTT topics for example, you can create a
"jsonToDifferentTableFields"transform to replicate data from one integration table to another. - If the specified integration table does not exist when an input is created, FairCom Edge creates it.
- A connector inserts records into an integration table, which is a historical log of data collection events. If your account has permissions, you may also update or delete collected records.
- A connector typically converts the data tags it collects into JSON and writes them to the
"source_payload"field of a newly inserted record. - Transforms can take data from the
"source_payload"field (or from other fields in the table), transform it, and place the results in other fields, such as user-defined fields.
Request examples
The following examples are for the Modbus connector. For examples of other connectors, visit the Allen-Bradley, OPC UA, or Siemens S7 API references.
Minimal
{
"action": "createInput",
"params": {
"inputName": "modbusTCP",
"serviceName": "modbus",
"settings": {
"modbusProtocol": "TCP",
"modbusServer": "127.0.0.1",
"modbusServerPort": 502,
"propertyMapList": [
{
"propertyPath": "temperature",
"modbusDataAccess": "holdingregister",
"modbusDataAddress": 1199,
"modbusUnitId": 5,
"modbusDataLen": 1
}
]
},
"tableName": "modbusTableTCP"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}RTU
{
"api": "hub",
"action": "createInput",
"params": {
"inputName": "modbusRTU",
"serviceName": "modbus",
"dataPersistenceStrategy": "onChange",
"dataCollectionIntervalMilliseconds": 5000,
"immediatelyCollectDataOnStart": true,
"dataCollectionBufferCount": 2,
"settings": {
"modbusProtocol": "RTU",
"modbusSerialPort": "COM2",
"modbusBaudRate": 19200,
"modbusParity": "None",
"modbusDataBits": 8,
"modbusStopBits": 2,
"propertyMapList": [
{
"propertyPath": "temperature",
"modbusDataAccess": "holdingregister",
"modbusDataAddress": 1199,
"modbusUnitId": 5,
"modbusDataLen": 1
}
]
},
"tableName": "modbusTableRTU"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Maximal
{
"api": "hub",
"action": "createInput",
"params": {
"inputName": "modbusTCP",
"serviceName": "modbus",
"databaseName": "ctreeSQL",
"ownerName": "admin",
"tableName": "modbusTableTCP",
"settings": {
"modbusProtocol": "TCP",
"modbusServer": "127.0.0.1",
"modbusServerPort": 502,
"modbusDataCollectionIntervalMilliseconds": 15000,
"propertyMapList": [
{
"propertyPath": "temperature",
"modbusDataAddress": 1199,
"modbusDataAccess": "holdingregister",
"modbusUnitId": 5,
"modbusDataLen": 1
},
{
"propertyPath": "volume",
"modbusDataAddress": 1299,
"modbusDataAccess": "holdingregister",
"modbusUnitId": 5,
"modbusByteOrder": "ABCD",
"modbusDataLen": 2
},
{
"propertyPath": "status",
"modbusDataAddress": 1199,
"modbusDataAccess": "coil",
"modbusUnitId": 5,
"modbusDataLen": 1
}
]
},
"retentionPolicy": "autoPurge",
"retentionPeriod": 4,
"retentionUnit": "week",
"metadata": {}
},
"requestId": "00000007",
"authToken": "replaceWithAuthTokenFromCreateSession"
}Conditional Data Persistence Code Example
{
"api": "hub",
"action": "createInput",
"params": {
"inputName": "modbusTCP",
"serviceName": "modbus",
"dataCollectionIntervalMilliseconds": 1000,
"dataPersistenceStrategy": "onChange",
"onChangeScope": "saveSpecificTags",
"onChangeScopeTags": ["t1"],
"onChangeTrigger": "saveWhenAnySpecifiedTagHasChanged",
"onChangeTriggerTags": ["t1"],
"maxUnsavedEvents": 360,
"databaseName": "faircom",
"ownerName": "admin",
"tableName": "modbusTableTCP",
"retentionPolicy": "autoPurge",
"retentionPeriod": 30,
"retentionUnit": "day",
"dataCollectionBufferCount": 1,
"immediatelyCollectDataOnStart": false,
"metadata": {},
"settings": {
"modbusProtocol": "TCP",
"modbusServer": "127.0.0.1",
"modbusServerPort": 502,
"propertyMapList": [
{
"propertyPath": "temperature",
"modbusDataAccess": "holdingregister",
"modbusDataAddress": 4003,
"modbusDataType": "int8Signed",
"normalLowerLimit": 10,
"normalUpperLimit": 30,
"deadbandLowerLimit": 17,
"deadbandUpperLimit": 19,
"significantMagnitude": 0.3
}
]
}
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Turn off data collection
The following example creates an input connector with data collection turned off, which is not the default behavior.
{
"action": "createInput",
"params": {
"inputName": "INPUT: PLC 74 & Modbus",
"serviceName": "modbus",
"thingName": "PLC 74",
"tableName": "temperature",
"enabled": false,
"dataCollectionIntervalMilliseconds": 1000,
"settings": {
"modbusProtocol": "TCP",
"modbusServer": "127.0.0.1",
"modbusServerPort": 502,
"propertyMapList": [
{
"propertyPath":"temperature",
"tagName": "plc74_modbus_temperature",
"modbusDataAddress": 2000,
"modbusDataAccess": "inputRegister",
"modbusUnitId": 5,
"modbusDataLen": 1
}
]
}
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Response examples
A response to a request is "0" when successful. A non-zero value response indicates an error occurred.
Success
{
"result": {},
"requestId": "00000007",
"errorCode": 0,
"errorMessage": ""
}Failure
{
"result": {},
"requestId": "00000011",
"debugInfo": {
"request": {
"api": "hub",
"action": "createInput",
"params": {
"inputName": "modbusTCP",
"serviceName": "modbus",
"settings": {
"modbusProtocol": "TCP",
"modbusServer": "127.0.0.1",
"modbusServerPort": 502,
"propertyMapList": [
{
"propertyPath": "temperature",
"modbusDataAddress": "holdingregister",
"modbusDataAddress": 1199,
"modbusUnitId": 5,
"modbusDataLen": 1
}
]
},
"tableName": "modbusTableTCP"
},
"requestId": "00000011",
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
},
"errorCode": 12012,
"errorMessage": "There is already an integration with name of [modbusTCP].",
"authToken": "replaceWithAuthTokenFromCreateSession"
}Turn off data collection
See the API reference for each connector for more details on connector specific properties.
{
"result": {
"data": [
{
"inputName": "INPUT: PLC 74 & Modbus",
"serviceName": "modbus",
"thingName": "PLC 74",
"tableName": "temperature",
"enabled": false,
"running": false,
"stopCode": 14400,
"stopReason": "Connector is disabled. Enable it to continue.",
"dataCollectionIntervalMilliseconds": 1000,
"settings": {
"modbusProtocol": "TCP",
"modbusServer": "127.0.0.1",
"modbusServerPort": 502,
"propertyMapList": [
{
"tagName": "plc74_modbus_temperature",
"sourceFieldName": "temperature_celsius",
"sourcePayloadPath": "celsius",
"propertyPath": "celsius",
"modbusDataAddress": 2000,
"modbusDataAccess": "inputRegister",
"modbusUnitId": 5,
"modbusDataLen": 1
}
]
},
"databaseName": "ctreeSQL",
"ownerName": "admin",
"tableName": "modbustabletcp",
"metadata": {
},
"retentionPolicy": "autoPurge",
"retentionPeriod": 30,
"retentionUnit": "day"
}
]
},
"requestId": "00000027",
"errorCode": 0,
"errorMessage": ""
}
Properties
Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
databaseName |
The You specify this property when you want to use a different database instead of the default. Your session's account must have the appropriate privileges to access the code package. This property is useful because objects, such as tables and code packages, can have the same name in multiple databases. This feature allows you to create multiple environments in the same server and reuse the same JSON actions in each environment. For example, you can create It is an error to set If no default database is specified during |
Defaults to the session's "defaultDatabaseName" property |
string | 1 to 64 bytes |
dataCollectionBufferCount |
The This option combines multiple data collection events and inserts them into the integration table as one MQTT message. If this value is more than |
Optional with default of 1
|
integer |
1 to 65535
|
dataCollectionIntervalMilliseconds |
The |
Optional with default of 10000 (10 seconds). |
integer |
0 and negative values are invalid. |
dataPersistenceStrategy |
The
|
Optional with default of "onSchedule"
|
string |
|
enabled |
The "enabled" property turns on or off an input or output connector. Thus, it pauses or starts data collection or delivery. |
Optional with default of true
|
Boolean |
|
immediatelyCollectDataOnStart |
The
|
Optional with default of false
|
Boolean |
|
inputName |
The "params": {
"inputName": "modbusTCP",
"serviceName": "modbus"
} |
Required - No default value |
string | 1 to 100 bytes |
maxUnsavedEvents |
The
|
Optional with default of "disabled"
|
integer |
1 to
4294967296
|
metadata |
The "metadata" property contains user-defined properties that add keywords and tags about the code package. The server indexes this field with a full-text index so you can search for any word or phrase to find code packages. |
Optional with default of {}
|
object | 0 or more key/value pairs |
onChangeScope |
The "onChangeScope" property specifies which tags the connector saves to an integration table. For more details, see "onChangeScope". |
Optional with default of "saveAllTags"
|
string enum |
|
onChangeScopeTags |
The "onChangeScopeTags" property specifies which tags the connector should save to the integration table when a save event occurs. Each "propertyPath" value is the connector's unique identifier to a collected data item, which is commonly called a "tag". For more details, see "onChangeScopeTags". |
Required when the "onChangeScope" property is set to "saveSpecificTags". |
array of strings | 1 or more strings |
onChangeTrigger |
The "onChangeTrigger" property specifies when the connector saves collected tags to an integration table. For more details, see "onChangeTrigger". |
Optional with default of "saveWhenAnyTagHasChanged"
|
string enum |
"saveWhenAnyTagHasChanged""saveWhenAllTagsHaveChanged""saveWhenAnySpecifiedTagHasChanged""saveWhenAllSpecifiedTagsHaveChanged"
|
onChangeTriggerTags |
The "onChangeTriggerTags" property specifies tags to work with the "onChangeTrigger" property to control when a connector saves collected data to an integration table. Each "propertyPath" value is the connector's unique identifier to a collected data item, which is commonly called a "tag". For more details, see "onChangeTriggerTags". |
Required when the "onChangeTrigger" property has one of the following values: "saveWhenAnySpecifiedTagHasChanged" or "saveWhenAllSpecifiedTagsHaveChanged". |
array of strings | 1 or more strings |
ownerName |
The You specify this property when you want to use a different account instead of the default. Your session's account must have the appropriate privileges to access the code package. This property is useful because objects, such as tables and code packages, can have the same name in the same database as long as different accounts own each object. This feature allows you to create duplicate objects for different users on the same server and reuse the same JSON actions on those objects. For example, an administrator can copy objects from a production environment to her account so she can troubleshoot an issue using the same JSON actions, JavaScript, and SQL code. It is an error to set If no default owner is specified during |
Optional with default of the session's "defaultOwnerName" property |
string | 1 to 64 bytes |
retentionPeriod |
The |
Optional with default of |
integer |
1 to 100
|
retentionPolicy |
The If not specified, the default found in the
retentionPolicy values:
|
Optional with default of |
string |
|
retentionUnit |
The If not specified, the default found in the
|
Optional with default of |
string |
|
serviceName |
The See the The following services are available as of the V5 release:
|
Required - No default value | string | 1 to 64 bytes |
settings |
The Connector-specific "settings" |
Optional with default of {}
|
object | |
tableName |
The See table name in System limits for the table naming requirements and limitations.
"params": {
"tableName": "ctreeTable"
} |
Required - No default value | string | 1 to 64 bytes |
thingName |
The "thingName" property specifies the unique name of a thing. It cannot be the empty string "". |
Required - No default value | string | 1 to 64 bytes |
Response properties ("result")
| Property | Description | Type | Limits (inclusive) |
|---|---|---|---|
data |
The |
array of objects | The action determines its contents. |
|
data .databaseName |
The
|
string | 1 to 64 bytes |
|
data .dataCollectionIntervalMilliseconds |
The |
integer |
0 and negative values are invalid. |
|
data .enabled |
|
boolean |
truefalse
|
|
data .inputName |
The "inputName" property specifies the unique name of an input. |
string | 1 to 64 bytes |
|
data .metadata |
The |
JSON | 0 to 65,500 bytes |
|
data .ownerName |
The "ownerName" property identifies the user who owns an object (see Object owner). |
string | 0 to 64 bytes |
|
data .retentionPeriod |
The |
integer |
1 to 100
|
|
data .retentionPolicy |
The If not specified, the default found in the
retentionPolicy values:
|
string |
|
|
data .retentionUnit |
The If not specified, the default found in the
|
string |
|
|
data .running |
The "running" property is true when an input connector is collecting data or an output connector is delivering data; otherwise, it is false. A disabled connector will never be running. An enabled connector may or may not be running. |
Boolean |
|
|
data .serviceName |
The See the The following services are available as of the V5 release:
|
string | A service name between 1 and 64 bytes. |
|
data .settings |
The |
object | |
|
data .stopCode |
The "stopCode" property is 0 when the connector is successfully connected to its device or software; otherwise, it is non-zero. |
integer |
-2147483648 to 2147483647
|
|
data .stopReason |
The "stopReason" property is "" when the input connector is collecting data; otherwise, it is a non-empty string. |
string | 0 to 256 bytes |
|
data .tableName |
The See table name in System limits for the table naming requirements and limitations. |
string | 1 to 64 bytes |
|
data .thingName |
The "thingName" property specifies the unique name of a thing. |
string | 1 to 64 bytes |