-
Notifications
You must be signed in to change notification settings - Fork 16
/
IScope.cs
171 lines (155 loc) · 5.87 KB
/
IScope.cs
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LabNation.DeviceInterface.DataSources;
using System.IO;
using System.Runtime.Serialization;
using System.Xml;
namespace LabNation.DeviceInterface.Devices
{
public delegate void AcquisitionTransferFinishedHandler(IScope scope, EventArgs e);
[Serializable()]
[DataContract]
public class Probe
{
[DataMember] public float Gain { get; private set; }
[DataMember] public float Offset { get; private set; }
[DataMember] public string Name { get; private set; }
[DataMember] public string Unit { get; private set; }
public Probe(string name, string unit, float gain, float offset, bool invert)
{
this.Name = name;
this.Unit = unit;
this.Gain = gain;
this.Offset = offset;
}
public void ChangeOffset(float offset)
{
this.Offset = offset;
}
private static Probe defaultX1Probe = new Probe("X1", "V", 1, 0, false);
public static Probe DefaultX1Probe {get { return defaultX1Probe; } }
private static Probe defaultX10Probe = new Probe("X10", "V", 10, 0, false);
public static Probe DefaultX10Probe { get { return defaultX10Probe; } }
}
public enum TriggerSource { Channel = 0, External = 1 };
public enum TriggerEdge { RISING = 0, FALLING = 1, ANY = 2 };
public enum TriggerMode { Edge = 0, Timeout = 1, Pulse = 2, Digital = 3 };
public enum Coupling { AC, DC };
public enum AcquisitionMode { SINGLE = 2, NORMAL = 1, AUTO = 0};
public enum DigitalTriggerValue { L, H, R, F, X };
/// <summary>
/// Describes an entire trigger condition
/// </summary>
public class TriggerValue
{
/// <summary>
/// Trigger mode (pulse,edge,timeout,digi)
/// </summary>
public TriggerMode mode = TriggerMode.Edge;
/// <summary>
/// Trigger source (analog/ext)
/// </summary>
public TriggerSource source = TriggerSource.Channel;
/// <summary>
/// Analog mode channel
/// </summary>
public AnalogChannel channel = AnalogChannel.ChA;
/// <summary>
/// Digital mode setting
/// </summary>
private Dictionary<DigitalChannel, DigitalTriggerValue> digital = new Dictionary<DigitalChannel,DigitalTriggerValue>();
public Dictionary<DigitalChannel, DigitalTriggerValue> Digital
{
get { return digital; }
set
{
if (value == null)
throw new Exception("Can't set trigger's digital value with null");
digital = value;
}
}
/// <summary>
/// The direction for analog/ext trigger
/// </summary>
public TriggerEdge edge = TriggerEdge.RISING;
/// <summary>
/// Trigger level in volt for analog mode
/// </summary>
public float level;
public double pulseWidthMin = 0.0;
public double pulseWidthMax = double.PositiveInfinity;
public TriggerValue()
{
foreach (DigitalChannel ch in DigitalChannel.List)
Digital[ch] = DigitalTriggerValue.X;
}
public TriggerValue(TriggerValue t) : this ()
{
mode = t.mode;
source = t.source;
channel = t.channel;
Digital = new Dictionary<DigitalChannel, DigitalTriggerValue>(t.Digital);
edge = t.edge;
level = t.level;
pulseWidthMax = t.pulseWidthMax;
pulseWidthMin = t.pulseWidthMin;
}
public TriggerValue Copy()
{
return (TriggerValue)this.MemberwiseClone();
}
}
public interface IScope : IDevice
{
DataPackageScope GetScopeData();
DataSources.DataSource DataSourceScope { get; }
bool Rolling { get; set; }
bool Running { get; set; }
bool CanRoll { get; }
bool StopPending { get; }
bool AwaitingTrigger { get; }
bool Armed { get; }
void Pause();
void Resume();
/* Acquisition & Trigger */
uint AcquisitionDepthUserMaximum { get; set; }
bool PreferPartial { get; set; }
AcquisitionMode AcquisitionMode { get; set; }
double AcquisitionLength { get; set; }
double SamplePeriod { get; }
double AcquisitionLengthMax { get; }
double AcquisitionLengthMin { get; }
uint AcquisitionDepthMax { get; }
uint InputDecimationMax { get; }
int SubSampleRate { get; }
uint AcquisitionDepth { get; set; }
double TriggerHoldOff { get; set; }
TriggerValue TriggerValue { get; set; }
bool SendOverviewBuffer { get; set; }
void ForceTrigger();
event AcquisitionTransferFinishedHandler OnAcquisitionTransferFinished;
/* Channel specifics */
void SetCoupling(AnalogChannel channel, Coupling coupling);
Coupling GetCoupling(AnalogChannel channel);
void SetVerticalRange(AnalogChannel channel, float minimum, float maximum);
void SetYOffset(AnalogChannel channel, float offset);
float GetYOffset(AnalogChannel channel);
float GetYOffsetLimit1(AnalogChannel ch);
float GetYOffsetLimit2(AnalogChannel ch);
/* Logic Analyser */
bool LogicAnalyserEnabled { get; }
AnalogChannel ChannelSacrificedForLogicAnalyser { set; }
/* Viewport */
void SetViewPort(double offset, double timespan);
double ViewPortTimeSpan { get; }
double ViewPortOffset { get; }
bool SuspendViewportUpdates { get; set; }
void CommitSettings();
}
public class ValidationException: Exception
{
public ValidationException(string message) : base(message) { }
}
}