# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyupm_hwxpxx', [dirname(__file__)])
except ImportError:
import _pyupm_hwxpxx
return _pyupm_hwxpxx
if fp is not None:
try:
_mod = imp.load_module('_pyupm_hwxpxx', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_hwxpxx = swig_import_helper()
del swig_import_helper
else:
import _pyupm_hwxpxx
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def getVersion():
return _pyupm_hwxpxx.getVersion()
getVersion = _pyupm_hwxpxx.getVersion
[docs]class HWXPXX(_object):
"""
UPM API for the Veris HWXPXX Hardware Protocol Humidity and
Temperature Sensor.
ID: hwxpxx
Name: Veris HWXPXX Hardware Protocol Humidity and Temperature Sensor
Category: temp
Manufacturer: veris
Connection: uart
Link:http://cpengineerscorp.net/veris-industries-hwxphtx.html This
module implements support for the Veris HWXPHTX Hardware Protocol
Humidity and Temperature Sensor family. It uses MODBUS over an RS485
interface. You must have libmodbus v3.1.2 (or greater) installed to
compile and use this driver.
This module was developed using libmodbus 3.1.2, and the HWXPHTX. This
sensor supports humidity, and optionally, temperature, slider switch,
and override switch reporting. The HWXPHTX used to develop this driver
did not include the optional slider or override switches, however
support for them is provided.
It was developed using an RS232->RS485 inteface. You cannot use the
built in MCU TTL UART pins for accessing this device you must use a
full serial RS232->RS485 interface connected via USB.
C++ includes: hwxpxx.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, HWXPXX, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, HWXPXX, name)
__repr__ = _swig_repr
INPUT_HUMIDITY = _pyupm_hwxpxx.HWXPXX_INPUT_HUMIDITY
INPUT_TEMPERATURE = _pyupm_hwxpxx.HWXPXX_INPUT_TEMPERATURE
INPUT_SLIDER = _pyupm_hwxpxx.HWXPXX_INPUT_SLIDER
COIL_TEMP_SCALE = _pyupm_hwxpxx.HWXPXX_COIL_TEMP_SCALE
COIL_OVERRIDE = _pyupm_hwxpxx.HWXPXX_COIL_OVERRIDE
HOLDING_TEMP_OFFSET = _pyupm_hwxpxx.HWXPXX_HOLDING_TEMP_OFFSET
HOLDING_HUM_OFFSET = _pyupm_hwxpxx.HWXPXX_HOLDING_HUM_OFFSET
def __init__(self, *args):
"""
HWXPXX(std::string
device, int address, int baud=19200, int bits=8, char parity='N', int
stopBits=2)
HWXPXX constructor
Parameters:
-----------
device: Path to the serial device
address: The MODBUS slave address
baud: The baudrate of the device. Default: 19200
bits: The number of bits per byte. Default: 8
parity: The parity of the connection, 'N' for None, 'E' for Even, 'O'
for Odd. Default: 'N'
stopBits: The number of stop bits. Default: 2
"""
this = _pyupm_hwxpxx.new_HWXPXX(*args)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_hwxpxx.delete_HWXPXX
__del__ = lambda self: None
[docs] def update(self):
"""
void update()
Read current values from the sensor and update internal stored values.
This method must be called prior to querying any values, such as
temperature, humidity, override switch status, or slider switch
status.
"""
return _pyupm_hwxpxx.HWXPXX_update(self)
[docs] def getTemperature(self, fahrenheit=False):
"""
float
getTemperature(bool fahrenheit=false)
Get the current temperature. update() must have been called prior to
calling this method. If this option was not installed, this method
will always return 0C/0F, depending on the scale the device is
operating in natively.
Parameters:
-----------
fahrenheit: true to return the temperature in degrees fahrenheit,
false to return the temperature in degrees celsius. The default is
false (degrees Celsius).
The last temperature reading in Celsius or Fahrenheit
"""
return _pyupm_hwxpxx.HWXPXX_getTemperature(self, fahrenheit)
[docs] def getHumidity(self):
"""
float getHumidity()
Get the current relative humidity. update() must have been called
prior to calling this method.
The last humidity reading
"""
return _pyupm_hwxpxx.HWXPXX_getHumidity(self)
[docs] def getSlider(self):
"""
int getSlider()
Get the current slider switch position. update() must have been called
prior to calling this method. This returns a value between 0-100
corresponding to the position of the slider switch. If this option is
not installed, this method will always return 0.
The last slider switch reading
"""
return _pyupm_hwxpxx.HWXPXX_getSlider(self)
[docs] def getOverrideSwitchStatus(self):
"""
bool
getOverrideSwitchStatus()
Get the current override switch status. update() must have been called
prior to calling this method. This returns true if the override switch
was pressed. Use clearOverrideSwitch() to reset this value to false.
If this option is not installed, then this method will always return
false. It is not possible to programatically set this value to true -
that can only be done by physically pressing the override switch.
The last overide switch status reading
"""
return _pyupm_hwxpxx.HWXPXX_getOverrideSwitchStatus(self)
[docs] def clearOverrideSwitch(self):
"""
void
clearOverrideSwitch()
Clear the override switch status (set it to false). If this option is
not installed, then this method will have no effect (the overide
switch status will always be false).
"""
return _pyupm_hwxpxx.HWXPXX_clearOverrideSwitch(self)
[docs] def getTemperatureOffset(self):
"""
int
getTemperatureOffset()
Return the current temperature offset stored on the device. This is a
value between -50 and +50, specified in tenths of a degree in whatever
scale (Celsius or Fahrenheit) is in use. This offset is applied to the
returned temperature reading by the device.
The current temperature offset in tenths of a degree
"""
return _pyupm_hwxpxx.HWXPXX_getTemperatureOffset(self)
[docs] def getHumidityOffset(self):
"""
int
getHumidityOffset()
Return the current humidity offset stored on the device. This is a
value between -100 and +100, specified in tenths of a percent. This
offset is applied to the returned humidity reading by the device.
The current humidity offset in tenths of a percent
"""
return _pyupm_hwxpxx.HWXPXX_getHumidityOffset(self)
[docs] def setTemperatureOffset(self, offset):
"""
void
setTemperatureOffset(int offset)
Set the stored temperature offset on the device. This is a value
between -50 and +50, specified in tenths of a degree in what ever
scale (Celsius or Fahrenheit) is in use. This offset is applied to the
returned temperature reading by the device.
Parameters:
-----------
offset: Offset in tenths of a degree with a range of -50 to +50
"""
return _pyupm_hwxpxx.HWXPXX_setTemperatureOffset(self, offset)
[docs] def setHumidityOffset(self, offset):
"""
void
setHumidityOffset(int offset)
Set the stored humidity offset on the device. This is a value between
-100 and +100, specified in tenths of a percent. This offset is
applied to the returned humidity reading by the device.
Parameters:
-----------
offset: Offset in tenths of a percent with a range of -100 to +100
"""
return _pyupm_hwxpxx.HWXPXX_setHumidityOffset(self, offset)
[docs] def setTemperatureScale(self, fahrenheit):
"""
void
setTemperatureScale(bool fahrenheit)
Set the temperature scale used by the device. This driver detects this
setting automatically and adjusts itself accordingly, so this is
generally never needed. It is used to set the native reporting scale
of the temperature either in degrees Celsius or Fahrenheit. Its
setting will not affect the operation of getTemperature().
Parameters:
-----------
fahrenheit: true to set Fahrenheit, false to set Celsius
"""
return _pyupm_hwxpxx.HWXPXX_setTemperatureScale(self, fahrenheit)
[docs] def getSlaveID(self):
"""
string getSlaveID()
Return a string corresponding the the device's MODBUS slave ID. This
includes information such as the manufacturer, device model number and
serial number.
string represnting the MODBUS slave ID
"""
return _pyupm_hwxpxx.HWXPXX_getSlaveID(self)
[docs] def setSlaveAddress(self, addr):
"""
void
setSlaveAddress(int addr)
Set a new MODBUS slave address. This is useful if you have multiple
HWXPXX devices on a single bus. When this method is called, the
current temperature scale is re-read so that further update() calls
can work correctly.
Parameters:
-----------
addr: The new slave address to set
"""
return _pyupm_hwxpxx.HWXPXX_setSlaveAddress(self, addr)
[docs] def setDebug(self, enable):
"""
void setDebug(bool
enable)
Enable or disable debugging output. This primarily enables and
disables libmodbus debugging output.
Parameters:
-----------
enable: true to enable debugging, false otherwise
"""
return _pyupm_hwxpxx.HWXPXX_setDebug(self, enable)
HWXPXX_swigregister = _pyupm_hwxpxx.HWXPXX_swigregister
HWXPXX_swigregister(HWXPXX)
# This file is compatible with both classic and new-style classes.