-
Notifications
You must be signed in to change notification settings - Fork 3
Prepare for release #37
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,14 +3,125 @@ | |
| [<img alt="docs.rs" src="https://img.shields.io/docsrs/frequenz-microgrid">](https://docs.rs/frequenz-microgrid) | ||
| [<img alt="Crates.io" src="https://img.shields.io/crates/v/frequenz-microgrid">](https://crates.io/crates/frequenz-microgrid) | ||
|
|
||
| High-level interface for Rust to the Frequenz Microgrid API. | ||
| High-level Rust interface for the Frequenz Microgrid API. | ||
|
|
||
| ## Documentation | ||
| The crate connects to a Microgrid API server, builds a [`ComponentGraph`] | ||
| from the live topology, and exposes typed, formula-driven streams of | ||
| microgrid metrics — grid power, battery state-of-charge, PV reactive | ||
| power, consumer current, and so on — without requiring callers to write | ||
| the per-component formulas by hand. | ||
|
|
||
| For more information, please visit the [documentation | ||
| website](https://docs.rs/frequenz-microgrid). | ||
| Support for controlling components is coming soon. | ||
|
|
||
| ## Quick start | ||
|
|
||
| ```toml | ||
| [dependencies] | ||
| frequenz-microgrid = "0.4" | ||
| chrono = "0.4" | ||
| tokio = { version = "1", features = ["macros", "rt-multi-thread"] } | ||
| ``` | ||
|
|
||
| Stream the grid's active power once per second: | ||
|
|
||
| ```rust , ignore | ||
| use chrono::TimeDelta; | ||
| use frequenz_microgrid::{Error, LogicalMeterConfig, Microgrid, metric}; | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Error> { | ||
| let microgrid = Microgrid::try_new( | ||
| "http://[::1]:8800", | ||
| LogicalMeterConfig::new(TimeDelta::try_seconds(1).unwrap()), | ||
| ) | ||
| .await?; | ||
|
|
||
| let mut grid = microgrid | ||
| .logical_meter() | ||
| .grid::<metric::AcPowerActive>()? | ||
| .subscribe() | ||
| .await?; | ||
|
|
||
| while let Ok(sample) = grid.recv().await { | ||
| println!("{:?}: {:?}", sample.timestamp(), sample.value()); | ||
| } | ||
| Ok(()) | ||
| } | ||
| ``` | ||
|
|
||
| [`Microgrid::try_new`] blocks (with retries) until the server is | ||
| reachable and returns a graph that builds successfully, so applications | ||
| can start before their backing service is ready. | ||
|
|
||
| ## Testing with the in-crate mock | ||
|
|
||
| [`frequenz_microgrid::test_utils`][`client::test_utils`] ships a | ||
| [`MockMicrogridApiClient`] (plus [`MockComponent`] and | ||
| [`TokioSyncedClock`] helpers) for downstream tests. Enable it as a | ||
| dev-dependency feature: | ||
|
|
||
| ```toml | ||
| [dev-dependencies] | ||
| frequenz-microgrid = { version = "0.4", features = ["test-utils"] } | ||
| ``` | ||
|
|
||
| ## What's included | ||
|
|
||
| - [`Microgrid`] / [`LogicalMeterHandle`]: typed formulas for [`grid`], | ||
| [`battery`], [`pv`], [`chp`], [`ev_charger`], [`consumer`], | ||
| [`producer`], and individual [`component`]s, parametrised over a | ||
| metric in [`metric`]. | ||
| - [`BatteryPool`]: aggregated active-power bounds and state-of-charge | ||
| for one or more batteries. | ||
| - [`MicrogridClientHandle`]: cloneable low-level gRPC handle with | ||
| per-stream automatic reconnect. | ||
| - [`quantity`]: [`Power`], [`Current`], [`Voltage`], [`ReactivePower`], | ||
| [`Energy`], [`Frequency`], [`Percentage`]. Unit conversions are | ||
| explicit at every API surface. | ||
|
|
||
| ## Configuring the underlying graph | ||
|
|
||
| [`LogicalMeterConfig::with_component_graph_config`] forwards a | ||
| [`ComponentGraphConfig`] to the | ||
| [`frequenz-microgrid-component-graph`](https://docs.rs/frequenz-microgrid-component-graph) | ||
| builder, exposing knobs like | ||
| [`prefer_meters_in_component_formulas`], | ||
| [`include_phantom_loads_in_consumer_formula`], and per-formula | ||
| overrides. If not set, the graph crate's `Default::default()` is used. | ||
|
|
||
| ## Contributing | ||
|
|
||
| If you want to know how to build this project and contribute to it, please | ||
| check out the [Contributing Guide](CONTRIBUTING.md). | ||
| See the [Contributing Guide](https://github.com/frequenz-floss/frequenz-microgrid-rs/blob/HEAD/CONTRIBUTING.md). | ||
|
|
||
| [`ComponentGraph`]: https://docs.rs/frequenz-microgrid-component-graph/latest/frequenz_microgrid_component_graph/struct.ComponentGraph.html | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this list of docs links about? It does not look related to "Contributing", the previous headline ...?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, they're the link references. So all occurrences of [
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And don't show up in the rendered markdown. |
||
| [`ComponentGraphConfig`]: https://docs.rs/frequenz-microgrid-component-graph/latest/frequenz_microgrid_component_graph/struct.ComponentGraphConfig.html | ||
| [`prefer_meters_in_component_formulas`]: https://docs.rs/frequenz-microgrid-component-graph/latest/frequenz_microgrid_component_graph/struct.ComponentGraphConfigBuilder.html#method.prefer_meters_in_component_formulas | ||
| [`include_phantom_loads_in_consumer_formula`]: https://docs.rs/frequenz-microgrid-component-graph/latest/frequenz_microgrid_component_graph/struct.ComponentGraphConfigBuilder.html#method.include_phantom_loads_in_consumer_formula | ||
| [`Microgrid`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.Microgrid.html | ||
| [`Microgrid::try_new`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.Microgrid.html#method.try_new | ||
| [`LogicalMeterHandle`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html | ||
| [`LogicalMeterConfig`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterConfig.html | ||
| [`LogicalMeterConfig::with_component_graph_config`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterConfig.html#method.with_component_graph_config | ||
| [`BatteryPool`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.BatteryPool.html | ||
| [`MicrogridClientHandle`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.MicrogridClientHandle.html | ||
| [`grid`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html#method.grid | ||
| [`battery`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html#method.battery | ||
| [`pv`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html#method.pv | ||
| [`chp`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html#method.chp | ||
| [`ev_charger`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html#method.ev_charger | ||
| [`consumer`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html#method.consumer | ||
| [`producer`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html#method.producer | ||
| [`component`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/struct.LogicalMeterHandle.html#method.component | ||
| [`metric`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/metric/index.html | ||
| [`quantity`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/quantity/index.html | ||
| [`Power`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/quantity/struct.Power.html | ||
| [`Current`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/quantity/struct.Current.html | ||
| [`Voltage`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/quantity/struct.Voltage.html | ||
| [`ReactivePower`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/quantity/struct.ReactivePower.html | ||
| [`Energy`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/quantity/struct.Energy.html | ||
| [`Frequency`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/quantity/struct.Frequency.html | ||
| [`Percentage`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/quantity/struct.Percentage.html | ||
| [`client::test_utils`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/client/test_utils/index.html | ||
| [`MockMicrogridApiClient`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/client/test_utils/struct.MockMicrogridApiClient.html | ||
| [`MockComponent`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/client/test_utils/struct.MockComponent.html | ||
| [`TokioSyncedClock`]: https://docs.rs/frequenz-microgrid/latest/frequenz_microgrid/client/test_utils/struct.TokioSyncedClock.html | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Announcements like this one usually don't age well, in my experience. And why ourselves under pressure? 😏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, because
microgrid-rsis supposed to read and control. This lets them know that it is not there yet. Also, this is the next big thing for me, multiple things are blocked until we get this.