ctGateway Gateway Technical Sheet

2025.4.23 Version 1.0

Update history

Time

content

chapter

2025.4.23

The supported protocols add the basic functions of smart meters DLT645, S7 and OPC-UA

3.4

directory

ctGateway Gateway Technical Sheet... 1

2025.4.23 Version 1.0. 1

Update history... 1

1 Overview... 2

2 Core Concepts... 2

3 Features... 2

3.1 Supported Systems... 2

3.2 Supported Platform Communication Carriers... 3

3.3 Supported Platforms... 3

3.4 Supported Device Protocols... 3

3.5 Supported Data Acquisition Functions... 3

3.6 Kunlun Tongtai touch screen device information export file support... 4

3.7 Compression... 4

3.8 Encryption... 4

4 Performance Indicators... 4

4.1 Real-time... 4

4.2 Number of Supported Devices... 5

4.3 Traffic Estimation... 5

5 Composition of Documents... 5

5.1 System Files... 5

5.2 Program Files... 5

6 Design Details... 6

6.1 Device Discovery... 6

6.2 LED Status... 6

6.3 Reset Button... 6

6.4 Data Serial Number... 7

6.5 No loss of data when power is lost... 7

6.6 Data will not be lost when the network is disconnected... 7

6.7 Online Upgrades... 7

6.8 Reliability Design... 7

 

 

1 Overview

The gateway program is implemented in C++ and uses the utf-8 character set, which the platform must use. If the device channel data is a string, you can specify the transmission mode or automatically convert the character set through parameter configuration.

It supports Modbus, transparent transmission, MQTT and MQTTS.

Log files and data files are limited in size to ensure that there is no disk full failure.

The data is saved instantly to ensure that the power is not lost.

The data sequence number and confirmation mechanism ensure that there is no data loss from the gateway to the platform.

The storage capacity of the network is different depending on the amount of data, and the gateway supports data compression.

2 Core Concepts

3 Features

3.1 Supported Systems

serial number

system

Support status

illustrate

1

Linux/Arm64

Priority support, full functionality

In the lite version of Linux, the dependent libraries need to be compiled by themselves

2

Linux/Arm

Complete basic tests, be able to run, and be able to report modbus_tcp data

Full Linux, you can install the required packages directly

3

 

 

 

 

3.2 Supported Platform Communication Carriers

serial number

The name of the agreement

Support status

illustrate

1

MQTT

Already: MQTT

Already: MQTTS

 

2

HTTP

Plan:

Dependent on the platform

 

3.3 Supported Platforms

serial number

The name of the platform

Supported features

illustrate

1

Demo platform

All instructions

That is, the supporting management tools

2

 

 

 

3.4 Supported Device Protocols

serial number

The name of the agreement

Support status

illustrate

1

Modbus

Already: TCP, RTU, RTU_TCP

Not sure: ASCII

The protocol libraries currently in use do not support Modbus-ASCII and are rarely used

2

Transparent transmission

Already: TCP, serial

Escalate any data received

Deliver any data through the platform

Send instructions at regular intervals

3

Smart meters

Already: DLT645-1997, DLT645-2007

 

4

Siemens S7

Soon

The basic function modules have been incorporated, and the configuration part has not yet been implemented

3

OPCUA

Soon

The basic function modules have been incorporated, and the configuration part has not yet been implemented

4

customize

plan

Customizable

3.5 Supported Data Acquisition Functions

serial number

name

Support status

illustrate

1

Periodical escalation

already

Report at a set interval

2

Change escalation

already

At a set period (milliseconds, less than each acquisition time is equivalent to a cyclic acquisition)

3

Dependent escalation

already

Report when the dependent channel is reported (usually the dependent channel is of the change reporting type)

4

Recapture all when you change

already

 

3.6 Kunlun Tongtai touch screen device information export file support

It supports direct import of the export file of Kunlun Tongtai touch screen, and currently directly imports the csv file corresponding to deviceCode, and automatically converts local encoding to UTF-8 (do not convert encoding in advance).

The original value of the channel acquisition frequency is usually 1, which means that it is not specially set (it follows the period setting of the device). Modify to implement specific features for the following scopes:

l 1XX represents differential upload, where XX represents the percentage. 100 represents different uploads.

l 2XX represents the difference when uploading all.

l 5XXXX represents the dependent upload, and XXXX represents the dependent channel sequence number.

Currently, the channel sequence number is channelNo and paramCode.

3.7 Compression

Data compression is supported to reduce data traffic. Compression is not enabled by default. Use zlib compression.

3.8 Encryption

Prevent insecure transmission processes through encryption. By default, registration, heartbeat, and reporting data are not encrypted. Use AES256-CBC encryption or SM4 encryption

4 Performance Indicators

4.1 Real-time

The gateway operates in the mode of setting the minimum period activation + event trigger, and the time control unit is milliseconds, which meets the real-time requirements.

The delivery operation is received in the event trigger mode and runs preferentially in the next round of scanning, and the maximum delay = network transmission time + one round of scanning time.

One round of scan time is about = number of channels * 15 ms (this is the measured result, 185 channels are less than 3 seconds, and the hold register is about 15 ms per read, and most of the time taken is indeed in the read operation itself).

