Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-S 2020 - PyRaTk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DELTA
DELTA Low-Cost 5.8GHz FMCW Radar PCB
AP-S 2020 Software
AP-S 2020 - PyRaTk
Commits
bfb2572c
Commit
bfb2572c
authored
4 years ago
by
Merlo, Jason
Browse files
Options
Downloads
Patches
Plain Diff
Fixed crash on platforms that don't support mcculw
parent
049b12b1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyratk/acquisition/mcdaq_win.py
+58
-47
58 additions, 47 deletions
pyratk/acquisition/mcdaq_win.py
with
58 additions
and
47 deletions
pyratk/acquisition/mcdaq_win.py
+
58
−
47
View file @
bfb2572c
...
...
@@ -10,11 +10,16 @@ Dependencies: mcculw
from
pyratk.acquisition.daq
import
DAQ
# Used for Measurement Computing hardware
from
mcculw
import
ul
from
mcculw.enums
import
(
ScanOptions
,
Status
,
FunctionType
,
EventType
,
TrigType
,
InfoType
,
BoardInfo
,
ULRange
,
ErrorCode
,
InterfaceType
)
from
mcculw.ul
import
ULError
SUPPORTED
=
True
try
:
from
mcculw
import
ul
from
mcculw.enums
import
(
ScanOptions
,
Status
,
FunctionType
,
EventType
,
TrigType
,
InfoType
,
BoardInfo
,
ULRange
,
ErrorCode
,
InterfaceType
)
from
mcculw.ul
import
ULError
except
:
SUPPORTED
=
False
print
(
'
`mcculw` not found on this system
'
)
import
ctypes
from
collections
import
namedtuple
...
...
@@ -27,64 +32,69 @@ class mcdaq_win(DAQ):
def
__init__
(
self
,
sample_rate
=
50000
,
sample_chunk_size
=
5000
,
low_channel
=
0
,
high_channel
=
7
):
self
.
daq_type
=
"
MC-DAQ-WIN
"
if
SUPPORTED
:
self
.
_low_channel
=
low_channel
self
.
_high_channel
=
high_channel
self
.
daq_type
=
"
MC-DAQ-WIN
"
self
.
_
board_num
=
0
self
.
_
pretr
ig_c
ount
=
0
self
.
_
low_channel
=
low_channel
self
.
_
h
ig
h
_c
hannel
=
high_channel
# Get available devices
dev_list
=
ul
.
get_daq_device_inventory
(
InterfaceType
.
ANY
)
print
(
"
Available Devices:
"
,
dev_list
)
self
.
_board_num
=
0
self
.
_pretrig_count
=
0
if
dev_list
==
[]:
raise
Exception
(
'
No DAQ devices found
'
)
# Get available devices
dev_list
=
ul
.
get_daq_device_inventory
(
InterfaceType
.
ANY
)
print
(
"
Available Devices:
"
,
dev_list
)
print
(
self
.
_get_available_ranges
())
try
:
self
.
_range
=
self
.
_get_available_ranges
()[
-
1
]
except
IndexError
:
self
.
_range
=
-
1
if
dev_list
==
[]:
raise
Exception
(
'
No DAQ devices found
'
)
print
(
self
.
_get_available_ranges
())
try
:
self
.
_range
=
self
.
_get_available_ranges
()[
-
1
]
except
IndexError
:
self
.
_range
=
-
1
print
(
'
Using range:
'
,
self
.
_range
)
print
(
'
Using range:
'
,
self
.
_range
)
channel_count
=
self
.
_high_channel
-
self
.
_low_channel
+
1
self
.
_buffer_size
=
sample_chunk_size
*
channel_count
channel_count
=
self
.
_high_channel
-
self
.
_low_channel
+
1
self
.
_buffer_size
=
sample_chunk_size
*
channel_count
super
().
__init__
(
sample_rate
,
sample_chunk_size
,
channel_count
)
super
().
__init__
(
sample_rate
,
sample_chunk_size
,
channel_count
)
self
.
_memhandle
=
ul
.
scaled_win_buf_alloc
(
self
.
_buffer_size
)
self
.
_ctypes_array
=
ctypes
.
cast
(
self
.
_memhandle
,
ctypes
.
POINTER
(
ctypes
.
c_double
))
self
.
_memhandle
=
ul
.
scaled_win_buf_alloc
(
self
.
_buffer_size
)
self
.
_ctypes_array
=
ctypes
.
cast
(
self
.
_memhandle
,
ctypes
.
POINTER
(
ctypes
.
c_double
))
self
.
_scan_options
=
(
ScanOptions
.
BACKGROUND
#| ScanOptions.CONTINUOUS
|
ScanOptions
.
SCALEDATA
|
ScanOptions
.
EXTTRIGGER
|
ScanOptions
.
BURSTIO
)
self
.
_scan_options
=
(
ScanOptions
.
BACKGROUND
#| ScanOptions.CONTINUOUS
|
ScanOptions
.
SCALEDATA
|
ScanOptions
.
EXTTRIGGER
|
ScanOptions
.
BURSTIO
)
self
.
_event_types
=
(
EventType
.
ON_DATA_AVAILABLE
|
EventType
.
ON_END_OF_INPUT_SCAN
|
EventType
.
ON_SCAN_ERROR
)
self
.
_event_types
=
(
EventType
.
ON_DATA_AVAILABLE
|
EventType
.
ON_END_OF_INPUT_SCAN
|
EventType
.
ON_SCAN_ERROR
)
self
.
_trig_types
=
(
TrigType
.
TRIG_POS_EDGE
)
self
.
_trig_types
=
(
TrigType
.
TRIG_POS_EDGE
)
self
.
_last_index
=
0
self
.
_last_index
=
0
# Create new sampling task
# try:
# pass
# except Exception as e:
# self.daq_type = "FakeDAQ"
# print("="*80)
# print("Warning: Exception occurred opening DAQ. Using fake data.")
# print(e)
# print("="*80)
# Create new sampling task
# try:
# pass
# except Exception as e:
# self.daq_type = "FakeDAQ"
# print("="*80)
# print("Warning: Exception occurred opening DAQ. Using fake data.")
# print(e)
# print("="*80)
def
start
(
self
):
print
(
'
Started mcdaq
'
)
self
.
run
()
if
SUPPORTED
:
print
(
'
Started mcdaq
'
)
self
.
run
()
else
:
print
(
'
`mcculw` not available, not starting DAQ.
'
)
def
run
(
self
):
# Stop any AI task running
...
...
@@ -166,7 +176,8 @@ class mcdaq_win(DAQ):
print
(
'
\n
The scan is complete
\n
'
)
def
close
(
self
):
ul
.
stop_background
(
self
.
_board_num
,
FunctionType
.
AIFUNCTION
)
if
SUPPORTED
:
ul
.
stop_background
(
self
.
_board_num
,
FunctionType
.
AIFUNCTION
)
super
().
close
()
def
_get_available_ranges
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment