Package networkTransfer.receive
Class NetworkReceiver
java.lang.Object
PamController.PamControlledUnit
networkTransfer.receive.NetworkReceiver
- All Implemented Interfaces:
NetworkDataUser
,PamSettings
,SettingsNameProvider
Receive near real time data over the network in the form of packaged PamDataUnits.
- Author:
- Doug Gillespie
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
Flags for dataType1 - these must match equivalent commands in other network C++ code, so don't mess with them !static String
-
Constructor Summary
ConstructorDescriptionNetworkReceiver
(String unitName) Some very basic commands to send straight through to receiving stations -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.void
addExtraTableInfo
(PairedValueInfo pairedValueInfo) Add extra data fields to the table, data units, etc.boolean
canClose()
Called before Pamguard shuts down.void
checkAcousticBuoyStats
(BuoyStatusDataUnit buoyStatusDataUnit) If data units coming out of this buoy are acoustic, then it will need hydrophones.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 itcreateDetectionMenu
(Frame parentFrame) Create a JMenu object containing MenuItems associated with PamProcessesvoid
detectionDialog
(Frame parentFrame) Display the network dialog and act if things change.findBuoyStatusDataUnit
(int buoyId1, int buoyId2, boolean create) Find buoy status data and optionally create it if it doesn't exist.findBuoyStatusDataUnit
(InetAddress address) Find a buoy status data unit from it's inet address.networkTransfer.receive.NetworkReceiver.NetworkReceiveProcess
static String
getPamCommandString
(int command) int
int
long
Gets a reference to a small panel to be displayed along the left hand edge of the main tab panel.Gets a reference to a panel to be added to a viewinterpretData
(NetworkObject receivedObject) interpretPamData
(NetworkObject receivedData, BuoyStatusDataUnit buoyStatusDataUnit) void
newReceivedDataUnit
(BuoyStatusDataUnit buoyStatusDataUnit, PamDataUnit dataUnit) void
notifyModelChanged
(int changeType) General notification when the PAMGAURD model changes.void
pamClose()
Called when PAMGUARD is finally closing down so that a module may free any remaining resources (e.g.boolean
restoreSettings
(PamControlledUnitSettings pamControlledUnitSettings) void
setTableMouseListener
(RXTableMouseListener<BuoyStatusDataUnit> tableMouseListener) void
socketClosed
(NetworkReceiveThread networkReceiveThread) boolean
useBuoyGPSData
(BuoyStatusDataUnit buoyStatusDataUnit, GpsDataUnit gpsDataUnit) Methods inherited from class PamController.PamControlledUnit
addOfflineTaskGroup, addOtherRelatedMenuItems, addPamProcess, addPamProcess, addRelatedMenuItems, canPlayViewerSound, createDisplayMenu, createFileMenu, createHelpMenu, flushDataBlockBuffers, getBackupInformation, getFrameNumber, getGUI, getGuiFrame, getInstanceIndex, getModuleStatus, getModuleStatusManager, getModuleSummary, getModuleSummary, getNumOfflineTaskGroups, getNumPamProcesses, getOfflineState, getOfflineTaskGroup, getPamConfiguration, getPamController, getPamModuleInfo, getPamProcess, getPamView, getPlugin, getShortUnitType, getTabClipCopier, getTabSpecificMenuBar, getToolbarComponent, getUnitName, getUnitType, getVerboseLevel, gotoTab, isInMainConfiguration, isNetRx, isViewer, pamHasStopped, pamToStart, playViewerSound, removePamProcess, removeUnit, rename, saveViewerData, setFrameNumber, setModuleStatusManager, setPamConfiguration, setPamController, setPamModuleInfo, setPamView, setSidePanel, setTabPanel, setToolbarComponent, setupControlledUnit, stopViewerSound, tellModule, terminalPrint, terminalPrintln, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface PamController.PamSettings
getUnitType
Methods inherited from interface PamController.SettingsNameProvider
getUnitName
-
Field Details
-
unitTypeString
-
NET_PAM_DATA
public static final int NET_PAM_DATAFlags 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
Some very basic commands to send straight through to receiving stations- Parameters:
unitName
-
-
-
Method Details
-
getNetworkReceiveProcess
public networkTransfer.receive.NetworkReceiver.NetworkReceiveProcess getNetworkReceiveProcess() -
getTabPanel
Description copied from class:PamControlledUnit
Gets a reference to a panel to be added to a view- Overrides:
getTabPanel
in classPamControlledUnit
- Returns:
- reference to a PamTabPanel object
- See Also:
-
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 classPamControlledUnit
- 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 classPamControlledUnit
- Parameters:
changeType
- type of change
-
createDetectionMenu
Description copied from class:PamControlledUnit
Create a JMenu object containing MenuItems associated with PamProcesses- Overrides:
createDetectionMenu
in classPamControlledUnit
- 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
- Returns:
- the buoyStatusDataBlock
-
detectionDialog
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
- Specified by:
socketClosed
in interfaceNetworkDataUser
-
interpretData
- Specified by:
interpretData
in interfaceNetworkDataUser
-
checkExistingThreads
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 stationsocket
- Socket data were read fromdataVersion2
- 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 1dataId2
- station id 2dataLen
- data lengthduBuffer
- data, including additional header information.- Returns:
-
getPamCommandString
-
findBuoyStatusDataUnit
Find buoy status data and optionally create it if it doesn't exist.- Parameters:
buoyId1
- buoy Id 1buoyId2
- buoy Id 2create
- automatically create- Returns:
- status data unit or null if not found.
-
findBuoyStatusDataUnit
Find a buoy status data unit from it's inet address.- Parameters:
address
-- Returns:
- status data unit.
-
checkAcousticBuoyStats
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
- Returns:
- the rxDataBlocks
-
getNetworkReceiveParams
- Returns:
- the networkReceiveParams
-
getSettingsReference
- Specified by:
getSettingsReference
in interfacePamSettings
- Returns:
- The serialisable object that will be stored
-
getSettingsVersion
public long getSettingsVersion()- Specified by:
getSettingsVersion
in interfacePamSettings
- Returns:
- An integer version number for the settings
-
restoreSettings
- Specified by:
restoreSettings
in interfacePamSettings
- 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 classPamControlledUnit
-
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 classPamControlledUnit
- Returns:
- true if OK for Pamguard to shut down, false otherwise.
-
getExtraTableInfo
-
addExtraTableInfo
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
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
-
getTableMouseListener
- Returns:
- the tableMouseListener
-
setTableMouseListener
- Parameters:
tableMouseListener
- the tableMouseListener to set
-
newReceivedDataUnit
- Specified by:
newReceivedDataUnit
in interfaceNetworkDataUser
-