Skip to content

Commit

Permalink
fix(plc-simulator): fix cBus using s7 port
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Nov 3, 2022
1 parent 4955117 commit ddf17ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ public static PlcSimulatorConfig plcSimulatorConfigFromArgs(String... args) thro
Options options = new Options();

options.addOption("public", false, "listen on all interfaces (overrides host option)");
options.addOption("host", true, "display current time");
options.addOption("s7port", true, "changes the s7 port");
options.addOption("host", true, "the host interface");
options.addOption("s7Port", true, "changes the s7 port");
options.addOption("cBusPort", true, "changes the port");

// Parse args
CommandLineParser parser = new DefaultParser();
Expand All @@ -161,6 +162,7 @@ public static PlcSimulatorConfig plcSimulatorConfigFromArgs(String... args) thro
config.host = null;
}
config.s7Port = cmd.getOptionValue("s7port");
config.cBusPort = cmd.getOptionValue("cBusPort");

return config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class PlcSimulatorConfig {
String host;

String s7Port;
String cBusPort;

public String getHost() {
return host;
Expand All @@ -30,4 +31,8 @@ public String getHost() {
public String getS7Port() {
return s7Port;
}

public String getCBusPort() {
return cBusPort;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void setContext(Context context) {
this.context = context;
}


@Override
public void start() throws SimulatorException {
if (loopGroup != null) {
Expand Down Expand Up @@ -90,8 +89,8 @@ public void initChannel(SocketChannel channel) {
.childOption(ChannelOption.SO_KEEPALIVE, true);

int port = CBusConstants.CBUSTCPDEFAULTPORT;
if (config.getS7Port() != null) {
port = Integer.parseInt(config.getS7Port());
if (config.getCBusPort() != null) {
port = Integer.parseInt(config.getCBusPort());
}
String host = config.getHost();
if (host != null) {
Expand Down

0 comments on commit ddf17ee

Please sign in to comment.