RadioShack 2200087 DMM Interface (tendril.testing.instruments.RS2200087
)¶
This module provides the instrument object for RadioShack’s 2200087 Digital
Multimeter with PC interface. It uses the driver2200087
module to
handle the communication with the instrument, while subclassing the Twisted
protocol of that module to provide one which produces
tendril.utils.types.signalbase.SignalPoint
and
tendril.utils.types.signalbase.SignalWave
objects instead, which
contain Type objects from the tendril.utils.types
module. This allows
seamless integration with Tendril’s tendril.testing
module.
Usage example
>>> from crochet import setup
>>> setup()
>>> from tendril.testing.instruments import get_instrument_object
>>> o = get_instrument_object('RS2200087')
>>> o.connect()
>>> o.channel.get()
>>> o.channel.reset_wave()
>>> wave = o.channel.get_next_chunk()
>>> wave += o.channel.get_next_chunk()
Module Contents
Classes
InstrumentRS2200087 () |
This is the primary class provided by this module, and the object generated by tendril.testing.instruments.get_instrument_object() is an instance of this class. |
DMMInputChannel (parent, interface) |
This class provides the bulk of the accessors to the instrument for downstream use. |
TendrilProtocol2200087 (port, buffer_size) |
This subclasses the twisted protocol from driver2200087.runner which handles serial communications with 2200087 multimeters. |
TendrilFactory2200087 () |
This factory produces protocols integrated with Tendril unit classes, producing SignalPoints and SignalWaves instead of strings. |
factory |
Module’s instance of the Protocol Factory. |
Processors
rex_list |
List of regular expressions, each of which matches the string for one type of data from driver2200087.serialDecoder . |
voltage_processor (m) |
Processor that converts a regex match of a Voltage string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
resistance_processor (m) |
Processor that converts a regex match of a Resistance string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
capacitance_processor (m) |
Processor that converts a regex match of a Capacitance string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
frequency_processor (m) |
Processor that converts a regex match of a Frequency string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
time_processor (m) |
Processor that converts a regex match of a Time string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
current_processor (m) |
Processor that converts a regex match of a Current string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
power_processor (m) |
Processor that converts a regex match of a PowerRatio string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
duty_processor (m) |
Processor that converts a regex match of a DutyCycle string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
hfe_processor (m) |
Processor that converts a regex match of a HFR string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
continuity_processor (m) |
Processor that converts a regex match of a Continuity string from driver2200087.serialDecoder and returns a string compatible with Tendril Unit Types. |
-
tendril.testing.instruments.RS2200087.
voltage_processor
(m)[source]¶ Processor that converts a regex match of a Voltage string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the Voltage regexs inrex_list
Returns: String compatible with the tendril.utils.types.electromagnetic.Voltage
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
resistance_processor
(m)[source]¶ Processor that converts a regex match of a Resistance string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the Resistance regexs inrex_list
Returns: String compatible with the tendril.utils.types.electromagnetic.Resistance
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
capacitance_processor
(m)[source]¶ Processor that converts a regex match of a Capacitance string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the Capacitance regexs inrex_list
Returns: String compatible with the tendril.utils.types.electromagnetic.Capacitance
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
frequency_processor
(m)[source]¶ Processor that converts a regex match of a Frequency string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the Frequency regexs inrex_list
Returns: String compatible with the tendril.utils.types.time.Frequency
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
time_processor
(m)[source]¶ Processor that converts a regex match of a Time string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the Time regexs inrex_list
Returns: String compatible with the tendril.utils.types.time.TimeSpan
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
current_processor
(m)[source]¶ Processor that converts a regex match of a Current string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the Current regexs inrex_list
Returns: String compatible with the tendril.utils.types.electromagnetic.Current
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
power_processor
(m)[source]¶ Processor that converts a regex match of a PowerRatio string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the PowerRatio regexs inrex_list
Returns: String compatible with the tendril.utils.types.electromagnetic.PowerRatio
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
hfe_processor
(m)[source]¶ Processor that converts a regex match of a HFR string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the HFE regexs inrex_list
Returns: String compatible with the tendril.utils.types.electromagnetic.HFE
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
duty_processor
(m)[source]¶ Processor that converts a regex match of a DutyCycle string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the DutyCycle regexs inrex_list
Returns: String compatible with the tendril.utils.types.electromagnetic.DutyCycle
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
continuity_processor
(m)[source]¶ Processor that converts a regex match of a Continuity string from
driver2200087.serialDecoder
and returns a string compatible with Tendril Unit Types.Parameters: m – re.match
object from one of the Continuity regexs inrex_list
.Returns: String compatible with the tendril.utils.types.electromagnetic.Continuity
class and its subclassesReturn type: str
-
tendril.testing.instruments.RS2200087.
rex_list
= [(<class 'tendril.utils.types.thermodynamic.Temperature'>, <_sre.SRE_Pattern object>, None), (<class 'tendril.utils.types.electromagnetic.VoltageDC'>, <_sre.SRE_Pattern object at 0x4b01230>, <function voltage_processor>), (<class 'tendril.utils.types.electromagnetic.VoltageAC'>, <_sre.SRE_Pattern object at 0x3ec6740>, <function voltage_processor>), (<class 'tendril.utils.types.electromagnetic.CurrentDC'>, <_sre.SRE_Pattern object at 0x49a4bb0>, <function current_processor>), (<class 'tendril.utils.types.electromagnetic.CurrentAC'>, <_sre.SRE_Pattern object at 0x4b32d50>, <function current_processor>), (<class 'tendril.utils.types.electromagnetic.Continuity'>, <_sre.SRE_Pattern object>, <function continuity_processor>), (<class 'tendril.utils.types.electromagnetic.DiodeVoltageDC'>, <_sre.SRE_Pattern object>, <function voltage_processor>), (<class 'tendril.utils.types.electromagnetic.Resistance'>, <_sre.SRE_Pattern object at 0x3e4b1b0>, <function resistance_processor>), (<class 'tendril.utils.types.electromagnetic.Capacitance'>, <_sre.SRE_Pattern object at 0x4676e80>, <function capacitance_processor>), (<class 'tendril.utils.types.time.Frequency'>, <_sre.SRE_Pattern object>, <function frequency_processor>), (<class 'tendril.utils.types.electromagnetic.PowerRatio'>, <_sre.SRE_Pattern object>, <function power_processor>), (<class 'tendril.utils.types.electromagnetic.DutyCycle'>, <_sre.SRE_Pattern object>, <function duty_processor>), (<class 'tendril.utils.types.time.TimeSpan'>, <_sre.SRE_Pattern object at 0x42b9bd0>, <function time_processor>), (<class 'tendril.utils.types.electromagnetic.HFE'>, <_sre.SRE_Pattern object>, <function hfe_processor>)]¶ List of regular expressions, each of which matches the string for one type of data from
driver2200087.serialDecoder
. Each element of the list is a tuple, containing the following elements:- Tendril type class from
tendril.utils.types
which is applicable to the data point. - The compiled regular expression.
- The applicable processor, which acts on the match object to produce a string. If the processor is None, then the named match group ‘string’ is used to instantiate the appropriate unit class.
- Tendril type class from
-
class
tendril.testing.instruments.RS2200087.
TendrilProtocol2200087
(port, buffer_size)[source]¶ Bases:
driver2200087.runner.InstProtocol2200087
This subclasses the twisted protocol from
driver2200087.runner
which handles serial communications with 2200087 multimeters. It producestendril.utils.types.signalbase.SignalPoint
andtendril.utils.types.signalbase.SignalWave
objects instead of strings and deque objects, which contain Type objects from thetendril.utils.types
module.This protocol exists and operates within the context of a twisted reactor. Applications themselves built on twisted should be able to simply import this protocol (or its factory).
Synchronous / non-twisted applications should directly use the
driver2200087.runner.InstInterface2200087
class instead, and pass this protocol’s factory to modify its behavior.Parameters: -
reset_buffer
(unitclass=<class 'tendril.utils.types.unitbase.DummyUnit'>)[source]¶ Resets the point buffer to a new
tendril.utils.types.signalbase.SignalWave
with the unitclass as specified by the parameter. Any data presently within it will be lost.Parameters: unitclass – Class of Unit that the Wave points are composed of.
-
connectionLost
(reason=<twisted.python.failure.Failure twisted.internet.error.ConnectionDone: Connection was closed cleanly.>)[source]¶ This function is called by twisted when the connection to the serial transport is lost.
-
next_chunk
()[source]¶ Returns: The next chunk of data points in the form of a SignalWave Return type: tendril.utils.types.signalbase.SignalWave
-
_get_point
(string)[source]¶ Processes a string returned by
driver2200087.serialDecoder
and converts it into atendril.utils.types.signalbase.SignalPoint
instance composed of the correct Unit class.Returns: SignalPoint composed of the correct type and value from the string Return type: tendril.utils.types.signalbase.SignalPoint
See also
-
-
class
tendril.testing.instruments.RS2200087.
TendrilFactory2200087
[source]¶ Bases:
driver2200087.runner.InstFactory2200087
This factory produces protocols integrated with Tendril unit classes, producing SignalPoints and SignalWaves instead of strings.
See the
driver2200087.runner.InstFactory2200087
documentation for more detailed information.
-
tendril.testing.instruments.RS2200087.
factory
= <tendril.testing.instruments.RS2200087.TendrilFactory2200087 instance>¶ Module’s instance of the Protocol Factory. This should be used whenever the Protocol class is to be instantiated (as opposed to subclassed)
-
class
tendril.testing.instruments.RS2200087.
DMMInputChannel
(parent, interface)[source]¶ Bases:
tendril.testing.instrumentbase.InstrumentInputChannelBase
This class provides the bulk of the accessors to the instrument for downstream use.
Parameters: - parent – The instrument of which this channel is a part of.
- interface – The interface to the instrument.
-
get
(unitclass=None, flush=True)[source]¶ Gets the latest data point in the channel’s point buffer. By default, it also flushes any older points from the buffer. This behavior can be suppressed by passing flush=False.
Parameters: - unitclass – Unit class of which the data point is expected, or None if you don’t care.
- flush – Whether or not older points should be flushed. Default True.
Returns: Latest datapoint.
Return type:
-
get_next_chunk
(unitclass=None)[source]¶ Gets the next chunk of data from the instrument channel. Note that the chunk returned has already been removed from the channel’s point buffer.
Parameters: unitclass – Unit class of which the data point is expected, or None if you don’t care. Returns: Wave containing all but the latest data point in the channel’s point buffer. Return type: tendril.utils.types.signalbase.SignalWave
-
class
tendril.testing.instruments.RS2200087.
InstrumentRS2200087
[source]¶ Bases:
tendril.testing.instrumentbase.InstrumentBase
This is the primary class provided by this module, and the object generated by
tendril.testing.instruments.get_instrument_object()
is an instance of this class. All downstream Tendril application code interfaces with this class, and through it, withDMMInputChannel
.The primary code access to this class is though it’s
channel
property.Instantiating this object results in the calling of
_detect()
, which prepares the object for use.Variables: _dmm – The underlying instrument interface object -
_detect
()[source]¶ Creates and initializes the
driver2200087.runner.InstInterface2200087
object, which in turn creates the protocol object and establishes the connection to the device.The instrument interface object created is stored in the object’s
_dmm
instance variable.Subsequently, a
DMMInputChannel
instance is instantiated and linked to the interface.
-
channel
¶ Returns: The IntrumentInputChannel object. Return type: DMMInputChannel
-