com.sentilla.host.client.admin
Class ServerAdminClientImpl

java.lang.Object
  extended by com.sentilla.host.client.admin.ServerAdminClientImpl
All Implemented Interfaces:
ServerAdminService

public class ServerAdminClientImpl
extends Object
implements ServerAdminService

ServerAdminService client side implementation using the mote protocol.

Author:
spence@sentilla.com

Field Summary
private  HostClientService client
           
 
Constructor Summary
ServerAdminClientImpl(HostClientService client)
           
 
Method Summary
 void connectGateway(String communicationPort)
          Connects to the gateway previously set via setGateway call.
 void disconnectGateway()
          Disconnects from gateway.
 byte[] getClassBytes(String name)
          Get a class definition from the server.
 GatewayNode getConnectedGateway()
          Returns the gateway communication port currently used by the host server.
 int getDebug()
          Queries the host server about the current debug level.
 String getDefaultBasestationComPort()
          Returns the default COM port of the gateway associated with this host.
 Collection<NetworkNode> getNetwork()
          Returns of NetworkNode objects reflecting the current motes present in the network connected via the current basestation.
 Object getProperty(String name)
          Get a property from the host server.
 Application getSystemBinary()
          Get the yaml data for the system binary.
 boolean isGatewayConnected()
          Returns the connected state of gateway
 Collection<GatewayNode> listComBaseStations()
          Lists the serial COM ports with BaseStations connected.
 Collection<String> listComPorts()
          Lists the serial COM ports available to be used/set.
private  ServerAdminMessage processMessage(HostMessage msg)
           
 void restartServer()
          Re-starts the server.
 void setDebug(int level)
          Directs the host server to use the given level of debugging.
 boolean setProperty(String name, Object value)
          Set a property with the host server.
 void startServer()
          Starts the server.
 void stopServer()
          Stop the server, except for the listener service so that the client can follow up by "startServer" invocation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

private HostClientService client
Constructor Detail

ServerAdminClientImpl

public ServerAdminClientImpl(HostClientService client)
Method Detail

processMessage

private ServerAdminMessage processMessage(HostMessage msg)
                                   throws ServiceException
Throws:
ServiceException

connectGateway

public void connectGateway(String communicationPort)
                    throws ServiceException
Description copied from interface: ServerAdminService
Connects to the gateway previously set via setGateway call.

Specified by:
connectGateway in interface ServerAdminService
Parameters:
communicationPort - communication port using SF (serial forwarder) syntax such as:
  • serial@COM8:tmote
  • sf@localhost:9002
  • sf@tmote-connect:9002
Throws:
ServiceException - if a transport or service related error occured or if gateway is already connected.

disconnectGateway

public void disconnectGateway()
                       throws ServiceException
Description copied from interface: ServerAdminService
Disconnects from gateway. If gateway is already disconnected, no action is take and no exception is thrown.

Specified by:
disconnectGateway in interface ServerAdminService
Throws:
ServiceException - if a transport or service related error occured

setDebug

public void setDebug(int level)
              throws ServiceException
Description copied from interface: ServerAdminService
Directs the host server to use the given level of debugging. Levels roughly correspond to log4j logging levels.

Specified by:
setDebug in interface ServerAdminService
Parameters:
level - to set debug to
Throws:
ServiceException - if a transport or service related error occured

getDebug

public int getDebug()
             throws ServiceException
Description copied from interface: ServerAdminService
Queries the host server about the current debug level.

Specified by:
getDebug in interface ServerAdminService
Returns:
true if debug is on, false otherwise.
Throws:
ServiceException

getDefaultBasestationComPort

public String getDefaultBasestationComPort()
                                    throws ServiceException,
                                           IOException
Description copied from interface: ServerAdminService
Returns the default COM port of the gateway associated with this host. This is typically the COM port the gateway thinks the basestation is associated with. It is useful in situations where several tmote devices are connected to a computer's COM ports.

Specified by:
getDefaultBasestationComPort in interface ServerAdminService
Returns:
the default basestation COM port.
Throws:
ServiceException
IOException

isGatewayConnected

