public class Connection
extends java.lang.Object
ClientSap
or passed to ServerSapListener
. Once it has been closed it cannot be opened again. A newly created connection
has successfully build up a TCP/IP connection to the server. Before receiving ASDUs or sending commands one has to
call startDataTransfer(ConnectionEventListener, int)
or
waitForStartDT(ConnectionEventListener, int)
. Afterwards incoming ASDUs are forwarded to the
ConnectionEventListener
. Incoming ASDUs are queued so that ConnectionEventListener.newASdu(ASdu)
is
never called simultaneously for the same connection. Note that the ASduListener is not notified of incoming
confirmation messages (CONs).
Connection offers a method for every possible command defined by IEC 60870 (e.g. singleCommand). Every command
function may throw an IOException indicating a fatal connection error. In this case the connection will be
automatically closed and a new connection will have to be built up.Modifier and Type | Method and Description |
---|---|
void |
ackFileOrSection(int commonAddress,
int informationObjectAddress,
IeNameOfFile nameOfFile,
IeNameOfSection nameOfSection,
IeAckFileOrSectionQualifier qualifier) |
void |
bitStringCommand(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeBinaryStateInformation binaryStateInformation)
Sends a bitstring of 32 bit (C_BO_NA_1, TI: 51).
|
void |
bitStringCommandWithTimeTag(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeBinaryStateInformation binaryStateInformation,
IeTime56 timeTag)
Sends a bitstring of 32 bit with time tag CP56Time2a (C_BO_TA_1, TI: 64).
|
void |
callOrSelectFiles(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeNameOfFile nameOfFile,
IeNameOfSection nameOfSection,
IeSelectAndCallQualifier qualifier) |
void |
close()
Will close the TCP connection to the server if its still open and free any resources of this connection.
|
void |
counterInterrogation(int commonAddress,
CauseOfTransmission cot,
IeQualifierOfCounterInterrogation qualifier)
Sends a counter interrogation command (C_CI_NA_1, TI: 101).
|
void |
delayAcquisitionCommand(int commonAddress,
CauseOfTransmission cot,
IeTime16 time)
Sends a delay acquisition command (C_CD_NA_1, TI: 106).
|
void |
doubleCommand(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeDoubleCommand doubleCommand)
Sends a double command (C_DC_NA_1, TI: 46).
|
void |
doubleCommandWithTimeTag(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeDoubleCommand doubleCommand,
IeTime56 timeTag)
Sends a double command with time tag CP56Time2a (C_DC_TA_1, TI: 59).
|
void |
fileReady(int commonAddress,
int informationObjectAddress,
IeNameOfFile nameOfFile,
IeLengthOfFileOrSection lengthOfFile,
IeFileReadyQualifier qualifier) |
int |
getNumUnconfirmedIPdusSent() |
int |
getOriginatorAddress()
Get the configured Originator Address.
|
void |
interrogation(int commonAddress,
CauseOfTransmission cot,
IeQualifierOfInterrogation qualifier)
Sends an interrogation command (C_IC_NA_1, TI: 100).
|
void |
lastSectionOrSegment(int commonAddress,
int informationObjectAddress,
IeNameOfFile nameOfFile,
IeNameOfSection nameOfSection,
IeLastSectionOrSegmentQualifier qualifier,
IeChecksum checksum) |
void |
parameterActivation(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeQualifierOfParameterActivation qualifier)
Sends a parameter activation (P_AC_NA_1, TI: 113).
|
void |
parameterNormalizedValueCommand(int commonAddress,
int informationObjectAddress,
IeNormalizedValue normalizedValue,
IeQualifierOfParameterOfMeasuredValues qualifier)
Sends a parameter of measured values, normalized value (P_ME_NA_1, TI: 110).
|
void |
parameterScaledValueCommand(int commonAddress,
int informationObjectAddress,
IeScaledValue scaledValue,
IeQualifierOfParameterOfMeasuredValues qualifier)
Sends a parameter of measured values, scaled value (P_ME_NB_1, TI: 111).
|
void |
parameterShortFloatCommand(int commonAddress,
int informationObjectAddress,
IeShortFloat shortFloat,
IeQualifierOfParameterOfMeasuredValues qualifier)
Sends a parameter of measured values, short floating point number (P_ME_NC_1, TI: 112).
|
void |
queryLog(int commonAddress,
int informationObjectAddress,
IeNameOfFile nameOfFile,
IeTime56 rangeStartTime,
IeTime56 rangeEndTime) |
void |
readCommand(int commonAddress,
int informationObjectAddress)
Sends a read command (C_RD_NA_1, TI: 102).
|
void |
regulatingStepCommand(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeRegulatingStepCommand regulatingStepCommand)
Sends a regulating step command (C_RC_NA_1, TI: 47).
|
void |
regulatingStepCommandWithTimeTag(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeRegulatingStepCommand regulatingStepCommand,
IeTime56 timeTag)
Sends a regulating step command with time tag CP56Time2a (C_RC_TA_1, TI: 60).
|
void |
resetProcessCommand(int commonAddress,
IeQualifierOfResetProcessCommand qualifier)
Sends a reset process command (C_RP_NA_1, TI: 105).
|
void |
sectionReady(int commonAddress,
int informationObjectAddress,
IeNameOfFile nameOfFile,
IeNameOfSection nameOfSection,
IeLengthOfFileOrSection lengthOfSection,
IeSectionReadyQualifier qualifier) |
void |
send(ASdu aSdu) |
void |
sendConfirmation(ASdu aSdu) |
void |
sendDirectory(int commonAddress,
int informationObjectAddress,
InformationElement[][] directory) |
void |
sendSegment(int commonAddress,
int informationObjectAddress,
IeNameOfFile nameOfFile,
IeNameOfSection nameOfSection,
IeFileSegment segment) |
void |
setNormalizedValueCommand(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeNormalizedValue normalizedValue,
IeQualifierOfSetPointCommand qualifier)
Sends a set-point command, normalized value (C_SE_NA_1, TI: 48).
|
void |
setNormalizedValueCommandWithTimeTag(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeNormalizedValue normalizedValue,
IeQualifierOfSetPointCommand qualifier,
IeTime56 timeTag)
Sends a set-point command with time tag CP56Time2a, normalized value (C_SE_TA_1, TI: 61).
|
void |
setOriginatorAddress(int originatorAddress)
Set the Originator Address.
|
void |
setScaledValueCommand(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeScaledValue scaledValue,
IeQualifierOfSetPointCommand qualifier)
Sends a set-point command, scaled value (C_SE_NB_1, TI: 49).
|
void |
setScaledValueCommandWithTimeTag(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeScaledValue scaledValue,
IeQualifierOfSetPointCommand qualifier,
IeTime56 timeTag)
Sends a set-point command with time tag CP56Time2a, scaled value (C_SE_TB_1, TI: 62).
|
void |
setShortFloatCommand(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeShortFloat shortFloat,
IeQualifierOfSetPointCommand qualifier)
Sends a set-point command, short floating point number (C_SE_NC_1, TI: 50).
|
void |
setShortFloatCommandWithTimeTag(int commonAddress,
CauseOfTransmission cot,
int informationObjectAddress,
IeShortFloat shortFloat,
IeQualifierOfSetPointCommand qualifier,
IeTime56 timeTag)
Sends a set-point command with time tag CP56Time2a, short floating point number (C_SE_TC_1, TI: 63).
|
void |
singleCommand(int commonAddress,
int informationObjectAddress,
IeSingleCommand singleCommand)
Sends a single command (C_SC_NA_1, TI: 45).
|
void |
singleCommandWithTimeTag(int commonAddress,
int informationObjectAddress,
IeSingleCommand singleCommand,
IeTime56 timeTag)
Sends a single command with time tag CP56Time2a (C_SC_TA_1, TI: 58).
|
void |
startDataTransfer(ConnectionEventListener listener,
int timeout)
Starts a connection.
|
void |
synchronizeClocks(int commonAddress,
IeTime56 time)
Sends a clock synchronization command (C_CS_NA_1, TI: 103).
|
void |
testCommand(int commonAddress)
Sends a test command (C_TS_NA_1, TI: 104).
|
void |
testCommandWithTimeTag(int commonAddress,
IeTestSequenceCounter testSequenceCounter,
IeTime56 time)
Sends a test command with time tag CP56Time2a (C_TS_TA_1, TI: 107).
|
void |
waitForStartDT(ConnectionEventListener listener,
int timeout)
Waits for incoming STARTDT ACT message and response with a STARTDT CON message.
|
public void startDataTransfer(ConnectionEventListener listener, int timeout) throws java.io.IOException, java.util.concurrent.TimeoutException
listener
- the listener that is notified of incoming ASDUstimeout
- the maximum time in ms to wait for a STARDT CON message after sending the STARTDT ACT message. If set
to zero, timeout is disabled.java.io.IOException
- if any kind of IOException occursjava.util.concurrent.TimeoutException
- if the configured response timeout runs outpublic void waitForStartDT(ConnectionEventListener listener, int timeout) throws java.io.IOException, java.util.concurrent.TimeoutException
listener
- the listener that is to be notified of incoming ASDUs and disconnect eventstimeout
- the maximum time in ms to wait for STARTDT ACT message before throwing a TimeoutException. If set to
zero, timeout is disabled.java.io.IOException
- if a fatal communication error occurredjava.util.concurrent.TimeoutException
- if the given timeout runs out before the STARTDT ACT message is received.public void setOriginatorAddress(int originatorAddress)
originatorAddress
- the Originator Address. Valid values are 0...255.public int getOriginatorAddress()
public int getNumUnconfirmedIPdusSent()
public void close()
public void send(ASdu aSdu) throws java.io.IOException
java.io.IOException
public void sendConfirmation(ASdu aSdu) throws java.io.IOException
java.io.IOException
public void singleCommand(int commonAddress, int informationObjectAddress, IeSingleCommand singleCommand) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.informationObjectAddress
- the information object address.singleCommand
- the command to be sent.java.io.IOException
- if a fatal communication error occurred.public void singleCommandWithTimeTag(int commonAddress, int informationObjectAddress, IeSingleCommand singleCommand, IeTime56 timeTag) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.informationObjectAddress
- the information object address.singleCommand
- the command to be sent.timeTag
- the time tag to be sent.java.io.IOException
- if a fatal communication error occurred.public void doubleCommand(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeDoubleCommand doubleCommand) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.doubleCommand
- the command to be sent.java.io.IOException
- if a fatal communication error occurred.public void doubleCommandWithTimeTag(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeDoubleCommand doubleCommand, IeTime56 timeTag) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.doubleCommand
- the command to be sent.timeTag
- the time tag to be sent.java.io.IOException
- if a fatal communication error occurred.public void regulatingStepCommand(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeRegulatingStepCommand regulatingStepCommand) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.regulatingStepCommand
- the command to be sent.java.io.IOException
- if a fatal communication error occurred.public void regulatingStepCommandWithTimeTag(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeRegulatingStepCommand regulatingStepCommand, IeTime56 timeTag) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.regulatingStepCommand
- the command to be sent.timeTag
- the time tag to be sent.java.io.IOException
- if a fatal communication error occurred.public void setNormalizedValueCommand(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeNormalizedValue normalizedValue, IeQualifierOfSetPointCommand qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.normalizedValue
- the value to be sent.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void setNormalizedValueCommandWithTimeTag(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeNormalizedValue normalizedValue, IeQualifierOfSetPointCommand qualifier, IeTime56 timeTag) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.normalizedValue
- the value to be sent.qualifier
- the qualifier to be sent.timeTag
- the time tag to be sent.java.io.IOException
- if a fatal communication error occurred.public void setScaledValueCommand(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeScaledValue scaledValue, IeQualifierOfSetPointCommand qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.scaledValue
- the value to be sent.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void setScaledValueCommandWithTimeTag(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeScaledValue scaledValue, IeQualifierOfSetPointCommand qualifier, IeTime56 timeTag) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.scaledValue
- the value to be sent.qualifier
- the qualifier to be sent.timeTag
- the time tag to be sent.java.io.IOException
- if a fatal communication error occurred.public void setShortFloatCommand(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeShortFloat shortFloat, IeQualifierOfSetPointCommand qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.shortFloat
- the value to be sent.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void setShortFloatCommandWithTimeTag(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeShortFloat shortFloat, IeQualifierOfSetPointCommand qualifier, IeTime56 timeTag) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.shortFloat
- the value to be sent.qualifier
- the qualifier to be sent.timeTag
- the time tag to be sent.java.io.IOException
- if a fatal communication error occurred.public void bitStringCommand(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeBinaryStateInformation binaryStateInformation) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.binaryStateInformation
- the value to be sent.java.io.IOException
- if a fatal communication error occurred.public void bitStringCommandWithTimeTag(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeBinaryStateInformation binaryStateInformation, IeTime56 timeTag) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.binaryStateInformation
- the value to be sent.timeTag
- the time tag to be sent.java.io.IOException
- if a fatal communication error occurred.public void interrogation(int commonAddress, CauseOfTransmission cot, IeQualifierOfInterrogation qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void counterInterrogation(int commonAddress, CauseOfTransmission cot, IeQualifierOfCounterInterrogation qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void readCommand(int commonAddress, int informationObjectAddress) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.informationObjectAddress
- the information object address.java.io.IOException
- if a fatal communication error occurred.public void synchronizeClocks(int commonAddress, IeTime56 time) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.time
- the time to be sent.java.io.IOException
- if a fatal communication error occurred.public void testCommand(int commonAddress) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.java.io.IOException
- if a fatal communication error occurred.public void resetProcessCommand(int commonAddress, IeQualifierOfResetProcessCommand qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void delayAcquisitionCommand(int commonAddress, CauseOfTransmission cot, IeTime16 time) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and spontaneous.time
- the time to be sent.java.io.IOException
- if a fatal communication error occurred.public void testCommandWithTimeTag(int commonAddress, IeTestSequenceCounter testSequenceCounter, IeTime56 time) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.testSequenceCounter
- the value to be sent.time
- the time to be sent.java.io.IOException
- if a fatal communication error occurred.public void parameterNormalizedValueCommand(int commonAddress, int informationObjectAddress, IeNormalizedValue normalizedValue, IeQualifierOfParameterOfMeasuredValues qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.informationObjectAddress
- the information object address.normalizedValue
- the value to be sent.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void parameterScaledValueCommand(int commonAddress, int informationObjectAddress, IeScaledValue scaledValue, IeQualifierOfParameterOfMeasuredValues qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.informationObjectAddress
- the information object address.scaledValue
- the value to be sent.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void parameterShortFloatCommand(int commonAddress, int informationObjectAddress, IeShortFloat shortFloat, IeQualifierOfParameterOfMeasuredValues qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.informationObjectAddress
- the information object address.shortFloat
- the value to be sent.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void parameterActivation(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeQualifierOfParameterActivation qualifier) throws java.io.IOException
commonAddress
- the Common ASDU Address. Valid value are 1...255 or 1...65535 for field lengths 1 or 2 respectively.cot
- the cause of transmission. Allowed are activation and deactivation.informationObjectAddress
- the information object address.qualifier
- the qualifier to be sent.java.io.IOException
- if a fatal communication error occurred.public void fileReady(int commonAddress, int informationObjectAddress, IeNameOfFile nameOfFile, IeLengthOfFileOrSection lengthOfFile, IeFileReadyQualifier qualifier) throws java.io.IOException
java.io.IOException
public void sectionReady(int commonAddress, int informationObjectAddress, IeNameOfFile nameOfFile, IeNameOfSection nameOfSection, IeLengthOfFileOrSection lengthOfSection, IeSectionReadyQualifier qualifier) throws java.io.IOException
java.io.IOException
public void callOrSelectFiles(int commonAddress, CauseOfTransmission cot, int informationObjectAddress, IeNameOfFile nameOfFile, IeNameOfSection nameOfSection, IeSelectAndCallQualifier qualifier) throws java.io.IOException
java.io.IOException
public void lastSectionOrSegment(int commonAddress, int informationObjectAddress, IeNameOfFile nameOfFile, IeNameOfSection nameOfSection, IeLastSectionOrSegmentQualifier qualifier, IeChecksum checksum) throws java.io.IOException
java.io.IOException
public void ackFileOrSection(int commonAddress, int informationObjectAddress, IeNameOfFile nameOfFile, IeNameOfSection nameOfSection, IeAckFileOrSectionQualifier qualifier) throws java.io.IOException
java.io.IOException
public void sendSegment(int commonAddress, int informationObjectAddress, IeNameOfFile nameOfFile, IeNameOfSection nameOfSection, IeFileSegment segment) throws java.io.IOException
java.io.IOException
public void sendDirectory(int commonAddress, int informationObjectAddress, InformationElement[][] directory) throws java.io.IOException
java.io.IOException
public void queryLog(int commonAddress, int informationObjectAddress, IeNameOfFile nameOfFile, IeTime56 rangeStartTime, IeTime56 rangeEndTime) throws java.io.IOException
java.io.IOException