LatestMessages can hold MarkRounding messages. It also holds XMLMessage for each message type.

MockOutput now uses LatestMessages for xml messages.
Moved xml message encoding into RaceVisionByteEncoder. Removed XMLMessageEncoder.
Moved XML message sub types into an enumeration (XMLMessageType).
XMLMessage can now be queried for its attributes (like timestamp, length, etc...).

VisualiserInput now uses LatestMessages.
VisualiserInput now (as it did previously) uses switch statements for checking packet type, instead of if statements.
VisualiserRace now uses LatestMessages instead of VisualiserInput.
This commit is contained in:
fjc40
2017-07-07 02:05:21 +12:00
parent 8e18ad62ca
commit f057ad58b7
20 changed files with 767 additions and 418 deletions
@@ -1,5 +1,7 @@
package network.MessageDecoders;
import network.Messages.Enums.XMLMessageType;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
@@ -42,7 +44,7 @@ public class XMLMessageDecoder {
this.sequenceNumber = bytesToShort(sequenceNumberBytes);
this.xmlMsgLength = bytesToShort(xmlMsgLengthBytes);
this.xmlMessage = new String(xmlMessagebytes);
this.xmlMessage = new String(xmlMessagebytes).trim();
}
public byte getMessageVersionNumber() {
@@ -57,8 +59,8 @@ public class XMLMessageDecoder {
return timeStamp;
}
public byte getXmlMsgSubType() {
return xmlMsgSubType;
public XMLMessageType getXmlMsgSubType() {
return XMLMessageType.fromByte(xmlMsgSubType);
}
public short getSequenceNumber() {
@@ -69,14 +71,14 @@ public class XMLMessageDecoder {
return xmlMsgLength;
}
/**
* this will be used latter for the vis
* @return xml string as inputsource
* Returns the contents of the XML message (e.g., the contents of a race.xml file).
* @return The contents of the XML message.
*/
public InputStream getXmlMessageInputStream() {
InputStream is = new ByteArrayInputStream(xmlMessage.trim().getBytes(StandardCharsets.UTF_8));
// InputSource is = new InputSource(new StringReader(xmlMessage.trim()));
return is;
public String getXmlMessageContents() {
return xmlMessage;
}
}