Skip to content

Commit f5621cb

Browse files
committed
First release on website, v0.8.0. Removal of the device class (functions now), parameter changes, up to date to LJM v0.2.19a, module/package structure changes, the addition of docstrings/documentation and core examples, and more.
1 parent c00a14b commit f5621cb

19 files changed

+2116
-1237
lines changed

CHANGES.TXT

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Version History
2+
---------------
3+
4+
0.8.0 (01/25/2013)
5+
- Initial release.

Examples/eAddresses.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eAddresses (LJM_eAddresses) function.
3+
4+
"""
5+
6+
from labjack import ljm
7+
8+
9+
# Open first found LabJack
10+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
11+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
12+
13+
info = ljm.getHandleInfo(handle)
14+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
15+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
16+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
17+
18+
# Setup and call eAddresses to write/read values to/from the LabJack.
19+
numFrames = 3
20+
aAddresses = [1000, 55110, 55110] # [DAC0, TEST_UINT16, TEST_UINT16]
21+
aDataTypes = [ljm.constants.FLOAT32, ljm.constants.UINT16, ljm.constants.UINT16]
22+
aWrites = [ljm.constants.WRITE, ljm.constants.WRITE, ljm.constants.READ]
23+
aNumValues = [1, 1, 1]
24+
aValues = [2.5, 12345, 0] # [write 2.5 V, write 12345, read]
25+
results = ljm.eAddresses(handle, numFrames, aAddresses, aDataTypes, aWrites, aNumValues, aValues)
26+
27+
print "\neAddresses results: "
28+
start = 0
29+
for i in range(numFrames):
30+
end = start + aNumValues[i]
31+
print " Address - %i, data type - %i, write - %i, values: %s" % \
32+
(aAddresses[i], aDataTypes[i], aWrites[i], str(results[start:end]))
33+
start = end
34+
35+
# Close handle
36+
ljm.close(handle)

Examples/eNames.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eNames (LJM_eNames) function.
3+
4+
"""
5+
6+
from labjack import ljm
7+
8+
9+
# Open first found LabJack
10+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
11+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
12+
13+
info = ljm.getHandleInfo(handle)
14+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
15+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
16+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
17+
18+
# Setup and call eNames to write/read values to/from the LabJack.
19+
numFrames = 3
20+
names = ["DAC0", "TEST_UINT16", "TEST_UINT16"]
21+
aWrites = [ljm.constants.WRITE, ljm.constants.WRITE, ljm.constants.READ]
22+
aNumValues = [1, 1, 1]
23+
aValues = [2.5, 12345, 0] # [write 2.5 V, write 12345, read]
24+
results = ljm.eNames(handle, numFrames, names, aWrites, aNumValues, aValues)
25+
26+
print "\neNames results: "
27+
start = 0
28+
for i in range(numFrames):
29+
end = start + aNumValues[i]
30+
print " Name - %s, write - %i, values %s" % \
31+
(names[i], aWrites[i], results[start:end])
32+
start = end
33+
34+
# Close handle
35+
ljm.close(handle)

Examples/eReadAddress.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eReadAddress (LJM_eReadAddress)
3+
function.
4+
5+
"""
6+
7+
from labjack import ljm
8+
9+
10+
# Open first found LabJack
11+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
12+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
13+
14+
info = ljm.getHandleInfo(handle)
15+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
16+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
17+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
18+
19+
# Setup and call eReadAddress to read a value from the LabJack.
20+
address = 60028 # Serial number
21+
dataType = ljm.constants.UINT32
22+
result = ljm.eReadAddress(handle, address, dataType)
23+
24+
print "\neReadAddress result: "
25+
print " Address - %i, data type - %i, value : %f" % \
26+
(address, dataType, result)
27+
28+
# Close handle
29+
ljm.close(handle)

Examples/eReadAddresses.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eReadAddresses (LJM_eReadAddresses)
3+
function.
4+
5+
"""
6+
7+
from labjack import ljm
8+
9+
10+
# Open first found LabJack
11+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
12+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
13+
14+
info = ljm.getHandleInfo(handle)
15+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
16+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
17+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
18+
19+
# Setup and call eReadAddresses to read values from the LabJack.
20+
numFrames = 3
21+
aAddresses = [60028, 60000, 60004] # [serial number, product ID, firmware version]
22+
aDataTypes = [ljm.constants.UINT32, ljm.constants.FLOAT32,
23+
ljm.constants.FLOAT32]
24+
results = ljm.eReadAddresses(handle, numFrames, aAddresses, aDataTypes)
25+
26+
print "\neReadAddresses results: "
27+
for i in range(numFrames):
28+
print " Address - %i, data type - %i, value : %f" % \
29+
(aAddresses[i], aDataTypes[i], results[i])
30+
31+
# Close handle
32+
ljm.close(handle)

Examples/eReadName.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eReadName (LJM_eReadName) function.
3+
4+
"""
5+
6+
from labjack import ljm
7+
8+
9+
# Open first found LabJack
10+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
11+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
12+
13+
info = ljm.getHandleInfo(handle)
14+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
15+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
16+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
17+
18+
# Setup and call eReadName to read a value from the LabJack.
19+
name = "SERIAL_NUMBER"
20+
result = ljm.eReadName(handle, name)
21+
22+
print "\neReadName result: "
23+
print " Name - %s, value : %f" % (name, result)
24+
25+
# Close handle
26+
ljm.close(handle)

Examples/eReadNames.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eReadNames (LJM_eReadNames) function.
3+
4+
"""
5+
6+
from labjack import ljm
7+
8+
9+
# Open first found LabJack
10+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
11+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
12+
13+
info = ljm.getHandleInfo(handle)
14+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
15+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
16+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
17+
18+
# Setup and call eReadNames to read values from the LabJack.
19+
numFrames = 3
20+
names = ["SERIAL_NUMBER", "PRODUCT_ID", "FIRMWARE_VERSION"]
21+
results = ljm.eReadNames(handle, numFrames, names)
22+
23+
print "\neReadNames results: "
24+
for i in range(numFrames):
25+
print " Name - %s, value : %f" % (names[i], results[i])
26+
27+
# Close handle
28+
ljm.close(handle)

Examples/eWriteAddress.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eWriteAddress (LJM_eWriteAddress)
3+
function.
4+
5+
"""
6+
7+
from labjack import ljm
8+
9+
10+
# Open first found LabJack
11+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
12+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
13+
14+
info = ljm.getHandleInfo(handle)
15+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
16+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
17+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
18+
19+
# Setup and call eWriteAddress to write a value to the LabJack.
20+
address = 1000 # DAC0
21+
dataType = ljm.constants.FLOAT32
22+
value = 2.5 # 2.5 V
23+
ljm.eWriteAddress(handle, address, dataType, value)
24+
25+
print "\neWriteAddress: "
26+
print " Address - %i, data type - %i, value : %f" % \
27+
(address, dataType, value)
28+
29+
# Close handle
30+
ljm.close(handle)

Examples/eWriteAddresses.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eWriteAddresses (LJM_eWriteAddresses)
3+
function.
4+
5+
"""
6+
7+
from labjack import ljm
8+
9+
10+
# Open first found LabJack
11+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
12+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
13+
14+
info = ljm.getHandleInfo(handle)
15+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
16+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
17+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
18+
19+
# Setup and call eWriteAddresses to write values to the LabJack.
20+
numFrames = 2
21+
aAddresses = [1000, 55110] # [DAC0, TEST_UINT16]
22+
aDataTypes = [ljm.constants.FLOAT32, ljm.constants.UINT16]
23+
aValues = [2.5, 12345] # [write 2.5 V, write 12345]
24+
ljm.eWriteAddresses(handle, numFrames, aAddresses, aDataTypes, aValues)
25+
26+
print "\neWriteAddresses: "
27+
for i in range(numFrames):
28+
print " Address - %i, data type - %i, value : %f" % \
29+
(aAddresses[i], aDataTypes[i], aValues[i])
30+
31+
# Close handle
32+
ljm.close(handle)

Examples/eWriteName.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eWriteName (LJM_eWriteName)
3+
function.
4+
5+
"""
6+
7+
from labjack import ljm
8+
9+
10+
# Open first found LabJack
11+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
12+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
13+
14+
info = ljm.getHandleInfo(handle)
15+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
16+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
17+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
18+
19+
# Setup and call eWriteName to write a value to the LabJack.
20+
name = "DAC0"
21+
value = 2.5 # 2.5 V
22+
ljm.eWriteName(handle, name, value)
23+
24+
print "\neWriteName: "
25+
print " Name - %s, value : %f" % (name, value)
26+
27+
# Close handle
28+
ljm.close(handle)

Examples/eWriteNames.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Demonstrates how to use the labjack.ljm.eWriteNames (LJM_eWriteNames) function.
3+
4+
"""
5+
6+
from labjack import ljm
7+
8+
9+
# Open first found LabJack
10+
handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "LJM_idANY")[2]
11+
#handle = ljm.openS("LJM_dtANY", "LJM_ctANY", "LJM_idANY")
12+
13+
info = ljm.getHandleInfo(handle)
14+
print "Opened a LabJack with Device type: %i, Connection type: %i,\n" \
15+
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
16+
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])
17+
18+
# Setup and call eWriteNames to write values to the LabJack.
19+
numFrames = 2
20+
names = ["DAC0", "TEST_UINT16"]
21+
aValues = [2.5, 12345] # [2.5 V, 12345]
22+
ljm.eWriteNames(handle, numFrames, names, aValues)
23+
24+
print "\neWriteNames: "
25+
26+
for i in range(numFrames):
27+
print " Name - %s, value : %f" % (names[i], aValues[i])
28+
29+
# Close handle
30+
ljm.close(handle)

LICENSE LICENSE.TXT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2012 LabJack Corporation <support@labjack.com>
1+
Copyright (C) 2013 LabJack Corporation <support@labjack.com>
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of
44
this software and associated documentation files (the "Software"), to deal in

README

-29
This file was deleted.

0 commit comments

Comments
 (0)