Show TOC

Background documentationJSON Messages for WebSocket Connections

 

PCo supports the following six JSON messages:

Message

Description

GetTemplates

This message lists all notification templates for the running agent instances for which you have created a WebSocket destination system.

Example Example

{ Action: "GetTemplates" }

End of the example.

GetFeatures

This message lists all functions that are supported by the running agent instance.

Example Example

{ Action: "GetFeatures" }

End of the example.

Subscribe

With this message, you can subscribe to the current WebSocket to receive notifications by using the given template.

Example Example

{

Action: "Subscribe",

Params: {

// Obligatory template.

Template:"Template1",

// Obligatory array of tag names with atleast one tag name.

TagNames: [

{ Name: "Random.Int1", IsNative:true, Alias:"Int1"}

],

// Optional trigger. If not set, Always trigger type will be used.

Trigger: {

// The trigger type can be Always, WhileTrue, WhileFalse,

// OnTrue or OnFalse.

Type: WhileTrue,

// The condition is obligatory. It will be ignored if the type

// is Always. Condition: "'Int1' > 0"

}

}

}

End of the example.

Unsubscribe

With the Unsubscribe message you can remove subscriptions. You can specify that the WebSocket is no longer subscribed to specific tags or to entire notifications.

If you want the WebSocket client to remove the subscription for the entire notification, the parameters ought not to be set.

To reduce the load on the source system, the Web clients need to send this command before the WebSocket closes (when you leave the website). Otherwise, the subscription for the notification is maintained.

Example Example

{

Action: "Unsubscribe",

// Optional parameters. Do not send them, if you want to unsubscribe the whole notification.

Params:{

TagNames:[

{ Name : "Random.Int1", IsNative : true, Alias : "Bucket"}

]

}

}

End of the example.

Reconnect

With the Reconnect message, you can reconnect the WebSocket with an existing notification using the given handle.

Example Example

{

Action: "Reconnect",

Params: { Handle : "87726337-1d44-47b3-8f65-91508b6c085e" }

}

End of the example.

Store

With this message, you can write tag values using the given time stamp.

Example Example

{

Action: "Store",

Params: {

TagValues: [

{

TagName: { Name: 'Data Type Examples.16 Bit Device.K Registers.Short1', IsNative: true, Alias: 'Test' }, Value: 111,

DateTime: '2015-03-10T12:00:00'

},

{

TagName: {Name: 'Data Type Examples.16 Bit Device.K Registers.Short2', IsNative: true, Alias: 'Test2' }, Value: 222,

DateTime: '2015-03-10T12:00:00'

}

]

}

}

End of the example.