Search in sources :

Example 1 with AssetConnection

use of de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnection in project FAAAST-Service by FraunhoferIOSB.

the class Service method init.

private void init() throws ConfigurationException {
    if (config.getPersistence() == null) {
        throw new InvalidConfigurationException("config.persistence must be non-null");
    }
    persistence = (Persistence) config.getPersistence().newInstance(config.getCore(), this);
    if (config.getMessageBus() == null) {
        throw new InvalidConfigurationException("config.messagebus must be non-null");
    }
    messageBus = (MessageBus) config.getMessageBus().newInstance(config.getCore(), this);
    if (config.getAssetConnections() != null) {
        List<AssetConnection> assetConnections = new ArrayList<>();
        for (AssetConnectionConfig assetConnectionConfig : config.getAssetConnections()) {
            assetConnections.add((AssetConnection) assetConnectionConfig.newInstance(config.getCore(), this));
        }
        assetConnectionManager = new AssetConnectionManager(config.getCore(), assetConnections, this);
    }
    if (config.getEndpoints() == null || config.getEndpoints().isEmpty()) {
        // TODO maybe be less restrictive and only print warning
        // throw new InvalidConfigurationException("at least endpoint must be defined in the configuration");
        logger.warn("no endpoint configuration found, starting service without endpoint which means the service will not be accessible via any kind of API");
    } else {
        endpoints = new ArrayList<>();
        for (EndpointConfig endpointConfig : config.getEndpoints()) {
            Endpoint endpoint = (Endpoint) endpointConfig.newInstance(config.getCore(), this);
            endpoints.add(endpoint);
        }
    }
    this.requestHandler = new RequestHandlerManager(this.config.getCore(), this.persistence, this.messageBus, this.assetConnectionManager);
}
Also used : AssetConnectionManager(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionManager) Endpoint(de.fraunhofer.iosb.ilt.faaast.service.endpoint.Endpoint) RequestHandlerManager(de.fraunhofer.iosb.ilt.faaast.service.request.RequestHandlerManager) ArrayList(java.util.ArrayList) AssetConnectionConfig(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionConfig) EndpointConfig(de.fraunhofer.iosb.ilt.faaast.service.endpoint.EndpointConfig) InvalidConfigurationException(de.fraunhofer.iosb.ilt.faaast.service.exception.InvalidConfigurationException) AssetConnection(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnection)

Example 2 with AssetConnection

use of de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnection in project FAAAST-Service by FraunhoferIOSB.

the class OpcUaEndpointFullTest method startTest.

/**
 * Initialize and start the test.
 *
 * @throws Exception If the operation fails
 */
@BeforeClass
public static void startTest() throws Exception {
    CoreConfig coreConfig = new CoreConfig();
    OpcUaEndpointConfig config = new OpcUaEndpointConfig();
    config.setTcpPort(OPC_TCP_PORT);
    config.setSecondsTillShutdown(0);
    AssetConnection assetConnection = new TestAssetConnection();
    // register Test Operation
    List<Key> keys = new ArrayList<>();
    keys.add(new DefaultKey.Builder().type(KeyElements.SUBMODEL).idType(KeyType.IRI).value("https://acplt.org/Test_Submodel3").build());
    keys.add(new DefaultKey.Builder().type(KeyElements.OPERATION).idType(KeyType.ID_SHORT).value("ExampleOperation").build());
    Reference ref = new DefaultReference.Builder().keys(keys).build();
    List<OperationVariable> outputArgs = new ArrayList<>();
    outputArgs.add(new DefaultOperationVariable.Builder().value(new DefaultProperty.Builder().idShort("Test Output 1").valueType("string").value("XYZ1").build()).build());
    assetConnection.registerOperationProvider(ref, new TestOperationProviderConfig(outputArgs));
    endpoint = new OpcUaEndpoint();
    service = new TestService(endpoint, assetConnection, true);
    endpoint.init(coreConfig, config, service);
    service.start();
}
Also used : TestAssetConnection(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.assetconnection.TestAssetConnection) DefaultOperationVariable(io.adminshell.aas.v3.model.impl.DefaultOperationVariable) OperationVariable(io.adminshell.aas.v3.model.OperationVariable) TestOperationProviderConfig(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.assetconnection.TestOperationProviderConfig) CoreConfig(de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig) TestService(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.TestService) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ArrayList(java.util.ArrayList) DefaultProperty(io.adminshell.aas.v3.model.impl.DefaultProperty) AssetConnection(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnection) TestAssetConnection(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.assetconnection.TestAssetConnection) DefaultOperationVariable(io.adminshell.aas.v3.model.impl.DefaultOperationVariable) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) Key(io.adminshell.aas.v3.model.Key) BeforeClass(org.junit.BeforeClass)

Aggregations

AssetConnection (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnection)2 ArrayList (java.util.ArrayList)2 AssetConnectionConfig (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionConfig)1 AssetConnectionManager (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionManager)1 CoreConfig (de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig)1 Endpoint (de.fraunhofer.iosb.ilt.faaast.service.endpoint.Endpoint)1 EndpointConfig (de.fraunhofer.iosb.ilt.faaast.service.endpoint.EndpointConfig)1 TestService (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.TestService)1 TestAssetConnection (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.assetconnection.TestAssetConnection)1 TestOperationProviderConfig (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.assetconnection.TestOperationProviderConfig)1 InvalidConfigurationException (de.fraunhofer.iosb.ilt.faaast.service.exception.InvalidConfigurationException)1 RequestHandlerManager (de.fraunhofer.iosb.ilt.faaast.service.request.RequestHandlerManager)1 Key (io.adminshell.aas.v3.model.Key)1 OperationVariable (io.adminshell.aas.v3.model.OperationVariable)1 Reference (io.adminshell.aas.v3.model.Reference)1 DefaultKey (io.adminshell.aas.v3.model.impl.DefaultKey)1 DefaultOperationVariable (io.adminshell.aas.v3.model.impl.DefaultOperationVariable)1 DefaultProperty (io.adminshell.aas.v3.model.impl.DefaultProperty)1 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)1 BeforeClass (org.junit.BeforeClass)1