diff --git a/README.md b/README.md index 77ef73f..2016bdf 100644 --- a/README.md +++ b/README.md @@ -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 ` ` -## 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 \**: @@ -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 +``` + +## 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 --temperature --light --humidity --watering +``` + +or reduce the typing by using the short version of the arguments: + +```bash +cd src +python3 main.py simple-package -i -t -l -h -w +``` + +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 --plant-name --deviated-temperature --deviated-light --deviated-humidity --deviated-watering +``` + +or reduce the typing by using the short version of the arguments: + +```bash +cd src +python3 main.py deviated-package -i -pn -dt -dl -dh -dw +``` + +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. \ No newline at end of file diff --git a/src/main.py b/src/main.py index 530f343..cdef38a 100644 --- a/src/main.py +++ b/src/main.py @@ -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", @@ -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",