I have just pushed a commit through to Bitbucket for this project which implements function block operations for the IEC 61131-3 virtual machine. While still undergoing testing and further development, the implementation of this functionality addresses a major omission of functionality within the IEC 61131-3 virtual machine to date.
Surprisingly, the major effort associated with this functionality was associated with the implementation of the C library interface, allowing for function blocks to be written in both IEC 61131-3 languages and C, rather than the implementation of function block operations per se. To date, only the edge detection function blocks (F_TRIG and R_TRIG) have been implemented in the external C library for execution by the IEC 61131-3 virtual machine run-time, but next immediate task will be to extend this implementation to cover all standard function blocks defined within the IEC 61131-3 standard such that these are all immediately available, in the most optimised manner, from within the run-time environment.
Nevertheless, the rudiments of this functionality is now in place and available to be pulled from the git repository on Bitbucket.
Over the last few months, I have made some excellent progress on this project – I have implemented branching and execution jumps in the compiler and run-time and am currently working on the implementation of parameter passing to function calls. This latter task in particular has been interesting in that it has led me to made some additions to the byte code employed within the IEC 61131-3 virtual machine run-time.
For some background, the byte code is the portable instruction set, shared between the compiler and virtual machine elements of this project, that dictate execution of the virtual machine run-time. The intent of using byte codes in this project, rather than compiling directly to C or machine-specific source (such as is performed by the MATIEC, https://bitbucket.org/mjsousa/matiec/) is to provide a very compact and portable instruction set for operations. Moreover, using the interpretation of byte code for directing execution of the virtual machine additionally allows for greater control to be exerted with respect to “unintended” operations that may result from the direct execution of machine assembly. For a further explanation of byte code and it’s use in portable systems, see Wikipedia (http://en.wikipedia.org/wiki/Bytecode or http://en.wikipedia.org/wiki/Java_bytecode).