Module achlys_pmod_nav_worker

The Pmod_NAV worker server.

Behaviours: gen_server.

Authors: Igor Kopestenski (igor.kopestenski@uclouvain.be) [web site: https://github.com/Laymer/achlys/].

See also: Pmod_NAV .

Description

The Pmod_NAV worker server. The general purpose of this worker is to gather and process sensor data from one of the 3 components available on the Pmod_NAV :

- Accelerometer => acc - Gyroscope => alt - Magnetometer => mag

Data can be retrieved as follows :

[Temperature] = pmod_nav:read(acc, [out_temp]).

Where acc is the component providing the data and [out_temp] is the list of registers that is read.

Data Types

nav_config()

nav_config() = #{table := atom(), gc_interval := pos_integer(), poll_interval := pos_integer(), aggregation_trigger := pos_integer()}

Function Index

code_change/3
get_crdt/0Returns the current view of the contents in the temperatures Lasp variable.
get_table/0Returns the current view of the contents in the temperatures Lasp variable.
handle_call/3
handle_cast/2
handle_continue/2
handle_info/2fetches the temperature value from the pmod_nav sensor and stores it in the corresponding ETS table.
run/0declares a Lasp variable for temperature aggregates and sets triggers for handlers after intervals have expired.
start_link/1starts the pmod_nav process using the configuration given in the sys.config file.
terminate/2

Function Details

code_change/3

code_change(OldVsn, State, Extra) -> any()

get_crdt/0

get_crdt() -> list()

Returns the current view of the contents in the temperatures Lasp variable.

get_table/0

get_table() -> ok

Returns the current view of the contents in the temperatures Lasp variable.

handle_call/3

handle_call(Request, From, State) -> any()

handle_cast/2

handle_cast(Msg, State) -> any()

handle_continue/2

handle_continue(Continue, State) -> any()

handle_info/2

handle_info(Info, State) -> any()

fetches the temperature value from the pmod_nav sensor and stores it in the corresponding ETS table. It is paired with the erlang:monotonic_time/0 to guarantee unique keys. For large amounts of sensor data e.g. accumulated for a long time and being larger than the maximum available memory, an alternative would be to use the dets storage module. They can also be combined as described below.

From OTP documentation :

Dets tables provide efficient file-based Erlang term storage. They are used together with ETS tables when fast access needs to be complemented with persistency.

run/0

run() -> ok

declares a Lasp variable for temperature aggregates and sets triggers for handlers after intervals have expired.

start_link/1

start_link(NavConfig::nav_config()) -> {ok, pid()} | ignore | {error, {already_started, pid()} | term()}

starts the pmod_nav process using the configuration given in the sys.config file.

terminate/2

terminate(Reason, State) -> any()


Generated by EDoc