Source code for dpxDevice

from pypixxlib._libdpx import DPxUpdateRegCache, DPxSelectDevice, DPxGetID, \
    DPxGetPartNumber, DPxGetFirmwareRev, DPxGetRamSize, DPxGetCustomDevName, DPxSetCustomDevName, \
    DPxSetVidSource, DPxGetVidSource, DPxGetVidLine, DPxOpen, DPxClose, \
    DPxIsReady, DPxReadRam, DPxWriteRam, DPxGetTime, DPxGetTemp2Celcius, \
    DPxGetTempCelcius, DPxGetSupplyCurrent, DPxGetSupply2Current, DPxGetTemp3Celcius, \
    DPxGetSupplyVoltage, DPxGetSupply2Voltage, part_number_constants, \
    DPxReadProductionInfo, DPxGetVidHActive, DPxGetVidVActive, \
    DPxIsVidDviActiveDual, DPxIsVidDviActive, DPxSetCustomStartupConfig, \
    DPxGetError, DPxClearError, DPxWriteRegCache, DPxUpdateRegCacheAfterVideoSync, \
    DPxWriteRegCacheAfterVideoSync, DPxUpdateRegCacheAfterPixelSync, DPxWriteRegCacheAfterPixelSync, \
    DPxSetMarker, DPxGetMarker
from abc import ABCMeta

#from PySide2 import QtCore

import functools

[docs]def DpxExceptionDecorate(function): """ A decorator that wraps the passed in function and raise exceptions if occur """ @functools.wraps(function) def wrapper(*args, **kwargs): ret = function(*args, **kwargs) error = DPxGetError() if error != 'DPX_SUCCESS': DPxClearError() raise Exception(error) return ret return wrapper
[docs]class DpxDevice(object, metaclass=ABCMeta): """Implements the features common for all Devices. Attributes: identification: Number which identifies the type of device. part_number: Part number of the device. firmware_revision: Firmware revision of the device. ram_size: The size of the Ram found on the device. """ def __init__(self, device_type): DPxOpen() if DPxGetError() != 'DPX_SUCCESS': DPxClearError() DPxDeviceError = "No device found. Please make sure that the device is connected to the computer and powered on." raise Exception(DPxDeviceError) else: DPxSelectDevice(device_type) production_info = DPxReadProductionInfo() custom_name = DPxGetCustomDevName() if custom_name == '\x01': custom_name = custom_name = "" self.identification = production_info['Part Number'] self.serial_number = production_info['S/N'] self.name = part_number_constants[DPxGetPartNumber()] self.custom_dev_name = custom_name self.firmware_revision = DPxGetFirmwareRev() self.ram_size = str(DPxGetRamSize() // 1048576)+" MB" # // is integer division self.assembly_revision = production_info['Assembly REV'] self.date_shipped = production_info['Shipping Date'] self.expiration_date = production_info['Expiration Date'] self.id_number = DPxGetID() self.device_type = device_type self.subsystems = [] self.active = True @DpxExceptionDecorate def _updateInformation(self): DPxSelectDevice(self.device_type) production_info = DPxReadProductionInfo() self.identification = production_info['Part Number'] self.serial_number = production_info['S/N'] self.name = part_number_constants[ DPxGetPartNumber()] self.custom_dev_name = str(DPxGetCustomDevName()) self.firmware_revision = DPxGetFirmwareRev() self.ram_size = str(DPxGetRamSize() // 1048576)+" MB" # // is intenger divison self.assembly_revision = production_info['Assembly REV'] self.date_shipped = production_info['Shipping Date'] self.expiration_date = production_info['Expiration Date']
[docs] def getAvailableSubSystem(self): """Gets the available subsystems for the device. Returns: List: Name of subsystems found on the device. """ return self.subsystems
#gmarin DELETE @DpxExceptionDecorate def setActive(self): if DPxSelectDevice(self.device_type): self.active = True else: self.active = False # gmarin DELETE def isActive(self): return self.active
[docs] def open(self): """Opens a VPixx device. This method is used to get a handle on a VPixx device. """ DPxOpen()
[docs] def close(self): """Closes a VPixx device. This method is used to release a handle on a VPixx device. """ DPxClose()
[docs] @DpxExceptionDecorate def isReady(self): """Verifies if s device has been properly opened. """ return DPxIsReady()
[docs] @DpxExceptionDecorate def readRam(self, address, int_list): """Reads a block of VPixx RAM into a local buffer. Args: address (int): Any even value equal or greater to 0. length (int): Any of value from 0 to RAM size. """ return DPxReadRam(address, int_list)
[docs] @DpxExceptionDecorate def writeRam(self, address, int_list): """Writes a local buffer into VPixx RAM. Args: address (int): Any even value equal or greater to 0. int_list (int): int_list is a list which will fill with RAM data. The length of RAM used is based on the length of int_list. It can't be bigger than RAM size. """ DPxWriteRam(address, int_list)
[docs] @DpxExceptionDecorate def updateRegisterCache(self): """Updates the registers and local register cache. This is a blocking call until the device returns its registers. """ DPxSelectDevice(self.device_type) DPxUpdateRegCache()
[docs] @DpxExceptionDecorate def writeRegisterCache(self): """Writes the registers with local register cache. """ DPxSelectDevice(self.device_type) DPxWriteRegCache()
[docs] @DpxExceptionDecorate def updateRegCacheAfterVideoSync(self): """Updates the registers and local register cache on the next Video Sync (eg: Screen flip) This will not work with a device which does not have video input such as a TRACKPixx3. This is a blocking call until the devices recieves a Vsync and returns its registers. """ if self.device_type == "TRACKPixx": DPxDeviceError = "The TRACKPixx3 cannot be register synced with with video." raise Exception(DPxDeviceError) DPxSelectDevice(self.device_type) DPxUpdateRegCacheAfterVideoSync()
[docs] @DpxExceptionDecorate def writeRegCacheAfterVideoSync(self): """Write the registers and local register cache on the next Video Sync (eg: Screen flip) This will not work with a device which does not have video input such as a TRACKPixx3 """ if self.device_type == "TRACKPixx": DPxDeviceError = "The TRACKPixx3 cannot be register synced with with video." raise Exception(DPxDeviceError) DPxSelectDevice(self.device_type) DPxWriteRegCacheAfterVideoSync()
[docs] @DpxExceptionDecorate def updateRegCacheAfterPixelSync(self, pixelData, timeout): """Writes local register cache to VPixx device over USB, using Pixel Sync timing. This function is like DPxUpdateRegCache, but waits for a pixel sync sequence before executing. Args: pixelData (list, tuple, or numpy array): The requested pattern for PSync. Formatted such that the array is shape (3*N,) or (N,3) where 'N' is the number of RGB pixel triplets. timeout (int): Maximum time to wait before a PSync in video frames. Exceptions: 1) pixelData is 1D and its length is not divisible by 3 or pixelData is 2D but does not have 3 columns or has more than 8 rows 2) pixelData contains values outside of the range [0,255] 3) timeout is not an integer or is outside of the range [0,65535] """ if self.device_type == "TRACKPIXX": DPxDeviceError = "The TRACKPixx3 cannot be register synced with with video." raise Exception(DPxDeviceError) DPxSelectDevice(self.device_type) DPxUpdateRegCacheAfterPixelSync(pixelData, timeout)
[docs] @DpxExceptionDecorate def writeRegCacheAfterPixelSync(self, pixelData, timeout=255): """Write local register cache to VPixx device over USB. This function is like DPxWriteRegCache, but it waits for a pixel sync sequence. Args: pixelData (list, tuple, or numpy array): The requested pattern for PSync. Formatted such that the array is shape (3*N,) or (N,3) where 'N' is the number of RGB pixel triplets. timeout (int): Maximum time to wait before a PSync in video frames. Exceptions: 1) pixelData is 1D and its length is not divisible by 3 or pixelData is 2D but does not have 3 columns or has more than 8 rows 2) pixelData contains values outside of the range [0,255] 3) timeout is not an integer or is outside of the range [0,65535] """ if self.device_type == "TRACKPixx": DPxDeviceError = "The TRACKPixx3 cannot be register synced with with video." raise Exception(DPxDeviceError) DPxSelectDevice(self.device_type) DPxWriteRegCacheAfterPixelSync(pixelData, timeout)
[docs] @DpxExceptionDecorate def setVideoSource(self, vidSource): """Set source of video to be displayed Args: vidSource (str): The source we want to display. \n - **DVI**: Monitor displays DVI signal. - **SWTP**: Software test pattern showing image from RAM. - **SWTP 3D**: 3D Software test pattern flipping between left/right eye images from RAM. - **RGB SQUARES**: RGB ramps. - **GRAY**: Uniform gray display having 12-bit intensity. - **BAR**: Drifting bar. - **BAR2**: Drifting bar. - **DOTS**: Drifting dots. - **RAMP**: Drifting ramp, with dots advancing x*2 pixels per video frame, where x is a 4-bit signed. - **RGB**: Uniform display with 8-bit intensity nn, send to RGBA channels enabled by mask m. - **PROJ**: Projector Hardware test pattern. """ DPxSetVidSource(vidSource)
[docs] @DpxExceptionDecorate def getVideoSource(self): """Get source of video pattern being displayed. Returns: int: Source of video pattern. """ return DPxGetVidSource()
[docs] @DpxExceptionDecorate def getVideoLine(self): """ Reads pixels from the VPixx device line buffer, and returns a list containing the data. For each pixel, the buffer contains 16 bit R/G/B/U (where U is thrown away). The returned data is a list containing three lists for the respective R/G/B colors. Return: lists of list: A list which has [[RED], [GREEN], [BLUE]] """ return DPxGetVidLine()
[docs] @DpxExceptionDecorate def getTime(self): """Gets the device time since power up. Returns: float: Time in seconds. """ return DPxGetTime()
[docs] @DpxExceptionDecorate def getFrameTemperature(self): """Gets the temperature from the device chassis. Returns: float: Temperature in Celsius. """ return DPxGetTempCelcius()
[docs] @DpxExceptionDecorate def getFrameTemperature2(self): """Gets the temperature from the device chassis. Returns: float: Temperature in Celsius. """ return DPxGetTemp2Celcius()
[docs] @DpxExceptionDecorate def getCoreTemperature(self): """Gets the core temperature from the device. Returns: float: Temperature in Celsius. """ return DPxGetTemp3Celcius()
[docs] @DpxExceptionDecorate def get5vCurrent(self): """Gets the current for the 5 volt Power supply. Returns: float: Temperature in Celsius. """ return DPxGetSupplyCurrent()
[docs] @DpxExceptionDecorate def get12vCurrent(self): """Gets the current for the 12 volt Power supply. Returns: float: Temperature in Celsius. """ return DPxGetSupply2Current()
[docs] @DpxExceptionDecorate def get5vVoltage(self): """Gets the voltage for the 5 volt Power supply. Returns: float: Temperature in Celsius. """ return DPxGetSupplyVoltage()
[docs] @DpxExceptionDecorate def get12vVoltage(self): """Gets the current for the 12 volt Power supply. Returns: float: Temperature in Celsius. """ return DPxGetSupply2Voltage()
[docs] @DpxExceptionDecorate def get5vPower(self): """Gets the current for the 5 volt Power supply. Returns: float: power in watts. """ return ( DPxGetSupplyVoltage() * DPxGetSupplyCurrent() )
[docs] @DpxExceptionDecorate def get12vPower(self): """Gets the power for the 12 volt Power supply. Returns: float: Power in watts. """ return ( DPxGetSupply2Voltage() * DPxGetSupply2Current() )
[docs] @DpxExceptionDecorate def getDisplayResolution(self): """Gets the resolution of the device. Returns: string: Horizontal resolution followed by vertical resolution. """ return str(DPxGetVidHActive()) +'x'+ str(DPxGetVidVActive())
[docs] @DpxExceptionDecorate def setCustomStartupConfig(self): """Save the current registers to be used on start up. This can be useful if you set your projector to Ceiling mode or Rear projection and you want to keep it as such on reboot. """ return DPxSetCustomStartupConfig()
[docs] @DpxExceptionDecorate def getName(self): """Gets the device type. Returns: string: Device type. """ return self.name
[docs] @DpxExceptionDecorate def getAssemblyRevision(self): """Gets the device revision. Returns: string: The assembly revision of the device. """ return self.assembly_revision
[docs] @DpxExceptionDecorate def getRamSize(self): """Gets the RAM size. Returns: string: The amount of RAM found on the device. """ return self.ram_size
[docs] @DpxExceptionDecorate def getFirmwareRevision(self): """Gets the firmware revision. Returns: string: The firmware revision of the device. """ return self.firmware_revision
[docs] @DpxExceptionDecorate def getSerialNumber(self): """Gets the serial number. Returns: string: The serial number of the device. """ return self.serial_number
[docs] @DpxExceptionDecorate def getInfo(self): """Gets the device production information. This method can be used to get information about the current device. Some of these information are different from one device to another. It can be useful when contacting VPixx Technologies. Returns: info (dict): Any of the predefined constants.\n - **Part Number**: The part number of the device. - **Shipping Date**: The date at which the device was shipped. - **Assembly REV**: The device assembly revision. - **Expiration Date**: Date when the warranty expires. - **S/N**: Serial number of the device. """ return DPxReadProductionInfo()
[docs] @DpxExceptionDecorate def setMarker(self): """Latches the current time value into the marker register. """ DPxSetMarker()
[docs] @DpxExceptionDecorate def getMarker(self): """Gets the current marker from the register. This function allows the user to get the marker value previously latched. """ return DPxGetMarker()
#class DeviceStatusCommunication(QtCore.QObject): # tracker_window_status = QtCore.Signal() # # def __init__(self): # super(DeviceStatusCommunication,self).__init__()