This program combines Shell scripting and C programming to process and analyze data stored in a .dat file (c-wire_v25.dat). The results are output to .csv files, which provide insights based on user requests. Additionally, a graph file is generated to visually represent the analyzed data for better comprehension. Our program also plays music during its run.
Before running this program, ensure you have the following tools installed on your machine:
- GCC Compiler: Required to compile the C program.
- Gnuplot: To generate graphs for visualizing the processed data.
- Git: To retrieve the latest version of the code.
- Makefile : Check that the tools for using a makefile are installed
To install the necessary tools and ensure your system is up-to-date, run the following commands on a Linux system:
sudo apt update && sudo apt upgradeGCC (GNU Compiler Collection) is a set of compilers for different programming languages, including C. This section explains how to install GCC on different operating systems and how to verify its installation.
- Update your package list:
sudo apt update
- Install GCC:
The build-essential package includes GCC, along with other essential tools like make and libraries needed for compiling software.
sudo apt install build-essential
- Verify the insatllation
gcc --versionYou should see the installed version of GCC.
-
Install MinGW (Minimalist GNU for Windows): -Download the MinGW installer from the official site: MinGW-w64(https://sourceforge.net/projects/mingw/) -Run the installer and select the version of GCC you want to install -Makesure to add thte bin directory to your system's PATH
-
Verify the installation
-Open Commande Prompt and ru
gcc --version
-You should see the insatlled version of GCC
Gnuplot is a software tool used to generate plots and graphs from data files. Follow the steps below to install Gnuplot depending on your operating system.
- Update your package list:
sudo apt update
- Install Gnuplot
sudo apt install gnuplot
- Verify the installation:Run the folowing command:
gnuplot --version
Exemple output
gnuplot 5.4 patchlevel 1-
Downoald gnuplot: -Go to the official Gnuplot page: Gnuplot Downloads(https://sourceforge.net/projects/gnuplot/) -Download the installer for Windows.
-
Run the installer: -Follow the installation wizard and install Gnuplot.
-
Add Gnuplot to your system path (optional): -During installation, ensure the option "Add Gnuplot to PATH" is selected.
-
Verify the installation: -Open Command Prompt or PowerShell and type:
gnuplot --version
-You should see the installed version of Gnuplot.
-
On Linux
sudo apt update sudo apt install git
On Windows -Download git via this link :https://git-scm.com/
-
1. Find the git repository url
-If the repository is on a platform such as GitHub, GitLab or Bitbucket, retrieve the HTTPS or SSH URL. For example : -HTTPS : https://github.com/utilisateur/projet.git -SSH : git@github.com:utilisateur/projet.git2.Exécutez la commande git clone
-Navigate to the directory where you want to clone the repository: ```bash cd /Path/to/folders ``` -Clone the repository: ```bash git clone https://github.com/utilisateur/projet.git ``` -Or, if you use SSH : ```bash git clone git@github.com:utilisateur/projet.git ``` -
```bash cd projet ``` -
1. Pulling changes from the remote repository
git pull
2. Check the condition of your local depot:
git status
```bash
sudo apt update
sudo apt install make
```
-Install make via MinGW or Cygwin, or use an environment such as WSL (Windows Subsystem for Linux).
-Retrieve the latest version of the project using Git:
```bash
git clone https://github.com/your-username/C_WIRE.git
cd C_WIRE
```
-Run the Shell script with the required parameters:
bash c_wire.sh <Data_file> <station_type> <consumer_type> [ID]-<Data_file>: The name of the file containing the data: c-wire_v25.dat
-<station_type>: Type of station. Valid options: hvb - High Voltage Bus hva - High Voltage Area lv - Low Voltage
-<consumer_type>: Type of consumer. Valid options: comp - Company indiv - Individual all - All consumers
-[ID] (Optional): Specific Station ID (1 to 5). If omitted, all stations will be processe
- Run GnuPlot
- Click on file at the top left, then on change directory and enter the main folder so that it finds our .gp file to launch the execution of the graph
- Then type :
load 'graphique.gp' - A png with our graph will appear in the tests folder.
-To process all stations of type hvb for individual consumers:
bash c_wire.sh c-wire_v25.dat hvb comp-To process station ID 3 of type hva for company consumers:
bash c_wire.sh c-wire_v25.dat hva comp 3- Data Analysis: Results are saved in a .csv file in the the tests/ directory.
-Graphical Representation: Generated graphs are stored in the Graphs/ directory.
At the end of execution, the script also displays the total runtime in seconds.
The repository is organized as follows:
Cwire/
├── codeC/
│ ├── c_wire.c # Fichier source C
│ ├── c_wire.exe
│ ├── fonctions.c
│ ├── fonctions.h
│ ├── MakeFile # Exécutable compilé
│ └── musique.mp3 # Fichier audio associé
├── Input/
│ └── c-wire_v00.dat # Fichier de données d'entrée
├── tests/
│ └── lv_all_0.csv # Répertoire pour les tests (vide ou à remplir)
├── c_wire.sh # Script principal pour exécuter le projet
├── graphique.gp # Script Gnuplot pour les graphiques
├── projet.pdf # Documentation du projet
├── README.md # Documentation générale du projet