GraphQL

Tentacle PLC has a GraphQL API which allows external applications (like REST clients and Tentacle PLC) to interact with it programmatically.

Schema Types

Table of Contents

Query

Read only queries

FieldArgumentTypeDescription
infoString!

Information about the Tentacle PLC environment as a string.

metrics[taskMetric!]!

Task diagnostic data

valueatomicVariable

Single value of an atomic variable or class property.Example path for classes: motor1.running where motor1 is the class instance and running is a property of motor1's class.

variablePathString!
values[atomicVariable!]!

Lists all variable and class property values

variables[Variable!]!

Lists all variables

programs[String!]!

Lists all programs

programString!

Returns the code for a single program

nameString!
classes[String!]!

Lists all classes

classString!

Returns the code for a single class

nameString!
configurationconfig!

The current configration

changes[change!]!

Lists all file changes that have occurred since the last PLC restart

plcPlc!

The PLC status information

Mutation

Read/Write queries

FieldArgumentTypeDescription
setValueatomicVariable

Sets the value of an atomic variable. Can only target a single atomic variable or the property of a class. Example path for classes: motor1.running where motor1 is the class instance and running is a property of motor1's class.

variablePathString!
valueString!
runFunctionString

Run the function of a class.Example path for classes: motor1.start where motor1 is the class instance and start is a property of motor1's class.

functionPathString!
argsString
startPlcPlc

Start the PLC runtime if stopped.

stopPlcPlc

Stop the PLC runtime.

restartPlcPlc

Stop the PLC runtime, if running, and the start the PLC with the latest runtime configration.

Objects

Plc

PLC status and diagnostics information

FieldArgumentTypeDescription
runningBoolean!

Variable

Variable configuration

FieldArgumentTypeDescription
nameString!
descriptionString
datatypeString!
initialValueString
persistentBoolean
sourceVariableSource
children[Variable!]!

VariableSource

Variable external source basic configuration

FieldArgumentTypeDescription
typeString!
nameString!
rateInt!
paramsVariableSourceParams

VariableSourceParams

Variable exertnal source parameters, used to configure the source specific to the protocol used

FieldArgumentTypeDescription
registerInt!
registerTypeString!
formatString!

atomicVariable

Atomic Variable type used for String, Numbers, and Booleans

FieldArgumentTypeDescription
pathString!
valueString
datatypeString!

change

File change type to use for change log (since last runtime update)

FieldArgumentTypeDescription
eventString!
pathString!

config

Overall Tentacle PLC configration

FieldArgumentTypeDescription
tasks[configTask!]!
mqtt[configMqtt!]!
modbus[configModbus!]!

configModbus

Modbus client basic configuration

FieldArgumentTypeDescription
nameString!
descriptionString!
configconfigModbusConfig!

configModbusConfig

Modbus client configuration

FieldArgumentTypeDescription
hostString
portInt
unitIdInt
reverseBitsBoolean
reverseWordsBoolean
zeroBasedBoolean
retryRateInt

configMqtt

MQTT Client basic configuration

FieldArgumentTypeDescription
nameString!
descriptionString!
configconfigMqttConfig!

configMqttConfig

Mqtt client configuration

FieldArgumentTypeDescription
serverUrlString
groupIdString
usernameString
passwordString
edgeNodeString
deviceNameString
clientIdString
versionString

configTask

Task configuration

FieldArgumentTypeDescription
nameString!
descriptionString!
scanRateInt!
programString!

taskMetric

Task metrics for diagnostic data

FieldArgumentTypeDescription
taskString!
functionExecutionTimeFloat!
intervalExecutionTimeFloat!
totalScanTimeFloat!

Scalars

Boolean

The Boolean scalar type represents true or false.

Float

The Float scalar type represents signed double-precision fractional values as specified by IEEE 754open in new window.

Int

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

String

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Examples

Query - PLC Running Status

  • Body:

    query {
      plc {
          running
        }
      }
    
  • Response:

    {
      "data": {
          "plc": {
            "running": true
          }
      }
    }
    
  • Postman Snippet:

    image

Mutation - Restart PLC

  • Body:

    mutation {
      restartPlc {
        running
      }
    }
    
  • Response:

    {
      "data": {
          "restartPlc": {
            "running": true
        }
      }
    }
    
  • Postman Snippet:

    image