Skip to content

Commit

Permalink
fix(plc-simulator/cbus): fixed simulator returning wrong status
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Aug 2, 2022
1 parent eede89a commit 0056237
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,22 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
StatusRequest statusRequest = cBusPointToMultiPointCommandStatus.getStatusRequest();
if (statusRequest instanceof StatusRequestBinaryState) {
StatusRequestBinaryState statusRequestBinaryState = (StatusRequestBinaryState) statusRequest;
StatusHeader statusHeader = new StatusHeader((short) (2 + 1)); // 2 we have always + 1 as we got one status byte
// TODO: map actuall values from simulator
byte blockStart = 0x0;
List<StatusByte> statusBytes = List.of(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
// TODO: this might be extended or standard depeding on exstat
StandardFormatStatusReply standardFormatStatusReply = new StandardFormatStatusReply(statusHeader, statusRequestBinaryState.getApplication(), blockStart, statusBytes);
EncodedReply encodedReply = new EncodedReplyStandardFormatStatusReply((byte) 0xC0, standardFormatStatusReply, cBusOptions, requestContext);
EncodedReply encodedReply;
if (exstat) {
ExtendedStatusHeader extendedStatusHeader = new ExtendedStatusHeader((short) (3 + 1));
// TODO: map actuall values from simulator
byte blockStart = 0x0;
List<StatusByte> statusBytes = List.of(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
ExtendedFormatStatusReply extendedFormatStatusReply = new ExtendedFormatStatusReply(extendedStatusHeader, StatusCoding.BINARY_BY_THIS_SERIAL_INTERFACE, statusRequestBinaryState.getApplication(), blockStart, statusBytes, null);// 3 we have always + 1 as we got one status byte
encodedReply = new EncodedReplyExtendedFormatStatusReply((byte) 0xE0, extendedFormatStatusReply, cBusOptions, requestContext);
} else {
StatusHeader statusHeader = new StatusHeader((short) (2 + 1)); // 2 we have always + 1 as we got one status byte
// TODO: map actuall values from simulator
byte blockStart = 0x0;
List<StatusByte> statusBytes = List.of(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
StandardFormatStatusReply standardFormatStatusReply = new StandardFormatStatusReply(statusHeader, statusRequestBinaryState.getApplication(), blockStart, statusBytes);
encodedReply = new EncodedReplyStandardFormatStatusReply((byte) 0xC0, standardFormatStatusReply, cBusOptions, requestContext);
}
ReplyEncodedReply replyEncodedReply = new ReplyEncodedReply((byte) 0xC0, encodedReply, null, cBusOptions, requestContext);
ReplyOrConfirmation replyOrConfirmation = new ReplyOrConfirmationReply((byte) 0xFF, replyEncodedReply, new ResponseTermination(), cBusOptions, requestContext);
Alpha alpha = requestCommand.getAlpha();
Expand Down Expand Up @@ -312,6 +321,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
pun = false;
pcn = false;
srchk = false;
stopMonitor();
return;
}
if (request instanceof RequestSmartConnectShortcut) {
Expand Down

0 comments on commit 0056237

Please sign in to comment.