Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
total_control_app
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Drechsler
total_control_app
Commits
a77cf865
Commit
a77cf865
authored
Oct 26, 2018
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added scanFunction file. Now, the scan is performed with a generator.
parent
eb3686c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
24 deletions
+53
-24
myWidgets.py
myWidgets.py
+12
-24
scanFunctions.py
scanFunctions.py
+41
-0
No files found.
myWidgets.py
View file @
a77cf865
...
...
@@ -14,6 +14,8 @@ import telnetlib
import
os
from
messages
import
show_warning
import
scanFunctions
#An example of a class
class
anal_control_signal
(
QWidget
):
_registry
=
[]
...
...
@@ -94,15 +96,11 @@ class anal_control_signal(QWidget):
def
scanEvent
(
self
):
if
float
(
self
.
scan_step
)
<
float
(
self
.
scan_sb_start
.
val
)
or
float
(
self
.
scan_step
)
>
float
(
self
.
scan_sb_stop
.
val
):
self
.
scan_direction
=
(
-
1
)
*
self
.
scan_direction
self
.
scan_step
=
self
.
scan_step
+
self
.
scan_direction
self
.
scan_step
=
next
(
self
.
scan_array_gen
)
self
.
AO
.
set_out
(
self
.
scan_step
)
#print(self.scan_step)
def
PbarEvent
(
self
):
try
:
self
.
scanpBar
.
setValue
(
100
*
float
(
self
.
scan_step
-
float
(
self
.
scan_sb_start
.
val
))
/
float
(
self
.
scan_sb_stop
.
val
-
self
.
scan_sb_start
.
val
)
)
...
...
@@ -114,12 +112,7 @@ class anal_control_signal(QWidget):
def
doScanAction
(
self
):
#self.scan_direction = -float( (self.scan_sb_stop.val-self.scan_sb_start.val)/self.scan_sb_period.val ) * 5e-3 * 2
#self.scan_step = float(self.scan_sb_start.val)
if
self
.
ScanTimer
.
isActive
():
self
.
ScanTimer
.
stop
()
self
.
scan_button
.
setText
(
'Start scan'
)
...
...
@@ -131,23 +124,18 @@ class anal_control_signal(QWidget):
else
:
b
=
float
(
self
.
scan_sb_stop
.
val
)
a
=
float
(
self
.
scan_sb_start
.
val
)
dt
=
5.0e-3
T
=
float
(
self
.
scan_sb_period
.
val
)
n
=
int
(
T
/
(
2
*
dt
)
)
self
.
scan_direction
=
-
abs
(
b
-
a
)
/
n
# this is the size in voltage of each step
self
.
scan_step
=
float
(
self
.
sb
.
val
)
# from here it beggins
dt
=
5.0e-3
self
.
scan_array
=
scanFunctions
.
create_scan_array
(
self
.
scan_sb_start
.
val
,
self
.
scan_sb_stop
.
val
,
self
.
scan_sb_period
.
val
,
dt
)
self
.
scan_array_gen
=
scanFunctions
.
yield_scan_array
(
self
.
scan_array
)
if
self
.
scan_step
>
b
or
self
.
scan_step
<
a
:
if
self
.
scan_step
>
float
(
self
.
scan_sb_stop
.
val
)
or
self
.
scan_step
<
float
(
self
.
scan_sb_start
.
val
)
:
details
=
'Remember remember the fifth of November.'
+
'
\n
'
+
'Also remember that scan starts from the value of the corresponding spin box'
show_warning
(
'Scan can not start outside scan range and scan start should be lower than scan stop'
,
details_text
=
details
)
elif
n
<
5
:
show_warning
(
'
%
i steps are too few, you need at least 5 steps'
%
(
n
)
)
pass
elif
len
(
self
.
scan_array
)
<
5
:
show_warning
(
'
%
i steps are too few, you need at least 5 steps'
%
(
len
(
self
.
scan_array
))
)
else
:
self
.
sb
.
setEnabled
(
False
)
self
.
scan_button
.
setStyleSheet
(
"background-color: green"
)
...
...
scanFunctions.py
0 → 100644
View file @
a77cf865
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 26 11:24:28 2018
@author: martindrech
Auxiliary functions for performing scans in a cleaner way
"""
import
numpy
as
np
def
create_scan_array
(
scan_start
,
scan_stop
,
scan_period
,
dt
):
"""
Returns the array that represents one period of the scan, including up and down paths of the triangle.
"""
scan_start
=
float
(
scan_start
)
scan_stop
=
float
(
scan_stop
)
scan_period
=
float
(
scan_period
)
number_of_points
=
1
+
(
scan_period
+
dt
)
//
(
2
*
dt
)
scan_array
=
np
.
linspace
(
scan_start
,
scan_stop
,
int
(
number_of_points
))
return
np
.
concatenate
((
scan_array
,
np
.
flip
(
scan_array
,
0
)[
1
:]))
def
yield_array
(
arr
):
larr
=
len
(
arr
)
cursor
=
0
while
cursor
<
larr
:
yield
arr
[
cursor
]
cursor
=
cursor
+
1
def
yield_scan_array
(
arr
):
while
True
:
yield
from
yield_array
(
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