--- a/iec60870/iec60870.py Fri Apr 10 11:20:01 2026 +0200
+++ b/iec60870/iec60870.py Fri Apr 10 15:25:38 2026 +0200
@@ -7,7 +7,9 @@
from ConfigTreeNode import ConfigTreeNode
from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_INPUT, \
LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
+import util.paths as paths +iec60870_path = paths.ThirdPartyPath("IEC60870") # (type_id, IEC_type, datasize, direction, size_code, description)
# direction: "I" for monitor (input), "Q" for control (output), "M" for memory
@@ -469,4 +471,35 @@
a3=port1, a4=addr1, a5=addr2)
self.FatalError(error_message)
+ # define a unique name for the generated C and h files + current_location = self.GetCurrentLocation() + prefix = "_".join(map(str, current_location)) + gen_iec60870_c_path = os.path.join(buildpath, "iec60870_%s.c" % prefix) + gen_iec60870_h_path = os.path.join(buildpath, "iec60870_%s.h" % prefix) + c_filename = os.path.join(os.path.split(__file__)[0], "iec60870_runtime.c") + h_filename = os.path.join(os.path.split(__file__)[0], "iec60870_runtime.h") + # TODO: get located variables and merge them with template files + loc_dict = {"locstr": "_".join(map(str, self.GetCurrentLocation()))} + loc_dict["loc_vars"] = "\n".join(loc_vars) + # create output files using templates + iec60870_main = open(h_filename).read() % loc_dict + f = open(gen_iec60870_h_path, 'w') + iec60870_main = open(c_filename).read() % loc_dict + f = open(gen_iec60870_c_path, 'w') + LDFLAGS.append(" \"-L" + iec60870_path + "\"") + LDFLAGS.append(" \"" + os.path.join(iec60870_path, "liblib60870.a") + "\"") + LDFLAGS.append(" \"-Wl,-rpath," + iec60870_path + "\"") + return [(gen_iec60870_c_path, ' -I"' + iec60870_path + '"')], LDFLAGS, False --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/iec60870/iec60870_runtime.c Fri Apr 10 15:25:38 2026 +0200
@@ -0,0 +1,29 @@
+/* iec60870 runtime C extension + * TODO: plugin-specific init/publish/retrieve/cleanup functions + * which Beremiz runtime can link and call. +int __init_iec60870(int argc, char **argv) { + fprintf(stderr, "iec60870 extension: __init_iec60870\n"); + // TODO: initialize resources, threads, state +void __publish_iec60870(void) { + // TODO: sync data from PLC to extension outputs (if needed) +void __retrieve_iec60870(void) { + // TODO: sync data from extension inputs to PLC (if needed) +int __cleanup_iec60870(void) { + fprintf(stderr, "iec60870 extension: __cleanup_iec60870\n"); + // TODO: release resources, stop threads --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/iec60870/iec60870_runtime.h Fri Apr 10 15:25:38 2026 +0200
@@ -0,0 +1,6 @@
\ No newline at end of file