SCL-T Template Programming for Siemens SCL

SCL-T Template Programming for Siemens SCL

SCL-T Template programming for Siemens SCL Version of August 19, 2019 Jeffrey Goderie SCL-T Template programming for Siemens SCL THESIS submitted in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE in COMPUTER SCIENCE by Jeffrey Goderie born in Steenbergen, the Netherlands Software Engineering Research Group Department of Software Technology Faculty EEMCS, Delft University of Technology CERN Delft, the Netherlands Geneva, Switzerland www.ewi.tudelft.nl www.cern.ch c 2019 Jeffrey Goderie. All rights reserved. SCL-T Template programming for Siemens SCL Author: Jeffrey Goderie Student id: 4006232 Email: [email protected] Abstract Programmable Logic Controllers (PLCs) are used to control large scale systems with thousands of I/O devices. Writing and maintaining the logic for each of these is a cum- bersome task, which is well suited to be abstracted through templating. For this purpose, CERN developed the Unicos Application Builder (UAB). While UAB is successful at tem- plating, it provides no guarantees over the validity of the outcome, leading to erroneous generated code. This is where SCL-T comes in. It builds on the foundation of UAB to facil- itate meta-programming for Siemens’ SCL. Unlike its predecessor, it guarantees syntactic correctness and also draw conclusions regarding the semantic validity of the generated code. Its architecture has been designed in such a way that support for other PLC languages can be added using the same meta-language, reducing the cost of a having a meta-programming language tailored for a specific PLC language. Thesis Committee: Chair: Prof. Dr. Eelco Visser Committee Member: Dr. Casper Bach Poulsen Committee Member: Dr. Christoph Lofi Preface First and foremost, I would like to thank Eelco Visser for guiding me through the process of writing this thesis. Additionally, I would like to extend my gratitude to him, Guido Wachsmuth, and CERN (in particular Ivan Prieto Barreiro and the PLC section) for giving me the opportunity to take on this project on premise at CERN. Jeffrey Goderie Delft, the Netherlands August 19, 2019 iii Contents Preface iii Contents v List of Figures vii 1 Introduction 1 2 Analysis of UAB 3 2.1 Introduction to UAB . 3 2.2 UAB’s limitations . 7 2.3 Evaluation . 18 3 Meta-programming approaches 21 3.1 Introduction to meta-programming . 21 3.2 Separation of languages . 23 3.3 Use time . 26 3.4 Separation of static and dynamic code . 27 3.5 Type of meta language . 28 3.6 Hygiene . 29 3.7 Type Validation in Meta-programming . 31 3.8 Evaluation . 32 4 Language Design 35 4.1 Introduction to SCL-T . 35 4.2 SCL-T by Example . 36 4.3 Data Types . 42 4.4 Functions . 49 4.5 Splicing . 50 5 Language Implementation 53 v CONTENTS 5.1 Architecture . 53 5.2 Type System . 55 5.3 Object language . 56 5.4 Meta-Language . 61 5.5 Mixin Language . 71 6 Evaluation 77 6.1 Evaluation of SCL-T . 77 6.2 Prototype Reception at CERN . 79 6.3 Discussion . 80 7 Conclusions 83 Bibliography 85 A Glossary 91 B Simple Template 93 C Template in Old and New Syntax 95 D Meta-Language Functions and Methods 99 E Meta-Language Syntax 103 vi List of Figures 2.1 UAB’s architecture . 6 2.2 UAB’s operational flow . 7 2.3 Example of a faulty but valid specification file . 9 2.4 Example of UAB output . 9 2.5 Source code . 10 2.6 Output from running Figure 2.5 in UAB . 10 2.7 Mixed indentation . 11 2.8 Missing keyword . 12 2.9 Variable lifting . 12 2.10 Arbitrary code constructs . 13 2.11 List comprehension . 14 2.12 Segmentation . 15 2.13 Representation of the ideal workflow. 17 2.14 More realistic representation of the workflow. 17 3.1 Homogeneous, string-based meta-programming . 24 3.2 Heterogeneous, string-based meta-programming . 24 3.3 Homogeneous meta-programming using Python3’s internal mechanisms . 25 3.4 Run-time evaluation . 26 3.5 Compile-time evaluation . 27 3.6 Hygiene violation . 29 3.7 Precedence violation . 30 4.1 An example SCL-T template, based on an actual production code file. 37 4.2 Excerpt of Figure 4.1: lines 12 to 15. 38 4.3 Excerpt of Figure 4.1: lines 16 to 23. 39 4.4 Excerpt of Figure 4.1: line 25. 40 4.5 Exploded version of the statement in Figure 4.4 . 41 4.6 Mutable objects and copy operations . 43 4.7 Differences between lists and sets . 44 vii LIST OF FIGURES 4.8 Methods to iterate over dictionaries . 45 4.9 Nested pairs . 46 4.10 Usage of <Var(T)> .................................. 47 4.11 Statement concatenation through splicing . 48 4.12 UNKNOWN type propagation . 49 4.13 Programmatic expression formation . 49 4.14 Valid and invalid function overloading . 50 4.15 Mappings from meta-level objects to object-level types . 51 4.16 Arbitrary code constructs . 51 4.17 Example of ‘generateIfElse’ function . 52 4.18 Output of ‘generateIfElse’ function in Figure 4.17 . 52 5.1 SCL-T’s language composition. The arrows indicate the direction of composition. 54 5.2 Meta-language reuse among various PLC languages . 54 5.3 Language composition based on varying the meta-language or the mixin-language . 55 5.4 Format and meaning of the various typing rules used in this chapter. 56 5.5 Type rules for variable declaration . 58 5.6 Type rules for units . 59 5.7 Type rules for function (block) calls . 61 5.8 Type rules related to Structs . 62 5.9 Noteworthy Meta-Language syntax rules . 63 5.10 Subtyping (<:) relationships for the meta-language . 64 5.11 Type rules to iterate over statements . 65 5.12 Type rule for control statements . 66 5.13 Type rules for variable declaration . 66 5.14 Type rules for variable assignment . 67 5.15 Type rule for function declaration . 67 5.16 Type rules for return statements . 68 5.17 Type rule for function calls . 68 5.18 Type rule for the ‘len(e)’ standard function . 68 5.19 Type rules for the ‘.add(...)’ method . 69 5.20 Type rules for the ‘.add(...)’ method . 70 5.21 Field Validation for Compound Devices. ‘AutoOff’ is not a field in T2. 71 5.22 Mixin-Language syntax additions . 72 5.23 Type rules for quoting operations . 73 5.24 Type rules for splicing operations . 74 5.25 Type mappings from meta-level objects to object-level types . 74 5.26 Type rule for expression splicing . 75 5.27 Mapping from meta-variable to object-level AST . 76 C.1 New Syntax . 95 C.2 Old Syntax . 96 C.3 Missing keyword . 96 C.4 Missing Keyword . 97 viii List of Figures E.1 Meta-Language: Start Symbols . 103 E.2 Meta-Language: Types . 103 E.3 Meta-Language: Statements . ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    119 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us