MCPcopy Create free account
hub / github.com/enthought/comtypes / test

Method test

comtypes/test/test_agilent.py:21–80  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

19
20 class Test(unittest.TestCase):
21 def test(self):
22 # The point of this test is the ReadWaveform method below,
23 # which takes several [in, out] arguments.
24 agDrvr = CreateObject("Agilent546XX.Agilent546XX")
25
26 # XXX XXX XXX The following call crashes hard with an accessviolation when
27 # the OANOCACHE environ variable is set.
28 import os
29
30 if "OANOCACHE" in os.environ:
31 print("Cannot test. buggy COM object?")
32 return
33
34 # Initialize the driver in simulation mode. Resource descriptor is ignored.
35 agDrvr.Initialize("", False, False, "Simulate=true")
36 # Initialize driver. Edit resource descriptor for your system.
37 # agDrvr.Initialize("GPIB0::7::INSTR", False, False, "QueryInstrStatus=true")
38
39 from comtypes.gen import IviScopeLib
40
41 iviDrvr = agDrvr.QueryInterface(IviScopeLib.IIviScope)
42
43 # Get driver Identity properties. Driver initialization not required.
44 # print "Identifier:", iviDrvr.Identity.Identifier
45 # print " Revision:", agDrvr.Identity.Revision
46 # print "Description:", agDrvr.Identity.Description
47
48 # Get instrument Identity properties.
49 # print "InstrumentModel: ", agDrvr.Identity.InstrumentModel
50 # print " FirmwareRevision: ", agDrvr.Identity.InstrumentFirmwareRevision
51 # print " SerialNumber: ", agDrvr.System.SerialNumber
52
53 # Setup for a measurement. Reset in this case.
54 agDrvr.Utility.Reset()
55
56 pMeasurement = agDrvr.Measurements.Item("UserChannel1")
57 # ReadWaveform() takes a sweep and reads the data.
58 #
59 # Definition generated for ReadWaveform():
60 # COMMETHOD([helpstring(u'Acquires and returns a waveform on the configured channels.')],
61 # HRESULT, 'ReadWaveform',
62 # ( ['in'], Agilent546XXTimeOutEnum, 'MaxTime' ),
63 # ( ['in', 'out'], POINTER(_midlSAFEARRAY(c_double)), 'pWaveformArray' ),
64 # ( ['in', 'out'], POINTER(c_double), 'pInitialX' ),
65 # ( ['in', 'out'], POINTER(c_double), 'pXIncrement' )),
66
67 # [in, out] arguments are now optional (comtypes
68 # constructs an empty default value when nothing is
69 # passed).
70 psaWaveform = _midlSAFEARRAY(c_double).create([])
71 self._check_result(pMeasurement.ReadWaveform(20000))
72 self._check_result(pMeasurement.ReadWaveform(20000, pInitialX=9.0))
73 self._check_result(
74 pMeasurement.ReadWaveform(20000, pXIncrement=9.0, pInitialX=3.0)
75 )
76 self._check_result(pMeasurement.ReadWaveform(20000))
77 self._check_result(pMeasurement.ReadWaveform(20000, []))
78 self._check_result(pMeasurement.ReadWaveform(20000, pWaveformArray=[]))

Callers

nothing calls this directly

Calls 6

_check_resultMethod · 0.95
CreateObjectFunction · 0.90
_midlSAFEARRAYFunction · 0.90
QueryInterfaceMethod · 0.45
ResetMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected