Class NetworkReceiver

java.lang.Object
PamController.PamControlledUnit
networkTransfer.receive.NetworkReceiver
All Implemented Interfaces:
NetworkDataUser, PamSettings, SettingsNameProvider

public class NetworkReceiver extends PamControlledUnit implements PamSettings, NetworkDataUser
Receive near real time data over the network in the form of packaged PamDataUnits.
Author:
Doug Gillespie
  • Field Details

    • unitTypeString

      public static String unitTypeString
    • NET_PAM_DATA

      public static final int NET_PAM_DATA
      Flags for dataType1 - these must match equivalent commands in other network C++ code, so don't mess with them !
      See Also:
    • NET_PAM_COMMAND

      public static final int NET_PAM_COMMAND
      See Also:
    • NET_AUDIO_DATA

      public static final int NET_AUDIO_DATA
      See Also:
    • NET_PAM_COMMAND_STOP

      public static final int NET_PAM_COMMAND_STOP
      See Also:
    • NET_PAM_COMMAND_PREPARE

      public static final int NET_PAM_COMMAND_PREPARE
      See Also:
    • NET_PAM_COMMAND_START

      public static final int NET_PAM_COMMAND_START
      See Also:
  • Constructor Details

    • NetworkReceiver

      public NetworkReceiver(String unitName)
      Some very basic commands to send straight through to receiving stations
      Parameters:
      unitName -
  • Method Details

    • getNetworkReceiveProcess

      public networkTransfer.receive.NetworkReceiver.NetworkReceiveProcess getNetworkReceiveProcess()
    • getTabPanel

      public PamTabPanel getTabPanel()
      Description copied from class: PamControlledUnit
      Gets a reference to a panel to be added to a view
      Overrides:
      getTabPanel in class PamControlledUnit
      Returns:
      reference to a PamTabPanel object
      See Also:
    • getSidePanel

      public PamSidePanel getSidePanel()
      Description copied from class: PamControlledUnit
      Gets a reference to a small panel to be displayed along the left hand edge of the main tab panel. Side panels should be small since they are always visible and any space they take will be taken from the main tab panel.

      It is possible for a PamControlled unit to have a side panel without having a pamTabPanel.

      Overrides:
      getSidePanel in class PamControlledUnit
      Returns:
      a pamSidePanel object.
      See Also:
    • notifyModelChanged

      public void notifyModelChanged(int changeType)
      Description copied from class: PamControlledUnit
      General notification when the PAMGAURD model changes.
      Overrides:
      notifyModelChanged in class PamControlledUnit
      Parameters:
      changeType - type of change
    • createDetectionMenu

      public JMenuItem createDetectionMenu(Frame parentFrame)
      Description copied from class: PamControlledUnit
      Create a JMenu object containing MenuItems associated with PamProcesses
      Overrides:
      createDetectionMenu in class PamControlledUnit
      Parameters:
      parentFrame - The owner frame of the menu
      Returns:
      reference to a JMenu which can be added to an existing menu or menu bar

      Note that if multiple views are to use the same menu, then they should each create a new menu (by setting Create to true) the first time they call this method.

    • getBuoyStatusDataBlock

      public BuoyStatusDataBlock getBuoyStatusDataBlock()
      Returns:
      the buoyStatusDataBlock
    • detectionDialog

      public void detectionDialog(Frame parentFrame)
      Display the network dialog and act if things change.
      Parameters:
      parentFrame - parent frame to own dialog
    • getRecentPackets

      public int getRecentPackets()
      Returns:
      the number of data packets received since the last call to this function
    • getRecentDataBytes

      public int getRecentDataBytes()
      Returns:
      The total number of bytes received since the last call to this function
    • socketClosed

      public void socketClosed(NetworkReceiveThread networkReceiveThread)
      Specified by:
      socketClosed in interface NetworkDataUser
    • interpretData

      public NetworkObject interpretData(NetworkObject receivedObject)
      Specified by:
      interpretData in interface NetworkDataUser
    • checkExistingThreads

      public void checkExistingThreads(Socket clientSocket, NetworkReceiveThread wantedThread)
      Before opening a new thread for this client, check to see if that client already has a receive thread open and then if it has close it
      Parameters:
      clientSocket -
      wantedThread - The thread we just made, so want to keep.
    • interpretPamData

      public NetworkObject interpretPamData(NetworkObject receivedData, BuoyStatusDataUnit buoyStatusDataUnit)
      Parameters:
      buoyStatusDataUnit - data unit holding information about this sending station
      socket - Socket data were read from
      dataVersion2 - This is from the Network packet header and should be used the same way as the HeaderVersion, i.e. for major structural changes to the data format.
      dataId1 - station id 1
      dataId2 - station id 2
      dataLen - data length
      duBuffer - data, including additional header information.
      Returns:
    • getPamCommandString

      public static String getPamCommandString(int command)
    • findBuoyStatusDataUnit

      public BuoyStatusDataUnit findBuoyStatusDataUnit(int buoyId1, int buoyId2, boolean create)
      Find buoy status data and optionally create it if it doesn't exist.
      Parameters:
      buoyId1 - buoy Id 1
      buoyId2 - buoy Id 2
      create - automatically create
      Returns:
      status data unit or null if not found.
    • findBuoyStatusDataUnit

      public BuoyStatusDataUnit findBuoyStatusDataUnit(InetAddress address)
      Find a buoy status data unit from it's inet address.
      Parameters:
      address -
      Returns:
      status data unit.
    • checkAcousticBuoyStats

      public void checkAcousticBuoyStats(BuoyStatusDataUnit buoyStatusDataUnit)
      If data units coming out of this buoy are acoustic, then it will need hydrophones. Note that all this code needs to work with non acoustic data too - such as logger forms, in which case it wn' tbe necessary to have hydrophones.
      Parameters:
      buoyStatusDataUnit - status data.
    • getRxDataBlocks

      public ArrayList<PamDataBlock> getRxDataBlocks()
      Returns:
      the rxDataBlocks
    • getNetworkReceiveParams

      public NetworkReceiveParams getNetworkReceiveParams()
      Returns:
      the networkReceiveParams
    • getSettingsReference

      public Serializable getSettingsReference()
      Specified by:
      getSettingsReference in interface PamSettings
      Returns:
      The serialisable object that will be stored
    • getSettingsVersion

      public long getSettingsVersion()
      Specified by:
      getSettingsVersion in interface PamSettings
      Returns:
      An integer version number for the settings
    • restoreSettings

      public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
      Specified by:
      restoreSettings in interface PamSettings
      Returns:
      true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required
    • pamClose

      public void pamClose()
      Description copied from class: PamControlledUnit
      Called when PAMGUARD is finally closing down so that a module may free any remaining resources (e.g. files or COMM ports).
      Overrides:
      pamClose in class PamControlledUnit
    • canClose

      public boolean canClose()
      Description copied from class: PamControlledUnit
      Called before Pamguard shuts down. Rather than returning false, this function can be used as a final oportunity to save settings, write to the database, etc.
      Overrides:
      canClose in class PamControlledUnit
      Returns:
      true if OK for Pamguard to shut down, false otherwise.
    • getExtraTableInfo

      public ArrayList<PairedValueInfo> getExtraTableInfo()
    • addExtraTableInfo

      public void addExtraTableInfo(PairedValueInfo pairedValueInfo)
      Add extra data fields to the table, data units, etc. this call primarily adds them to the list of stuff that will get displayed.
      Parameters:
      pairedValueInfo - Information about a value that will be stored in the appropriate BuoyStatusDataunit
    • addExtraDataUser

      public void addExtraDataUser(NetworkDataUser extraDataUser)
      Add an extra data user which will get called with ALL data arriving over the network so can handle additional functions / data types not managed by the standard build in data user which doesn't know much about anything but PAMDataUnits.
      Parameters:
      extraDataUser -
    • useBuoyGPSData

      public boolean useBuoyGPSData(BuoyStatusDataUnit buoyStatusDataUnit, GpsDataUnit gpsDataUnit)
    • getTableMouseListener

      public RXTableMouseListener<BuoyStatusDataUnit> getTableMouseListener()
      Returns:
      the tableMouseListener
    • setTableMouseListener

      public void setTableMouseListener(RXTableMouseListener<BuoyStatusDataUnit> tableMouseListener)
      Parameters:
      tableMouseListener - the tableMouseListener to set
    • newReceivedDataUnit

      public void newReceivedDataUnit(BuoyStatusDataUnit buoyStatusDataUnit, PamDataUnit dataUnit)
      Specified by:
      newReceivedDataUnit in interface NetworkDataUser