Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
distributed oscilloscope
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
distributed oscilloscope
Commits
f3c8eeff
Commit
f3c8eeff
authored
Aug 16, 2019
by
Milosz Malczak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adc: added comments, removed unused function in server_expose
parent
931e8daf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
16 deletions
+79
-16
devices_access.py
...tributedOscilloscope/nodes/adc_lib_node/devices_access.py
+69
-13
server_expose.py
...stributedOscilloscope/nodes/adc_lib_node/server_expose.py
+10
-3
No files found.
software/DistributedOscilloscope/nodes/adc_lib_node/devices_access.py
View file @
f3c8eeff
...
...
@@ -39,7 +39,12 @@ class DevicesAccess():
self
.
run
=
False
def
set_user_app_name
(
self
,
user_app_name
):
print
(
user_app_name
)
"""
Sets the name of the User Application -- this name is used to
distinguish WRTD rules.
:param user_app_name: Name of the User Application
"""
self
.
user_app_name
=
user_app_name
if
user_app_name
:
self
.
distribute_triggers_name
=
'dt_'
+
user_app_name
[
0
:
8
]
...
...
@@ -60,6 +65,31 @@ class DevicesAccess():
def
set_WRTD_master
(
self
,
WRTD_master
,
trigger_type
=
None
,
ADC_trigger_idx
=
None
):
"""
Defines if particular device works as master or slave. The master
distributed the triggers, the slave receives the triggers.
Master mode:
* enables the selected trigger
* adds WRTD rule to distribute timestamps
* modifies the number of presmaples and postsamples to align data
\
from various ADCs
Slave mode:
* disables all triggers
* adds WRTD rule to receive timestamps
* modifies the number of presmaples and postsamples to align data
\
from various ADCs
:param WRTD_master: if True device works as master, if False device
\
works as slave
:param trigger_type: in master mode defines the type of the trigger to
\
enable
:param ADC_trigger_idx: in master mode dfines the index of the trigger
\
to enable
"""
for
count
in
range
(
4
):
self
.
__ADC
.
set_internal_trigger_enable
(
0
,
count
)
self
.
__ADC
.
set_external_trigger_enable
(
0
,
0
)
...
...
@@ -95,6 +125,14 @@ class DevicesAccess():
self
.
__WRTD
.
enable_rule
(
self
.
receive_triggers_name
)
def
configure_adc_parameter
(
self
,
function_name
,
*
args
):
"""
Generic function to modify the ADC parameters.
:param function_name: the name of the function, which modifies
\
particular ADC parameter
:param *args: arguments passed to the function -- the type of
\
arguments depends on the selected function
"""
if
(
function_name
==
'set_presamples'
and
self
.
__WRTD_master
is
False
):
self
.
__required_presamples
=
args
[
0
]
args
=
list
(
args
)
...
...
@@ -109,6 +147,11 @@ class DevicesAccess():
self
.
configure_acquisition
(
self
.
__channels
)
def
get_current_adc_conf
(
self
):
"""
Retrieves the configuration of the ADC.
:return: Dictionary with ADC configurations
"""
conf
=
self
.
__ADC
.
current_config
()
conf
[
'is_WRTD_master'
]
=
self
.
__WRTD_master
if
(
not
self
.
__WRTD_master
):
...
...
@@ -121,18 +164,13 @@ class DevicesAccess():
acq_conf
[
'presamples'
]
-=
delay_samples
return
acq_conf
def
stop_acquisition
(
self
):
self
.
__ADC
.
acq_stop
(
0
)
try
:
self
.
selector
.
unregister
(
self
)
logger
.
debug
(
"The ADC device unregistered from the poller selector"
)
except
KeyError
:
logger
.
warning
(
"The ADC device not available to unregister from "
"the poller selector stop acquisition"
)
self
.
__acquisition_configured
=
False
def
configure_acquisition
(
self
,
channels
):
"""
Configures single acquisition.
:param channels: list of channels indexes from which the data should
\
be retrieved
"""
self
.
__channels
=
channels
self
.
__ADC
.
stop_acquisition
()
...
...
@@ -144,11 +182,29 @@ class DevicesAccess():
def
run_acquisition
(
self
,
run
,
channels
=
None
):
"""channels could be None only if run is False"""
"""
Starts or stops continuous acquisition.
:param run: if True start acquisition, if False stop acquisition
:param channels: list of channels indexes from which the data should
\
be retrieved
"""
#channels could be None only if run is False
self
.
run
=
run
if
run
:
self
.
configure_acquisition
(
channels
)
def
stop_acquisition
(
self
):
self
.
__ADC
.
acq_stop
(
0
)
try
:
self
.
selector
.
unregister
(
self
)
logger
.
debug
(
"The ADC device unregistered from the poller selector"
)
except
KeyError
:
logger
.
warning
(
"The ADC device not available to unregister from "
"the poller selector stop acquisition"
)
self
.
__acquisition_configured
=
False
def
fileno
(
self
):
return
self
.
__ADC
.
fileno
()
...
...
software/DistributedOscilloscope/nodes/adc_lib_node/server_expose.py
View file @
f3c8eeff
...
...
@@ -28,10 +28,17 @@ class ServerExpose():
return
getattr
(
self
.
__devices_access
,
function_name
)
def
set_server_address
(
self
,
addr
):
self
.
server_publisher
=
Publisher
(
addr
,
self
.
__port_server
)
"""
If address of the Server is provided by the user, this function
is called from main.
If address of the Server is discovered by zeroconf, this function is
called by RPC call from the server.
It created the Publisher object used for sending the notifications
and acquisition data to the Server.
def
set_user_app_name
(
self
,
user_app_name
):
self
.
__devices_access
.
set_user_app_name
(
user_app_name
)
:param addr: address of the Server
"""
self
.
server_publisher
=
Publisher
(
addr
,
self
.
__port_server
)
def
exit
(
self
):
"""This fucntion is just for testing and will be removed after
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment