Server
-
class Server : public std::enable_shared_from_this<Server>
service model for IEC60870-5-104 communication as server
Public Functions
-
~Server()
Close and destroy server.
-
std::string getIP() const
Getter for ip of remote server
- Returns:
ip string
-
std::uint_fast16_t getPort() const
Getter for port of remote server
- Returns:
port number
-
void start()
start listening for client connections, send periodic broadcasts
- Throws:
std::runtime_error – if slave thread failed to start
-
void stop()
stop listening for client connections
-
bool isRunning()
test if server is currently active
- Returns:
information on active state of server
-
bool hasStations() const
Test if Stations exists at this NetworkStation.
- Returns:
information on availability of child Station objects
-
bool hasOpenConnections() const
Test if Server has open connections to clients.
- Returns:
information if at least one connection exists
-
std::uint_fast8_t getOpenConnectionCount() const
get number of open connections to clients
- Returns:
open connection count
-
bool hasActiveConnections() const
Test if Server has active (open and not muted) connections to clients.
- Returns:
information if at least one connection is active
-
std::uint_fast8_t getActiveConnectionCount() const
get number of active (open and not muted) connections to clients
- Returns:
active connection count
-
Object::StationVector getStations() const
Get a list of all Stations.
- Returns:
vector with object stationer
-
std::shared_ptr<Object::Station> getStation(std::uint_fast16_t commonAddress) const
Get a Station that exists at this NetworkStation and is identified via information object address.
- Returns:
Stationer to Station or nullptr
-
bool hasStation(std::uint_fast16_t commonAddress) const
Test if Stations exists at this NetworkStation.
- Returns:
information on availability of child Station objects
-
std::shared_ptr<Object::Station> addStation(std::uint_fast16_t commonAddress)
Add a Station to this Station.
-
void setOnReceiveRawCallback(py::object &callable)
set python callback that will be executed on incoming message
- Throws:
std::invalid_argument – if callable signature does not match
-
void setOnSendRawCallback(py::object &callable)
set python callback that will be executed on outgoing message
- Throws:
std::invalid_argument – if callable signature does not match
-
void setOnClockSyncCallback(py::object &callable)
set python callback that will be executed on incoming clock sync command
- Throws:
std::invalid_argument – if callable signature does not match
-
void setOnUnexpectedMessageCallback(py::object &callable)
set python callback that will be executed on unexpected incoming messages
- Throws:
std::invalid_argument – if callable signature does not match
-
void setOnConnectCallback(py::object &callable)
set python callback that will be executed on incoming connection requests
- Throws:
std::invalid_argument – if callable signature does not match
transmit a datapoint related message to a remote client
- Parameters:
point – datapoint that should be send via server
cause – reason for transmission
- Throws:
std::invalid_argument – if point type is not supported for this operation
- Returns:
information on operation success
send a message object to a remote client
- Parameters:
message – message that should be send via server
connection – send to a single client identified via internal connection object
- Returns:
information on operation success
-
void sendInterrogationResponse(CS101_CauseOfTransmission cot, uint_fast16_t commonAddress = IEC60870_GLOBAL_COMMON_ADDRESS, IMasterConnection connection = nullptr)
Send full interrogation response or periodic measurement broadcasts.
- Parameters:
cot – cause of transmission: why this message should be send
commonAddress – send interrogation for a single station only identified via common address
connection – send to a single client identified via internal connection object
-
std::shared_ptr<Remote::Message::IncomingMessage> getValidMessage(IMasterConnection connection, CS101_ASDU asdu)
validate incoming ASDU, send negative response if invalid receiver station or return ASDU wrapped in a IncomingMessage facade otherwise
- Parameters:
connection – reference to internal connection object
asdu – incoming ASDU packet
- Returns:
Public Static Functions
-
static bool connectionRequestHandler(void *parameter, const char *ipAddress)
server thread function
Callback to accept or decline incoming client connections
- Parameters:
parameter – reference to custom bound connection data
ipAddress – ip address of client
- Returns:
-
static void connectionEventHandler(void *parameter, IMasterConnection connection, CS104_PeerConnectionEvent event)
Callback to handle connection state changes.
- Parameters:
parameter – reference to custom bound connection data
connection – reference to internal connection object
event – state change event (opened,closed,muted,unmuted identified via constants)
-
static void rawMessageHandler(void *parameter, IMasterConnection connection, uint_fast8_t *msg, int msgSize, bool sent)
Callback for logging incoming and outgoing byteStreams.
Warning
DEBUG FUNCTION, IN ORDER TO ACTIVE THIS CALLBACK REMOVE COMMENT WRAPPER IN CONSTRUCTOR
- Parameters:
parameter – reference to custom bound connection data
connection – reference to internal connection object
msg – pointer to first character of message
msgSize – character count of message
sent – direction of message
-
static bool interrogationHandler(void *parameter, IMasterConnection connection, CS101_ASDU asdu, QualifierOfInterrogation qoi)
Callback for reacting on incoming clock sync command and sending responses.
Callback for reacting on incoming interrogation command and sending responses
- Parameters:
parameter – reference to custom bound connection data
connection – reference to internal connection object
asdu – incoming ASDU packet
newtime – synchronized current timestamp formated as CP56Time2a
parameter – reference to custom bound connection data
connection – reference to internal connection object
asdu – incoming ASDU packet
qoi – which group of states and measurements are requested for interrogation (group 1-16 or general represented in constants)
- Returns:
if command was handled.. if not it will be passed to asduHandler
- Returns:
if command was handled.. if not it will be passed to asduHandler
-
static bool counterInterrogationHandler(void *parameter, IMasterConnection connection, CS101_ASDU asdu, QualifierOfCIC qcc)
Callback for reacting on incoming counter interrogation command and sending responses.
- Parameters:
parameter – reference to custom bound connection data
connection – reference to internal connection object
asdu – incoming ASDU packet
qcc – which group of counters are requested for interrogation (group 1-4 or general represented in constants)
- Returns:
if command was handled.. if not it will be passed to asduHandler
-
static bool readHandler(void *parameter, IMasterConnection connection, CS101_ASDU asdu, int ioAddress)
Callback for reacting on incoming read request command and sending responses.
- Parameters:
parameter – reference to custom bound connection data
connection – reference to internal connection object
asdu – incoming ASDU packet
ioAddress – unqiue identifier of information object whom’s state/value should be responded
- Returns:
if command was handled.. if not it will be passed to asduHandler
-
static bool asduHandler(void *parameter, IMasterConnection connection, CS101_ASDU asdu)
Callback for reacting on incoming commands.
- Parameters:
parameter – reference to custom bound connection data
connection – reference to internal connection object
asdu – incoming ASDU packet
- Returns:
if command was handled.. if not server responds negative confirmation to sender
-
~Server()