def test_setter_called_with_value(mocker):
    m = mocker.Mock()
    value = 22
    a = EigerValueContainer(name="test",
                            access_mode="rw",
                            value=True,
                            setter=m)
    a.put({"value": value})
    m.assert_called_once_with(value)
Ejemplo n.º 2
0
def add_eiger_monitor():
    module = EigerModule("monitor")
    module.add_child(
        EigerValueContainer(name="version", access_mode="r", value="1.6.0")
    )
    module.add_child(EigerValueContainer(name="images", access_mode="r", value=[]))
    module.add_child(add_command())
    module.add_child(add_config())
    module.add_child(add_status())
    return module
Ejemplo n.º 3
0
def add_status(state_machine):
    status = EigerTask("status")
    state = EigerValueContainer(name="state",
                                access_mode="rw",
                                value=state_machine.get_state)
    state.add_child(
        EigerValue(name="critical_values",
                   access_mode="r",
                   value=["na", "error"]))
    status.add_child(state)
    return status
Ejemplo n.º 4
0
def add_status():
    command = EigerTask("status")
    command.add_child(
        EigerValueContainer(name="state", access_mode="rw", value="na"))
    command.add_child(
        EigerValueContainer(name="error", access_mode="rw", value="na"))
    command.add_child(
        EigerValueContainer(name="time", access_mode="rw", value="na"))
    command.add_child(
        EigerValueContainer(name="buffer_free", access_mode="rw", value="na"))
    return command
Ejemplo n.º 5
0
def add_eiger_filewriter():
    module = EigerModule("filewriter")
    module.add_child(
        EigerValueContainer(name="version", access_mode="r", value="1.6.0"))
    module.add_child(
        EigerValueContainer(name="files",
                            access_mode="r",
                            value=["test_1_master.h5", "test_1_00001.h5"]))
    module.add_child(add_command())
    module.add_child(add_config())
    module.add_child(add_status())
    return module
def test_value_unit():
    unit = "s"
    a = EigerValueContainer(name="test",
                            access_mode="w",
                            value="test_123",
                            unit=unit)
    assert a.unit.get() == "s"
def test_value_type():
    value_type = "bool"
    a = EigerValueContainer(name="test",
                            access_mode="rw",
                            value=True,
                            value_type=value_type)
    assert a.value_type.get() == value_type
def test_allowed_values():
    allowed_values = ["aaa", "bbb", "ccc"]
    a = EigerValueContainer(name="test",
                            access_mode="rw",
                            value="test_123",
                            allowed_values=allowed_values)
    assert a.allowed_values.get() == allowed_values
Ejemplo n.º 9
0
def add_eiger_detector(state_machine):
    module = EigerModule("detector")
    module.add_child(
        EigerValueContainer(name="version", access_mode="r", value="1.6.0"))
    module.add_child(add_command(state_machine))
    module.add_child(add_config(state_machine))
    module.add_child(add_status(state_machine))
    return module
def test_value_function():
    value = "abc"

    def func():
        return value

    a = EigerValueContainer(name="test", access_mode="r", value=func)
    assert a.value.get() == value
Ejemplo n.º 11
0
def add_eiger_stream():
    module = EigerModule("stream")
    module.add_child(
        EigerValueContainer(name="version", access_mode="r", value="1.6.0")
    )
    module.add_child(add_command())
    module.add_child(add_config())
    module.add_child(add_status())
    return module
Ejemplo n.º 12
0
def add_config():
    config = EigerTask("config")
    config.add_child(
        EigerValueContainer(name="name_pattern",
                            access_mode="rw",
                            value="series_$id"))
    config.add_child(
        EigerValueContainer(name="compression_enabled",
                            access_mode="rw",
                            value=True))
    config.add_child(
        EigerValueContainer(name="nimages_per_file",
                            access_mode="rw",
                            value=1000))
    config.add_child(
        EigerValueContainer(
            name="mode",
            access_mode="rw",
            value="enabled",
            allowed_values=["enabled", "disabled"],
        ))
    return config
def test_get_value():
    value = "test_123"
    a = EigerValueContainer(name="test", access_mode="rw", value=value)
    assert a.value.get() == value
def test_get_raises_no_access():
    a = EigerValueContainer(name="test", access_mode="w", value="test_123")
    with pytest.raises(AccessNotPermittedException):
        a.value.get()
Ejemplo n.º 15
0
def add_config():
    config = EigerTask("config")
    initialize = EigerValueContainer(name="buffer_size", access_mode="rw", value=100)
    config.add_child(initialize)
    return config
Ejemplo n.º 16
0
def add_status():
    command = EigerTask("status")
    state = EigerValueContainer(name="state", access_mode="rw", value="na")
    command.add_child(state)
    return command
Ejemplo n.º 17
0
def add_config(state_machine):
    config = EigerTask("config")
    config.add_child(
        EigerValueContainer(
            name="countrate_correction_applied",
            access_mode="rw",
            value=True,
            value_type="bool",
        ))
    config.add_child(
        EigerValueContainer(
            name="flatfield_correction_applied",
            access_mode="rw",
            value=True,
            value_type="bool",
        ))
    config.add_child(
        EigerValueContainer(
            name="pixel_mask_applied",
            access_mode="rw",
            value=True,
            value_type="bool",
        ))
    config.add_child(
        EigerValueContainer(
            name="detector_number",
            access_mode="r",
            value="E-02-0100",
            value_type="string",
        ))
    config.add_child(
        EigerValueContainer(name="count_time",
                            access_mode="rw",
                            value=1.0,
                            unit="s",
                            value_type="float"))
    config.add_child(
        EigerValueContainer(name="frame_time",
                            access_mode="rw",
                            value=1.0,
                            unit="s",
                            value_type="float"))
    config.add_child(
        EigerValueContainer(name="nimages",
                            access_mode="rw",
                            value=1,
                            value_type="int"))
    config.add_child(
        EigerValueContainer(name="ntrigger",
                            access_mode="rw",
                            value=1,
                            value_type="int"))
    config.add_child(
        EigerValueContainer(
            name="trigger_mode",
            access_mode="rw",
            value="ints",
            allowed_values=["ints", "exts"],
            value_type="string",
        ))
    config.add_child(
        EigerValueContainer(
            name="auto_summation",
            access_mode="rw",
            value=False,
            value_type="bool",
        ))
    config.add_child(
        EigerValueContainer(
            name="element",
            access_mode="rw",
            value=state_machine.get_element,
            allowed_values=[el for el in state_machine.ELEMENTS],
            value_type="string",
            setter=state_machine.set_element,
        ))
    config.add_child(
        EigerValueContainer(
            name="photon_energy",
            access_mode="rw",
            value=state_machine.get_photon_energy,
            unit="eV",
            value_type="float",
            setter=state_machine.set_photon_energy,
        ))
    config.add_child(
        EigerValueContainer(
            name="threshold_energy",
            access_mode="rw",
            value=state_machine.get_threshold_energy,
            unit="eV",
            value_type="float",
            setter=state_machine.set_threshold_energy,
        ))
    config.add_child(
        EigerValueContainer(name="sensor_material",
                            access_mode="rw",
                            value="Si",
                            value_type="string"))
    config.add_child(
        EigerValueContainer(
            name="sensor_thickness",
            access_mode="r",
            value="0.000320",
            unit="m",
            value_type="float",
        ))
    return config
def test_value_has_access_mode(mode):
    a = EigerValueContainer(name="test", access_mode=mode, value="test_123")
    assert a.access_mode.get() == mode
def test_set_value():
    new_value = "test_xxx"
    a = EigerValueContainer(name="test", access_mode="rw", value="test_123")
    a.put({"value": new_value})
    assert a.value.get() == new_value
def test_task_keys():
    parameters = ["aaa", "bbb", "ccc"]
    a = EigerTask("test_abc")
    for parameter in parameters:
        a.add_child(EigerValueContainer(name=parameter, access_mode="rw"))
    assert not set(a.keys.get()) ^ set(parameters + ["keys"])