-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphSubs.py
executable file
·89 lines (63 loc) · 1.84 KB
/
GraphSubs.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
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Sub programs for doing the measurements
author : Eoin O'Farrell
email : phyoec@nus.edu.sg
last edited : July 2013
Explantion:
There are 3 variables in our instrument:
1 Temperature
2 Field
3 Device parameter; e.g. Backgate V, Topgate V, Current, Angle (one day)
Typically a measurement will fix two of these and vary the other.
The controls for temperature and field are controlled by external
services that can be called by the measurement. The measurement
invokes a localhost for each of these services and can then
access certain methods
The generic ports for these are
Magnet: 18861
Temperature: 18871
Data from these processes can also be accessed through named pipes
Device parameters are so far controlled in situ in the measurement
loop. This should probably also be changed to be consistent
ToDo:
InitializeInstruments
ScanInstruments
InitializeDataFile
WriteDataFile
CloseDataFile
GraphData
"""
import string as string
import re as re
import time
import multiprocessing
import numpy as np
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph as pg
import pyqtgraph.opengl as gl
import sys
import os
def MakeGraph(conn):
win = pg.GraphicsWindow(title = "test")
win.resize(300,300)
p1 = win.addPlot(title = "test")
curve = p1.plot(pen = 'y')
timer = QtCore.QTimer()
CurveData = np.random.normal(size=(10,1000))
def Update():
global CurveData
try:
ConnData = conn.recv()
ConnData = [float(i) for i in ConnData]
CurveData = np.append(CurveData,ConnData)
curve.setData(CurveData)
except EOFError:
print "Graph connection closed\n"
timer.stop()
QtGui.QApplication.quit()
timer.timeout.connect(Update)
timer.start(0)
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()