Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
fjpacheco committed Jun 15, 2024
1 parent 27d7e9f commit d1d5ca5
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 5 deletions.
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ This parameters are fetched from the [OpenWeatherMap API](https://openweathermap
## Commands
It would be nice to accept commands from TUI to simulate deviations fixes. Something like `<parameter> <increase/decrease> <amount>`

## Usage Instructions
## Usage Instructions to Simulator of Packages

### Docker
The repository includes a **Makefile** that encapsulates various commands used frequently in the project as targets. The targets are executed by invoking:

* **make \<target\>**:
Expand All @@ -34,3 +36,75 @@ Available targets are:
* **docker-image**: Builds the images to be used. This target is used by **docker-compose-up**, so it can be used to test new changes in the images before starting the project.

Important Note: This service assumes a running instance of RabbitMQ and connects to it. Therefore, to run this service, it is necessary to first have the **measurements** service running. Please make sure to also check [measurements repository](https://github.com/Hanagotchi/measurements).

### CLI (command-line interface) with Virtual Environment

To run the simulator using the CLI, you need to install the dependencies. Its highly recommended to use a virtual environment. You can create a virtual environment and install the dependencies by running the following commands:

```bash
cd simulator
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```

After installing the dependencies, you can run the simulator by executing the following command:

```bash
cd src
python3 main.py simulator
```

By default, the simulator assigns a random device ID to the sensor. If you want to specify a device ID, you can pass it as an argument:

```
cd src
python3 main.py simulator --id-device <string>
```

## Usage Instructions to Send Custom Package

### Docker

Sorry, this is not available yet. . .

### CLI (command-line interface) with Virtual Environment

#### Sending a Simple Package with custom parameters

To send a custom package, you can run the following command:

```bash
cd src
python3 main.py simple-package --id-device <string> --temperature <float> --light <float> --humidity <int> --watering <int>
```

or reduce the typing by using the short version of the arguments:

```bash
cd src
python3 main.py simple-package -i <string> -t <float> -l <float> -h <int> -w <int>
```

By executing the command above, the simulator will send a package with the specified parameters.


#### Sending a deviated package

To send a deviated package, you can run the following command:

```bash
cd src
python3 main.py deviated-package --id-device <string> --plant-name <string> --deviated-temperature <higher|lower|ideal> --deviated-light <higher|lower|ideal> --deviated-humidity <higher|lower|ideal> --deviated-watering <higher|lower|ideal>
```

or reduce the typing by using the short version of the arguments:

```bash
cd src
python3 main.py deviated-package -i <string> -pn <string> -dt <higher|lower|ideal> -dl <higher|lower|ideal> -dh <higher|lower|ideal> -dw <higher|lower|ideal>
```

By executing the command above, the simulator will send a package with the specified deviations.

The parameters `deviated-temperature`, `deviated-light`, `deviated-humidity`, and `deviated-watering` can be set to `higher`, `lower`, or `ideal`. The simulator will generate a package with the specified deviations based on the plant's ideal values [indicated in the dataset](src/resources/plants_dataset.csv) and rules defined in measurements service.
8 changes: 4 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

@app.command("deviated-package")
def deviated_package(
id_device: str = typer.Option(..., "--id_device", "-i"),
plant_name: str = typer.Option(..., "--plant_name", "-pn",
id_device: str = typer.Option(..., "--id-device", "-i"),
plant_name: str = typer.Option(..., "--plant-name", "-pn",
help="Botanical name of the plant"),
deviated_temperature: Deviated = typer.Option(Deviated.IDEAL,
"--deviated-temperature",
Expand All @@ -35,14 +35,14 @@ def deviated_package(

@app.command("simulator")
def simulator(id_device: Optional[str] = typer.Option(None,
"--id_device",
"--id-device",
"-i")):
execute_simulator(id_device)


@app.command("simple-package")
def simple_package(
id_device: str = typer.Option(..., "--id_device", "-i"),
id_device: str = typer.Option(..., "--id-device", "-i"),
temperature: Optional[float] = typer.Option(None,
"--temperature",
"-t",
Expand Down

0 comments on commit d1d5ca5

Please sign in to comment.