Пример #1
0
class MaxiGaugePlugin(object):
    ''' This plugin passes a MaxiGauge class handle to route callbacks
that accept a `maxigauge` keyword argument.
It is based on the example on
http://bottlepy.org/docs/stable/plugindev.html#plugin-example-sqliteplugin
'''
    name = 'maxigauge'
    api = 2

    def __init__(self, device, keyword='maxigauge'):
         self.device = device
         self.keyword = keyword

    def setup(self, app):
        ''' Make sure that other installed plugins don't affect the same
keyword argument.'''
        for other in app.plugins:
            if not isinstance(other, MaxiGaugePlugin): continue
            if other.keyword == self.keyword:
                raise PluginError("Found another MaxiGauge plugin with "\
                "conflicting settings (non-unique keyword).")
        try:
            ### Initialize an instance of the MaxiGauge controller with
            ### the handle of the serial terminal it is connected to
            self.maxigauge = MaxiGauge(self.device)
            self.maxigauge.start_continuous_pressure_updates(.4, 75)
        except Exception, e:
            raise PluginError("Could not connect to the MaxiGauge (on port %s). Error: %s" % (self.device, e) )
Пример #2
0
    def setup(self, app):
        ''' Make sure that other installed plugins don't affect the same
keyword argument.'''
        for other in app.plugins:
            if not isinstance(other, MaxiGaugePlugin): continue
            if other.keyword == self.keyword:
                raise PluginError("Found another MaxiGauge plugin with "\
                "conflicting settings (non-unique keyword).")
        try:
            ### Initialize an instance of the MaxiGauge controller with
            ### the handle of the serial terminal it is connected to
            self.maxigauge = MaxiGauge(self.device)
            self.maxigauge.start_continuous_pressure_updates(.4, 75)
        except Exception, e:
            raise PluginError("Could not connect to the MaxiGauge (on port %s). Error: %s" % (self.device, e) )
Пример #3
0
    def initialization(self):
        self.problem = False
        try:
            self.panel = GHSPanel(str(self.portGHS))
        except:
            self.emit(SIGNAL('panelMessage(QString)'),
                      'Can\'t connect socket to MicroTask')
            time.sleep(0.2)
            self.problem = True
            self.emit(SIGNAL('initProblem(bool)'), self.problem)
            time.sleep(0.2)

        try:
            self.mg = MaxiGauge(str(self.portMG))
        except:
            self.emit(SIGNAL('panelMessage(QString)'),
                      'Can\'t connect socket to MaxiGauge')
            time.sleep(0.2)
            self.problem = True
            self.emit(SIGNAL('initProblem(bool)'), self.problem)
            time.sleep(0.2)
Пример #4
0
#!/usr/bin/env python

### Load the module:
from PfeifferVacuum import MaxiGauge, MaxiGaugeError
import time
import sys

### Initialize an instance of the MaxiGauge controller with
### the handle of the serial terminal it is connected to
mg = MaxiGauge('/dev/ttyUSB1')

### Read out the pressure gauges
while True:
    startTime = time.time()

    try:
        ps = mg.pressures()
    except MaxiGaugeError, mge:
        print mge
        continue
    line = ""
    for sensor in ps:
        #print sensor values
        if sensor.status in [0,1,2]: # if normal, over or under range
            line += str(sensor.pressure)
        line += ", "
    print line[0:-2] # omit the last comma and space
    sys.stdout.flush()
    
    # do this every second
    endTime = time.time()-startTime
Пример #5
0
#!/usr/bin/env python

### Load the module:
from PfeifferVacuum import MaxiGauge

### Initialize an instance of the MaxiGauge controller with
### the handle of the serial terminal it is connected to
mg = MaxiGauge('/dev/ttyUSB0')

### Run the self check (not needed)
print(mg.checkDevice())

### Set device characteristics (here: change the display contrast)
print("Set the display contrast to: %d" % mg.displayContrast(10))

### Read out the pressure gauges
print(mg.pressures())

### Display the value of the pressure gauges for 20 repeated read outs
for i in range(20):
    ps = mg.pressures()
    print "Sensor 1: %4e mbar" % ps[0].pressure + "Sensor 6: %4e mbar" % ps[5].pressure
Пример #6
0
import sys, os, time, datetime
from PfeifferVacuum import MaxiGauge
from time import gmtime, strftime

file_header = '/home/outgassing/outgassing/pressure_data/'

nowtime = strftime("%Y-%m-%d %H:%M:%S")
nowtime2 = strftime("%Y%m%d_%H%M%S")
try:
    filename = os.path.join(file_header, sys.argv[1])
except IndexError:
    print('Usage: python log_pressure.py <file name (not including path)>')
    sys.exit()
file1 = open(filename, 'a')
file1.write('Pfeiffer read started at ' + nowtime + ' (EDT)\n' +
            'Time (s)\tPressure (Torr)\n')
file1.close()
while True:
    mg = MaxiGauge('/dev/my_usb_serial')
    #mg = MaxiGauge('/dev/ttyUSB0')
    ps = mg.pressures()
    file1 = open(filename, 'a')
    #file1.write(str(time.time())+'\n')
    file1.write(
        str(int(round(time.time()))) + '\t' + str(ps[0].pressure) + '\n')
    file1.close()
    time.sleep(59)
Пример #7
0
#!/usr/bin/env python

### Load the module:
from PfeifferVacuum import MaxiGauge

### Initialize an instance of the MaxiGauge controller with
### the handle of the serial terminal it is connected to
mg = MaxiGauge('/dev/ttyUSB0')

### Run the self check (not needed)
print(mg.checkDevice())

### Set device characteristics (here: change the display contrast)
print("Set the display contrast to: %d" % mg.displayContrast(10))

### Read out the pressure gauges
print(mg.pressures())

### Display the value of the pressure gauges for 20 repeated read outs
for i in range(20):
    ps = mg.pressures()
    print "Sensor 1: %4e mbar" % ps[0].pressure + "Sensor 6: %4e mbar" % ps[
        5].pressure