Re-usable BaSyx components
Added components that simplify BaSyx installations
diff --git a/components/basys.components/src/org/eclipse/basyx/components/configuration/CFGBaSyxConnection.java b/components/basys.components/src/org/eclipse/basyx/components/configuration/CFGBaSyxConnection.java
new file mode 100644
index 0000000..2a92d6e
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/configuration/CFGBaSyxConnection.java
@@ -0,0 +1,101 @@
+package org.eclipse.basyx.components.configuration;
+
+import org.eclipse.basyx.vab.core.IConnectorProvider;
+import org.eclipse.basyx.vab.core.IDirectoryService;
+
+
+
+
+/**
+ * Configure a server connection
+ *
+ * @author kuhn
+ *
+ */
+public class CFGBaSyxConnection {
+
+
+ /**
+ * Protocol type
+ */
+ protected CFGBaSyxProtocolType protocol = null;
+
+
+ /**
+ * Directory type for this connection
+ */
+ protected String directoryProviderName = null;
+
+
+
+
+ /**
+ * Constructor
+ */
+ public CFGBaSyxConnection() {
+ // Do nothing
+ }
+
+
+ /**
+ * Set protocol type
+ *
+ * @return CFGBaSyxConnection to support builder pattern
+ */
+ public CFGBaSyxConnection setProtocol(CFGBaSyxProtocolType proto) {
+ // Store protocol type
+ protocol = proto;
+
+ // Return 'this' instance
+ return this;
+ }
+
+
+ /**
+ * Set directory
+ *
+ * @return CFGBaSyxConnection to support builder pattern
+ */
+ public CFGBaSyxConnection setDirectoryProvider(String providerName) {
+ // Store protocol type
+ directoryProviderName = providerName;
+
+ // Return 'this' instance
+ return this;
+ }
+
+
+
+ /**
+ * Create protocol provider
+ */
+ public IConnectorProvider createConnectorProvider() {
+ // Create connector provider instance
+ return protocol.createInstance();
+ }
+
+
+ /**
+ * Instantiate the directory class
+ */
+ public IDirectoryService createDirectoryInstance() {
+ // Try to create instance
+ try {
+ // Get Java class by name
+ Class<?> clazz = Class.forName(directoryProviderName);
+
+ // Instantiate class
+ IDirectoryService directoryService = (IDirectoryService) clazz.newInstance();
+
+ // Return directory service instance
+ return directoryService;
+ } catch (IllegalAccessException | ClassNotFoundException | InstantiationException e) {
+ // this is more or less fatal, so just inform the user
+ e.printStackTrace();
+ }
+
+ // Return null pointer
+ return null;
+ }
+}
+
diff --git a/components/basys.components/src/org/eclipse/basyx/components/configuration/CFGBaSyxProtocolType.java b/components/basys.components/src/org/eclipse/basyx/components/configuration/CFGBaSyxProtocolType.java
new file mode 100644
index 0000000..eba7b05
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/configuration/CFGBaSyxProtocolType.java
@@ -0,0 +1,68 @@
+package org.eclipse.basyx.components.configuration;
+
+import org.eclipse.basyx.aas.backend.connector.basyx.BaSyxConnectorProvider;
+import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
+import org.eclipse.basyx.vab.core.IConnectorProvider;
+
+
+
+/**
+ * Enumerate supported BaSyx protocol types
+ *
+ * @author kuhn
+ *
+ */
+public enum CFGBaSyxProtocolType {
+
+ /**
+ * HTTP protocol
+ */
+ HTTP(),
+
+ /**
+ * BaSyx protocol
+ */
+ BASYX();
+
+
+
+ /**
+ * Return BaSyx protocol type by value
+ */
+ public static CFGBaSyxProtocolType byValue(String cfgKey) {
+ // Parse configuration key
+ switch (cfgKey.toLowerCase()) {
+ // Parse known protocols
+ case "http": return CFGBaSyxProtocolType.HTTP;
+ case "basyx": return CFGBaSyxProtocolType.BASYX;
+
+ // Unknown protocol
+ default: return null;
+ }
+ }
+
+
+
+ /**
+ * Constructor
+ */
+ private CFGBaSyxProtocolType() {
+ // Do nothing
+ }
+
+
+
+ /**
+ * Create protocol instance
+ */
+ public IConnectorProvider createInstance() {
+ // Create protocol instance
+ if (this.equals(HTTP)) return new HTTPConnectorProvider();
+ if (this.equals(BASYX)) return new BaSyxConnectorProvider();
+
+ // Unknown protocol
+ return null;
+ }
+}
+
+
diff --git a/components/basys.components/src/org/eclipse/basyx/components/configuration/ConfigurableComponent.java b/components/basys.components/src/org/eclipse/basyx/components/configuration/ConfigurableComponent.java
new file mode 100644
index 0000000..48898ce
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/configuration/ConfigurableComponent.java
@@ -0,0 +1,24 @@
+package org.eclipse.basyx.components.configuration;
+
+import org.eclipse.basyx.components.configuration.builder.BaSyxConfigurationBuilder;
+
+/**
+ * Base interface for configurable components
+ *
+ * @author kuhn
+ *
+ */
+public interface ConfigurableComponent<T extends BaSyxConfigurationBuilder<?>> {
+
+
+ /**
+ * Create a component builder for this component that is used for configurating the component
+ */
+ public T configure();
+
+
+ /**
+ * Configure the component
+ */
+ public void configureComponent(T configuration);
+}
diff --git a/components/basys.components/src/org/eclipse/basyx/components/configuration/ConfigurableProperty.java b/components/basys.components/src/org/eclipse/basyx/components/configuration/ConfigurableProperty.java
new file mode 100644
index 0000000..761d64b
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/configuration/ConfigurableProperty.java
@@ -0,0 +1,12 @@
+package org.eclipse.basyx.components.configuration;
+
+
+/**
+ * Marker interface for configurable properties of configurable BaSyx components
+ *
+ * @author kuhn
+ *
+ */
+public @interface ConfigurableProperty {
+
+}
diff --git a/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxConfigurationBuilder.java b/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxConfigurationBuilder.java
new file mode 100644
index 0000000..ec71492
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxConfigurationBuilder.java
@@ -0,0 +1,70 @@
+package org.eclipse.basyx.components.configuration.builder;
+
+import org.eclipse.basyx.components.configuration.ConfigurableComponent;
+
+
+
+
+/**
+ * Base class for component configuration builders
+ *
+ * If the end() operation of a component configuration builder is invoked, and no sufficient configuration is provided, the component will
+ * throw an InsufficientConfigurationDataException.
+ *
+ * @author kuhn
+ *
+ */
+public abstract class BaSyxConfigurationBuilder<ParentBuilderType> {
+
+
+ /**
+ * Configured component
+ */
+ @SuppressWarnings("rawtypes")
+ protected ConfigurableComponent configuredComponent = null;
+
+
+ /**
+ * Parent builder
+ */
+ protected ParentBuilderType parentBuilder = null;
+
+
+
+ /**
+ * End configuration
+ *
+ * This base implementation invokes the <<<>>> operation of the configured component if configured
+ * component is not null. Only set the configured component for the top level builder, not for
+ * nested builders.
+ */
+ @SuppressWarnings("unchecked")
+ public ParentBuilderType end() {
+ // Null pointer check
+ // - If configured component is null, this is the case for nested builders, parent builder
+ // must not be null.
+ if (configuredComponent == null) return parentBuilder;
+
+ // Configure configured component
+ configuredComponent.configureComponent(this);
+
+ // Return null - if a configured component is set, no parent builder is set
+ return null;
+ }
+
+
+ /**
+ * Set reference to configured component
+ */
+ public void setConfiguredComponent(ConfigurableComponent<?> component) {
+ configuredComponent = component;
+ }
+
+
+ /**
+ * Set parent builder
+ */
+ public void setParentBuilder(ParentBuilderType parentBldr) {
+ parentBuilder = parentBldr;
+ }
+}
diff --git a/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxDeviceManagerConfigurationBuilder.java b/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxDeviceManagerConfigurationBuilder.java
new file mode 100644
index 0000000..df88e88
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxDeviceManagerConfigurationBuilder.java
@@ -0,0 +1,25 @@
+package org.eclipse.basyx.components.configuration.builder;
+
+import org.eclipse.basyx.components.configuration.ConfigurableComponent;
+
+
+
+/**
+ * Configuration builder for BaSyx device managers
+ *
+ * @author kuhn
+ *
+ */
+public class BaSyxDeviceManagerConfigurationBuilder<T extends BaSyxDeviceManagerConfigurationBuilder<T>> extends BaSyxServiceConfigurationBuilder<T> {
+
+
+
+ /**
+ * Constructor
+ */
+ public BaSyxDeviceManagerConfigurationBuilder(ConfigurableComponent<?> component) {
+ // Invoke base constructor
+ super(component);
+ }
+}
+
diff --git a/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxServiceConfigurationBuilder.java b/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxServiceConfigurationBuilder.java
new file mode 100644
index 0000000..b56eb55
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/configuration/builder/BaSyxServiceConfigurationBuilder.java
@@ -0,0 +1,88 @@
+package org.eclipse.basyx.components.configuration.builder;
+
+import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
+import org.eclipse.basyx.components.configuration.CFGBaSyxProtocolType;
+import org.eclipse.basyx.components.configuration.ConfigurableComponent;
+import org.eclipse.basyx.components.proxy.registry.AASHTTPRegistryProxy;
+import org.eclipse.basyx.components.proxy.registry.AASRegistryProxyIF;
+import org.eclipse.basyx.vab.core.VABConnectionManager;
+
+
+
+/**
+ * Configuration builder for BaSyx services
+ *
+ * @author kuhn
+ *
+ */
+public class BaSyxServiceConfigurationBuilder<T extends BaSyxServiceConfigurationBuilder<T>> extends BaSyxConfigurationBuilder<Void> {
+
+
+ /**
+ * BaSyx registry URL
+ */
+ protected String registryURL = null;
+
+
+ /**
+ * BaSyx connection manager type
+ */
+ protected CFGBaSyxProtocolType protocoltype = null;
+
+
+
+
+ /**
+ * Constructor
+ */
+ public BaSyxServiceConfigurationBuilder(ConfigurableComponent<?> component) {
+ // Set configured component
+ this.setConfiguredComponent(component);
+ }
+
+
+
+ /**
+ * Set registry URL
+ */
+ @SuppressWarnings("unchecked")
+ public T registryURL(String url) {
+ // Store registry URL
+ registryURL = url;
+
+ // Return 'this' reference
+ return (T) this;
+ }
+
+
+ /**
+ * Create registry instance based on configuration
+ */
+ public AASRegistryProxyIF getRegistry() {
+ // Create and return registry
+ return new AASHTTPRegistryProxy(registryURL);
+ }
+
+
+
+ /**
+ * Set connection manager type
+ */
+ @SuppressWarnings("unchecked")
+ public T connectionManagerType(CFGBaSyxProtocolType protocol) {
+ // Store protocol type
+ protocoltype = protocol;
+
+ // Return 'this' reference
+ return (T) this;
+ }
+
+ /**
+ * Create connection manager based on configuration
+ */
+ public VABConnectionManager getConnectionManager() {
+ // Create and return VABConnectionManager
+ return new VABConnectionManager(getRegistry(), new HTTPConnectorProvider());
+ }
+}
+
diff --git a/components/basys.components/src/org/eclipse/basyx/components/configuration/exception/InsufficientConfigurationDateException.java b/components/basys.components/src/org/eclipse/basyx/components/configuration/exception/InsufficientConfigurationDateException.java
new file mode 100644
index 0000000..dc9e5ed
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/configuration/exception/InsufficientConfigurationDateException.java
@@ -0,0 +1,38 @@
+package org.eclipse.basyx.components.configuration.exception;
+
+
+/**
+ * indicate insufficient configuration data, i.e. important configuration properties have not been set when a configurable component is instantiated.
+ *
+ * @author kuhn
+ *
+ */
+public class InsufficientConfigurationDateException extends RuntimeException {
+
+
+ /**
+ * Version of serialized instances
+ */
+ private static final long serialVersionUID = 1L;
+
+
+
+
+ /**
+ * Default constructor
+ */
+ public InsufficientConfigurationDateException() {
+ // Invoke base constructor
+ super();
+ }
+
+
+ /**
+ * Constructor with additional message
+ */
+ public InsufficientConfigurationDateException(String message) {
+ // Invoke base constructor
+ super(message);
+ }
+}
+
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ControlComponent.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ControlComponent.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ControlComponent.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ControlComponent.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ControlComponentChangeListener.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ControlComponentChangeListener.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ControlComponentChangeListener.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ControlComponentChangeListener.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ExecutionMode.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ExecutionMode.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ExecutionMode.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ExecutionMode.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ExecutionOrder.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ExecutionOrder.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ExecutionOrder.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ExecutionOrder.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ExecutionState.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ExecutionState.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/ExecutionState.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/ExecutionState.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/OccupationState.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/OccupationState.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/OccupationState.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/OccupationState.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/SimpleControlComponent.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/SimpleControlComponent.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/SimpleControlComponent.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/SimpleControlComponent.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/SimpleProxyControlComponent.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/SimpleProxyControlComponent.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/SimpleProxyControlComponent.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/SimpleProxyControlComponent.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/TestSimpleControlComponent.java b/components/basys.components/src/org/eclipse/basyx/components/controlcomponent/TestSimpleControlComponent.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/controlcomponent/TestSimpleControlComponent.java
rename to components/basys.components/src/org/eclipse/basyx/components/controlcomponent/TestSimpleControlComponent.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/device/BaSysNativeDeviceStatusIF.java b/components/basys.components/src/org/eclipse/basyx/components/device/BaSysNativeDeviceStatusIF.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/device/BaSysNativeDeviceStatusIF.java
rename to components/basys.components/src/org/eclipse/basyx/components/device/BaSysNativeDeviceStatusIF.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/device/BaseDevice.java b/components/basys.components/src/org/eclipse/basyx/components/device/BaseDevice.java
similarity index 63%
rename from examples/basys.examples/src/org/eclipse/basyx/components/device/BaseDevice.java
rename to components/basys.components/src/org/eclipse/basyx/components/device/BaseDevice.java
index b684ae2..265c827 100644
--- a/examples/basys.examples/src/org/eclipse/basyx/components/device/BaseDevice.java
+++ b/components/basys.components/src/org/eclipse/basyx/components/device/BaseDevice.java
@@ -32,6 +32,9 @@
*/
@Override
public void deviceInitialized() {
+ // Indicate initialization to device
+ onInitialize();
+
// Change status
statusChange(ExecutionState.IDLE.getValue());
}
@@ -42,7 +45,7 @@
*/
@Override
public void serviceRunning() {
- // Indicate service invocation to device manager
+ // Indicate service invocation to device
onServiceInvocation();
// Change status
@@ -55,6 +58,9 @@
*/
@Override
public void serviceCompleted() {
+ // Indicate service invocation to device
+ onServiceEnd();
+
// Change status
statusChange(ExecutionState.COMPLETE.getValue());
}
@@ -65,6 +71,9 @@
*/
@Override
public void resetCompleted() {
+ // Indicate reset to device
+ onReset();
+
// Change status
statusChange(ExecutionState.IDLE.getValue());
}
@@ -77,14 +86,41 @@
protected abstract void statusChange(String newStatus);
+
+
+ /**
+ * Indicate device initialization
+ */
+ protected void onInitialize() {
+ // Here: Initialize device
+ System.out.println("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDevice status change: initialize");
+ }
+
+
/**
* Indicate device service invocation
*/
- protected abstract void onServiceInvocation();
-
+ protected void onServiceInvocation() {
+ // Here: Invoke device service
+ System.out.println("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDevice status change: invoke");
+ }
+
/**
* Indicate device service end
*/
- protected abstract void onServiceEnd();
+ protected void onServiceEnd() {
+ // Here: Perform device operation after device service end (if necessary)
+ System.out.println("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDevice status change: end");
+ }
+
+
+ /**
+ * Indicate device reset
+ */
+ protected void onReset() {
+ // Here: Reset device
+ System.out.println("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDevice status change: reset");
+ }
}
+
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/device/BaseSmartDevice.java b/components/basys.components/src/org/eclipse/basyx/components/device/BaseSmartDevice.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/device/BaseSmartDevice.java
rename to components/basys.components/src/org/eclipse/basyx/components/device/BaseSmartDevice.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/device/BaseTCPControllableDevice.java b/components/basys.components/src/org/eclipse/basyx/components/device/BaseTCPControllableDeviceAdapter.java
similarity index 89%
rename from examples/basys.examples/src/org/eclipse/basyx/components/device/BaseTCPControllableDevice.java
rename to components/basys.components/src/org/eclipse/basyx/components/device/BaseTCPControllableDeviceAdapter.java
index efbdd03..750f8ee 100644
--- a/examples/basys.examples/src/org/eclipse/basyx/components/device/BaseTCPControllableDevice.java
+++ b/components/basys.components/src/org/eclipse/basyx/components/device/BaseTCPControllableDeviceAdapter.java
@@ -15,7 +15,7 @@
* @author kuhn
*
*/
-public abstract class BaseTCPControllableDevice extends BaseTCPDevice implements BaSysNativeDeviceStatusIF, NetworkReceiver {
+public abstract class BaseTCPControllableDeviceAdapter extends BaseTCPDeviceAdapter implements BaSysNativeDeviceStatusIF, NetworkReceiver {
/**
@@ -41,7 +41,7 @@
/**
* Constructor
*/
- public BaseTCPControllableDevice(int port) {
+ public BaseTCPControllableDeviceAdapter(int port) {
// Invoke base constructor
super(port);
}
@@ -98,9 +98,8 @@
@Override
protected void statusChange(String newStatus) {
// React to device status change
- // - Example - indicate running service in EXECUTE state
+ // - Indicate running service in EXECUTE state
if (newStatus.equals("EXECUTE")) onServiceInvocation();
- if (newStatus.equals("COMPLETE")) onServiceEnd();
// Set requested device execution state
exState = ExecutionState.byValue(newStatus);
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/device/BaseTCPDevice.java b/components/basys.components/src/org/eclipse/basyx/components/device/BaseTCPDeviceAdapter.java
similarity index 83%
rename from examples/basys.examples/src/org/eclipse/basyx/components/device/BaseTCPDevice.java
rename to components/basys.components/src/org/eclipse/basyx/components/device/BaseTCPDeviceAdapter.java
index 092a575..164938c 100644
--- a/examples/basys.examples/src/org/eclipse/basyx/components/device/BaseTCPDevice.java
+++ b/components/basys.components/src/org/eclipse/basyx/components/device/BaseTCPDeviceAdapter.java
@@ -18,7 +18,7 @@
* @author kuhn
*
*/
-public abstract class BaseTCPDevice extends BaseDevice implements BaSysNativeDeviceStatusIF {
+public abstract class BaseTCPDeviceAdapter extends BaseDevice implements BaSysNativeDeviceStatusIF {
/**
@@ -38,7 +38,7 @@
/**
* Constructor
*/
- public BaseTCPDevice(int port) {
+ public BaseTCPDeviceAdapter(int port) {
// Store server port
serverPort = port;
}
@@ -51,8 +51,11 @@
*/
@Override
protected void onServiceInvocation() {
+ // Invoke base implementation
+ super.onServiceInvocation();
+
// Write bytes to device manager
- communicationClient.sendMessage("invocation:\n");
+ communicationClient.sendMessage("invocation:start\n");
}
@@ -60,8 +63,11 @@
* Indicate device service end
*/
protected void onServiceEnd() {
+ // Invoke base implementation
+ super.onServiceEnd();
+
// Write bytes to device manager
- communicationClient.sendMessage("invocationEnd:\n");
+ communicationClient.sendMessage("invocation:end\n");
}
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/devicemanager/DeviceManagerComponent.java b/components/basys.components/src/org/eclipse/basyx/components/devicemanager/DeviceManagerComponent.java
similarity index 96%
rename from examples/basys.examples/src/org/eclipse/basyx/components/devicemanager/DeviceManagerComponent.java
rename to components/basys.components/src/org/eclipse/basyx/components/devicemanager/DeviceManagerComponent.java
index d94b1fb..c415697 100644
--- a/examples/basys.examples/src/org/eclipse/basyx/components/devicemanager/DeviceManagerComponent.java
+++ b/components/basys.components/src/org/eclipse/basyx/components/devicemanager/DeviceManagerComponent.java
@@ -2,12 +2,11 @@
import org.eclipse.basyx.aas.metamodel.hashmap.aas.identifier.IdentifierType;
import org.eclipse.basyx.components.service.BaseBaSyxService;
+import org.eclipse.basyx.tools.aasdescriptor.AASDescriptor;
+import org.eclipse.basyx.tools.aasdescriptor.SubmodelDescriptor;
+import org.eclipse.basyx.tools.modelurn.ModelUrn;
import org.eclipse.basyx.vab.core.tools.VABPathTools;
-import basys.examples.aasdescriptor.AASDescriptor;
-import basys.examples.aasdescriptor.ModelUrn;
-import basys.examples.aasdescriptor.SubmodelDescriptor;
-
/**
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/devicemanager/TCPControllableDeviceManagerComponent.java b/components/basys.components/src/org/eclipse/basyx/components/devicemanager/TCPControllableDeviceManagerComponent.java
similarity index 98%
rename from examples/basys.examples/src/org/eclipse/basyx/components/devicemanager/TCPControllableDeviceManagerComponent.java
rename to components/basys.components/src/org/eclipse/basyx/components/devicemanager/TCPControllableDeviceManagerComponent.java
index edb9af3..6cb28c4 100644
--- a/examples/basys.examples/src/org/eclipse/basyx/components/devicemanager/TCPControllableDeviceManagerComponent.java
+++ b/components/basys.components/src/org/eclipse/basyx/components/devicemanager/TCPControllableDeviceManagerComponent.java
@@ -74,7 +74,7 @@
// Check what was being received. This check is performed based on a prefix that he device has to provide);
// - Device indicates completion of service
- if (hasPrefix(rxStr, "invocationEnd:")) {
+ if (hasPrefix(rxStr, "invocation:end")) {
// Update control component with status
simpleControlComponent.setExecutionState(ExecutionState.COMPLETE.getValue());
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/devicemanager/TCPDeviceManagerComponent.java b/components/basys.components/src/org/eclipse/basyx/components/devicemanager/TCPDeviceManagerComponent.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/devicemanager/TCPDeviceManagerComponent.java
rename to components/basys.components/src/org/eclipse/basyx/components/devicemanager/TCPDeviceManagerComponent.java
diff --git a/components/basys.components/src/org/eclipse/basyx/components/devicemanager/config/DeviceManagerConfiguration.java b/components/basys.components/src/org/eclipse/basyx/components/devicemanager/config/DeviceManagerConfiguration.java
new file mode 100644
index 0000000..59288b8
--- /dev/null
+++ b/components/basys.components/src/org/eclipse/basyx/components/devicemanager/config/DeviceManagerConfiguration.java
@@ -0,0 +1,16 @@
+package org.eclipse.basyx.components.devicemanager.config;
+
+
+
+/**
+ * Device manager configuration object
+ *
+ *
+ * This class supports the builder pattern for the creation of device manager configurations
+ *
+ * @author kuhn
+ *
+ */
+public class DeviceManagerConfiguration {
+
+}
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/netcomm/NetworkReceiver.java b/components/basys.components/src/org/eclipse/basyx/components/netcomm/NetworkReceiver.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/netcomm/NetworkReceiver.java
rename to components/basys.components/src/org/eclipse/basyx/components/netcomm/NetworkReceiver.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/netcomm/TCPClient.java b/components/basys.components/src/org/eclipse/basyx/components/netcomm/TCPClient.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/netcomm/TCPClient.java
rename to components/basys.components/src/org/eclipse/basyx/components/netcomm/TCPClient.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/netcomm/TCPCommunicator.java b/components/basys.components/src/org/eclipse/basyx/components/netcomm/TCPCommunicator.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/netcomm/TCPCommunicator.java
rename to components/basys.components/src/org/eclipse/basyx/components/netcomm/TCPCommunicator.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/netcomm/TCPServer.java b/components/basys.components/src/org/eclipse/basyx/components/netcomm/TCPServer.java
similarity index 100%
rename from examples/basys.examples/src/org/eclipse/basyx/components/netcomm/TCPServer.java
rename to components/basys.components/src/org/eclipse/basyx/components/netcomm/TCPServer.java
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/proxy/registry/AASHTTPRegistryProxy.java b/components/basys.components/src/org/eclipse/basyx/components/proxy/registry/AASHTTPRegistryProxy.java
similarity index 60%
rename from examples/basys.examples/src/org/eclipse/basyx/components/proxy/registry/AASHTTPRegistryProxy.java
rename to components/basys.components/src/org/eclipse/basyx/components/proxy/registry/AASHTTPRegistryProxy.java
index acd08c3..9f7e55f 100644
--- a/examples/basys.examples/src/org/eclipse/basyx/components/proxy/registry/AASHTTPRegistryProxy.java
+++ b/components/basys.components/src/org/eclipse/basyx/components/proxy/registry/AASHTTPRegistryProxy.java
@@ -5,9 +5,11 @@
import org.eclipse.basyx.aas.backend.http.tools.GSONTools;
import org.eclipse.basyx.aas.backend.http.tools.factory.DefaultTypeFactory;
+import org.eclipse.basyx.aas.metamodel.hashmap.aas.identifier.IdentifierType;
+import org.eclipse.basyx.tools.aasdescriptor.AASDescriptor;
+import org.eclipse.basyx.tools.modelurn.ModelUrn;
import org.eclipse.basyx.tools.webserviceclient.WebServiceRawClient;
-import basys.examples.aasdescriptor.AASDescriptor;
-import basys.examples.aasdescriptor.ModelUrn;
+import org.eclipse.basyx.vab.core.IDirectoryService;
@@ -104,5 +106,60 @@
// Return AAS descriptor
return aasDescriptor;
}
+
+
+
+ /**
+ * Add an AAS mapping to a directory
+ *
+ * This function creates an AAS descriptor and registers it in the directory
+ */
+ @Override
+ public IDirectoryService addMapping(String key, String value) {
+ // Create AAS descriptor and set ID, ID type, and endpoint
+ AASDescriptor aasDescriptor = new AASDescriptor(key, IdentifierType.URI, value);
+
+ // Push AAS descriptor to server
+ client.post(aasRegistryURL+"/api/v1/registry", serializer.getJsonString(serializer.serialize(aasDescriptor)));
+
+ // Return 'this' reference
+ return this;
+ }
+
+
+ /**
+ * Delete an AAS mapping
+ */
+ @Override
+ public void removeMapping(String key) {
+ // Invoke delete operation of AAS registry
+ try {client.delete(aasRegistryURL+"/api/v1/registry/"+key);} catch (Exception e) {e.printStackTrace();}
+ }
+
+
+ /**
+ * Lookup one AAS mapping
+ */
+ @Override @SuppressWarnings("unchecked")
+ public String lookup(String id) {
+ // Lookup AAS from AAS directory, get AAS descriptor
+ String jsonData = client.get(aasRegistryURL+"/api/v1/registry/"+id);
+
+ // Deserialize AAS descriptor
+ AASDescriptor aasDescriptor = new AASDescriptor((Map<String, Object>) serializer.deserialize(serializer.getMap(serializer.getObjFromJsonStr(jsonData))));
+
+ // Return endpoint
+ return aasDescriptor.getFirstEndpoint();
+ }
+
+
+ /**
+ * Return all locally registered mappings
+ */
+ @Override
+ public Map<String, String> getMappings() {
+ // Currently not implemented
+ return null;
+ }
}
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/proxy/registry/AASRegistryProxyIF.java b/components/basys.components/src/org/eclipse/basyx/components/proxy/registry/AASRegistryProxyIF.java
similarity index 71%
rename from examples/basys.examples/src/org/eclipse/basyx/components/proxy/registry/AASRegistryProxyIF.java
rename to components/basys.components/src/org/eclipse/basyx/components/proxy/registry/AASRegistryProxyIF.java
index 3f538f9..1569c7d 100644
--- a/examples/basys.examples/src/org/eclipse/basyx/components/proxy/registry/AASRegistryProxyIF.java
+++ b/components/basys.components/src/org/eclipse/basyx/components/proxy/registry/AASRegistryProxyIF.java
@@ -1,7 +1,8 @@
package org.eclipse.basyx.components.proxy.registry;
-import basys.examples.aasdescriptor.AASDescriptor;
-import basys.examples.aasdescriptor.ModelUrn;
+import org.eclipse.basyx.tools.aasdescriptor.AASDescriptor;
+import org.eclipse.basyx.tools.modelurn.ModelUrn;
+import org.eclipse.basyx.vab.core.IDirectoryService;
@@ -12,7 +13,7 @@
* @author kuhn
*
*/
-public interface AASRegistryProxyIF {
+public interface AASRegistryProxyIF extends IDirectoryService {
/**
diff --git a/examples/basys.examples/src/org/eclipse/basyx/components/service/BaseBaSyxService.java b/components/basys.components/src/org/eclipse/basyx/components/service/BaseBaSyxService.java
similarity index 78%
rename from examples/basys.examples/src/org/eclipse/basyx/components/service/BaseBaSyxService.java
rename to components/basys.components/src/org/eclipse/basyx/components/service/BaseBaSyxService.java
index b9ab6c7..91d5ce6 100644
--- a/examples/basys.examples/src/org/eclipse/basyx/components/service/BaseBaSyxService.java
+++ b/components/basys.components/src/org/eclipse/basyx/components/service/BaseBaSyxService.java
@@ -3,13 +3,14 @@
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.basyx.components.configuration.ConfigurableComponent;
+import org.eclipse.basyx.components.configuration.builder.BaSyxServiceConfigurationBuilder;
import org.eclipse.basyx.components.proxy.registry.AASRegistryProxyIF;
import org.eclipse.basyx.sdk.api.service.BaSyxService;
+import org.eclipse.basyx.tools.modelurn.ModelUrn;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
-import basys.examples.aasdescriptor.ModelUrn;
-
/**
@@ -18,7 +19,7 @@
* @author kuhn
*
*/
-public abstract class BaseBaSyxService implements BaSyxService {
+public abstract class BaseBaSyxService implements BaSyxService, ConfigurableComponent<BaSyxServiceConfigurationBuilder<?>> {
/**
@@ -55,6 +56,29 @@
+
+ /**
+ * Configure this BaSyx component
+ */
+ @Override @SuppressWarnings({ "rawtypes", "unchecked" })
+ public BaSyxServiceConfigurationBuilder configure() {
+ // Create and return BaSyx configuration builder, set configured component to this component
+ return new BaSyxServiceConfigurationBuilder(this);
+ }
+
+
+ /**
+ * Configure this component
+ */
+ @Override
+ public void configureComponent(BaSyxServiceConfigurationBuilder<?> configuration) {
+ // Set registry
+ setRegistry(configuration.getRegistry());
+
+ // Create BaSyx connection manager
+ setConnectionManager(configuration.getConnectionManager());
+ }
+