Search in sources :

Example 1 with CANOpenDataType

use of org.apache.plc4x.java.canopen.readwrite.CANOpenDataType in project plc4x by apache.

the class CANOpenPDOField method of.

public static CANOpenPDOField of(String addressString) {
    Matcher matcher = getMatcher(addressString);
    int nodeId = Integer.parseInt(matcher.group("nodeId"));
    String pdo = matcher.group("pdo");
    CANOpenService service = CANOpenService.valueOf(pdo);
    String canDataTypeString = matcher.group("canDataType");
    CANOpenDataType canOpenDataType = CANOpenDataType.valueOf(canDataTypeString);
    return new CANOpenPDOField(nodeId, service, canOpenDataType);
}
Also used : Matcher(java.util.regex.Matcher) CANOpenService(org.apache.plc4x.java.canopen.readwrite.CANOpenService) CANOpenDataType(org.apache.plc4x.java.canopen.readwrite.CANOpenDataType)

Example 2 with CANOpenDataType

use of org.apache.plc4x.java.canopen.readwrite.CANOpenDataType in project plc4x by apache.

the class CANOpenSDOField method of.

public static CANOpenSDOField of(String addressString) {
    Matcher matcher = getMatcher(addressString);
    int nodeId = Integer.parseInt(matcher.group("nodeId"));
    short index = parseHex(matcher.group("indexHex"), matcher.group("index"));
    short subIndex = parseHex(matcher.group("subIndexHex"), matcher.group("subIndex"));
    String canDataTypeString = matcher.group("canDataType");
    CANOpenDataType canOpenDataType = CANOpenDataType.valueOf(canDataTypeString);
    String answerNode = matcher.group("answerNodeId");
    if (answerNode != null) {
        int answerNodeId = Integer.parseInt(matcher.group("answerNodeId"));
        return new CANOpenSDOField(nodeId, answerNodeId, index, subIndex, canOpenDataType);
    }
    return new CANOpenSDOField(nodeId, index, subIndex, canOpenDataType);
}
Also used : Matcher(java.util.regex.Matcher) CANOpenDataType(org.apache.plc4x.java.canopen.readwrite.CANOpenDataType)

Aggregations

Matcher (java.util.regex.Matcher)2 CANOpenDataType (org.apache.plc4x.java.canopen.readwrite.CANOpenDataType)2 CANOpenService (org.apache.plc4x.java.canopen.readwrite.CANOpenService)1