Hide last authors
Alexander Schulz-Rosengarten 6.1 1 {{toc maxLevel="2"/}}
Alexander Schulz-Rosengarten 1.1 2
3 = Components =
4
5 The component diagram below shows the architecture of generated and created Railway Controller.
6
7 [[image:attach:components.png]]
8
Alexander Schulz-Rosengarten 9.1 9
Alexander Schulz-Rosengarten 1.1 10 == SCCharts Contoroller ==
11
Richard Kreissig 17.1 12 {{code}}
Alexander Schulz-Rosengarten 1.1 13 scccontroller.h <compiled-sccchart>.c
Richard Kreissig 17.1 14 {{/code}}
Alexander Schulz-Rosengarten 1.1 15
16 This component is the compiled Controller-SCChart.
17
18 The interface offers an the sequential synchronous tick function and additionally access to some internal variables to determine the internal state of the SCChart during execution. Furthermore the component uses the provided hostcode-interface to control the railway.
19
20 == Hostcode ==
21
Richard Kreissig 17.1 22 {{code}}
Alexander Schulz-Rosengarten 1.1 23 hostcode.h hostcode.c
Richard Kreissig 17.1 24 {{/code}}
Alexander Schulz-Rosengarten 1.1 25
Alexander Schulz-Rosengarten 5.1 26 This component provides an interface to affect the railway and request events.
Alexander Schulz-Rosengarten 1.1 27
Alexander Schulz-Rosengarten 5.1 28 The interface provides shorter and simpler access to most of the railway API. To prevent conflicts with existing function names all functions in our interface are prefixed with //rail//.
29
Alexander Schulz-Rosengarten 1.1 30 Most controls and requests are forwarded to the controller maintaining the synchronous environment of the tick-function. Some controls which do not require this maintenance are directly forwarded to the railway API.
31
Alexander Schulz-Rosengarten 3.1 32 The hostcode header contains the general documentation for any hostcode call used in the SCChart.
33
Alexander Schulz-Rosengarten 1.1 34 == Controller ==
35
Richard Kreissig 17.1 36 {{code}}
Alexander Schulz-Rosengarten 1.1 37 controller.h defaults.h controller.c
Richard Kreissig 17.1 38 {{/code}}
Alexander Schulz-Rosengarten 3.1 39
Alexander Schulz-Rosengarten 7.1 40 The core controller component sets up a connection to the railway, maintains an environment for the synchronous tick-function and invokes the tick-function in a loop.
41
42 Additionally some time tracking is performed to determine time consumption of the tick function and its environment.
43
44 To increase the robustness of the system the controller checks internal permissions of the SCChart-Controller against detected trains on the railway.
45
Alexander Schulz-Rosengarten 3.1 46 == State Monitor ==
47
Richard Kreissig 17.1 48 {{code}}
Alexander Schulz-Rosengarten 4.1 49 statemonitor.h statemonitor.c
Richard Kreissig 17.1 50 {{/code}}
Alexander Schulz-Rosengarten 4.1 51
csp 11.1 52 The state monitor component allows a thread-safe communication between connected GUIs and the running controller. This communication is also tick-safe meaning that changes are only applied at tick-borders. In addition to that the communication is mutual excluded without blocking the controller thread and thus the controller remains a reactive system.
Alexander Schulz-Rosengarten 8.1 53
Alexander Schulz-Rosengarten 9.1 54 Furthermore it allows the generation of the current state of the controller in JSON format.
55
Alexander Schulz-Rosengarten 4.1 56 == GUI Server ==
57
Richard Kreissig 17.1 58 {{code}}
Alexander Schulz-Rosengarten 4.1 59 guiserver.h guiserver.c
Richard Kreissig 17.1 60 {{/code}}
Alexander Schulz-Rosengarten 5.1 61
csp 11.1 62 The GUI server allows multiple GUI clients concurrently connecting to the controller. The number of available slots is defined in the guiserver header.
Alexander Schulz-Rosengarten 10.1 63
Soeren Domroes 19.1 64 The communication is established via TCP and the message format is JSON. Each client can request the current status of the controller and interact with some commands changing most of the important properties of each train, especially the schedule. The detailed communication format and capabilities are documented in the [[doc:Projects.Archive.Railway Project (summer term 2014).Documentation.C Controller.TCP Communication.WebHome]] section.
Alexander Schulz-Rosengarten 10.1 65
csp 11.1 66 Most controls are performed delayed and thread-safe with the state monitor, some are directly performed via the hostcode component. Changes of the same property from different clients is processed with first-come-first-serve-principle which may cause lost update writes but will not affect the integrity of the controller.
Alexander Schulz-Rosengarten 10.1 67
Alexander Schulz-Rosengarten 5.1 68 = Interaction =
69
Alexander Schulz-Rosengarten 6.1 70 == GUI ==
71
Soeren Domroes 18.1 72 The controller allows multiple [[doc:Projects.Archive.Railway Project (summer term 2014).Documentation.C Controller.GUIs.WebHome]] to connect and interact with the controller.
Alexander Schulz-Rosengarten 6.1 73
74 == Interrupts ==
75
Alexander Schulz-Rosengarten 5.1 76 === Quit, Pause and Cleanup ===
77
78 While running the console the following user inputs are provided by the controller:
79
80 * **CTRL+C** (SIGINT)** **quits the controller
81 * **CTRL+\** (SIGQUIT)** **cleans up
82 * **CTRL+Z **(SIGSTP) pauses and continues