Module device :: Class Device
[hide private]
[frames] | no frames]

type Device

source code

object --+
         |
        Device

Class that represents a device.

Instance Methods [hide private]
 
__init__(self, device_id, sensor_data, supervisor)
Constructor.
source code
String
__str__(self)
Pretty prints this device.
source code
 
setup_devices(self, devices)
Setup the devices before simulation begins.
source code
 
assign_script(self, script, location)
Provide a script for the device to execute.
source code
Float
get_data(self, location)
Returns the pollution value this device has for the given location.
source code
 
set_data(self, location, data)
Sets the pollution value stored by this device for the given location.
source code
 
shutdown(self)
Instructs the device to shutdown (terminate all threads).
source code
Method Details [hide private]

__init__(self, device_id, sensor_data, supervisor)
(Constructor)

source code 

Constructor.

Parameters:
  • device_id (Integer) - the unique id of this node; between 0 and N-1
  • sensor_data (List of (Integer, Float)) - a list containing (location, data) as measured by this device
  • supervisor (Supervisor) - the testing infrastructure's control and validation component
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

Pretty prints this device.

Returns: String
a string containing the id of this device
Overrides: object.__str__

setup_devices(self, devices)

source code 

Setup the devices before simulation begins.

Parameters:
  • devices (List of Device) - list containing all devices

assign_script(self, script, location)

source code 

Provide a script for the device to execute.

Parameters:
  • script (Script) - the script to execute from now on at each timepoint; None if the current timepoint has ended
  • location (Integer) - the location for which the script is interested in

get_data(self, location)

source code 

Returns the pollution value this device has for the given location.

Parameters:
  • location (Integer) - a location for which obtain the data
Returns: Float
the pollution value

set_data(self, location, data)

source code 

Sets the pollution value stored by this device for the given location.

Parameters:
  • location (Integer) - a location for which to set the data
  • data (Float) - the pollution value

shutdown(self)

source code 

Instructs the device to shutdown (terminate all threads). This method is invoked by the tester. This method must block until all the threads started by this device terminate.