示例#1
0
# conditioned imports
if os.name == 'nt':
    import yaml
else:
    from ruamel import yaml

if not fg.my_dev_flag and fg.i2c:
    from I2CDevice import I2CDevice
elif not fg.my_dev_flag and fg.is_serial:
    # Quick hack to switch to USB
    from SerialDevice import SerialDevice as I2CDevice

# %%  Code
# activate logging
logger = logger_createChild('io', 'UC2')


def load_config(config_file):
    try:
        if not os.path.isfile(config_file):
            raise fluidException('File "{0}" not found.'.format(config_file))

        tmp_dict = {}
        config_load = fluid_load(config_file)

        for sub in config_load:
            sub_file = uni.Path(config_file.parent, config_load[sub])
            if not os.path.isfile(sub_file):
                raise fluidException('File "{0}" not found.'.format(sub_file))
            tmp_dict[sub] = {}
示例#2
0
import tifffile as tif
# math
import numpy as np
from PIL import Image
try:
    from scipy.ndimage import gaussian_filter
except Exception as e:
    print(str(e))

if not fg.my_dev_flag:
    from picamera.array import PiRGBArray
else:
    import imageio as imo

# %% parameters and pre starts
logger = logger_createChild('autofocus', 'UC2')
#
# %%
# ----------------------------------- #
# @       interface toolbox         @ #
# ----------------------------------- #


def autofocus_callback(self, instance, key, *rargs):
    '''
        Tests whether autofocus is already running or anything else is blocking. If not: blocks all measurements (and further autofocus-calls) and resets autofocus-count if scheduled.
        To block running autofocus, click "AF now" as implemented in Toolbox.run_autofocus-function.
    '''
    # skip if AF already running
    if fg.config['experiment']['autofocus_busy']:
        pass
示例#3
0
 def __init__(self, setup, device):
     self.setup = setup
     self.device = device
     self.topic_base = "/" + self.setup + "/" + self.device + "/"
     self.mqtt_subscribe()
     self.logger = logger_createChild(self.topic_base, 'UC2')
    from I2CBus import I2CBus
elif fg.is_serial:
    # Quick hack to switch to USB
    from SerialDevice import SerialDevice as I2CDevice
elif fg.is_gpio:
    # Quick hack to switch to GPIO
    from GPIODevice import GPIODevice as I2CDevice
else:
    from MQTTDevice import MQTTDevice
    import paho.mqtt.client as mqtt

if not fg.my_dev_flag:
    import picamera

# logging Functions ------------------------------------------------------------------------------
logger = logger_createChild('init', 'UC2')

# General Init ------------------------------------------------------------------------------


def controller_init():
    if fg.i2c:
        arduino_init()
    elif fg.is_serial:
        serial_init()
    elif fg.is_gpio:
        gpio_init()
    else:  # case of e.g. ESP32
        mqtt_init()
    camera_init()
示例#5
0
    import fluidiscopeInit
    import fluidiscopeToolbox as toolbox
    import fluidiscopeIO
    import fluidiscopeLogging as fl

if fg.is_use_picamera:
    import picamera

# Initialization
fl.logging_init()
fluidiscopeInit.load_config()
fluidiscopeInit.controller_init()
fluidiscopeInit.GUI_define_sizes()

# activate main-logger
logger = fl.logger_createChild('main', 'UC2')

# GUI classes


class Fluidiscope(BoxLayout):
    init_var = ListProperty([
        fg.config['light']['intensity_expt'],
        str(fg.config['motor']['stepsize_z']),
        fg.config['light_patterns']['active_p1'],
        fg.config['light_patterns']['active_p2'],
        fg.config['light_patterns']['active_p3'],
        fg.config['light_patterns']['active_p4']
    ])
    meas_var = ListProperty([
        toolbox.imaging_set_time_write(fg.config['experiment']['interval']),
示例#6
0
'''
Module that contains the tomography code.
'''
from fluidiscopeLogging import logger_createChild
import fluidiscopeGlobVar as fg
import fluidiscopeToolbox as toolbox
import fluidiscopeIO as fio


logger = logger_createChild('tomography','UC2')


# ----------------------------------------------------------------
#                      Tomographic-Functions


def tomography_callback(self):
    '''
    Real image acquisition-routine for tomographd mode. 
    '''
    # parameters
    nbr_steps = fg.config['tomo']['steps']+1
    fg.config['tomo']['done'] = False

    # get update (motor-movement direction)
    fg.config['tomo']['direction'] = -1 if fg.config['tomo']['posSTART'] >= fg.config['tomo']['posEND'] else 1
    if  fg.config['tomo']['posSTART'] ==  fg.config['tomo']['posEND']:
        logger.warning("Start and END-Pos are the same hence the system will take {} images at the same position.".format(nbr_steps))

    # iterate through tomography stack
    for imnbr in range(fg.config['tomo']['steps']+1):