Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo: structured data over CA #836

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tacaswell
Copy link
Collaborator

I finally did the work to do a proof of principle of what I proposed at the EPICS meeting in Australia in 2018 to get structured data over CA.

This is making use of a bytes channel, but in principle we could go as far as getting a new type(s) for various schemes of encoding.

The three examples:

  • using msgspec to build an IOC that publishes a jsonspec + json as a bytestring. This is good because it gets easy interop with the web world and it should be an easy but the downside that it is going through a text encoding so that is not great for (big) arrays.
  • using msgpack + fancy encoders to get numpy arrays in. This is used to mimic something that looks like a table (e.g. flyscan trajectories + trigger conditions). The underlying structure of the numpy array encoding is dtype (as str), shape, and the array buffer so it should in principle be possible to interpret it in non-Python schemes. An alternate here that may be better (and more accessible to other languages) is to use arrow chunks, but msgpack + numpy is what I was playing with.
  • using protobuf to encode frame number + image. Again it is using a very simple encoding of the exact numpy dtype, shape, and array buffer. There may be better ways to encode imegas (and more cross-language ways!), but this was enough to get it to work. Using protobuf gets us way more cross-language support out of the box (at the cost of having to pre-declare the message models

Currently publishes as json as a bytestring, but could be adapted to use
msgpack (or any of the other formats msgspec supports out of the box)
Uses some fancy encoding/decoding hooks to directly support numpy arrays
@tacaswell
Copy link
Collaborator Author

An obvious improvement is to call the encoding channel "mimetype" and make the values the correct mimetypes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant