mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
merging refactor (replacing)
This commit is contained in:
17
python/simple-integration-tests/jungfrau_0_6/config_test.py
Executable file
17
python/simple-integration-tests/jungfrau_0_6/config_test.py
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Tue Nov 14 16:49:07 2017
|
||||
|
||||
@author: l_frojdh
|
||||
"""
|
||||
|
||||
fw_version = 0x180220
|
||||
detector_type = 'Jungfrau'
|
||||
known_hostnames = ['bchip038']
|
||||
image_size = (512,1024) #rows, cols
|
||||
module_geometry = (1,1) #horizontal, vertical
|
||||
|
||||
#Remember to change these in the settings file as well!
|
||||
settings_path = '/home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau'
|
||||
file_path = '/home/l_lopez/out'
|
23
python/simple-integration-tests/jungfrau_0_6/fixtures.py
Executable file
23
python/simple-integration-tests/jungfrau_0_6/fixtures.py
Executable file
@ -0,0 +1,23 @@
|
||||
import pytest
|
||||
|
||||
from sls_detector import Detector
|
||||
|
||||
@pytest.fixture
|
||||
def detector():
|
||||
from sls_detector import Detector
|
||||
return Detector()
|
||||
|
||||
@pytest.fixture
|
||||
def eiger():
|
||||
from sls_detector import Eiger
|
||||
return Eiger()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jungfrau():
|
||||
from sls_detector import Jungfrau
|
||||
return Jungfrau()
|
||||
|
||||
detector_type = Detector().detector_type
|
||||
eigertest = pytest.mark.skipif(detector_type != 'Eiger', reason = 'Only valid for Eiger')
|
||||
jungfrautest = pytest.mark.skipif(detector_type != 'Jungfrau', reason = 'Only valid for Jungfrau')
|
17
python/simple-integration-tests/jungfrau_0_6/test_main.py
Executable file
17
python/simple-integration-tests/jungfrau_0_6/test_main.py
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
General tests for the Jungfrau detector.
|
||||
|
||||
NOTE! Uses hostnames from config_test
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import config_test
|
||||
import tests
|
||||
|
||||
import os
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
pytest.main(['-x', '-s', os.path.join(dir_path, 'tests/test_load_config.py')]) #Test 1
|
||||
pytest.main(['-x', '-s', os.path.join(dir_path, 'tests/test_overtemperature.py')]) #Test 2
|
21
python/simple-integration-tests/jungfrau_0_6/tests/test.config
Executable file
21
python/simple-integration-tests/jungfrau_0_6/tests/test.config
Executable file
@ -0,0 +1,21 @@
|
||||
detsizechan 1024 512
|
||||
|
||||
settingsdir /home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau
|
||||
caldir /home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau
|
||||
lock 0
|
||||
|
||||
hostname bchip094+
|
||||
|
||||
rx_udpport 1754
|
||||
rx_udpip 10.1.1.107
|
||||
rx_udpmac 90:E2:BA:9A:4F:D4
|
||||
detectorip 10.1.1.9
|
||||
detectormac 00:aa:bb:cc:dd:ee
|
||||
configuremac 0
|
||||
|
||||
powerchip 1
|
||||
timing auto
|
||||
|
||||
outdir /home/l_lopez/out
|
||||
threaded 1
|
||||
high
|
1
python/simple-integration-tests/jungfrau_0_6/tests/test.par
Executable file
1
python/simple-integration-tests/jungfrau_0_6/tests/test.par
Executable file
@ -0,0 +1 @@
|
||||
vhighvoltage 200
|
43
python/simple-integration-tests/jungfrau_0_6/tests/test_load_config.py
Executable file
43
python/simple-integration-tests/jungfrau_0_6/tests/test_load_config.py
Executable file
@ -0,0 +1,43 @@
|
||||
|
||||
import pytest
|
||||
import config_test
|
||||
import os
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
from fixtures import jungfrau, jungfrautest
|
||||
|
||||
|
||||
def load_config_file_jungfrau_test(jungfrau):
|
||||
"""Load a settings file and assert all settings"""
|
||||
|
||||
print('\tStarting load_config_file_jungfrau_test test case')
|
||||
|
||||
jungfrau.free_shared_memory
|
||||
jungfrau.load_config(os.path.join(dir_path, 'test.config'))
|
||||
|
||||
assert jungfrau.lock == False
|
||||
assert jungfrau.rx_udpport == ['1754']
|
||||
assert jungfrau.hostname == ['bchip094']
|
||||
assert jungfrau.firmware_version == config_test.fw_version
|
||||
|
||||
print('\tFinished load_config_file_jungfrau_test test case')
|
||||
|
||||
def load_parameters_file_jungfrau_test(jungfrau):
|
||||
"""Load a parametes file and assert the settings in the file"""
|
||||
|
||||
print('\tStarting load_parameters_file_jungfrau_test test case')
|
||||
|
||||
jungfrau.load_parameters(os.path.join(dir_path, 'test.par'))
|
||||
assert jungfrau.high_voltage == 200
|
||||
|
||||
print('\tFinished load_parameters_file_jungfrau_test test case')
|
||||
|
||||
@jungfrautest
|
||||
def test_main(jungfrau):
|
||||
print('\nTesting configuration file loading')
|
||||
|
||||
load_config_file_jungfrau_test(jungfrau)
|
||||
load_parameters_file_jungfrau_test(jungfrau)
|
||||
|
||||
print('Tested configuration file loading')
|
||||
|
68
python/simple-integration-tests/jungfrau_0_6/tests/test_overtemperature.py
Executable file
68
python/simple-integration-tests/jungfrau_0_6/tests/test_overtemperature.py
Executable file
@ -0,0 +1,68 @@
|
||||
|
||||
import pytest
|
||||
import config_test
|
||||
import time
|
||||
from fixtures import jungfrau, jungfrautest
|
||||
|
||||
def powerchip_test(jungfrau, control):
|
||||
"""
|
||||
|
||||
Test the main overtemperature protection control
|
||||
|
||||
"""
|
||||
#Set test initial conditions
|
||||
print('\tStarting powerchip_test test case')
|
||||
|
||||
jungfrau.power_chip = False
|
||||
jungfrau.temperature_control = control
|
||||
assert jungfrau.power_chip == False
|
||||
jungfrau.temperature_threshold = 35
|
||||
jungfrau.power_chip = True
|
||||
|
||||
|
||||
if jungfrau.temperature_control is True:
|
||||
if jungfrau.temperature_event is True:
|
||||
assert jungfrau.power_chip == False
|
||||
jungfrau.power_chip = True
|
||||
assert jungfrau.power_chip == False
|
||||
jungfrau.temperature_control = False
|
||||
assert jungfrau.power_chip == True
|
||||
jungfrau.temperature_control = True
|
||||
jungfrau.temperature_threshold = 50
|
||||
assert jungfrau.power_chip == False
|
||||
|
||||
print('\t\tWaiting to cool down the board. This may take a while...')
|
||||
while jungfrau.temperature_threshold < jungfrau.temp.fpga[0]:
|
||||
time.sleep(5)
|
||||
print('\t\tJungfrau MCB temperature: {0:.2f} °C'.format(jungfrau.temp.fpga[0]))
|
||||
|
||||
#Leave enough time to let the board cool down a bit more
|
||||
time.sleep(30)
|
||||
jungfrau.reset_temperature_event()
|
||||
|
||||
assert jungfrau.temperature_event == False
|
||||
assert jungfrau.power_chip == True
|
||||
|
||||
else:
|
||||
assert jungfrau.power_chip == True
|
||||
else:
|
||||
print('\t\tWaiting to warm up the board. This may take a while...')
|
||||
while jungfrau.temperature_threshold > jungfrau.temp.fpga[0]:
|
||||
time.sleep(5)
|
||||
print('\t\tJungfrau MCB temperature: {0:.2f} °C'.format(jungfrau.temp.fpga[0]))
|
||||
|
||||
assert jungfrau.temperature_event == False
|
||||
assert jungfrau.power_chip == True
|
||||
|
||||
print('\tFinished powerchip_test test case')
|
||||
|
||||
|
||||
#@jungfrautest
|
||||
def test_main(jungfrau):
|
||||
|
||||
print('\nTesting overtemperature protection control')
|
||||
|
||||
powerchip_test(jungfrau, False)
|
||||
powerchip_test(jungfrau, True)
|
||||
|
||||
print('Tested overtemperature protection control')
|
Reference in New Issue
Block a user