https://github.com/slaclab/pycaserver
Python-based Channel Access Websockets Server
https://github.com/slaclab/pycaserver
bottle epics python websockets
Last synced: 5 months ago
JSON representation
Python-based Channel Access Websockets Server
- Host: GitHub
- URL: https://github.com/slaclab/pycaserver
- Owner: slaclab
- License: mit
- Created: 2016-05-13T16:01:23.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-19T21:03:22.000Z (over 9 years ago)
- Last Synced: 2025-04-14T15:45:29.197Z (11 months ago)
- Topics: bottle, epics, python, websockets
- Language: Python
- Size: 47.9 KB
- Stars: 4
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pycaserver
A Python-based Channel Access WebSockets Server
This is a tiny web server for getting channel access data via a WebSockets connection. Useful if you want to make a website that displays a real-time updating value of some PVs. Built with Bottle, PyEpics, and Geventwebsockets.
### How to use
First, establish a WebSockets connection to the server's '/monitor' URL.
```javascript
var ws = new WebSocket("ws://localhost:8888/monitor");
```
Send messages to the server to connect to PVs:
```javascript
socket.send({"action":"connect", "pv":"myPVName"});
```
Sit back and wait for messages to roll in. The messages are JSON dictionaries with this format:
```javascript
{ "msg_type": "monitor", "pvname": pvname, "value": value, "count": count, "timestamp": timestamp }
```
If you want to stop listening to a PV, send the server a disconnect message:
```javascript
socket.send({"action":"disconnect", "pv":"myPVName"});
```
That is pretty much it. For more details, see the [wiki](https://github.com/slaclab/pycaserver/wiki). Have fun!