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 # unisim_cpp
## Guidelines ## Guidelines
There are a few rules to follow when creating a big project with multiple people. There are a few rules to follow when creating a big project with multiple people.
### 1 Pragma once ### 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 ### 2 File naming
Change this setting in Qt creator \
Edit > Preferences > C++ > File Naming > Headers > Suffix Change this setting in Qt creator
Change this to hpp > Edit > Preferences > C++ > File Naming > Headers > Suffix
Change this setting in Qt creator \ > Change this to hpp
Edit > Preferences > C++ > File Naming > Sources > Suffix
Change this to cpp Change this setting in Qt creator
> Edit > Preferences > C++ > File Naming > Sources > Suffix
> Change this to cpp
### 3 How to write type names ### 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 Use snake case and make the first letter a capital letter to show that it is a type name
### 4 Linting rules ### 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 ### 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. 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 ## 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) [How to create a server sim](create_server.md)
## Setup ## Setup
### Requirements ### Requirements
Fedora packages: Fedora packages:
```bash ```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 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 ### 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. 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 ```bash
git clone --recurse-submodules git@bitbucket.org:belgiantrain/unisim-cpp.git git clone --recurse-submodules git@bitbucket.org:belgiantrain/unisim-cpp.git
``` ```
### Server build ### Server build
```bash ```bash
cmake -S . -B ./build/ -G Ninja cmake -S . -B ./build/ -G Ninja
cmake --build ./build/ --target unisim_server #your sims (sim_*) cmake --build ./build/ --target unisim_server #your sims (sim_*)
``` ```
### Client build ### Client build
```bash ```bash
cmake -S . -B ./build/ -G Ninja cmake -S . -B ./build/ -G Ninja
cmake --build ./build/ --target unisim_client #your ui (ui_*) cmake --build ./build/ --target unisim_client #your ui (ui_*)
``` ```
### Running the project ### Running the project
Copy the libsim_* and/or libui_* together with the server or client to /usr/local/bin Copy the libsim_* and/or libui_* together with the server or client to /usr/local/bin
```bash ```bash
sudo cp build/bin/unisim_* build/bin/libsim_* build/bin/libui_* /usr/local/bin/ 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 for more info on each executables commandline params run with -h option
### Enabling CAN bus on Raspberry Pi ### Enabling CAN bus on Raspberry Pi
Append this to /boot/config.txt Append this to /boot/config.txt
``` ```
dtparam=spi=on dtparam=spi=on
@@ -74,6 +97,7 @@ sudo reboot
``` ```
### Autostart server on boot ### Autostart server on boot
Copy unsim_cpp.service to /etc/systemd/system Copy unsim_cpp.service to /etc/systemd/system
If you use can you could copy can_dev.service as well If you use can you could copy can_dev.service as well
(Remove -c can0 if you don't use can) (Remove -c can0 if you don't use can)
+12 -10
View File
@@ -1,14 +1,16 @@
## Client UI ## Client UI
To create a new simulator ui follow these steps To create a new simulator ui follow these steps
1) Make sure the client folder is folded down 1. Make sure the client folder is folded down
2) Right click on unisim_client and select Add new 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 3. Choose Qt in files and classes and then select Qt widgets designer form class + Choose
4) Select Mainwindow + Next 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 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 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 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 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 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 OPTIONAL Add id_to_label is optional if you want to use value labels
```cpp ```cpp
#pragma once #pragma once
@@ -33,7 +35,7 @@ class Test_Sim : public Simulator_base
Ui::Test_Sim *ui; 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 OPTIONAL Add id_to_label is optional if you want to use value labels switch case is also an option instead of if
```cpp ```cpp
#include "test.hpp" #include "test.hpp"
+12 -9
View File
@@ -1,14 +1,17 @@
## Server simulator ## Server simulator
To create a simulator server follow these steps 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 1. Make sure the server folder is folded down
3) Choose C/C++ in files and classes and then select C++ class + Choose 2. Right click on unisim_server and select Add new
4) Change the classname to the name of your sim use underscores as spaces, don't forget classnames always start with a capital letter 3. Choose C/C++ in files and classes and then select C++ class + Choose
5) Set as base Simulator_base and check "Add Q_Object" 4. 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 server/simulators folder + Next 5. Set as base Simulator_base and check "Add Q_Object"
7) Set add to project to None + Finish 6. Select the path by clicking browse and make sure it is in the server/simulators folder + Next
8) Refresh CMake by right clicking on the project name + Run Cmake, it should show your sim as sim_ + filename 7. Set add to project to None + Finish
9) Change the hpp file as following. This is an example out of test sim 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 ```cpp
#pragma once #pragma once
#include "simulator_base.hpp" #include "simulator_base.hpp"