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)
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) mps.set_scan_units('PA') output_file = 'run_' + now.strftime('%Y-%m-%d_%H_%M_%S') + '.csv' mps.scan_to_csv(output_file) mps.disconnect() print('Data written to ' + output_file) input()