ops.system — Provides high-level control over the production system

This module contains the ProductionSystem class – the cornerstone of the application.

The ProductionSystem Class

class ops.system.ProductionSystem

A class that provides high-level control over an FCI-7011 fiber coupler production system (the device). Each instance of this class wraps a DeviceInterface object (which handles the communication with the device) and complements the low-level functionality it provides with a number of high-level services:

  • Instances hold calibration data for the device. If this calibration data is complete, clients can interact with the device in terms of heating temperatures rather than temperature sensor voltages and heating currents by using its temperature property and startHeatingToTemperature() method. The calibration data itself is stored in a CalibrationData object, and can be accessed using the calibrationData property.

    The necessary data can be gathered by performing a calibration procedure, which requires the application’s user to take a series of temperature measurements, and may take several hours. A calibration procedure can be started by calling startCalibration(). See the documentation for ops.calibration.manager for further information

    To check whether an instance has a complete set of calibration data for its device, use isCalibrated.

  • Instances monitor the device’s temperature and temperature sensor voltage. If either exceeds its safe limits (maxSafeTemperature and maxSafeTemperatureSensorVoltage, respectively), the instance is switched into its safe mode. In safe mode, the device’s heating current is set to heatingCurrentInSafeMode, and the instance’s isInSafeMode flag is set. The instance leaves safe mode when a new new heating procedure is started.

  • Instances can be locked. While an instance is locked, clients cannot perform any operations on the device without providing the appropriate key. This ensures that different operations do not interfere with each other.

    To lock or unlock an instance, use the lock() and unlock() methods. To check whether an instance is locked, use the isLocked property.

An ops.simulation.SimulatedDeviceInterface object can be substituted for the DeviceInterface in order to test the application without using an actual device.

General Attributes

ProductionSystem.__init__(mediator, interface=None)

Instantiates a new instance of this class.

mediator is used to set mediator.

interface is the DeviceInterface the instance uses to communicate with the device it controls, a SimulatedDeviceInterface, or None, in which case a new SimulatedDeviceInterface object is used.

ProductionSystem.mediator
The Mediator the instance uses to communicate with the GUI, or an object that provides a compatible interface. Immutable.

Locking

ProductionSystem.isLocked
Indicates whether the instance is locked. Read-only. To lock or unlock the instance, use the lock() and unlock() methods.
ProductionSystem.lock(key)

Locks the instance with the given key. While it is locked, clients cannot perform any operations on the device without providing the appropriate key.

Any object other than None may be used as the key. If the instance is already locked, a SystemLockedError is raised.

ProductionSystem.unlock(key)
Unlocks the instance, using the given key. If the instance is not locked, a SystemNotLockedError is raised. If a key other than the one used to lock the instance is passed, a WrongKeyError is raised.

Calibration

ProductionSystem.isCalibrated
Indicates whether the instance has complete calibration data for the device. This is always False while a calibration procedure is underway. Read -only.
ProductionSystem.isBeingCalibrated
Indicates whether a calibration procedure is underway. Read-only.
ProductionSystem.calibrationData

A CalibrationData object that holds the resuts of the calibration procedure of the device the instance controls.

May be modified, but the new calibration data object may not be currently used by another ProductionSystem (that is, its system property must be None), or an ApplicationError is raised.

ProductionSystem.calibrationManager
The CalibrationManager that is managing the ongoing calibration procedure of the device the instance controls, or None if the device is not being calibrated. Read-only.
ProductionSystem.startCalibration(currents)

Starts a calibration procedure. currents is a list of the heating currents (in mA) for which measurements are to be taken. The actual work is done by ops.calibration.manager.CalibrationManager. See that class for further documentation.

This method is asynchronous. The calibration procedure itself may take several hours to complete, but the method returns immediately.

The instance is locked for the duration of the calibration procedure. If the instance is already locked when this method is called, a SystemLockedError is raised.

During the calibration procedure, the application’s user needs to be available to take a series of temperature measurements.

ProductionSystem.abortCalibration()
Aborts the ongoing calibration procedure.

Monitoring

ProductionSystem.isInSafeMode
Indicates whether the instance is in its safe mode. Read-only.
ProductionSystem.monitorInterval
The interval the temperature is monitored in, in milliseconds. This is a class attribute. Setting it on an instance has no effect.
ProductionSystem.maxSafeTemperature
The highest safe heating temperature, in °C. If this temperature is exceeded, the instance switches into its safe mode. The device needs to be calibrated for this to work.
ProductionSystem.maxSafeTemperatureSensorVoltage
The highest safe temperature sensor voltage, in V. If this voltage is exceeded the instance switches into its safe mode. Having a highest safe temperature sensor voltage as well as a highest safe heating temperature allows monitoring the device even if it is uncalibrated.
ProductionSystem.heatingCurrentInSafeMode
The heating current used in safe mode, in mA.
ProductionSystem.enterSafeMode()

Switches the instance into its safe mode. In safe mode, the device’s heating current is set to heatingCurrentInSafeMode, and the instance’s isInSafeMode flag is set. The instance leaves safe mode when a new new heating procedure is started.

Calling this method on a locked instance does not require a key; operations must be able to deal with the fact that the instance may unexpectedly enter safe mode while they are running. Entering safe mode does not unlock the instance, however.

Heating

ProductionSystem.heatingCurrent
The device’s heating current, in mA. Read-only. To change the heating current, use the startHeatingWithCurrent() method.
ProductionSystem.heatingCurrentWhileIdle
The heating current used when the device is idle, in mA.
ProductionSystem.maxHeatingCurrent
The highest legal heating current, in mA.
ProductionSystem.temperatureSensorVoltage

The voltage reported by the temperature sensor, in V. Read-only.

In most cases, clients will want to use temperature instead.

Note

If the heater is not in its foremost position (see heaterPosition), the returned voltage will not be an accurate reflection of the heater’s temperature. If the user has moved the temperature sensor aside, it will be unrelated to the heater’s temperature.

ProductionSystem.temperature

The heating temperature that corresponds to the measured temperature sensor voltage, in °C, or None if the device isn’t calibrated. Read-only.

Note

The returned temperature is only accurate if the temperature sensor can get an accurate reading. If the heater is not in its foremost position (see heaterPosition), the returned temperature will be inaccurate. If the user has moved the temperature sensor aside, it will be unrelated to the actual heating temperature.

ProductionSystem.targetTemperature

The temperature the heater is being heated to, in °C, or None if it is not being heated to a particular temperature.

Read-only. To change the target temperature, or start heating towards a particular temperature, use the startHeatingToTemperature() method.

Changing the heating current using startHeatingWithCurrent() resets this property to None.

ProductionSystem.minTargetTemperature

The lowest target temperature that can be passed to startHeatingToTemperature(), in °C, or None if the device is not calibrated.

The value is equal to the lowest temperature measured during the calibration procedure. Read-only.

ProductionSystem.maxTargetTemperature

The highest target temperature that can be passed to startHeatingToTemperature(), in °C, or None if the device is not calibrated.

The value is equal to the lowest of maxSafeTemperature, the temperature that can be reached with a heating current equal to maxHeatingCurrent, or the highest temperature measured during the calibration procedure. Read-only.

ProductionSystem.isValidTargetTemperature(temperature)

Indicates whether the given temperature (in °C) can be passed to startHeatingToTemperature(), that is, whether it lies between minTargetTemperature and maxTargetTemperature.

If the device is not calibrated, a NotCalibratedError is raised.

ProductionSystem.startHeatingWithCurrent(current, key=None)

Sets the device’s heating current to current, in mA. Also clears the isInSafeMode flag and sets targetTemperature to None.

If the instance is locked, the appropriate key must be passed, otherwise a SystemLockedError is raised. If the wrong key is passed, a WrongKeyError is raised. If a key is passed even though the instance is not locked, a SystemNotLockedError is raised.

