From be4aafdd89ef3ec93fbc98465f6a19db7b3e5eff Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Thu, 16 Oct 2025 18:25:56 +0200 Subject: [PATCH] readme fix bad syntax --- README.md | 44 ++++++++++++++++++++++++++++++++++---------- create_client.md | 24 +++++++++++++----------- create_server.md | 23 +++++++++++++---------- 3 files changed, 60 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index e86d409..ec3ce2b 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/create_client.md b/create_client.md index 4ef95a4..f3ad645 100644 --- a/create_client.md +++ b/create_client.md @@ -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" diff --git a/create_server.md b/create_server.md index 392380b..be97fff 100644 --- a/create_server.md +++ b/create_server.md @@ -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"