PCP3 Package Overview

PCP3 is written in Python following object-oriented programming (OOP) principles, meaning that data and methods are organized in terms of distinct “objects” with clearly defined attributes and behaviors, which are only instantiated (given specific values) in the __main__.py method. This modular approach (see Figure below) greatly simplifies the process of adding additional hardware and sequences by isolating these blocks of code into distinct submodules (folders) that are separate from the more complex user interface and main methods. In order to add a new sequence to the program, for example, the user can simply clone one of the existing light blue .py files, rename it and modify the contents to contain the desired motion/tool commands, and place it in the sequence folder. On startup, PCP3 automatically attempts to load any new sequences, axes, or tool .py files, after checking for compiler errors.

_images/CodeMap.png

PCP3 also takes advantage of the OOP concept of inheritance to streamline addition of new code files to the program. The grey boxes in the Figure are effectively blueprints (‘Abstract Base Classes’, in Python) for the class declarations (light blue .py files) that inherit from them (signified by grey arrows from the parent to the child class). This system enforces a standardized format for each type of code file. All ‘sequences’ are required to behave following the rules of the parent sequenceSpec class to compile properly, or else they are not loaded when PCP3 starts. In addition to minimizing runtime errors, this approach provides another way to isolate the user from having to deal with repetitive boilerplate code common across many different objects. For example, there is no need to explicitly write logging methods for each sequence, because they already inherit them from the loggerSpec Abstract Base Class. Finally, the main method contains the data structures which hold all of the instantiated objects as well as containing all Menu classes and driving the user interface.