Пример #1
0
 def __init__(self, address):
     try:
         self.flowcontroller = propar.instrument(address)
         self.checkControlMode()
         self.capacity = self.flowcontroller.readParameter(21)
         self.units = self.flowcontroller.readParameter(129)
         self.fluidName = self.flowcontroller.readParameter(25)
         if (self.capacity == None):
             print('Problem getting the capacity. Trying once more')
             self.flowcontroller = propar.instrument(address)
             self.capacity = self.flowcontroller.readParameter(21)
             self.units = self.flowcontroller.readParameter(129)
             self.fluidName = self.flowcontroller.readParameter(25)
     except Exception as e:
         print('Could not find device: {}'.format(e))
    def _connect(self, port):
        """Connect to the instrument serial port.
        https://pypi.org/project/bronkhorst-propar/

        Arguments
        port (str): Filename of device (e.g. "/dev/ttyUSB0")
        """
        return propar.instrument(port)
Пример #3
0
 def init_device(self):
     """Initialises the attributes and properties of the BronkhorstPressureCtrl."""
     self.info_stream("init_device()")
     Device.init_device(self)
     self.set_state(DevState.INIT)
           
     self.info_stream("port: {:s}".format(self.Port))
     
     # connect to device
     self.__el_flow = propar.instrument(self.Port)
     
     self.set_status("The device is in ON state")
     self.set_state(DevState.ON)
    def write(self, data):
        #print(f'dummy serial write {data}')

        # Check if it is a read for serial number
        if b'\x80\x06\x04\x71\x63\x71\x63\x00\x10\x03' in data:
            # Copy start and sequence number from resquest to response
            self.read_data = data[:3]
            if data[2] == 0x10:
                self.read_data = data[:4]
            self.read_data += b'\x80\x0F\x02\x71\x63\x00'

            # Generate random serial number to check for correct functionality
            self.serial_number = ''.join(
                random.choice(string.ascii_lowercase) for i in range(10))

            self.read_data += self.serial_number.encode('ascii')
            self.read_data += b'\x00\x10\x03'

        return len(data)


dut = propar.instrument('dummy_serial', serial_class=dummy_serial)

for i in range(20):
    serial = dut.readParameter(92)
    if serial == dut.master.propar.serial.serial_number:
        print('Ok!', serial)
    else:
        print('Error!', serial, '!=', dut.master.propar.serial.serial_number)
import propar
import time

dut = propar.instrument('com1')

dut.master.dump(2)

while True:
    time.sleep(1)
    v = dut.readParameter(11)
    #print(v)
Пример #6
0
# Import the propar module
import propar
import time
import numpy as np

# Connect to the local instrument, when no settings provided
# defaults to locally connected instrument (address=0x80, baudrate=38400)
cori_flow = propar.instrument('COM12')
# Prepare a list of parameters for a chained read containing:
# fmeasure, fsetpoint, temperature, valve output
params = [{
    'proc_nr': 33,
    'parm_nr': 0,
    'parm_type': propar.PP_TYPE_FLOAT
}, {
    'proc_nr': 33,
    'parm_nr': 3,
    'parm_type': propar.PP_TYPE_FLOAT
}, {
    'proc_nr': 33,
    'parm_nr': 7,
    'parm_type': propar.PP_TYPE_FLOAT
}, {
    'proc_nr': 114,
    'parm_nr': 1,
    'parm_type': propar.PP_TYPE_INT32
}]

# Note that this uses the read_parameters function.
values = cori_flow.read_parameters(params)
Пример #7
0
#CharMM_readout.py: reads, processes and plots sensor data from the CharMM setup every .5 seconds for use in the Java app.
#The output of this script is a csv file and 4 jpeg images (plots)
#For more information, see the 2018-2019 S2 student report

#Importing the required packages.
import pandas as pd  #Data is stored in a Pandas dataframe.
import numpy as np
import matplotlib.pyplot as plt  #Pyplot is used for plotting sensor data.
import datetime
import time
import propar  #This is the Bronkhorst sensor reading package and does not come with Anaconda.
import threading  #For reading out the sensors every .5 seconds.

#Connecting to the different instruments. Both COM port and node have to be specified.
#Additional sensors can be added here.
bl100 = propar.instrument('COM4', 3)
diffp = propar.instrument('COM8', 4)
coriflow = propar.instrument('COM8', 5)


#Defining the readout function, which reads out the sensors.
def readout():
    """Reads the relevant data from the sensors"""

    #Getting the time of measurement.
    thetime = datetime.datetime.now().strftime("%H:%M:%S,%f")[:-5]

    #Additional parameters to read out can be added here.
    T_BL100 = bl100.readParameter(142)
    MF_BL100 = bl100.readParameter(205)
    Rho_BL100 = bl100.readParameter(270)
Пример #8
0
#params.py: reads out all parameters from a chosen Bronkhorst device. Uses the Bronkhorst Propar module.

# Importing the module
import propar

#Define the COM port and node of the sensor here.
sensor = propar.instrument('COM8', 4)

db = sensor.db
parameters = db.get_all_parameters()

#Printing all parameter numbers and their current values.
for i in parameters :
   print(i)
   print(sensor.readParameter(i["dde_nr"]))