This is an automated email from the ASF dual-hosted git repository. cdutz pushed a commit to branch feature/ads-symbol-discovery in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 73a6d8e2a91c297568de2d2b5ce114d83675055e Author: Christofer Dutz <[email protected]> AuthorDate: Wed Aug 24 08:54:46 2022 +0200 chore(plc4j/api): Added new versions of PlcValueType, PlcResponseCode, PlcSubscriptionType. --- .../plc4x/java/api/types/PlcResponseCode.java | 49 ++++++++++--- .../plc4x/java/api/types/PlcSubscriptionType.java | 44 +++++++----- .../apache/plc4x/java/api/types/PlcValueType.java | 84 ++++++++++++++++++++++ 3 files changed, 150 insertions(+), 27 deletions(-) diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcResponseCode.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcResponseCode.java index a0db07985..612c64423 100644 --- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcResponseCode.java +++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcResponseCode.java @@ -18,18 +18,45 @@ */ package org.apache.plc4x.java.api.types; +import java.util.HashMap; +import java.util.Map; + public enum PlcResponseCode { + OK((short) 0x01), + NOT_FOUND((short) 0x02), + ACCESS_DENIED((short) 0x03), + INVALID_ADDRESS((short) 0x04), + INVALID_DATATYPE((short) 0x06), + INVALID_DATA((short) 0x07), + INTERNAL_ERROR((short) 0x08), + REMOTE_BUSY((short) 0x09), + REMOTE_ERROR((short) 0x0A), + UNSUPPORTED((short) 0x0B), + RESPONSE_PENDING((short) 0x0C); + private static final Map<Short, PlcResponseCode> map; + + static { + map = new HashMap<>(); + for (PlcResponseCode value : PlcResponseCode.values()) { + map.put((short) value.getValue(), value); + } + } + + private final short value; + + PlcResponseCode(short value) { + this.value = value; + } + + public short getValue() { + return value; + } - OK, - NOT_FOUND, - ACCESS_DENIED, - INVALID_ADDRESS, - INVALID_DATATYPE, - INVALID_DATA, - INTERNAL_ERROR, - REMOTE_BUSY, - REMOTE_ERROR, - UNSUPPORTED, - RESPONSE_PENDING + public static PlcResponseCode enumForValue(short value) { + return map.get(value); + } + public static Boolean isDefined(short value) { + return map.containsKey(value); + } } diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcSubscriptionType.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcSubscriptionType.java index c28207bd0..a7d8b0455 100644 --- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcSubscriptionType.java +++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcSubscriptionType.java @@ -18,25 +18,37 @@ */ package org.apache.plc4x.java.api.types; -/** - * {@link PlcSubscriptionType} specifies the nature of the subscription. - * In general PLC4X supports exactly 3 types of subscriptions. - */ +import java.util.HashMap; +import java.util.Map; + public enum PlcSubscriptionType { + CYCLIC((short) 0x01), + CHANGE_OF_STATE((short) 0x02), + EVENT((short) 0x03); + private static final Map<Short, PlcSubscriptionType> map; + + static { + map = new HashMap<>(); + for (PlcSubscriptionType value : PlcSubscriptionType.values()) { + map.put((short) value.getValue(), value); + } + } + + private final short value; - /** - * A cyclic subscription where a value is sent no matter if it's value changed in a given interval. - */ - CYCLIC, + PlcSubscriptionType(short value) { + this.value = value; + } - /** - * Only send data, if a value in the PLC changed. - */ - CHANGE_OF_STATE, + public short getValue() { + return value; + } - /** - * Subscribe to events created by the PLC which usually are defined in the PLCs application (Alarms). - */ - EVENT + public static PlcSubscriptionType enumForValue(short value) { + return map.get(value); + } + public static Boolean isDefined(short value) { + return map.containsKey(value); + } } diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcValueType.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcValueType.java new file mode 100644 index 000000000..04031b70f --- /dev/null +++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/PlcValueType.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.plc4x.java.api.types; + +import java.util.HashMap; +import java.util.Map; + +// Code generated by code-generation. DO NOT EDIT. + +public enum PlcValueType { + NULL((short) 0x00), + BOOL((short) 0x01), + BYTE((short) 0x02), + WORD((short) 0x03), + DWORD((short) 0x04), + LWORD((short) 0x05), + USINT((short) 0x11), + UINT((short) 0x12), + UDINT((short) 0x13), + ULINT((short) 0x14), + SINT((short) 0x21), + INT((short) 0x22), + DINT((short) 0x23), + LINT((short) 0x24), + REAL((short) 0x31), + LREAL((short) 0x32), + CHAR((short) 0x41), + WCHAR((short) 0x42), + STRING((short) 0x43), + WSTRING((short) 0x44), + TIME((short) 0x51), + LTIME((short) 0x52), + DATE((short) 0x53), + LDATE((short) 0x54), + TIME_OF_DAY((short) 0x55), + LTIME_OF_DAY((short) 0x56), + DATE_AND_TIME((short) 0x57), + LDATE_AND_TIME((short) 0x58), + Struct((short) 0x61), + List((short) 0x62), + RAW_BYTE_ARRAY((short) 0x71); + private static final Map<Short, PlcValueType> map; + + static { + map = new HashMap<>(); + for (PlcValueType value : PlcValueType.values()) { + map.put((short) value.getValue(), value); + } + } + + private short value; + + PlcValueType(short value) { + this.value = value; + } + + public short getValue() { + return value; + } + + public static PlcValueType enumForValue(short value) { + return map.get(value); + } + + public static Boolean isDefined(short value) { + return map.containsKey(value); + } +}
