Search in sources :

Example 1 with Event

use of io.adminshell.aas.v3.model.Event in project formula1-telemetry-kafka by ppatierno.

the class EventDeserializer method deserialize.

@Override
public Event deserialize(String topic, Headers headers, byte[] bytes) {
    ByteBuf bb = Unpooled.wrappedBuffer(bytes);
    ParticipantData participantData = null;
    // check if the raw bytes contains the participant data, depending the kind of event to deserialize
    if (bytes.length > PacketEventData.SIZE) {
        participantData = new ParticipantData().fill(bb);
    }
    Event event = new Event(participantData, (PacketEventData) new PacketEventData().fill(bb));
    return event;
}
Also used : Event(io.ppatierno.formula1.model.Event) ByteBuf(io.netty.buffer.ByteBuf) ParticipantData(io.ppatierno.formula1.data.ParticipantData) PacketEventData(io.ppatierno.formula1.packets.PacketEventData)

Example 2 with Event

use of io.adminshell.aas.v3.model.Event in project formkiq-core by formkiq.

the class AwsResourceTest method assertLambdaFunctionConfigurations.

/**
 * Assert {@link LambdaFunctionConfiguration}.
 *
 * @param c {@link LambdaFunctionConfiguration}
 * @param arn {@link String}
 * @param event {@link String}
 */
private static void assertLambdaFunctionConfigurations(final LambdaFunctionConfiguration c, final String arn, final String event) {
    assertTrue(c.lambdaFunctionArn().contains(arn));
    assertEquals(1, c.events().size());
    Event e = c.events().get(0);
    assertEquals(event, e.toString());
}
Also used : Event(software.amazon.awssdk.services.s3.model.Event)

Example 3 with Event

use of io.adminshell.aas.v3.model.Event in project FAAAST-Service by FraunhoferIOSB.

the class HttpEndpointIT method testAssetAdministrationShellInterfaceUpdateAssetInformation.

@Test
public void testAssetAdministrationShellInterfaceUpdateAssetInformation() throws InterruptedException, MessageBusException, IOException, URISyntaxException, SerializationException, DeserializationException {
    AssetAdministrationShell aas = environment.getAssetAdministrationShells().get(1);
    AssetInformation expected = aas.getAssetInformation();
    expected.getSpecificAssetIds().add(new DefaultIdentifierKeyValuePair.Builder().key("foo").value("bar").build());
    // TODO does this trigger any message bus event?
    executeAndAssertSingleEntity(HttpMethod.PUT, API_PATHS.aasInterface(aas).assetInformation(), StatusCode.SUCCESS_NO_CONTENT, expected, null, AssetInformation.class);
}
Also used : AssetInformation(io.adminshell.aas.v3.model.AssetInformation) DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Test(org.junit.Test)

Example 4 with Event

use of io.adminshell.aas.v3.model.Event in project FAAAST-Service by FraunhoferIOSB.

the class HttpEndpointIT method testAssetAdministrationShellInterfaceGetAssetInformation.

@Test
public void testAssetAdministrationShellInterfaceGetAssetInformation() throws IOException, DeserializationException, InterruptedException, URISyntaxException, SerializationException {
    AssetAdministrationShell aas = environment.getAssetAdministrationShells().get(1);
    AssetInformation expected = aas.getAssetInformation();
    // TODO does this trigger any message bus event?
    executeAndAssertSingleEntity(HttpMethod.GET, API_PATHS.aasInterface(aas).assetInformation(), StatusCode.SUCCESS, null, expected, AssetInformation.class);
}
Also used : AssetInformation(io.adminshell.aas.v3.model.AssetInformation) DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Test(org.junit.Test)

Example 5 with Event

use of io.adminshell.aas.v3.model.Event in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method elementCreated.

/**
 * Handles an elementCreated event.
 *
 * @param element Reference to the created element.
 * @param value The element that was added.
 * @throws StatusException If the operation fails
 * @throws ServiceResultException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws AddressSpaceException If the operation fails
 */
