Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.). <br> **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.). <br> **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()`."
]
},
{
Expand All @@ -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",
Expand Down Expand Up @@ -535,7 +520,7 @@
},
"vscode": {
"interpreter": {
"hash": "457d73575bcd07fce3b582d06bfae9446395c25f1ea618852d5f58e28a465e48"
"hash": "cec805858b69cacb2b7ad611a1d16c309b9d5c2fd3283013a8f0cd0423ba3fc5"
}
}
},
Expand Down
12 changes: 12 additions & 0 deletions paseos/actors/actor_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 (
Expand Down
5 changes: 5 additions & 0 deletions paseos/paseos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down