-
Notifications
You must be signed in to change notification settings - Fork 6
Added docs for the @unit tag #71
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
docs/mission-modeling/activity-types/activity-type-metadata.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# 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: | ||
|
||
- `brief_description` | ||
- `@aerie.computedAttribute` | ||
- `contact` | ||
- `@aerie.resourceName` | ||
- `subsystem` | ||
- `@aerie.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 processor can leverage the `@aerie.unit` tag to parse and display units for Parameters, Computed Attributes, and Resource Types. | ||
|
||
### Parameters | ||
|
||
There are 2 valid locations to parse a parameters units, on the parameter itself if it is a property 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. | ||
|
||
```java | ||
/** | ||
* @param duration | ||
* @aerie.unit seconds | ||
* @param energyConsumptionRate | ||
* @aerie.unit kWh | ||
*/ | ||
@ActivityType("RunHeater") | ||
public record RunHeater(long duration, int energyConsumptionRate) | ||
``` | ||
|
||
```java | ||
@ActivityType("RunHeater") | ||
public class RunHeater { | ||
/** | ||
* @aerie.unit seconds | ||
*/ | ||
@Parameter | ||
public long duration; | ||
|
||
/** | ||
* @aerie.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 `@aerie.unit` tag here needs a `@aerie.computedAttribute` tag on the previous line the annotation processor knows which property to assign the units to. | ||
|
||
```java | ||
/** | ||
* | ||
* @aerie.computedAttribute durationInSeconds | ||
* @aerie.unit seconds | ||
* @aerie.computedAttribute energyConsumptionRate | ||
* @aerie.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 `@aerie.resourceName` tag with the name of the resource on a previous line. | ||
|
||
```java | ||
/** | ||
* @aerie.resourceName /flag | ||
* @aerie.unit A, B | ||
*/ | ||
public final class Mission { | ||
/** | ||
* @aerie.resourceName /fruit | ||
* @aerie.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); | ||
} | ||
} | ||
``` | ||
|
||
Resource types can also be matched using Regex, if invalid Regex is provided or it doesn't find any matches it'll be ignored. | ||
|
||
```java | ||
/** | ||
* @aerie.resourceName \/f.* | ||
* @aerie.unit F resources | ||
*/ | ||
public final class Mission { | ||
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); | ||
} | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.