lasp/examples/test_ppm.ipynb

174 lines
3.4 KiB
Plaintext
Raw Permalink Normal View History

{
"cells": [
{
"cell_type": "markdown",
"id": "740b4091",
"metadata": {},
"source": [
"# Test PPM"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "ac06df04",
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
2022-10-10 17:29:24 +00:00
"#!make -j -C ~/wip/mycode/lasp"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "ce0dd691",
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"import lasp\n",
"# Get handle to stream manager\n",
"mgr = lasp.StreamMgr.getInstance()"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "3cd242a8",
"metadata": {},
"outputs": [],
"source": [
"ds = mgr.getDeviceInfo()"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "a5d878e9",
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"# Search for a device\n",
"for i, d in enumerate(ds):\n",
" print(f'{i}: ' + d.device_name)\n",
"d = ds[0]"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "6d5b281e",
"metadata": {},
"outputs": [],
"source": [
"# Create a configuration and enable some input channels\n",
"config = lasp.DaqConfiguration(d)\n",
"config.inchannel_config[0].enabled = True\n",
"config.inchannel_config[1].enabled = True\n",
"# Choose a different number of frames per block\n",
"config.framesPerBlockIndex = 4"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "1ead3995",
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"print('Out channels:',d.noutchannels)\n",
"print('In channels:',d.ninchannels)"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "12db8306",
"metadata": {
"tags": []
},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"# Start a stream with a configuration\n",
"mgr.startStream(config)"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "5323356f-4239-4f0b-ad58-0025501bf7a3",
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"ppm = lasp.PPMHandler(mgr)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d9f0103",
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"daq = mgr.getDaq(lasp.StreamMgr.StreamType.input)\n",
"print(daq)"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "26277ef0-3389-4581-9cc5-2c500e789dfa",
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
2022-10-10 17:29:24 +00:00
"ppm.start()\n",
"import time\n",
"t=0\n",
"while t < 1:\n",
" time.sleep(0.1)\n",
" t += 0.1\n",
" level, clip = ppm.getCurrentValue()\n",
2022-10-10 17:29:24 +00:00
" print(f'\\r {levels[0]:.1f}')"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"id": "30b77ce0-40ee-4b88-89fa-83b7a62e493c",
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"mgr.stopAllStreams()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "78cc8353-0e0b-4d96-a263-f4ad3fe4ee4c",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}