If current is negative or exceeds maxHeatingCurrent, an InvalidHeatingCurrentError is raised.

ProductionSystem.startHeatingToTemperature(targetTemperature, key=None)

Sets the device’s heating current to a value that should result in the heater reaching, but not exceeding, targetTemperature, in °C. The device must be calibrated for this method to be usable. Also clears the isInSafeMode flag and sets targetTemperature to targetTemperature.

If the instance is locked, the appropriate key must be passed, otherwise a SystemLockedError is raised. If the wrong key is passed, a WrongKeyError is raised. If a key is passed even though the instance is not locked, a SystemNotLockedError is raised.

If the device is not calibrated, a NotCalibratedError is raised.

If targetTemperature is less than minTargetTemperature or greater then maxTargetTemperature, an InvalidTargetTemperatureError is raised.

The temperature sensor is not used by the heating procedure started by this method at all. The current used is determined from the temperature measurements taken during the calibration procedure, and no second-guessing based on the temperature sensor voltages reported during the heating procedure takes place. This means this method is not affected by the issues mentioned in the documentation for the temperature property.

This method is asynchronous. It will take some time for the heater to reach the target temperature, but the method will return immediately.

ProductionSystem.idle(key=None)

Sets the device’s heating current to heatingCurrentWhileIdle.

If the instance is locked, the appropriate key must be passed, otherwise a SystemLockedError is raised. If the wrong key is passed, a WrongKeyError is raised. If a key is passed even though the instance is not locked, a SystemNotLockedError is raised.

Heater Movement

ProductionSystem.heaterPosition
The position of the heater, as a fraction of the distance between rearmost position (0.0) and foremost position (1.0). Read-only. To move the heater to another position, use the startHeaterMovement() method.
ProductionSystem.heaterTargetPosition

The position the heater is supposed to be at, as a fraction of the distance between rearmost position (0.0) and foremost position (1.0).

If heaterTargetPosition is not equal to heaterPosition, the heater is still moving to its target position.

Read-only. To change the heater’s target position, use the startHeaterMovement() method.

ProductionSystem.startHeaterMovement(targetPosition, key=None)

Moves the heater to the given position, expressed as a fraction of the distance between rearmost position (0.0) and foremost position (1.0).

If the instance is locked, the appropriate key must be passed, otherwise a SystemLockedError is raised. If the wrong key is passed, a WrongKeyError is raised. If a key is passed even though the instance is not locked, a SystemNotLockedError is raised.

If targetPosition is less than 0.0 or greater than 1.0, an InvalidHeaterPositionError is raised.

This method is asynchronous. Moving the heater can take several seconds, but this method returns immediately.

To check which position the heater is currently moving to, use heaterTargetPosition; to get its actual position use heaterPosition.

Testing

ProductionSystem.isSimulation
Indicates whether the device the instance controls is simulated; that is, whether it wraps a SimulatedDeviceInterface or a DeviceInterface. Immutable.
ProductionSystem.speedFactor

The factor by which all operations performed with the device are sped up. Setting this property to, say, 5.0 greatly reduces the time required to test the application. Mutable.

This property is intended for testing purposes only. If the instance wraps a real DeviceInterface, any attempt to acess it raises a RequiresSimulationError.

ProductionSystem.performMagicCalibration()

Creates a CalibrationData object using the parameters of the SimulatedDeviceInterface used by the instance, and assigns it to calibrationData. Unlike a real calibration procedure, magic calibration is instant. The CalibrationManager is not used.

This method is intended for testing purposes only. If the instance wraps a real DeviceInterface, this method raises a RequiresSimulationError.

Magic calibration will generate measurements for heating currents starting at heatingCurrentWhileIdle and increasing in steps of 2 mA until they would exceed maxHeatingCurrent or the temperature sensor voltage reached with this current would exceed maxSafeTemperatureSensorVoltage.