2022-09-03 14:07:44 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
2022-09-03 18:59:14 +00:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "740b4091",
|
2022-09-03 18:59:14 +00:00
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Test DAQ input on a device"
|
|
|
|
]
|
|
|
|
},
|
2022-09-03 14:07:44 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-10-10 17:29:24 +00:00
|
|
|
"execution_count": null,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "ac06df04",
|
2022-09-03 14:07:44 +00:00
|
|
|
"metadata": {},
|
2022-10-10 17:29:24 +00:00
|
|
|
"outputs": [],
|
2022-09-03 14:07:44 +00:00
|
|
|
"source": [
|
2022-10-10 17:29:24 +00:00
|
|
|
"!make -j -C ~/wip/mycode/lasp"
|
2022-09-03 14:07:44 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "ce0dd691",
|
2022-09-03 14:07:44 +00:00
|
|
|
"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
|
|
|
]
|
|
|
|
},
|
2022-10-10 17:29:24 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "9ad46772-a969-4693-b4e6-d78a67183787",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"mgr.rescanDAQDevices()"
|
|
|
|
]
|
|
|
|
},
|
2022-09-03 14:07:44 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "3cd242a8",
|
2022-09-03 14:07:44 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-09-03 18:59:14 +00:00
|
|
|
"ds = mgr.getDeviceInfo()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "a5d878e9",
|
2022-09-03 18:59:14 +00:00
|
|
|
"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",
|
2022-09-28 07:41:02 +00:00
|
|
|
"d = ds[0]"
|
2022-09-03 14:07:44 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "a456054e",
|
2022-09-03 14:07:44 +00:00
|
|
|
"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,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "6d5b281e",
|
2022-09-03 14:07:44 +00:00
|
|
|
"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,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "1ead3995",
|
2022-09-03 14:07:44 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"print('Out channels:',d.noutchannels)\n",
|
|
|
|
"print('In channels:',d.ninchannels)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "12db8306",
|
|
|
|
"metadata": {
|
|
|
|
"tags": []
|
|
|
|
},
|
2022-09-03 14:07:44 +00:00
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-09-03 18:59:14 +00:00
|
|
|
"# Start a stream with a configuration\n",
|
2022-09-28 07:41:02 +00:00
|
|
|
"mgr.startStream(config)\n",
|
|
|
|
"\n",
|
2022-10-10 17:29:24 +00:00
|
|
|
"def reset_cb():\n",
|
|
|
|
" print('Reset called')\n",
|
|
|
|
"\n",
|
2022-09-03 14:07:44 +00:00
|
|
|
"def cb(data):\n",
|
2022-10-10 17:29:24 +00:00
|
|
|
" # Print something on callback\n",
|
2022-09-28 07:41:02 +00:00
|
|
|
" print(data.shape)\n",
|
2022-10-10 17:29:24 +00:00
|
|
|
"\n",
|
2022-09-28 07:41:02 +00:00
|
|
|
"import time\n",
|
|
|
|
"#time.sleep(4)"
|
2022-09-03 14:07:44 +00:00
|
|
|
]
|
|
|
|
},
|
2022-10-10 17:29:24 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "dc751e51-3d09-41c8-a2dd-02d9568181da",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"# Attach the indata handler to the stream\n",
|
|
|
|
"i = lasp.InDataHandler(mgr, cb, reset_cb)"
|
|
|
|
]
|
|
|
|
},
|
2022-09-03 14:07:44 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "4d9f0103",
|
2022-09-03 14:07:44 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-09-28 07:41:02 +00:00
|
|
|
"mgr.stopStream(lasp.StreamMgr.StreamType.input)"
|
2022-09-03 14:07:44 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2022-09-28 07:41:02 +00:00
|
|
|
"id": "61b7282f",
|
2022-09-03 14:07:44 +00:00
|
|
|
"metadata": {
|
|
|
|
"scrolled": true
|
|
|
|
},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"del i"
|
|
|
|
]
|
2022-10-10 17:29:24 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "99342a4d-16ff-4b0c-8994-4c7e6b3f97b8",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "5bd21b65-5bfd-4f83-b420-8491ca3ade57",
|
|
|
|
"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
|
|
|
|
}
|