def test_mps_scan():
    time.sleep(0.2) # sleep to make sure the socket is closed from previous test
    mps = MPS(HOST)
    mps.set_frames_per_scan(1)
    data = mps.scan()
    assert type(data) is list
    assert len(data) == 2
def test_mps_scan_to_csv():
    time.sleep(0.2) # sleep to make sure the socket is closed from previous test
    mps = MPS(HOST)
    mps.set_frames_per_scan(1)
    test_file = 'test_scan.csv'
    mps.scan_to_csv(test_file)
    assert os.path.exists(test_file)
    os.remove(test_file)
print('Welcome to MPS4264')
print()
print('Run name: ' + RUN_NAME)
print('Frames to take: ' + str(FRAMES_PER_SCAN))
print('Frame rate: ' + str(RATE) + ' Hz')
print()

# you shouldn't need to edit below this line

from scanivalve_mps.mps import MPS
from datetime import datetime

MPS_HOST = "191.30.90.1"

mps = MPS(MPS_HOST)

if not mps.status() == 'ready':
    raise RuntimeError('MPS is not ready; try again later.')

print('Starting zero calibration. This will take 15 seconds or so...')
mps.calibrate_zero()
print('Calibration done.')

now = datetime.now()
print('Setting time to ', now)
res = mps.set_time(now)

mps.set_format('csv')
mps.set_frames_per_scan(FRAMES_PER_SCAN)
mps.set_rate(RATE)
def test_mps_calibrate_zero():
    time.sleep(0.2)
    mps = MPS(HOST)
    mps.calibrate_zero()
    assert True
    mps.disconnect()
def test_mps_version():
    time.sleep(0.2)
    mps = MPS(HOST)
    version = mps.version()
    assert 'MPS Scanivalve' in version
    mps.disconnect()
def test_mps_status():
    time.sleep(0.2) # sleep to make sure the socket is closed from previous test
    mps = MPS(HOST)
    status = mps.status()
    assert type(status) is str
    mps.disconnect()
def test_mps_set_time():
    time.sleep(0.2) # sleep to make sure the socket is closed from previous test
    mps = MPS(HOST)
    t = datetime.now()
    mps_time = mps.set_time(t)
    assert type(mps_time) is datetime
def test_mps_get_scan_start_time():
    time.sleep(0.2) # sleep to make sure the socket is closed from previous test
    mps = MPS(HOST)
    mps_time = mps.get_scan_start_time()
    assert type(mps_time) is datetime
def test_mps_bootloader_version():
    time.sleep(0.2) # sleep to make sure the socket is closed from previous test
    mps = MPS(HOST)
    assert 'BOOTLOADER VERSION' in mps.bootloader_version()
    mps.disconnect()
def test_mps_init():
    mps = MPS(HOST)
    assert type(mps) is MPS
    mps.disconnect()
from scanivalve_mps.mps import MPS
from datetime import datetime
import os

host = os.environ['MPS_HOST']

mps = MPS(host)

if not mps.status() == 'ready':
    raise RuntimeError('MPS is not ready; try again later.')

now = datetime.now()
print('Setting time to ', now)
res = mps.set_time(now)

print('Starting zero calibration. This will take 15 seconds or so...')
mps.calibrate_zero()
print('Calibration done.')

mps.set_format('csv')
mps.set_frames_per_scan(100)
mps.set_rate(10)
mps.set_scan_units('PA')
mps.stream()
mps.disconnect()