Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/app/select-modbus/select-modbus.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ <h1>List of Modbus Controllers</h1>
</mat-form-field>
</div>
<div>
<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">
<mat-label>TCP Bridge Port</mat-label>
<input type='number' matInput formControlName="tcpBridgePort" />
</mat-form-field>
<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>

</div>

</div>
Expand Down
20 changes: 11 additions & 9 deletions src/app/select-modbus/select-modbus.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
MatCardContent,
} from "@angular/material/card";
import { NgFor, NgIf } from "@angular/common";
import { MatSlideToggle } from "@angular/material/slide-toggle";

@Component({
selector: "app-select-modbus",
Expand All @@ -62,6 +63,7 @@ import { NgFor, NgIf } from "@angular/common";
MatCard,
MatCardHeader,
MatCardTitle,
MatSlideToggle,
MatTooltip,
NgIf,
MatIconButton,
Expand Down Expand Up @@ -170,8 +172,8 @@ export class SelectModbusComponent implements AfterViewInit, OnDestroy {
let serialport = (bus.connectionData as IRTUConnection).serialport;
let baudRate = (bus.connectionData as IRTUConnection).baudrate;
let timeout = (bus.connectionData as IRTUConnection).timeout;
let tcpBridgePort = (bus.connectionData as IRTUConnection)
.tcpBridgePort;
let tcpBridge = (bus.connectionData as IRTUConnection)
.tcpBridge;

let sd = this.getBusFormGroup(idx).get([
"rtu",
Expand All @@ -183,8 +185,8 @@ export class SelectModbusComponent implements AfterViewInit, OnDestroy {
if (br) br.setValue(baudRate);
let to = fg.get(["rtu", "timeout"]);
if (to) to.setValue(timeout);
let tbp = fg.get(["rtu", "tcpBridgePort"]);
if (tbp) tbp.setValue(tcpBridgePort);
let tbp = fg.get(["rtu", "tcpBridge"]);
if (tbp) tbp.setValue(tcpBridge);
} else {
let host = (bus.connectionData as ITCPConnection).host;
let port = (bus.connectionData as ITCPConnection).port;
Expand Down Expand Up @@ -254,10 +256,10 @@ export class SelectModbusComponent implements AfterViewInit, OnDestroy {
(connectionData as IRTUConnection).timeout = timeout.value;
}
// Optional BridgePort
let tcpBridgePort = fg.get(["rtu", "tcpBridgePort"]);
if (null != tcpBridgePort && tcpBridgePort.value)
(connectionData as IRTUConnection).tcpBridgePort =
tcpBridgePort.value;
let tcpBridge = fg.get(["rtu", "tcpBridge"]);
if (null != tcpBridge && tcpBridge.value)
(connectionData as IRTUConnection).tcpBridge =
tcpBridge.value;

delete (connectionData as any).host;
delete (connectionData as any).port;
Expand Down Expand Up @@ -330,7 +332,7 @@ export class SelectModbusComponent implements AfterViewInit, OnDestroy {
serial: [null, this.serialValidator],
selectBaudRate: [9600, Validators.required],
timeout: [BUS_TIMEOUT_DEFAULT, Validators.required],
tcpBridgePort: [null],
tcpBridge: [false],
}),
tcp: this._formBuilder.group({
host: ["", Validators.required],
Expand Down