2022-09-03 14:07:44 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
2022-09-03 18:59:14 +00:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Test DAQ input on a device"
|
|
|
|
]
|
|
|
|
},
|
2022-09-03 14:07:44 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-09-03 18:59:14 +00:00
|
|
|
"# !make -j -C ~/wip/mycode/lasp"
|
2022-09-03 14:07:44 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import lasp\n",
|
2022-09-03 18:59:14 +00:00
|
|
|
"# Get handle to stream manager\n",
|
|
|
|
"mgr = lasp.StreamMgr.getInstance()"
|
2022-09-03 14:07:44 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-09-03 18:59:14 +00:00
|
|
|
"ds = mgr.getDeviceInfo()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"# Search for a device\n",
|
2022-09-03 14:07:44 +00:00
|
|
|
"for i, d in enumerate(ds):\n",
|
|
|
|
" print(f'{i}: ' + d.device_name)\n",
|
|
|
|
"d = ds[1]"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-09-03 18:59:14 +00:00
|
|
|
"# Check the available block sizes\n",
|
2022-09-03 14:07:44 +00:00
|
|
|
"d.availableFramesPerBlock"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-09-03 18:59:14 +00:00
|
|
|
"# Create a configuration and enable some input channels\n",
|
2022-09-03 14:07:44 +00:00
|
|
|
"config = lasp.DaqConfiguration(d)\n",
|
|
|
|
"config.inchannel_config[0].enabled = True\n",
|
|
|
|
"config.inchannel_config[1].enabled = True\n",
|
2022-09-03 18:59:14 +00:00
|
|
|
"# Choose a different number of frames per block\n",
|
2022-09-03 14:07:44 +00:00
|
|
|
"config.framesPerBlockIndex = 4"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"print('Out channels:',d.noutchannels)\n",
|
|
|
|
"print('In channels:',d.ninchannels)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-09-03 18:59:14 +00:00
|
|
|
"# Start a stream with a configuration\n",
|
|
|
|
"mgr.startStream(config)"
|
2022-09-03 14:07:44 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"mgr.stopStream(lasp.StreamMgr.StreamType.input)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"mgr.stopAllStreams()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"def cb(data):\n",
|
|
|
|
" # raise RuntimeError('hh')\n",
|
|
|
|
" print(data.shape)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"i = lasp.InDataHandler(mgr, cb)\n",
|
|
|
|
"import time\n",
|
|
|
|
"#time.sleep(4)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {
|
|
|
|
"scrolled": true
|
|
|
|
},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"del i"
|
|
|
|
]
|
2022-09-03 18:59:14 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
2022-09-03 14:07:44 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3 (ipykernel)",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
2022-09-03 18:59:14 +00:00
|
|
|
"version": "3.8.10"
|
2022-09-03 14:07:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 5
|
|
|
|
}
|