advancedrelay.laygo
Class ProtocolService

java.lang.Object
  |
  +--advancedrelay.laygo.ProtocolService

public class ProtocolService
extends java.lang.Object

Encapsulation of a LayGO CID into a ProtocolService. This module wraps functionality related to LayGO CIDs into a Java object. Clients of this module may retreive the value of the CID for display purposes, but must not use it to directly call Laygo class functions.

Function names follow Java naming conventions. Most functions are straightforward encapsulations of standard LayGO API functions. However, functions return true on success, false on failure. Use getLastError() to retrieve the actual result code. Whenever binary data is passed to the service through parameters byte [] buffer and int size, the data is assumed to be in the first size bytes of the buffer. For complete documentation of each function, see the LayGO API Manual.


Constructor Summary
ProtocolService()
          Basic constructor for a protocol service.
ProtocolService(int cid)
          Constructs a protocol service from an open CID.
ProtocolService(int protocol, int major, int minor)
          Constructs a protocol service from protocol, major and minor device ids.
ProtocolService(java.lang.String service)
          Constructs a protocol service from a service name.
 
Method Summary
 boolean attach()
          Attach to the service previously detached.
 boolean attach(int protocol, int major, int minor)
          Attach to a service by protocol, major and minor device id.
 boolean attach(java.lang.String service)
          Attach to a service by name.
 boolean clearStatistics()
          Clear statistics for the protocol service.
 boolean close()
          Close an open protocol service.
 boolean connectAccept()
          Accept a connection without additional data.
 boolean connectAccept(byte[] buffer, int size)
          Accept a connection with additional data.
 boolean connectReject()
          Reject a connection without additional data.
 boolean connectReject(byte[] buffer, int size)
          Reject a connection with additional data.
 boolean connectRequest()
          Request a connection without additional data.
 boolean connectRequest(byte[] buffer, int size)
          Request a connection with additional data.
 boolean detach()
          Detach from the currently open service.
 boolean discardData()
          Discard the next queued data event.
 boolean disconnectConfirm()
          Confirm a disconnect without additional data.
 boolean disconnectConfirm(byte[] buffer, int size)
          Confirm a disconnect with additional data.
 boolean disconnectRequest()
          Request a disconnect without additional data.
 boolean disconnectRequest(byte[] buffer, int size)
          Request a disconnect with additional data.
 ProtocolEvent event()
          Read the next queued non-data event.
 int getCid()
          Returns the CID of the protocol service.
 byte[] getConfiguration()
          Read the configuration of the protocol service.
 int getLastError()
          Returns the last error code from the protocol service.
 java.lang.String getLastErrorMessage()
          Returns a string describing the last error from the protocol service.
 StatisticsTable getStatistics()
          Read the statistics table of the protocol service.
 StatusReport getStatus()
          Read the status of the protocol service.
 void invalidate()
          Special reconstructor for the LayGO Device Library.
 boolean ioctl(int function)
          Request an IO control function without input or output data.
 boolean ioctl(int function, byte[] bufferIn, int sizeIn)
          Request an IO control function with input data only.
 boolean ioctl(int function, byte[] bufferIn, int sizeIn, byte[] bufferOut, Result sizeOut)
          Request an IO control function with both input and output data.
 boolean ioctl(int function, byte[] bufferOut, Result sizeOut)
          Request an IO control function with output data only.
 boolean listen()
          Request a listen on the protocol service.
 boolean listenCancel()
          Cancel a listen request on the protocol service.
 boolean loadConfiguration(java.lang.String fileName)
          Load a configuration from a .cfg file into the protocol service.
 int maxBufferSize()
          Returns the maxmimum buffer size for data written to the protocol service.
 boolean open()
          Opens a protocol service previously opened and closed.
 boolean open(int cid)
          Opens a protocol service by previously opened CID.
 boolean open(int protocol, int major)
          Opens a protocol service by protocol and major device id.
 boolean open(int protocol, int major, int minor)
          Opens a protocol service by protocol, major and minor device id.
 boolean open(java.lang.String service)
          Opens a protocol service by name.
 ProtocolEvent poll()
          Polls the next queued event, but does not dequeue it.
 boolean pop()
          Pops the protocol service from the top of the stack.
 int protocol()
          Return the protocol of the service.
 boolean push(ProtocolService stackTop)
          Pushes the protocol service onto the top of the stack.
 DataEvent read()
          Reads the next data event queued for the protocol service.
 DataEvent readSpecial()
          Reads the next data event with flags queued for the protocol service.
 boolean reopen()
          Reopens the protocol service.
 boolean resetRequest()
          Request a reset without additional data.
 boolean resetRequest(byte[] buffer, int size)
          Request a reset with additional data.
 boolean setConfiguration(byte[] buffer, int size)
          Set the configuration of the protocol service.
 int state()
          Returns the state of the protocol service.
 java.lang.String toString()
          Returns a string describing the protocol service.
 boolean write(byte[] buffer, int size)
          Writes data through the protocol service.
 boolean writeSpecial(byte[] buffer, int size, int flags)
          Writes data with flags through the protocol service.
 boolean xoff()
          Requests a protocol xoff.
 boolean xon()
          Requests a protocol xon.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProtocolService

public ProtocolService()
Basic constructor for a protocol service.


ProtocolService

public ProtocolService(int cid)
Constructs a protocol service from an open CID.

Parameters:
cid - The open CID

ProtocolService

public ProtocolService(int protocol,
                       int major,
                       int minor)
Constructs a protocol service from protocol, major and minor device ids.

Parameters:
protocol - The protocol to open
major - The major device id
minor - The minor device id

ProtocolService

public ProtocolService(java.lang.String service)
Constructs a protocol service from a service name.

Parameters:
service - Service name in the service database.
Method Detail

attach

public boolean attach()
Attach to the service previously detached.


attach

public boolean attach(int protocol,
                      int major,
                      int minor)
Attach to a service by protocol, major and minor device id.

Parameters:
protocol - The protocol to open
major - The major device id
minor - The minor device id

attach

public boolean attach(java.lang.String service)
Attach to a service by name.

Parameters:
service - Service name in the service database.

clearStatistics

public boolean clearStatistics()
Clear statistics for the protocol service.


close

public boolean close()
Close an open protocol service.


connectAccept

public boolean connectAccept()
Accept a connection without additional data.


connectAccept

public boolean connectAccept(byte[] buffer,
                             int size)
Accept a connection with additional data.

Parameters:
buffer - additional data
size - number of bytes of additional data

connectReject

public boolean connectReject()
Reject a connection without additional data.


connectReject

public boolean connectReject(byte[] buffer,
                             int size)
Reject a connection with additional data.


connectRequest

public boolean connectRequest()
Request a connection without additional data.


connectRequest

public boolean connectRequest(byte[] buffer,
                              int size)
Request a connection with additional data.

Parameters:
buffer - additional data
size - number of bytes of additional data

detach

public boolean detach()
Detach from the currently open service.


discardData

public boolean discardData()
Discard the next queued data event.


disconnectConfirm

public boolean disconnectConfirm()
Confirm a disconnect without additional data.


disconnectConfirm

public boolean disconnectConfirm(byte[] buffer,
                                 int size)
Confirm a disconnect with additional data.

Parameters:
buffer - additional data
size - number of bytes of additional data

disconnectRequest

public boolean disconnectRequest()
Request a disconnect without additional data.


disconnectRequest

public boolean disconnectRequest(byte[] buffer,
                                 int size)
Request a disconnect with additional data.

Parameters:
buffer - additional data
size - number of bytes of additional data

event

public ProtocolEvent event()
Read the next queued non-data event.


getCid

public int getCid()
Returns the CID of the protocol service.


getConfiguration

public byte[] getConfiguration()
Read the configuration of the protocol service.


getLastError

public int getLastError()
Returns the last error code from the protocol service.


getLastErrorMessage

public java.lang.String getLastErrorMessage()
Returns a string describing the last error from the protocol service.


getStatistics

public StatisticsTable getStatistics()
Read the statistics table of the protocol service.


getStatus

public StatusReport getStatus()
Read the status of the protocol service.


invalidate

public void invalidate()
Special reconstructor for the LayGO Device Library.


ioctl

public boolean ioctl(int function)
Request an IO control function without input or output data.

Parameters:
function - IO control function id

ioctl

public boolean ioctl(int function,
                     byte[] bufferIn,
                     int sizeIn)
Request an IO control function with input data only.

Parameters:
function - IO control function id
bufferIn - input data
sizeIn - number of bytes of input data

ioctl

public boolean ioctl(int function,
                     byte[] bufferIn,
                     int sizeIn,
                     byte[] bufferOut,
                     Result sizeOut)
Request an IO control function with both input and output data.

Parameters:
function - IO control function id
bufferIn - input data
sizeIn - number of bytes of input data
bufferOut - output data buffer
sizeOut - number of bytes of output data

ioctl

public boolean ioctl(int function,
                     byte[] bufferOut,
                     Result sizeOut)
Request an IO control function with output data only.

Parameters:
function - IO control function id
bufferOut - output data buffer
sizeOut - number of bytes of output data

listen

public boolean listen()
Request a listen on the protocol service.


listenCancel

public boolean listenCancel()
Cancel a listen request on the protocol service.


loadConfiguration

public boolean loadConfiguration(java.lang.String fileName)
Load a configuration from a .cfg file into the protocol service.

Parameters:
fileName - Name of .cfg file

maxBufferSize

public int maxBufferSize()
Returns the maxmimum buffer size for data written to the protocol service.


open

public boolean open()
Opens a protocol service previously opened and closed.


open

public boolean open(int cid)
Opens a protocol service by previously opened CID.

Parameters:
cid - The open CID

open

public boolean open(int protocol,
                    int major)
Opens a protocol service by protocol and major device id.

Parameters:
protocol - The protocol to open
major - The major device id

open

public boolean open(int protocol,
                    int major,
                    int minor)
Opens a protocol service by protocol, major and minor device id.

Parameters:
protocol - The protocol to open
major - The major device id
minor - The minor device id

open

public boolean open(java.lang.String service)
Opens a protocol service by name.

Parameters:
service - Service name in the service database.

poll

public ProtocolEvent poll()
Polls the next queued event, but does not dequeue it.


pop

public boolean pop()
Pops the protocol service from the top of the stack.


protocol

public int protocol()
Return the protocol of the service.


push

public boolean push(ProtocolService stackTop)
Pushes the protocol service onto the top of the stack.

Parameters:
stackTop - service which is currently on top of the stack

read

public DataEvent read()
               throws ProtocolEventException
Reads the next data event queued for the protocol service.

Throws:
ProtocolEventException - The next queued event if not data.

readSpecial

public DataEvent readSpecial()
                      throws ProtocolEventException
Reads the next data event with flags queued for the protocol service.

Throws:
ProtocolEventException - The next queued event if not data.

reopen

public boolean reopen()
Reopens the protocol service.


resetRequest

public boolean resetRequest()
Request a reset without additional data.


resetRequest

public boolean resetRequest(byte[] buffer,
                            int size)
Request a reset with additional data.

Parameters:
buffer - additional data
size - number of bytes of additional data

setConfiguration

public boolean setConfiguration(byte[] buffer,
                                int size)
Set the configuration of the protocol service.

Parameters:
buffer - configuration data
size - number of bytes of configuration data

state

public int state()
Returns the state of the protocol service.


toString

public java.lang.String toString()
Returns a string describing the protocol service.

Overrides:
toString in class java.lang.Object

write

public boolean write(byte[] buffer,
                     int size)
Writes data through the protocol service.

Parameters:
buffer - data to write
size - number of bytes of data

writeSpecial

public boolean writeSpecial(byte[] buffer,
                            int size,
                            int flags)
Writes data with flags through the protocol service.

Parameters:
buffer - data to write
size - number of bytes of data
flags - flags to send with data

xoff

public boolean xoff()
Requests a protocol xoff.


xon

public boolean xon()
Requests a protocol xon.