Instrument Control Systems Seminar 2014, 20 th -24 th October 2014 Instrument Control Systems 2014 Software Engineering for PLC Development: practices and their level of maturity Michele Zamparelli Werther Pirani
Instrument Control System Seminar, 20 th -24 th October Motivation 2. Context 3. Version Control 4. Directory Structure 5. Configuration Control 6. Coding Standards Agenda
Instrument Control System Seminar, 20 th -24 th October 2014 Software engineering practices are need to ensure: functional specifications are met software architecture, including technological choices, is adopted appropriate level of robustness is reached final product is maintainable, because it complies with adopted notational and documentation standards Software engineering practices should be commensurate to the criticality and complexity of the code Motivation
Instrument Control System Seminar, 20 th -24 th October 2014 Software engineering practices are still by and large an unknown in the community of PLC development and electronics engineering. Different vendors show different degrees of adoption. PLCOpen standard is not operationally effective for S.E. purposes, hence we cannot do much inspection on code Hardly any third-party quality control tool exists for PLC development ESO only has moderate experience of Windows as development environment, most notably for practices enforcement Vendor provided "version" concept is misleading and error prone (since it is based on manual, good-will procedure). Some vendors merely provide checksums which tell you whether there is an offline-online mismatch, but not which version is in use The level of configuration of the development environment is sometimes low (though improving with newer versions). The level of openness to third-party plug-ins also varies. Assorted troubles with batch inspection execution: MVS stability problem when running C# applications Incomplete API resorts to sending graphical codes to development environment to execute functions Context
Instrument Control System Seminar, 20 th -24 th October 2014 Goals: 1. PLC applications can be archived 2. Running PLC applications may be queried for their version in a reliable fashion Status 1. PLC Code is archived in SVN, location is project dependent, e.g. : /PLC Intermixed with non PLC code 1. Flat files structure fo Beckhoff’s TWinCAT, ZIP files for Step7 2. External libraries are referenced both as SVN external (directory PLC_LIBS) and as reference in the TWinCAT project. Developers have the obligation to upgrade the SVN URL to reflect version changes. 2. Version “injection” is possible, requires (minor) standard compliance and some development environment customization Version Control
Instrument Control System Seminar, 20 th -24 th October 2014 Free of charge ANKH SVN plug-in for Microsoft Visual Studio is a must (TwinCAT development) For Step 7, project must be exported to ZIP, then archived using any SVN client on Windows (e.g. TortoiseSVN). 1. Good working knowledge of SVN is indispensible, including, but not limited to, the handling of externals 2. Avoid avoid making copies outside of SVN and rearchive them 3. Avoid archiving references to local machine file systems 4. Avoid adding version information in the name (e.g. *_TC3) but use proper branches instead Version Control (cont.)
Instrument Control System Seminar, 20 th -24 th October 2014 In VLTSW C/C++ world, with standard build environment: export SVN_VERSION:=$(shell svnversion -cn $(MOD_ROOT) | sed -e 's/^[0-9]*://' -e 's/M/+/g' -e 's/[SP]//g' 2>/dev/null ) CFLAGS += -D'MOD_VERSION="$(SVN_VERSION)"' -D'MOD_NAME="$(MOD_NAME)"' $(OBJD)/%.o : %.c "== C 64 bits Compiling: $<" $(AT)$(CC) -c $(CFLAGS) $(C_ONLY_FLAGS) $(I_PATH) $($*_CFLAGS) -o $< Make all install With PLC: launch external application for deployment which: (Steps7 requires exporting the block to text format first) searches for a specific FB (with a given name) locates a specific variable for versioning adds the value returned by the `svnversion` command (Step7 requires importing back the module from text) deploys application to the target Version injection
Edit footer on master slide, 1 January 2011
Instrument Control System Seminar, 20 th -24 th October 2014 largely dictated by the GUI development environment. Directory Structure
Instrument Control System Seminar, 20 th -24 th October 2014 Goal: changes to existing libraries are subject to a controlled process of impact analysis and approval, before they are implemented. Also applies to bug reports. Status: not enforced, moderate adoption of existing JIRA system at: Configuration control
Instrument Control System Seminar, 20 th -24 th October 2014 Naming conventions: Taken as is from the vendor for ST (object definitions, object instances: e.g. for functions, structures, etc.), with minor ESO adaptations. Not applicable for IL. Missing for FBD (comments are welcome). Example at: Coding Standards "FUNCTION BLOCK NAME""FB_" "FUNCTION NAME""F_" "PROG NAME""P_" "STRUCT NAME""T_" "ENUM NAME""E_" "FUNCTION BLOCK NAME""FB_" "FUNCTION NAME""F_" "PROG NAME""P_" "STRUCT NAME""T_" "ENUM NAME""E_"
Instrument Control System Seminar, 20 th -24 th October 2014 version injection for Siemens S7 demonstrated version injection for Beckhoff demonstrated demonstration of rudimentary code inspection for Beckhoff document with proposed Coding Conventions under review Evaluation of PLC Technology as a Standard Control System Development Platform at ESO GEN-TRE-ESO Coding Conventions for IEC PLC Development ESO Conclusion
Instrument Control System Seminar, 20 th -24 th October 2014 The END
Instrument Control System Seminar, 20 th -24 th October 2014 Reserve Slides
Instrument Control System Seminar, 20 th -24 th October 2014