Module Tezos_oxymeter.Report

Utility used by the entire library to represent a report. Once it's created, it can't be ereased.

Representation

A report is a representation of the state of an Observer.observer at a given time.

type t

Abstract representation for a report. To get the content, it's recommanded to use the encoding system.

val create : ?⁠joule:float -> ?⁠volt:float -> ?⁠ampere:float -> ?⁠power:float -> ?⁠watt_hour:float -> float -> t

create builds a report with the information provide.

Usage: create ~joule ~volt ~ampere ~power ~watt_hour time

  • joule is the instant energy (default is 0).
  • volt represents the voltage (default is 0).
  • ampere represents the intensity (default is 0).
  • power refers to the power consumption (default is 0).
  • watt_hour is the energy per time consumption (default is 0).
  • time is a UNIX timestamp.

Manipulation

Even if the t type is immutable, you can execute some actions on it and generates new reports.

val diff : t -> t -> t

diff r1 r2 creates a new report which represents the difference between the two reports (r1 - r2), field by field.

val pp : Stdlib.Format.formatter -> t -> unit

pp ppf report is used to pretty print the report.

Conversion

The report can convert to various to be:

  • send through the network
  • print as a string
  • use as a normalize representation
val encoding : t Data_encoding.t

It provides an encoding used by tezos to transform data in JSON format.

val string_of_t : t -> string

string_ot_t converts t report into a readable string.

val json_of_t : t -> Data_encoding.json

json_of_t report converts a t report into a JSON, usable by Data_encoding.

val ezjsonm_of_t : t -> Ezjsonm.value

ezjsonm_of_t report converts t report into a JSON, usable bytes Ezjsonm.