Mock Driver Level¶
The library comes with a support for rs232 (slow) and bulk USB(recommended) interfaces. It also has a mock driver that allows testing and debugging of the software.
To import the mock driver instead of actual driver for the DI-4108
In [1]: from icarus_nmr.driver_mock import Driver
In [2]: driver = Driver()
To fully initialize the driver and start the data collection.
In [3]: driver.init()
In [4]: driver.get_hardware_information()
Out[4]:
{b'Device name': '4108',
b'Firmware version': 'VS',
b'Serial Number': '00000000',
b'Sample Rate Divisor': '60000000'}
The current readings can be requested.
In [6]: driver.get_readings()
Out[6]:
(array([[10999, -9, 8005, 28, 7979, 10966, 9028, -13, 0,
127]], dtype=int16), True)
The mock driver generates random data to simulate actual data stream from DI-4108. These are the control variables that define what is the level of a signal and what is noise.
In [8]: driver.sim_digital
Out[8]: 127
In [9]: driver.sim_analog
Out[9]: [11000, 0, 8000, 0, 8000, 11000, 9000, 0]
In [10]: driver.sim_analog_std
Out[10]: [30, 30, 30, 30, 30, 30, 30, 30]
One can also request a pressurization or depressurization traceback
Note, the code below does not work, see issue 9 on GitHub
#.. plot:: ./examples_py/get_depre_trace.py # :include-source:
Detailed description of the function and properties of the mock_driver class below.
- class icarus_nmr.driver_mock.Driver[source]¶
- get_hardware_information()[source]¶
emulates retrieval of information via usb. Creates two new atrbiutes to the class: self.dev_dict and self.epi_dict
- Returns
- dic :: dictionary
dictionary of hardware information
Examples
>>> dic = mock.get_hardware_information() >>> dic
- get_information()[source]¶
emulates retrieval of information via usb. Creates two new atrbiutes to the class: self.dev_dict and self.epi_dict
Examples
>>> mock.get_information()
- get_readings(points_to_read=1, to_read_analog=8, to_read_digital=1)[source]¶
the original get_readings function should just return data from the buffer on the DI-4108 DATAQ. Since this is module is a mock device, there are extra functionality build in into this specific function. The function handles random number generation around specified values with specified standard deviations. The fucntion also includes what happens if pressurization and depresurrization event flags are True.
- parse_binary_number(value=0, Nbits=7)[source]¶
parses integer number into bits and represents them as an array
- Parameters
- value :: integer
integer number
Examples
>>> mock.write(command = 'info 1 \r')
- pinhole_leak()[source]¶
creates a pin hole leak event. Values in channel 5,6 are set to 0.
Examples
>>> mock.pinhole_leak()
- readall()[source]¶
reads all information in the usb buffer
- Returns
- buffer :: string
buffer information as a string
Examples
>>> dic = mock.get_hardware_information() >>> dic
- set_acquisition_rate(rate=1000, baserate=20000, dec=0, echo=True)[source]¶
sets acquisition rate (simulation rate)
- Parameters
- rate :: integer
integer number that will be set to DI-4108 digital outputs
- baserate :: boolean, optional
optional flag that turn on reply.
- dec :: integer
Examples
>>> mock.set_acquisition_rate(rate = 1000, baserate = 20000, dec = 4)
- set_digital(number=127, echo=False)[source]¶
sets digital value. The mock driver emulates pressure transitions due to change in digital state.
- Parameters
- number :: integer
integer number that will be set to DI-4108 digital outputs
- echo :: boolean, optional
optional flag that turn on reply.
Examples
>>> mock.set_digital(number = 127)