agl-demo-control-panel: Update documentation
[AGL/documentation.git] / docs / 06_Component_Documentation / 09_AGL_Demo_Control_Panel.md
1 ---
2 title: AGL Demo Control Panel
3 ---
4 # AGL Demo Control Panel
5
6 ## Introduction
7
8 This document describes the design and usage of the **AGL Demo Control Panel**, a **Qt5-based** tool that allows you to control and interact with various **Automotive Grade Linux (AGL)** demo applications. The tool uses **Kuksa.val** and **CAN frame messages** to communicate with the target machine that runs the AGL image(s). You can use the tool to perform tasks such as starting and stopping scripts, changing the vehicle speed and engine RPM, adjusting the HVAC settings, and providing Steering Inputs. The tool is designed to **demonstrate** the capabilities and features of AGL in a **user-friendly** and **interactive** way.
9 ### Application Overview
10
11 To use the control panel, you need to connect the main machine that runs the control panel to the target machine that runs the AGL image(s) using a **LAN/ethernet cable**. You also need to configure the IP address of the Kuksa server and set your preferences in the tool’s settings menu.
12
13 ![Layers_And_Extensions](images/AGL-Demo-Control-Panel/Application-Logic.png)
14 ## Installation  
15
16   
17
18 - _Note_:
19         If errors occur in Debian based/Rasbian OS during installation, follow the steps mentioned below and skip to step 2:
20 ```bash
21 $ nano requirements.txt
22 # -> Comment pyqt5 dependency using "#"
23 $ sudo apt install python3-pyqt5 python3-qtpy pyqt5-dev-tools python3-pyqt5.qtsvg -y
24 ```
25
26 - Step 1
27 ```bash
28 $ python3 -m venv control-panel
29 $ source control-panel/bin/activate
30 ```
31
32 - Step 2
33 ```bash
34 $ pip3 install -r requirements.txt
35 $ pyrcc5 assets/res.qrc -o res_rc.py
36 ```
37 ## Setup
38
39 Before using the  `AGL Demo Control Panel`, we need to make sure to run the Kuksa.val server  and also have our `can0` interface set up (Optional).
40
41 ### 1. Connect the Machines
42
43 First, we need to connect the machines, i.e. the host machine (Running the control panel) and the target machine (running the AGL image) via LAN or a bridged network (QEMU or VM) 
44 ### 2. CAN interface (WIP)
45
46 To set up the CAN interface between the Host system and the target machine(s) we use [cannelloni](https://github.com/mguentner/cannelloni),
47
48 1. Create the virtual CAN interface with the command:
49
50         ```bash
51         $ sudo ip link add dev can0 type vcan
52         ```
53
54 2. On both machines, bring the virtual CAN interface online with the command: 
55
56         ```bash
57         $ sudo ip link set up can0
58         ```
59
60 3. Install cannelloni from its [GitHub repository](https://github.com/mguentner/cannelloni) and run cannelloni with the following commands. 
61
62         _Note_: `cannelloni` is available in AGL, just add `IMAGE_INSTALL:append = " cannelloni"`       to your `conf/local.conf`
63
64         Host Machine (Running `AGL Demo Control Panel`)
65         ```bash
66         cannelloni -I can0 -R <target-ip> -r 20000 -l 20000
67         ```
68          Target Machine (Running AGL image)
69         ```bash
70         cannelloni -I can0 -R <host-ip> -r 20000 -l 20000 -p
71         ```
72
73         You should now be able to send and receive CAN messages between the two machines using the vcan interface and cannelloni.
74
75 ### 3. Configuration for Kuksa-val-server/ Kuksa databroker
76
77 Run the `kuksa-val-server`/`databroker` on `0.0.0.0` by either restarting the server, editing `/etc/default/kuksa-databroker` or add the `agl-demo-preload` as a feature to your build of AGL.  The server should be started using the `--address 0.0.0.0` argument.
78
79 Now, you can create a custom configuration to save your specific preferences for the settings page by creating the `*.ini*` files in the,
80 -  `/etc/agl-demo-control-panel.ini`
81 - `$HOME/.local/share/agl-demo-control-panel/config.ini`
82         
83 ```python
84 [default]
85 preferred-config=AGL-kuksa-val-server
86
87 # [cutom-config-template]
88 # ip=<ip address>
89 # port=<port number>
90 # protocol=<ws|grpc>       # ws/grpc -> kuksa-val-server, grpc -> databroker
91 # insecure=<true|false>    
92 # cacert=<default|/path/to/CA.pem>
93 # token=<default|/path/to/token>      
94 # tls_server_name=<name>
95
96 [kuksa-val-server]
97 ip=localhost
98 port=8090
99 protocol=ws
100 insecure=false
101 token=default
102 tls_server_name=
103 ```
104
105 ### 4. Start AGL Demo Control Panel
106
107 1. To start the control panel
108         ```
109         $ cd /Path/to/agl-demo-control-panel
110         $ source control-panel/bin/activate
111         $ python -u main.py
112         ```
113
114 ![Layers_And_Extensions](images/AGL-Demo-Control-Panel/Dashboard.png)
115
116 2. Go to settings
117         - Start (load default config from drop-down menu)
118         -  Configure: make changes as required
119                 - IP-Address
120                 - Port
121                 - Secure Mode: if toggled **"on"**, specify the `CA.pem File`
122                 - Protocol: websocket ← ? → gRPC
123                 - TLS Server Name
124                 - JWT/Auth Token path 
125                 - CA.pem certificate path
126         - Start/Stop
127         - Reconnect
128         - Page settings: Configure the visibility of pages and switch between CAN and Kuksa messages by using the toggle for the same.
129
130 ![Layers_And_Extensions](images/AGL-Demo-Control-Panel/Settings_Page.png)
131
132 1. Navigate to the desired page using the provided buttons at the bottom
133
134 |  |
135 |---|
136 | ![Layers_And_Extensions](images/AGL-Demo-Control-Panel/IC.png) |
137
138 |  |  |
139 |---|---|
140 | ![Layers_And_Extensions](images/AGL-Demo-Control-Panel/HVAC.png) | ![Layers_And_Extensions](images/AGL-Demo-Control-Panel/SC.png) |