123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- """
- Actions performed on the board.
- Fore some more actions also see sequences.py
- """
- import time
- from communication import *
- from utils import wait_for_revolutions
- def acquire_data(board_id, filename, simulate=False):
- """
- Acquire data. This sets registers and reads data to a file
- :param board_id: the id of the board to acquire with
- :param filename: the file to write to
- :param simulate: whether to use the pilotbunch simulator or not
- """
- if simulate:
- start_pilot_bunch_emulator(board_id)
- start_acquisition(board_id)
- wait_for_revolutions(board_id)
- stop_acquisition(board_id)
- enable_transfer(board_id)
- pci.read(board_id, dma='dma0', destination=filename)
- flush_dma(board_id)
- def data_reset(board_id):
- """
- Reset data
- :param board_id: the board to reset
- :return:
- """
- log.vinfo('Data reset')
- pci.write(board_id, '000003f5', hex_mask='7')
- time.sleep(0.05)
- pci.write(board_id, '000003f0', hex_mask='7')
- time.sleep(0.05)
- def flush_dma(board_id, dma='dma0'):
- """
- Flush dma. This basically reads data to /dev/null
- :param board_id: the id to flush dma
- :param dma: the dma to flush
- """
- log.vinfo('Flushing DMA Pipeline')
- pci.write(board_id, '03f0', hex_mask='CF0')
- pci.read(board_id, dma=dma, destination='/dev/null')
- def stop_board(board_id):
- """
- Stop a board (turn it off)
- :param board_id: the board to work with
- """
- pci.write(board_id, '0x01', '0x9040')
- pci.stop_dma(board_id)
- def soft_reset(board_id):
- """
- Perform a soft reset on the board.
- :param board_id: the board to reset
- :return:
- """
- pci.write(board_id, '0x1', '0x9040', hex_mask='0x1')
- time.sleep(1)
- pci.write(board_id, '0x0', '0x9040', hex_mask='0x1')
- def start_pilot_bunch_emulator(board_id):
- """
- Start the pilot bunch emulator
- :param board_id: the board to start it for
- """
- log.vinfo('Start pilot bunch emulator')
- pci.write(board_id, '400003f0', hex_mask='400003F0')
- time.sleep(0.005)
- pci.write(board_id, '03f0', hex_mask='CF0')
- def start_acquisition(board_id):
- """
- Start an acquisition. This will only tell the board to acquire. It will not read data
- :param board_id: the id to acquire with
- """
- log.vinfo('Start acquisition')
- pci.write(board_id, '1', '4', hex_mask='1') # what's this? write value 1 to register 4???
- time.sleep(0.005)
- pci.write(board_id, '00bf0', hex_mask='CF0')
- def stop_acquisition(board_id):
- """
- Stop an acquisition. This will only stop the acquisition on the board.
- :param board_id: the board to stop for
- """
- log.vinfo('Stop acquisition')
- pci.write(board_id, '003f0', hex_mask='CF0')
- time.sleep(0.005)
- def enable_transfer(board_id):
- """
- Enable data transfer. This will not transfer data.
- :param board_id: the id of the board to transfer data from
- :return:
- """
- log.vinfo('Enable data transfer')
- pci.write(board_id, '007f0', hex_mask='CF0')
- time.sleep(0.005)
|