Skip to content

Commit

Permalink
Remove duplicate methods on class implementation. (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-radixiot authored Oct 23, 2024
1 parent 9fce169 commit 61906c0
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 86 deletions.
27 changes: 0 additions & 27 deletions pubber/src/main/java/daq/pubber/ProxyDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,6 @@ private static PubberConfiguration makeProxyConfiguration(ManagerHost host, Stri
return proxyConfiguration;
}

@Override
public void activate() {
try {
active.set(false);
info("Activating proxy device " + deviceId);
MqttDevice mqttDevice = pubberHost.getMqttDevice(deviceId);
mqttDevice.registerHandler(MqttDevice.CONFIG_TOPIC, this::configHandler, Config.class);
mqttDevice.connect(deviceId);
deviceManager.activate();
active.set(true);
} catch (Exception e) {
error(format("Could not connect proxy device %s: %s", deviceId, friendlyStackTrace(e)));
}
}

@Override
public void configHandler(Config config) {
pubberHost.configPreprocess(deviceId, config);
deviceManager.updateConfig(config);
pubberHost.publisherConfigLog("apply", null, deviceId);
}

@Override
public void shutdown() {
deviceManager.shutdown();
Expand All @@ -90,11 +68,6 @@ public void publish(String targetId, Object message) {
pubberHost.publish(targetId, message);
}

@Override
public void setMetadata(Metadata metadata) {
deviceManager.setMetadata(metadata);
}

@Override
public DeviceManager getDeviceManager() {
return deviceManager;
Expand Down
19 changes: 0 additions & 19 deletions pubber/src/main/java/daq/pubber/PubberDiscoveryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,6 @@ private Map<String, RefDiscovery> enumerateRefs(String deviceId) {
udmi.lib.client.DiscoveryManager::getVendorRefValue));
}

/**
* Update the discovery config.
*/
@Override
public void updateConfig(DiscoveryConfig discovery) {
discoveryConfig = discovery;
if (discovery == null) {
discoveryState = null;
updateState();
return;
}
if (discoveryState == null) {
discoveryState = new DiscoveryState();
}
updateDiscoveryEnumeration(discovery);
updateDiscoveryScan(discovery.families);
updateState();
}

public void setSiteModel(SiteModel siteModel) {
this.siteModel = siteModel;
}
Expand Down
25 changes: 0 additions & 25 deletions pubber/src/main/java/daq/pubber/PubberGatewayManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ public PubberGatewayManager(ManagerHost host, PubberConfiguration configuration)
super(host, configuration);
}

/**
* Publish log message for target device.
*/
@Override
public void publishLogMessage(Entry logEntry, String targetId) {
ifNotNullThen(proxyDevices, p -> p.values().forEach(pd -> {
if (pd.getDeviceId().equals(targetId)) {
pd.getDeviceManager().publishLogMessage(logEntry, targetId);
}
}));
}

public void setMetadata(Metadata metadata) {
this.metadata = metadata;
proxyDevices = ifNotNullGet(metadata.gateway, g -> createProxyDevices(g.proxy_ids));
Expand Down Expand Up @@ -100,19 +88,6 @@ public void updateConfig(GatewayConfig gateway) {
updateState();
}

/**
* Sets the status of the gateway.
*/
@Override
public void setGatewayStatus(String category, Level level, String message) {
// TODO: Implement a map or tree or something to properly handle different error sources.
gatewayState.status = new Entry();
gatewayState.status.category = category;
gatewayState.status.level = level.value();
gatewayState.status.message = message;
gatewayState.status.timestamp = getNow();
}

@Override
public void shutdown() {
super.shutdown();
Expand Down
10 changes: 0 additions & 10 deletions pubber/src/main/java/daq/pubber/PubberPointsetManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ public void restorePoint(String pointName) {
PointsetManager.super.restorePoint(pointName);
}

@Override
public void setExtraField(String extraField) {
ifNotNullThen(extraField, field -> pointsetEvent.extraField = field);
}

/**
* Set the underlying static model for this pointset. This is information that would NOT be
* normally available for a device, but would, e.g. be programmed directly into a device. It's
Expand All @@ -120,11 +115,6 @@ public void setPointsetModel(PointsetModel model) {
points.forEach((name, point) -> addPoint(makePoint(name, point)));
}

@Override
public void addPoint(AbstractPoint point) {
managedPoints.put(point.getName(), point);
}

/**
* updates the data of all points in the managedPoints map.
*/
Expand Down
5 changes: 2 additions & 3 deletions pubber/src/main/java/udmi/lib/client/GatewayManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package udmi.lib.client;

import static com.google.udmi.util.GeneralUtils.catchToNull;
import static com.google.udmi.util.GeneralUtils.getNow;
import static com.google.udmi.util.GeneralUtils.ifNotNullThen;
import static java.lang.String.format;
import static java.util.Optional.ofNullable;
Expand Down Expand Up @@ -76,16 +77,14 @@ default void publishLogMessage(Entry logEntry, String targetId) {
/**
* Sets gateway status.
*
* @param category Category.
* @param level Level.
* @param message Message.
*/
default void setGatewayStatus(String category, Level level, String message) {
// TODO: Implement a map or tree or something to properly handle different error sources.
getGatewayState().status = new Entry();
getGatewayState().status.category = category;
getGatewayState().status.level = level.value();
getGatewayState().status.message = message;
getGatewayState().status.timestamp = getNow();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions pubber/src/main/java/udmi/lib/client/ProxyDeviceHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public interface ProxyDeviceHost extends ManagerHost, ManagerLog {
default void activate() {
try {
isActive().set(false);
info("Activating proxy device " + getDeviceId());
MqttDevice mqttDevice = getUdmiPublisher().getMqttDevice(getDeviceId());
mqttDevice.registerHandler(MqttDevice.CONFIG_TOPIC, this::configHandler, Config.class);
mqttDevice.connect();
mqttDevice.connect(getDeviceId());
getDeviceManager().activate();
isActive().set(true);
info("Activated proxy device " + getDeviceId());
} catch (Exception e) {
error(format("Could not connect proxy device %s: %s", getDeviceId(), friendlyStackTrace(e)));
}
Expand Down

0 comments on commit 61906c0

Please sign in to comment.