Beispiel #1
0
import logging
import unittest
import time
from copy import copy

import epics

from ophyd import EpicsMCA, EpicsDXP
from ophyd.mca import add_rois
from ophyd.utils import enum, ReadOnlyError
from .test_signal import FakeEpicsPV
from . import main

MCAMode = enum(PHA='PHA', MCS='MCS', List='List')
DxpPresetMode = enum(No_preset='No preset',
                     Real_time='Real time',
                     Live_time='Live time')

logger = logging.getLogger(__name__)

REAL_SCALER = False
devs = ['XF:23ID2-ES{Vortex}mca1', 'XF:23ID2-ES{Vortex}dxp1:']


def setUpModule():
    if not REAL_SCALER:
        epics._PV = epics.PV
        epics.PV = FakeEpicsPV


def tearDownModule():
Beispiel #2
0

import logging
import unittest
import time
from copy import copy

import epics

from ophyd import EpicsMCA, EpicsDXP
from ophyd.mca import add_rois
from ophyd.utils import enum, ReadOnlyError
from .test_signal import FakeEpicsPV
from . import main

MCAMode = enum(PHA='PHA', MCS='MCS', List='List')
DxpPresetMode = enum(No_preset='No preset',
                     Real_time='Real time',
                     Live_time='Live time')

logger = logging.getLogger(__name__)


REAL_SCALER = False
devs = ['XF:23ID2-ES{Vortex}mca1', 'XF:23ID2-ES{Vortex}dxp1:']


def setUpModule():
    if not REAL_SCALER:
        epics._PV = epics.PV
        epics.PV = FakeEpicsPV
Beispiel #3
0
import logging
import pytest
import time

from copy import copy
from types import SimpleNamespace

from ophyd.scaler import EpicsScaler, ScalerCH
from ophyd.utils import enum
from .test_utils import assert_OD_equal_ignore_ts

from caproto.tests.conftest import run_example_ioc

ScalerMode = enum(ONE_SHOT=0, AUTO_COUNT=1)

logger = logging.getLogger(__name__)


@pytest.fixture(scope='function')
def scaler_test_ioc(prefix, request):
    name = 'test_signal IOC'
    pvs = dict(scaler_prefix=f'{prefix}')

    process = run_example_ioc('ophyd.tests.scaler_ioc',
                              request=request,
                              pv_to_check=pvs['scaler_prefix'] + '.CNT',
                              args=('--prefix', prefix, '-v'))
    return SimpleNamespace(process=process,
                           prefix=prefix,
                           name=name,
                           pvs=pvs,
Beispiel #4
0
import time

import config
from ophyd.controls import scaler
from ophyd.utils import enum

ScalerMode = enum(ONE_SHOT=0, AUTO_COUNT=1)

def test():
    loggers = ('ophyd.controls.signal',
               'ophyd.controls.scaler',
               'ophyd.session',
               )

    config.setup_loggers(loggers)
    logger = config.logger


    sca = scaler.EpicsScaler(config.scalers[0])

    sca.preset_time = 5.2

    logger.info('Counting in One-Shot mode for %f s...' % sca.preset_time)
    sca.start()
    logger.info('Sleeping...')
    time.sleep(3)
    logger.info('Done sleeping. Stopping counter...')
    sca.stop()

    logger.info('Set mode to AutoCount')
    sca.count_mode = ScalerMode.AUTO_COUNT