-
Notifications
You must be signed in to change notification settings - Fork 1
/
connect.py
76 lines (58 loc) · 2.03 KB
/
connect.py
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
### SmartScopeConnect.m
import clr
clr.AddReference("/opt/smartscope/DeviceInterface.dll")
from LabNation.DeviceInterface import Devices
from LabNation.DeviceInterface import DataSources
def connection_handler(x, y):
print("connection_handler")
print(x)
print(y)
device_manager = Devices.DeviceManager(connection_handler)
print(device_manager)
#Devices.DeviceConnectHandler(device_manager.fallbackDevice, True)
device_manager.Start(True)
scope = device_manager.MainDevice
print(scope)
scope.Running = False
scope.CommitSettings()
scope.DataSourceScope.Start()
# define timebase and trigger position
scope.AcquisitionLength = 0.001
scope.TriggerHoldOff = 0.0005
# set optimal configuration for analog scoping
scope.Rolling = False
scope.SendOverviewBuffer = False
scope.AcquisitionMode = Devices.AcquisitionMode.AUTO
scope.PreferPartial = False
scope.SetViewPort(0, scope.AcquisitionLength)
# define ChannelA input
scope.SetVerticalRange(Devices.AnalogChannel.ChA, -3, 3)
scope.SetYOffset(Devices.AnalogChannel.ChA, 0)
scope.SetCoupling(Devices.AnalogChannel.ChA, Devices.Coupling.DC)
Devices.AnalogChannel.ChA.SetProbe(Devices.Probe.DefaultX1Probe)
# define ChannelB input
scope.SetVerticalRange(Devices.AnalogChannel.ChB, -3, 3)
scope.SetYOffset(Devices.AnalogChannel.ChB, 0)
scope.SetCoupling(Devices.AnalogChannel.ChB, Devices.Coupling.DC)
Devices.AnalogChannel.ChB.SetProbe(Devices.Probe.DefaultX1Probe)
# define trigger
tv = Devices.TriggerValue()
tv.source = Devices.TriggerSource.Channel
tv.channel = Devices.AnalogChannel.ChA
tv.edge = Devices.TriggerEdge.RISING
tv.level = 0.5
scope.TriggerValue = tv
# go!
scope.CommitSettings()
scope.Running = True
scope.CommitSettings()
print(scope.DataSourceScope.IsRunning)
### SmartScopePlot.m
import numpy as np
def data_handler(data, args):
print(np.asarray(data.GetData(DataSources.ChannelDataSourceScope.Viewport, Devices.AnalogChannel.ChA).array))
scope.DataSourceScope.OnNewDataAvailable += data_handler
scope.DataSourceScope.Start()
from time import sleep
sleep(10)
print("finished")