Continuous address read optimization is supported. Successive addresses can be collected at one time, which can significantly shorten the collection time.

4.2 Number of Supported Devices

There is no limit to the number of devices and channels in the program, only the hardware interface.

4.3 Traffic Estimation

Data compression is supported.

The reported data of the measured 185 channels is about 10K. According to the usual collection frequency of once per minute, one day = 60 * 24 * 10K = 14 M, one month = 420 M.

This type of data generally has a high compression ratio, which can be reduced by 80-90%.

The compression rate of a piece of data of about 10K is 90%, and 85% after using base64 encoding (base64 encoding will increase by one-third), and data compression of less than 200 bytes is meaningless (the program can choose the transmission mode according to the actual effect, which needs to be supported by the platform).

5 Composition of Documents

5.1 System Files

System files are provided by the hardware and vary from gateway to gateway.

Here's what happens for a piece of hardware:

serial number

The name of the file

function

illustrate

1

/home/sn.txt

Model Serial number

Static files

2

/home/sysInfo.txt

SIM card number Signal strength

Dynamic files

3

/home/run/start.sh

Start the script

Executed at system startup (content provided by the application system)

4

/home/run/publish.tar.bz2

Original program

Normal program runs automatically when it fails

5

/home/backup/ led_gpio.txt

 

LED Operating Instructions

5.2 Program Files

All files of the program itself are based on a single directory "/home/root/publish".

serial number

The name of the file

function

illustrate

1

gwmian.exe

Main program

-auto gateway auto-start script is used, prohibiting interactive input

-test to start the built-in modbusTCP test service (available for default device acquisition)

2

appConfig.json

App configuration

file size limits, etc

3

northConfig.json

Platform Configuration (Northbound)

Platform connection parameters

4

defaultNorthConfig.json

Default configuration

 

5

DeviceConfig.json

Device Configuration (Southbound)

Data acquisition configuration

6

gwmain.log

gwmain.log.log

gwmain.log.log.bz2

log file

The total file size does not exceed the limits configured by the app

gwmain.log.log will be compressed into gwmain.log.log.bz2

7

data.dat

data2.dat

Data files

The total file size does not exceed the limits configured by the app

8

SSL/

Certificate documents

Certificate file for MQTTS, one subdirectory per platform

 

6 Design Details

6.1 Device Discovery

In order for devices with unknown IP addresses to be discovered, the device periodically sends UDP broadcasts to port 9999 (the physical network and all configured network segments, depending on the network management device).

A PC directly connected to the network cable can use the packet capture tool to see the source information and discover the device. The current means rely on the installation of third-party libraries.

Plan: PC configurator implementation.

6.2 LED Status

A certain piece of hardware has 9 LEDs, all of which are green, and have the following features:

System use

Device 2 connection status

Device 5 connection status

System use

Device 1 connection status

Device 4 connection status

System use

Platform connection status

Device 3 connection status

       The three on the left are used by the system, and the remaining six are used by the program.

       Status Table:

 

Always extinguished

Solid on

flashing

platform

Not connected

Registration is successful

Connected, not registered

equipment

The interface is not connected

The device reads the data

The device does not read data (the interface is connected)

       The flashes are on and off for one second each, and the cycle keeps on and on.

6.3 Reset Button

The manufacturer has not yet finished.

It is planned to provide two functions: northbound configuration restoration and factory reset reset.

6.4 Data Serial Number

The data serial number identifies a piece of data, and 1 starts to increment. The gateway records the confirmed serial number, the next serial number, and the serial number sent.

The data serial number is the basis for achieving no data loss.

6.5 No loss of data when power is lost

The data is saved first and then sent, so as to ensure that the power is not lost without data loss.

6.6 Data will not be lost when the network is disconnected

Since MQTT between the gateway and the platform does not save data and is not directly discarded by subscribers, and MQTT cannot ensure that data is not lost when the power is off, the gateway confirms that the platform has received the data through the platform acknowledgment message. The platform does not need to confirm every piece of data instantly, but only needs to confirm it before the gateway storage is full.

The gateway can clear the confirmed data only after receiving confirmation from the platform. The historical data platform that exists on the gateway can be refrieved.

If the gateway store is full, the consequences are uncertain. The gateway may stop writing new data, or it may delete old data.

6.7 Online Upgrades

The startup script copies the program files to a temporary storage space (this space is not storage, it is lost in case of power failure), so the program can file can be copied.

Save a copy of the original file to prevent the upgrade from becoming bricked if it fails (the probability of the upgrade failing seems to be quite high due to the large file being split and transferred).

Currently, the upgrade is manual, select the file to upload to the gateway, and then send the restart command to take effect.

6.8 Reliability Design

This program uses a variety of mechanisms to prevent hardware from hanging. It is recommended that the hardware itself has a watchdog mechanism.

There are several layers of protection at the software level:

1. Start the script, the program fails to run the factory configuration, to ensure that the device does not lose contact

2. The main program has two processes, one monitors the other work, and the monitoring process decides how to deal with it according to the status of the work process

3. Timed out failed to connect to the platform and restart the gateway

4. Timed out without receiving any message from the platform to restart the gateway

5. There was a storage write error deleting the old log file