Kaspersky Industrial CyberSecurity for Networks API Developer's Guide

Getting tags

This section explains how to get tags by using Kaspersky Industrial CyberSecurity for Networks API.

Overview

Tags are values that describe parameters of an industrial process. For example, a manufacturing process involving a thermal oxidizer may have temperature, residence time, and turbulence among many other tags.

You can get information about tags by using the TagProvider service methods. This service is defined in the tag_provider_service.proto file. Messages and enumerations are defined in the tag_provider.proto, tag_provider_service.proto, and common.proto files.

The TagProvider service has the following method for getting tags:

  • GetTags

    Returns tags. You can specify a filter for tags.

    This method is synchronous. The response time for this method depends on the number of requested tags.

Getting tags (example)

To get all tags, use the GetTags method and specify an empty filter. This method returns a stream of tags.

In the following example, a stub requests all tags.

tagStub = tag_provider_service_pb2_grpc.TagProviderStub(channel)

 

#rpc GetTags(TagsRequest) returns(stream Tag);

 

request = tag_provider_service_pb2.TagsRequest(filter = "")

response = tagStub.GetTags(request)

 

for tag in response:

if tag.HasField("boolVal"):

value = tag.boolVal

elif tag.HasField("int64Val"):

value = tag.int64Val

elif tag.HasField("doubleVal"):

value = tag.doubleVal

elif tag.HasField("stringVal"):

value = tag.stringVal

elif tag.HasField("binaryVal"):

value = tag.binaryVal

else:

value = "No value"

print("\n\n")

print("Tag:", tag.id,

"| Name:", tag.briefInfo.name,

"| Description:", tag.briefInfo.description,

"| Changed at:", datetime.datetime.utcfromtimestamp(tag.timestamp.seconds).strftime('%Y-%m-%d %H:%M:%S'),

"| Value type: ", tag.WhichOneof("value"),

"| Value: ", value)