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
|
import logging
# this should be done before justpy is called or log formatter does not work
logging.basicConfig(format='%(asctime)s %(levelname)8s %(name)s: %(message)s', datefmt='%m/%d/%Y %H:%M:%S')
import justpy as jp
import pyvisa
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import qolab.tsdb as tsdb
import asyncio
import time
import qolab.gui.web as gui
from qolab.hardware import BasicInstrument
from qolab.hardware.scope import SDS1104X
from qolab.hardware.rf_generator import AgilentE8257D
from qolab.hardware.lockin import SRS_SR865A
from qolab.feedback import PID
from qolab.data import TraceSetSameX, TraceXY, Trace
from qolab.hardware.i_server import I800
l = logging.getLogger('qolab.gui.web')
l.setLevel(logging.INFO)
l = logging.getLogger('qolab.tsdb')
l.setLevel(logging.INFO)
logger = logging.getLogger('Magnetometer')
logger.setLevel(logging.INFO)
def getConfig(apparatus):
config = apparatus.config.copy()
ai = apparatus.instruments
for n, i in ai.items():
config[n]=i.getConfig()
return config
if __name__ == '__main__':
# TSDB logger setting
tsdb_client = tsdb.Client('influx', 'http://lumus.physics.wm.edu:8428', database='qolab')
tsdb_ingester = tsdb.Ingester(tsdb_client, batch=11, measurement_prefix='VAMPIRE.HighPower')
# creating Apparatus with all instruments to be logged
apparatus = Apparatus(tsdb_ingester=tsdb_ingester, device_nickname='magnetometer',)
apparatus.config['Device type'] = 'QOL VAMPIRE HighPower magnetometer'
apparatus.config['Device model'] = 'v0.1'
apparatus.config['FnamePrefix'] = 'magnetometer_eit'
apparatus.config['SavePath'] = '/mnt/qol_grp_data/data.VAMPIRE.HighPower'
app_nickname=apparatus.config['DeviceNickname']
logger.info("Accessing hardware")
rm = pyvisa.ResourceManager()
instr_scope=rm.open_resource('TCPIP::192.168.0.61::INSTR')
scope_fdbk = SDS1104X(instr_scope, device_nickname='.'.join([app_nickname, 'scope.feedback']), tsdb_ingester=tsdb_ingester)
instr_scope=rm.open_resource('TCPIP::192.168.0.62::INSTR')
scope_mon = SDS1104X(instr_scope, device_nickname='.'.join([app_nickname, 'scope.monitor']), tsdb_ingester=tsdb_ingester)
instr_rfgen=rm.open_resource('TCPIP::192.168.0.114::INSTR')
rfgen = AgilentE8257D(instr_rfgen, device_nickname='.'.join([app_nickname, 'rfgen']), tsdb_ingester=tsdb_ingester)
instr_lockin=rm.open_resource('TCPIP::192.168.0.51::INSTR')
lockin = SRS_SR865A(instr_lockin, device_nickname='.'.join([app_nickname, 'lockin']), tsdb_ingester=tsdb_ingester)
# adding instruments to apparatus
apparatus.instruments={}
ai = apparatus.instruments
ai['rfgen'] = rfgen
ai['lockin'] = lockin
ai['cellTemperatureController'] = I800(device_nickname='.'.join([app_nickname, 'cellTemperatureController']), tsdb_ingester=tsdb_ingester)
ai['scope.feedback'] = scope_fdbk
# scope_fdbk.setRoll(False)
# scope_fdbk.setRun(True)
# scope_fdbk.setTimePerDiv(0.0005)
# scope_fdbk.setChanVoltsPerDiv(1, 0.02)
# scope_fdbk.setChanVoltsPerDiv(3, 0.02)
scope_mon.config['SavePath'] = '/mnt/qol_grp_data/data.VAMPIRE.HighPower'
scope_mon.config['FnamePrefix'] = 'scope_eit'
ai['scope.monitor'] = scope_mon
# scope_mon.setRoll(False)
# scope_mon.setRun(True)
# scope_mon.setTimePerDiv(0.0005)
# scope_mon.setChanVoltsPerDiv(2, 0.002)
# scope_mon.setChanVoltageOffset(2, -0.0726)
# if we want to save new set of traces repeat this two commands
scope_fdbk.config['tags']['apparatus']=getConfig(apparatus)
scope_fdbk.save( maxRequiredPoints=1000 )
|