Search in sources :

Example 6 with AmsPort

use of org.apache.plc4x.java.ads.api.generic.types.AmsPort in project plc4x by apache.

the class ADSProtocolBenchmark method buildADSWriteResponse.

private static byte[] buildADSWriteResponse() {
    AmsNetId targetAmsNetId = AmsNetId.of("1.2.3.4.5.6");
    AmsPort targetAmsPort = AmsPort.of(7);
    AmsNetId sourceAmsNetId = AmsNetId.of("8.9.10.11.12.13");
    AmsPort sourceAmsPort = AmsPort.of(14);
    Invoke invokeId = Invoke.of(15);
    Result result = Result.of(AdsReturnCode.ADS_CODE_0);
    return AdsWriteResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, result).getBytes();
}
Also used : AmsPort(org.apache.plc4x.java.ads.api.generic.types.AmsPort) AmsNetId(org.apache.plc4x.java.ads.api.generic.types.AmsNetId) Invoke(org.apache.plc4x.java.ads.api.generic.types.Invoke)

Example 7 with AmsPort

use of org.apache.plc4x.java.ads.api.generic.types.AmsPort in project plc4x by apache.

the class AbstractProtocolTest method amsPacketStream.

public static Stream<AmsPacket> amsPacketStream() {
    AmsNetId targetAmsNetId = AmsNetId.of("1.2.3.4.5.6");
    AmsPort targetAmsPort = AmsPort.of(7);
    AmsNetId sourceAmsNetId = AmsNetId.of("8.9.10.11.12.13");
    AmsPort sourceAmsPort = AmsPort.of(14);
    Invoke invokeId = Invoke.of(15);
    Data data = Data.of("Hello World!".getBytes());
    return Stream.of(AdsAddDeviceNotificationRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, IndexGroup.of(1), IndexOffset.of(1), Length.of(1), TransmissionMode.of(1), MaxDelay.of(1), CycleTime.of(1)), AdsAddDeviceNotificationResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0), NotificationHandle.of(0)), AdsDeleteDeviceNotificationRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, NotificationHandle.of(0)), AdsDeleteDeviceNotificationResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0)), AdsDeviceNotificationRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Stamps.of(1), Collections.singletonList(// Nano times need to be offset by (1.1.1970 - 1.1.1601) years in nanos
    AdsStampHeader.of(TimeStamp.of(new Date()), Collections.singletonList(AdsNotificationSample.of(NotificationHandle.of(0), data))))), AdsReadDeviceInfoRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId), AdsReadDeviceInfoResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0), MajorVersion.of((byte) 1), MinorVersion.of((byte) 2), Version.of(3), Device.of("Random DeviceId")), AdsReadRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, IndexGroup.of(0), IndexOffset.NONE, Length.of(1)), AdsReadResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0), data), AdsReadStateRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId), AdsReadStateResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0), AdsState.of(0), DeviceState.of(0)), AdsReadWriteRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, IndexGroup.of(0), IndexOffset.NONE, ReadLength.of(data.getCalculatedLength()), data), AdsReadWriteResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0), data), AdsWriteControlRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, AdsState.of(0xaffe), DeviceState.of(0xaffe), data), AdsWriteControlResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0)), AdsWriteRequest.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, IndexGroup.of(0), IndexOffset.NONE, data), AdsWriteResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0)));
}
Also used : AmsPort(org.apache.plc4x.java.ads.api.generic.types.AmsPort) AmsNetId(org.apache.plc4x.java.ads.api.generic.types.AmsNetId) Date(java.util.Date) Invoke(org.apache.plc4x.java.ads.api.generic.types.Invoke)

Aggregations

AmsNetId (org.apache.plc4x.java.ads.api.generic.types.AmsNetId)7 AmsPort (org.apache.plc4x.java.ads.api.generic.types.AmsPort)7 Invoke (org.apache.plc4x.java.ads.api.generic.types.Invoke)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Before (org.junit.Before)2 Field (java.lang.reflect.Field)1 Modifier (java.lang.reflect.Modifier)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 java.util (java.util)1 Date (java.util.Date)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1 RandomStringUtils (org.apache.commons.lang3.RandomStringUtils)1