diff --git a/setup.cfg b/setup.cfg index 1a25da2..8cecb65 100644 --- a/setup.cfg +++ b/setup.cfg @@ -81,6 +81,7 @@ ignore_errors = True # Prevent third party typing errors [mypy-spectrum_gmbh.*] ignore_errors = True +ignore_missing_imports = True [mypy-matplotlib.*] ignore_missing_imports = True diff --git a/src/spectrum_gmbh/__init__.py b/src/spectrum_gmbh/__init__.py index 9b8fcbd..3af3751 100644 --- a/src/spectrum_gmbh/__init__.py +++ b/src/spectrum_gmbh/__init__.py @@ -1,2 +1,7 @@ # Files in this module are provided free of charge by Spectrum GMBH with no restrictions on use. # They have been included here to simplify installation of the spectrumdevice package. +import sys + +from .py_header import regs, spcerr +sys.modules[__name__ + ".regs"] = regs +sys.modules[__name__ + ".spcerr"] = spcerr diff --git a/src/spectrum_gmbh/py_header/__init__.py b/src/spectrum_gmbh/py_header/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/spectrum_gmbh/regs.py b/src/spectrum_gmbh/py_header/regs.py similarity index 92% rename from src/spectrum_gmbh/regs.py rename to src/spectrum_gmbh/py_header/regs.py index b1787f5..f87c1a2 100644 --- a/src/spectrum_gmbh/regs.py +++ b/src/spectrum_gmbh/py_header/regs.py @@ -1,38 +1,14 @@ -# -# ************************************************************************** -# -# regs.py (c) Spectrum GmbH -# -# ************************************************************************** -# -# Feel free to use this source for own projects and modify it in any kind. -# -# ************************************************************************** +def KILO(k): return ( 1000 * (k)) +def MEGA(m): return ( 1000 * 1000 * (m)) -def KILO(k): - return 1000 * (k) +def GIGA(g): return ( 1000 * 1000 * 1000 * (g)) +def KILO_B(k): return ( 1024 * (k)) -def MEGA(m): - return 1000 * 1000 * (m) - - -def GIGA(g): - return 1000 * 1000 * 1000 * (g) - - -def KILO_B(k): - return 1024 * (k) - - -def MEGA_B(m): - return 1024 * 1024 * (m) - - -def GIGA_B(g): - return 1024 * 1024 * 1024 * (g) +def MEGA_B(m): return ( 1024 * 1024 * (m)) +def GIGA_B(g): return ( 1024 * 1024 * 1024 * (g)) TYP_PCIDEVICEID = 0x00000000 TYP_EVAL = 0x00000010 @@ -82,6 +58,7 @@ def GIGA_B(g): TYP_M4IEXPSERIES = 0x00070000 TYP_M4XEXPSERIES = 0x00080000 TYP_M2PEXPSERIES = 0x00090000 +TYP_M5IEXPSERIES = 0x000A0000 TYP_MI2020 = 0x00002020 TYP_MI2021 = 0x00002021 TYP_MI2025 = 0x00002025 @@ -272,6 +249,12 @@ def GIGA_B(g): TYP_M3I3221EXP = 0x00063221 TYP_M3I3240EXP = 0x00063240 TYP_M3I3242EXP = 0x00063242 +TYP_M5I33XX_X16 = 0x000A3300 +TYP_M5I3321_X16 = 0x000A3321 +TYP_M5I3330_X16 = 0x000A3330 +TYP_M5I3337_X16 = 0x000A3337 +TYP_M5I3350_X16 = 0x000A3350 +TYP_M5I3357_X16 = 0x000A3357 TYP_MI4020 = 0x00004020 TYP_MI4021 = 0x00004021 TYP_MI4022 = 0x00004022 @@ -709,6 +692,7 @@ def GIGA_B(g): SPCM_FEAT_EXTFW_SEGSTAT = 0x00000001 SPCM_FEAT_EXTFW_SEGAVERAGE = 0x00000002 SPCM_FEAT_EXTFW_BOXCAR = 0x00000004 +SPCM_FEAT_EXTFW_PULSEGEN = 0x00000008 ERRORTEXTLEN = 200 SPC_LASTERRORTEXT = 999996 SPC_LASTERRORVALUE = 999997 @@ -804,7 +788,7 @@ def GIGA_B(g): M2STAT_EXTRA_OVERRUN = 0x00004000 M2STAT_EXTRA_ERROR = 0x00008000 M2STAT_TSCNT_OVERRUN = 0x00010000 -M2STAT_INTERNALMASK = 0xFF000000 +M2STAT_INTERNALMASK = 0xff000000 M2STAT_INTERNAL_SYSLOCK = 0x02000000 SPC_DATA_AVAIL_USER_LEN = 200 SPC_DATA_AVAIL_USER_POS = 201 @@ -1522,6 +1506,7 @@ def GIGA_B(g): SPC_TMASK_EXT1 = 0x00000004 SPC_TMASK_EXT2 = 0x00000008 SPC_TMASK_EXT3 = 0x00000010 +SPC_TMASK_EXT4 = 0x00000020 SPC_TMASK_XIO0 = 0x00000100 SPC_TMASK_XIO1 = 0x00000200 SPC_TMASK_XIO2 = 0x00000400 @@ -1631,10 +1616,15 @@ def GIGA_B(g): SPC_TRIG_EXT3_MODE = 40513 SPC_TRIG_EXT3_AVAILMODES = 40514 SPC_TRIG_EXT3_AVAILMODESOR = 40515 +SPC_TRIG_EXT4_AVAILMODES = 40516 +SPC_TRIG_EXT4_AVAILMODESOR = 40517 +SPC_TRIG_EXT4_AVAILMODESAND = 40518 +SPC_TRIG_EXT4_MODE = 40519 SPC_TRIG_EXT0_READFEATURES = 40520 SPC_TRIG_EXT1_READFEATURES = 40521 SPC_TRIG_EXT2_READFEATURES = 40522 SPC_TRIG_EXT3_READFEATURES = 40523 +SPC_TRIG_EXT4_READFEATURES = 40524 SPCM_TRFEAT_TERM = 0x00000001 SPCM_TRFEAT_HIGHIMP = 0x00000002 SPCM_TRFEAT_DCCOUPLING = 0x00000004 @@ -1867,6 +1857,22 @@ def GIGA_B(g): SPC_AVAILTHRESHOLD_MIN = 42420 SPC_AVAILTHRESHOLD_MAX = 42421 SPC_AVAILTHRESHOLD_STEP = 42422 +SPC_AVAILAVRGMODES = 42429 +SPC_AVRGMODE_CH0 = 42430 +SPC_AVRGMODE_CH1 = 42431 +SPC_AVRGMODE_CH2 = 42432 +SPC_AVRGMODE_CH3 = 42433 +AVRGMODE_NORMAL = 0x0 +AVRGMODE_TDA_HIGH = 0x1 +AVRGMODE_TDA_LOW = 0x2 +SPC_TDA_THRESHOLD_CH0 = 42440 +SPC_TDA_THRESHOLD_CH1 = 42441 +SPC_TDA_THRESHOLD_CH2 = 42442 +SPC_TDA_THRESHOLD_CH3 = 42443 +SPC_TDA_REPLACEMENT_CH0 = 42450 +SPC_TDA_REPLACEMENT_CH1 = 42451 +SPC_TDA_REPLACEMENT_CH2 = 42452 +SPC_TDA_REPLACEMENT_CH3 = 42453 SPC_CLOCK_AVAILTHRESHOLD_MIN = 42423 SPC_CLOCK_AVAILTHRESHOLD_MAX = 42424 SPC_CLOCK_AVAILTHRESHOLD_STEP = 42425 @@ -2041,6 +2047,7 @@ def GIGA_B(g): SPCM_XMODE_SYNCARMSTATE = 0x00010000 SPCM_XMODE_OPTDIGIN2BIT = 0x00020000 SPCM_XMODE_OPTDIGIN4BIT = 0x00040000 +SPCM_XMODE_PULSEGEN = 0x00080000 SPCM_XMODE_MODEMASK = 0x000FFFFF SPCM_XMODE_DIGOUTSRC_CH0 = 0x01000000 SPCM_XMODE_DIGOUTSRC_CH1 = 0x02000000 @@ -2068,25 +2075,26 @@ def GIGA_B(g): SPC_DIGMODE6 = 47256 SPC_DIGMODE7 = 47257 SPCM_DIGMODE_OFF = 0x00000000 +SPCM_DIGMODE_X0 = 0x21084000 SPCM_DIGMODE_X1 = 0x294A5000 SPCM_DIGMODE_X2 = 0x318C6000 SPCM_DIGMODE_X3 = 0x39CE7000 SPCM_DIGMODE_X4 = 0x84210001 -SPCM_DIGMODE_X5 = 0x8C631002 -SPCM_DIGMODE_X6 = 0x94A52004 -SPCM_DIGMODE_X7 = 0x9CE73008 -SPCM_DIGMODE_X8 = 0xA5294010 -SPCM_DIGMODE_X9 = 0xAD6B5020 -SPCM_DIGMODE_X10 = 0xB5AD6040 -SPCM_DIGMODE_X11 = 0xBDEF7080 -SPCM_DIGMODE_X12 = 0xC6318100 -SPCM_DIGMODE_X13 = 0xCE739200 -SPCM_DIGMODE_X14 = 0xD6B5A400 -SPCM_DIGMODE_X15 = 0xDEF7B800 -SPCM_DIGMODE_X16 = 0xE739C000 -SPCM_DIGMODE_X17 = 0xEF7BD000 -SPCM_DIGMODE_X18 = 0xF7BDE000 -SPCM_DIGMODE_X19 = 0xFFFFF000 +SPCM_DIGMODE_X5 = 0x8c631002 +SPCM_DIGMODE_X6 = 0x94a52004 +SPCM_DIGMODE_X7 = 0x9ce73008 +SPCM_DIGMODE_X8 = 0xa5294010 +SPCM_DIGMODE_X9 = 0xad6b5020 +SPCM_DIGMODE_X10 = 0xb5ad6040 +SPCM_DIGMODE_X11 = 0xbdef7080 +SPCM_DIGMODE_X12 = 0xc6318100 +SPCM_DIGMODE_X13 = 0xce739200 +SPCM_DIGMODE_X14 = 0xd6b5a400 +SPCM_DIGMODE_X15 = 0xdef7b800 +SPCM_DIGMODE_X16 = 0xe739c000 +SPCM_DIGMODE_X17 = 0xef7bd000 +SPCM_DIGMODE_X18 = 0xf7bde000 +SPCM_DIGMODE_X19 = 0xfffff000 DIGMODEMASK_BIT15 = 0xF8000000 DIGMODEMASK_BIT14 = 0x07C00000 DIGMODEMASK_BIT13 = 0x003E0000 @@ -2211,6 +2219,7 @@ def GIGA_B(g): ADJ_CALSRC_GND = -1 ADJ_CALSRC_GNDOFFS = -2 ADJ_CALSRC_AC = 10 +ADJ_CALSRC_ADC = 11 SPC_ADJ_CALIBVALUE0 = 50060 SPC_ADJ_CALIBVALUE1 = 50061 SPC_ADJ_CALIBVALUE2 = 50062 @@ -2781,10 +2790,40 @@ def GIGA_B(g): SPC_MON_TC_MODB_5 = 500075 SPC_MON_TF_MODA_5 = 500076 SPC_MON_TF_MODB_5 = 500077 +SPC_MON_V_MOD_0 = 500078 +SPC_MON_V_MOD_1 = 500079 +SPC_MON_V_MOD_2 = 500080 +SPC_MON_V_MOD_3 = 500081 +SPC_MON_V_MOD_4 = 500082 +SPC_MON_V_MOD_5 = 500083 +SPC_MON_V_MOD_6 = 500084 +SPC_MON_V_MOD_7 = 500085 +SPC_MON_V_MOD_8 = 500086 +SPC_MON_V_MOD_9 = 500087 +SPC_MON_V_MOD_10 = 500088 +SPC_MON_TK_MODULE_2 = 500089 +SPC_MON_TC_MODULE_2 = 500090 +SPC_MON_TF_MODULE_2 = 500091 +SPC_MON_RPM_FAN0 = 500092 +SPC_MON_RPM_FAN1 = 500093 +SPC_MON_V_MEMVTTA = 500094 +SPC_MON_V_MEMVTTB = 500095 +SPC_MON_V_VCCAUX = 500096 +SPC_MON_V_MEMAUXA = 500097 +SPC_MON_V_MEMAUXB = 500098 +SPC_MON_TK_BASE_0 = 500099 +SPC_MON_TC_BASE_0 = 500100 +SPC_MON_TF_BASE_0 = 500101 +SPC_MON_TK_BASE_1 = 500102 +SPC_MON_TC_BASE_1 = 500103 +SPC_MON_TF_BASE_1 = 500104 +SPC_MON_I_CORE = 500105 +SPC_MON_V_CORE_REMOTE = 500106 SPC_AVAILMONITORS = 510000 SPCM_MON_T_BASE_CTRL = 0x0000000000000001 SPCM_MON_T_MODULE_0 = 0x0000000000000002 SPCM_MON_T_MODULE_1 = 0x0000000000000004 +SPCM_MON_T_MODULE_2 = 0x0000000000000008 SPCM_MON_V_PCIE_BUS = 0x0000000000000010 SPCM_MON_V_CONNECTOR = 0x0000000000000020 SPCM_MON_CARD_PWRSOURCE = 0x0000000000000040 @@ -2829,10 +2868,33 @@ def GIGA_B(g): SPCM_MON_I_MODA_3 = 0x0000080000000000 SPCM_MON_I_MODB_0 = 0x0000100000000000 SPCM_MON_I_MODB_1 = 0x0000200000000000 -SPCM_MON_I_MODB_2 = 0x0000300000000000 -SPCM_MON_I_MODB_3 = 0x0000400000000000 -SPCM_MON_T_MODA_5 = 0x0000800000000000 -SPCM_MON_T_MODB_5 = 0x0001000000000000 +SPCM_MON_I_MODB_2 = 0x0000400000000000 +SPCM_MON_I_MODB_3 = 0x0000800000000000 +SPCM_MON_T_MODA_5 = 0x0001000000000000 +SPCM_MON_T_MODB_5 = 0x0002000000000000 +SPCM_MON_V_MEMVTTA = 0x0004000000000000 +SPCM_MON_V_MEMVTTB = 0x0008000000000000 +SPCM_MON_V_MEMAUXA = 0x0010000000000000 +SPCM_MON_V_MEMAUXB = 0x0020000000000000 +SPCM_MON_V_VCCAUX = 0x0040000000000000 +SPCM_MON_T_BASE_0 = 0x0080000000000000 +SPCM_MON_T_BASE_1 = 0x0100000000000000 +SPCM_MON_RPM_FAN0 = 0x0200000000000000 +SPCM_MON_RPM_FAN1 = 0x0400000000000000 +SPCM_MON_I_CORE = 0x0800000000000000 +SPCM_MON_V_CORE_REMOTE = 0x1000000000000000 +SPC_AVAILMONITORS1 = 510001 +SPCM_MON_V_MOD_0 = 0x0000000000000001 +SPCM_MON_V_MOD_1 = 0x0000000000000002 +SPCM_MON_V_MOD_2 = 0x0000000000000004 +SPCM_MON_V_MOD_3 = 0x0000000000000008 +SPCM_MON_V_MOD_4 = 0x0000000000000010 +SPCM_MON_V_MOD_5 = 0x0000000000000020 +SPCM_MON_V_MOD_6 = 0x0000000000000040 +SPCM_MON_V_MOD_7 = 0x0000000000000080 +SPCM_MON_V_MOD_8 = 0x0000000000000100 +SPCM_MON_V_MOD_9 = 0x0000000000000200 +SPCM_MON_V_MOD_10 = 0x0000000000000400 SPC_X0_READFEATURES = 600000 SPC_X1_READFEATURES = 600001 SPC_X2_READFEATURES = 600002 @@ -2920,6 +2982,79 @@ def GIGA_B(g): SPCM_X17_AVAILMODES = 600317 SPCM_X18_AVAILMODES = 600318 SPCM_X19_AVAILMODES = 600319 +SPC_XIO_PULSEGEN0_MODE = 601000 +SPC_XIO_PULSEGEN1_MODE = 601100 +SPC_XIO_PULSEGEN2_MODE = 601200 +SPC_XIO_PULSEGEN3_MODE = 601300 +SPCM_PULSEGEN_MODE_GATED = 1 +SPCM_PULSEGEN_MODE_TRIGGERED = 2 +SPCM_PULSEGEN_MODE_SINGLESHOT = 3 +SPC_XIO_PULSEGEN0_LEN = 601001 +SPC_XIO_PULSEGEN1_LEN = 601101 +SPC_XIO_PULSEGEN2_LEN = 601201 +SPC_XIO_PULSEGEN3_LEN = 601301 +SPC_XIO_PULSEGEN0_HIGH = 601002 +SPC_XIO_PULSEGEN1_HIGH = 601102 +SPC_XIO_PULSEGEN2_HIGH = 601202 +SPC_XIO_PULSEGEN3_HIGH = 601302 +SPC_XIO_PULSEGEN0_OFFSET = 601003 +SPC_XIO_PULSEGEN1_OFFSET = 601103 +SPC_XIO_PULSEGEN2_OFFSET = 601203 +SPC_XIO_PULSEGEN3_OFFSET = 601303 +SPC_XIO_PULSEGEN0_LOOPS = 601004 +SPC_XIO_PULSEGEN1_LOOPS = 601104 +SPC_XIO_PULSEGEN2_LOOPS = 601204 +SPC_XIO_PULSEGEN3_LOOPS = 601304 +SPC_XIO_PULSEGEN0_MUX1_SRC = 601005 +SPC_XIO_PULSEGEN1_MUX1_SRC = 601105 +SPC_XIO_PULSEGEN2_MUX1_SRC = 601205 +SPC_XIO_PULSEGEN3_MUX1_SRC = 601305 +SPCM_PULSEGEN_MUX1_SRC_UNUSED = 0 +SPCM_PULSEGEN_MUX1_SRC_RUN = 1 +SPCM_PULSEGEN_MUX1_SRC_ARM = 2 +SPC_XIO_PULSEGEN0_MUX2_SRC = 601006 +SPC_XIO_PULSEGEN1_MUX2_SRC = 601106 +SPC_XIO_PULSEGEN2_MUX2_SRC = 601206 +SPC_XIO_PULSEGEN3_MUX2_SRC = 601306 +SPCM_PULSEGEN_MUX2_SRC_UNUSED = 0 +SPCM_PULSEGEN_MUX2_SRC_SOFTWARE = 1 +SPCM_PULSEGEN_MUX2_SRC_CARDTRIGGER = 2 +SPCM_PULSEGEN_MUX2_SRC_PULSEGEN0 = 3 +SPCM_PULSEGEN_MUX2_SRC_PULSEGEN1 = 4 +SPCM_PULSEGEN_MUX2_SRC_PULSEGEN2 = 5 +SPCM_PULSEGEN_MUX2_SRC_PULSEGEN3 = 6 +SPCM_PULSEGEN_MUX2_SRC_XIO0 = 7 +SPCM_PULSEGEN_MUX2_SRC_XIO1 = 8 +SPCM_PULSEGEN_MUX2_SRC_XIO2 = 9 +SPCM_PULSEGEN_MUX2_SRC_XIO3 = 10 +SPC_XIO_PULSEGEN0_CONFIG = 601007 +SPC_XIO_PULSEGEN1_CONFIG = 601107 +SPC_XIO_PULSEGEN2_CONFIG = 601207 +SPC_XIO_PULSEGEN3_CONFIG = 601307 +SPCM_PULSEGEN_CONFIG_MUX1_INVERT = 0x1 +SPCM_PULSEGEN_CONFIG_MUX2_INVERT = 0x2 +SPCM_PULSEGEN_CONFIG_INVERT = 0x4 +SPCM_PULSEGEN_CONFIG_HIGH = 0x8 +SPC_XIO_PULSEGEN_ENABLE = 601500 +SPCM_PULSEGEN_ENABLE0 = 0x01 +SPCM_PULSEGEN_ENABLE1 = 0x02 +SPCM_PULSEGEN_ENABLE2 = 0x04 +SPCM_PULSEGEN_ENABLE3 = 0x08 +SPC_XIO_PULSEGEN_COMMAND = 601501 +SPCM_PULSEGEN_CMD_FORCE = 0x1 +SPC_XIO_PULSEGEN_CLOCK = 602000 +SPC_XIO_PULSEGEN_AVAILLEN_MIN = 602001 +SPC_XIO_PULSEGEN_AVAILLEN_MAX = 602002 +SPC_XIO_PULSEGEN_AVAILLEN_STEP = 602003 +SPC_XIO_PULSEGEN_AVAILHIGH_MIN = 602004 +SPC_XIO_PULSEGEN_AVAILHIGH_MAX = 602005 +SPC_XIO_PULSEGEN_AVAILHIGH_STEP = 602006 +SPC_XIO_PULSEGEN_AVAILOFFSET_MIN = 602007 +SPC_XIO_PULSEGEN_AVAILOFFSET_MAX = 602008 +SPC_XIO_PULSEGEN_AVAILOFFSET_STEP = 602009 +SPC_XIO_PULSEGEN_AVAILLOOPS_MIN = 602010 +SPC_XIO_PULSEGEN_AVAILLOOPS_MAX = 602011 +SPC_XIO_PULSEGEN_AVAILLOOPS_STEP = 602012 SPC_REG0x00 = 900000 SPC_REG0x02 = 900010 SPC_REG0x04 = 900020 diff --git a/src/spectrum_gmbh/spcerr.py b/src/spectrum_gmbh/py_header/spcerr.py similarity index 83% rename from src/spectrum_gmbh/spcerr.py rename to src/spectrum_gmbh/py_header/spcerr.py index ff2e36a..da57762 100644 --- a/src/spectrum_gmbh/spcerr.py +++ b/src/spectrum_gmbh/py_header/spcerr.py @@ -1,15 +1,3 @@ -# -# ************************************************************************** -# -# spcerr.py (c) Spectrum GmbH -# -# ************************************************************************** -# -# Feel free to use this source for own projects and modify it in any kind. -# -# ************************************************************************** - - SPCM_ERROR_ORIGIN_MASK = 0x80000000 SPCM_ERROR_ORIGIN_LOCAL = 0x00000000 SPCM_ERROR_ORIGIN_REMOTE = 0x80000000 @@ -41,6 +29,7 @@ ERR_RESTRICTEDACCESS = 0x0045 ERR_INVALIDPARAM = 0x0046 ERR_TEMPERATURE = 0x0047 +ERR_FAN = 0x0048 ERR_REG = 0x0100 ERR_VALUE = 0x0101 ERR_FEATURE = 0x0102 @@ -75,6 +64,7 @@ ERR_STARHUBENABLE = 0x014B ERR_PATPWSMALLEDGE = 0x014C ERR_XMODESETUP = 0x014D +ERR_AVRG_TDA = 0x014E ERR_NOPCI = 0x0200 ERR_PCIVERSION = 0x0201 ERR_PCINOBOARDS = 0x0202 diff --git a/src/spectrum_gmbh/pyspcm.py b/src/spectrum_gmbh/pyspcm.py index 66a27fc..b5ebdd7 100644 --- a/src/spectrum_gmbh/pyspcm.py +++ b/src/spectrum_gmbh/pyspcm.py @@ -1,67 +1,57 @@ -# -# ************************************************************************** -# -# pyspcm.py (c) Spectrum GmbH -# -# ************************************************************************** -# -# Feel free to use this source for own projects and modify it in any kind. -# -# ************************************************************************** - import os import platform import sys from ctypes import * # load registers for easier access +# from py_header.regs import * # removed by King's, not needed because regs available in this module # load registers for easier access +# from py_header.spcerr import * # removed by King's, not needed because spcerr available in this module SPCM_DIR_PCTOCARD = 0 SPCM_DIR_CARDTOPC = 1 -SPCM_BUF_DATA = 1000 # main data buffer for acquired or generated samples -SPCM_BUF_ABA = 2000 # buffer for ABA data, holds the A-DATA (slow samples) -SPCM_BUF_TIMESTAMP = 3000 # buffer for timestamps +SPCM_BUF_DATA = 1000 # main data buffer for acquired or generated samples +SPCM_BUF_ABA = 2000 # buffer for ABA data, holds the A-DATA (slow samples) +SPCM_BUF_TIMESTAMP = 3000 # buffer for timestamps # determine bit width of os oPlatform = platform.architecture() -if oPlatform[0] == "64bit": +if (oPlatform[0] == '64bit'): bIs64Bit = 1 else: bIs64Bit = 0 # define pointer aliases -int8 = c_int8 +int8 = c_int8 int16 = c_int16 int32 = c_int32 int64 = c_int64 -ptr8 = POINTER(int8) -ptr16 = POINTER(int16) -ptr32 = POINTER(int32) -ptr64 = POINTER(int64) +ptr8 = POINTER (int8) +ptr16 = POINTER (int16) +ptr32 = POINTER (int32) +ptr64 = POINTER (int64) -uint8 = c_uint8 +uint8 = c_uint8 uint16 = c_uint16 uint32 = c_uint32 uint64 = c_uint64 -uptr8 = POINTER(uint8) -uptr16 = POINTER(uint16) -uptr32 = POINTER(uint32) -uptr64 = POINTER(uint64) +uptr8 = POINTER (uint8) +uptr16 = POINTER (uint16) +uptr32 = POINTER (uint32) +uptr64 = POINTER (uint64) # Windows -if os.name == "nt": - # Line commented out by King's College - # sys.stdout.write("Python Version: {0} on Windows\n\n".format(platform.python_version())) +if os.name == 'nt': + sys.stdout.write("Python Version: {0} on Windows\n\n".format (platform.python_version())) # define card handle type - if bIs64Bit: + if (bIs64Bit): # for unknown reasons c_void_p gets messed up on Win7/64bit, but this works: drv_handle = POINTER(c_uint64) else: @@ -69,13 +59,13 @@ # Load DLL into memory. # use windll because all driver access functions use _stdcall calling convention under windows - if bIs64Bit == 1: - spcmDll = windll.LoadLibrary("c:\\windows\\system32\\spcm_win64.dll") + if (bIs64Bit == 1): + spcmDll = windll.LoadLibrary ("c:\\windows\\system32\\spcm_win64.dll") else: - spcmDll = windll.LoadLibrary("c:\\windows\\system32\\spcm_win32.dll") + spcmDll = windll.LoadLibrary ("c:\\windows\\system32\\spcm_win32.dll") # load spcm_hOpen - if bIs64Bit: + if (bIs64Bit): spcm_hOpen = getattr(spcmDll, "spcm_hOpen") else: spcm_hOpen = getattr(spcmDll, "_spcm_hOpen@4") @@ -83,7 +73,7 @@ spcm_hOpen.restype = drv_handle # load spcm_vClose - if bIs64Bit: + if (bIs64Bit): spcm_vClose = getattr(spcmDll, "spcm_vClose") else: spcm_vClose = getattr(spcmDll, "_spcm_vClose@4") @@ -91,7 +81,7 @@ spcm_vClose.restype = None # load spcm_dwGetErrorInfo - if bIs64Bit: + if (bIs64Bit): spcm_dwGetErrorInfo_i32 = getattr(spcmDll, "spcm_dwGetErrorInfo_i32") else: spcm_dwGetErrorInfo_i32 = getattr(spcmDll, "_spcm_dwGetErrorInfo_i32@16") @@ -99,7 +89,7 @@ spcm_dwGetErrorInfo_i32.restype = uint32 # load spcm_dwGetParam_i32 - if bIs64Bit: + if (bIs64Bit): spcm_dwGetParam_i32 = getattr(spcmDll, "spcm_dwGetParam_i32") else: spcm_dwGetParam_i32 = getattr(spcmDll, "_spcm_dwGetParam_i32@12") @@ -107,7 +97,7 @@ spcm_dwGetParam_i32.restype = uint32 # load spcm_dwGetParam_i64 - if bIs64Bit: + if (bIs64Bit): spcm_dwGetParam_i64 = getattr(spcmDll, "spcm_dwGetParam_i64") else: spcm_dwGetParam_i64 = getattr(spcmDll, "_spcm_dwGetParam_i64@12") @@ -115,7 +105,7 @@ spcm_dwGetParam_i64.restype = uint32 # load spcm_dwSetParam_i32 - if bIs64Bit: + if (bIs64Bit): spcm_dwSetParam_i32 = getattr(spcmDll, "spcm_dwSetParam_i32") else: spcm_dwSetParam_i32 = getattr(spcmDll, "_spcm_dwSetParam_i32@12") @@ -123,7 +113,7 @@ spcm_dwSetParam_i32.restype = uint32 # load spcm_dwSetParam_i64 - if bIs64Bit: + if (bIs64Bit): spcm_dwSetParam_i64_ = getattr(spcmDll, "spcm_dwSetParam_i64") else: spcm_dwSetParam_i64_ = getattr(spcmDll, "_spcm_dwSetParam_i64@16") @@ -135,10 +125,10 @@ def spcm_dwSetParam_i64(hDrv, lReg, Val): llVal = int64(Val.value) except AttributeError: llVal = int64(Val) - return spcm_dwSetParam_i64_(hDrv, lReg, llVal) + return spcm_dwSetParam_i64_ (hDrv, lReg, llVal) # load spcm_dwSetParam_i64m - if bIs64Bit: + if (bIs64Bit): spcm_dwSetParam_i64m = getattr(spcmDll, "spcm_dwSetParam_i64m") else: spcm_dwSetParam_i64m = getattr(spcmDll, "_spcm_dwSetParam_i64m@16") @@ -146,7 +136,7 @@ def spcm_dwSetParam_i64(hDrv, lReg, Val): spcm_dwSetParam_i64m.restype = uint32 # load spcm_dwDefTransfer_i64 - if bIs64Bit: + if (bIs64Bit): spcm_dwDefTransfer_i64 = getattr(spcmDll, "spcm_dwDefTransfer_i64") else: spcm_dwDefTransfer_i64 = getattr(spcmDll, "_spcm_dwDefTransfer_i64@36") @@ -154,7 +144,7 @@ def spcm_dwSetParam_i64(hDrv, lReg, Val): spcm_dwDefTransfer_i64.restype = uint32 # load spcm_dwInvalidateBuf - if bIs64Bit: + if (bIs64Bit): spcm_dwInvalidateBuf = getattr(spcmDll, "spcm_dwInvalidateBuf") else: spcm_dwInvalidateBuf = getattr(spcmDll, "_spcm_dwInvalidateBuf@8") @@ -162,7 +152,7 @@ def spcm_dwSetParam_i64(hDrv, lReg, Val): spcm_dwInvalidateBuf.restype = uint32 # load spcm_dwGetContBuf_i64 - if bIs64Bit: + if (bIs64Bit): spcm_dwGetContBuf_i64 = getattr(spcmDll, "spcm_dwGetContBuf_i64") else: spcm_dwGetContBuf_i64 = getattr(spcmDll, "_spcm_dwGetContBuf_i64@16") @@ -170,19 +160,18 @@ def spcm_dwSetParam_i64(hDrv, lReg, Val): spcm_dwGetContBuf_i64.restype = uint32 -elif os.name == "posix": - # Line commented out by King's College - # sys.stdout.write("Python Version: {0} on Linux\n\n".format(platform.python_version())) +elif os.name == 'posix': + sys.stdout.write("Python Version: {0} on Linux\n\n".format (platform.python_version())) # define card handle type - if bIs64Bit: + if (bIs64Bit): drv_handle = POINTER(c_uint64) else: drv_handle = c_void_p # Load DLL into memory. # use cdll because all driver access functions use cdecl calling convention under linux - spcmDll = cdll.LoadLibrary("libspcm_linux.so") + spcmDll = cdll.LoadLibrary ("libspcm_linux.so") # load spcm_hOpen spcm_hOpen = getattr(spcmDll, "spcm_hOpen") @@ -240,4 +229,4 @@ def spcm_dwSetParam_i64(hDrv, lReg, Val): spcm_dwGetContBuf_i64.restype = uint32 else: - raise Exception("Operating system not supported by pySpcm") + raise Exception('Operating system not supported by pySpcm') diff --git a/src/spectrumdevice/devices/awg/awg_channel.py b/src/spectrumdevice/devices/awg/awg_channel.py index 41ba3f3..6e4b649 100644 --- a/src/spectrumdevice/devices/awg/awg_channel.py +++ b/src/spectrumdevice/devices/awg/awg_channel.py @@ -1,4 +1,4 @@ -from typing import Any +from typing import Any, cast from numpy import int16 @@ -49,7 +49,7 @@ def set_dig_out_settings(self, dig_out_settings: DigOutIOLineModeSettings) -> No def _get_io_line_mode_settings_mask(self, mode: IOLineMode) -> int: if mode == IOLineMode.SPCM_XMODE_DIGOUT: - return self._dig_out_settings.source_channel.value | self._dig_out_settings.source_bit.value + return cast(int, self._dig_out_settings.source_channel.value | self._dig_out_settings.source_bit.value) else: return 0 diff --git a/src/tests/configuration.py b/src/tests/configuration.py index 6b61a9f..38bf32c 100644 --- a/src/tests/configuration.py +++ b/src/tests/configuration.py @@ -14,7 +14,7 @@ class SpectrumTestMode(Enum): # Set to TestMode.REAL_HARDWARE to run tests on a real hardware device as configured below. SINGLE_DIGITISER_CARD_TEST_MODE = SpectrumTestMode.MOCK_HARDWARE DIGITISER_STAR_HUB_TEST_MODE = SpectrumTestMode.MOCK_HARDWARE -SINGLE_AWG_CARD_TEST_MODE = SpectrumTestMode.MOCK_HARDWARE +SINGLE_AWG_CARD_TEST_MODE = SpectrumTestMode.REAL_HARDWARE # Set IP address of real spectrum device (for use if TestMode.REAL_HARDWARE is set above). Set to None to run tests on # a local (PCIe) card.