RtdeTextMessage.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package at.acdp.urweb.rtde.packets;
  2. import java.io.DataInputStream;
  3. import java.io.DataOutputStream;
  4. import java.io.IOException;
  5. import static at.acdp.urweb.rtde.CommandType.RTDE_GET_URCONTROL_VERSION;
  6. import static at.acdp.urweb.rtde.CommandType.RTDE_TEXT_MESSAGE;
  7. public class RtdeTextMessage implements IRtdeData {
  8. private int replySize;
  9. public String text;
  10. public String source;
  11. public int warningLevel;
  12. @Override
  13. public int getType() {
  14. return RTDE_TEXT_MESSAGE;
  15. }
  16. @Override
  17. public int getSize() {
  18. return 3;
  19. }
  20. @Override
  21. public void setReplySize(int s) {
  22. replySize = s;
  23. }
  24. @Override
  25. public RtdeTextMessage read(DataInputStream di) throws IOException {
  26. readHeader(di);
  27. int mLength=di.readByte();
  28. byte[] msgb=new byte[mLength];
  29. di.readFully(msgb);
  30. text=new String(msgb);
  31. int sLength=di.readByte();
  32. byte[] sourceb=new byte[sLength];
  33. di.readFully(sourceb);
  34. source=new String(sourceb);
  35. warningLevel=di.readByte();
  36. return this;
  37. }
  38. @Override
  39. public RtdeTextMessage send(DataOutputStream dos) throws IOException {
  40. sendHeader(dos);
  41. return this;
  42. }
  43. }