STRUC++
OpenPLC के पीछे का open-source Structured Text compiler।
STruC++ IEC 61131-3 Structured Text को साफ़ और पढ़ने लायक C++14 में compile करता है। इसमें built-in unit testing framework, interactive REPL और reusable library system है, सब एक ही binary में।
- 29K+
- कंपाइलर डाउनलोड
- 60+
- जारी किए गए संस्करण
- 85+
- GitHub पर स्टार
- नेटिव
- मशीन कोड, कोई इंटरप्रेटर नहीं
नया compiler क्यों
दो दशकों तक लगभग हर open-source PLC प्रोजेक्ट एक ही compiler पर निर्भर रहा, जो IEC 61131-3 के दूसरे edition तक सीमित था और macros से भरा C बनाता था। जब हमने OpenPLC को v4 के रूप में दोबारा बनाया, तो compiler पुराने stack का आख़िरी हिस्सा था। STruC++ उसकी जगह लेता है, शुरू से लिखा गया।
इसमें क्या अलग है
पढ़ने लायक C++, macros नहीं
Function blocks classes बनते हैं, interfaces virtual methods और generics templates। आउटपुट पढ़ा, debug किया और किसी मौजूदा C++ प्रोजेक्ट में जोड़ा जा सकता है।
ST में unit tests
test runner compiler के अंदर ही है। assertions, mocks, SETUP/TEARDOWN और simulated time के साथ TEST blocks लिखें और बिना PLC के किसी भी मशीन पर चलाएँ, CI pipelines के लिए आदर्श।
Interactive REPL
--build से प्रोग्राम बनाएँ और cycle दर cycle चलाएँ: inputs सेट करें, variables देखें और force करें, और ST व generated C++ साथ-साथ देखें।
Zero runtime dependencies
compiler एक ही binary है और C++ runtime header-only है। target पर और कुछ इंस्टॉल नहीं करना।
Structured Text अंदर, C++ बाहर
एक function block C++ class बन जाता है: inputs और outputs members होते हैं और लॉजिक call operator में।
FUNCTION_BLOCK Counter
VAR_INPUT
enable : BOOL;
reset : BOOL;
END_VAR
VAR_OUTPUT
count : INT;
END_VAR
IF reset THEN
count := 0;
ELSIF enable THEN
count := count + 1;
END_IF;
END_FUNCTION_BLOCKnamespace strucpp {
class Counter {
public:
IEC_BOOL enable;
IEC_BOOL reset;
IEC_INT count;
void operator()();
};
void Counter::operator()() {
if (reset) {
count = 0;
} else if (enable) {
count = count + 1;
}
}
} // namespace strucppभाषा कवरेज
IEC 61131-3 Edition 3 का बड़ा हिस्सा, साथ में इंडस्ट्री में आम extensions।
Data types
सभी elementary types, जिनमें 64-bit integers, strings और time व date के L-variants शामिल हैं, साथ में arrays, structs, enums और subranges।
POUs और variables
PROGRAM, FUNCTION, FUNCTION_BLOCK और INTERFACE, inputs, outputs, globals, constants, RETAIN और located variables के साथ।
Object orientation
Methods, GET और SET वाली properties, EXTENDS, IMPLEMENTS, ABSTRACT, FINAL, OVERRIDE और access modifiers।
Pointers और references
POINTER TO, REF_TO, REFERENCE_TO, ADR, dereferencing और dynamic allocation।
Standard library
80 से ज़्यादा standard functions, साथ में timers, counters, edge detectors और bistables। OSCAT Basic library सीधे compile होती है।
Project model
CONFIGURATION, RESOURCE और TASK, program scheduling के साथ।
जहाँ आप काम करते हैं, वहीं चलता है
Command line
Linux x64 और ARM64, macOS Intel और Apple Silicon, और Windows x64 के लिए standalone binaries।
ब्राउज़र में
बिना native dependencies वाली JavaScript और TypeScript library भी, Node.js, browsers, Deno और Bun के लिए।
VS Code में
STruC++ extension Structured Text के लिए real-time diagnostics, autocomplete, go to definition और debugging देता है।
Microcontrollers पर
आउटपुट C++14 पर आधारित है, इसलिए Arduino boards के toolchains से build होता है, avr-g++ 7.3 तक।
Open source, और आपके प्रोग्राम आपके ही रहते हैं
compiler GPL-3.0 लाइसेंस में है। C++ runtime और standard libraries में STruC++ Runtime Library Exception है, इसलिए आपके compile किए प्रोग्राम किसी भी लाइसेंस में बाँटे जा सकते हैं।
STruC++ आज़माएँ
कोई release डाउनलोड करें, पहली ST फ़ाइल compile करें और उसके tests चलाएँ, बिना PLC के।

