Module zio :: Class Sensor

Class Sensor

object --+    
         |    
    Module --+
             |
object --+   |
         |   |
     LockI --+
             |
            Sensor

Sensor class is used to access analog inputs usually driven by sensors.
Instance Methods
 
__init__(self, agent)
Constructs an Sensor object.
int
read_pin_raw(self, pin)
Reads and returns the value on the specified analog input pin.
list of ints
read_raw(self)
Reads and returns the value (0 - 0xFFFF) on all analog input pins.
list of floats
read(self)
Reads and returns the value (0 - Vref) on all analog input pins.
float
read_pin(self, pin)
Reads and returns the value on the specified analog input pin.
 
set_trigger_raw(self, pin, amount)
Sets the trigger amount (0 to 0xFFFF) for the specified pin.
int
get_trigger_raw(self, pin)
Gets the trigger amount (0 to 0xFFFF) set for the pin.
 
set_trigger(self, pin, amount)
Sets the trigger amount (0 to Vref) for the specified pin.
float
get_trigger(self, pin)
Gets the trigger amount (0 to Vref) set for the pin.
 
add_change_handler(self, handler)
Adds a handler to be invoked if the input driven on a pin changes by atleast the trigger amount.
 
remove_change_handler(self, handler)
Removes a previously registered handler.

Inherited from Module: do_op

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods

Inherited from LockI: synchronized

Properties
  vref
The ADC reference voltage (Vref).
  input_pin_count
The no.
  last_read_time
The relative time in microsec at which the last read operation occured.

Inherited from object: __class__

Method Details

__init__(self, agent)
(Constructor)

 
Constructs an Sensor object.
Parameters:
  • agent (Agent) - the agent interface object
Raises:
  • ProtocolError - If communication with agent fails or if data sent or received is corrupted
Overrides: object.__init__

read_pin_raw(self, pin)

 
Reads and returns the value on the specified analog input pin. The returned value represents the analog input as quantized levels in the range 0 to 0xFFFF.
Returns: int
the value driven on the pin

See Also: Sensor.read_pin

read_raw(self)

 
Reads and returns the value (0 - 0xFFFF) on all analog input pins.
Returns: list of ints
the values driven on the analog pins

read(self)

 
Reads and returns the value (0 - Vref) on all analog input pins.
Returns: list of floats
the data read from the pins.
Raises:
  • ProtocolError - If communication with agent fails or or if data sent or received is corrupted

read_pin(self, pin)

 
Reads and returns the value on the specified analog input pin. The returned value represents the analog input as a value in the range 0 to Vref.
Returns: float
the value driven on the pin

set_trigger_raw(self, pin, amount)

 
Sets the trigger amount (0 to 0xFFFF) for the specified pin. When the value driven on the pin changes by the specified amount a SensorChangeEvent is generated, and all registered handlers are invoked.
Parameters:
  • pin (int) - the index of the pin
  • amount (int) - the trigger amount
Decorators:
  • @LockI.synchronized

get_trigger_raw(self, pin)

 
Gets the trigger amount (0 to 0xFFFF) set for the pin.
Parameters:
  • pin (int) - the index of the pin
Returns: int
the trigger amount
Decorators:
  • @LockI.synchronized

set_trigger(self, pin, amount)

 
Sets the trigger amount (0 to Vref) for the specified pin. When the value driven on the pin changes by the specified amount a SensorChangeEvent is generated, and all registered handlers are invoked.
Parameters:
  • pin (int) - the index of the pin
  • amount (float) - the trigger amount

get_trigger(self, pin)

 
Gets the trigger amount (0 to Vref) set for the pin.
Parameters:
  • pin (int) - the index of the pin
Returns: float
the trigger amount

add_change_handler(self, handler)

 
Adds a handler to be invoked if the input driven on a pin changes by atleast the trigger amount.
Parameters:
  • handler (funtion) - the callback function
Decorators:
  • @LockI.synchronized

remove_change_handler(self, handler)

 
Removes a previously registered handler.
Parameters:
  • handler (function) - the handler to be removed
Decorators:
  • @LockI.synchronized

Property Details

vref

The ADC reference voltage (Vref).
Get Method:
_get_vref(self)

input_pin_count

The no. of input pins available in this module.
Get Method:
_get_input_pin_count(self)

last_read_time

The relative time in microsec at which the last read operation occured.
Get Method:
_get_last_read_time(self)