public SOSBitArray toBitArray(ChannelSystemType channelType) { if (messageBitArray != null) { if (lastChannelType == channelType) return messageBitArray; SOSAgent.currentAgent() .sosLogger .messageContent .debug( "lastchanneltype is different!!!!!" + lastChannelType + " new chaneltype" + channelType); } lastChannelType = channelType; MessageGroup messageGroup = ReadXml.getValidChannelMessages(channelType); messageBitArray = new SOSBitArray(getBitSize(channelType)); int tempBitPosition = 0; messageBitArray.set( tempBitPosition, SOSBitArray.makeBit(messageGroup.headerToIndex(header), messageGroup.bitSize())); tempBitPosition += messageGroup.bitSize(); DataArrayList xmlData = ReadXml.blocks.get(header).data(); for (int i = 0; i < xmlData.size(); i++) { if (xmlData.getValue(i) < 0) { new Error("value is negetive!!!!!!!!!!!![TO BIT ARRAY]").printStackTrace(); messageBitArray.set(tempBitPosition, SOSBitArray.makeBit(0, xmlData.getValue(i))); } else messageBitArray.set( tempBitPosition, SOSBitArray.makeBit(getData(xmlData.getKey(i)), xmlData.getValue(i))); tempBitPosition += xmlData.getValue(i); } return messageBitArray; }
public int getBitSize(ChannelSystemType channelType) { return ReadXml.getBlockSize(header, channelType); }