msl.equipment.resources.omega.ithx module

OMEGA iTHX Series Temperature and Humidity Chart Recorder.

This class is compatible with the following model numbers:

  • iTHX-W3

  • iTHX-D3

  • iTHX-SD

  • iTHX-M

  • iTHX-W

  • iTHX-2

class msl.equipment.resources.omega.ithx.iTHX(record)[source]

Bases: ConnectionSocket

OMEGA iTHX Series Temperature and Humidity Chart Recorder.

The properties for an iTHX connection supports the following key-value pairs in the Connections Database:

'nprobes': int, the number of probes the device has
'nbytes': int, the number of bytes to read from each probe

as well as those key-value pairs supported by the parent ConnectionSocket class.

Do not instantiate this class directly. Use the connect() method to connect to the equipment.

Parameters

record (EquipmentRecord) – A record from an Equipment-Register Database.

temperature(probe=1, celsius=True, nbytes=None)[source]

Read the temperature.

Parameters
  • probe (int, optional) – The probe number to read the temperature of (for iTHX’s that contain multiple probes).

  • celsius (class:bool, optional) – True to return the temperature in celsius, False for fahrenheit.

  • nbytes (class:int, optional) – The number of bytes to read. If None then read until the termination character sequence.

Returns

float or tuple of float – The temperature.

humidity(probe=1, nbytes=None)[source]

Read the percent humidity.

Parameters
  • probe (int, optional) – The probe number to read the humidity of (for iTHX’s that contain multiple probes).

  • nbytes (class:int, optional) – The number of bytes to read. If None then read until the termination character sequence.

Returns

float or tuple of float – The percent humidity.

dewpoint(probe=1, celsius=True, nbytes=None)[source]

Read the dew point.

Parameters
  • probe (int, optional) – The probe number to read the dew point of (for iTHX’s that contain multiple probes).

  • celsius (bool, optional) – True to return the dew point in celsius, False for fahrenheit.

  • nbytes (class:int, optional) – The number of bytes to read. If None then read until the termination character sequence.

Returns

float or tuple of float – The dew point.

temperature_humidity(probe=1, celsius=True, nbytes=None)[source]

Read the temperature and the humidity.

Parameters
  • probe (int, optional) – The probe number to read the temperature and humidity of (for iTHX’s that contain multiple probes).

  • celsius (bool, optional) – True to return the temperature in celsius, False for fahrenheit.

  • nbytes (class:int, optional) – The number of bytes to read. If None then read until the termination character sequence. If specified, nbytes is the combined value to read both values.

Returns

  • float – The temperature.

  • float – The humidity.

temperature_humidity_dewpoint(probe=1, celsius=True, nbytes=None)[source]

Read the temperature, the humidity and the dew point.

Parameters
  • probe (int, optional) – The probe number to read the temperature, humidity and dew point (for iTHX’s that contain multiple probes).

  • celsius (bool, optional) – If True then return the temperature and dew point in celsius, False for fahrenheit.

  • nbytes (int, optional) – The number of bytes to read. If None then read until the termination character sequence. If specified, nbytes is the combined value to read all three values.

Returns

  • float – The temperature.

  • float – The humidity.

  • float – The dew point.

reset(wait=True, password=None, port=2002, timeout=10)[source]

Power reset the iServer.

Some iServers accept the reset command to be sent via the TCP/UDP protocol and some require the reset command to be sent via the Telnet protocol.

Parameters
  • wait (bool, optional) – Whether to wait for the connection to the iServer to be re-established before returning to the calling program. Rebooting an iServer takes about 10 to 15 seconds.

  • password (str, optional) – The administrator’s password of the iServer. If not specified then uses the default manufacturer’s password. Only used if the iServer needs to be reset via the Telnet protocol.

  • port (int, optional) – The port to use for the Telnet connection. Only used if the iServer needs to be reset via the Telnet protocol.

  • timeout (float, optional) – The timeout value to use during the Telnet session. Only used if the iServer needs to be reset via the Telnet protocol.

start_logging(path, wait=60, nprobes=None, nbytes=None, celsius=True, msg_format=None, db_timeout=10, validator=None)[source]

Start logging the temperature, humidity and dew point to the specified path.

The information is logged to an SQLite database. To stop logging press CTRL+C.

Parameters
  • path (str) – The path to the SQLite database. If you only specify a directory then a database with the default filename, model_serial.sqlite3, is created/opened in this directory.

  • wait (int, optional) – The number of seconds to wait between each log event.

  • nprobes (int, optional) – The number of probes that the iServer has (1 or 2). If not specified then gets the value defined in properties. Default is 1.

  • nbytes (int, optional) – The number of bytes to read from each probe (the probes are read sequentially). The value is passed to temperature_humidity_dewpoint(). If not specified then gets the value defined in properties. Default is None.

  • celsius (bool, optional) – True to return the temperature and dew point in celsius, False for fahrenheit.

  • msg_format (str, optional) –

    The format to use for the INFO logging messages each time data is read from an iServer. The format must use the str.format() syntax, {}. The positional arguments to str.format() are the values from the iServer, where the values are (temperature, humidity, dewpoint) for a 1-probe sensor and (temperature1, humidity1, dewpoint1, temperature2, humidity2, dewpoint2) for a 2-probe sensor. The keyword arguments to str.format() are the attributes of an EquipmentRecord.

    Examples:

    • T={0} H={1} D={2}

    • {connection[address]} T={0:.1f} H={1:.1f} D={2:.1f}

    • T1={0} T2={3} H1={1} H2={4} D1={2} D2={5}

    • {alias} {serial} -> T={0}C H={1}% D={2}C

  • db_timeout (float, optional) – The number of seconds the connection to the database should wait for the lock to go away until raising an exception.

  • validator – A callback that is used to validate the data. The callback must accept two arguments (data, ithx), where data is a tuple of the temperature, humidity and dewpoint values for each probe and ithx is the iTHX instance (i.e., self). The callback must return a value whose truthness decides whether to insert the data into the database. If the returned value evaluates to True then the data is inserted into the database.

static data(path, start=None, end=None, as_datetime=True, select='*')[source]

Fetch all the log records between two dates.

Parameters
  • path (str) – The path to the SQLite database.

  • start (datetime or str, optional) – Include all records that have a timestamp \(\ge\) start. If a str then in the ISO 8601 yyyy-mm-dd or yyyy-mm-ddTHH:MM:SS format.

  • end (datetime or str, optional) – Include all records that have a timestamp \(\le\) end. If a str then in the ISO 8601 yyyy-mm-dd or yyyy-mm-ddTHH:MM:SS format.

  • as_datetime (bool, optional) – Whether to fetch the timestamps in the database as datetime objects. If False then the timestamps will be of type str and this function will return much faster if requesting data over a large date range.

  • select (str or list of str, optional) – The field name(s) in the database table to use for the SELECT SQL command (e.g., 'datetime,temperature' or ['datetime', 'humidity']).

Returns

list of tuple – A list of (pid, datetime, temperature, humidity, dewpoint, ...) log records, depending on the value of select.

msl.equipment.resources.omega.ithx.convert_datetime(value)[source]

Convert a date and time to a datetime object.

Parameters

value (bytes) – The datetime value from an SQLite database.

Returns

datetime.datetime – The value as a datetime object.