PamController
Class NetworkController

java.lang.Object
  extended by PamController.NetworkController

public class NetworkController
extends java.lang.Object


Nested Class Summary
(package private)  class NetworkController.ListenerThread
           
private  class NetworkController.NetworkRecorderTrigger
           
 
Field Summary
private  byte[] byteBuffer
           
private  boolean initialisationComplete
           
private  NetworkController.ListenerThread listenerThread
           
private static int MAX_COMMAND_LENGTH
           
private  PamController pamController
           
private  java.net.DatagramSocket receiveSocket
           
private  NetworkController.NetworkRecorderTrigger[] recorderTriggers
           
private  java.net.DatagramPacket udpPacket
           
 
Constructor Summary
NetworkController(PamController pamController)
           
 
Method Summary
 void closeUDPPort()
          Close the UDP port.
private  void createRecorderTriggers()
           
private  NetworkController.NetworkRecorderTrigger findTrigger(java.lang.String name)
           
private  java.lang.String getCommand()
          Blocking function to wait for a command string to be sent over UDP
private  boolean interpretCommand(java.lang.String command)
          Interpret and act on a udp command string.
 void notifyModelChanged(int changeType)
           
 boolean openUDPPort()
          Open the UDP port.
private  boolean sendData(java.lang.String dataString)
           
 void sitInLoop()
          Infinite loop.
private  boolean triggerRecording(java.lang.String name, int seconds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pamController

private PamController pamController

listenerThread

private NetworkController.ListenerThread listenerThread

receiveSocket

private java.net.DatagramSocket receiveSocket

udpPacket

private java.net.DatagramPacket udpPacket

initialisationComplete

private boolean initialisationComplete

MAX_COMMAND_LENGTH

private static final int MAX_COMMAND_LENGTH
See Also:
Constant Field Values

byteBuffer

private byte[] byteBuffer

recorderTriggers

private NetworkController.NetworkRecorderTrigger[] recorderTriggers
Constructor Detail

NetworkController

public NetworkController(PamController pamController)
Method Detail

openUDPPort

public boolean openUDPPort()
Open the UDP port.

Returns:
true if opened OK

closeUDPPort

public void closeUDPPort()
Close the UDP port.


sitInLoop

public void sitInLoop()
Infinite loop. The program sits here waiting for commands and interpreting them as needs.
It will exit when InterpretCommand returns false, which it should only do when the exit program command has been sent.


interpretCommand

private boolean interpretCommand(java.lang.String command)
Interpret and act on a udp command string.

Parameters:
command - command string
Returns:
false if the command was to exit the program (in which case this thread will exit and close the port). True otherwise.

sendData

private boolean sendData(java.lang.String dataString)

getCommand

private java.lang.String getCommand()
Blocking function to wait for a command string to be sent over UDP

Returns:
command string or null if should exit.

notifyModelChanged

public void notifyModelChanged(int changeType)

createRecorderTriggers

private void createRecorderTriggers()

triggerRecording

private boolean triggerRecording(java.lang.String name,
                                 int seconds)

findTrigger

private NetworkController.NetworkRecorderTrigger findTrigger(java.lang.String name)