GitHub Source | SCXML Wiki | SCXML Editor | Examples | Forum |
---|
USCXML C-Style Wrapper (for C++ Builder, Delphi, Qt)
State Machines in C++ Builder, Delphi
The main objective of the project is to execute dynamic SCXML state charts in C++ Builder by using such a great library as USCXML. But the problem is that USCXML source code can not be compiled by Borland C++ Compiler (not full C11 support, compiler bugs etc). We have an option to use uscxml-transformer application for transpiling SCXML source code to ANSI-C. But in this case you have to compile application every time once you've made corrections to state chart. The solution seems to have a common library wrapper with only C-functions, which could be executed on all versions of C++ Builder.
UscxmlCLib consists of only 1 lib and 1 header which should be added to C++ Builder to start executing state charts.
However it is possible and easy to use UscxmlCLib in other systems such as Qt.
Supported Operating System
Windows 7, Windows 8, Windows 10
Supported Compilers for building UscxmlCLib from source code
MSVC 2015 SP3
Supported Compilers for using UscxmlCLib.dll
UscxmlCLib\Lib\UscxmlCLib_borland.lib - for Borland C++ Compiler (tests were performed on C++ Builder 2010, C++ Builder XE7)
UscxmlCLib\Lib\UscxmlCLib.lib - for MSVC 2015 SP3
Installation
-
Install Visual C++ Redistributable for Visual Studio 2015 SP3
-
Put UscxmlCLib\Bin binaries to Windows search path or add dir with binaries to PATH environment settings
Build from source code
There will be special article
Getting Started
Let's start 'Hello, world' example in C++ Builder
- Add library to project
#include "UscxmlCLib.h"
#pragma comment(lib,"UscxmlCLib_borland.lib")
- Set callbacks from interpreter and notifiers for main thread
class TLogNotify : public TIdNotify {
const UnicodeString FMessage;
protected:
virtual void __fastcall DoNotify(void) {
FormHelloWorld->Memo1->Lines->Add(FMessage);
}
public:
__fastcall TLogNotify(const UnicodeString &sMsg) : FMessage(sMsg) {
}
};
void __stdcall OnInterpreterLogCallback(const UsclibInterpreter *AInterpreter, const int nSeverity, const char *chMessage, void *AUser) {
(new TLogNotify(chMessage))->Notify();
}
- Work with interprter
if (USCLIB_SUCCESS != usclib_OpenInterpreter(&g_Interpreter, 0, 0, 0))
throw Exception(usclib_GetLastError());
usclib_RegisterLogCallback(g_Interpreter, OnInterpreterLogCallback, NULL);
if (USCLIB_SUCCESS != usclib_StartInterpreter(g_Interpreter, g_chScxml, USCLIB_SCXML_AS_TEXT))
throw Exception(usclib_GetLastError());
if (USCLIB_SUCCESS != usclib_CloseInterpreter(g_Interpreter))
throw Exception(usclib_GetLastError());
Output
Library Usage Chart
Licensing
UscxmlCLib itself is distributed under under the terms of the BSD 3-Clause License but it include external components with their own licensies
Project | License | Comment |
---|---|---|
uSCXML | Simplified BSD license | This wrapper mostly based on uSCXML original SDK |
libcurl | MIT/X derivate | Used in uSCXML to fetch remote content |
Xerces-C++ | Apache v2 | XML parser and DOM implementation |
libevent | 3-clause BSD | Delayed event queues |
uriparser | New BSD | Referring and resolving URIs |
Lua | Under the terms of the MIT license | Lua Data Model |
JavaScriptCore | Under the LGPL and BSD licenses | EcmaScript Data Model |
SCXML Standard Compliance
Almost the same as uSCXML original with some restrictions. Run W3C testing application to get more info
DataModels supported
- NULL
- Lua
- Luavia (Lua datamodel with some non-standard extensions to increase state chart performance)
- EcmaScript Based on JavaScriptCore binaries
Examples
After installation you are able to start ready-to-use examples.
C++ Builder Examples
- Hello World
- Traffic Light
- Calculator
- Multiple Interpreters
- KT76C Transponder Simulator
- Salus RT500 (Digital Room Thermostat) Simulator
- W3C SCXML Testing Application
- UscxmlCLib Testing Application
Qt Examples
KT76C Transponder Example!
Take special look atIt has ZERO lines of device logic in C++! Just connected GUI controls!
TOP | GitHub Source | SCXML Wiki | SCXML Editor | Examples | Forum |
---|