Skip to content

Commit

Permalink
Merge pull request #3 from HEnquist/develop
Browse files Browse the repository at this point in the history
Add plotting of Filter pipeline steps
  • Loading branch information
HEnquist authored Sep 4, 2020
2 parents e9038e1 + 604f414 commit 4330568
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,48 @@ The complete GUI is made up of two parts:
- a backend based on AIOHTTP: https://docs.aiohttp.org/en/stable/

## Setting up
### Python dependencies
Install the dependencies:
- python 3.6 or later
- numpy
- matplotlib
- websocket-client (required by pycamilladsp)
- numpy (required by pycamilladsp-plot)
- matplotlib (required by pycamilladsp-plot)
- aiohttp


These are the names of the packages needed:
| Distribution | python | websocket-client | numpy | matplotlib | aiohttp |
|--------------|--------|------------------|-------|------------|---------|
| Fedora | python3 | python3-websocket-client | python3-numpy | python3-matplotlib | python3-aiohttp |
| Debian/Raspbian | python3 | python3-websocket | python3-numpy | python3-matplotlib | python3-aiohttp |
| Arch | python | python-websocket-client | python-numpy | python-matplotlib | python-aiohttp |
| pip | - | websocket_client | numpy | matplotlib | aiohttp |
| Anaconda | - | websocket_client | numpy | matplotlib | aiohttp |

#### Linux
Most linux distributions have Python 3.6 or newer installed by default. Use the normal package manager to install the packages.

#### Windows
Use Anaconda: https://www.anaconda.com/products/individual. Then use Anaconda Navigator to install the dependencies.

#### macOS
On macOS use either Anaconda or Homebrew. The Anaconda procedure is the same as for Windows.

For Homebrew, install Python with `brew install python`, after which you can install the needed packages with pip, `pip3 install websocket_client` etc.

### CamillaDSP Python libraries
You also need these two packages:
- pycamilladsp from https://github.com/HEnquist/pycamilladsp
- pycamilladsp-plot from https://github.com/HEnquist/pycamilladsp-plot

Download them both, either by `git clone` or by downloading a zip file of the code. Then unpack the files, go to the folder containing the `setup.py` file and run
```sh
pip install .
```
Note that on some systems the command is `pip3` instead of `pip`.


### Install gui server
Go to "Releases": https://github.com/HEnquist/camillagui-backend/releases
Download the zip-file ("camillagui.zip") for the latest release. This includes both the backend and the frontend.

Expand Down
8 changes: 4 additions & 4 deletions routes.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from camilladsp import plot_pipeline, plot_filter, CamillaError
import yaml
from views import gui, get_param, set_param, eval_filter, eval_pipeline, get_config, set_config, config_to_yml, yml_to_json, validate_config, get_version
from views import get_param, set_param, eval_filter, eval_filterstep, eval_pipeline, get_config, set_config, config_to_yml, yml_to_json, validate_config, get_version, get_gui_index
import pathlib

BASEPATH = pathlib.Path(__file__).parent.absolute()

def setup_routes(app):
#app.router.add_get('/gui/', gui)
app.router.add_get('/api/getparam/{name}', get_param)
app.router.add_post('/api/setparam/{name}', set_param)
app.router.add_post('/api/evalfilter', eval_filter)
app.router.add_post('/api/evalfilterstep', eval_filterstep)
app.router.add_post('/api/evalpipeline', eval_pipeline)
app.router.add_get('/api/getconfig', get_config)
app.router.add_post('/api/setconfig', set_config)
app.router.add_post('/api/configtoyml', config_to_yml)
app.router.add_post('/api/ymltojson', yml_to_json)
app.router.add_post('/api/validateconfig', validate_config)
app.router.add_get('/api/version', get_version)
app.router.add_get('/', get_gui_index)


def setup_static_routes(app):
app.router.add_static('/gui/',
Expand Down
14 changes: 11 additions & 3 deletions views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from aiohttp import web
from camilladsp import plot_pipeline, plot_filter, CamillaError
from camilladsp import CamillaError
from camilladsp_plot import plot_pipeline, plot_filter, plot_filterstep
import yaml

async def gui(request):
return web.Response(text='Hello Aiohttp!')
async def get_gui_index(request):
raise web.HTTPFound('/gui/index.html')

async def get_param(request):
# Get a parameter value
Expand Down Expand Up @@ -63,6 +64,13 @@ async def eval_filter(request):
image=plot_filter(content["config"], name=content["name"], samplerate=content["samplerate"], npoints=1000, toimage=True)
return web.Response(body=image, content_type='image/svg+xml')

async def eval_filterstep(request):
# Plot a filter
content = await request.json()
print("content", content)
image=plot_filterstep(content["config"], content["index"], name="Filterstep {}".format(content["index"]), npoints=1000, toimage=True)
return web.Response(body=image, content_type='image/svg+xml')

async def eval_pipeline(request):
# Plot a pipeline
content = await request.json()
Expand Down

0 comments on commit 4330568

Please sign in to comment.