Class NetworkObjectPacker

java.lang.Object
networkTransfer.send.NetworkObjectPacker

public class NetworkObjectPacker extends Object
Functions to pack up data for sending over the network.
Author:
Doug Gillespie
  • Field Details

  • Constructor Details

    • NetworkObjectPacker

      public NetworkObjectPacker()
  • Method Details

    • packData

      public byte[] packData(int buoyId1, int buoyId2, short dataType1, int dataType2, byte[] data)
    • packDataUnit

      public String packDataUnit(PamDataBlock dataBlock, PamDataUnit dataUnit)
      Pack a data unit as a json-formatted String for TCP/IP transfer
      Parameters:
      dataBlock -
      dataUnit -
      Returns:
    • packDataUnit

      public byte[] packDataUnit(int buoyId1, int buoyId2, PamDataBlock dataBlock, PamDataUnit dataUnit)
      Pack a data unit as a byte array for TCPIP transfer. Note that data units get additional head information comprising an objectid, a time in millis and the actual datalength.
      Parameters:
      buoyId1 -
      buoyId2 -
      dataBlock -
      dataUnit -
      Returns:
    • packData

      public byte[] packData(NetworkObject netObj)
    • packData

      public byte[] packData(int buoyId1, int buoyId2, short dataType1, int dataType2, byte[] data, int dataLength)
      Pack any type of data for TCP transfer between programmes.
      Parameters:
      buoyId1 - buoy id1
      buoyId2 - buoy id2
      dataType1 - first data identifier
      dataType2 - second data identifier
      data - data
      dataLength - length of data in bytes.
      Returns:
      byte packed array