PyICe.twi_instrument¶
Channel Wraper for SMBus Compliant Devices¶
Can automatically populate channels/reisters from XML description
Classes
twi_instrument (interface_twi[, ...]) |
|
twi_instrument_dummy () |
use for formatters, etc without having to set up a master and physical hardware. |
-
class
PyICe.twi_instrument.
twi_instrument_dummy
[source]¶ Bases:
PyICe.twi_instrument.twi_instrument
use for formatters, etc without having to set up a master and physical hardware.
-
add_channel
(channel_name)¶ - Usage: Add channel name to instrument. For multi-channel instruments,
- typically also takes a second argument representing the physical channel of the instrument. May also take channel configuration arguments specific to the instrument.
Operation: This method should create the channel object then call self._add_channel(channel) to add it to the internal channel group
Method must be overloaded by each instrument driver.
-
create_format
(format_name, format_function, unformat_function, signed=False, description=None, units='')¶ Create a new format definition or modify an existing definition.
format_function should take a single argument of integer raw data from the register and return a version of the data scaled to appropriate units. unformat_function should take a single argument of data in real units and return an integer version of the data scaled to the register LSB weight. If the data is signed in two’s-complement format, set signed=True. After creating format, use set_active_format method to make the new format active.
-
get_constant
(constant)¶ Sets the constants found in the datasheet used by the formatters to convert from real world values to digital value and back.
-
get_error
()¶ Return the first error from the instrument. Overload in scpi_instrument or the actual instrument class
-
get_errors
()¶ Return a list of all errors from the instrument. Overload in scpi_instrument or the actual instrument class
-
get_flat_channel_group
(name=None)¶ returns a channel_group directly containing all channels this one can resolve
-
list_constants
()¶ Returns the list of constants found in the datasheet used by the formatters to convert from real world values to digital value and back.
-
merge_in_channel_group
(channel_group_object)¶ merges in a channel group
-
populate_from_file
(xml_file, format_dict={}, access_list=[], use_case=None, channel_prefix='', channel_suffix='')¶ - xml_register parsing accepts xml input complying with the following DTD (register_map.dtd):
<!– Visit http://en.wikipedia.org/wiki/Document_Type_Definition for an excellent explanation of DTD syntax –> <!ELEMENT register_map (chip+, use*, format_definitions?)> <!ELEMENT chip (description, address+, command_code*)> <!ELEMENT address EMPTY> <!ELEMENT command_code (description?, access+, bit_field+)> <!ELEMENT access EMPTY> <!ELEMENT bit_field (description, default?, preset*, format*)> <!ELEMENT description (#PCDATA)> <!ELEMENT default (#PCDATA)> <!ELEMENT preset (description?)> <!ELEMENT format EMPTY> <!ELEMENT use (category+)> <!ELEMENT category (#PCDATA)> <!ELEMENT format_definitions (format_definition+)> <!ELEMENT format_definition (description, transformed_units?, piecewise_linear_points?)> <!ELEMENT transformed_units (#PCDATA)> <!ELEMENT piecewise_linear_points (point,point+)> <!ELEMENT point EMPTY> <!ATTLIST chip name CDATA #REQUIRED word_size CDATA #REQUIRED> <!ATTLIST address address_7bit CDATA #REQUIRED> <!ATTLIST command_code name ID #REQUIRED value CDATA #REQUIRED> <!ATTLIST bit_field name ID #REQUIRED size CDATA #REQUIRED offset CDATA #REQUIRED category CDATA #REQUIRED> <!ATTLIST access mode CDATA #REQUIRED type (read | write) #REQUIRED> <!ATTLIST preset name CDATA #REQUIRED value CDATA #REQUIRED> <!ATTLIST format name IDREF #REQUIRED> <!ATTLIST use name CDATA #REQUIRED> <!ATTLIST format_definition name ID #REQUIRED signed (True | False | 1 | 0) #REQUIRED> <!ATTLIST point native CDATA #REQUIRED transformed CDATA #REQUIRED>
-
read_all_channels
(categories=None, exclusions=[])¶ read all readable channels in channel group and return orderd dictionary of results. Optionally filter by list of categories.
-
read_channels
(item_list)¶ item list is a list of channel objects, names or channel_groups
-
resolve_channel_list
(item_list)¶ takes a list of channels, channel_names, or channel_groups and produces a single channel group
-
set_constant
(constant, value)¶ Sets the constants found in the datasheet used by the formatters to convert from real world values to digital value and back.
-
write_html
(file_name=None, verbose=True, sort_categories=False)¶ return html document string and optionally write to file_name if verbose, include tables of presets and attributes for each channel if sort_categories, group channel names first by category before alphabetical sort of channel name
-