Module achlys_pmod_als_worker

The Pmod_ALS worker server.

Behaviours: gen_server.

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

See also: Pmod_ALS .

Description

The Pmod_ALS worker server. The general purpose of this worker is to gather and process sensor data the pmod_als module :

- Ambient Light (raw) - Ambient Light percentage

Data can be retrieved as follows :

Raw = pmod_als:read(). Percentage = pmod_als:percentage().

Data Types

task()

task() = #{name => atom(), targets => task_targets(), execution_type => task_execution_type(), function => function()}

task_execution_type()

task_execution_type() = bitstring()

task_targets()

task_targets() = [node()] | bitstring()

Function Index

code_change/3
get_crdt/1Returns the current view of the contents in Lasp variable.
get_table/1Returns the current view of the contents in Lasp variable.
handle_continue/2
handle_info/2fetches the values from the pmod_als sensor and stores them in the corresponding ETS table.
run/0declares a Lasp variable for aggregates and sets triggers for handlers after intervals have expired.
start_link/0starts the pmod_als 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/1

get_crdt(Name::atom()) -> list()

Returns the current view of the contents in Lasp variable. -spec get_crdt() -> crdt().

get_table/1

get_table(Name::atom()) -> ok

Returns the current view of the contents in Lasp variable.

handle_continue/2

handle_continue(Continue, State) -> any()

handle_info/2

handle_info(Info, State) -> any()

fetches the values from the pmod_als sensor and stores them in the corresponding ETS table. It is paired with the erlang:monotonic_time/0 to guarantee unique keys. The first call is used to redirect towards implemented handlers e.g. temperature, pressure. 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 aggregates and sets triggers for handlers after intervals have expired.

start_link/0

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

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

terminate/2

terminate(Reason, State) -> any()


Generated by EDoc