## 3 Results
### Description of Developed Software Tool: \"PetriNet editor + PetriNet engine\"
#### 3.1.1 Presentation Layer--PetriNet Editor  
As the basis of the presentation layer (GUI) of the application, we decided to use the modeling tool PNEditor, which was necessary to modify and adapt to the system designed by us. To illustrate, we present the following Figure 5. Here you can see the original PNEditor application, which we implemented our designed solution in. The step of enabling the generation of the control algorithm itself is preceded by a set of dependencies that the user in the system is forced to perform. First of all, it is necessary to select the board for which the code is to be generated. We have implemented support for three types of Arduino boards, namely Nano, Uno and Mega 2560. It is also necessary to determine the parameters needed to create the correct communication path, which is the setting of the serial port through which the selected board will communicate with the computer. Part of this setting is also the possibility to specify whether the user wants to keep temporary files created during code generation in the directory structure of the application, and the choice of an extended compilation listing in the log. Secondly, the basis for generating the control algorithm is the association of the Petri net with the individual components of the Arduino. We implemented the support of the association to the places and also the transitions of the Petri net. After right-clicking on the selected element, the user has the option to specify this association, which is specified by selecting the Arduino pin, which must be selected based on the required functionality. Support for digital and analog I/O (input/output) as well as specific components such as the servo motor and seven-segment display was successfully implemented. By selecting the required component, the availability of free pins on the board that can be associated is adjusted based on an agreed convention. For example, the connection of a seven-segment display itself requires eight digital pins for control, but also one virtual control pin, which gives us the number that the display will currently display. It is called a virtual pin because it does not need to be physically connected to the board. However, it is necessary for the ability to transfer information and control the board. By selecting this component, the system automatically reserves the first nine digital pins of the board, which the user no longer has the possibility to associate with another element of the Petri net, thus avoiding collisions and conflicts in control. All user-defined properties are added to the output.pflow file under the individual added XML elements of the file structure. The developed system generates code in C++ language, which represents a full-fledged Arduino project. Its output is a standard.ino file that meets the specifics of the _Wiring_ library used by the Arduino IDE. It defines the exact structure of this file, which consists of two main program blocks, namely the function setup() and loop(). The first is performed only once. The second is performed continuously and repeatedly until the power supply to the board is disconnected. Without their  
Figure 5: GUI of original PNEditor. presence, the program would end in error and never execute. The body of the logic for performing these functions is generated dynamically by the system based on the specifics of the modeled Petri net. The system allows you to upload the generated control algorithm directly to the Arduino microcontroller. For this action, it is necessary to have the Arduino IDE installed on the computer (which the editor is running on), as the compilation and subsequent loading takes place by internal invocation of the command via the command line of the _AvrDude_ utility, which is part of this IDE. In order to avoid possible freezing of the main thread of the GUI application, the overall process of compilation and loading is realised by means of a special thread created specifically for this purpose.