示例#1
0
def pressureTask(pressureIndex, period):
    """Set the selected pressure channel to a random value every [period] seconds"""
    minPressure, maxPressure = fgt_get_pressureRange(pressureIndex)
    while not cancellationToken:
        pressureOrder = random.random() * maxPressure
        fgt_set_pressure(pressureIndex, pressureOrder)
        print("task {}: New pressure order: {:.2f} mbar".format(
            pressureIndex, pressureOrder))
        time.sleep(period)
示例#2
0
from __future__ import print_function
import time

from Fluigent.SDK import fgt_init, fgt_close
from Fluigent.SDK import fgt_set_pressure, fgt_get_pressure, fgt_get_pressureRange

## Initialize the session
# This step is optional, if not called session will be automatically
# created
fgt_init()

## Set and read pressure

# Set pressure to 20 mbar on first pressure channel of the list
# mbar is the default unit at initialization
fgt_set_pressure(0, 20)

# Wait 5 seconds for the pressure to settle
print('Waiting 5 seconds...')
time.sleep(5)

# Read pressure value
pressureMeasurement = fgt_get_pressure(0)
print('Current pressure: {}'.format(pressureMeasurement))

## Create a pressure ramp profile
# The ramp goes from device minimal to maximal pressure in 10 steps

# Create the pressure steps

示例#3
0
            pressureIndex, pressureOrder))
        time.sleep(period)


## Initialize the session
# This step is mandatory before starting threads at the same time
fgt_init()

## Create the threads
# Thread 1: drives the first pressure channel (index 0) every 2 seconds
thread1 = Thread(target=pressureTask, args=(0, 2))
# Thread 2: drives the second pressure channel (index 1) every 5 seconds
thread2 = Thread(target=pressureTask, args=(1, 5))

try:
    # Start the threads
    thread1.start()
    thread2.start()
    # Wait 10 seconds
    time.sleep(10)
finally:
    # Stop the threads
    cancellationToken = True
    thread1.join()
    thread2.join()
    # Reset pressure on all channels
    for pressure_index in range(fgt_get_pressureChannelCount()):
        fgt_set_pressure(pressure_index, 0)
    ## Close the session
    fgt_close()
示例#4
0
print('Waiting 5 seconds...')
time.sleep(5)

# Read sensor value
sensorMeasurement = fgt_get_sensorValue(0)
print('Current sensor value: {:.2f}'.format(sensorMeasurement))

## Create a sinusoidal profile
# The profile oscillates between the minimum and the maximum sensor value

# Create the sine wave setpoints
amplitude = (maxSensor - minSensor)
offset = minSensor
sinePoints = [(sin(angle * pi / 180) + 1) / 2 for angle in range(0, 360, 10)]
setpoints = [value * amplitude + offset for value in sinePoints]

for sensorSetpoint in setpoints:
    # Set new setpoint
    print('Set sensor regulation to {:.2f}'.format(sensorSetpoint))
    fgt_set_sensorRegulation(0, 0, sensorSetpoint)
    # Wait 1 second
    time.sleep(1)
    # Read sensor value
    sensorMeasurement = fgt_get_sensorValue(0)
    print('Current sensor value: {:.2f}'.format(sensorMeasurement))

## Close the session
# Set pressure to 0 before closing. This also stops the regulation
fgt_set_pressure(0, 0)
fgt_close()