@SuppressWarnings("java:S2629")
private void elementCreated(Reference element, Referable value) throws StatusException, ServiceResultException, ServiceException, AddressSpaceException {
    if (element == null) {
        throw new IllegalArgumentException(ELEMENT_NULL);
    } else if (value == null) {
        throw new IllegalArgumentException(VALUE_NULL);
    }
    try {
        LOG.debug("elementCreated called. Reference {}", AasUtils.asString(element));
        // The element is the parent object where the value is added
        ObjectData parent = null;
        if (referableMap.containsKey(element)) {
            parent = referableMap.get(element);
        } else {
            LOG.info("elementCreated: element not found in referableMap: {}", AasUtils.asString(element));
        }
        if (value instanceof ConceptDescription) {
            addConceptDescriptions(List.of((ConceptDescription) value));
        } else if (value instanceof Asset) {
            addAsset(aasEnvironmentNode, (Asset) value);
        } else if (value instanceof Submodel) {
            addSubmodel(aasEnvironmentNode, (Submodel) value);
        } else if (value instanceof AssetAdministrationShell) {
            addAssetAdministrationShell((AssetAdministrationShell) value);
        } else if (parent != null) {
            if (value instanceof EmbeddedDataSpecification) {
                if (parent.getNode() instanceof AASAssetAdministrationShellType) {
                    addEmbeddedDataSpecifications((AASAssetAdministrationShellType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASSubmodelType) {
                    addEmbeddedDataSpecifications((AASSubmodelType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    addEmbeddedDataSpecifications((AASSubmodelElementType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASAssetType) {
                    addEmbeddedDataSpecifications((AASAssetType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else {
                    LOG.warn("elementCreated: EmbeddedDataSpecification parent class not found");
                }
            } else if (value instanceof Constraint) {
                if (parent.getNode() instanceof AASSubmodelType) {
                    addQualifiers(((AASSubmodelType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    addQualifiers(((AASSubmodelElementType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
                } else {
                    LOG.warn("elementCreated: Constraint parent class not found");
                }
            } else if (value instanceof SubmodelElement) {
                if (parent.getNode() instanceof AASSubmodelType) {
                    LOG.info("elementCreated: call addSubmodelElements");
                    addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), (Submodel) parent.getReferable(), element);
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    LOG.info("elementCreated: call addSubmodelElements");
                    addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), parent.getSubmodel(), element);
                } else {
                    LOG.warn("elementCreated: SubmodelElement parent class not found: {}; {}", parent.getNode().getNodeId(), parent.getNode());
                }
            }
        } else {
            LOG.warn("elementCreated: element not found: {}", AasUtils.asString(element));
        }
    } catch (Exception ex) {
        LOG.error("elementCreated Exception", ex);
        throw ex;
    }
}
Also used : Submodel(io.adminshell.aas.v3.model.Submodel) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) AASAssetType(opc.i4aas.AASAssetType) Constraint(io.adminshell.aas.v3.model.Constraint) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) StatusException(com.prosysopc.ua.StatusException) MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) ServiceException(com.prosysopc.ua.ServiceException) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException) EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) AASSubmodelType(opc.i4aas.AASSubmodelType) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) Asset(io.adminshell.aas.v3.model.Asset) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription)

Aggregations

Test (org.junit.Test)11 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)10 UaClient (com.prosysopc.ua.client.UaClient)9 BrowsePathResult (com.prosysopc.ua.stack.core.BrowsePathResult)9 RelativePath (com.prosysopc.ua.stack.core.RelativePath)9 RelativePathElement (com.prosysopc.ua.stack.core.RelativePathElement)9 DefaultKey (io.adminshell.aas.v3.model.impl.DefaultKey)9 ArrayList (java.util.ArrayList)9 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)7 LangString (io.adminshell.aas.v3.model.LangString)6 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)4 ElementCreateEventMessage (de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage)4 ServiceException (com.prosysopc.ua.ServiceException)3 StatusException (com.prosysopc.ua.StatusException)3 AddressSpaceException (com.prosysopc.ua.client.AddressSpaceException)3 DataValue (com.prosysopc.ua.stack.builtintypes.DataValue)3 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)3 ServiceResultException (com.prosysopc.ua.stack.common.ServiceResultException)3 BrowsePathTarget (com.prosysopc.ua.stack.core.BrowsePathTarget)3 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)3