org.openmuc.jsml.tl
Class SML_TConnection

java.lang.Object
  extended by org.openmuc.jsml.tl.SML_TConnection

public class SML_TConnection
extends java.lang.Object


Constructor Summary
SML_TConnection(java.net.Socket socket, int messageTimeout, int messageFragmentTimeout)
           
 
Method Summary
 void close()
           
static int crc16(byte[] bytes)
          calculates crc16 as specified by DIN EN 62056-46
static int crc16(byte[] bytes, int length)
          calculates crc16 from element 0 to length-1 as specified by DIN EN 62056-46
 void disconnect()
           
 SML_File receive()
           
 void send(byte[] smlPackage)
           
 void sendAttentionResponse(OctetString attentionType, java.lang.String message, OctetString serverID, SML_Message faultyMessage, java.net.Socket socket)
          sends an SML_AttentionRes with sock
 void setMessageFragmentTimeout(int messageFragmentTimeout)
          Set the TConnection timeout for receiving data once the beginning of a message has been received.
 void setMessageTimeout(int messageTimeout)
          Set the TConnection timeout for waiting for the first byte of a new message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SML_TConnection

public SML_TConnection(java.net.Socket socket,
                       int messageTimeout,
                       int messageFragmentTimeout)
                throws java.io.IOException
Throws:
java.io.IOException
Method Detail

crc16

public static int crc16(byte[] bytes)
calculates crc16 as specified by DIN EN 62056-46

Parameters:
bytes -
Returns:
crc16 value

crc16

public static int crc16(byte[] bytes,
                        int length)
calculates crc16 from element 0 to length-1 as specified by DIN EN 62056-46

Parameters:
bytes -
length - bytes in array to take for calculation
Returns:
crc16 value

send

public void send(byte[] smlPackage)
          throws java.io.IOException
Throws:
java.io.IOException

sendAttentionResponse

public void sendAttentionResponse(OctetString attentionType,
                                  java.lang.String message,
                                  OctetString serverID,
                                  SML_Message faultyMessage,
                                  java.net.Socket socket)
sends an SML_AttentionRes with sock

Parameters:
attentionType - see SML_AttentionRes
message - OPTIONAL human readable message
serverID - id of this machine
faultyMessage - the SML_Message which caused this attentionResponse
socket - socket from which the faulty message was received, to answer on the same

receive

public SML_File receive()
                 throws java.io.IOException
Throws:
java.io.IOException

disconnect

public void disconnect()

setMessageTimeout

public void setMessageTimeout(int messageTimeout)
                       throws java.net.SocketException
Set the TConnection timeout for waiting for the first byte of a new message. Default is 0 (unlimited)

Parameters:
messageTimeout - in milliseconds
Throws:
java.net.SocketException

setMessageFragmentTimeout

public void setMessageFragmentTimeout(int messageFragmentTimeout)
                               throws java.net.SocketException
Set the TConnection timeout for receiving data once the beginning of a message has been received. Default is 2000 (2seconds)

Parameters:
messageFragmentTimeout - in milliseconds
Throws:
java.net.SocketException

close

public void close()


Copyright © 2011. All Rights Reserved.