diff --git a/README.md b/README.md
index c6bc40ea..b5bcb1a9 100644
--- a/README.md
+++ b/README.md
@@ -483,6 +483,16 @@ sim.register_activity(
sim.perform_activity("activity_A")
```
+##### Waiting for Activities to Finish
+
+If you want to run multiple activities in a row or just wait for the existing one to finish, you can use
+
+```py
+await sim.wait_for_activity()
+```
+
+to wait until the running activity has finished.
+
#### Activities with Inputs and Outputs
The next code snippet will show how to register and perform activities with inputs and outputs. In particular, we will register an [activity function](#activity-function) `activity_function_with_in_and_outs` that takes an input argument and returns its value multiplied by two. Then, it waits for 0.1 s before concluding the activity.
diff --git a/examples/Sentinel_2_example_notebook/Sentinel2_example_notebook.ipynb b/examples/Sentinel_2_example_notebook/Sentinel2_example_notebook.ipynb
index dc8adf15..1e86fa8b 100644
--- a/examples/Sentinel_2_example_notebook/Sentinel2_example_notebook.ipynb
+++ b/examples/Sentinel_2_example_notebook/Sentinel2_example_notebook.ipynb
@@ -36,24 +36,6 @@
"from matplotlib import patches"
]
},
- {
- "cell_type": "markdown",
- "id": "d286021d",
- "metadata": {},
- "source": [
- "Setting logging level of `paseos` to `INFO` to reduce the verbosity of the execution."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "c0edb116",
- "metadata": {},
- "outputs": [],
- "source": [
- "paseos.set_log_level(\"INFO\")"
- ]
- },
{
"cell_type": "markdown",
"id": "3670f211",
@@ -429,7 +411,7 @@
"source": [
"### 3.c) - Performing activities.\n",
"\n",
- "We can now perform the activities. In scheduling the activities, we assume that data are acquired and stored into the mass memory to be, then, processed during the off part of the satellite duty cycle. Please, refer to: [Copernicus: Sentinel-2](https://www.eoportal.org/satellite-missions/copernicus-sentinel-2#space-segment.).
**N.B.** Notice that, when `sim.perform_activity(...)` is called, the keyword `await` is needed **only for Jupyter notebooks** to ensure the correct management of asynchronous functions. **Remove it otherwise**. "
+ "We can now perform the activities. In scheduling the activities, we assume that data are acquired and stored into the mass memory to be, then, processed during the off part of the satellite duty cycle. Please, refer to: [Copernicus: Sentinel-2](https://www.eoportal.org/satellite-missions/copernicus-sentinel-2#space-segment.).
**N.B.** Notice that PASEOS only supports executing one activity at a time. To wait for the current one to finish, you can use `await sim.wait_for_activity()`."
]
},
{
@@ -453,14 +435,17 @@
" output_event_bbox_info_tmp=[None]\n",
" \n",
" # Run the activity\n",
- " await sim.perform_activity(\"idle_state\", activity_func_args=[10])\n",
+ " sim.perform_activity(\"idle_state\", activity_func_args=[10])\n",
+ " await sim.wait_for_activity()\n",
" \n",
" #Run the activity\n",
- " await sim.perform_activity(\"data_acquisition\", activity_func_args=[data_name, data_acquired_tmp, data_acquired_coordinates_tmp])\n",
- " \n",
+ " sim.perform_activity(\"data_acquisition\", activity_func_args=[data_name, data_acquired_tmp, data_acquired_coordinates_tmp])\n",
+ " await sim.wait_for_activity()\n",
+ "\n",
" #Run the activity\n",
- " await sim.perform_activity(\"volcanic_event_detection\", \n",
+ " sim.perform_activity(\"volcanic_event_detection\", \n",
" activity_func_args=[data_acquired_tmp, data_acquired_coordinates_tmp, output_event_bbox_info_tmp])\n",
+ " await sim.wait_for_activity()\n",
"\n",
" #Storing results of the current iteration\n",
" data_acquired.append(data_acquired_tmp)\n",
@@ -535,7 +520,7 @@
},
"vscode": {
"interpreter": {
- "hash": "457d73575bcd07fce3b582d06bfae9446395c25f1ea618852d5f58e28a465e48"
+ "hash": "cec805858b69cacb2b7ad611a1d16c309b9d5c2fd3283013a8f0cd0423ba3fc5"
}
}
},
diff --git a/paseos/actors/actor_builder.py b/paseos/actors/actor_builder.py
index de2748f5..5e393ccc 100644
--- a/paseos/actors/actor_builder.py
+++ b/paseos/actors/actor_builder.py
@@ -152,6 +152,12 @@ def set_power_devices(
actor, SpacecraftActor
), "Power devices are only supported for SpacecraftActors"
+ # Check if the actor already had a power device
+ if actor.has_power_model:
+ logger.warning(
+ "The actor already had a power device. Currently only one device is supported. Overriding old device."
+ )
+
logger.trace("Checking battery values for sensibility.")
assert battery_level_in_Ws > 0, "Battery level must be non-negative"
assert max_battery_level_in_Ws > 0, "Battery level must be non-negative"
@@ -211,6 +217,12 @@ def set_thermal_model(
actor, SpacecraftActor
), "Thermal models are only supported for SpacecraftActors"
+ # Check if the actor already had a thermal model
+ if actor.has_thermal_model:
+ logger.warning(
+ "The actor already had a thermal model. Currently only one model is supported. Overriding old model."
+ )
+
assert actor_mass > 0, "Actor mass has to be positive."
assert (
diff --git a/paseos/paseos.py b/paseos/paseos.py
index 530961fc..86161cca 100644
--- a/paseos/paseos.py
+++ b/paseos/paseos.py
@@ -62,6 +62,11 @@ def __init__(self, local_actor: BaseActor, cfg=None):
)
self._operations_monitor = OperationsMonitor(self.local_actor.name)
+ async def wait_for_activity(self):
+ """This functions allows waiting for the currently running activity to finish."""
+ while self._is_running_activity is True:
+ await asyncio.sleep(0.1)
+
def save_status_log_csv(self, filename) -> None:
"""Saves the status log incl. all kinds of information such as battery charge,
running activtiy, etc.