use of org.apache.plc4x.java.canopen.readwrite.CANOpenService in project plc4x by apache.
the class CANOpenFrameDataHandler method fromCAN.
@Override
public CANOpenFrame fromCAN(FrameData frame) {
CANOpenService service = StaticHelper.serviceId((short) frame.getNodeId());
int nodeId = Math.abs(service.getMin() - frame.getNodeId());
return new CANOpenFrame((short) nodeId, service, frame.read(CANOpenPayload::staticParse, service));
}
use of org.apache.plc4x.java.canopen.readwrite.CANOpenService in project plc4x by apache.
the class CANOpenProtocolLogic method decode.
@Override
public void decode(ConversationContext<CANOpenFrame> context, CANOpenFrame msg) throws Exception {
int nodeId = msg.getNodeId();
CANOpenService service = msg.getService();
CANOpenPayload payload = msg.getPayload();
if (service != null && nodeId != this.configuration.getNodeId()) {
if (service.getPdo() && payload instanceof CANOpenPDOPayload) {
publishEvent(service, nodeId, payload);
} else if (service == CANOpenService.HEARTBEAT && payload instanceof CANOpenHeartbeatPayload) {
publishEvent(service, nodeId, payload);
} else {
logger.debug("Decoded CANOpen {} from {}, message {}", service, nodeId, payload);
}
}
// int identifier = msg.getIdentifier();
// CANOpenService service = CANOpenService.valueOf((byte) (identifier >> 7));
// if (service != null) {
// ReadBuffer buffer = new ReadBuffer(msg.getData());
// CANOpenPayload payload = CANOpenPayloadIO.staticParse(buffer, service);
//
//
// }
}
use of org.apache.plc4x.java.canopen.readwrite.CANOpenService 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);
}
Aggregations