Skip to content

Commit

Permalink
Fix channel number address parser
Browse files Browse the repository at this point in the history
  • Loading branch information
docbender committed Sep 29, 2020
1 parent 21dffa1 commit 6abf418
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public void handleRemoval() {
*/
public void updateConfig() {
int stateChannelCount = 0;
channelCount = 0;

for (Thing th : getThing().getThings()) {
var h = ((SimaticGenericHandler) th.getHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,23 @@ public void clear() {
address, channelType.getId());
return null;
}
if (matcher.group(1) == null) {
return new SimaticPLCAddress(Integer.parseInt(matcher.group(6)), matcher.group(7),
Integer.parseInt(matcher.group(8)),
matcher.group(9) != null && !matcher.group(9).isEmpty());
if (matcher.group(1) != null) {
return new SimaticPLCAddress(matcher.group(2), Integer.parseInt(matcher.group(3)), false);
} else if (matcher.group(4) != null) {
return new SimaticPLCAddress(matcher.group(5), Integer.parseInt(matcher.group(6)),
matcher.group(7) != null && !matcher.group(7).isEmpty());
} else if (matcher.group(8) != null) {
return new SimaticPLCAddress(Integer.parseInt(matcher.group(9)), matcher.group(10),
Integer.parseInt(matcher.group(11)), false);
} else if (matcher.group(12) != null) {
return new SimaticPLCAddress(Integer.parseInt(matcher.group(13)), matcher.group(14),
Integer.parseInt(matcher.group(15)),
matcher.group(16) != null && !matcher.group(16).isEmpty());
} else {
return new SimaticPLCAddress(matcher.group(2), Integer.parseInt(matcher.group(3)),
matcher.group(4) != null && !matcher.group(4).isEmpty());
error = String.format(
"Unsupported address '%s' for typeID=%s. Supported types B,W,D. Address example IB10, MW100, DB1.DBD0, DB1.DBD0F",
address, channelType.getId());
return null;
}
case SimaticBindingConstants.CHANNEL_STRING:
matcher = stringAddressPattern.matcher(address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@NonNullByDefault
public class SimaticBindingConstants {

public static final String VERSION = "3.0.0-beta.2";
public static final String VERSION = "3.0.0-beta.3";

private static final String BINDING_ID = "simatic";

Expand Down

0 comments on commit 6abf418

Please sign in to comment.