com.kuka.roboticsAPI.controllerModel.sunrise
Class SunriseConnection

java.lang.Object
  extended by com.kuka.roboticsAPI.controllerModel.sunrise.SunriseConnection
All Implemented Interfaces:
IMessageHandler

public class SunriseConnection
extends Object
implements IMessageHandler

Holds a connection to a Sunrise controller.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

Field Summary
static String CURRENT_SUNRISE_VERSION
          Holds the current expected Sunrise version.
 
Constructor Summary
protected SunriseConnection(NameserverProxy nameserver, int keepAliveSendTimeout, int keepAliveReceiveTimeout)
          Creates a new connection to Sunrise.
 
Method Summary
protected  void cancelSPR(SPRRuntime spr)
          Cancels the specified SPR.
 void connectionLost()
          Called to indicate that the connection was lost.
protected  long createNewId(long type, long counter)
          Creates a new message id as mix of API id, type and counter.
protected  long createNewSPRId()
          Creates a new SPR id.
protected  long createNewSPRStackId()
          Creates a new SPR stack id.
 long createNewSSRId()
          Creates a new SSR id.
 void dispose()
          Disposes the connection to the remote system.
static void disposeAllSunriseConnections()
          Disposes all available sunrise connections.
 long getInstanceId()
          Gets the instance id which was assigned from the remote system.
protected  String getLocalSystemVersion()
          Gets the version of the local system.
protected  NameserverProxy getNameserver()
           
protected  String getRegisterChannelName()
          Gets the channel name that is used for the registration process.
 String getRemoteSystemVersion()
          Gets the version of the system to which this connection is connected.
static SunriseConnection getSunriseConnectionAndRegisterAsHandler(NameserverProxy nameserver, IMessageHandler handler, int keepAliveSendInterval, int keepAliveReceiveTimeout)
          Gets the sunrise connection for the specified nameserver.
static int getSunriseConnectionCount()
           
 void handleMessage(Message message)
          Handles the given message.
 boolean isConnected()
          Checks if the connection is active, which means that the receiver is still active.
static boolean isSPR(Message message)
          Determines if the given message contains a SPR.
static boolean isSSR(Message message)
          Determines if the given message contains a SSR.
 void removeHandler(IMessageHandler handler)
          Removes the specified message handler.
protected  void send(Message message)
          Sends a message over the outchannel.
protected  void sendSPR(SPR spr)
          Sends a SPR to Sunrise.
protected  void sendSSR(SSR ssr)
          Sends a SSR to Sunrise.
 String toString()
          
protected  void updateSPR(SPR spr)
          Updates the given SPR.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CURRENT_SUNRISE_VERSION

public static final String CURRENT_SUNRISE_VERSION
Holds the current expected Sunrise version.

See Also:
Constant Field Values
Constructor Detail

SunriseConnection

protected SunriseConnection(NameserverProxy nameserver,
                            int keepAliveSendTimeout,
                            int keepAliveReceiveTimeout)
Creates a new connection to Sunrise.

Parameters:
nameserver - The nameserver used for the connection.
keepAliveSendTimeout - timeout for Sunrise in which it must have received our KeepAlive signal, in milliseconds (0:disabled)
keepAliveReceiveTimeout - timeout for receiving keep-alive messages in milliseconds (0:disabled)
Method Detail

getSunriseConnectionAndRegisterAsHandler

public static SunriseConnection getSunriseConnectionAndRegisterAsHandler(NameserverProxy nameserver,
                                                                         IMessageHandler handler,
                                                                         int keepAliveSendInterval,
                                                                         int keepAliveReceiveTimeout)
Gets the sunrise connection for the specified nameserver.

If connection does not exists - creates it, otherwise - returns an existing connection. Registers the specified message handler for the returned connection.

Parameters:
nameserver - nameserver used to create the requested connection.
handler - message handler that should be registered for the returned connection
keepAliveSendInterval - interval for sending keep-alive messages in milliseconds (0:disabled, default 1000ms)
keepAliveReceiveTimeout - timeout for receiving keep-alive messages in milliseconds (0:disabled - default)
Returns:
the sunrise connection for the specified nameserver.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

disposeAllSunriseConnections

public static void disposeAllSunriseConnections()
Disposes all available sunrise connections.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

removeHandler

public void removeHandler(IMessageHandler handler)
Removes the specified message handler.

Parameters:
handler - the message handler to remove.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

isConnected

public boolean isConnected()
Checks if the connection is active, which means that the receiver is still active.

Returns:
True if the connection is connected.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getInstanceId

public long getInstanceId()
Gets the instance id which was assigned from the remote system.

Returns:
The instance id which was assigned from the remote system.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getRemoteSystemVersion

public String getRemoteSystemVersion()
Gets the version of the system to which this connection is connected.

Returns:
The version of the system to which this connection is connected.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

dispose

public void dispose()
Disposes the connection to the remote system.

Will not throw an exception.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

toString

public String toString()

Overrides:
toString in class Object
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getLocalSystemVersion

protected String getLocalSystemVersion()
Gets the version of the local system.

This version is sent down during the registration process and if the version does not fix the remote system version, the registration will fails.

Returns:
The version of the local system.

getRegisterChannelName

protected String getRegisterChannelName()
Gets the channel name that is used for the registration process.

Returns:
The channel name that is used for the registration process.

send

protected void send(Message message)
Sends a message over the outchannel.

Parameters:
message - The message.

createNewId

protected long createNewId(long type,
                           long counter)
Creates a new message id as mix of API id, type and counter.

Parameters:
type - The type if the message.
counter - The counter.
Returns:
The created id.

createNewSPRId

protected long createNewSPRId()
Creates a new SPR id.

Returns:
The new SPR id.

createNewSPRStackId

protected long createNewSPRStackId()
Creates a new SPR stack id.

Returns:
The new SPR stack id.

createNewSSRId

public long createNewSSRId()
Creates a new SSR id.

Returns:
The new SSR id.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

sendSSR

protected void sendSSR(SSR ssr)
Sends a SSR to Sunrise. The SSR has to have a valid id. Will not block the calling thread.

Parameters:
ssr - The SSR to be sent.

sendSPR

protected void sendSPR(SPR spr)
Sends a SPR to Sunrise. Will not block the calling thread.

Parameters:
spr - The SPR to be sent.

updateSPR

protected void updateSPR(SPR spr)
Updates the given SPR. Will not block the calling thread.

Parameters:
spr - The SPR to be updated. null is not allowed.

cancelSPR

protected void cancelSPR(SPRRuntime spr)
Cancels the specified SPR. Will not block the calling thread.

Parameters:
spr - The SPR to be cancelled. null is not allowed.

isSSR

public static boolean isSSR(Message message)
Determines if the given message contains a SSR. This is determined by the type id contained in the message id.

Parameters:
message - The message.
Returns:
True if the message contains an SSR.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

isSPR

public static boolean isSPR(Message message)
Determines if the given message contains a SPR. This is determined by the type id contained in the message id.

Parameters:
message - The message.
Returns:
True if the message contains an SPR.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getNameserver

protected NameserverProxy getNameserver()
Returns:
the nameserver

handleMessage

public void handleMessage(Message message)
Handles the given message.

Specified by:
handleMessage in interface IMessageHandler
Parameters:
message - The message to be handled. Will never be null.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

connectionLost

public void connectionLost()
Called to indicate that the connection was lost.

Specified by:
connectionLost in interface IMessageHandler
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getSunriseConnectionCount

public static int getSunriseConnectionCount()
Returns:
The number of sunrise connections currently open.


Copyright © 2019. All rights reserved.