public CommandStationPomMessage prepareTerminatingDataPacket(DecoderInformation.DecoderType decoderType) { LOGGER.info("Prepare terminating data packet for decoder type: {}", decoderType); // prepare the decoder type AddressTypeEnum addressType = AddressTypeEnum.LOCOMOTIVE_FORWARD; if (decoderType == DecoderType.accessoryDecoder) { addressType = AddressTypeEnum.ACCESSORY; } AddressData decoderAddress = new AddressData(ADDR_TERM_PACKET, addressType); CommandStationPom opCode = CommandStationPom.WR_BYTE; int cvNumber = 166; byte[] data = { 0 }; CommandStationPomMessage message = new CommandStationPomMessage(decoderAddress, opCode, cvNumber, data); return message; }
public PomAcknowledge readPom(DecoderIdAddressData locoAddress, CommandStationPom opCode, int cvNumber) throws ProtocolException { byte[] data = { 0 }; BidibMessage response = delegate.send(new CommandStationPomMessage(locoAddress, opCode, cvNumber, data), null, true, CommandStationPomAcknowledgeResponse.TYPE); PomAcknowledge result = null; if (response instanceof CommandStationPomAcknowledgeResponse) { result = ((CommandStationPomAcknowledgeResponse) response).getAcknState(); } LOGGER.debug("Return the pomAcknowledge: {}", result); return result; }
public PomAcknowledge readPom(AddressData locoAddress, CommandStationPom opCode, int cvNumber) throws ProtocolException { byte[] data = { 0 }; BidibMessage response = delegate.send(new CommandStationPomMessage(locoAddress, opCode, cvNumber, data), null, true, CommandStationPomAcknowledgeResponse.TYPE); PomAcknowledge result = null; if (response instanceof CommandStationPomAcknowledgeResponse) { result = ((CommandStationPomAcknowledgeResponse) response).getAcknState(); } LOGGER.debug("Return the pomAcknowledge: {}", result); return result; }
public List<CommandStationPomMessage> prepareDecoderInfoPomMessages( DecoderInformation decoderInfo, int decoderAddress) { // prepare the decoder type AddressTypeEnum addressType = AddressTypeEnum.LOCOMOTIVE_FORWARD; if (decoderInfo.getDecoderType() == DecoderType.accessoryDecoder) { addressType = AddressTypeEnum.ACCESSORY; } AddressData address = new AddressData(decoderAddress, addressType); CommandStationPom opCode = CommandStationPom.WR_BYTE; List<CommandStationPomMessage> messages = new ArrayList<CommandStationPomMessage>(); for (int cvNumber = 800; cvNumber < 812; cvNumber++) { byte[] data = { decoderInfo.getCvValue(cvNumber) }; CommandStationPomMessage message = new CommandStationPomMessage(address, opCode, cvNumber, data); messages.add(message); } return messages; }
public CommandStationPomMessage prepareDecoderInfoPomMessage( DecoderInformation decoderInfo, int decoderAddress, int cvNumber) { // prepare the decoder type AddressTypeEnum addressType = AddressTypeEnum.LOCOMOTIVE_FORWARD; if (decoderInfo.getDecoderType() == DecoderType.accessoryDecoder) { addressType = AddressTypeEnum.ACCESSORY; } AddressData address = new AddressData(decoderAddress, addressType); CommandStationPom opCode = CommandStationPom.WR_BYTE; byte[] data = { decoderInfo.getCvValue(cvNumber) }; CommandStationPomMessage message = new CommandStationPomMessage(address, opCode, cvNumber, data); return message; }
public PomAcknowledge writePom(AddressData locoAddress, CommandStationPom opCode, int cvNumber, int cvValue) throws ProtocolException { byte[] data = { ByteUtils.getLowByte(cvValue) }; if (CommandStationPom.XWR_BYTE2.equals(opCode)) { data = new byte[] { ByteUtils.getLowByte(cvValue), ByteUtils.getHighByte(cvValue) }; cvNumber = 0x04; // short form CV access for long address LOGGER.info("Prepared data for short form CV access write, cvNumber (instruction type): {}, 2 bytes: {}", cvNumber, ByteUtils.bytesToHex(data)); } BidibMessage response = delegate.send(new CommandStationPomMessage(locoAddress, opCode, cvNumber, data), null, true, CommandStationPomAcknowledgeResponse.TYPE); PomAcknowledge result = null; if (response instanceof CommandStationPomAcknowledgeResponse) { result = ((CommandStationPomAcknowledgeResponse) response).getAcknState(); } LOGGER.debug("Return the pomAcknowledge: {}", result); return result; }
public CommandStationPomMessage prepareInitiatingDataPacket(DecoderInformation decoderInfo) { DecoderInformation.DecoderType decoderType = decoderInfo.getDecoderType(); // prepare the decoder type AddressTypeEnum addressType = AddressTypeEnum.LOCOMOTIVE_FORWARD; if (decoderType == DecoderType.accessoryDecoder) { addressType = AddressTypeEnum.ACCESSORY; } AddressData decoderAddress = new AddressData(ADDR_INIT_PACKET, addressType); CommandStationPom opCode = CommandStationPom.WR_BYTE; // + 1 because the cvNumber is decremented before send int cvNumber = ByteUtils.getHighByte(decoderInfo.getDecoderId()) + 1; byte[] data = { ByteUtils.getLowByte(decoderInfo.getDecoderId()) }; CommandStationPomMessage message = new CommandStationPomMessage(decoderAddress, opCode, cvNumber, data); return message; }
CommandStationPomMessage message = new CommandStationPomMessage(decoderAddress, opCode, cvNumber, data);
CommandStationPomMessage message = new CommandStationPomMessage(decoderAddress, opCode, cvNumber, data);
break; case BidibLibrary.MSG_CS_POM: concreteBidibMessage = new CommandStationPomMessage(message); break; case BidibLibrary.MSG_CS_PROG: