Skip to content

Commit

Permalink
docs: Added some documentation to the PlcResponseCode values
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Sep 24, 2024
1 parent f291490 commit daee93f
Showing 1 changed file with 65 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,75 @@
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);

/**
* Everything went ok.
*/
OK((short) 0x01),
/**
* The requested ressource could not be found on the target device.
* (The address was syntactically correct, but the item it addressed simply didn't exist)
*/
NOT_FOUND((short) 0x02),
/**
* The remote device denied access to the requested resource.
* (Possibly remote access is disabled, or an authentication is required)
*/
ACCESS_DENIED((short) 0x03),
/**
* The resource address was syntactically invalid.
*/
INVALID_ADDRESS((short) 0x04),
/**
* The requested datatype does not exist or was not compatible with the requested ressource.
*/
INVALID_DATATYPE((short) 0x06),
INVALID_DATA((short) 0x07),
/**
* Something went wrong internally in the driver logic.
* (This is most probably a PLC4X bug)
*/
INTERNAL_ERROR((short) 0x08),
/**
* The remote device is currently unable to process the request due to overload.
*/
REMOTE_BUSY((short) 0x09),
/**
* Something went wrong on the remote side.
*/
REMOTE_ERROR((short) 0x0A),
/**
* The requested resource uses a feature of the driver which has not been implemented.
*/
UNSUPPORTED((short) 0x0B),
/**
* Indicates a response is pending.
*/
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;
private final short value;

PlcResponseCode(short value) {
this.value = value;
}
PlcResponseCode(short value) {
this.value = value;
}

public short getValue() {
return value;
}
public short getValue() {
return value;
}

public static PlcResponseCode enumForValue(short value) {
return map.get(value);
}
public static PlcResponseCode enumForValue(short value) {
return map.get(value);
}

public static Boolean isDefined(short value) {
return map.containsKey(value);
}
public static Boolean isDefined(short value) {
return map.containsKey(value);
}
}

0 comments on commit daee93f

Please sign in to comment.