lib60870.NET  2.2.0
IEC 60870-5-101/104 Protocol Source Code Library for C#/.NET
lib60870.CS101.CS101Master Class Reference
Inheritance diagram for lib60870.CS101.CS101Master:
Collaboration diagram for lib60870.CS101.CS101Master:

Public Member Functions

void Run ()
 Run the protocol state machines a single time. Alternative to Start/Stop when no background thread should be used Has to be called frequently More...
 
void Start ()
 Start a background thread running the master More...
 
void Stop ()
 Stop the background thread More...
 
LinkLayerState GetLinkLayerState ()
 
override void SetReceivedRawMessageHandler (RawMessageHandler handler, object parameter)
 Sets the raw message handler for receoved messages More...
 
override void SetSentRawMessageHandler (RawMessageHandler handler, object parameter)
 Sets the sent message handler for sent messages. More...
 
 CS101Master (SerialPort port, LinkLayerMode mode, LinkLayerParameters llParams=null, ApplicationLayerParameters alParams=null)
 
 CS101Master (Stream serialStream, LinkLayerMode mode, LinkLayerParameters llParams=null, ApplicationLayerParameters alParams=null)
 
void SetTimeouts (int messageTimeout, int characterTimeout)
 Sets the timeouts for receiving messages (in milliseconds) More...
 
void SetASDUReceivedHandler (ASDUReceivedHandler handler, object parameter)
 
void AddSlave (int slaveAddress)
 
LinkLayerState GetLinkLayerState (int slaveAddress)
 
void SetLinkLayerStateChangedHandler (LinkLayerStateChanged handler, object parameter)
 
void UseSlaveAddress (int slaveAddress)
 Sets the slave link layer address to be used More...
 
void PollSingleSlave (int address)
 
void SendLinkLayerTestFunction ()
 
override void SendInterrogationCommand (CauseOfTransmission cot, int ca, byte qoi)
 Sends the interrogation command. More...
 
override void SendCounterInterrogationCommand (CauseOfTransmission cot, int ca, byte qcc)
 Sends the counter interrogation command (C_CI_NA_1 typeID: 101) More...
 
override void SendReadCommand (int ca, int ioa)
 Sends a read command (C_RD_NA_1 typeID: 102). More...
 
override void SendClockSyncCommand (int ca, CP56Time2a time)
 Sends a clock synchronization command (C_CS_NA_1 typeID: 103). More...
 
override void SendTestCommand (int ca)
 Sends a test command (C_TS_NA_1 typeID: 104). More...
 
override void SendTestCommandWithCP56Time2a (int ca, ushort tsc, CP56Time2a time)
 Sends a test command with CP56Time2a time (C_TS_TA_1 typeID: 107). More...
 
override void SendResetProcessCommand (CauseOfTransmission cot, int ca, byte qrp)
 Sends a reset process command (C_RP_NA_1 typeID: 105). More...
 
override void SendDelayAcquisitionCommand (CauseOfTransmission cot, int ca, CP16Time2a delay)
 Sends a delay acquisition command (C_CD_NA_1 typeID: 106). More...
 
override void SendControlCommand (CauseOfTransmission cot, int ca, InformationObject sc)
 Sends the control command. More...
 
override void SendASDU (ASDU asdu)
 Sends an arbitrary ASDU to the connected slave More...
 
override ApplicationLayerParameters GetApplicationLayerParameters ()
 Get the application layer parameters used by this master instance More...
 
override void GetFile (int ca, int ioa, NameOfFile nof, IFileReceiver receiver)
 Gets the file. More...
 

Protected Attributes

Thread workerThread = null
 
SerialPort port = null
 
bool running = false
 
- Protected Attributes inherited from lib60870.CS101.Master
bool debugOutput
 

Properties

bool DIR [get, set]
 Value of DIR bit when sending messages. More...
 
int OwnAddress [get, set]
 
int SlaveAddress [get, set]
 Gets or sets the link layer slave address More...
 
- Properties inherited from lib60870.CS101.Master
bool DebugOutput [get, set]
 

Member Function Documentation

◆ GetApplicationLayerParameters()

override ApplicationLayerParameters lib60870.CS101.CS101Master.GetApplicationLayerParameters ( )
virtual

Get the application layer parameters used by this master instance

Returns
used application layer parameters

Implements lib60870.CS101.Master.

◆ GetFile()

override void lib60870.CS101.CS101Master.GetFile ( int  ca,
int  ioa,
NameOfFile  nof,
IFileReceiver  receiver 
)
virtual

Gets the file.

Parameters
caCa.
ioaIoa.
nofNof.
receiverReceiver.

Implements lib60870.CS101.Master.

◆ Run()

void lib60870.CS101.CS101Master.Run ( )

Run the protocol state machines a single time. Alternative to Start/Stop when no background thread should be used Has to be called frequently

◆ SendASDU()

override void lib60870.CS101.CS101Master.SendASDU ( ASDU  asdu)
virtual

Sends an arbitrary ASDU to the connected slave

Parameters
asduThe ASDU to send

Implements lib60870.CS101.Master.

◆ SendClockSyncCommand()

override void lib60870.CS101.CS101Master.SendClockSyncCommand ( int  ca,
CP56Time2a  time 
)
virtual

