Skip to content

Commit cdb1741

Browse files
committed
Sendiing only changed data now works
1 parent 8bf6a29 commit cdb1741

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

modules/hivemq-edge-module-s7/src/main/java/com/hivemq/edge/adapters/s7/S7ProtocolAdapter.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,18 @@ public void poll(
136136
dataPoint = s7Client.read(s7ToMqtt.getDataType(), List.of(tagAddress)).get(0);
137137
}
138138

139-
if(adapterConfig.getPublishChangedDataOnly() && dataPoints.containsKey(tagAddress)) {
140-
final DataPoint existingDataPoint = dataPoints.get(tagAddress);
141-
if(existingDataPoint != null && !existingDataPoint.equals(dataPoint)) {
139+
if(adapterConfig.getPublishChangedDataOnly()) {
140+
if(dataPoints.containsKey(tagAddress)) {
141+
final DataPoint existingDataPoint = dataPoints.get(tagAddress);
142+
if(existingDataPoint != null && existingDataPoint.equals(dataPoint)) {
143+
log.info("Skipping sending for {} because publishChangedDataOnly=true", tagAddress);
144+
} else {
145+
dataPoints.put(tagAddress, dataPoint);
146+
pollingOutput.addDataPoint(dataPoint);
147+
}
148+
} else {
142149
dataPoints.put(tagAddress, dataPoint);
143150
pollingOutput.addDataPoint(dataPoint);
144-
} else {
145-
log.debug("Skipping sending for {} because publishChangedDataOnly=true", tagAddress);
146151
}
147152
} else {
148153
pollingOutput.addDataPoint(dataPoint);

modules/hivemq-edge-module-s7/src/main/java/com/hivemq/edge/adapters/s7/config/S7AdapterConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public enum ControllerType {
124124
@JsonCreator
125125
public S7AdapterConfig(
126126
@JsonProperty(value = "id", required = true) final @NotNull String id,
127-
@JsonProperty(value = "port", required = true) final int port,
127+
@JsonProperty(value = "port", required = true, defaultValue = "102") final int port,
128128
@JsonProperty(value = "host", required = true) final @NotNull String host,
129129
@JsonProperty(value = "controllerType", required = true) final @NotNull ControllerType controllerType,
130130
@JsonProperty(value = "remoteRack") final @Nullable Integer remoteRack,

0 commit comments

Comments
 (0)