RtdeTextMessage.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. int mLength=di.readByte();
  27. byte[] msgb=new byte[mLength];
  28. di.readFully(msgb);
  29. text=new String(msgb);
  30. int sLength=di.readByte();
  31. byte[] sourceb=new byte[sLength];
  32. di.readFully(sourceb);
  33. source=new String(sourceb);
  34. warningLevel=di.readByte();
  35. return this;
  36. }
  37. @Override
  38. public RtdeTextMessage send(DataOutputStream dos) throws IOException {
  39. sendHeader(dos);
  40. return this;
  41. }
  42. }