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 AddressData getAddress() { byte[] data = getData(); int index = 1; byte lowByte = data[index++]; byte highByte = data[index]; int address = ByteUtils.getWord(lowByte, (byte) (highByte & 0x3F)); LOGGER.debug("Return the address of MSG_BM_DYN_STATE: {}", address); return new AddressData(address, AddressTypeEnum.valueOf((byte) ((highByte & 0xC0) >> 6))); }
public AddressData getAddress() { byte[] data = getData(); int index = 0; byte lowByte = data[index++]; byte highByte = data[index++]; int address = ByteUtils.getWord(lowByte, (byte) (highByte & 0x3F)); LOGGER.debug("Return the address of MSG_BM_CV: {}", address); return new AddressData(address, AddressTypeEnum.valueOf((byte) ((highByte & 0xC0) >> 6))); }
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 List<AddressData> getAddresses() { List<AddressData> result = new LinkedList<AddressData>(); byte[] data = getData(); int index = 1; while (index < data.length) { byte lowByte = data[index++]; byte highByte = data[index++]; int address = ByteUtils.getWord(lowByte, (byte) (highByte & 0x3F)); if (address > 0) { AddressData addressData = new AddressData(address, AddressTypeEnum.valueOf((byte) ((highByte & 0xC0) >> 6))); LOGGER.trace("Add current address: {}", addressData); result.add(addressData); } } return result; } }
public AddressData getDecoderAddress() { int index = 0; byte lowByte = getData()[index++]; byte highByte = getData()[index++]; int address = ByteUtils.getWord(lowByte, highByte); AddressTypeEnum addressTypeEnum = AddressTypeEnum.LOCOMOTIVE_BACKWARD; AddressData addressData = new AddressData(address, addressTypeEnum); LOGGER.debug("Prepared address data: {}", addressData); return addressData; }
/** * Get the address data from the provided byte array. * * @param data * the byte array * @param offset * the offset inside the provided byte array * @return the AddressData instance */ public static AddressData fromByteArray(byte[] data, int offset) { int index = offset; byte lowByte = data[index++]; byte highByte = data[index++]; int address = ByteUtils.getWord(lowByte, (byte) (highByte & 0x3F)); AddressData addressData = new AddressData(address, AddressTypeEnum.valueOf((byte) ((highByte & 0xC0) >> 6))); return addressData; }
public AddressData getAddress() { byte[] data = getData(); int index = 0; byte decVid = data[index++]; if (decVid > 0) { // the decVid is > 0 -> no address return null; } byte lowByte = data[index++]; byte highByte = data[index++]; int address = ByteUtils.getWord(lowByte, (byte) (highByte & 0x3F)); LOGGER.debug("Return the address of MSG_BM_BLOCK_CV: {}", address); return new AddressData(address, AddressTypeEnum.valueOf((byte) ((highByte & 0xC0) >> 6))); }
public AddressData getAddress() { byte[] data = getData(); return new AddressData(ByteUtils.getWord(data[0], data[1]), AddressTypeEnum.valueOf((byte) ((data[1] & 0xC0) >> 6))); }
public FeedbackSpeedResponse(byte[] addr, int num, int decoderAddress, int speed) throws ProtocolException { this(addr, num, TYPE, ByteUtils .concat(AddressData.toByteArray(new AddressData(decoderAddress, AddressTypeEnum.LOCOMOTIVE_FORWARD)), ByteUtils.toWORD(speed))); }
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 AddressData getDecoderAddress() { int index = 0; byte lowByte = getData()[index++]; byte highByte = getData()[index++]; int address = ByteUtils.getWord(lowByte, highByte); index += 2; byte data2 = getData()[index]; AddressTypeEnum addressTypeEnum = AddressTypeEnum.LOCOMOTIVE_BACKWARD; if ((data2 & 0x80) == 0x80) { addressTypeEnum = AddressTypeEnum.LOCOMOTIVE_FORWARD; } AddressData addressData = new AddressData(address, addressTypeEnum); LOGGER.debug("Prepared address data: {}", addressData); return addressData; }
public AddressData getDecoderAddress() { LOGGER.debug("Get accessory decoder address from data: {}", ByteUtils.bytesToHex(getData())); int index = 0; byte lowByte = getData()[index++]; byte highByte = getData()[index++]; int address = ByteUtils.getWord(lowByte, highByte); byte data0 = getData()[DATA_INDEX]; AddressData addressData = new AddressData(address, ((data0 & 0x80) == 0x80 ? AddressTypeEnum.EXTENDED_ACCESSORY : AddressTypeEnum.ACCESSORY)); LOGGER.debug("Prepared address data: {}", addressData); return addressData; }
public AddressData getDecoderAddress() { LOGGER.info("Get accessory decoder address from data: {}", ByteUtils.bytesToHex(getData())); int index = 0; byte lowByte = getData()[index++]; byte highByte = getData()[index++]; int address = ByteUtils.getWord(lowByte, highByte); byte data0 = getData()[DATA_INDEX]; AddressData addressData = new AddressData(address, ((data0 & 0x80) == 0x80 ? AddressTypeEnum.EXTENDED_ACCESSORY : AddressTypeEnum.ACCESSORY)); LOGGER.debug("Prepared address data: {}", addressData); return addressData; }
public AddressData getAddress() { int index = 0; byte lowByte = getData()[index++]; byte highByte = getData()[index++]; int address = ByteUtils.getWord(lowByte, (byte) (highByte & 0x3F)); AddressData addressData = new AddressData(address, AddressTypeEnum.valueOf((byte) ((highByte & 0xC0) >> 6))); return addressData; }
public AddressData getDecoderAddress() { int index = 0; byte lowByte = getData()[index++]; byte highByte = getData()[index++]; int address = ByteUtils.getWord(lowByte, (byte) (highByte & 0x3F)); AddressData addressData = new AddressData(address, AddressTypeEnum.valueOf((byte) ((highByte & 0xC0) >> 6))); return addressData; }
public AddressData getDecoderAddress() { if (getDecoderVendorId() > 0) { // the decVid is > 0 -> no address return null; } int index = 0; byte lowByte = getData()[index++]; byte highByte = getData()[index++]; int address = ByteUtils.getWord(lowByte, (byte) (highByte & 0x3F)); AddressData addressData = new AddressData(address, AddressTypeEnum.valueOf((byte) ((highByte & 0xC0) >> 6))); return addressData; }
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; }
AddressData decoderAddress = new AddressData(ADDR_DATA_PACKET + lowAddress, addressType); CommandStationPom opCode = CommandStationPom.WR_BYTE;
AddressData decoderAddress = new AddressData(ADDR_NEW_ROW, addressType); CommandStationPom opCode = CommandStationPom.WR_BYTE;