Skip to content

DemoExfoCtp10#

Controls a simulated EXFO CTP10 component test platform from Python. It provides the same API as ExfoCtp10 without real hardware. This class inherits from MeasmaticDevice.


method check_error()#

Reads the next entry of the device error queue and stores it for get_error and get_last_error_code.

Returns#

Type Description
bool True if the error queue contained an error, otherwise False.

Example#

ctp = measmatic.get_device('device-ctp10')
if ctp.check_error():
print(ctp.get_error())

method discard_input_byte()#

Discards a pending line terminator in the receive buffer of the device communication.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.discard_input_byte()

method do_scan()#

Starts the wavelength scan that was defined with set_scan or set_sweep. The scan runs in the background, use wait_completed to wait for its end.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_scan(1, 1520.0, 1580.0, 10)
ctp.do_scan()
ctp.wait_completed(60000)

method get_error()#

Returns the text of the errors that were stored by the last check_error call.

Returns#

Type Description
str The error text, or an empty string if there is no stored error.

Example#

ctp = measmatic.get_device('device-ctp10')
if ctp.check_error():
print(ctp.get_error())

method get_laser(slot: int)#

Returns the description of the laser module in the given slot.

Parameters#

Name Description
slot The slot number (1..10).

Returns#

Type Description
str The description of the laser module.

Example#

ctp = measmatic.get_device('device-ctp10')
print(ctp.get_laser(1))

method get_last_error_code()#

Returns the code of the last error stored by check_error.

Returns#

Type Description
int The error code, or 0 if there is no stored error.

Example#

ctp = measmatic.get_device('device-ctp10')
if ctp.check_error():
print(ctp.get_last_error_code())

method get_receiver(slot: int)#

Returns the description of the detector module in the given slot.

Parameters#

Name Description
slot The slot number (1..10).

Returns#

Type Description
str The description of the detector module.

Example#

ctp = measmatic.get_device('device-ctp10')
print(ctp.get_receiver(1))

method laser_disable(slot: int)#

Switches the laser of the given slot off.

Parameters#

Name Description
slot The slot number (1..10).

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.laser_disable(1)

method laser_enable(slot: int)#

Switches the laser of the given slot on.

Parameters#

Name Description
slot The slot number (1..10).

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.laser_enable(1)

method read_intensity(slot: int, chan: int)#

Reads the current optical power of a detector channel.

Parameters#

Name Description
slot The slot number of the detector module (1..10).
chan The detector channel number.

Returns#

Type Description
float The measured optical power.

Example#

ctp = measmatic.get_device('device-ctp10')
power = ctp.read_intensity(2, 1)

method reset()#

Clears the error queue and the status registers of the device and forgets the laser selected with set_scan. A full factory reset is not performed because it takes very long.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.reset()

method retrieve_scan_result(slot: int, chan: int, trace: int, wavelength: Any, trace_data: Any)#

Retrieves the data of the last scan from a detector channel. The C# method has the out parameters wavelength and trace_data, which Python receives as part of the result tuple.

Parameters#

Name Description
slot The slot number of the detector module (1..10).
chan The detector channel number.
trace The trace type number.
wavelength Out parameter, returned as part of the result tuple.
trace_data Out parameter, returned as part of the result tuple.

Returns#

Type Description
bool True if scan data was available and has been returned, otherwise False.
float The wavelengths of the data points, as reported by the device.
float The trace values in dB, one per wavelength.

Example#

ctp = measmatic.get_device('device-ctp10')
ok, wavelength, trace_data = ctp.retrieve_scan_result(2, 1, 1)

method set_average_auto()#

Switches automatic averaging on for the laser that was last defined with set_scan.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_scan(1, 1520.0, 1580.0, 10)
ctp.set_average_auto()

method set_power(slot: int, dbm: float)#

Sets the output power of the laser in the given slot.

Parameters#

Name Description
slot The slot number of the laser module (1..10).
dbm The output power in dBm.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_power(1, 0.0)

method set_scan(startWavelength: float, stopWavelength: float, samplingPm: int, powerDbm: int)#

Defines the wavelength scan and the scan power for the first available scan laser.

Parameters#

Name Description
startWavelength The start wavelength in nm.
stopWavelength The stop wavelength in nm.
samplingPm The wavelength sampling step in pm.
powerDbm The scan power in dBm.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_scan(1520.0, 1580.0, 10, 0)

method set_scan(laserNumber: int, startWavelength: float, stopWavelength: float, samplingPm: int, powerDbm: int)#

Defines the wavelength scan and the scan power for the laser in the given slot.

Parameters#

Name Description
laserNumber The slot number of the laser module (1..10).
startWavelength The start wavelength in nm.
stopWavelength The stop wavelength in nm.
samplingPm The wavelength sampling step in pm.
powerDbm The scan power in dBm.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_scan(1, 1520.0, 1580.0, 10, 0)

method set_scan(laserNumber: int, startWavelength: float, stopWavelength: float, samplingPm: int)#

Defines the wavelength scan for the laser in the given slot. The scan power is not changed.

Parameters#

Name Description
laserNumber The slot number of the laser module (1..10).
startWavelength The start wavelength in nm.
stopWavelength The stop wavelength in nm.
samplingPm The wavelength sampling step in pm.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_scan(1, 1520.0, 1580.0, 10)

method set_scan_power(powerDbm: float)#

Sets the scan power of the laser that was last defined with set_scan. set_scan must be called first.

Parameters#

Name Description
powerDbm The scan power in dBm.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_scan(1, 1520.0, 1580.0, 10)
ctp.set_scan_power(0.0)

method set_scan_speed(speedNanometerPerSecond: int)#

Sets the scan speed of the laser that was last defined with set_scan. set_scan must be called first.

Parameters#

Name Description
speedNanometerPerSecond The scan speed in nm/s.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_scan(1, 1520.0, 1580.0, 10)
ctp.set_scan_speed(20)

method set_sweep(startWaveLength: float, stopWavelength: float, samplingPm: int)#

Defines the wavelength scan for the first available scan laser. The scan power is not changed.

Parameters#

Name Description
startWaveLength The start wavelength in nm.
stopWavelength The stop wavelength in nm.
samplingPm The wavelength sampling step in pm.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_sweep(1520.0, 1580.0, 10)

method set_wavelength(laserNumber: int, nanometer: float)#

Sets the fixed output wavelength of the laser in the given slot.

Parameters#

Name Description
laserNumber The slot number of the laser module (1..10).
nanometer The wavelength in nm.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.set_wavelength(1, 1550.0)

method wait_completed(timeoutMilliseconds: int)#

Waits until the device is idle again and returns the result of the final error check. Raises an error on timeout or on an unexpected device error.

Parameters#

Name Description
timeoutMilliseconds The maximum time to wait in milliseconds. A negative value waits without timeout.

Returns#

Type Description
int 0 on success, or the device error code if the scan has to be repeated (-338 or -334).

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.do_scan()
result = ctp.wait_completed(60000)

method wait_completed()#

Waits until the device is idle again, without timeout.

Example#

ctp = measmatic.get_device('device-ctp10')
ctp.do_scan()
ctp.wait_completed()