Commit 229a0360 authored by thaag's avatar thaag
Browse files

Tested version, running on the Acquisition machine

- changed path in config file
- logging cleanup
- the data is now transposed earlier .T
parent 865edf70
......@@ -52,8 +52,8 @@ Acquisition:
timeout : 8000 # ms, when during this time not transfer_size data is available -> timeout
use_16_bit_mode : False # store Data as 16 or 32 bit in the ASDF file
asdf_settings:
data_folder : 'c:/20181107_sw_test/'
data_folder_tmp : 'c:/20181107_sw_test/tmp/'
data_folder : 'e:/20181122_sw_test/'
data_folder_tmp : 'e:/20181122_sw_test/tmp/'
compression : 'gzip-3' # default: 'gzip-3', 'gzip-0' to 'gzip-9' or None
file_length_sec : 30.0 # in seconds
channel_naming : [0,2,4,6,8,10,12,14,1,3,5,7,9,11,13,15,16,18,20,22,24,26,28,30,17,19,21,23,25,27,29,31]
......
......@@ -16,6 +16,7 @@ import dug_seis.acquisition.card_manager as card_manager
def acquisition_(param):
logging.info('Acquisition script started')
logging.info('==========================')
_check_if_hardware_needs_to_be_simulated(param)
_write_used_param_to_log_recursive(param, 'Acquisition')
......
......@@ -38,11 +38,11 @@ class SimulatedHardware:
def _simulated_read_data(self):
x = cast(addressof(self._pv_buffer)+self._l_pc_pos, POINTER(c_int16)) # cast to pointer to 16bit integer
np_data = np.ctypeslib.as_array(x, shape=(self._nr_of_datapoints, 16))
np_data = np.ctypeslib.as_array(x, shape=(self._nr_of_datapoints, 16)).T
if self._use_16_bit_mode:
np_data = np_data.T
pass
else:
np_data = np.require(np_data.T, dtype=np.int32, requirements=["C"]) # convert to 32 bit, transpose
np_data = np.require(np_data, dtype=np.int32, requirements=["C"]) # convert to 32 bit, transpose
return np_data
def _simulated_data_has_been_read(self):
......
......@@ -13,6 +13,12 @@ import dug_seis.acquisition.hardware_driver.spcerr as err
from math import floor
from ctypes import byref, c_int32, POINTER, c_int16, cast, addressof
try:
from dug_seis.acquisition.one_card_std_init import init_card as sdt_init_card
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwSetParam_i32, spcm_dwGetParam_i32, spcm_vClose
except OSError:
logging.warning('one_card.py: problems loading the hardware driver. simulation still available.')
class Card:
......@@ -31,9 +37,6 @@ class Card:
self._nr_of_datapoints = floor(param['Acquisition']['bytes_per_transfer'] / 16 / 2)
def init_card(self, param):
from dug_seis.acquisition.one_card_std_init import init_card as sdt_init_card
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwSetParam_i32, spcm_dwGetParam_i32, spcm_vClose
"""Initialise card. Setup card parameters. Reserve buffers for DMA data transfer."""
logging.info("init card: {}".format(self.card_nr))
if self.card_nr == 0 or self.card_nr == 1:
......@@ -76,22 +79,22 @@ class Card:
def read_data(self):
# cast to pointer to 16bit integer
x = cast(addressof(self._pv_buffer) + self.read_buffer_position(), POINTER(c_int16))
np_data = np.ctypeslib.as_array(x, shape=(self._nr_of_datapoints, 16))
np_data = np.ctypeslib.as_array(x, shape=(self._nr_of_datapoints, 16)).T
if self._use_16_bit_mode:
np_data = np_data.T
pass
else:
np_data = np.require(np_data.T, dtype=np.int32, requirements=["C"]) # convert to 32 bit, transpose
np_data = np.require(np_data, dtype=np.int32, requirements=["C"]) # convert to 32 bit, transpose
return np_data
def data_has_been_read(self):
"""Mark buffer space as available again."""
if self.debug_buffer_behaviour is True:
print("mark buffer as available: {0:08x}\n".format(self.l_notify_size.value))
print("mark buffer as available: {0:08x}".format(self.l_notify_size.value))
spcm_dwSetParam_i32(self.h_card, regs.SPC_DATA_AVAIL_CARD_LEN, self.l_notify_size)
def stop_recording(self):
"""Send the stop command to the card."""
logging.info("card {0} stopped.\n".format(self.card_nr))
logging.info("card {0} stopped.".format(self.card_nr))
spcm_dwSetParam_i32(self.h_card, regs.SPC_M2CMD, regs.M2CMD_CARD_STOP | regs.M2CMD_DATA_STOPDMA)
def close(self):
......
......@@ -37,7 +37,7 @@ def sz_type_to_name(l_card_type):
def init_card(param, card_nr):
"""Initialise card. Setup card parameters. Reserve buffers for DMA data transfer."""
logging.debug("Initializing card {} sdt_init...\n".format(card_nr))
logging.debug("Initializing card {} sdt_init...".format(card_nr))
sampling_frequency = param['Acquisition']['hardware_settings']['sampling_frequency']
qw_buffer_size = c_uint64(param['Acquisition']['hardware_settings']['ram_buffer_size'])
......@@ -50,7 +50,7 @@ def init_card(param, card_nr):
else:
h_card = spcm_hOpen(create_string_buffer(b'/dev/spcm1'))
if h_card is None:
logging.error("card {} not found...\n".format(card_nr))
logging.error("card {} not found...".format(card_nr))
return -1
# exit ()
......@@ -64,9 +64,9 @@ def init_card(param, card_nr):
s_card_name = sz_type_to_name(l_card_type.value)
if l_fnc_type.value == regs.SPCM_TYPE_AI:
logging.info("Found: {0} sn {1:05d}\n".format(s_card_name, l_serial_number.value))
logging.info("Found: {0} sn {1:05d}".format(s_card_name, l_serial_number.value))
else:
logging.error("Card: {0} sn {1:05d} not supported by example\n".format(s_card_name, l_serial_number.value))
logging.error("Card: {0} sn {1:05d} not supported by example".format(s_card_name, l_serial_number.value))
return -1
""" do a simple FIFO setup """
......@@ -92,7 +92,7 @@ def init_card(param, card_nr):
# set sample rate
spcm_dwSetParam_i32(h_card, regs.SPC_SAMPLERATE, sampling_frequency)
logging.info("using: {0} sps\n".format(sampling_frequency))
logging.info("using: {0} sps".format(sampling_frequency))
# no clock output
spcm_dwSetParam_i32(h_card, regs.SPC_CLOCKOUT, 0)
......@@ -103,13 +103,13 @@ def init_card(param, card_nr):
qw_cont_buf_len = c_uint64(0)
spcm_dwGetContBuf_i64(h_card, SPCM_BUF_DATA, byref(pv_buffer),
byref(qw_cont_buf_len))
logging.debug("ContBuf length: {0:d}\n".format(qw_cont_buf_len.value))
logging.debug("ContBuf length: {0:d}".format(qw_cont_buf_len.value))
if qw_cont_buf_len.value >= qw_buffer_size.value:
logging.info("Using continuous buffer\n")
logging.info("Using continuous buffer")
else:
pv_buffer = create_string_buffer(qw_buffer_size.value)
logging.info("Using buffer allocated by user program\n")
logging.info("Using buffer allocated by user program")
spcm_dwDefTransfer_i64(h_card, SPCM_BUF_DATA, SPCM_DIR_CARDTOPC, l_notify_size.value, pv_buffer, c_uint64(0),
qw_buffer_size)
......
......@@ -15,6 +15,12 @@ from ctypes import create_string_buffer, byref
from ctypes import c_int32
try:
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_hOpen, spcm_dwSetParam_i32, spcm_dwGetParam_i32
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwGetErrorInfo_i32, spcm_vClose
except OSError:
logging.warning('star_hub.py: problems loading the hardware driver. simulation still available.')
class StarHub:
def __init__(self):
......@@ -22,8 +28,6 @@ class StarHub:
self.h_sync = None
def init_star_hub(self, card_list):
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_hOpen, spcm_dwSetParam_i32, spcm_dwGetParam_i32
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwGetErrorInfo_i32, spcm_vClose
"""Initialise the star hub."""
logging.info("init star hub")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment