pub struct MicrogridClientHandle { /* private fields */ }Expand description
A handle to the microgrid client connection.
This handle can be cloned as many times as needed, and each clone will share the same underlying connection to the microgrid API.
Implementations§
Source§impl MicrogridClientHandle
impl MicrogridClientHandle
Sourcepub async fn try_new(url: impl Into<String>) -> Result<Self, Error>
pub async fn try_new(url: impl Into<String>) -> Result<Self, Error>
Creates a new MicrogridClientHandle that connects to the microgrid API
at the specified URL.
pub fn new_from_client(client: impl MicrogridApiClient) -> Self
Sourcepub async fn receive_electrical_component_telemetry_stream(
&self,
electrical_component_id: u64,
) -> Result<Receiver<ElectricalComponentTelemetry>, Error>
pub async fn receive_electrical_component_telemetry_stream( &self, electrical_component_id: u64, ) -> Result<Receiver<ElectricalComponentTelemetry>, Error>
Returns a telemetry stream from an electrical component with a given ID.
When a connection to the API service is lost, reconnecting is handled automatically, and the receiver will resume receiving data from the component once the connection is re-established.
Sourcepub async fn list_electrical_components(
&self,
electrical_component_ids: Vec<u64>,
electrical_component_categories: Vec<ElectricalComponentCategory>,
) -> Result<Vec<ElectricalComponent>, Error>
pub async fn list_electrical_components( &self, electrical_component_ids: Vec<u64>, electrical_component_categories: Vec<ElectricalComponentCategory>, ) -> Result<Vec<ElectricalComponent>, Error>
Lists the electrical components in the local microgrid.
If provided, the filters for component IDs and categories have an AND
relationship with one another, meaning that they are applied serially,
but the elements within a single filter list have an OR relationship with
each other.
For example, if ids = [1, 2, 3], and categories = [
ComponentCategory::COMPONENT_CATEGORY_INVERTER,
ComponentCategory::COMPONENT_CATEGORY_BATTERY
],
then the results will consist of elements that
have the IDs 1, OR 2, OR 3,
AND
are of the categories ComponentCategory::COMPONENT_CATEGORY_INVERTER OR
ComponentCategory::COMPONENT_CATEGORY_BATTERY.
If a filter list is empty, then that filter is not applied.
Sourcepub async fn list_electrical_component_connections(
&self,
source_electrical_component_ids: Vec<u64>,
destination_electrical_component_ids: Vec<u64>,
) -> Result<Vec<ElectricalComponentConnection>, Error>
pub async fn list_electrical_component_connections( &self, source_electrical_component_ids: Vec<u64>, destination_electrical_component_ids: Vec<u64>, ) -> Result<Vec<ElectricalComponentConnection>, Error>
Lists the connections between the electrical components in a microgrid,
denoted by (start, end).
The direction of a connection is always away from the grid endpoint, i.e. aligned with the direction of positive current according to the passive sign convention: https://en.wikipedia.org/wiki/Passive_sign_convention
If provided, the start and end filters have an AND relationship
between each other, meaning that they are applied serially, but an OR
relationship with other elements in the same list. For example, if
start = [1, 2, 3], and end = [4, 5, 6], then the result should
have all the connections where
- each
startcomponent ID is either1,2, OR3, AND - each
endcomponent ID is either4,5, OR6.
Sourcepub async fn augment_electrical_component_bounds<M, I>(
&self,
electrical_component_id: u64,
target_metric: M,
bounds: Vec<I>,
request_lifetime: Option<TimeDelta>,
) -> Result<Option<DateTime<Utc>>, Error>
pub async fn augment_electrical_component_bounds<M, I>( &self, electrical_component_id: u64, target_metric: M, bounds: Vec<I>, request_lifetime: Option<TimeDelta>, ) -> Result<Option<DateTime<Utc>>, Error>
Augments the overall bounds for a given metric of a given electrical component with the provided bounds. Returns the UTC time at which the provided bounds will expire and its effects will no longer be visible in the overall bounds for the given metric.
The request parameters allows users to select a duration until which the bounds will stay in effect. If no duration is provided, then the bounds will be removed after a default duration of 5 seconds.
Inclusion bounds give the range that the system will try to keep the
metric within. If the metric goes outside of these bounds, the system will
try to bring it back within the bounds.
If the bounds for a metric are [`lower_1, upper_1], [lower_2, upper_2](<lower_1, upper_1], [lower_2, upper_2>), then this metric's valueneeds to comply with the constraintslower_1 <= value <= upper_1ORlower_2 <= value <= upper_2`.
If multiple inclusion bounds have been provided for a metric, then the overlapping bounds are merged into a single bound, and non-overlapping bounds are kept separate. E.g. if the bounds are [0, 10], [5, 15], 20, 30, then the resulting bounds will be [0, 15], 20, 30.
The following diagram illustrates how bounds are applied:
lower_1 upper_1
<----|========|--------|========|-------->
lower_2 upper_2The bounds in this example are [[lower_1, upper_1], [lower_2, upper_2]].
–– values here are considered out of range.
==== values here are considered within range.
Note that for power metrics, regardless of the bounds, 0W is always allowed.
Trait Implementations§
Source§impl Clone for MicrogridClientHandle
impl Clone for MicrogridClientHandle
Source§fn clone(&self) -> MicrogridClientHandle
fn clone(&self) -> MicrogridClientHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MicrogridClientHandle
impl RefUnwindSafe for MicrogridClientHandle
impl Send for MicrogridClientHandle
impl Sync for MicrogridClientHandle
impl Unpin for MicrogridClientHandle
impl UnsafeUnpin for MicrogridClientHandle
impl UnwindSafe for MicrogridClientHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request