lasp/examples/Test input.ipynb

169 lines
3.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "b0d15138",
"metadata": {},
"outputs": [],
"source": [
"!make -j -C ~/wip/mycode/lasp"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1787e24c",
"metadata": {},
"outputs": [],
"source": [
"import lasp\n",
"ds = lasp.DeviceInfo.getDeviceInfo()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "22ae99b1",
"metadata": {},
"outputs": [],
"source": [
"for i, d in enumerate(ds):\n",
" print(f'{i}: ' + d.device_name)\n",
"d = ds[1]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b1321c4a",
"metadata": {},
"outputs": [],
"source": [
"d.availableFramesPerBlock"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "47385b02",
"metadata": {},
"outputs": [],
"source": [
"config = lasp.DaqConfiguration(d)\n",
"config.inchannel_config[0].enabled = True\n",
"config.inchannel_config[1].enabled = True\n",
"config.framesPerBlockIndex = 4"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d12f84b7",
"metadata": {},
"outputs": [],
"source": [
"print('Out channels:',d.noutchannels)\n",
"print('In channels:',d.ninchannels)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "902ce309",
"metadata": {},
"outputs": [],
"source": [
"mgr = lasp.StreamMgr.getInstance()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b209294b",
"metadata": {},
"outputs": [],
"source": [
"mgr.startStream(d, config)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0830ffb5",
"metadata": {},
"outputs": [],
"source": [
"mgr.stopStream(lasp.StreamMgr.StreamType.input)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a7fddc19",
"metadata": {},
"outputs": [],
"source": [
"mgr.stopAllStreams()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d11c7dae",
"metadata": {},
"outputs": [],
"source": [
"def cb(data):\n",
" # raise RuntimeError('hh')\n",
" print(data.shape)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0eeb2311",
"metadata": {},
"outputs": [],
"source": [
"i = lasp.InDataHandler(mgr, cb)\n",
"import time\n",
"#time.sleep(4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f893b639",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"del i"
]
}
],
"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",
"version": "3.10.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}