The invention discloses a lightweight cross-platform PLC (
Programmable Logic Controller) multi-
language code generation method, which relates to the field of industrial
process control, and firstly provides a unified intermediate
data model, and on the basis, a module for converting each PLC language into the unified intermediate
data model is realized; on the basis of a standardized
JSON data structure, a modularized unified
intermediate language conversion chain is further supported, an analyzer and a generator communicate through a
JSON interface, a cross-platform conversion path is supported, and unified
intermediate language conversion from PLC to
JSON to
XML to ST to C is completed; the method comprises the following steps of: integrating an
open source compiler and runtime, constructing an open and pluggable automatic execution framework, compiling a generated C code into a platform
executable file by using an adaptive GCC tool chain aiming at different target platforms, and deploying a program generated by compiling to a soft PLC
runtime system supporting multiple platforms. According to the method, a JSON intermediate
data structure which is light in weight, unrelated to languages and uniform in structure and a matched conversion framework of the JSON intermediate
data structure are constructed.