From 2ed9fd5349ac789b7ceeb9000d681d38dfbc3d28 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Thu, 8 Aug 2024 17:09:17 +0300 Subject: [PATCH 1/2] Gateway Modbus Connector UI adjustments and hints --- .../modbus-basic-config.component.html | 2 +- .../modbus-data-keys-panel.component.html | 24 ++++++++-- .../modbus-security-config.component.html | 8 +++- .../modbus-security-config.component.ts | 2 + .../modbus-slave-config.component.html | 20 +++++---- .../modbus-slave-config.component.ts | 2 + .../modbus-slave-dialog.component.html | 44 ++++++++++--------- .../modbus-slave-dialog.component.ts | 5 ++- .../dialog/add-connector-dialog.component.ts | 3 +- .../lib/gateway/gateway-widget.models.ts | 8 ++-- .../gateway/modbus-functions-data-types_fn.md | 33 ++++++++++++++ .../assets/locale/locale.constant-en_US.json | 30 ++++++++++++- 12 files changed, 139 insertions(+), 42 deletions(-) create mode 100644 ui-ngx/src/assets/help/en_US/widget/lib/gateway/modbus-functions-data-types_fn.md diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-basic-config/modbus-basic-config.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-basic-config/modbus-basic-config.component.html index 105a3c0e8e..30233cddcf 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-basic-config/modbus-basic-config.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-basic-config/modbus-basic-config.component.html @@ -19,7 +19,7 @@ - + diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-data-keys-panel/modbus-data-keys-panel.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-data-keys-panel/modbus-data-keys-panel.component.html index f53e3ee277..cfb97f674d 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-data-keys-panel/modbus-data-keys-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-data-keys-panel/modbus-data-keys-panel.component.html @@ -39,10 +39,19 @@ +
+ {{ 'gateway.hints.modbus.data-keys' | translate }} +
+
+
gateway.platform-side
-
+
gateway.key
@@ -91,7 +100,7 @@
-
gateway.objects-count
+
gateway.objects-count
+ + warning +
-
gateway.address
+
gateway.address
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-security-config/modbus-security-config.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-security-config/modbus-security-config.component.html index 66db8c5018..3fc3e33ad0 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-security-config/modbus-security-config.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-security-config/modbus-security-config.component.html @@ -18,7 +18,9 @@
{{ 'gateway.hints.path-in-os' | translate }}
-
gateway.client-cert-path
+
+ gateway.client-cert-path +
@@ -26,7 +28,9 @@
-
gateway.private-key-path
+
+ gateway.private-key-path +
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-security-config/modbus-security-config.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-security-config/modbus-security-config.component.ts index bc40727b55..062f77fafb 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-security-config/modbus-security-config.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-security-config/modbus-security-config.component.ts @@ -42,6 +42,7 @@ import { CommonModule } from '@angular/common'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { coerceBoolean } from '@shared/decorators/coercion'; +import { TruncateWithTooltipDirective } from '@shared/directives/truncate-with-tooltip.directive'; @Component({ selector: 'tb-modbus-security-config', @@ -63,6 +64,7 @@ import { coerceBoolean } from '@shared/decorators/coercion'; imports: [ CommonModule, SharedModule, + TruncateWithTooltipDirective, ] }) export class ModbusSecurityConfigComponent implements ControlValueAccessor, Validator, OnChanges, OnDestroy { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.html index d1a16c33bc..9360ef499a 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.html @@ -28,7 +28,7 @@ class="tb-form-row column-xs" fxLayoutAlign="space-between center" > -
gateway.host
+
gateway.host
@@ -48,7 +48,7 @@ class="tb-form-row column-xs" fxLayoutAlign="space-between center" > -
gateway.port
+
gateway.port
-
gateway.port
+
gateway.port
@@ -86,7 +86,7 @@
-
+
gateway.method
@@ -100,7 +100,7 @@
-
gateway.unit-id
+
gateway.unit-id
@@ -151,7 +151,11 @@
-
gateway.poll-period
+
+ + gateway.poll-period + +
@@ -159,7 +163,7 @@
-
gateway.baudrate
+
gateway.baudrate
@@ -184,7 +188,7 @@
-
gateway.byte-order
+
gateway.byte-order
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts index 5f5b4d293c..206b0c2ac5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts @@ -48,6 +48,7 @@ import { GatewayPortTooltipPipe } from '@home/components/widget/lib/gateway/pipe import { ModbusSecurityConfigComponent } from '../modbus-security-config/modbus-security-config.component'; import { ModbusValuesComponent, } from '../modbus-values/modbus-values.component'; import { isEqual } from '@core/utils'; +import { TruncateWithTooltipDirective } from '@shared/directives/truncate-with-tooltip.directive'; @Component({ selector: 'tb-modbus-slave-config', @@ -72,6 +73,7 @@ import { isEqual } from '@core/utils'; ModbusValuesComponent, ModbusSecurityConfigComponent, GatewayPortTooltipPipe, + TruncateWithTooltipDirective, ], }) export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validator, OnDestroy { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.html index 088b385623..d8f2ca9626 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.html @@ -57,7 +57,7 @@ class="tb-form-row column-xs" fxLayoutAlign="space-between center" > -
gateway.host
+
gateway.host
@@ -77,7 +77,7 @@ class="tb-form-row column-xs" fxLayoutAlign="space-between center" > -
gateway.port
+
gateway.port
-
gateway.port
+
gateway.port
@@ -116,7 +116,7 @@
-
+
gateway.method
@@ -131,7 +131,7 @@
-
gateway.baudrate
+
gateway.baudrate
@@ -141,7 +141,7 @@
-
gateway.bytesize
+
gateway.bytesize
@@ -151,7 +151,7 @@
-
gateway.stopbits
+
gateway.stopbits
@@ -159,7 +159,7 @@
-
gateway.parity
+
gateway.parity
@@ -170,14 +170,14 @@
- + {{ 'gateway.strict' | translate }}
-
gateway.unit-id
+
gateway.unit-id
@@ -243,7 +243,7 @@
-
gateway.connection-timeout
+
gateway.connection-timeout
@@ -251,7 +251,7 @@
-
gateway.byte-order
+
gateway.byte-order
@@ -261,7 +261,7 @@
-
gateway.word-order
+
gateway.word-order
@@ -286,27 +286,31 @@
- + {{ 'gateway.retries' | translate }}
- + {{ 'gateway.retries-on-empty' | translate }}
- + {{ 'gateway.retries-on-invalid' | translate }}
-
gateway.poll-period
+
+ + gateway.poll-period + +
@@ -314,7 +318,7 @@
-
gateway.connect-attempt-time
+
gateway.connect-attempt-time
@@ -322,7 +326,7 @@
-
gateway.connect-attempt-count
+
gateway.connect-attempt-count
@@ -330,7 +334,7 @@
-
gateway.wait-after-failed-attempts
+
gateway.wait-after-failed-attempts
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.ts index e21a9921a7..3d2f5b6f5d 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.ts @@ -52,6 +52,8 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { GatewayPortTooltipPipe } from '@home/components/widget/lib/gateway/pipes/gateway-port-tooltip.pipe'; import { takeUntil } from 'rxjs/operators'; import { isEqual } from '@core/utils'; +import { TruncateWithTooltipDirective } from '@shared/directives/truncate-with-tooltip.directive'; +import { helpBaseUrl } from '@shared/models/constants'; @Component({ selector: 'tb-modbus-slave-dialog', @@ -76,6 +78,7 @@ import { isEqual } from '@core/utils'; ModbusValuesComponent, ModbusSecurityConfigComponent, GatewayPortTooltipPipe, + TruncateWithTooltipDirective, ], styleUrls: ['./modbus-slave-dialog.component.scss'], }) @@ -97,7 +100,7 @@ export class ModbusSlaveDialogComponent extends DialogComponent( export const HelpLinkByMappingTypeMap = new Map( [ - [MappingType.DATA, 'https://thingsboard.io/docs/iot-gateway/config/mqtt/#section-mapping'], - [MappingType.OPCUA, 'https://thingsboard.io/docs/iot-gateway/config/opc-ua/#section-mapping'], - [MappingType.REQUESTS, 'https://thingsboard.io/docs/iot-gateway/config/mqtt/#section-mapping'] + [MappingType.DATA, helpBaseUrl + '/docs/iot-gateway/config/mqtt/#section-mapping'], + [MappingType.OPCUA, helpBaseUrl + '/docs/iot-gateway/config/opc-ua/#section-mapping'], + [MappingType.REQUESTS, helpBaseUrl + '/docs/iot-gateway/config/mqtt/#section-mapping'] ] ); diff --git a/ui-ngx/src/assets/help/en_US/widget/lib/gateway/modbus-functions-data-types_fn.md b/ui-ngx/src/assets/help/en_US/widget/lib/gateway/modbus-functions-data-types_fn.md new file mode 100644 index 0000000000..6a38f9220f --- /dev/null +++ b/ui-ngx/src/assets/help/en_US/widget/lib/gateway/modbus-functions-data-types_fn.md @@ -0,0 +1,33 @@ +# Modbus Functions + +The Modbus connector supports the following Modbus functions: + +| Modbus Function Code | Description | +|----------------------|----------------------------------| +| 1 | Read Coils | +| 2 | Read Discrete Inputs | +| 3 | Read Multiple Holding Registers | +| 4 | Read Input Registers | +| 5 | Write Coil | +| 6 | Write Register | +| 15 | Write Coils | +| 16 | Write Registers | + +## Data Types + +A list and description of the supported data types for reading/writing data: + +| Type | Function Code | Objects Count | Note | +|----------|---------------|---------------|----------------------------------------------------| +| string | 3-4 | 1-… | Read bytes from registers and decode it (‘UTF-8’ coding). | +| bytes | 3-4 | 1-… | Read bytes from registers. | +| bits | 1-4 | 1-… | Read coils. If the objects count is 1, result will be interpreted as a boolean. Otherwise, the result will be an array with bits. | +| 16int | 3-4 | 1 | Integer 16 bit. | +| 16uint | 3-4 | 1 | Unsigned integer 16 bit. | +| 16float | 3-4 | 1 | Float 16 bit. | +| 32int | 3-4 | 2 | Integer 32 bit. | +| 32uint | 3-4 | 2 | Unsigned integer 32 bit. | +| 32float | 3-4 | 2 | Float 32 bit. | +| 64int | 3-4 | 4 | Integer 64 bit. | +| 64uint | 3-4 | 4 | Unsigned integer 64 bit. | +| 64float | 3-4 | 4 | Float 64 bit. | diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index b32818723b..a71c93a184 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3312,6 +3312,7 @@ "exactly-once": "2 - Exactly once" }, "objects-count": "Objects count", + "objects-count-required": "Objects count is required", "wait-after-failed-attempts": "Wait after failed attempts (ms)", "tls-path-private-key": "Path to private key on gateway", "toggle-fullscreen": "Toggle fullscreen", @@ -3367,7 +3368,6 @@ "permit-without-calls": "Allow server to keep the GRPC connection alive even when there are no active RPC calls.", "path-in-os": "Path in gateway os.", "memory": "Your data will be stored in the in-memory queue, it is a fastest but no persistence guarantee.", - "framer-type": "Type of framer.", "file": "Your data will be stored in separated files and will be saved even after the gateway restart.", "sqlite": "Your data will be stored in file based database. And will be saved even after the gateway restart.", "opcua-timeout": "Timeout in seconds for connecting to OPC-UA server.", @@ -3376,7 +3376,33 @@ "enable-subscription": "If true - the gateway will subscribe to interesting nodes and wait for data update and if false - the gateway will rescan OPC-UA server every scanPeriodInMillis.", "show-map": "Show nodes on scanning.", "method-name": "Name of method on OPC-UA server.", - "arguments": "Arguments for the method (will be overwritten by arguments from the RPC request)." + "arguments": "Arguments for the method (will be overwritten by arguments from the RPC request).", + "modbus": { + "framer-type": "Type of a framer (Socket, RTU, or ASCII), if needed.", + "host": "Hostname or IP address of Modbus server.", + "port": "Modbus server port for connection.", + "unit-id": "Modbus slave ID.", + "connection-timeout": "Connection timeout (in seconds) for the Modbus server.", + "byte-order": "Byte order for reading data.", + "word-order": "Word order when reading multiple registers.", + "retries": "Retrying data transmission to the master. Acceptable values: true or false.", + "retries-on-empty": "Retry sending data to the master if the data is empty.", + "retries-on-invalid": "Retry sending data to the master if it fails.", + "poll-period": "Period in milliseconds to check attributes and telemetry on the slave.", + "connect-attempt-time": "A waiting period in milliseconds before establishing a connection to the master.", + "connect-attempt-count": "The number of connection attempts made through the gateway.", + "wait-after-failed-attempts": "A waiting period in milliseconds before attempting to send data to the master.", + "serial-port": "Serial port for connection.", + "baudrate": "Baud rate for the serial device.", + "stopbits": "The number of stop bits sent after each character in a message to indicate the end of the byte.", + "bytesize": "The number of bits in a byte of serial data. This can be one of 5, 6, 7, or 8.", + "parity": "The type of checksum used to verify data integrity. Options: (E)ven, (O)dd, (N)one.", + "strict": "Use inter-character timeout for baudrates ≤ 19200.", + "objects-count": "Depends on the selected type.", + "address": "Register address to verify.", + "key": "Key to be used as the attribute key for the platform instance.", + "data-keys": "For more information about function codes and data types click on help icon" + } } }, "grid": { From 3e6247082deca6494b4d2a3f0c2a5658d76d0f33 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Thu, 8 Aug 2024 17:55:29 +0300 Subject: [PATCH 2/2] adjustments --- .../modbus-slave-dialog.component.html | 10 +++++----- .../modbus-slave-dialog.component.scss | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.html index d8f2ca9626..1cf95ad06e 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.html @@ -281,7 +281,7 @@ - +
@@ -306,7 +306,7 @@
-
+
gateway.poll-period @@ -318,7 +318,7 @@
-
gateway.connect-attempt-time
+
gateway.connect-attempt-time
@@ -326,7 +326,7 @@
-
gateway.connect-attempt-count
+
gateway.connect-attempt-count
@@ -334,7 +334,7 @@
-
gateway.wait-after-failed-attempts
+
gateway.wait-after-failed-attempts
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.scss b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.scss index 8900741a93..0c68b6af9e 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-dialog/modbus-slave-dialog.component.scss @@ -23,4 +23,14 @@ margin-right: 16px; color: rgba(0, 0, 0, 0.87); } + + .fixed-title-width-260 { + min-width: 260px; + } + + ::ng-deep.security-config { + .fixed-title-width { + min-width: 230px; + } + } }