Search in sources :

Example 1 with AdsPlcFieldHandler

use of org.apache.plc4x.java.ads.model.AdsPlcFieldHandler in project plc4x by apache.

the class Plc4x2AdsProtocolTest method data.

@Parameterized.Parameters(name = "{index} Type:{0} {3} {5}")
public static Collection<Object[]> data() {
    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(2);
    return streamOfLittleEndianDataTypePairs().filter(o -> o.getDataTypeClass() != LocalDateTime.class).filter(o -> o.getDataTypeClass() != Byte[].class).filter(o -> o.getDataTypeClass() != byte[].class).map(Plc4x2AdsProtocolTest::mapToAdsDataType).map(pair -> Stream.of(ImmutablePair.of(new PlcRequestContainer<>((InternalPlcRequest) // TODO: remove null
    new DefaultPlcWriteRequest.Builder(null, new AdsPlcFieldHandler()).addItem(RandomStringUtils.randomAscii(10), "1/1:" + pair.adsDataType.name(), pair.getValue()).build(), new CompletableFuture<>()), AdsWriteResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0))), ImmutablePair.of(new PlcRequestContainer<>((InternalPlcRequest) // TODO: remove null
    new DefaultPlcReadRequest.Builder(null, new AdsPlcFieldHandler()).addItem(RandomStringUtils.randomAscii(10), "1/1:" + pair.adsDataType.name()).build(), new CompletableFuture<>()), AdsReadResponse.of(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, Result.of(0), Data.of(pair.getByteRepresentation()))))).flatMap(stream -> stream).map(pair -> new Object[] { "???", pair.left, pair.left.getResponseFuture(), pair.left.getRequest().getClass().getSimpleName(), pair.right, pair.right.getClass().getSimpleName() }).collect(Collectors.toList());
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) AdsReadResponse(org.apache.plc4x.java.ads.api.commands.AdsReadResponse) java.util(java.util) Assume.assumeThat(org.junit.Assume.assumeThat) AdsWriteRequest(org.apache.plc4x.java.ads.api.commands.AdsWriteRequest) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) LocalDateTime(java.time.LocalDateTime) CompletableFuture(java.util.concurrent.CompletableFuture) Assert.assertThat(org.junit.Assert.assertThat) BigDecimal(java.math.BigDecimal) Data(org.apache.plc4x.java.ads.api.commands.types.Data) AdsWriteResponse(org.apache.plc4x.java.ads.api.commands.AdsWriteResponse) LocalTime(java.time.LocalTime) AmsHeader(org.apache.plc4x.java.ads.api.generic.AmsHeader) AdsPlcFieldHandler(org.apache.plc4x.java.ads.model.AdsPlcFieldHandler) BigInteger(java.math.BigInteger) ExpectedException(org.junit.rules.ExpectedException) AdsDataType(org.apache.plc4x.java.ads.model.AdsDataType) Parameterized(org.junit.runners.Parameterized) Invoke(org.apache.plc4x.java.ads.api.generic.types.Invoke) Before(org.junit.Before) Result(org.apache.plc4x.java.ads.api.commands.types.Result) AmsPacket(org.apache.plc4x.java.ads.api.generic.AmsPacket) Logger(org.slf4j.Logger) AmsNetId(org.apache.plc4x.java.ads.api.generic.types.AmsNetId) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) org.apache.plc4x.java.spi.messages(org.apache.plc4x.java.spi.messages) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) AtomicLong(java.util.concurrent.atomic.AtomicLong) Rule(org.junit.Rule) Stream(java.util.stream.Stream) Ignore(org.junit.Ignore) Modifier(java.lang.reflect.Modifier) LocalDate(java.time.LocalDate) AmsPort(org.apache.plc4x.java.ads.api.generic.types.AmsPort) RandomStringUtils(org.apache.commons.lang3.RandomStringUtils) AmsPort(org.apache.plc4x.java.ads.api.generic.types.AmsPort) AmsNetId(org.apache.plc4x.java.ads.api.generic.types.AmsNetId) AdsPlcFieldHandler(org.apache.plc4x.java.ads.model.AdsPlcFieldHandler) Invoke(org.apache.plc4x.java.ads.api.generic.types.Invoke)

Aggregations

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 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)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 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 AdsReadResponse (org.apache.plc4x.java.ads.api.commands.AdsReadResponse)1 AdsWriteRequest (org.apache.plc4x.java.ads.api.commands.AdsWriteRequest)1 AdsWriteResponse (org.apache.plc4x.java.ads.api.commands.AdsWriteResponse)1 Data (org.apache.plc4x.java.ads.api.commands.types.Data)1