fix bad syntax
This commit is contained in:
2026-02-14 14:32:12 +01:00
parent 474906c4af
commit be4aafdd89
3 changed files with 60 additions and 31 deletions
+34 -10
View File
@@ -1,50 +1,72 @@
# unisim_cpp
## Guidelines
There are a few rules to follow when creating a big project with multiple people.
### 1 Pragma once
Change this setting in Qt creator \
Edit > Preferences > C++ > File Naming > Headers > Include guard template and check the box "Use pragma once instead"
Change this setting in Qt creator
> Edit > Preferences > C++ > File Naming > Headers > Include guard template and check the box "Use pragma once instead"
### 2 File naming
Change this setting in Qt creator \
Edit > Preferences > C++ > File Naming > Headers > Suffix
Change this to hpp
Change this setting in Qt creator \
Edit > Preferences > C++ > File Naming > Sources > Suffix
Change this to cpp
Change this setting in Qt creator
> Edit > Preferences > C++ > File Naming > Headers > Suffix
> Change this to hpp
Change this setting in Qt creator
> Edit > Preferences > C++ > File Naming > Sources > Suffix
> Change this to cpp
### 3 How to write type names
Use snake case and make the first letter a capital letter to show that it is a type name
### 4 Linting rules
Please run clang-format using the given .clang-fomrat file and check that linting passes on bitbucket piplines
Please run clang-format using the given .clang-format file and check that linting passes on bitbucket piplines
### 5 No broken code in main branch
Always use a pull request to merge code in the main branch, this makes it so that no broken code can get in the main branch.
## Creating a new simulator
[How to create a client ui](create_client.md)\
[How to create a client ui](create_client.md)
[How to create a server sim](create_server.md)
## Setup
### Requirements
Fedora packages:
```bash
sudo dnf install gtest-devel cmake git ninja-build qt6-qttools-devel qt6-qtsvg-devel qt6-qtwebsockets-devel qt6-qtserialport-devel libsocketcan qt6-qtserialbus-devel libgpiod-devel
```
### Clone repo
Easiest way to download a repo from our bitbucket is to use an ssh-key. Put or generate the key on the system and copy the private key to your bitbucket account. (Cog > Personal Bitbucket Settings > SSH keys) Then run this command on the system.
```bash
git clone --recurse-submodules git@bitbucket.org:belgiantrain/unisim-cpp.git
```
### Server build
```bash
cmake -S . -B ./build/ -G Ninja
cmake --build ./build/ --target unisim_server #your sims (sim_*)
```
### Client build
```bash
cmake -S . -B ./build/ -G Ninja
cmake --build ./build/ --target unisim_client #your ui (ui_*)
```
### Running the project
Copy the libsim_* and/or libui_* together with the server or client to /usr/local/bin
```bash
sudo cp build/bin/unisim_* build/bin/libsim_* build/bin/libui_* /usr/local/bin/
@@ -60,6 +82,7 @@ unisim_server
for more info on each executables commandline params run with -h option
### Enabling CAN bus on Raspberry Pi
Append this to /boot/config.txt
```
dtparam=spi=on
@@ -74,6 +97,7 @@ sudo reboot
```
### Autostart server on boot
Copy unsim_cpp.service to /etc/systemd/system
If you use can you could copy can_dev.service as well
(Remove -c can0 if you don't use can)
+13 -11
View File
@@ -1,14 +1,16 @@
## Client UI
To create a new simulator ui follow these steps
1) Make sure the client folder is folded down
2) Right click on unisim_client and select Add new
3) Choose Qt in files and classes and then select Qt widgets designer form class + Choose
4) Select Mainwindow + Next
5) Change the classname to the name of your sim use underscores as spaces, don't forget classnames always start with a capital letter
6) Select the path by clicking browse, and make sure it is in the client/simulators folder + Next
7) Set add to project to None + Finished
8) Refresh CMake by right clicking on the project name + Run Cmake, it should show your sim as ui_ + filename
9) Change the hpp file as following. This is an example out of test sim
To create a new simulator ui follow these steps
1. Make sure the client folder is folded down
2. Right click on unisim_client and select Add new
3. Choose Qt in files and classes and then select Qt widgets designer form class + Choose
4. Select Mainwindow + Next
5. Change the classname to the name of your sim use underscores as spaces, don't forget classnames always start with a capital letter
6. Select the path by clicking browse, and make sure it is in the client/simulators folder + Next
7. Set add to project to None + Finished
8. Refresh CMake by right clicking on the project name + Run Cmake, it should show your sim as ui_ + filename
9. Change the hpp file as following. This is an example out of test sim
OPTIONAL Add id_to_label is optional if you want to use value labels
```cpp
#pragma once
@@ -33,7 +35,7 @@ class Test_Sim : public Simulator_base
Ui::Test_Sim *ui;
};
```
10) Change the cpp file as following. This is an example out of test sim. PUSH_UI_ITEM is the method to add new QWidgets to the similator UI
10. Change the cpp file as following. This is an example out of test sim. PUSH_UI_ITEM is the method to add new QWidgets to the similator UI
OPTIONAL Add id_to_label is optional if you want to use value labels switch case is also an option instead of if
```cpp
#include "test.hpp"
+13 -10
View File
@@ -1,14 +1,17 @@
## Server simulator
To create a simulator server follow these steps
1) Make sure the server folder is folded down
2) Right click on unisim_server and select Add new
3) Choose C/C++ in files and classes and then select C++ class + Choose
4) Change the classname to the name of your sim use underscores as spaces, don't forget classnames always start with a capital letter
5) Set as base Simulator_base and check "Add Q_Object"
6) Select the path by clicking browse and make sure it is in the server/simulators folder + Next
7) Set add to project to None + Finish
8) Refresh CMake by right clicking on the project name + Run Cmake, it should show your sim as sim_ + filename
9) Change the hpp file as following. This is an example out of test sim
To create a simulator server follow these steps
1. Make sure the server folder is folded down
2. Right click on unisim_server and select Add new
3. Choose C/C++ in files and classes and then select C++ class + Choose
4. Change the classname to the name of your sim use underscores as spaces, don't forget classnames always start with a capital letter
5. Set as base Simulator_base and check "Add Q_Object"
6. Select the path by clicking browse and make sure it is in the server/simulators folder + Next
7. Set add to project to None + Finish
8. Refresh CMake by right clicking on the project name + Run Cmake, it should show your sim as sim_ + filename
9. Change the hpp file as following. This is an example out of test sim
```cpp
#pragma once
#include "simulator_base.hpp"