Sends a clock synchronization command (C_CS_NA_1 typeID: 103).

Parameters
caCommon address
timethe new time to set
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SendControlCommand()

override void lib60870.CS101.CS101Master.SendControlCommand ( CauseOfTransmission  cot,
int  ca,
InformationObject  sc 
)
virtual

Sends the control command.

The type ID has to match the type of the InformationObject!

C_SC_NA_1 -> SingleCommand C_DC_NA_1 -> DoubleCommand C_RC_NA_1 -> StepCommand C_SC_TA_1 -> SingleCommandWithCP56Time2a C_SE_NA_1 -> SetpointCommandNormalized C_SE_NB_1 -> SetpointCommandScaled C_SE_NC_1 -> SetpointCommandShort C_BO_NA_1 -> Bitstring32Command

Parameters
cotCause of transmission (use ACTIVATION to start a control sequence)
caCommon address
scInformation object of the command
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SendCounterInterrogationCommand()

override void lib60870.CS101.CS101Master.SendCounterInterrogationCommand ( CauseOfTransmission  cot,
int  ca,
byte  qcc 
)
virtual

Sends the counter interrogation command (C_CI_NA_1 typeID: 101)

Parameters
cotCause of transmission
caCommon address
qccQualifier of counter interrogation command
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SendDelayAcquisitionCommand()

override void lib60870.CS101.CS101Master.SendDelayAcquisitionCommand ( CauseOfTransmission  cot,
int  ca,
CP16Time2a  delay 
)
virtual

Sends a delay acquisition command (C_CD_NA_1 typeID: 106).

Parameters
cotCause of transmission
caCommon address
delaydelay for acquisition
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SendInterrogationCommand()

override void lib60870.CS101.CS101Master.SendInterrogationCommand ( CauseOfTransmission  cot,
int  ca,
byte  qoi 
)
virtual

Sends the interrogation command.

Parameters
cotCause of transmission
caCommon address
qoiQualifier of interrogation (20 = station interrogation)
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SendReadCommand()

override void lib60870.CS101.CS101Master.SendReadCommand ( int  ca,
int  ioa 
)
virtual

Sends a read command (C_RD_NA_1 typeID: 102).

This will send a read command C_RC_NA_1 (102) to the slave/outstation. The COT is always REQUEST (5). It is used to implement the cyclical polling of data application function.

Parameters
caCommon address
ioaInformation object address
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SendResetProcessCommand()

override void lib60870.CS101.CS101Master.SendResetProcessCommand ( CauseOfTransmission  cot,
int  ca,
byte  qrp 
)
virtual

Sends a reset process command (C_RP_NA_1 typeID: 105).

Parameters
cotCause of transmission
caCommon address
qrpQualifier of reset process command
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SendTestCommand()

override void lib60870.CS101.CS101Master.SendTestCommand ( int  ca)
virtual

Sends a test command (C_TS_NA_1 typeID: 104).

Not required and supported by IEC 60870-5-104.

Parameters
caCommon address
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SendTestCommandWithCP56Time2a()

override void lib60870.CS101.CS101Master.SendTestCommandWithCP56Time2a ( int  ca,
ushort  tsc,
CP56Time2a  time 
)
virtual

Sends a test command with CP56Time2a time (C_TS_TA_1 typeID: 107).

Parameters
caCommon address
tsctest sequence number
timetest timestamp
Exceptions
ConnectionExceptiondescription

Implements lib60870.CS101.Master.

◆ SetReceivedRawMessageHandler()

override void lib60870.CS101.CS101Master.SetReceivedRawMessageHandler ( RawMessageHandler  handler,
object  parameter 
)
virtual

Sets the raw message handler for receoved messages

Parameters
handlerHandler/delegate that will be invoked when a message is received
parameterwill be passed to the delegate

Implements lib60870.CS101.Master.

◆ SetSentRawMessageHandler()

override void lib60870.CS101.CS101Master.SetSentRawMessageHandler ( RawMessageHandler  handler,
object  parameter 
)
virtual

Sets the sent message handler for sent messages.

Parameters
handlerHandler/delegate that will be invoked when a message is sent<
parameterwill be passed to the delegate

Implements lib60870.CS101.Master.

◆ SetTimeouts()

void lib60870.CS101.CS101Master.SetTimeouts ( int  messageTimeout,
int  characterTimeout 
)

Sets the timeouts for receiving messages (in milliseconds)

Parameters
messageTimeoutTimeout to wait for the first character of a message
characterTimeoutTimeout to wait for next characters in a message

◆ Start()

void lib60870.CS101.CS101Master.Start ( )

Start a background thread running the master

◆ Stop()

void lib60870.CS101.CS101Master.Stop ( )

Stop the background thread

◆ UseSlaveAddress()

void lib60870.CS101.CS101Master.UseSlaveAddress ( int  slaveAddress)

Sets the slave link layer address to be used

Parameters
slaveAddressSlave link layer address.

Property Documentation

◆ DIR

bool lib60870.CS101.CS101Master.DIR
getset

Value of DIR bit when sending messages.

◆ SlaveAddress

int lib60870.CS101.CS101Master.SlaveAddress
getset

Gets or sets the link layer slave address

Slave link layer address.


The documentation for this class was generated from the following file: