Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DEL 1ns 4cha
Commits
caaa2d4c
Commit
caaa2d4c
authored
Nov 06, 2011
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software: added PyQT demo application
parent
0cae1105
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
852 additions
and
0 deletions
+852
-0
demo.py
software/python/demo.py
+120
-0
fd_demo.ui
software/python/fd_demo.ui
+657
-0
fdelay_lib.py
software/python/fdelay_lib.py
+75
-0
No files found.
software/python/demo.py
0 → 100755
View file @
caaa2d4c
#!/usr/bin/python
import
sys
import
PyQt4
import
PyQt4.QtGui
import
PyQt4.QtCore
import
PyQt4.uic
from
PyQt4.QtGui
import
*
from
PyQt4.QtCore
import
*
from
fdelay_lib
import
FineDelay
FormClass
=
PyQt4
.
uic
.
loadUiType
(
'fd_demo.ui'
)[
0
]
class
MainWindow
(
QMainWindow
,
FormClass
):
def
__init__
(
self
):
super
(
MainWindow
,
self
)
.
__init__
()
self
.
setupUi
(
self
)
# self.setWindowTitle("ion")
def
channel_update
(
channel
):
print
(
"UpdateCh:
%
d"
%
channel
)
en
=
ch_enable
[
channel
-
1
]
.
checkState
();
dly
=
int
(
ch_nsec
[
channel
-
1
]
.
value
()
*
1000
+
(
ch_sec
[
channel
-
1
]
.
value
()
*
1000000000000
))
w
=
int
(
ch_width
[
channel
-
1
]
.
value
()
*
1000
)
card
.
conf_output
(
channel
,
en
,
dly
,
w
)
def
trigger_update
():
card
.
conf_trigger
(
m
.
en_trigger
.
checkState
(),
m
.
en_term
.
checkState
())
def
on_ts_enable_disable
():
print
(
"ontsen"
)
card
.
conf_readout
(
m
.
en_ts
.
checkState
())
prev_ts
=
0
def
on_ts_clear
():
print
(
"ontabclear"
)
poll_timer
.
stop
()
for
i
in
range
(
0
,
m
.
ts_table
.
rowCount
()):
m
.
ts_table
.
removeRow
(
i
)
prev_ts
=
0
poll_timer
.
start
()
def
poll_timer_cb
():
buf
=
card
.
read_ts
()
for
ts
in
buf
:
global
prev_ts
row
=
m
.
ts_table
.
rowCount
()
m
.
ts_table
.
insertRow
(
row
)
m
.
ts_table
.
setItem
(
row
,
0
,
QTableWidgetItem
(
"
%
d"
%
ts
.
seq_id
))
m
.
ts_table
.
setItem
(
row
,
1
,
QTableWidgetItem
(
"
%
d"
%
ts
.
utc
))
m
.
ts_table
.
setItem
(
row
,
2
,
QTableWidgetItem
(
"
%.3
f"
%
ts
.
nsecs
()))
m
.
ts_table
.
setItem
(
row
,
3
,
QTableWidgetItem
(
"
%.3
f"
%
(
ts
.
nsecs_full
()
-
prev_ts
)))
prev_ts
=
ts
.
nsecs_full
()
# i = QTableWidgetItem()
m
.
ts_table
.
scrollToBottom
()
m
.
wr_status
.
setText
(
card
.
get_sync_status
())
def
on_chk_wr
():
if
(
m
.
wr_checkbox
.
checkState
()):
card
.
conf_sync
(
card
.
SYNC_WR
)
else
:
card
.
conf_sync
(
card
.
SYNC_LOCAL
)
if
__name__
==
"__main__"
:
app
=
QApplication
(
sys
.
argv
)
if
(
sys
.
argv
[
1
]
==
"1"
):
location
=
"minibone/eth8/00:50:0c:de:bc:f8/0x100000"
else
:
location
=
"minibone/eth8/00:50:e4:95:36:f8/0x100000"
m
=
MainWindow
()
m
.
show
()
m
.
setWindowTitle
(
"Fine Delay Demo @
%
s"
%
location
)
card
=
FineDelay
(
location
)
m
.
wr_status
.
setText
(
""
)
ch_enable
=
[
m
.
en_ch1
,
m
.
en_ch2
,
m
.
en_ch3
,
m
.
en_ch4
];
ch_nsec
=
[
m
.
nsec_ch1
,
m
.
nsec_ch2
,
m
.
nsec_ch3
,
m
.
nsec_ch4
];
ch_sec
=
[
m
.
sec_ch1
,
m
.
sec_ch2
,
m
.
sec_ch3
,
m
.
sec_ch4
];
ch_width
=
[
m
.
width_ch1
,
m
.
width_ch2
,
m
.
width_ch3
,
m
.
width_ch4
];
for
i
in
range
(
1
,
5
):
channel_update
(
i
)
ch_enable
[
0
]
.
stateChanged
.
connect
(
lambda
:
channel_update
(
1
))
ch_enable
[
1
]
.
stateChanged
.
connect
(
lambda
:
channel_update
(
2
))
ch_enable
[
2
]
.
stateChanged
.
connect
(
lambda
:
channel_update
(
3
))
ch_enable
[
3
]
.
stateChanged
.
connect
(
lambda
:
channel_update
(
4
))
ch_nsec
[
0
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
1
))
ch_nsec
[
1
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
2
))
ch_nsec
[
2
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
3
))
ch_nsec
[
3
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
4
))
ch_sec
[
0
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
1
))
ch_sec
[
1
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
2
))
ch_sec
[
2
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
3
))
ch_sec
[
3
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
4
))
ch_width
[
0
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
1
))
ch_width
[
1
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
2
))
ch_width
[
2
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
3
))
ch_width
[
3
]
.
valueChanged
.
connect
(
lambda
:
channel_update
(
4
))
m
.
en_trigger
.
stateChanged
.
connect
(
lambda
:
trigger_update
())
m
.
en_term
.
stateChanged
.
connect
(
lambda
:
trigger_update
())
m
.
en_ts
.
stateChanged
.
connect
(
on_ts_enable_disable
)
m
.
wr_checkbox
.
stateChanged
.
connect
(
on_chk_wr
)
m
.
btn_clear
.
clicked
.
connect
(
on_ts_clear
)
trigger_update
();
on_ts_enable_disable
()
m
.
ts_table
.
clearContents
()
# m.ts_table
poll_timer
=
QTimer
()
poll_timer
.
setInterval
(
200
)
poll_timer
.
timeout
.
connect
(
poll_timer_cb
)
poll_timer
.
start
()
app
.
exec_
()
software/python/fd_demo.ui
0 → 100644
View file @
caaa2d4c
This diff is collapsed.
Click to expand it.
software/python/fdelay_lib.py
0 → 100755
View file @
caaa2d4c
#!/usr/bin/python
from
ctypes
import
*
import
sys
import
re
class
fd_timestamp
(
Structure
):
_fields_
=
[(
"utc"
,
c_ulong
),
(
"coarse"
,
c_ulong
),
(
"frac"
,
c_ulong
),
(
"seq_id"
,
c_ushort
)]
def
nsecs
(
self
):
return
(
float
(
self
.
frac
)
*
8000.0
/
4096.0
+
float
(
self
.
coarse
)
*
8000.0
)
/
1000.0
;
def
nsecs_full
(
self
):
return
(
float
(
self
.
frac
)
*
8000.0
/
4096.0
+
float
(
self
.
coarse
)
*
8000.0
)
/
1000.0
+
float
(
self
.
utc
)
*
1000000000.0
;
def
__str__
(
self
):
return
"
%
d:
%
d"
%
(
self
.
utc
,
self
.
nsecs
())
class
FineDelay
:
FREE_RUNNING
=
0x10
WR_OFFLINE
=
0x8
WR_READY
=
0x1
WR_SYNCING
=
0x2
WR_SYNCED
=
0x4
SYNC_LOCAL
=
0x1
SYNC_WR
=
0x2
def
__init__
(
self
,
dev_path
):
s
=
re
.
split
(
"
\
/"
,
dev_path
)
self
.
fd
=
CDLL
(
'../lib/libfinedelay.so'
)
if
(
s
[
0
]
==
"local"
):
print
(
"Initializing local at
%
x"
%
int
(
s
[
1
],
16
))
self
.
handle
=
c_voidp
(
self
.
fd
.
fdelay_create_rawrabbit
(
int
(
s
[
1
],
16
)));
elif
(
s
[
0
]
==
"minibone"
):
print
(
"Initializing minibone at
%
s [
%
s]
\n
"
%
(
s
[
1
],
s
[
2
]))
self
.
handle
=
c_voidp
(
self
.
fd
.
fdelay_create_minibone
(
c_char_p
(
s
[
1
]),
c_char_p
(
s
[
2
]),
int
(
s
[
3
],
16
)));
if
(
self
.
fd
.
fdelay_init
(
self
.
handle
)
<
0
):
print
(
"Init failed.."
);
# sys.exit(-1)
def
conf_trigger
(
self
,
enable
,
termination
):
self
.
fd
.
fdelay_configure_trigger
(
self
.
handle
,
c_int
(
enable
),
c_int
(
termination
))
def
conf_output
(
self
,
channel
,
enable
,
delay
,
width
):
self
.
fd
.
fdelay_configure_output
(
self
.
handle
,
c_int
(
channel
),
c_int
(
enable
),
c_ulonglong
(
delay
),
c_ulonglong
(
width
))
def
conf_readout
(
self
,
enable
):
self
.
fd
.
fdelay_configure_readout
(
self
.
handle
,
enable
)
def
conf_sync
(
self
,
mode
):
self
.
fd
.
fdelay_configure_sync
(
self
.
handle
,
mode
)
def
get_sync_status
(
self
):
htab
=
{
self
.
FREE_RUNNING
:
"oscillator free-running"
,
self
.
WR_OFFLINE
:
"WR core offline"
,
self
.
WR_READY
:
"WR core ready"
,
self
.
WR_SYNCING
:
"Syncing local clock with WR"
,
self
.
WR_SYNCED
:
"Synced with WR"
}
status
=
c_int
(
self
.
fd
.
fdelay_get_sync_status
(
self
.
handle
));
# print("GetSyncStatus %x" % status.value);
return
htab
[
status
.
value
]
def
read_ts
(
self
):
buf
=
(
fd_timestamp
*
256
)();
ptr
=
pointer
(
buf
)
n
=
self
.
fd
.
fdelay_read
(
self
.
handle
,
ptr
,
256
)
arr
=
[];
for
i
in
range
(
0
,
n
):
arr
.
append
(
buf
[
i
])
return
arr
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