• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - Sequencer
  • ProtobufEncode

ProtobufEncode

ProtobufEncode

The ProtobufEncode block is an operator, that allows to encode input arguments as fields in Protocol Buffers message encoding.

Protocol Buffers (protobuf) is a method for serializing structured data, developed by Google. It is designed to be a language-agnostic, platform-neutral, and extensible mechanism for serializing structured data. Protocol Buffers is widely used for communication protocols, data storage, and configuration files, among other things.

Protocol Buffers uses an Interface Definition Language (IDL) to define data structures - message types and their fields. Protocol Buffers definitions are usually contained in the files having .proto extension and have to be compiled to the programming language used by the application using protoc compiler. For this block you only need to copy the definitions into the block Proto attribute value instead and the definitions will be runtime-compiled from there.

Arguments

NameAppearanceDescription
Protocol Buffers message field name to encodeAny number of user-configurable input argumentsArgument value will be encoded to output as Protocol Buffers message field
OutPredefined output argumentThe Protocol Buffers encoded message (binary string)

Properties

NameDescription
ProtoProtocol Buffers message definition in Interface Definition Language (IDL). It can be copied here from the .proto file, used for the particular communication definition.
MessageMessage name to use from the Protocol Buffers definition for the output encoding. There can be several messages described in the Proto definition, but only the one named in Message is used for this operator for encoding.

Note: The encoded message (Out argument) may contain non-printable characters that are not always printable in the CDP Studio Block Diagram next to the connection line. But you can still get some printed representation of the message binary body from the Table Editor or in the Block Diagram sidebar.

Example

The following block diagram shows how to encode a Protocol Buffers message like this:

syntax = "proto3";
message SensorInfo {
  string name = 1;
  uint64 timestamp = 2;
  double value = 3;
}

The ProtobufEncode operator Proto attribute was set to the message definition given above and the Message attribute was set to SensorInfo. To get the message field values for encoding, 3 input arguments were added to the block: name (Sequencer.Argument<string>), timestamp ((Sequencer.Argument<uint64_t>) and value ((Sequencer.Argument<string>)). These arguments' current values (and as for all operators, the argument values can be routed from any value object in CDP) will be used to encode and output the Protocol Buffers message, as can be seen in the block diagram (with the sidebar, to show the argument and attribute values):

See also ProtobufEncoder, ProtobufDecode, and Argument.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top