public boolean isGatewayConnected()
                           throws ServiceException
Description copied from interface: ServerAdminService
Returns the connected state of gateway

Specified by:
isGatewayConnected in interface ServerAdminService
Returns:
true if connected, false otherwise.
Throws:
ServiceException - if a transport or service related error occured

listComPorts

public Collection<String> listComPorts()
                                throws ServiceException
Description copied from interface: ServerAdminService
Lists the serial COM ports available to be used/set. Note: This call doesn't list TCP/IP-based communication ports.

Specified by:
listComPorts in interface ServerAdminService
Returns:
COM ports found on the gateway associated with hist host server.
Throws:
ServiceException - if a transport or service related error occured

getConnectedGateway

public GatewayNode getConnectedGateway()
                                throws ServiceException
Description copied from interface: ServerAdminService
Returns the gateway communication port currently used by the host server. This can be either a serial port such as serial@COM8:tmote or a remote TCP/IP port such as sf@tmote-connect:9002 or sf@localhost:9002

Specified by:
getConnectedGateway in interface ServerAdminService
Returns:
current gateway communication port host server is connected to
Throws:
ServiceException - if a transport or service related error occured or if gateway is not connected

restartServer

public void restartServer()
                   throws ServiceException
Description copied from interface: ServerAdminService
Re-starts the server. Semantics of restart are identical to the sequence of start/stop server.

Specified by:
restartServer in interface ServerAdminService
Throws:
ServiceException

startServer

public void startServer()
                 throws ServiceException
Description copied from interface: ServerAdminService
Starts the server. All threads on the server will start their operation. The server will attempt to connect the gateway if it was previously defined via a 'connectGateway(communicationPort)' call. Otherwise it will started in disconnected state. If the server can't connect, it will still continue other operation in disconnecte state.

Specified by:
startServer in interface ServerAdminService
Throws:
ServiceException - if a transport or service related error occured

stopServer

public void stopServer()
                throws ServiceException
Description copied from interface: ServerAdminService
Stop the server, except for the listener service so that the client can follow up by "startServer" invocation.

Specified by:
stopServer in interface ServerAdminService
Throws:
ServiceException - if a transport or service related error occured or if service is already stopped.

getNetwork

public Collection<NetworkNode> getNetwork()
                                   throws IOException
Description copied from interface: ServerAdminService
Returns of NetworkNode objects reflecting the current motes present in the network connected via the current basestation.

Specified by:
getNetwork in interface ServerAdminService
Returns:
Collection the set of nodes currently present in the network
Throws:
IOException

setProperty

public boolean setProperty(String name,
                           Object value)
Description copied from interface: ServerAdminService
Set a property with the host server.

Specified by:
setProperty in interface ServerAdminService
Parameters:
name - a String property key
value - an Object to associate with the given key
Returns:
boolean returns true if the property is successfully set, false otherwise

getProperty

public Object getProperty(String name)
Description copied from interface: ServerAdminService
Get a property from the host server.

Specified by:
getProperty in interface ServerAdminService
Parameters:
name - the key of the property value to return.
Returns:
Object the Object associated with the given key

getSystemBinary

public Application getSystemBinary()
Description copied from interface: ServerAdminService
Get the yaml data for the system binary.

Specified by:
getSystemBinary in interface ServerAdminService
Returns:
Application metadata data for the system binary.

listComBaseStations

public Collection<GatewayNode> listComBaseStations()
                                            throws ServiceException
Description copied from interface: ServerAdminService
Lists the serial COM ports with BaseStations connected. Note: This call doesn't list TCP/IP-based communication ports.

Specified by:
listComBaseStations in interface ServerAdminService
Returns:
COM ports found on the gateway associated with hist host server.
Throws:
ServiceException - if a transport or service related error occured

getClassBytes

public byte[] getClassBytes(String name)
Description copied from interface: ServerAdminService
Get a class definition from the server.

Specified by:
getClassBytes in interface ServerAdminService
Returns:
byte[] the bytes of a class definition.


Copyright © 2007 Sentilla, Inc. All Rights Reserved.