Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EW control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
whuie2
EW control
Commits
e5407fad
Commit
e5407fad
authored
3 years ago
by
whuie2
Browse files
Options
Downloads
Patches
Plain Diff
function arg adjustments; add Computer.rerun and Sequence.from_digital1_data
parent
430095a2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/sequences.py
+5
-4
5 additions, 4 deletions
lib/sequences.py
lib/structures.py
+58
-24
58 additions, 24 deletions
lib/structures.py
with
63 additions
and
28 deletions
lib/sequences.py
+
5
−
4
View file @
e5407fad
...
...
@@ -37,7 +37,8 @@ class SuperSequence:
"""
def
__init__
(
self
,
outdir
:
pathlib
.
Path
,
name
:
str
,
sequences
:
dict
[
str
,
Sequence
]
=
None
,
defaults
:
ConnectionLayout
=
None
):
sequences
:
dict
[
str
,
Sequence
]
=
None
,
defaults
:
ConnectionLayout
=
None
):
"""
Constructor.
...
...
@@ -62,7 +63,7 @@ class SuperSequence:
assert
isinstance
(
seq
,
Sequence
)
self
.
sequences
[
key
]
=
seq
def
get
(
self
,
key
,
default
)
->
Sequence
:
def
get
(
self
,
key
,
default
=
None
)
->
Sequence
:
return
self
.
sequences
.
get
(
key
,
default
)
def
keys
(
self
):
...
...
@@ -216,7 +217,7 @@ class SuperSequence:
# set up background lines and histories on each connection
# each history is a list of matplotlib line objects for each sequence
conn_history
=
dict
()
for
k
,
(
conn_label
,
conn
)
in
enumerate
(
_connections
):
for
k
,
(
conn_label
,
conn
)
in
enumerate
(
reversed
(
_connections
)
)
:
if
isinstance
(
conn
,
DigitalConnection
):
P
.
ax
.
axhline
(
hk
*
k
+
1
,
color
=
"
0.85
"
,
linestyle
=
"
-
"
,
linewidth
=
0.4
,
...
...
@@ -260,7 +261,7 @@ class SuperSequence:
t0
=
seq
.
min_time
()
P
.
ax
.
axvline
(
t0
,
color
=
"
k
"
,
linestyle
=
"
--
"
,
linewidth
=
0.4
,
zorder
=
102
)
for
k
,
(
conn_label
,
conn
)
in
enumerate
(
_connections
):
for
k
,
(
conn_label
,
conn
)
in
enumerate
(
reversed
(
_connections
)
)
:
ts
=
seq
.
_get_states
(
**
conn
)
if
len
(
ts
)
>
0
:
_t
=
[
conn_history
[
conn
][
-
1
].
get_xdata
()[
-
1
]]
...
...
This diff is collapsed.
Click to expand it.
lib/structures.py
+
58
−
24
View file @
e5407fad
...
...
@@ -374,9 +374,35 @@ class Sequence:
board
=
board
,
connector
=
connector
,
mask
=
mask
,
state
=
S
[
i
],
time
=
T
[
i
]
)
for
i
in
range
(
len
(
T
))
state
=
s
,
time
=
t
)
for
t
,
s
in
zip
(
T
,
S
)
])
@staticmethod
def
from_digital1_data
(
T
:
list
[
float
],
S
:
list
[
int
],
board
:
int
,
connector
:
int
,
channel
:
int
)
->
Sequence
:
"""
Construct a Sequence of digital events on `board`, `connector`,
`channel` from lists of times and states.
Parameters
----------
T : list[float]
S : list[int]
board : int
connector : int
channel : int
"""
assert
len
(
T
)
==
len
(
S
)
return
Sequence
([
Event
(
EventType
.
Digital
,
board
=
board
,
connector
=
connector
,
mask
=
1
<<
channel
,
state
=
int
(
bool
(
s
))
<<
channel
,
time
=
t
)
for
t
,
s
in
zip
(
T
,
S
)
])
@staticmethod
...
...
@@ -401,9 +427,9 @@ class Sequence:
Event
(
EventType
.
Analog
,
board
=
board
,
channel
=
channel
,
state
=
V
[
i
]
,
time
=
T
[
i
]
)
for
i
in
range
(
len
(
T
)
)
state
=
v
,
time
=
t
)
for
t
,
v
in
zip
(
T
,
V
)
])
def
to_primitives
(
self
)
->
dict
[
str
,
...]:
...
...
@@ -557,8 +583,8 @@ class Sequence:
return
seq
@staticmethod
def
analog_ramp_lin
(
channel
:
int
,
V
0
:
float
,
V
1
:
float
,
t
0
:
float
,
t
1
:
float
)
->
Sequence
:
def
analog_ramp_lin
(
channel
:
int
,
t
0
:
float
,
t
1
:
float
,
V
0
:
float
,
V
1
:
float
)
->
Sequence
:
"""
Construct a Sequence of events for a linear analog ramp beginning at
(t0, V0) and ending at (t1, V1) on the specified channel at maximum
...
...
@@ -578,8 +604,8 @@ class Sequence:
*
ewm
.
linear_ramp
(
V0
,
V1
,
t0
,
t1
),
0
,
channel
)
@staticmethod
def
analog_ramp_exp
(
channel
:
int
,
V
0
:
float
,
V
1
:
float
,
t
0
:
float
,
t
1
:
float
,
rate
:
float
)
->
Sequence
:
def
analog_ramp_exp
(
channel
:
int
,
t
0
:
float
,
t
1
:
float
,
V
0
:
float
,
V
1
:
float
,
rate
:
float
)
->
Sequence
:
"""
Construct a Sequence of events for an exponential ramp beginning at
(t0, V0) and ending at (t1, V1) on the specified channel at maximum
...
...
@@ -600,8 +626,8 @@ class Sequence:
*
ewm
.
exponential_ramp
(
V0
,
V1
,
t0
,
t1
,
rate
),
0
,
channel
)
@staticmethod
def
analog_sin
(
channel
:
int
,
amp
:
float
,
dc
:
float
,
freq
:
float
,
phase
:
float
,
t0
:
float
,
t1
:
float
)
->
Sequence
:
def
analog_sin
(
channel
:
int
,
t0
:
float
,
t1
:
float
,
amp
:
float
,
dc
:
float
,
freq
:
float
,
phase
:
float
)
->
Sequence
:
"""
Construct a Sequence of events for a a sine wave beginning at `t0` and
ending at `t1` with amplitude `amp`, DC offset `dc`, frequency `freq`,
...
...
@@ -621,8 +647,8 @@ class Sequence:
*
ewm
.
sin
(
amp
,
dc
,
freq
,
phase
,
t0
,
t1
),
0
,
channel
)
@staticmethod
def
analog_cos
(
channel
:
int
,
amp
:
float
,
dc
:
float
,
freq
:
float
,
phase
:
float
,
t0
:
float
,
t1
:
float
)
->
Sequence
:
def
analog_cos
(
channel
:
int
,
t0
:
float
,
t1
:
float
,
amp
:
float
,
dc
:
float
,
freq
:
float
,
phase
:
float
)
->
Sequence
:
"""
Construct a Sequence of events for a a sine wave beginning at `t0` and
ending at `t1` with amplitude `amp`, DC offset `dc`, frequency `freq`,
...
...
@@ -1055,6 +1081,14 @@ class Computer:
ew
.
run_sequence
()
return
self
def
rerun
(
self
):
"""
Re-run the last-loaded sequence.
"""
assert
self
.
_connected
,
"
Must be connected
"
ew
.
rerun_last_sequence
()
return
self
def
stop
(
self
):
"""
Halt execution of the current sequence.
...
...
@@ -1093,18 +1127,18 @@ def ch(*ch_nums: int, num_channels: int=32) -> int:
return
acc
# set_digital_state(
# seqtime: f64, // time of state change
# board: u8, // board number, only have one
# connector: u8, // connector on board, 0-3
# channel_mask: u32, // bitmask for channels to be changed
# output_enable_state: u32, // bitmask for which channels drive their outputs
# output_state: u32 // state of channels
# seqtime: f64,
// time of state change
# board: u8,
// board number, only have one
# connector: u8,
// connector on board, 0-3
# channel_mask: u32,
// bitmask for channels to be changed
# output_enable_state: u32,
// bitmask for which channels drive their outputs
# output_state: u32
// state of channels
# )
# set_analog_state(
# seqtime: f64, // time of state change
# board: u8, // board number, only have one
# channel: u8, // 0-31
# value: f42 // -10
-
+10
# seqtime: f64,
// time of state change
# board: u8,
// board number, only have one
# channel: u8,
// 0-31
# value: f42
//
[
-10
,
+10
]
# )
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