From abaf5cb31039673f72749b1382564239d1d89601 Mon Sep 17 00:00:00 2001 From: u55 Date: Fri, 12 Feb 2016 23:33:14 -0700 Subject: [PATCH 1/6] Remove trailing whitespace. --- UniversalLibrary/UniversalLibrary.py | 122 +++++++++++++-------------- examples/pyscope.py | 20 ++--- examples/simpletrig.py | 2 +- examples/ulai08.py | 2 +- examples/uldi01.py | 4 +- examples/uldi03.py | 4 +- examples/uldo02.py | 4 +- 7 files changed, 79 insertions(+), 79 deletions(-) diff --git a/UniversalLibrary/UniversalLibrary.py b/UniversalLibrary/UniversalLibrary.py index 5928190..203cfb4 100644 --- a/UniversalLibrary/UniversalLibrary.py +++ b/UniversalLibrary/UniversalLibrary.py @@ -78,7 +78,7 @@ 'cbSelectSignal', 'cbSetConfig', 'cbSetTrigger', - + 'cbDBitIn', 'cbDBitOut', 'cbDConfigBit', @@ -92,11 +92,11 @@ 'cbTIn', 'cbTInScan', - + 'cbFromEngUnits', 'cbToEngUnits', 'cbGetStatus', - + ] + all_constants __version__ = '20061020' @@ -129,7 +129,7 @@ def CHK(UDStat): """raise appropriate exception if error occurred""" if UDStat != NOERRORS: raise UniversalLibraryError(UDStat) - + def CHK_ARRAY( arr, N, nxtype ): if not hasattr(arr,'shape'): raise UniversalLibraryPythonError("input argument is not an array") @@ -142,7 +142,7 @@ def CHK_ARRAY( arr, N, nxtype ): if not arr.flags['CONTIGUOUS']: raise UniversalLibraryPythonError("array is not contiguous") return arr - + def __declare_revlevel__(): RevLevel = ctypes.c_float(constants.CURRENTREVNUM) CHK(cbw.cbDeclareRevision(ctypes.byref(RevLevel))) @@ -153,8 +153,8 @@ def __declare_revlevel__(): # ############################### -def cbAConvertData (BoardNum, NumPoints, ADData, - ChanTags): +def cbAConvertData(BoardNum, NumPoints, ADData, + ChanTags): """Convert data collected by cbAInScan() Inputs @@ -167,11 +167,11 @@ def cbAConvertData (BoardNum, NumPoints, ADData, """ CHK_ARRAY( ADData, NumPoints, numpy.uint16 ) CHK_ARRAY( ChanTags, NumPoints, numpy.uint16 ) - CHK( cbw.cbAConvertData(BoardNum, NumPoints, ADData.ctypes.data, + CHK( cbw.cbAConvertData(BoardNum, NumPoints, ADData.ctypes.data, ChanTags.ctypes.data)) - -def cbAConvertPretrigData(BoardNum, PreTrigCount, - TotalCount, ADData, + +def cbAConvertPretrigData(BoardNum, PreTrigCount, + TotalCount, ADData, ChanTags): """Convert data collected by cbAPretrig(). @@ -186,21 +186,21 @@ def cbAConvertPretrigData(BoardNum, PreTrigCount, """ CHK_ARRAY( ADData, NumPoints, numpy.uint16 ) CHK_ARRAY( ChanTags, NumPoints, numpy.uint16 ) - CHK( cbw.cbAConvertPretrigData(BoardNum, PreTrigCount, - TotalCount, ADData.ctypes.data, + CHK( cbw.cbAConvertPretrigData(BoardNum, PreTrigCount, + TotalCount, ADData.ctypes.data, ChanTags.ctypes.data)) -def cbACalibrateData(BoardNum, NumPoints, Gain, +def cbACalibrateData(BoardNum, NumPoints, Gain, ADData): - CHK( cbw.cbACalibrateData ( BoardNum, NumPoints, Gain, - ADData.ctypes.data)) + CHK( cbw.cbACalibrateData(BoardNum, NumPoints, Gain, + ADData.ctypes.data)) def cbAIn( BoardNum, Chan, Gain, DataValue=0): """Read A/D input channel Inputs ------ - + BoardNum Chan Gain @@ -209,7 +209,7 @@ def cbAIn( BoardNum, Chan, Gain, DataValue=0): Outputs ------- DataValue - + """ cDataValue = ctypes.c_ushort(DataValue) CHK(cbw.cbAIn(BoardNum, Chan, Gain, ctypes.byref(cDataValue))) @@ -234,9 +234,9 @@ def cbAInScan(BoardNum, LowChan, HighChan, Count, Outputs ------- - + Rate - + """ Rate = ctypes.c_long(Rate) CHK_ARRAY( ADData, Count, numpy.int16 ) @@ -244,34 +244,34 @@ def cbAInScan(BoardNum, LowChan, HighChan, Count, byref(Rate), Gain, ADData.ctypes.data, Options)) return Rate.value -def cbALoadQueue ( BoardNum, ChanArray, GainArray, - NumChans): +def cbALoadQueue(BoardNum, ChanArray, GainArray, + NumChans): CHK_ARRAY( ChanArray, NumChans, numpy.int16 ) CHK_ARRAY( GainArray, NumChans, numpy.int16 ) CHK(cbw.cbALoadQueue(BoardNum, ChanArray.ctypes.data, GainArray.ctypes.data, NumChans)) - + def cbAOut(BoardNum, Chan, Gain, DataValue): CHK( cbw.cbAOut(BoardNum, Chan, Gain, DataValue)) -def cbAOutScan(BoardNum, LowChan, HighChan, - Count, Rate, Gain, +def cbAOutScan(BoardNum, LowChan, HighChan, + Count, Rate, Gain, MemHandle, Options): CHK_ARRAY( MemHandle, Count, numpy.int16 ) Rate = ctypes.c_long(Rate) - CHK(cbw.cbAOutScan( BoardNum, LowChan, HighChan, - Count, byref(Rate), Gain, + CHK(cbw.cbAOutScan( BoardNum, LowChan, HighChan, + Count, byref(Rate), Gain, MemHandle.ctypes.data, Options)) return Rate.value - + def cbAPretrig(BoardNum, LowChan, HighChan, - PreTrigCount, TotalCount, Rate, + PreTrigCount, TotalCount, Rate, Gain, ADData, Options): """Acquire analog data upon being triggered. Inputs ------ - + BoardNum LowChan HighChan @@ -290,21 +290,21 @@ def cbAPretrig(BoardNum, LowChan, HighChan, Rate """ - + CHK_ARRAY( ADData, TotalCount+512, numpy.int16 ) PreTrigCount = ctypes.c_long(PreTrigCount) TotalCount = ctypes.c_long(TotalCount) Rate = ctypes.c_long(Rate) CHK(cbw.cbAPretrig( BoardNum, LowChan, HighChan, - byref(PreTrigCount), byref(TotalCount), - byref(Rate), - Gain, ADData.ctypes.data, Options)) + byref(PreTrigCount), byref(TotalCount), + byref(Rate), + Gain, ADData.ctypes.data, Options)) return PreTrigCount.value, TotalCount.value, Rate.value -def cbATrig(BoardNum, Chan, TrigType, +def cbATrig(BoardNum, Chan, TrigType, TrigValue, Gain, DataValue): DataValue = ctypes.c_ushort(DataValue) - CHK(cbw.cbATrig( BoardNum, Chan, TrigType, + CHK(cbw.cbATrig( BoardNum, Chan, TrigType, TrigValue, Gain, byref(DataValue))) return DataValue.value @@ -314,7 +314,7 @@ def cbATrig(BoardNum, Chan, TrigType, # ################################### -def cbGetConfig(InfoType, BoardNum, DevNum, +def cbGetConfig(InfoType, BoardNum, DevNum, ConfigItem, ConfigVal): """Return a configuration option for a card. @@ -331,8 +331,8 @@ def cbGetConfig(InfoType, BoardNum, DevNum, ConfigVal """ ConfigVal = ctypes.c_int(ConfigVal) - CHK( cbw.cbGetConfig(InfoType, BoardNum, DevNum, - ConfigItem, byref(ConfigVal))) + CHK( cbw.cbGetConfig(InfoType, BoardNum, DevNum, + ConfigItem, byref(ConfigVal))) return ConfigVal.value def cbGetSignal(BoardNum, Direction, Signal, Index, Connection, Polarity): @@ -353,7 +353,7 @@ def cbGetSignal(BoardNum, Direction, Signal, Index, Connection, Polarity): Connection Polarity - + """ Connection = ctypes.c_int(Connection) Polarity = ctypes.c_int(Polarity) @@ -367,17 +367,17 @@ def cbSelectSignal(BoardNum, Direction, Signal, Connection, Polarity): Inputs ------ - + BoardNum Direction Signal Connection Polarity - + """ CHK(cbw.cbSelectSignal(BoardNum, Direction, Signal, Connection, Polarity)) -def cbSetConfig(InfoType, BoardNum, DevNum, +def cbSetConfig(InfoType, BoardNum, DevNum, ConfigItem, ConfigVal): """Set configuration option for a card. @@ -390,19 +390,19 @@ def cbSetConfig(InfoType, BoardNum, DevNum, ConfigVal """ CHK(cbw.cbSetConfig(InfoType,BoardNum,DevNum, ConfigItem,ConfigVal)) - -def cbSetTrigger(BoardNum, TrigType, LowThreshold, + +def cbSetTrigger(BoardNum, TrigType, LowThreshold, HighThreshold): """Selects trigger source and sets up parameters Inputs ------ - + BoardNum TrigType LowThreshold HighThreshold - + """ CHK( cbw.cbSetTrigger(BoardNum,TrigType,LowThreshold,HighThreshold)) @@ -417,7 +417,7 @@ def cbDBitIn(BoardNum, PortType, BitNum, BitValue): Inputs ------ - + BoardNum PortType BitNum @@ -438,12 +438,12 @@ def cbDBitOut(BoardNum, PortType, BitNum, BitValue): Inputs ------ - + BoardNum PortType BitNum BitValue - + """ CHK( cbw.cbDBitOut( BoardNum, PortType, BitNum, BitValue)) @@ -468,7 +468,7 @@ def cbDConfigPort(BoardNum, PortNum, Direction): BoardNum PortNum Direction - + """ CHK( cbw.cbDConfigPort( BoardNum, PortNum, Direction)) @@ -524,7 +524,7 @@ def cbDOut(BoardNum, PortNum, DataValue): BoardNum PortNum DataValue - + """ CHK(cbw.cbDOut(BoardNum, PortNum, DataValue)) @@ -534,7 +534,7 @@ def cbDOutScan(BoardNum, PortNum, Count, Rate, Inputs ------ - + BoardNum PortNum Count @@ -563,7 +563,7 @@ def cbDOutScan(BoardNum, PortNum, Count, Rate, def cbGetRevision(): RevNum = ctypes.c_float() VxDRevNum = ctypes.c_float() - cbw.cbGetRevision (byref(RevNum), byref(VxDRevNum)) + cbw.cbGetRevision(byref(RevNum), byref(VxDRevNum)) return RevNum.value, VxDRevNum.value ############################### @@ -586,7 +586,7 @@ def cbTIn(BoardNum, Chan, Scale, TempValue, Options): Outputs ------- - + TempValue """ @@ -612,7 +612,7 @@ def cbTInScan(BoardNum, LowChan, HighChan, Scale, CHK_ARRAY( DataBuffer, HighChan - LowChan + 1, numpy.float32 ) CHK(cbw.cbTInScan(BoardNum, LowChan, HighChan, Scale, DataBuffer.ctypes.data, Options)) - + ############################### # # Miscellaneous functions @@ -621,20 +621,20 @@ def cbTInScan(BoardNum, LowChan, HighChan, Scale, def cbFromEngUnits(BoardNum, Range, EngUnits, DataVal): """Convert a voltage or current to an A/D count value - + Inputs ------ - + BoardNum Range EngUnits DataVal - + Outputs ------- DataVal - + """ DataVal = ctypes.c_ushort(DataVal) EngUnits = ctypes.c_float(EngUnits) @@ -661,7 +661,7 @@ def cbToEngUnits(BoardNum, Range, DataVal, EngUnits=0.0): EngUnits = ctypes.c_float(EngUnits) CHK(cbw.cbToEngUnits(BoardNum, Range, DataVal, byref(EngUnits))) return EngUnits.value - + def cbGetStatus(BoardNum, Status, CurCount, CurIndex, FunctionType): """Returns status about potentially currently running background operation""" diff --git a/examples/pyscope.py b/examples/pyscope.py index 4d209a9..44c9976 100644 --- a/examples/pyscope.py +++ b/examples/pyscope.py @@ -2,7 +2,7 @@ """ Copyright (C) Jeremy O'Donoghue, 2003 Copyright (C) California Institute of Technology, 2005-2006 - + License: This work is licensed under the PSF. A copy is available at http://www.python.org/psf/license.html @@ -35,7 +35,7 @@ def __init__(self,totalcount,data): def daq_thread_func(wxapp): TotalCount = 3000 ADData = numpy.zeros((TotalCount+512,), dtype=numpy.int16) - + BoardNum = 0 UDStat = 0 Gain = UL.BIP5VOLTS @@ -46,7 +46,7 @@ def daq_thread_func(wxapp): Rate = 20000 PretrigCount = 500 - + Options = UL.CONVERTDATA while 1: PretrigCount, TotalCount, Rate = UL.cbAPretrig (BoardNum, @@ -92,18 +92,18 @@ def OnInit(self,*args,**kw): self.frame.Show() self.SetTopWindow(self.frame) return True - + def GetToolBar(self): - # You will need to override GetToolBar if you are using an + # You will need to override GetToolBar if you are using an # unmanaged toolbar in your frame return self.frame.toolbar - + def OnTrig(self, evt): assert evt.GetEventType() == EVT_TRIG_ID - + ch0 = evt.data[0:evt.totalcount:2] ch1 = evt.data[1:evt.totalcount:2] - + if hasattr(self.frame,'ind'): # we have already been run once and have an old copy of data self.frame.lines[0].set_data( self.frame.ind, ch0 ) @@ -115,12 +115,12 @@ def OnTrig(self, evt): self.frame.ind, ch1, 'g-' ) self.frame.canvas.draw() self.frame.canvas.gui_repaint() - + if __name__ == '__main__': app = App(redirect=False) daq_thread = threading.Thread(target=daq_thread_func,args=(app,)) daq_thread.setDaemon(True) daq_thread.start() - + app.MainLoop() diff --git a/examples/simpletrig.py b/examples/simpletrig.py index ef5858c..dca8886 100644 --- a/examples/simpletrig.py +++ b/examples/simpletrig.py @@ -52,7 +52,7 @@ Options = UL.CONVERTDATA + UL.EXTTRIGGER ADData = numpy.zeros((Count,), dtype=numpy.int16) Rate = UL.cbAInScan(BoardNum, LowChan, HighChan, Count, - Rate, Gain, ADData, Options) + Rate, Gain, ADData, Options) pylab.plot( ADData ) pylab.show() diff --git a/examples/ulai08.py b/examples/ulai08.py index a3b1166..c0dd2f4 100644 --- a/examples/ulai08.py +++ b/examples/ulai08.py @@ -52,7 +52,7 @@ PretrigCount, TotalCount, Rate = UL.cbAPretrig (BoardNum, LowChan, HighChan, PretrigCount, TotalCount, Rate, Gain, ADData, Options) - + ##Rate = UL.cbAInScan(BoardNum, LowChan, HighChan, Count, ## Rate, Gain, ADData, Options) diff --git a/examples/uldi01.py b/examples/uldi01.py index 73259b6..822b910 100644 --- a/examples/uldi01.py +++ b/examples/uldi01.py @@ -40,5 +40,5 @@ while 1: DataValue = UL.cbDIn(BoardNum, PortNum, DataValue) print "Port Value:",DataValue - - + + diff --git a/examples/uldi03.py b/examples/uldi03.py index a2ba236..9b0cd4b 100644 --- a/examples/uldi03.py +++ b/examples/uldi03.py @@ -48,5 +48,5 @@ Rate = 15 DataBuffer = numpy.zeros((Count,),dtype=numpy.uint8) Rate = UL.cbDInScan(BoardNum, PortNum, Count, Rate, DataBuffer, Options) - - + + diff --git a/examples/uldo02.py b/examples/uldo02.py index f8b492d..3ebbc76 100644 --- a/examples/uldo02.py +++ b/examples/uldo02.py @@ -60,7 +60,7 @@ FirstBit = 20 else: FirstBit = 0 - + Direction = UL.DIGITALOUT UL.cbDConfigPort(BoardNum, FirstPort+1, Direction) DataValue = 5 @@ -72,6 +72,6 @@ BitValue = 0 else: BitValue = 0 - + PortType=UL.FIRSTPORTA UL.cbDBitOut(BoardNum, PortType, FirstBit+BitNum, BitValue) From 3baa7ebc74cfc5ef5de6395d0fc09dfd4caacc22 Mon Sep 17 00:00:00 2001 From: u55 Date: Fri, 12 Feb 2016 23:35:46 -0700 Subject: [PATCH 2/6] Allow 64-bit python. --- UniversalLibrary/UniversalLibrary.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/UniversalLibrary/UniversalLibrary.py b/UniversalLibrary/UniversalLibrary.py index 203cfb4..dd8292b 100644 --- a/UniversalLibrary/UniversalLibrary.py +++ b/UniversalLibrary/UniversalLibrary.py @@ -48,13 +48,17 @@ """ +import platform import ctypes from ctypes import byref import numpy import constants # PyUL contants from constants import * # PyUL contants -cbw = ctypes.windll.cbw32 # open CBW32.DLL +if platform.architecture()[0] == '64bit': + cbw = ctypes.windll.cbw64 # open CBW64.DLL +else: + cbw = ctypes.windll.cbw32 # open CBW32.DLL all_constants = [attr for attr in constants.__dict__ if not attr.startswith('__')] From 5b828c8021cfb8d8c0d5edde23c62655ef2426d8 Mon Sep 17 00:00:00 2001 From: u55 Date: Sat, 13 Feb 2016 00:23:54 -0700 Subject: [PATCH 3/6] Fix broken example ulai14. --- examples/ulai14.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/ulai14.py b/examples/ulai14.py index 8a4228d..cc58d99 100644 --- a/examples/ulai14.py +++ b/examples/ulai14.py @@ -52,6 +52,8 @@ Rate, Gain, ADData, Options) Status = UL.RUNNING +CurCount = 0 +CurIndex = 0 while Status==UL.RUNNING: print 'b' - Status, CurCount, CurIndex = cbGetStatus(BoardNum, Status, CurCount, CurIndex, UL.AIFUNCTION) + Status, CurCount, CurIndex = UL.cbGetStatus(BoardNum, Status, CurCount, CurIndex, UL.AIFUNCTION) From a788ddbc5cbdc0e093bcd7738f0c7c69e478df3e Mon Sep 17 00:00:00 2001 From: u55 Date: Sat, 13 Feb 2016 00:45:26 -0700 Subject: [PATCH 4/6] Make python-3 compatible. --- README.rst | 3 ++- UniversalLibrary/UniversalLibrary.py | 5 +++-- UniversalLibrary/__init__.py | 3 ++- examples/simpletrig.py | 3 ++- examples/ulai01.py | 3 ++- examples/ulai02.py | 3 +++ examples/ulai03.py | 6 +++++- examples/ulai08.py | 3 +++ examples/ulai14.py | 8 ++++++-- examples/ulao02.py | 4 ++-- examples/uldi01.py | 5 ++--- examples/uldo01.py | 2 +- setup.py | 8 ++++++++ 13 files changed, 41 insertions(+), 15 deletions(-) diff --git a/README.rst b/README.rst index ac05194..22ad0b9 100644 --- a/README.rst +++ b/README.rst @@ -107,6 +107,7 @@ exceptions. :: + from __future__ import print_function import UniversalLibrary as UL BoardNum = 0 @@ -117,7 +118,7 @@ exceptions. DataValue = UL.cbAIn(BoardNum, Chan, Gain) EngUnits = UL.cbToEngUnits(BoardNum, Gain, DataValue) - print DataValue, EngUnits + print(DataValue, EngUnits) Further examples are included, including a simple diff --git a/UniversalLibrary/UniversalLibrary.py b/UniversalLibrary/UniversalLibrary.py index dd8292b..f6f333b 100644 --- a/UniversalLibrary/UniversalLibrary.py +++ b/UniversalLibrary/UniversalLibrary.py @@ -48,12 +48,13 @@ """ +from __future__ import absolute_import import platform import ctypes from ctypes import byref import numpy -import constants # PyUL contants -from constants import * # PyUL contants +from . import constants # PyUL contants +from .constants import * # PyUL contants if platform.architecture()[0] == '64bit': cbw = ctypes.windll.cbw64 # open CBW64.DLL diff --git a/UniversalLibrary/__init__.py b/UniversalLibrary/__init__.py index c4caa20..b68b590 100644 --- a/UniversalLibrary/__init__.py +++ b/UniversalLibrary/__init__.py @@ -33,4 +33,5 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Author: Andrew Straw -from UniversalLibrary import * +from __future__ import absolute_import +from .UniversalLibrary import * diff --git a/examples/simpletrig.py b/examples/simpletrig.py index dca8886..ef0840b 100644 --- a/examples/simpletrig.py +++ b/examples/simpletrig.py @@ -32,6 +32,7 @@ # Author: Andrew Straw +from __future__ import print_function import UniversalLibrary as UL import numpy import pylab @@ -48,7 +49,7 @@ UL.cbSetTrigger(BoardNum, UL.TRIG_HIGH, 0, 0) -print 'Waiting for trigger' +print('Waiting for trigger') Options = UL.CONVERTDATA + UL.EXTTRIGGER ADData = numpy.zeros((Count,), dtype=numpy.int16) Rate = UL.cbAInScan(BoardNum, LowChan, HighChan, Count, diff --git a/examples/ulai01.py b/examples/ulai01.py index b200fd0..5570607 100644 --- a/examples/ulai01.py +++ b/examples/ulai01.py @@ -32,6 +32,7 @@ # Author: Andrew Straw +from __future__ import print_function import UniversalLibrary as UL BoardNum = 0 @@ -42,4 +43,4 @@ DataValue = UL.cbAIn(BoardNum, Chan, Gain) EngUnits = UL.cbToEngUnits(BoardNum, Gain, DataValue) - print DataValue, EngUnits + print(DataValue, EngUnits) diff --git a/examples/ulai02.py b/examples/ulai02.py index c49b282..d9eb807 100644 --- a/examples/ulai02.py +++ b/examples/ulai02.py @@ -32,6 +32,7 @@ # Author: Andrew Straw +from __future__ import print_function import UniversalLibrary as UL import numpy @@ -49,3 +50,5 @@ Rate = UL.cbAInScan(BoardNum, LowChan, HighChan, Count, Rate, Gain, ADData, Options) +print(Rate) +print(ADData) diff --git a/examples/ulai03.py b/examples/ulai03.py index 4dbbcb3..3d9bbf1 100644 --- a/examples/ulai03.py +++ b/examples/ulai03.py @@ -32,6 +32,7 @@ # Author: Andrew Straw +from __future__ import print_function import UniversalLibrary as UL import numpy @@ -45,15 +46,18 @@ Rate = 3125 Options = UL.CONVERTDATA + UL.BACKGROUND + UL.SINGLEIO -ADData = numpy.zeros((10000,), dtype=numpy.int16) +ADData = numpy.zeros((Count,), dtype=numpy.int16) # Note that one could do similar things with a multi-threaded program Rate = UL.cbAInScan(BoardNum, LowChan, HighChan, Count, Rate, Gain, ADData, Options) +print(Rate) Status = UL.RUNNING CurCount = 0 CurIndex = 0 while Status==UL.RUNNING: Status, CurCount, CurIndex = UL.cbGetStatus(BoardNum, Status, CurCount, CurIndex, UL.AIFUNCTION) + +print(ADData) diff --git a/examples/ulai08.py b/examples/ulai08.py index c0dd2f4..9fcf2da 100644 --- a/examples/ulai08.py +++ b/examples/ulai08.py @@ -32,6 +32,7 @@ # Author: Andrew Straw +from __future__ import print_function import UniversalLibrary as UL import numpy @@ -56,3 +57,5 @@ ##Rate = UL.cbAInScan(BoardNum, LowChan, HighChan, Count, ## Rate, Gain, ADData, Options) + +print(ADData) diff --git a/examples/ulai14.py b/examples/ulai14.py index cc58d99..1f88706 100644 --- a/examples/ulai14.py +++ b/examples/ulai14.py @@ -32,6 +32,7 @@ # Author: Andrew Straw +from __future__ import print_function import UniversalLibrary as UL import numpy @@ -47,13 +48,16 @@ Options = UL.CONVERTDATA + UL.BACKGROUND + UL.SINGLEIO ADData = numpy.zeros((Count,), dtype=numpy.int16) -print 'a' +print('a') Rate = UL.cbAInScan(BoardNum, LowChan, HighChan, Count, Rate, Gain, ADData, Options) +print(Rate) Status = UL.RUNNING CurCount = 0 CurIndex = 0 while Status==UL.RUNNING: - print 'b' + print('b') Status, CurCount, CurIndex = UL.cbGetStatus(BoardNum, Status, CurCount, CurIndex, UL.AIFUNCTION) + +print(ADData) diff --git a/examples/ulao02.py b/examples/ulao02.py index b6295ec..5582e97 100644 --- a/examples/ulao02.py +++ b/examples/ulao02.py @@ -46,5 +46,5 @@ Rate = UL.NOTUSED Options = 0 -Rate = UL.cbAOutScan (BoardNum, LowChan, HighChan, Count, Rate, Gain, ADData, - Options) +Rate = UL.cbAOutScan(BoardNum, LowChan, HighChan, Count, Rate, Gain, ADData, + Options) diff --git a/examples/uldi01.py b/examples/uldi01.py index 822b910..54fd60b 100644 --- a/examples/uldi01.py +++ b/examples/uldi01.py @@ -31,6 +31,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Author: Andrew Straw +from __future__ import print_function import UniversalLibrary as UL BoardNum = 0 PortNum = UL.FIRSTPORTA @@ -39,6 +40,4 @@ DataValue = 0 while 1: DataValue = UL.cbDIn(BoardNum, PortNum, DataValue) - print "Port Value:",DataValue - - + print("Port Value:", DataValue) diff --git a/examples/uldo01.py b/examples/uldo01.py index b660c2e..2c79d32 100644 --- a/examples/uldo01.py +++ b/examples/uldo01.py @@ -36,7 +36,7 @@ BoardNum = 0 PortNum = UL.FIRSTPORTA Direction = UL.DIGITALOUT -UL.cbDConfigPort (BoardNum, PortNum, Direction) +UL.cbDConfigPort(BoardNum, PortNum, Direction) DataValue = 0 UL.cbDOut(BoardNum, PortNum, DataValue) diff --git a/setup.py b/setup.py index 34d597f..0768a2b 100644 --- a/setup.py +++ b/setup.py @@ -8,4 +8,12 @@ author_email = 'strawman@astraw.com', url = 'https://github.com/astraw/PyUniversalLibrary', packages=['UniversalLibrary'], + classifiers=[ + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Operating System :: Microsoft :: Windows', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + 'Topic :: System :: Hardware :: Hardware Drivers', + ], ) From c72552a8fa555170ed10a1da2a7650f2aac1ef03 Mon Sep 17 00:00:00 2001 From: u55 Date: Sat, 13 Feb 2016 02:06:32 -0700 Subject: [PATCH 5/6] Update list of related projects. --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 22ad0b9..edfaf12 100644 --- a/README.rst +++ b/README.rst @@ -54,9 +54,12 @@ Also of interest Various Python wrappers for data acquisition are available. Here are a few I know of: * National Instruments NI-DAQ: http://sourceforge.net/projects/uncpythontools/ + * National Instruments NIDAQmx: http://pythonhosted.org/PyDAQmx/ * Data Translation: `Martin Spacek`_ has indicated (personal commication) he has drivers * Comedi apparently comes with Python wrappers: http://www.comedi.org/ * `Dr. Warren Jasper's`_ `Measurement Computing USB drivers for Linux`_ (Andrew Straw has written Python wrappers for these - contact him for further information) + * IOtech (now owned by Measurement Computing): https://github.com/fake-name/PyIOTech/ + * LabJack: https://github.com/labjack/LabJackPython/ .. _Martin Spacek: http://www.ece.ualberta.ca/~mspacek/ .. _Dr. Warren Jasper's: http://www.tx.ncsu.edu/faculty_center/directory/detail.cfm?id=57 From 7c9d6083d536b29bbc860c5ddbe47f10d4af1bbf Mon Sep 17 00:00:00 2001 From: u55 Date: Sat, 13 Feb 2016 02:09:49 -0700 Subject: [PATCH 6/6] Github syntax highlighting for README example. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index edfaf12..1c7af4f 100644 --- a/README.rst +++ b/README.rst @@ -108,7 +108,7 @@ translation of the essentials of ulai01.c, included with `Universal Library`_. Error checking occurs automatically through Python exceptions. -:: +.. code:: python from __future__ import print_function import UniversalLibrary as UL