Skip to content

Commit 33ed21c

Browse files
Merge pull request #7 from volkmarnissen/modbuscache
Angular TcpBridge Fix
2 parents c2bb976 + da8797d commit 33ed21c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/app/select-modbus/select-modbus.component.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ <h1>List of Modbus Controllers</h1>
7474
</mat-form-field>
7575
</div>
7676
<div>
77-
<mat-form-field matTooltip="If this field is not empty, a Modbus TCP bridge will listen on this port and forwards modbus requests to this RTU connection">
78-
<mat-label>TCP Bridge Port</mat-label>
79-
<input type='number' matInput formControlName="tcpBridgePort" />
80-
</mat-form-field>
77+
<mat-slide-toggle formControlName="tcpBridge" matTooltip="A Modbus TCP bridge will listen on port 502 and forwards modbus requests to this RTU connection">TCP Bridge to RTU </mat-slide-toggle>
78+
8179
</div>
8280

8381
</div>

src/app/select-modbus/select-modbus.component.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import {
5050
MatCardContent,
5151
} from "@angular/material/card";
5252
import { NgFor, NgIf } from "@angular/common";
53+
import { MatSlideToggle } from "@angular/material/slide-toggle";
5354

5455
@Component({
5556
selector: "app-select-modbus",
@@ -62,6 +63,7 @@ import { NgFor, NgIf } from "@angular/common";
6263
MatCard,
6364
MatCardHeader,
6465
MatCardTitle,
66+
MatSlideToggle,
6567
MatTooltip,
6668
NgIf,
6769
MatIconButton,
@@ -170,8 +172,8 @@ export class SelectModbusComponent implements AfterViewInit, OnDestroy {
170172
let serialport = (bus.connectionData as IRTUConnection).serialport;
171173
let baudRate = (bus.connectionData as IRTUConnection).baudrate;
172174
let timeout = (bus.connectionData as IRTUConnection).timeout;
173-
let tcpBridgePort = (bus.connectionData as IRTUConnection)
174-
.tcpBridgePort;
175+
let tcpBridge = (bus.connectionData as IRTUConnection)
176+
.tcpBridge;
175177

176178
let sd = this.getBusFormGroup(idx).get([
177179
"rtu",
@@ -183,8 +185,8 @@ export class SelectModbusComponent implements AfterViewInit, OnDestroy {
183185
if (br) br.setValue(baudRate);
184186
let to = fg.get(["rtu", "timeout"]);
185187
if (to) to.setValue(timeout);
186-
let tbp = fg.get(["rtu", "tcpBridgePort"]);
187-
if (tbp) tbp.setValue(tcpBridgePort);
188+
let tbp = fg.get(["rtu", "tcpBridge"]);
189+
if (tbp) tbp.setValue(tcpBridge);
188190
} else {
189191
let host = (bus.connectionData as ITCPConnection).host;
190192
let port = (bus.connectionData as ITCPConnection).port;
@@ -254,10 +256,10 @@ export class SelectModbusComponent implements AfterViewInit, OnDestroy {
254256
(connectionData as IRTUConnection).timeout = timeout.value;
255257
}
256258
// Optional BridgePort
257-
let tcpBridgePort = fg.get(["rtu", "tcpBridgePort"]);
258-
if (null != tcpBridgePort && tcpBridgePort.value)
259-
(connectionData as IRTUConnection).tcpBridgePort =
260-
tcpBridgePort.value;
259+
let tcpBridge = fg.get(["rtu", "tcpBridge"]);
260+
if (null != tcpBridge && tcpBridge.value)
261+
(connectionData as IRTUConnection).tcpBridge =
262+
tcpBridge.value;
261263

262264
delete (connectionData as any).host;
263265
delete (connectionData as any).port;
@@ -330,7 +332,7 @@ export class SelectModbusComponent implements AfterViewInit, OnDestroy {
330332
serial: [null, this.serialValidator],
331333
selectBaudRate: [9600, Validators.required],
332334
timeout: [BUS_TIMEOUT_DEFAULT, Validators.required],
333-
tcpBridgePort: [null],
335+
tcpBridge: [false],
334336
}),
335337
tcp: this._formBuilder.group({
336338
host: ["", Validators.required],

0 commit comments

Comments
 (0)