Skip to content

Commit

Permalink
Refactor plc4x integration to work with source concept.
Browse files Browse the repository at this point in the history
Signed-off-by: Łukasz Dywicki <luke@code-house.org>
  • Loading branch information
splatch committed Mar 5, 2024
1 parent 1fa5805 commit 4d57fd7
Show file tree
Hide file tree
Showing 41 changed files with 810 additions and 350 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ public interface TACANopenBindingConstants extends CANopenBindingConstants {
String TA_DIGITAL_SWITCH = TA_DIGITAL_PREFIX + "-switch";
String TA_DIGITAL_CONTACT = TA_DIGITAL_PREFIX + "-contact";

@Deprecated
ThingTypeUID TA_UVR_16x2_THING_TYPE = new ThingTypeUID(BINDING_ID, TA_UVR_16x2);

ThingTypeUID TA_DEVICE_THING_TYPE = new ThingTypeUID(BINDING_ID, TA_DEVICE);

ChannelTypeUID TA_ANALOG_RAS_MODE_CHANNEL_TYPE = new ChannelTypeUID(BINDING_ID, TA_ANALOG_RAS_MODE);
Expand Down Expand Up @@ -97,7 +94,7 @@ public interface TACANopenBindingConstants extends CANopenBindingConstants {

ThingTypeUID TA_FUNCTION_THING_TYPE = new ThingTypeUID(BINDING_ID, TA_FUNCTION);

Set<ThingTypeUID> SUPPORTED_DEVICES = new HashSet<>(Arrays.asList(TA_UVR_16x2_THING_TYPE, TA_DEVICE_THING_TYPE));
Set<ThingTypeUID> SUPPORTED_DEVICES = new HashSet<>(Arrays.asList(TA_DEVICE_THING_TYPE));

Set<ThingTypeUID> DISCOVERABLE_CAN_THINGS = new HashSet<>(Arrays.asList(TA_FUNCTION_THING_TYPE
// TA_ANALOG_RAS_THING_TYPE, TA_ANALOG_TEMPERATURE_THING_TYPE, TA_ANALOG_LENGTH_THING_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.canopen.tag.CANOpenTag;
import org.connectorio.addons.binding.canopen.api.CoConnection;
import org.connectorio.addons.binding.canopen.api.CoNode;
import org.connectorio.addons.binding.canopen.handler.CoBridgeHandler;
Expand Down Expand Up @@ -61,8 +62,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TADeviceThingHandler extends PollingPlc4xBridgeHandler<PlcConnection, DeviceConfig>
implements Plc4xBridgeHandler<PlcConnection, DeviceConfig>, Consumer<Boolean>, Runnable {
public class TADeviceThingHandler extends PollingPlc4xBridgeHandler<CANOpenTag, DeviceConfig>
implements Plc4xBridgeHandler<DeviceConfig>, Consumer<Boolean>, Runnable {

// no safe caller since initialization might wait much longer than default 5000 ms
private final static ExecutorService initializer = Executors.newSingleThreadExecutor(new NamedThreadFactory("initializer"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ protected ThingHandler createHandler(Thing thing) {
}
}

if (TA_UVR_16x2_THING_TYPE.equals(thing.getThingTypeUID())) {
return new TAUVR16x2ThingHandler(thing, semaphore);
}

return null;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,4 @@
</config-description>
</bridge-type>

<thing-type id="ta-uvr16x2">
<supported-bridge-type-refs>
<bridge-type-ref id="socketcan"/>
</supported-bridge-type-refs>

<label>Technische Alternative UVR 16x2</label>
<description>Freely programmable logic controller.</description>

<config-description>
<parameter name="nodeId" type="integer" required="true">
<label>CANopen Node ID</label>
<description>
Identifier of device in CANopen network.
</description>
</parameter>
<parameter name="ignoreLoginFailure" type="boolean" required="true">
<label>Ignore login failure</label>
<description>
Determine if channel configuration should be refreshed even if controller refused "login" registration of this node.
</description>
<default>false</default>
</parameter>
</config-description>
</thing-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@

import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.plc4x.java.api.PlcConnection;
import org.connectorio.addons.binding.canopen.api.CoConnection;
import org.connectorio.addons.binding.canopen.config.CoNodeConfig;
import org.connectorio.addons.binding.canopen.discovery.CoDiscoveryParticipant;
import org.connectorio.addons.binding.handler.polling.PollingBridgeHandler;
import org.connectorio.addons.binding.plc4x.handler.Plc4xBridgeHandler;
import org.connectorio.plc4x.extras.decorator.Decorator;

public interface CoBridgeHandler<C extends CoNodeConfig> extends Plc4xBridgeHandler<PlcConnection, C>, PollingBridgeHandler<C> {
public interface CoBridgeHandler<C extends CoNodeConfig> extends Plc4xBridgeHandler<C>, PollingBridgeHandler<C> {

String getName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.concurrent.TimeUnit;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.canopen.readwrite.CANOpenDataType;
import org.apache.plc4x.java.canopen.tag.CANOpenTag;
import org.connectorio.addons.binding.canopen.CANopenBindingConstants;
import org.connectorio.addons.binding.canopen.api.CoConnection;
import org.connectorio.addons.binding.canopen.api.CoNode;
Expand All @@ -48,7 +49,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CoNodeBridgeHandler extends PollingPlc4xBridgeHandler<PlcConnection, CoNodeBridgeConfig> {
public class CoNodeBridgeHandler extends PollingPlc4xBridgeHandler<CANOpenTag, CoNodeBridgeConfig> {

private final Logger logger = LoggerFactory.getLogger(CoNodeBridgeHandler.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.canopen.tag.CANOpenTag;
import org.apache.plc4x.java.spi.connection.AbstractPlcConnection;
import org.connectorio.addons.binding.can.statistic.CANStatisticCollector;
import org.connectorio.addons.binding.canopen.api.CoConnection;
Expand Down Expand Up @@ -55,7 +56,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CoSocketCANBridgeHandler extends PollingPlc4xBridgeHandler<PlcConnection, SocketCANConfiguration>
public class CoSocketCANBridgeHandler extends PollingPlc4xBridgeHandler<CANOpenTag, SocketCANConfiguration>
implements CoBridgeHandler<SocketCANConfiguration> {

private final Logger logger = LoggerFactory.getLogger(CoSocketCANBridgeHandler.class);
Expand Down
Loading

0 comments on commit 4d57fd7

Please sign in to comment.