"alterInput"
(JSON Action)
JSON hub "alterInput"
action modifies an existing FairCom Edge input
The "alterInput"
action alters an existing input connector in FairCom Edge to collect tags automatically from a device or software system. Before you can alter an input, you must use "createInput"
to create it.
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
.
"alterInput"
modifies how an input service collects data from a data source, transforms it, and inserts it into an integration table.For example, an input can configure the OPC UA service to collect data from an external source and write that data to an integration table in FairCom Edge.
You can do the following:
You can change the settings of an input.
You can change the retention policy of the input’s integration table.
You can change the transforms applied to the data when it is inserted into the integration table.
You can change metadata about the input to make it easier to locate.
You cannot do the following:
You cannot change the mapping between the service and the integration table. To do this, you need to create a new input and delete the old one.
You cannot remap a connector service to a different integration table because this mapping is fundamental to the nature of the input. In the future, we may enhance this action to be able to remap the connector service to a different integration table, or we may provide a special action just for this purpose.
The action,
"alterInput"
, is the only way to configure an existing input. If the specified value of"inputName"
does not find an existing input, this action returns an error. To create an input, use the"createInput"
action.
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 request
{ "api": "hub", "action": "createInput", "params": { "inputName": "modbusTCP", "serviceName": "modbus", "settings": { "modbusProtocol": "TCP", "modbusServer": "127.0.0.1", "modbusServerPort": 1505, "propertyMapList": [ { "propertyPath": "temperature", "modbusDataAccess": "holdingregister", "modbusDataAddress": 1199, "modbusUnitId": 5, "modbusDataLen": 1 } ] }, "tableName": "modbusTableTCP" }, "authToken": "replaceWithAuthTokenFromCreateSession" }
{ "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" }
{ "api": "hub", "action": "createInput", "params": { "inputName": "modbusTCP", "serviceName": "modbus", "dataPersistenceStrategy": "onChange", "dataCollectionIntervalMilliseconds": 5000, "immediatelyCollectDataOnStart": true, "sourcePayloadFormat": "binary", "dataCollectionBufferCount": 2, "settings": { "modbusProtocol": "TCP", "modbusServer": "127.0.0.1", "modbusServerPort": 1505, "modbusDataAddressType": "zeroBased", "propertyMapList": [ { "propertyPath": "temperature", "modbusDataAddress": 1199, "modbusDataAccess": "holdingregister", "modbusUnitId": 5, "modbusDataLen": 1, "modbusDataType": "int16SignedAB" }, { "propertyPath": "volume", "modbusDataAddress": 1299, "modbusDataAccess": "holdingregister", "modbusUnitId": 5, "modbusDataLen": 2, "modbusDataType": "ieeeFloat32ABCD" }, { "propertyPath": "status", "modbusDataAddress": 1199, "modbusDataAccess": "coil", "modbusUnitId": 5, "modbusDataLen": 1, "modbusDataType": "int8Signed" } ] }, "ownerName": "admin", "tableName": "modbusTableTCP", "retentionPolicy": "autoPurge", "retentionPeriod": 30, "retentionUnit": "day", "metadata": {} }, "authToken": "replaceWithAuthTokenFromCreateSession" }
A response to a request is "0" when successful. A non-zero value response indicates an error occurred.
{ "result": {}, "requestId": "00000007", "errorCode": 0, "errorMessage": "" }
{ "result": {}, "requestId": "00000011", "debugInfo": { "request": { "api": "hub", "action": "createInput", "params": { "inputName": "modbusTCP", "serviceName": "modbus", "settings": { "modbusProtocol": "TCP", "modbusServer": "127.0.0.1", "modbusServerPort": 1505, "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" }
Use the alterInput JSON API action to alter an existing input connector in FairCom edge
The "params"
property is an object that contains an action's parameters. Each action defines its own required and optional properties. See System limits for a comprehensive look at property requirements and limitations.
"params"
property summariesProperty | Description | Default | Type | Limits (inclusive) | ||||||
---|---|---|---|---|---|---|---|---|---|---|
(optional) specifies the number of milliseconds to wait until reading PLC data again. For example, |
| integer | 0 and negative values are invalid. | |||||||
(optional) specifies the number of times the collector retrieves and caches data from the device before writing the data to the integration table |
| integer |
| |||||||
(optional) specifies when the connector writes collected data to the specified table |
| string |
| |||||||
(optional) configures the input to collect data immediately when the server or connector starts. This occurs even if the data persistence strategy is to collect data changes |
| Boolean |
| |||||||
inputName | (optional) contains a unique name for the mapping of a data source to an input plugin to an integration table | A FairCom generated name that follows the pattern | string | 1 to 100 bytes | ||||||
(optional) exists primarily for the user interface to find integration information |
| object | May contain any number and type of user-defined properties | |||||||
(optional) contains properties needed to configure the data source of the specified plugin |
| object | ||||||||
(optional) specifies the variant type format of the |
| string |
| |||||||
(optional) specifies the name of a transform process you have created. See the "createTransform" and "alterTransform" actions |
| string | 1 to 64 bytes |
The "dataCollectionBufferCount"
property specifies the number of times the collector retrieves and caches data from the device before writing the data to the integration table.
This option combines multiple data collection events and inserts them into the integration table as one MQTT message.
If this value is more than 1
, the connector converts each set of collected data into a JSON object and adds the object to an array inside a JSON document. When the count is reached, the connector writes the JSON document to the source_payload
field of a record it inserts into the integration table.
The "dataCollectionIntervalMilliseconds"
property schedules the connector to collect data periodically using the specified number of milliseconds. It defaults to 10000
, which is ten seconds. It must be an integer number >= 1
.
The "dataPersistenceStrategy"
property controls when a connector writes collected data to a record in the input table specified by "tableName"
. It is an optional string enum property with two values: "onSchedule"
and "onChange"
. The default value when the property is omitted or set to null
is "onSchedule"
.
The
"onSchedule"
setting causes the connector to persist each collected value, which occurs on the schedule set by the"dataCollectionIntervalMilliseconds"
property. This setting is useful for continuously collecting device data for trend analysis and machine learning.The
"onChange"
setting causes the connector to collect data on the schedule set by the"dataCollectionIntervalMilliseconds"
property, but it only persists data when it changes. This allows the connector to detect and store data changes as events, such as alerts and status updates. This setting greatly reduces data storage for infrequently changing telemetry, such as changes to a temperature sensor.Note
The connector misses events when its data collection schedule is not frequent enough to see data changes. Thus, the
"onChange"
setting makes a polling protocol, such as Modbus, behave like a push protocol, but it is not a push protocol like MQTT.
The "immediatelyCollectDataOnStart"
property controls how a connector first collects data after being started.
When
true
, it immediately collects and stores data and thereafter collects data according to the strategy specified in"dataPersistenceStrategy"
. In other words, it ignores the"dataPersistenceStrategy"
for the initial data collection event and unconditionally stores the first set of data it collects. This setting allows subscribers to receive an initial data collection message each time the server or connector starts, which is useful for systems that display live status information.When
false
, which is the default, it collects data according to the strategy specified in"dataPersistenceStrategy"
. For example, when the"dataPersistenceStrategy"
is"onChange"
, the connector collects data on a schedule and persists it only when the data changes - even after a restart.
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.", }
The "settings"
property contains properties that are specific for each connector type. Settings for Modbus are different than settings for OPC UA, and so forth. See the API reference "params" property of each connector for details of the "settings"
property for that connector.
Connector-specific "settings"
The "sourcePayloadFormat"
property is an optional string that specifies the expected data type of the MQTT payload. When omitted or set to null
, it defaults to "binary"
. When the server receives an MQTT message, it always takes the binary value from the MQTT payload and stores it in the source_payload
field. The source_payload
field is a variant, which means it stores the type of data it contains. If there are no errors in validating the MQTT payload to match the type specified in "sourcePayloadFormat"
, the server assigns the value of "sourcePayloadFormat"
as the variant field's type.
Depending on the values of the "sourcePayloadFormat"
and "validateMqttPayload"
properties, the server may validate the MQTT payload to ensure it matches the type. The default value for the "validateMqttPayload"
property is true
. The server may also convert the MQTT payload into another form before storing it. If the MQTT payload does not match the type or cannot be converted, the server stores the payload in the source_payload
field, sets its variant type to "binary"
, and sets the error field to 1
to indicate there is an error. It also adds an error entry to the JSON array in the log field.
FairCom's MQTT server does the following when a topic receives an MQTT message and "sourcePayloadFormat"
is set to one of the following values:
"sourcePayloadFormat" Value | Description |
---|---|
| The server stores the MQTT payload in the |
| The server stores the MQTT payload in the
|
| The server stores the MQTT payload in the
|
| The server validates the payload as a variant object.
The server ignores the value of |
| The server stores the MQTT payload in the |
| The server stores the MQTT payload in the |
| The server stores the MQTT payload in the |
This property is a hint to the server about the format and type of the MQTT message payload.
This property does not cause server to validate the MQTT payload to see if it matches the type you set. The server stores the payload as is without validation. For example, setting the type to
"json"
, it does not stop the server from receiving and storing a non-JSON value or invalid JSON document in the source payload.The FairCom Edge Explorer application may use the value of this property to determine the default way to display a topic's payload.
The transform engine may use the value of this property to help it transform the source payload.
The "transformName"
property is an optional string that contains the unique name of a transform process, which consists of one or more transform steps.
The value of "transformName"
must be the name of a transform process you created. It cannot be the name of a FairCom-provided transform method.
You must create a transform before you can assign it to an integration table. See the "createTransform"
and "alterTransform"
actions.
A transform is a process that works like a pipeline where the output of one transformation can become the input for another transformation.
The following actions use the
"transformName"
property to assign a transform to an integration table:"configureTopic"
"createInput"
"alterInput"
"createIntegrationTable"
"alterIntegrationTable"