sruehl commented on code in PR #1400: URL: https://github.com/apache/plc4x/pull/1400#discussion_r1486391136
########## plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java: ########## @@ -1448,54 +1452,86 @@ private CompletableFuture<S7Message> sendInternal(S7Message request) { } /** - * This method is only called when there is no Response Handler. + * DECODE: + * This method is called when there is no handler for the message. + * By default it must correspond to asynchronous events, which if so, + * must be transferred to the event queue. + * + * The event's own information is encapsulated in the parameters and payload + * field. From this it is abstracted to the corresponding event model. + * + * 01. S7ModeEvent: + * 02. S7UserEvent: + * 03. S7SysEvent: + * 04. S7CyclicEvent: + * + * TODO: Use mspec to generate types that allow better interpretation of + * the code using "instanceof". */ @Override protected void decode(ConversationContext<TPKTPacket> context, TPKTPacket msg) throws Exception { - - S7Message s7msg = msg.getPayload().getPayload(); - S7Parameter parameter = s7msg.getParameter(); - if (parameter instanceof S7ParameterModeTransition) { - // TODO: The eventQueue is only drained in the S7ProtocolEventLogic.ObjectProcessor and here only messages of type S7Event are processed, so S7PayloadUserDataItem elements will just be ignored. - //eventQueue.add(parameter); + System.out.println(msg); + final S7Message s7msg = msg.getPayload().getPayload(); + final S7Parameter parameter = s7msg.getParameter(); + final S7PayloadUserData payload = (S7PayloadUserData) s7msg.getPayload(); + + if (parameter instanceof S7ParameterModeTransition) { //(01) + + S7ModeEvent modeEvent = new S7ModeEvent((S7ParameterModeTransition) parameter); + eventQueue.add(modeEvent); + } else if (parameter instanceof S7ParameterUserData) { + S7ParameterUserData parameterUD = (S7ParameterUserData) parameter; List<S7ParameterUserDataItem> parameterUDItems = parameterUD.getItems(); + for (S7ParameterUserDataItem parameterUDItem : parameterUDItems) { + if (parameterUDItem instanceof S7ParameterUserDataItemCPUFunctions) { + Review Comment: why are there so many empty lines now? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@plc4x.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org