A Python module to simulate SCADA and RTU communication over protocol 60870-5-104 to research ICT behavior in power grids.
Project description
iec104-python
Table of contents
Introduction
This software provides an object-oriented high-level python module to simulate scada systems and remote terminal units communicating via 60870-5-104 protocol.
The python module c104 combines the use of lib60870-C with state structures and python callback handlers.
Example remote terminal unit
import c104
# server and station preparation
server = c104.Server(ip="0.0.0.0", port=2404)
# add local station and points
station = server.add_station(common_address=47)
measurement_point = station.add_point(io_address=11, type=c104.Type.M_ME_NC_1, report_ms=1000)
command_point = station.add_point(io_address=12, type=c104.Type.C_RC_TA_1)
server.start()
Example scada unit
import c104
client = c104.Client(tick_rate_ms=1000, command_timeout_ms=5000)
# add RTU with station and points
connection = client.add_connection(ip="127.0.0.1", port=2404, init=c104.Init.INTERROGATION)
station = connection.add_station(common_address=47)
measurement_point = station.add_point(io_address=11, type=c104.Type.M_ME_NC_1, report_ms=1000)
command_point = station.add_point(io_address=12, type=c104.Type.C_RC_TA_1)
client.start()
See examples folder for more detailed examples.
Licensing
This software is licensed under the GPLv3 (https://www.gnu.org/licenses/gpl-3.0.en.html).
See LICENSE file for the complete license text.
Dependencies
lib60870-C
This project is build on top of lib60870-C v2 from MZ Automation GmbH, which is licensed under GPLv3.
The library is used for 60870-5-104 protocol based communication.
mbedtls
This project is build on top of mbedtls from the Mbed TLS Contributors, which is licensed under Apache-2.0.
The library is used to add transport layer security to the 60870-5-104 protocol based communication.
pybind11
This project is build on top of pybind11 from Wenzel Jakob, which is licensed under a BSD-style license.
The library is used to wrap c++ code into a python module and allow seamless operability between python and c++.
catch2
This project is build on top of catch2 from the Catch2 Authors, which is licensed under BSL-1.0.
The library is used as testing framework for test-automation.
System requirements
Operating systems
- Debian/Ubuntu (x64): YES >= 20.04
- Raspbian (arm32v7): YES
- Windows (x64): YES
- Raspbian (aarch64): Not yet tested
Python versions
- python >= 3.6, < 3.13
Installation
Please adjust the version number to the latest version or use a specific version according to your needs.
Install from pypi.org
python3 -m pip install c104
Install from git with tag
python3 -m pip install c104@git+https://github.com/fraunhofer-fit-dien/iec104-python.git
Documentation
Read more about the Classes and their Properties in our read the docs documentation.
Contribution
How to contribute
-
Add feature requests and report bugs using GitHub's issues
-
Create pull requests
How to build for multiple python versions (linux with docker)
- Build wheels via docker
/bin/bash ./bin/linux-build.sh
How to build (linux)
-
Install dependencies
sudo apt-get install build-essential python3-pip python3-dev python3-dbg python3 -m pip install --upgrade pip
-
Build wheel
python3 -m pip wheel .
How to analyze performance (linux)
-
Install dependencies
sudo apt-get install google-perftools valgrind sudo pip3 install yep
-
Copy pprof binary
cd /usr/bin sudo wget https://raw.githubusercontent.com/gperftools/gperftools/master/src/pprof sudo chmod +x pprof
-
Execute profiler script
./bin/profiler.sh
How to build (windows)
-
Install dependencies
- Python 3
- Buildtools für Visual Studio 201x (Scroll down » All Downloads » Tools for Visual Studio 201x)
-
Build wheel
python3 -m pip wheel .
Generate documentation
-
Build c104 module
-
Install dependencies
python3 -m pip install --upgrade sphinx breathe sphinx-autodoc-typehints
- doxygen
- graphviz
-
Build doxygen xml
doxygen Doxyfile
-
Build sphinx html
python3 bin/build-docs.py
Change log
Track all changes in our CHANGELOG documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for c104-1.18.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e69c744ee4b395ea1c9997468f7aca0fe8a9cd9ce9ac1d81a8442a2e0e74c70 |
|
MD5 | 15e729ddfe90fcdd409680992140b790 |
|
BLAKE2b-256 | 46accf83aea232cbc88debceaec70cd2ec1d57db7f8c1f9b85c5b2d635152628 |
Hashes for c104-1.18.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4fad79d9bb2974579a930f94a76b4e821a94b0c3390a1a33c0c3c6c7186adbc |
|
MD5 | f44d1d48bf42d55aad61629e614341e5 |
|
BLAKE2b-256 | a69d13633b91d781fcc6a14f9e440f8b045d172b79796611602f8a825a34bd46 |
Hashes for c104-1.18.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65666c0e1c95a42ceaf465904766eeab77dda2c74cb37257a34ff9eea4085fc7 |
|
MD5 | d0b6f2a904e590850c81d9690511e4d9 |
|
BLAKE2b-256 | f5c9c312fa706dfb671dc622f55fdb935c1434d3a13b820d138c188044afdca5 |
Hashes for c104-1.18.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5e5dd3740415a752568abf08da36f02d5d0771acd8adefd63f9cfbbf6fa29f5 |
|
MD5 | c1263a89d2a54e9648c52abad9366aaa |
|
BLAKE2b-256 | 3cdcbb0f6c36568bf53ab897a0a56fc80568f73a0cfc6328a222289e231655db |
Hashes for c104-1.18.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba48bdb34604197f12c000c8bcd922e8e82addc36ca26338efbbeb6ff65aeb37 |
|
MD5 | 24023aa151432a655efda6ac293330f3 |
|
BLAKE2b-256 | 500695566c9c4034c0b11e95fb3a6230152ad16277e2c54c09e05411a386922c |
Hashes for c104-1.18.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74707b121855f316d9b1360b085f776bc346152c1915f53c6e0f87e46b9e8435 |
|
MD5 | 58aee0e10466a47e7dada45de5c14e20 |
|
BLAKE2b-256 | ed5bf118944881eeb80d6a1043bf8164f6293331f661b665f8c1a13a71a48a49 |
Hashes for c104-1.18.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed3b2a8339157af364e82f2b38b887d5ff7e2ee500c1d0d96da79d234f65e3d5 |
|
MD5 | e92ecfa1cb16542889e4e19ac2389e13 |
|
BLAKE2b-256 | 5bd05d92b565096925bc24e688d089fb40b3f6d28ae81577335e5a0c2062989a |
Hashes for c104-1.18.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bbb0c61444f53e259138af3e4522ca0a4f13fdc821cb3df01dd68be3079c820 |
|
MD5 | 82262f5f0e6e51a416e1fc746c9c8189 |
|
BLAKE2b-256 | fe76e444ed9f85d4999befbacc0cc80449155b9c5ef84cd0741784cc8cb1d496 |
Hashes for c104-1.18.0-cp39-cp39-linux_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db3cd221af1af8d4c998a8ae5bb4147122ea5d2322060b59b7af184f8898d5b9 |
|
MD5 | 9e3f801c4df767013546ef57ec431457 |
|
BLAKE2b-256 | 39ecaed69fc22a1dafa75c9fc52cac8516abe78f10f83750ae8379d7ee3048d9 |
Hashes for c104-1.18.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48aeda50a03d35ce4d3e559fd7acdb208b9b2314c9b55cdb7aff2cdd9aac7c22 |
|
MD5 | 73d703479c17fce5737c8419253a36a2 |
|
BLAKE2b-256 | a4ce498fb5ebbb98a8d397dd9cdcdbe4c01ddc2b35899e5ee5c9f2cde2feba1f |
Hashes for c104-1.18.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b64db41fa5badbd58cc9550abc9ae811b0507ac1efd5d78f5a29c2bb4c41d493 |
|
MD5 | ed4da13c3c72e5b1b88b169b1708b1c7 |
|
BLAKE2b-256 | daf6f88958e14784f902acbb9ae4607b791f38e688d1ee637c94e12d2c95adaa |
Hashes for c104-1.18.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20728aca325f3272566f7afb20debfde7c7323723a2bcc7b655bfc84d3255b1f |
|
MD5 | fd6be37b403be95dac95b01b63bc1de9 |
|
BLAKE2b-256 | 3647169c5c96597732018ed991784bda9c1177ce1bcf16364065b375fdd8bbb6 |
Hashes for c104-1.18.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 124f7ff9b891455c26a00853befae2c687af57531e705754f9db097ba8bb5643 |
|
MD5 | f1d331b9d0c74bd0d5a9c9175cfb4762 |
|
BLAKE2b-256 | 0ac3c3c79c89145768a9113c2ddbce64d96d1880115e5c9da8e4b1298b310c40 |
Hashes for c104-1.18.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92db8669625169f6c0f56f4f65dba6f27b0785de2a4a53930bc750a70239f33e |
|
MD5 | af663327bb9ac708cbf95cc4b8601a58 |
|
BLAKE2b-256 | 24e53ae7ac00c7c492299c490d3b7c7824d0add6fa1ca0bb922ec971d7748820 |
Hashes for c104-1.18.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a8ec423670153e5e89690a51f6e667f4be3e6c79f4cf9a91bb66479dd1c14fb |
|
MD5 | d295976ed4e82e4f7ca9383e23b1f997 |
|
BLAKE2b-256 | 3a687a1a39257368e26eb72d36f64bd6f0d7175c30e9e43f7d2f0869c97a30b6 |