Skip to content

Commit

Permalink
feat(bacnet): renamed access credential all
Browse files Browse the repository at this point in the history
+ worked a bit on tests
  • Loading branch information
sruehl committed Jun 14, 2022
1 parent e4d55f4 commit 10de05b
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 54 deletions.
2 changes: 1 addition & 1 deletion plc4go/internal/ads/fieldtype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plc4go/internal/modbus/fieldtype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plc4go/internal/s7/fieldtype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plc4go/internal/spi/testutils/steptype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,37 @@ public class Utils {

static int PAYLOAD_START_INDEX = 42;

static void tryParseBytes(int[] rawBytesAsInts) throws ParseException {
tryParseBytes(rawBytesAsInts, PAYLOAD_START_INDEX);
static BVLC tryParseBytes(int[] rawBytesAsInts) throws ParseException {
return tryParseBytes(rawBytesAsInts, PAYLOAD_START_INDEX);
}

static void tryParseBytes(int[] rawBytesAsInts, int startIndex) throws ParseException {
tryParseBytes(rawBytesAsInts, PAYLOAD_START_INDEX, DUMP_PACKAGES);
static BVLC tryParseBytes(int[] rawBytesAsInts, int startIndex) throws ParseException {
return tryParseBytes(rawBytesAsInts, startIndex, DUMP_PACKAGES);
}

static void tryParseBytes(int[] rawBytesAsInts, int startIndex, boolean dumpPackages) throws ParseException {
static BVLC tryParseBytes(int[] rawBytesAsInts, int startIndex, boolean dumpPackages) throws ParseException {
var rawBytes = (byte[]) ArrayUtils.toPrimitive(IntStream.of(rawBytesAsInts).boxed().map(Integer::byteValue).toArray(Byte[]::new));
rawBytes = ArrayUtils.subarray(rawBytes, startIndex, rawBytes.length);
BVLC bvlc = BVLC.staticParse(new ReadBufferByteBased(rawBytes));
assertNotNull(bvlc);
if (dumpPackages) System.out.println(bvlc);
return bvlc;
}

static void tryParseHex(String hex) throws ParseException, DecoderException {
tryParseHex(hex, DUMP_PACKAGES);
static BVLC tryParseHex(String hex) throws ParseException, DecoderException {
return tryParseHex(hex, DUMP_PACKAGES);
}

static void tryParseHex(String hex, boolean dumpPackages) throws ParseException, DecoderException {
tryParseHex(hex, 0, dumpPackages);
static BVLC tryParseHex(String hex, boolean dumpPackages) throws ParseException, DecoderException {
return tryParseHex(hex, 0, dumpPackages);
}

static void tryParseHex(String hex, int startIndex, boolean dumpPackages) throws ParseException, DecoderException {
static BVLC tryParseHex(String hex, int startIndex, boolean dumpPackages) throws ParseException, DecoderException {
byte[] rawBytes = Hex.decodeHex(hex);
rawBytes = ArrayUtils.subarray(rawBytes, startIndex, rawBytes.length);
BVLC bvlc = BVLC.staticParse(new ReadBufferByteBased(rawBytes));
assertNotNull(bvlc);
if (dumpPackages) System.out.println(bvlc);
return bvlc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,7 @@
/////
// All property implementations for every object

['ACCESS_CREDENTIAL' , 'ALL' BACnetConstructedDataAccessCredentialAl
['ACCESS_CREDENTIAL' , 'ALL' BACnetConstructedDataAccessCredentialAll
[validation '1==2' "All should never occur in context of constructed data. If it does please report"]
]
['ACCESS_DOOR' , 'ALL' BACnetConstructedDataAccessDoorAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
package org.apache.plc4x.protocol.bacnetip;

import org.apache.plc4x.plugins.codegenerator.protocol.TypeContext;
import org.apache.plc4x.plugins.codegenerator.types.definitions.ComplexTypeDefinition;
import org.apache.plc4x.plugins.codegenerator.types.definitions.EnumTypeDefinition;
import org.apache.plc4x.plugins.codegenerator.types.definitions.TypeDefinition;
import org.apache.plc4x.plugins.codegenerator.types.definitions.*;
import org.apache.plc4x.plugins.codegenerator.types.enums.EnumValue;
import org.apache.plc4x.plugins.codegenerator.types.fields.Field;
import org.apache.plc4x.plugins.codegenerator.types.fields.FieldConversions;
import org.apache.plc4x.plugins.codegenerator.types.fields.PropertyField;
import org.apache.plc4x.plugins.codegenerator.types.fields.ValidationField;
import org.junit.jupiter.api.*;
Expand All @@ -35,6 +32,7 @@
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static org.apache.plc4x.protocol.bacnetip.BACnetObjectsDefinitions.*;
import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -374,5 +372,18 @@ void outputNonUniqueProperties() {
LOGGER.info("property {} is used by {} non uniquely", propertyIdentifier, bacNetObjectNames);
});
}

@Test
void outputDataConstructedDataChilds(){
ComplexTypeDefinition baCnetConstructedData = typeDefinitions.get("BACnetConstructedData").asComplexTypeDefinition().orElseThrow();
Set<String> childsOfConstructedData = typeDefinitions.values().stream()
.filter(TypeDefinitionConversions::isDiscriminatedComplexTypeDefinition)
.map(DiscriminatedComplexTypeDefinition.class::cast)
.filter(discriminatedComplexTypeDefinition -> discriminatedComplexTypeDefinition.getParentType().isPresent())
.filter(discriminatedComplexTypeDefinition -> discriminatedComplexTypeDefinition.getParentType().get() == baCnetConstructedData)
.map(TypeDefinition::getName)
.collect(Collectors.toSet());
childsOfConstructedData.stream().sorted().forEach(System.out::println);
}
}
}

0 comments on commit 10de05b

Please sign in to comment.