Skip to content

Commit

Permalink
fix plc4x
Browse files Browse the repository at this point in the history
  • Loading branch information
DC2-DanielKrueger committed Feb 12, 2025
1 parent a1fd1ea commit e0ca6ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ private Plc4xConnection<T> initConnection() {
return processPlcFieldData(Plc4xDataUtils.readDataFromReadResponse(readEvent));
}
}
return new Plc4xDataSample<>(adapterFactories.dataPointFactory());
return new Plc4xDataSample(adapterFactories.dataPointFactory());
}

protected @NotNull Plc4xDataSample processPlcFieldData(
final @NotNull List<Pair<String, PlcValue>> l) {
final Plc4xDataSample data = new Plc4xDataSample<>(adapterFactories.dataPointFactory());
final Plc4xDataSample data = new Plc4xDataSample(adapterFactories.dataPointFactory());
//-- For every tag value associated with the sample, write a data point to be published
if (!l.isEmpty()) {
l.forEach(pair -> data.addDataPoint(pair.getLeft(), convertTagValue(pair.getLeft(), pair.getValue())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
*
* @author Simon L Johnson
*/
public class Plc4xDataSample<T extends ProtocolSpecificAdapterConfig> {
public class Plc4xDataSample {

protected @NotNull Long timestamp = System.currentTimeMillis();
protected @NotNull PollingContext pollingContext;
private final @NotNull DataPointFactory dataPointFactory;

//-- Handle multiple tags in the same sample
Expand All @@ -46,28 +44,10 @@ public Plc4xDataSample(final @NotNull DataPointFactory dataPointFactory) {
this.dataPointFactory = dataPointFactory;
}

@JsonIgnore
public @NotNull PollingContext getPollingContext() {
return pollingContext;
}

@JsonIgnore
public @NotNull Long getTimestamp() {
return timestamp;
}

public void addDataPoint(final @NotNull String tagName, final @NotNull Object tagValue) {
dataPoints.add(dataPointFactory.create(tagName, tagValue));
}

public void addDataPoint(final @NotNull DataPoint dataPoint) {
dataPoints.add(dataPoint);
}

public void setDataPoints(@NotNull final List<DataPoint> list) {
this.dataPoints = list;
}

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public @NotNull List<DataPoint> getDataPoints() {
return dataPoints;
Expand Down

0 comments on commit e0ca6ed

Please # to comment.