SEAL Components

From DiLab
Revision as of 11:29, 5 October 2012 by Atis (talk | contribs)
Jump to: navigation, search

Introduction

Most of SEAL application syntax is based on component (sensors, LEDs, output channels etc.) use case descriptions.

The description of a component use case contains the name of the component followed by a list of parameters. For example, the line:

use Beeper, times 10, period 100ms;

tells to use Beeper component for 10 times with 100 millisecond period (i.e. beep for one second with 10Hz on/off frequency).

Parameters

A parameter is described by parameter name followed by optional parameter value.

For example, period 1h or on are both valid parameter descriptions.

Parameter value formats

  • Integer: a whole number, for example 1, 100, 1234
  • Boolean: true/false value, for example True, False
  • String: a sequence of ASCII symbols, for example "hello world"
  • Time value is an integer with an optional suffix, for example 13min
    • h - hours
    • min - minutes
    • s - seconds
    • ms - milliseconds.
  • If no suffix is specified, the value is treated as milliseconds.

If only parameter name is specified, the default value (usually 0 or False) is used.

Parameters common for all components

  • id (integer) - object identifier
  • period (time value) - the use/read period
  • once (boolean) - use just once
  • times (integer) - use just the number of times ("times 1" is the same as once)
  • duration (time value) - use just for a specific duration (time period) since first used
  • pattern (pattern name) - read/use using a specific time valu patter.

Sensor-specific parameters

  • turnOnOff (boolean) - turn on the sensor before reading and off afterwards. By default the sensors are on whole time. This parameter can be used to save energy.
  • cache (boolean) - use cache to store and retrieve sensor values? By default, all sensors are read every time they are accessed.

Actuator-specific parameters

  • on (boolean) - turn the component on
  • off (boolean) - turn the component off
  • blink (boolean) - turn the component on, then off (using "period" parameter)


Output-specific parameters

  • aggregate (boolean) - if true, then a packet is formed; if no, then values are sent individually. True by default for all except serial port.


Components

Sensors

Real sensors

Light

Sample light reading.

Parameters: all sensor parameters.

Humidity

Sample air humidity sensor reading.

Parameters: all sensor parameters.

Temperature

Sample air humidity sensor reading.

Parameters: all sensor parameters.

AnalogIn

Parameters:

  • all sensor parameters
  • channel (integer) - which channel to read. Possible values depend on device.

DigitalIn

Parameters:

  • all sensor parameters
  • channel (integer) - which channel to read. Possible values depend on device.

Pseudosensors

Constant

Read a constant value.

Parameters:

  • all sensor parameters
  • value (integer) - the constant value to read.

Counter

Read a monotonically increasing counter.

Parameters: all sensor parameters

Random

Read a random number. By default, numbers in [0..65535] are returned.

Parameters:

  • all sensor parameters
  • min (integer) - lower bound of returned values
  • max (integer) - upper bound of returned values

TimeCounter

Read a monotonically increasing time counter value.

Parameters: all sensor parameters.

Timestamp

Read UNIX timestamp value (in seconds). If the clock of the system is synchonized with the real clock, real time is returned. If no, the seconds since system's start are returned.

Parameters: all sensor parameters.

Uptime

Read UNIX timestamp value (in seconds) since system's start.

Parameters: all sensor parameters

Actuators

LED

Control the default LED.

Parameters: all actuator parameters.

RedLed

Control the red LED, if the system has one.

Parameters: all actuator parameters.

GreenLed

Control the green LED, if the system has one.

Parameters: all actuator parameters.

BlueLed

Control the blue LED, if the system has one.

Parameters: all actuator parameters.

Beeper

Control the beeper, if the system has one.

Parameters: all actuator parameters.

AnalogOut

Control a specific analog output channel.

Parameters:

  • all actuator parameters
  • channel (integer) - which channel use. Possible values depend on device.

Warning: not implemented at the moment!

DigitalOut

Control a specific digital output channel.

Parameters:

  • all actuator parameters
  • channel (integer) - which channel use. Possible values depend on device.

Print

Control a specific digital output channel.

Parameters:

  • all actuator parameters
  • format (string) - the format to use (printf-like).
  • arg1 (depends on format) - first argument to format string.
  • arg2...arg9 (depends on format) - other arguments to format string.

Usage example:

use Print, period 1000, format "hello %s\n", arg1 "world";

Outputs

Serial

Serial interface (virtual COM port).

Radio

Raw radio output.

Network

Network output.

SdCard

Output to SD card, if the system has one.

File

Output to a file card, if the device supports file system.

Other syntax elements

C variables

The MansOS C variables can be accessed using variables.<name> syntax.

Example variables:

  • localAddress - the network address of the mote (2 bytes)
  • ...

C constants

The MansOS C constants can be accessed using constants.<name> syntax.

Example constants:

  • ADC_LIGHT_TOTAL - total light sensor analog input channel ID
  • ADC_LIGHT_PHOTOSYNTHETIC - photosyntetically active light sensor analog input channel ID
  • ADC_INTERNAL_VOLTAGE - battery voltage analog input channel ID