|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jaer.eventio.AEUnicastOutput
public class AEUnicastOutput
Streams AE packets to network using UDP DatagramPacket's that are unicast. AEViewers can receive these packets to render them.
The implementation using a BlockingQueue to buffer the AEPacketRaw's that are offered. The packets are sent by a separate Consumer thread. The consumer has a queue length that determines how many packets can be buffered before the writePacket method blocks.
The datagram socket is not connect'ed to the receiver.
Field Summary | |
---|---|
protected java.nio.channels.DatagramChannel |
channel
|
protected java.net.DatagramSocket |
socket
|
Constructor Summary | |
---|---|
AEUnicastOutput()
Creates a new instance, binding any available local port (since we will be just sending from here). |
|
AEUnicastOutput(java.lang.String host,
int port)
Creates a new instance, binding any available local port (since we will be just sending from here) and using the last host and port. |
Method Summary | |
---|---|
void |
close()
|
java.lang.String |
getHost()
|
int |
getPort()
|
float |
getTimestampMultiplier()
|
boolean |
is4ByteAddrTimestampEnabled()
|
boolean |
isAddressFirstEnabled()
|
boolean |
isSequenceNumberEnabled()
|
boolean |
isSwapBytesEnabled()
|
void |
set4ByteAddrTimestampEnabled(boolean yes)
Sets whether to use 4 byte address and 4 byte timestamp or 2 byte address and 2 byte timestamp. |
void |
setAddressFirstEnabled(boolean addressFirstEnabled)
If set true, the first int32 of each AE is the address, and the second is the timestamp. |
void |
setHost(java.lang.String host)
You need to setHost before this will send events. |
void |
setPort(int port)
You set the port to say which port the packet will be sent to. |
void |
setSequenceNumberEnabled(boolean sequenceNumberEnabled)
If set true (default), then an int32 sequence number is the first word of the packet. |
void |
setSwapBytesEnabled(boolean yes)
Java is little endian (in linear memory, LSB comes first, at lower address) and intel procesors are big endian. |
void |
setTimestampMultiplier(float timestampMultiplier)
Sets the mutliplier of jAER timestamps/remote host timestamps. |
java.lang.String |
toString()
|
void |
writePacket(AEPacketRaw ae)
Writes the packet out as sequence of address/timestamp's, just as they came as input from the device. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.nio.channels.DatagramChannel channel
protected java.net.DatagramSocket socket
Constructor Detail |
---|
public AEUnicastOutput(java.lang.String host, int port)
host
- the hostname to send toport
- the port to send tosetHost(java.lang.String)
,
setPort(int)
public AEUnicastOutput()
setHost(java.lang.String)
,
setPort(int)
Method Detail |
---|
public void writePacket(AEPacketRaw ae) throws java.io.IOException
The notion of a packet is discarded to simplify later reading an input stream from the output stream result. The AEPacketRaw is written in chunks of AESocketStream.SOCKET_BUFFER_SIZE bytes (which must be a multiple of AESocketStream.EVENT_SIZE_BYTES). Each DatagramPacket has a sequence number as the first Integer value which is used on the reciever to detect dropped packets.
If an empty packet is supplied as ae, then a packet is still written but it contains only a sequence number.
This method actually offers new Datagram packets to the consumer thread for later tranmission. The datagram address and port are taken from the current settings for the AEUnicastOutput.
ae
- a raw addresse-event packet
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public void close()
public java.lang.String getHost()
getHost
in interface AEUnicastSettings
public void setHost(java.lang.String host)
setHost
in interface AEUnicastSettings
host
- the hostnamepublic int getPort()
getPort
in interface AEUnicastSettings
public void setPort(int port)
setPort
in interface AEUnicastSettings
port
- the UDP port number.public boolean isSequenceNumberEnabled()
isSequenceNumberEnabled
in interface AEUnicastSettings
public void setSequenceNumberEnabled(boolean sequenceNumberEnabled)
setSequenceNumberEnabled
in interface AEUnicastSettings
sequenceNumberEnabled
- default truepublic boolean isAddressFirstEnabled()
isAddressFirstEnabled
in interface AEUnicastSettings
setAddressFirstEnabled(boolean)
public void setAddressFirstEnabled(boolean addressFirstEnabled)
setAddressFirstEnabled
in interface AEUnicastSettings
addressFirstEnabled
- default true.public void setSwapBytesEnabled(boolean yes)
setSwapBytesEnabled
in interface AEUnicastSettings
public boolean isSwapBytesEnabled()
isSwapBytesEnabled
in interface AEUnicastSettings
public float getTimestampMultiplier()
getTimestampMultiplier
in interface AEUnicastSettings
AEUnicastSettings.setTimestampMultiplier(float)
public void setTimestampMultiplier(float timestampMultiplier)
setTimestampMultiplier
in interface AEUnicastSettings
timestampMultiplier
- public void set4ByteAddrTimestampEnabled(boolean yes)
AEUnicastSettings
set4ByteAddrTimestampEnabled
in interface AEUnicastSettings
public boolean is4ByteAddrTimestampEnabled()
is4ByteAddrTimestampEnabled
in interface AEUnicastSettings
|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |