Update Automatic generation of user_model IO of mbsysc projects - subfolder authored by Sebastien Timmermans's avatar Sebastien Timmermans
To automatically generate the *user_model.c/.h* and *user_IO.c/.h* files of projects of mbsysC, this file execute the *Gen_mds_user.exe* that should have been generate under mbsysC *build* folder. To automatically generate the *user_model.c/.h* and *user_IO.c/.h* files of projects of mbsysC, this file execute the *Gen_mds_user.exe* that should have been generate under mbsysC *build* folder.
We provide 3 solutions to update user files automatically: We provide 3 solutions to update user files automatically:
* A python script that iterate automatically in all subfolders * A python script that iterate automatically in all subfolders
* A shell script * A shell script
* A unix shell command * A unix shell command
## Python script ## Python script
See python script in the **ExampleProject** folder: See python script in the **ExampleProject** folder:
[update_user_files.py](https://git.immc.ucl.ac.be/robotran/mbsysc/blob/dev/ExampleProjects/update_user_files.py) [update_user_files.py](https://git.immc.ucl.ac.be/robotran/mbsysc/blob/dev/ExampleProjects/update_user_files.py)
## Shell script ## Shell script
Look at the file to modify the paths, depending on where you put the .sh :) Look at the file to modify the paths, depending on where you put the .sh :)
[automatic_user_file_generation.sh](uploads/dedbf5e9c3b2ab2536f65bef92b7c659/automatic_user_file_generation.sh) [automatic_user_file_generation.sh](uploads/dedbf5e9c3b2ab2536f65bef92b7c659/automatic_user_file_generation.sh)
The list of all project is (for now) hard-coded. The list of all project is (for now) hard-coded.
Only tested on Windows 10, bash command *MINGW64* Only tested on Windows 10, bash command *MINGW64*
To call it, open bash windows and type : To call it, open bash windows and type :
```bash ```bash
./automatic_user_file_generation.sh ./automatic_user_file_generation.sh
``` ```
It should say that all files are correctly created. It should say that all files are correctly created.
**Note** **Note**
```./Gen_mbs_user "mbs_file.mbs" fichier ``` ```./Gen_mbs_user "mbs_file.mbs" fichier ```
avec fichier= avec fichier=
"all" -> Tous, pareil que de ne rien mettre "all" -> Tous, pareil que de ne rien mettre
"user_models" "user_models"
"user_IOs" "user_IOs"
"user_all_id" "user_all_id"
"user_hard_param" "user_hard_param"
## Unix single line command ## Unix single line command
Open a terminal in *mbsysc* folder then call `find . -name \*.mbs -exec "./MBsysC/build/bin/Gen_mds_user" {} \;`. Open a terminal in *mbsysc* folder then call `find . -name \*.mbs -exec "./MBsysC/build/bin/Gen_mds_user" {} \;`.
- `find` will list all files (recursively) ending with *.mbs*; - `find` will list all files (recursively) ending with *.mbs*;
- `-exec ...` will call `Gen_mds_user` with each file found. - `-exec ...` will call `Gen_mds_user` with each file found.
\ No newline at end of file
## output path
Since !698, output folder can be specified:
Saving directory of the generated user C-file can be specified by the argument:
* **`sub:`** : save them in _userfctR/mbs_name_ (name of the mbs in the file);
* **`sub:any/path`** : save them in the provided path (absolute or relative);
* **`sub:PRJPATH/myfolder`** : save them in the provided path, replacing **`PRJPATH`** by the one determined when the mbs file was loaded;
* Omitting the new argument has the same behavior than the previous version;
\ No newline at end of file