-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLogicAnalyzerCaptureStep.py
More file actions
59 lines (47 loc) · 2.33 KB
/
LogicAnalyzerCaptureStep.py
File metadata and controls
59 lines (47 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from OpenTap import AvailableValues, Display, EnabledIf, Unit
from System import Boolean, Double, Int32
from System.Collections.Generic import List
from System.ComponentModel import Browsable
from opentap import *
from .LogicAnalyzer import *
@attribute(
Display("Capture", "Captures logic events using Logic Analyzer", Groups=["PSLab", "Logic Analyzer"]))
class LogicAnalyzerCaptureStep(TestStep):
# Properties
channels = property(Int32, 1) \
.add_attribute(AvailableValues("Available")) \
.add_attribute(Display("Channels", "Number of channels to sample from simultaneously",
"Measurements", -50))
@property(List[Int32])
@attribute(Browsable(False)) # property not visible for the user.
def Available(self):
available = List[Int32]()
available.Add(1)
available.Add(2)
available.Add(3)
available.Add(4)
return available
events = property(Int32, 2500) \
.add_attribute(
Display("Events", "Number of logic events to capture on each channel", "Measurements", -40))
block = property(Boolean, True) \
.add_attribute(Display("Block", "Whether to block while waiting for events to be captured",
"Measurements", -30))
timeout = property(Double, 1) \
.add_attribute(Display("Timeout", "Timeout before cancelling measurement in blocking mode",
"Measurements", -20)) \
.add_attribute(Unit("s")) \
.add_attribute(EnabledIf("block"))
LogicAnalyzer = property(LogicAnalyzer, None) \
.add_attribute(Display("Logic Analyzer", "", "Resources", 0))
def __init__(self):
super(LogicAnalyzerCaptureStep, self).__init__()
self.Rules.Add(
Rule("timeout", lambda: not self.block or self.timeout >= 0, lambda: 'Timeout must not be negative.'))
self.Rules.Add(Rule("events", lambda: self.events >= 0, lambda: 'Number of events must not be negative.'))
self.Rules.Add(
Rule("events", lambda: self.events <= 2500, lambda: 'Number of events cannot be greater than 2500.'))
def Run(self):
super().Run() # 3.0: Required for debugging to work.
data = self.LogicAnalyzer.capture(self.channels, events=self.events, timeout=self.timeout, block=self.block)
print(data)