Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docs for the @unit tag #71

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
102 changes: 102 additions & 0 deletions docs/mission-modeling/activity-types/activity-type-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Activity Type Metadata
camargo marked this conversation as resolved.
Show resolved Hide resolved

Metadata of activities are structured such that the Aerie annotation processor can extract this metadata given particular keywords. Currently, the annotation processor recognizes the following tags:

- `brief_description`
- `computedAttribute`
- `contact`
- `resourceName`
- `subsystem`
- `units`
- `verbose_description`

These metadata tags are placed in a [Javadoc](https://en.wikipedia.org/wiki/Javadoc) style comment block above the activity type to which they refer. For example:

```java
/**
* @subsystem Data
* @contact camargo
* @brief_description A data management activity that deletes old files
*/
@ActivityType("DeleteOldFiles")
```

## Units

The Aerie annotation processer can leverage the `@unit` tag to parse and display units for Parameters, Computed Attributes, and Resource Types.
camargo marked this conversation as resolved.
Show resolved Hide resolved

### Parameters

There are 2 valid locations to parse a parameters units, on the parameter itself if it is a proptery of a class, or on the record defining an activity type. When you define the units as part of a record type you need to include the `@param` you're defining the units for on the previous line.
camargo marked this conversation as resolved.
Show resolved Hide resolved

```java
/**
* @param duration
* @unit seconds
* @param energyConsumptionRate
* @unit kWh
*/
@ActivityType("RunHeater")
public record RunHeater(long duration, int energyConsumptionRate)
```

```java
@ActivityType("RunHeater")
public class RunHeater {
/**
* @unit seconds
*/
@Paramter
camargo marked this conversation as resolved.
Show resolved Hide resolved
public long duration;

/**
* @unit kWh
*/
@Parameter
public int energyConsumptionRate;
}
```

### Computed Attributes

Units can be specified for computed attributes as well, this happens on the record that defines the `ComputedAttributes`. The `@unit` tag here needs a `@computedAttribute` tag on the previous line the annotation processor knows which property to assign the units to.

```java
/**
*
* @computedAttribute durationInSeconds
* @unit seconds
* @computedAttribute energyConsumptionRate
* @unit kWh
*/
@AutoValueMapper.Record
record ComputedAttributes(
long durationInSeconds,
int energyConsumptionRate
) {}
```

### Resource Types

Units for resource types can be defined in two places similar to parameters. The first is on the `Mission` class where resources are registered, alternatively it can be defined on the resource itself. The units defined here need to have a `@resourceName` tag with the name of the resource on a previous line.

```java
/**
* @resourceName /flag
* @unit A, B
*/
public final class Mission {
/**
* @resourceName /fruit
* @unit number of fruit
*/
public final Register<Accumulator> fruit;

public final Register<Flag> flag;

public Mission(final Registrar registrar, final Configuration config) {
registrar.discrete("/flag", this.flag, new EnumValueMapper<>(Flag.class));
registrar.real("/fruit", this.fruit);
}
}
```
14 changes: 0 additions & 14 deletions docs/mission-modeling/activity-types/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,3 @@ In order for Aerie to detect an activity type, its class must be annotated with
```

By doing so, the Aerie annotation processor can discover all activity types declared in the mission model, and validate that activity type names are unique.

## Activity Type Metadata

Metadata of activities are structured such that the Aerie annotation processor can extract this metadata given particular keywords. Currently, the annotation processor recognizes the following tags: `contact`, `subsystem`, `brief_description`, and `verbose_description`.
These metadata tags are placed in a [Javadoc](https://en.wikipedia.org/wiki/Javadoc) style comment block above the activity type to which they refer. For example:

```java
/**
* @subsystem Data
* @contact camargo
* @brief_description A data management activity that deletes old files
*/
@ActivityType("DeleteOldFiles")
```